summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Liu <luciferleo@google.com>2015-05-12 19:06:06 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-05-12 19:06:06 +0000
commitf0c4f0ddb6167bac5f40b1f68044ecbf8486db7c (patch)
tree556549c7141f8d18814ae9a408c00c51ce934799
parent353232ecee06d1828d8628c4e3917e3b428485aa (diff)
parent3d76e2f35ae5e4557979c053aa35c3cf3b02f1c3 (diff)
downloadframeworks_base-f0c4f0ddb6167bac5f40b1f68044ecbf8486db7c.zip
frameworks_base-f0c4f0ddb6167bac5f40b1f68044ecbf8486db7c.tar.gz
frameworks_base-f0c4f0ddb6167bac5f40b1f68044ecbf8486db7c.tar.bz2
am 3d76e2f3: Merge "Create GpsLocationProvider only if GPS is supported." into lmp-mr1-modular-dev
* commit '3d76e2f35ae5e4557979c053aa35c3cf3b02f1c3': Create GpsLocationProvider only if GPS is supported.
-rw-r--r--services/core/java/com/android/server/LocationManagerService.java27
-rw-r--r--services/core/java/com/android/server/location/GeofenceProxy.java4
-rw-r--r--services/core/java/com/android/server/location/GpsLocationProvider.java3
3 files changed, 21 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index eca6ec7..974e169 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -62,6 +62,7 @@ import android.location.GeocoderParams;
import android.location.Geofence;
import android.location.GpsMeasurementsEvent;
import android.location.GpsNavigationMessageEvent;
+import android.location.IGpsGeofenceHardware;
import android.location.IGpsMeasurementsListener;
import android.location.IGpsNavigationMessageListener;
import android.location.IGpsStatusListener;
@@ -164,6 +165,7 @@ public class LocationManagerService extends ILocationManager.Stub {
private LocationBlacklist mBlacklist;
private GpsMeasurementsProvider mGpsMeasurementsProvider;
private GpsNavigationMessageProvider mGpsNavigationMessageProvider;
+ private IGpsGeofenceHardware mGpsGeofenceProxy;
// --- fields below are protected by mLock ---
// Set of providers that are explicitly enabled
@@ -403,18 +405,19 @@ public class LocationManagerService extends ILocationManager.Stub {
addProviderLocked(passiveProvider);
mEnabledProviders.add(passiveProvider.getName());
mPassiveProvider = passiveProvider;
- // Create a gps location provider
- GpsLocationProvider gpsProvider = new GpsLocationProvider(mContext, this,
- mLocationHandler.getLooper());
if (GpsLocationProvider.isSupported()) {
+ // Create a gps location provider
+ GpsLocationProvider gpsProvider = new GpsLocationProvider(mContext, this,
+ mLocationHandler.getLooper());
mGpsStatusProvider = gpsProvider.getGpsStatusProvider();
mNetInitiatedListener = gpsProvider.getNetInitiatedListener();
addProviderLocked(gpsProvider);
mRealProviders.put(LocationManager.GPS_PROVIDER, gpsProvider);
+ mGpsMeasurementsProvider = gpsProvider.getGpsMeasurementsProvider();
+ mGpsNavigationMessageProvider = gpsProvider.getGpsNavigationMessageProvider();
+ mGpsGeofenceProxy = gpsProvider.getGpsGeofenceProxy();
}
- mGpsMeasurementsProvider = gpsProvider.getGpsMeasurementsProvider();
- mGpsNavigationMessageProvider = gpsProvider.getGpsNavigationMessageProvider();
/*
Load package name(s) containing location provider support.
@@ -510,7 +513,7 @@ public class LocationManagerService extends ILocationManager.Stub {
com.android.internal.R.string.config_geofenceProviderPackageName,
com.android.internal.R.array.config_locationProviderPackageNames,
mLocationHandler,
- gpsProvider.getGpsGeofenceProxy(),
+ mGpsGeofenceProxy,
flpHardwareProvider != null ? flpHardwareProvider.getGeofenceHardware() : null);
if (provider == null) {
Slog.e(TAG, "Unable to bind FLP Geofence proxy.");
@@ -1853,7 +1856,7 @@ public class LocationManagerService extends ILocationManager.Stub {
Binder.restoreCallingIdentity(identity);
}
- if (!hasLocationAccess) {
+ if (!hasLocationAccess || mGpsMeasurementsProvider == null) {
return false;
}
return mGpsMeasurementsProvider.addListener(listener);
@@ -1861,7 +1864,9 @@ public class LocationManagerService extends ILocationManager.Stub {
@Override
public void removeGpsMeasurementsListener(IGpsMeasurementsListener listener) {
- mGpsMeasurementsProvider.removeListener(listener);
+ if (mGpsMeasurementsProvider != null) {
+ mGpsMeasurementsProvider.removeListener(listener);
+ }
}
@Override
@@ -1882,7 +1887,7 @@ public class LocationManagerService extends ILocationManager.Stub {
Binder.restoreCallingIdentity(identity);
}
- if (!hasLocationAccess) {
+ if (!hasLocationAccess || mGpsNavigationMessageProvider == null) {
return false;
}
return mGpsNavigationMessageProvider.addListener(listener);
@@ -1890,7 +1895,9 @@ public class LocationManagerService extends ILocationManager.Stub {
@Override
public void removeGpsNavigationMessageListener(IGpsNavigationMessageListener listener) {
- mGpsNavigationMessageProvider.removeListener(listener);
+ if (mGpsNavigationMessageProvider != null) {
+ mGpsNavigationMessageProvider.removeListener(listener);
+ }
}
@Override
diff --git a/services/core/java/com/android/server/location/GeofenceProxy.java b/services/core/java/com/android/server/location/GeofenceProxy.java
index b886eef..d1bb8db 100644
--- a/services/core/java/com/android/server/location/GeofenceProxy.java
+++ b/services/core/java/com/android/server/location/GeofenceProxy.java
@@ -129,7 +129,9 @@ public final class GeofenceProxy {
private void setGpsGeofenceLocked() {
try {
- mGeofenceHardware.setGpsGeofenceHardware(mGpsGeofenceHardware);
+ if (mGpsGeofenceHardware != null) {
+ mGeofenceHardware.setGpsGeofenceHardware(mGpsGeofenceHardware);
+ }
} catch (RemoteException e) {
Log.e(TAG, "Error while connecting to GeofenceHardwareService");
}
diff --git a/services/core/java/com/android/server/location/GpsLocationProvider.java b/services/core/java/com/android/server/location/GpsLocationProvider.java
index af2da89..ec423b4 100644
--- a/services/core/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/core/java/com/android/server/location/GpsLocationProvider.java
@@ -444,13 +444,12 @@ public class GpsLocationProvider implements LocationProviderInterface {
int networkState;
if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false) ||
- !info.isConnected()) {
+ !info.isConnected()) {
networkState = LocationProvider.TEMPORARILY_UNAVAILABLE;
} else {
networkState = LocationProvider.AVAILABLE;
}
-
updateNetworkState(networkState, info);
} else if (PowerManager.ACTION_POWER_SAVE_MODE_CHANGED.equals(action)
|| Intent.ACTION_SCREEN_OFF.equals(action)