From 9b0884713ab1fd1b6dc3b612e1f9625d28c5c887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Chudziak?= Date: Thu, 24 Nov 2022 17:12:06 +0100 Subject: [PATCH] fix: fix coarse permission bug (#223) --- .../geolocation/AndroidLocationManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/reactnativecommunity/geolocation/AndroidLocationManager.java b/android/src/main/java/com/reactnativecommunity/geolocation/AndroidLocationManager.java index f369fa7..f5f901d 100644 --- a/android/src/main/java/com/reactnativecommunity/geolocation/AndroidLocationManager.java +++ b/android/src/main/java/com/reactnativecommunity/geolocation/AndroidLocationManager.java @@ -1,5 +1,6 @@ package com.reactnativecommunity.geolocation; +import android.Manifest; import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageManager; @@ -132,7 +133,8 @@ private String getValidProvider(LocationManager locationManager, boolean highAcc } // If it's an enabled provider, but we don't have permissions, ignore it int finePermission = ContextCompat.checkSelfPermission(mReactContext, android.Manifest.permission.ACCESS_FINE_LOCATION); - if (provider.equals(LocationManager.GPS_PROVIDER) && finePermission != PackageManager.PERMISSION_GRANTED) { + int coarsePermission = ContextCompat.checkSelfPermission(mReactContext, android.Manifest.permission.ACCESS_COARSE_LOCATION); + if (provider.equals(LocationManager.GPS_PROVIDER) && (finePermission != PackageManager.PERMISSION_GRANTED && coarsePermission != PackageManager.PERMISSION_GRANTED)) { return null; } return provider;