Background Service Architecture
Relevant source files
The following files were used as context for generating this wiki page:
- app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/ScannerService.kt
- app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt
- app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/SensorCollectionService.kt
- app/src/main/AndroidManifest.xml
- app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/ui/screens/HomeScreen.kt
- app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/ui/screens/SettingsScreen.kt
ShadowCheck Mobile utilizes a robust background service architecture to facilitate real-time signals intelligence (SIGINT) collection. The system is designed to perform continuous scanning of wireless environments—including WiFi, Bluetooth (Classic and LE), and cellular networks—while simultaneously logging high-frequency sensor data and device hardware metadata.
The architecture relies on Android Foreground Services to ensure persistent operation and bypass system-level power management restrictions. This allows the application to maintain a constant state of situational awareness, updating local databases and user notifications even when the application is not in the foreground.
Core Service Components
The background architecture is composed of specialized services that handle different aspects of data acquisition. These services are declared as foreground services with specific types, such as location, to satisfy Android's security and performance requirements.
Sources: app/src/main/AndroidManifest.xml:51-51, app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt:20-30
CompleteScannerService
The primary orchestrator for network intelligence collection. It integrates location tracking with wireless radio scanning to provide georeferenced signal data.
- Responsibilities: Coordinates WiFi, Bluetooth, and Cellular scanning; manages the Room database connection; updates system notifications with real-time discovery counts.
- Location Integration: Requests updates from both
GPS_PROVIDERandNETWORK_PROVIDERto maintain a high-accuracy location context for every discovered signal.
Sources: app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt:143-155, app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt:216-225
SensorCollectionService
A specialized utility class managed by the scanner services to capture environmental and inertial data.
- Sensors Monitored: Accelerometer, Gyroscope, Magnetometer, Light, Pressure, Temperature, Proximity, and more.
- Hardware Profiling: Captures detailed device specifications, including manufacturer, SOC model, and supported ABIs, to establish a hardware baseline.
Sources: app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/SensorCollectionService.kt:39-60, app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/SensorCollectionService.kt:105-130
Data Discovery and Deduplication Flow
The system employs a rigorous deduplication logic to prevent database bloat. Signals are processed only if they are new or if a specific time threshold (30 seconds) has passed since the last sighting.
Flow of discovery from hardware triggers to database persistence.
Sources: app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt:45-55, app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt:157-167
Implementation Details
Signal Capture Logic
The background services utilize specialized BroadcastReceivers and Callbacks to handle asynchronous hardware events.
| Component | Mechanism | Key Data Points Captured |
|---|---|---|
| WiFi | WifiManager.SCAN_RESULTS_AVAILABLE_ACTION | BSSID, SSID, Frequency, Capabilities, Channel Width |
| Bluetooth LE | ScanCallback.onScanResult | MAC Address, Device Name, RSSI, TX Power, Service UUIDs |
| Cellular | TelephonyManager.allCellInfo | Cell ID, LAC/TAC, MCC, MNC, Signal Level, Network Type |
| Sensors | SensorEventListener.onSensorChanged | X/Y/Z Values, Accuracy, Sensor Type |
Sources: app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt:41-80, app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt:173-205, app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/SensorCollectionService.kt:80-100
Lifecycle Management
Services are controlled via specific Intent actions. The lifecycle is strictly managed to ensure hardware resources (like GPS and Bluetooth) are released when scanning stops.
Sequence of service initialization and data loop.
Sources: app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/ui/screens/HomeScreen.kt:130-136, app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt:135-141, app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt:207-214
System Configuration
The background behavior is configurable through encrypted shared preferences, allowing users to balance detection granularity with battery consumption.
| Setting | Default Value | Description |
|---|---|---|
scan_interval | 3 seconds | Time delay between scan iterations in the background loop. |
auto_scan | True | Boolean determining if services start on app launch. |
map_provider | Mapbox | Determines which API is used for coordinate visualization. |
Sources: app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/ui/screens/SettingsScreen.kt:41-43, app/src/main/kotlin/com/shadowcheck/mobile/ui/screens/settings/SettingsScreen.kt:25-30
Conclusion
The Background Service Architecture of ShadowCheck Mobile represents a sophisticated implementation of Android's foreground service model. By decoupling signal discovery (WiFi/BT/Cell) from the UI layer and centralizing data persistence through a deduplicating scanner service, the application achieves high-fidelity surveillance detection without sacrificing system stability. The integration of sensor logging and hardware profiling further enriches the collected intelligence, providing a comprehensive audit trail of the device's environment.