Context
In the initial multiplatform LocationSource implementation (#1817) and the maps-compose-multiplatform-demo integration (googlemaps/android-maps-compose#1038), iOS callers can create a LocationSource with a single call (manager.asLocationSource()), whereas Android callers currently need extra wrapper logic around LocationManager to handle cached fixes, indoor fallback, and Android 12+ coarse-only permissions.
Proposed Enhancements
-
Built-in Cached Fix & Coarse Fallback in LocationManager.asLocationSource() (androidMain):
- Emit the freshest cached location across
GPS_PROVIDER, NETWORK_PROVIDER, and PASSIVE_PROVIDER (each wrapped in try / catch (_: SecurityException)) when collection begins, matching CLLocationManager.startUpdatingLocation() on iOS.
- For
LocationPriority.HIGH_ACCURACY, merge fineLocationEvents (GPS_PROVIDER) and coarseLocationEvents (NETWORK_PROVIDER). Because fineLocationEvents catches SecurityException and closes cleanly when only ACCESS_COARSE_LOCATION ("Approximate" location on Android 12+) is granted, merging the two allows LocationManager.asLocationSource() to:
- Automatically degrade to
NETWORK_PROVIDER when the user grants "Approximate" location instead of "Precise".
- Deliver indoor network fixes while waiting for a GPS satellite lock.
- Close cleanly if neither fine nor coarse permission is granted.
- This reduces Android
LocationSource creation in consumer apps to a single line (manager.asLocationSource()), matching iOS.
-
Automatic Authorization Prompt on kCLAuthorizationStatusNotDetermined in CLLocationManager.locationEvents() (iosMain):
- When
authorizationStatus == kCLAuthorizationStatusNotDetermined, invoke requestWhenInUseAuthorization() before startUpdatingLocation() so collecting the flow on iOS triggers the system permission prompt and begins emitting as soon as the user grants permission.
-
Shared Compose Permission Helper (maps-compose-multiplatform):
- Provide a reusable
@Composable permission/location helper using LifecycleEventEffect(Lifecycle.Event.ON_RESUME) and ActivityResultContracts.RequestMultiplePermissions on Android alongside CLLocationManagerDelegateProtocol.locationManagerDidChangeAuthorization on iOS.
Context
In the initial multiplatform
LocationSourceimplementation (#1817) and themaps-compose-multiplatform-demointegration (googlemaps/android-maps-compose#1038), iOS callers can create aLocationSourcewith a single call (manager.asLocationSource()), whereas Android callers currently need extra wrapper logic aroundLocationManagerto handle cached fixes, indoor fallback, and Android 12+ coarse-only permissions.Proposed Enhancements
Built-in Cached Fix & Coarse Fallback in
LocationManager.asLocationSource()(androidMain):GPS_PROVIDER,NETWORK_PROVIDER, andPASSIVE_PROVIDER(each wrapped intry / catch (_: SecurityException)) when collection begins, matchingCLLocationManager.startUpdatingLocation()on iOS.LocationPriority.HIGH_ACCURACY, mergefineLocationEvents(GPS_PROVIDER) andcoarseLocationEvents(NETWORK_PROVIDER). BecausefineLocationEventscatchesSecurityExceptionand closes cleanly when onlyACCESS_COARSE_LOCATION("Approximate" location on Android 12+) is granted, merging the two allowsLocationManager.asLocationSource()to:NETWORK_PROVIDERwhen the user grants "Approximate" location instead of "Precise".LocationSourcecreation in consumer apps to a single line (manager.asLocationSource()), matching iOS.Automatic Authorization Prompt on
kCLAuthorizationStatusNotDeterminedinCLLocationManager.locationEvents()(iosMain):authorizationStatus == kCLAuthorizationStatusNotDetermined, invokerequestWhenInUseAuthorization()beforestartUpdatingLocation()so collecting the flow on iOS triggers the system permission prompt and begins emitting as soon as the user grants permission.Shared Compose Permission Helper (
maps-compose-multiplatform):@Composablepermission/location helper usingLifecycleEventEffect(Lifecycle.Event.ON_RESUME)andActivityResultContracts.RequestMultiplePermissionson Android alongsideCLLocationManagerDelegateProtocol.locationManagerDidChangeAuthorizationon iOS.