@@ -45,10 +45,12 @@ public void onStatusChanged(String provider, int status, Bundle extras) {
45
45
}
46
46
47
47
@ Override
48
- public void onProviderEnabled (String provider ) { }
48
+ public void onProviderEnabled (String provider ) {
49
+ }
49
50
50
51
@ Override
51
- public void onProviderDisabled (String provider ) { }
52
+ public void onProviderDisabled (String provider ) {
53
+ }
52
54
};
53
55
54
56
protected AndroidLocationManager (ReactApplicationContext reactContext ) {
@@ -134,7 +136,8 @@ private String getValidProvider(LocationManager locationManager, boolean highAcc
134
136
// If it's an enabled provider, but we don't have permissions, ignore it
135
137
int finePermission = ContextCompat .checkSelfPermission (mReactContext , android .Manifest .permission .ACCESS_FINE_LOCATION );
136
138
int coarsePermission = ContextCompat .checkSelfPermission (mReactContext , android .Manifest .permission .ACCESS_COARSE_LOCATION );
137
- if (provider .equals (LocationManager .GPS_PROVIDER ) && (finePermission != PackageManager .PERMISSION_GRANTED && coarsePermission != PackageManager .PERMISSION_GRANTED )) {
139
+ if ((provider .equals (LocationManager .GPS_PROVIDER ) && finePermission != PackageManager .PERMISSION_GRANTED ) ||
140
+ (provider .equals (LocationManager .NETWORK_PROVIDER ) && coarsePermission != PackageManager .PERMISSION_GRANTED )) {
138
141
return null ;
139
142
}
140
143
return provider ;
@@ -178,13 +181,16 @@ public void onLocationChanged(Location location) {
178
181
}
179
182
180
183
@ Override
181
- public void onStatusChanged (String provider , int status , Bundle extras ) {}
184
+ public void onStatusChanged (String provider , int status , Bundle extras ) {
185
+ }
182
186
183
187
@ Override
184
- public void onProviderEnabled (String provider ) {}
188
+ public void onProviderEnabled (String provider ) {
189
+ }
185
190
186
191
@ Override
187
- public void onProviderDisabled (String provider ) {}
192
+ public void onProviderDisabled (String provider ) {
193
+ }
188
194
};
189
195
private boolean mTriggered ;
190
196
@@ -209,11 +215,12 @@ public void invoke(Location location) {
209
215
210
216
private static final int TWO_MINUTES = 1000 * 60 * 2 ;
211
217
212
- /** Determines whether one Location reading is better than the current Location fix
218
+ /**
219
+ * Determines whether one Location reading is better than the current Location fix
213
220
* taken from Android Examples https://developer.android.com/guide/topics/location/strategies.html
214
221
*
215
- * @param location The new Location that you want to evaluate
216
- * @param currentBestLocation The current Location fix, to which you want to compare the new one
222
+ * @param location The new Location that you want to evaluate
223
+ * @param currentBestLocation The current Location fix, to which you want to compare the new one
217
224
*/
218
225
private boolean isBetterLocation (Location location , Location currentBestLocation ) {
219
226
if (currentBestLocation == null ) {
@@ -258,7 +265,9 @@ private boolean isBetterLocation(Location location, Location currentBestLocation
258
265
return false ;
259
266
}
260
267
261
- /** Checks whether two providers are the same */
268
+ /**
269
+ * Checks whether two providers are the same
270
+ */
262
271
private boolean isSameProvider (String provider1 , String provider2 ) {
263
272
if (provider1 == null ) {
264
273
return provider2 == null ;
0 commit comments