am 3d76e2f3: Merge "Create GpsLocationProvider only if GPS is supported." into lmp-mr1-modular-dev
* commit '3d76e2f35ae5e4557979c053aa35c3cf3b02f1c3':
Create GpsLocationProvider only if GPS is supported.
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.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 @@
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 @@
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 @@
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 @@
Binder.restoreCallingIdentity(identity);
}
- if (!hasLocationAccess) {
+ if (!hasLocationAccess || mGpsMeasurementsProvider == null) {
return false;
}
return mGpsMeasurementsProvider.addListener(listener);
@@ -1861,7 +1864,9 @@
@Override
public void removeGpsMeasurementsListener(IGpsMeasurementsListener listener) {
- mGpsMeasurementsProvider.removeListener(listener);
+ if (mGpsMeasurementsProvider != null) {
+ mGpsMeasurementsProvider.removeListener(listener);
+ }
}
@Override
@@ -1882,7 +1887,7 @@
Binder.restoreCallingIdentity(identity);
}
- if (!hasLocationAccess) {
+ if (!hasLocationAccess || mGpsNavigationMessageProvider == null) {
return false;
}
return mGpsNavigationMessageProvider.addListener(listener);
@@ -1890,7 +1895,9 @@
@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 @@
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 af2da892..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 @@
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)