Permalink
Browse files

Fix wrong error code when location service is turned off on Android d…

…evice

Reviewed By: achen1

Differential Revision: D6106890

fbshipit-source-id: ab6ccdc2625745e4bbcdb0d7fe284de504d09641
  • Loading branch information...
Tao Huang authored and facebook-github-bot committed Oct 20, 2017
1 parent 9036980 commit 7e0b7ef8d02c82c6d3c655e1b580a6975c097e87
@@ -16,21 +16,18 @@
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;
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 void getCurrentPosition(
(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 void startObserving(ReadableMap options) {
(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)) {

0 comments on commit 7e0b7ef

Please sign in to comment.