How globalpolicy/phonemonitor works
Project type and purpose
• This is a full-stack remote administration tool.
• Android client (PhoneMonitor app) that runs in the background, monitors calls/SMS/files/camera, and uploads data to a server.
• Web panel (PHP scripts) for administrators to view logs, send commands, and manage users.
• MySQL database (“phonemonitor”) to store device data, user accounts, and command queues.
File structure
• Top-level folders:
• AndroidStudioProject/PhoneMonitor – native Android app project (Gradle build, Java source, resources, manifests, tests, libs).
• Webpanel – collection of PHP endpoints (authenticate.php, getcommands.php, setcommands.php, helperfuncs.php, etc.) and UI pages.
• LICENSE, README.md – documentation and license.
• Key patterns:
• Android: BroadcastReceivers (Alarm, CallState, SMS, NetworkChange, OnBootCompleted) trigger actions in MainService or directly start tasks.
• Background service pattern: MainService + ServerTalkLoopThread handles periodic polling and data upload.
• Web panel: procedural PHP pages act as REST‐style endpoints; helperfuncs.php centralizes DB helper routines.
• Database integration: PHP scripts connect to MySQL with credentials in helperfuncs.php.
Extract README insights
• Android minimum API 15, target API 21.
• Setup involves replacing placeholders in AppSettings.java, building signed APK, installing on device.
• Web setup involves editing helperfuncs.php DB credentials, uploading PHP files, creating MySQL “phonemonitor” database, approving a user account.
a. Main components
• Android Device
• Android App:
– UI Layer: MainActivity (app settings, manual triggers)
– Background Layer: MainService, BroadcastReceivers, HelperMethods, RepeatTask
– Network Layer: FileUploader, ServerTalkLoopThread, WebCommandsExecutor, SMSExecutor
• Server:
– Web Server (Apache/Nginx + PHP runtime) hosting Webpanel directory with endpoints
– PHP helper library: helperfuncs.php
• Data Store: MySQL database “phonemonitor” (tables: users, calls, sms, photos, commands, settings)
• Administrator’s Browser (Web UI for clientlist, displaycalllogs, setcommands, etc.)
b. Relationships and data flows
1. Device events (call received, SMS, boot, network change, alarm) → BroadcastReceiver → MainService or task executor
2. Data capture (camera image, call log, SMS content) → HelperMethods → FileUploader → HTTP POST to server endpoint (e.g., setoutput.php)
3. Periodic polling: ServerTalkLoopThread → HTTP GET getcommands.php → WebCommandsExecutor or SMSExecutor executes remote commands
4. Web UI (admin) interacts via browser → PHP scripts (clientlist.php, displayphotos.php, setcommands.php) → helperfuncs.php → MySQL queries
c. Architectural patterns/design principles
• Client-server architecture with REST-style PHP endpoints
• Observer pattern in Android (BroadcastReceivers)
• Service pattern for long-running background processes
• Separation of concerns: capture → upload → server processing → storage → admin UI
d. Key technologies/frameworks
• Android SDK (Java), Gradle, commons-net library
• PHP 7+, Apache/Nginx
• MySQL
• HTML/CSS for web panel UI