Skip to content

feat(settings): add toggle for sync device location and harden background feeder - #478

Closed
full-bars wants to merge 2 commits into
urnetwork:mainfrom
full-bars:fix/settings-mock-location-toggle
Closed

feat(settings): add toggle for sync device location and harden background feeder#478
full-bars wants to merge 2 commits into
urnetwork:mainfrom
full-bars:fix/settings-mock-location-toggle

Conversation

@full-bars

@full-bars full-bars commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Overview

In SettingsScreen.kt, the "Device location sync" row lacked a toggle switch and visually mismatched the surrounding rows (Allow providing on cellular network, Kill switch, Receive connection notifications).

This PR adds the switch aligned with adjacent setting toggles, implements intelligent setup routing and dynamic status feedback, and decouples the mock location SDK feeder from the UI lifecycle to ensure robust, background-safe location synchronization.

Tip

Toggling the switch ON when setup is incomplete (e.g., Developer options not enabled or mock location app not selected) automatically navigates to Route.MockLocationGuide. Once setup is complete, the toggle directly controls location simulation without requiring navigation.

Important

Test providers are never automatically removed by Android on process death or app exit. The SDK event listener has been moved to a process-scoped singleton (MockLocationFeeder) started in MainApplication.onCreate(), ensuring test providers are disarmed and cleanly unregistered immediately when the tunnel drops, even if the user is outside the Settings UI.


Logical Impact & Changes

Features & UI Alignment

  • Settings Screen Alignment (SettingsScreen.kt):
    • Added URSwitch to the "Device location sync" row, perfectly matching the vertical alignment, sizing, and spacing of "Kill switch" and "Cellular network".
    • Preserved tap navigation on the label and chevron to Route.MockLocationGuide.
    • Added contextual status subtitle below the row when enabled or orphaned (e.g., Syncing with <City>, Setup required, Waiting for provider location, or cleanup errors).
  • Mock Location Guide (MockLocationGuideScreen.kt):
    • Added an inline URSwitch in the "Ready" state banner once all three system setup prerequisites are satisfied.
    • Dynamically updates banner text to reflect active syncing status (Syncing with <City>) or waiting state.

Stability & Hardening

  • Background Feeder Decoupling (MockLocationFeeder.kt):
    • Replaced the short-lived Jetpack ViewModel event subscription with a dedicated @Singleton MockLocationFeeder started in MainApplication.onCreate().
    • Subscribes to DeviceLocal.addConnectChangeListener to guarantee that when the VPN tunnel disconnects, MockLocationController.onTunnelChanged(false) is dispatched immediately to disarm providers and restore real device GPS.
    • Subscribes to DeviceLocal.addConnectedProviderLocationChangeListener to push exit provider coordinate changes across the entire app lifecycle without requiring the UI to remain open.
  • Leak & Lifecycle Prevention (MockLocationViewModel.kt):
    • Converted MockLocationViewModel into a clean UI bridge exposing controller state and UI actions without dangling SDK subscriptions.
  • Orphaned State Recovery:
    • Toggling or tapping the row when in MockLocationStatus.ORPHANED routes directly to MockLocationGuideScreen to display recovery steps for revoked app ops.

What's Changed

Full Changelog

main...full-bars:android:fix/settings-mock-location-toggle

@full-bars

Copy link
Copy Markdown
Contributor Author

Closed: Opened upstream prematurely; moving to full-bars/android fork PR.

@full-bars full-bars closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant