Android Native Background Client for the Guardian Parental Control System
Runs stealthily and resiliently in the background, providing real-time device monitoring, instant GPS tracking, notification interception, app usage telemetry, and anti-tamper protections.
Important
Interdependency Requirement: This client requires a running instance of Guardian Admin Server to receive telemetry data, relay real-time push commands, and authenticate requests.
Guardian Mobile Client is the device-side component of the Guardian ecosystem. Designed for concerned parents, it operates silently on the child's device to safeguard their digital activities.
Unlike conventional tracker apps that are easily killed by OEM battery savers (Xiaomi HyperOS, Samsung OneUI, Oppo ColorOS), Guardian utilizes a multi-layered watchdog architecture combining ForegroundService, AccessibilityService, and NotificationListenerService to guarantee persistent operation and immediate responsiveness to remote commands.
- Fresh GPS Acquisition: Executes
getCurrentLocation()withPRIORITY_HIGH_ACCURACYupon remote request, guaranteeing current coordinates instead of stale cached data. - Smart Movement Filter: Implements
setMinUpdateDistanceMeters(50f)— avoids waking up the cellular/GPS radios when the device is completely stationary. - Emergency Fallback: Gracefully falls back to
lastLocationif fresh satellite fixes are momentarily obscured.
- Inbox Logging: Intercepts notifications from WhatsApp, Telegram, SMS, Gmail, and other apps via
NotificationListenerServiceand pushes them straight to the server. - System Overlay Cleanup: Automatically detects and dismisses intrusive Android system alert banners like "Guardian is displaying over other apps".
- App Inventory: Gathers full package lists, app names, icons, and versions.
- Daily Screen Time: Tracks precise usage intervals via
UsageStatsManager. - Side-Loaded APK Gatekeeper: Detects when new APK packages are installed outside Google Play Store (
ACTION_PACKAGE_ADDED) and queries the parent server for real-time approval.
- 0% Idle CPU App Blocking: Replaced high-drain polling with event-driven window state transitions via
AccessibilityService(TYPE_WINDOW_STATE_CHANGED). - Anti-Uninstall Shield: Monitors system settings, Package Installer, and dialog windows; intercepts attempts to clear data, uninstall Guardian, or revoke Device Admin by redirecting back to the Home screen.
- Stealth Mode: Ability to hide or show launcher app icons on remote command.
- Lock Screen & Remote Popup: Displays full-screen lockouts with parental password unlock or simple alert dialogs.
- Supports granular WebSocket ping commands (
all,location,battery,apps,usage,permissions) via Socket.IO. - Bypasses background scheduler queues and executes immediate I/O coroutines to update the parent dashboard in under 2 seconds.
- Exponential Backoff: Socket.IO client reconnects with dynamic jitter (
reconnectionDelayMax = 30s), saving battery when offline or sleeping. - DataStore Singleton: Shared
appDataStorepreventing process deadlocks and duplicate instance crashes.
Guardian-Mobile-Client
├── app/src/main/java/id/irnhakim/guardian/
│ ├── core/
│ │ ├── receivers/ # BootReceiver, DeviceAdmin, AppInstallReceiver
│ │ ├── services/ # LocationForegroundService, NotificationListener, Accessibility
│ │ ├── utils/ # Permission utilities, helpers
│ │ └── workers/ # Periodic sync background WorkManager tasks
│ ├── data/
│ │ ├── local/ # DataStore Preferences (GuardianPreferences)
│ │ └── remote/ # Retrofit API interface, DTOs
│ ├── di/ # Dagger Hilt Application Module
│ ├── ui/ # Jetpack Compose UI (Setup, MainActivity, Lock Overlay)
│ └── GuardianApp.kt # Application entrypoint with Hilt & singleton DataStore
- Language: Kotlin 2.0+
- UI: Jetpack Compose with Material 3
- Dependency Injection: Dagger Hilt 2.51+
- Networking: Retrofit 2, OkHttp 4, Socket.IO Client Java (v2.1.0)
- Storage: Jetpack Preferences DataStore
- Background Processing: AndroidX WorkManager, Coroutines & Flow
- Hardware API: Google Play Services Location (Fused Location Provider)
- Android 9.0 (API level 28) or higher.
- Google Play Services installed.
- Location (Allow all the time): Required for continuous background GPS tracking.
- Notification Access: Required for
NotificationListenerServiceto capture messages. - Accessibility Service: Required for anti-uninstall protection and zero-battery app blocking.
- Usage Access: Required to calculate daily screen time and monitor app launches.
- Display Over Other Apps: Required for the remote lock screen and app block overlay.
- Device Administrator: Prevents simple uninstallation through settings.
git clone https://github.com/Irnhakim/Guardian-Mobile-Client.git
cd Guardian-Mobile-ClientOpen app/src/main/java/id/irnhakim/guardian/di/AppModule.kt (or configure via the app onboarding UI):
// Default fallback URL if not configured via QR / manual input
BuildConfig.API_BASE_URL // e.g. "http://192.168.1.50:3001/api/v1"You can compile via Gradle CLI or Android Studio:
# Using Gradle Wrapper
./gradlew assembleDebugThe output APK will be generated at:
app/build/outputs/apk/debug/app-debug.apk
adb install -r app/build/outputs/apk/debug/app-debug.apkFor devices with aggressive process killers (e.g. Xiaomi / Redmi / Poco):
- Autostart:
Settings→Apps→Guardian→ enable Autostart. - Battery Saver: Set
Battery Saverto No restrictions. - Recent Apps: Open recent apps, long-press Guardian, and tap the Padlock icon to lock it in memory.
- Enable Accessibility Service and Notification Access for Guardian.
This project is licensed under the MIT License — see the LICENSE file for details.
