Skip to content

Commit

Permalink
location service: fix implementation of getCurrentLocation()
Browse files Browse the repository at this point in the history
Client code expects Status.SUCCESS even when the result is null.
  • Loading branch information
muhomorr authored and thestinger committed Jan 20, 2025
1 parent 266bdb9 commit 96da060
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/app/grapheneos/gmscompat/location/GLocationService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -216,23 +216,20 @@ class GLocationService(val ctx: Context) : IGoogleLocationManagerService.Stub()
val provider = OsLocationProvider.get(client, request.priority, request.granularity)

val consumer = Consumer<Location> { origLocation ->
// location.elapsedRealtimeAgeMillis <= request.maxUpdateAgeMillis
// check is not needed, maxUpdateAgeMillis applies only to historical locations
// which are never returned by OsLocationProvider
if (origLocation != null) {
val location: Location = provider.maybeFudge(origLocation)

try {
callback.onResult(Status.SUCCESS, location)
} catch (e: RemoteException) {
logd{e}
}
// (location.elapsedRealtimeAgeMillis <= request.maxUpdateAgeMillis) check is not needed,
// maxUpdateAgeMillis applies only to historical locations which are never returned
// by OsLocationProvider

val result: Location? = if (origLocation != null) {
provider.maybeFudge(origLocation)
} else {
try {
callback.onResult(Status(CommonStatusCodes.TIMEOUT), null)
} catch (e: RemoteException) {
logd{e}
}
null
}
try {
// client code expects Status.SUCCESS even when the result is null
callback.onResult(Status.SUCCESS, result)
} catch (e: RemoteException) {
logd{e}
}
}

Expand Down

0 comments on commit 96da060

Please sign in to comment.