diff --git a/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManager.kt b/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManager.kt index 2e7af73869..a652e861d8 100644 --- a/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManager.kt +++ b/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManager.kt @@ -210,6 +210,8 @@ class LocationManager(private val context: Context, private val lifecycle: Lifec } } catch (e: SecurityException) { // Ignore + } catch (e: Exception) { + // Ignore } } diff --git a/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManagerInstance.kt b/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManagerInstance.kt index f9d8a08b5f..b2bbaa1794 100644 --- a/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManagerInstance.kt +++ b/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManagerInstance.kt @@ -29,6 +29,7 @@ import com.google.android.gms.location.internal.* import com.google.android.gms.location.internal.DeviceOrientationRequestUpdateData.REMOVE_UPDATES import com.google.android.gms.location.internal.DeviceOrientationRequestUpdateData.REQUEST_UPDATES import org.microg.gms.common.NonCancelToken +import org.microg.gms.location.hasNetworkLocationServiceBuiltIn import org.microg.gms.utils.warnOnTransactionIssues class LocationManagerInstance( @@ -158,7 +159,7 @@ class LocationManagerInstance( lifecycleScope.launchWhenStarted { val locationManager = context.getSystemService() val gpsPresent = locationManager?.allProviders?.contains(GPS_PROVIDER) == true - val networkPresent = locationManager?.allProviders?.contains(NETWORK_PROVIDER) == true + val networkPresent = locationManager?.allProviders?.contains(NETWORK_PROVIDER) == true || context.hasNetworkLocationServiceBuiltIn() val gpsUsable = gpsPresent && locationManager?.isProviderEnabled(GPS_PROVIDER) == true && context.packageManager.checkPermission(ACCESS_FINE_LOCATION, clientIdentity.packageName) == PERMISSION_GRANTED val networkUsable = networkPresent && locationManager?.isProviderEnabled(NETWORK_PROVIDER) == true && diff --git a/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationRequestManager.kt b/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationRequestManager.kt index 39dcc603b9..2354bd4413 100644 --- a/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationRequestManager.kt +++ b/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationRequestManager.kt @@ -364,7 +364,7 @@ class LocationRequestManager(private val context: Context, private val lifecycle return request.priority } val maxUpdateDelayMillis: Long - get() = max(request.maxUpdateDelayMillis, intervalMillis) + get() = max(max(request.maxUpdateDelayMillis, intervalMillis), 1000L) val intervalMillis: Long get() = request.intervalMillis val updatesPending: Int @@ -415,6 +415,7 @@ class LocationRequestManager(private val context: Context, private val lifecycle fun check() { if (!context.checkAppOpForEffectiveGranularity(clientIdentity, effectiveGranularity)) throw RuntimeException("Lack of permission") + if (effectiveGranularity > permissionGranularity) throw RuntimeException("Lack of permission") if (timePendingMillis < 0) throw RuntimeException("duration limit reached (active for ${(SystemClock.elapsedRealtime() - start).formatDuration()}, duration ${request.durationMillis.formatDuration()})") if (updatesPending <= 0) throw RuntimeException("max updates reached") if (callback?.asBinder()?.isBinderAlive == false) throw RuntimeException("Binder died") @@ -426,7 +427,7 @@ class LocationRequestManager(private val context: Context, private val lifecycle if (lastLocation != null && location.distanceTo(lastLocation!!) < request.minUpdateDistanceMeters) return false if (lastLocation == location) return false val returnedLocation = if (effectiveGranularity > permissionGranularity) { - throw RuntimeException("lack of permission") + throw RuntimeException("Lack of permission") } else { if (!context.noteAppOpForEffectiveGranularity(clientIdentity, effectiveGranularity)) { throw RuntimeException("app op denied")