Skip to content

Commit

Permalink
fix: fix coarse permission bug (michalchudziak#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalchudziak authored Nov 24, 2022
1 parent b6d3a06 commit 9b08847
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.reactnativecommunity.geolocation;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9b08847

Please sign in to comment.