summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/location
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2012-05-27 16:12:45 -0700
committerNick Pelly <npelly@google.com>2012-05-29 13:36:46 +0200
commit00355d5a592533a3ecb0a5a74aef8e69dd16902a (patch)
treeb012ef055253877f2922ed707dd66475ccb09444 /services/java/com/android/server/location
parentbbedfa0036f8de393c05b2ad981695ae74e7ab42 (diff)
downloadframeworks_base-00355d5a592533a3ecb0a5a74aef8e69dd16902a.zip
frameworks_base-00355d5a592533a3ecb0a5a74aef8e69dd16902a.tar.gz
frameworks_base-00355d5a592533a3ecb0a5a74aef8e69dd16902a.tar.bz2
Make location providers upgradeable.
Use config_netowrkLocationProviderPackageName and config_geocodeProviderPackageName as intial packages. If another package exists (or is later installed) that also implements a provider, and has the same signatures as the original providers, and has a hgiher version number, then use that instead. The old code used a funky fix of package name substring checks and service checks that was broken and not upgradeable. Bug: 6499445 Change-Id: Ic58f09cf85d31d9abf47707093e22f31dda25cf0
Diffstat (limited to 'services/java/com/android/server/location')
-rw-r--r--services/java/com/android/server/location/GeocoderProxy.java25
-rw-r--r--services/java/com/android/server/location/LocationProviderProxy.java29
2 files changed, 28 insertions, 26 deletions
diff --git a/services/java/com/android/server/location/GeocoderProxy.java b/services/java/com/android/server/location/GeocoderProxy.java
index b38ea13..07f3125 100644
--- a/services/java/com/android/server/location/GeocoderProxy.java
+++ b/services/java/com/android/server/location/GeocoderProxy.java
@@ -39,27 +39,28 @@ public class GeocoderProxy {
private static final String TAG = "GeocoderProxy";
+ public static final String SERVICE_ACTION =
+ "com.android.location.service.GeocodeProvider";
+
private final Context mContext;
private final Intent mIntent;
private final Object mMutex = new Object(); // synchronizes access to mServiceConnection
- private Connection mServiceConnection = new Connection(); // never null
+ private Connection mServiceConnection; // never null after ctor
- public GeocoderProxy(Context context, String serviceName) {
+ public GeocoderProxy(Context context, String packageName) {
mContext = context;
- mIntent = new Intent(serviceName);
- mContext.bindService(mIntent, mServiceConnection,
- Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND
- | Context.BIND_ALLOW_OOM_MANAGEMENT);
+ mIntent = new Intent(SERVICE_ACTION);
+ reconnect(packageName);
}
- /**
- * When unbundled NetworkLocationService package is updated, we
- * need to unbind from the old version and re-bind to the new one.
- */
- public void reconnect() {
+ /** Bind to service. Will reconnect if already connected */
+ public void reconnect(String packageName) {
synchronized (mMutex) {
- mContext.unbindService(mServiceConnection);
+ if (mServiceConnection != null) {
+ mContext.unbindService(mServiceConnection);
+ }
mServiceConnection = new Connection();
+ mIntent.setPackage(packageName);
mContext.bindService(mIntent, mServiceConnection,
Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND
| Context.BIND_ALLOW_OOM_MANAGEMENT);
diff --git a/services/java/com/android/server/location/LocationProviderProxy.java b/services/java/com/android/server/location/LocationProviderProxy.java
index 0bc1664..a227ab6 100644
--- a/services/java/com/android/server/location/LocationProviderProxy.java
+++ b/services/java/com/android/server/location/LocationProviderProxy.java
@@ -42,12 +42,15 @@ public class LocationProviderProxy implements LocationProviderInterface {
private static final String TAG = "LocationProviderProxy";
+ public static final String SERVICE_ACTION =
+ "com.android.location.service.NetworkLocationProvider";
+
private final Context mContext;
private final String mName;
private final Intent mIntent;
private final Handler mHandler;
private final Object mMutex = new Object(); // synchronizes access to non-final members
- private Connection mServiceConnection = new Connection(); // never null
+ private Connection mServiceConnection; // never null after ctor
// cached values set by the location manager
private boolean mLocationTracking = false;
@@ -58,28 +61,26 @@ public class LocationProviderProxy implements LocationProviderInterface {
private NetworkInfo mNetworkInfo;
// constructor for proxying location providers implemented in a separate service
- public LocationProviderProxy(Context context, String name, String serviceName,
+ public LocationProviderProxy(Context context, String name, String packageName,
Handler handler) {
mContext = context;
mName = name;
- mIntent = new Intent(serviceName);
+ mIntent = new Intent(SERVICE_ACTION);
mHandler = handler;
- mContext.bindService(mIntent, mServiceConnection,
- Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND
- | Context.BIND_ALLOW_OOM_MANAGEMENT);
+ reconnect(packageName);
}
- /**
- * When unbundled NetworkLocationService package is updated, we
- * need to unbind from the old version and re-bind to the new one.
- */
- public void reconnect() {
+ /** Bind to service. Will reconnect if already connected */
+ public void reconnect(String packageName) {
synchronized (mMutex) {
- mContext.unbindService(mServiceConnection);
+ if (mServiceConnection != null) {
+ mContext.unbindService(mServiceConnection);
+ }
mServiceConnection = new Connection();
+ mIntent.setPackage(packageName);
mContext.bindService(mIntent, mServiceConnection,
- Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND
- | Context.BIND_ALLOW_OOM_MANAGEMENT);
+ Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND |
+ Context.BIND_ALLOW_OOM_MANAGEMENT);
}
}