Loading play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/FakeLocationResolver.kt +5 −5 Original line number Diff line number Diff line Loading @@ -15,15 +15,15 @@ object FakeLocationResolver { private data class FakeLocation(var latitude: Double, var longitude: Double) fun fakeLocations( fun fakeLocation( context: Context, identity: ClientIdentity, baseLocations: List<Location> ): List<Location> { baseLocation: Location ): Location { val latLon = getFakeLocation(context, identity.packageName, identity.uid) ?: return baseLocations ?: return baseLocation return baseLocations.map { overrideLatLon(it, latLon) } return overrideLatLon(baseLocation, latLon) } private fun getFakeLocation(context: Context, packageName: String, uid: Int): FakeLocation? { Loading play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManager.kt +6 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ class LocationManager(private val context: Context, override val lifecycle: Life val permissionGranularity = context.granularityFromPermission(clientIdentity) var effectiveGranularity = getEffectiveGranularity(request.granularity, permissionGranularity) if (effectiveGranularity == GRANULARITY_FINE && database.getForceCoarse(clientIdentity.packageName) && !clientIdentity.isSelfUser()) effectiveGranularity = GRANULARITY_COARSE val returnedLocation = if (effectiveGranularity > permissionGranularity) { val baseLocation = if (effectiveGranularity > permissionGranularity) { // No last location available at requested granularity due to lack of permission null } else { Loading @@ -99,6 +99,11 @@ class LocationManager(private val context: Context, override val lifecycle: Life processedLocation } } val returnedLocation = baseLocation?.let { FakeLocationResolver.fakeLocation(context, clientIdentity, it) } if (!clientIdentity.isSelfUser()) database.noteAppLocation(clientIdentity.packageName, returnedLocation) return returnedLocation?.let { Location(it).apply { provider = "fused" } } } Loading play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationRequestManager.kt +3 −3 Original line number Diff line number Diff line Loading @@ -476,9 +476,9 @@ class LocationRequestManager(private val context: Context, override val lifecycl } } val result = LocationResult.create(FakeLocationResolver.fakeLocations( context, clientIdentity, listOf(returnedLocation) )) val result = LocationResult.create(listOf(FakeLocationResolver.fakeLocation( context, clientIdentity, returnedLocation ))) callback?.onLocationResult(result) pendingIntent?.send(context, 0, Intent().apply { putExtra(LocationResult.EXTRA_LOCATION_RESULT, result) }) Loading Loading
play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/FakeLocationResolver.kt +5 −5 Original line number Diff line number Diff line Loading @@ -15,15 +15,15 @@ object FakeLocationResolver { private data class FakeLocation(var latitude: Double, var longitude: Double) fun fakeLocations( fun fakeLocation( context: Context, identity: ClientIdentity, baseLocations: List<Location> ): List<Location> { baseLocation: Location ): Location { val latLon = getFakeLocation(context, identity.packageName, identity.uid) ?: return baseLocations ?: return baseLocation return baseLocations.map { overrideLatLon(it, latLon) } return overrideLatLon(baseLocation, latLon) } private fun getFakeLocation(context: Context, packageName: String, uid: Int): FakeLocation? { Loading
play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManager.kt +6 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ class LocationManager(private val context: Context, override val lifecycle: Life val permissionGranularity = context.granularityFromPermission(clientIdentity) var effectiveGranularity = getEffectiveGranularity(request.granularity, permissionGranularity) if (effectiveGranularity == GRANULARITY_FINE && database.getForceCoarse(clientIdentity.packageName) && !clientIdentity.isSelfUser()) effectiveGranularity = GRANULARITY_COARSE val returnedLocation = if (effectiveGranularity > permissionGranularity) { val baseLocation = if (effectiveGranularity > permissionGranularity) { // No last location available at requested granularity due to lack of permission null } else { Loading @@ -99,6 +99,11 @@ class LocationManager(private val context: Context, override val lifecycle: Life processedLocation } } val returnedLocation = baseLocation?.let { FakeLocationResolver.fakeLocation(context, clientIdentity, it) } if (!clientIdentity.isSelfUser()) database.noteAppLocation(clientIdentity.packageName, returnedLocation) return returnedLocation?.let { Location(it).apply { provider = "fused" } } } Loading
play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationRequestManager.kt +3 −3 Original line number Diff line number Diff line Loading @@ -476,9 +476,9 @@ class LocationRequestManager(private val context: Context, override val lifecycl } } val result = LocationResult.create(FakeLocationResolver.fakeLocations( context, clientIdentity, listOf(returnedLocation) )) val result = LocationResult.create(listOf(FakeLocationResolver.fakeLocation( context, clientIdentity, returnedLocation ))) callback?.onLocationResult(result) pendingIntent?.send(context, 0, Intent().apply { putExtra(LocationResult.EXTRA_LOCATION_RESULT, result) }) Loading