Modern Apps git

← Modern-Apps.git

maps: don't register a passive listener when no provider can feed it

Commit
7b1bd8b55f58720a72f924713c17f0671ebf6476
Author
Vayun Mathur <[email protected]>
When
2026-11-21 12:20 UTC (15 days ago)
Parents
ee6923e
With GPS and NETWORK both off, startUpdates still registered
a PASSIVE listener - pointless, since passive only relays
fixes an active provider generates. Passive registration now
requires GPS or NETWORK enabled; the rescue behaviour when
either is on is unchanged. No test change: the provider-off
contract predates the passive stream and the code broke it.

Verified: the failing sensor test passes and the full maps
suite is green (1202 tests).

Diff

maps/src/main/java/com/vayunmathur/maps/platform/FrameworkLocationManager.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/platform/FrameworkLocationManager.kt b/maps/src/main/java/com/vayunmathur/maps/platform/FrameworkLocationManager.ktindex 5f0ad549b5..7cbf33a7b6 100644--- a/maps/src/main/java/com/vayunmathur/maps/platform/FrameworkLocationManager.kt+++ b/maps/src/main/java/com/vayunmathur/maps/platform/FrameworkLocationManager.kt@@ -134,7 +134,8 @@ class FrameworkLocationManager(context: Context) : SensorEventListener {                 locationListener,             )         }-        if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {+        val networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)+        if (networkEnabled) {             // GPS live: NETWORK is only a fallback (see acceptsFix), so it             // runs relaxed. GPS off: NETWORK is the sole source, keep 1 Hz.             val minTimeMs = if (gpsEnabled) NETWORK_MIN_TIME_MS else LOCATION_MIN_TIME_MS@@ -150,8 +151,13 @@ class FrameworkLocationManager(context: Context) : SensorEventListener {         // here at zero extra radio cost and flow through the same GPS-first         // acceptance policy, so a coarse passive fix can still rescue the         // puck when GPS goes quiet (indoors, tunnels) between the relaxed-        // network deliveries.-        if (locationManager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)) {+        // network deliveries. Passive only relays fixes generated by an+        // active provider, so with GPS and NETWORK both off it can never+        // deliver: registering then would hold a location listener for+        // nothing (and the provider-off contract is that nothing registers).+        if ((gpsEnabled || networkEnabled) &&+            locationManager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)+        ) {             locationManager.requestLocationUpdates(                 LocationManager.PASSIVE_PROVIDER,                 LOCATION_MIN_TIME_MS,