Wardriving on Android (Wi-Fi and cell logging with GPS)
androidwifiwardrivinggpsforeground-servicewiglelocationflutter
Wardriving means logging the Wi-Fi access points and cell towers a phone sees along with where it saw them. Spectre (~/dev/spectre, Flutter with native Kotlin) gained a Drive tab for this in v0.6.0. The design choices below make recording robust and the data honest.
Recording architecture
- A native location-type foreground service with a partial wake lock and a Stop action in its notification is the only writer of an append-only JSONL log per session (
files/drive/<id>.log). The Flutter side only tails and replays the log, so recording never depends on the Flutter engine being alive. - Sessions survive force-stop (offered for resume next launch), swiping the task away, and screen-off. Verified: 5 minutes backgrounded with the screen off logged 309 fixes and a scan every 30 s.
- Use
LocationManagerGPS directly; no Play Services needed.
Placing sightings
- Join each scan result to the track by the scan result's own boot-clock timestamp, not by when your code received it. Drop a sighting if no fix is within 3 s or the fix is worse than 30 m.
- Draw networks as uncertainty areas (radius from sighting spread, the radio range implied by the best RSSI, and GPS accuracy), never as exact pins: a single sighting does not locate an AP.
Platform limits
- Android throttles Wi-Fi scans for foreground apps to 4 per 2 minutes.
settings put global wifi_scan_throttle_enabled 0does not disable it on API 35; only the Developer options toggle does. Tell the user. NEARBY_WIFI_DEVICESwithneverForLocationforbids deriving location from scans; a wardriving app must drop that flag and hold location permission.- Emulator GPS reports speed 0 while a route plays; compute speed from distance over time.
Ethics line (set without asking, open to Justin's overrule)
- Log Wi-Fi APs and cell towers only; never Bluetooth with location (Bluetooth devices are people, APs are infrastructure).
- Passive only; skip SSIDs ending in
_nomapor_optout(the opt-out convention); upload nothing.
Export formats
- WiGLE CSV (exact header, 14 columns per row), KML, GPX via
ACTION_CREATE_DOCUMENT(save) and a FileProvider share. - Map tiles: OpenStreetMap tiles require following the tile usage policy (identifying User-Agent, caching, attribution, no bulk prefetch); keep an offline grid fallback.
See also
- Doze, WorkManager backoff, and background sync that stalls
- Flutter and Dart gotchas (collections, widgets, theming)