Fix wrong error code when location service is turned off on Android device
Reviewed By: achen1 Differential Revision: D6106890 fbshipit-source-id: ab6ccdc2625745e4bbcdb0d7fe284de504d09641
This commit is contained in:
parent
90369808ee
commit
7e0b7ef8d0
|
@ -16,7 +16,7 @@ import android.location.LocationManager;
|
|||
import android.location.LocationProvider;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
|
@ -24,13 +24,10 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.common.SystemClock;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
|
||||
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.common.logging.FLog;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -126,9 +123,9 @@ public class LocationModule extends ReactContextBaseJavaModule {
|
|||
(LocationManager) getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE);
|
||||
String provider = getValidProvider(locationManager, locationOptions.highAccuracy);
|
||||
if (provider == null) {
|
||||
error.invoke(PositionError.buildError(
|
||||
PositionError.PERMISSION_DENIED,
|
||||
"No location provider available."));
|
||||
error.invoke(
|
||||
PositionError.buildError(
|
||||
PositionError.POSITION_UNAVAILABLE, "No location provider available."));
|
||||
return;
|
||||
}
|
||||
Location location = locationManager.getLastKnownLocation(provider);
|
||||
|
@ -162,7 +159,7 @@ public class LocationModule extends ReactContextBaseJavaModule {
|
|||
(LocationManager) getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE);
|
||||
String provider = getValidProvider(locationManager, locationOptions.highAccuracy);
|
||||
if (provider == null) {
|
||||
emitError(PositionError.PERMISSION_DENIED, "No location provider available.");
|
||||
emitError(PositionError.POSITION_UNAVAILABLE, "No location provider available.");
|
||||
return;
|
||||
}
|
||||
if (!provider.equals(mWatchedProvider)) {
|
||||
|
|
Loading…
Reference in New Issue