diff --git a/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/NetworkLocationService.kt b/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/NetworkLocationService.kt index 9744ba2aad..cc19b0044e 100644 --- a/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/NetworkLocationService.kt +++ b/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/NetworkLocationService.kt @@ -57,7 +57,7 @@ class NetworkLocationService : LifecycleService(), WifiDetailsCallback, CellDeta private val cache by lazy { LocationCacheDatabase(this) } private val movingWifiHelper by lazy { MovingWifiHelper(this) } private val settings by lazy { LocationSettings(this) } - private val wifiScanCache = LruCache(100) + private val wifiScanCache = LruCache(100) private var lastHighPowerScanRealtime = 0L private var lastLowPowerScanRealtime = 0L @@ -98,6 +98,8 @@ class NetworkLocationService : LifecycleService(), WifiDetailsCallback, CellDeta ) } } catch (e: SecurityException) { + Log.d(TAG, "GPS location retriever not initialized due to lack of permission") + } catch (e: Exception) { Log.d(TAG, "GPS location retriever not initialized", e) } } @@ -439,7 +441,7 @@ class NetworkLocationService : LifecycleService(), WifiDetailsCallback, CellDeta } } -private operator fun LruCache.set(key: K, value: V) { +private operator fun LruCache.set(key: K, value: V) { put(key, value) } diff --git a/play-services-location/core/src/main/kotlin/org/microg/gms/location/ui/LocationPreferencesFragment.kt b/play-services-location/core/src/main/kotlin/org/microg/gms/location/ui/LocationPreferencesFragment.kt index 99b02de86c..d05baa3abc 100644 --- a/play-services-location/core/src/main/kotlin/org/microg/gms/location/ui/LocationPreferencesFragment.kt +++ b/play-services-location/core/src/main/kotlin/org/microg/gms/location/ui/LocationPreferencesFragment.kt @@ -5,9 +5,10 @@ package org.microg.gms.location.ui -import android.annotation.SuppressLint +import android.location.LocationManager import android.os.Build.VERSION.SDK_INT import android.os.Bundle +import androidx.core.content.getSystemService import androidx.core.os.bundleOf import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.findNavController @@ -90,8 +91,10 @@ class LocationPreferencesFragment : PreferenceFragmentCompat() { networkProviderCategory.isVisible = requireContext().hasNetworkLocationServiceBuiltIn() wifiMls.isVisible = requireContext().hasMozillaLocationServiceSupport() cellMls.isVisible = requireContext().hasMozillaLocationServiceSupport() - wifiLearning.isVisible = SDK_INT >= 17 - cellLearning.isVisible = SDK_INT >= 17 + wifiLearning.isVisible = + SDK_INT >= 17 && requireContext().getSystemService()?.allProviders.orEmpty().contains(LocationManager.GPS_PROVIDER) + cellLearning.isVisible = + SDK_INT >= 17 && requireContext().getSystemService()?.allProviders.orEmpty().contains(LocationManager.GPS_PROVIDER) } override fun onResume() {