From e7efda2e90cf6fa1a225dd6096e87e132610761c Mon Sep 17 00:00:00 2001 From: johan12345 Date: Sun, 7 Aug 2022 21:29:24 +0200 Subject: [PATCH] Android Auto: request fine location permission --- app/src/google/java/net/vonforst/evmap/auto/CarAppService.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/google/java/net/vonforst/evmap/auto/CarAppService.kt b/app/src/google/java/net/vonforst/evmap/auto/CarAppService.kt index dcfd5766..62bba39f 100644 --- a/app/src/google/java/net/vonforst/evmap/auto/CarAppService.kt +++ b/app/src/google/java/net/vonforst/evmap/auto/CarAppService.kt @@ -30,7 +30,7 @@ import androidx.core.location.LocationListenerCompat import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import net.vonforst.evmap.R -import net.vonforst.evmap.utils.checkAnyLocationPermission +import net.vonforst.evmap.utils.checkFineLocationPermission interface LocationAwareScreen { @@ -132,7 +132,7 @@ class EVMapSession(val cas: CarAppService) : Session(), DefaultLifecycleObserver return mapScreen } - fun locationPermissionGranted() = carContext.checkAnyLocationPermission() + private fun locationPermissionGranted() = carContext.checkFineLocationPermission() private fun updateLocation(location: Location?) { Log.d(TAG, "Received location: $location") @@ -159,6 +159,7 @@ class EVMapSession(val cas: CarAppService) : Session(), DefaultLifecycleObserver requestPhoneLocationUpdates() } + @RequiresPermission(anyOf = [Manifest.permission.ACCESS_FINE_LOCATION]) private fun requestCarHardwareLocationUpdates() { if (supportsCarApiLevel3(carContext)) { val exec = ContextCompat.getMainExecutor(carContext)