summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2009-05-07 13:27:54 -0400
committerMike Lockwood <lockwood@android.com>2009-05-07 13:27:54 -0400
commit95427cdbd802f7cb529d62bb79953c45b36a8fcf (patch)
treeae907dc90b346cd96e62f44ccb589eae2bb0d560 /services/java/com
parent8dfe5d8c6ba9cb165994f09843abaa6302d63c1d (diff)
downloadframeworks_base-95427cdbd802f7cb529d62bb79953c45b36a8fcf.zip
frameworks_base-95427cdbd802f7cb529d62bb79953c45b36a8fcf.tar.gz
frameworks_base-95427cdbd802f7cb529d62bb79953c45b36a8fcf.tar.bz2
location: Fix mock provider support
Allow mock providers to be used for proximity alerts. Clear calling identity so mock provider support does not fail due to lack of INSTALL_LOCATION_PROVIDER permission. Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/LocationManagerService.java25
1 files changed, 12 insertions, 13 deletions
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index c924d8d..14c834b 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -918,12 +918,9 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
}
}
}
- if (LocationManager.GPS_PROVIDER.equals(provider) ||
- LocationManager.NETWORK_PROVIDER.equals(provider)) {
- for (ProximityAlert alert : mProximityAlerts.values()) {
- if (alert.mUid == uid) {
- return true;
- }
+ for (ProximityAlert alert : mProximityAlerts.values()) {
+ if (alert.mUid == uid) {
+ return true;
}
}
return false;
@@ -1359,13 +1356,8 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
mProximityListener = new ProximityListener();
mProximityReceiver = new Receiver(mProximityListener);
- LocationProviderProxy provider = mProvidersByName.get(LocationManager.GPS_PROVIDER);
- if (provider != null) {
- requestLocationUpdatesLocked(provider.getName(), 1000L, 1.0f, mProximityReceiver);
- }
-
- provider = mProvidersByName.get(LocationManager.NETWORK_PROVIDER);
- if (provider != null) {
+ for (int i = mProviders.size() - 1; i >= 0; i--) {
+ LocationProviderProxy provider = mProviders.get(i);
requestLocationUpdatesLocked(provider.getName(), 1000L, 1.0f, mProximityReceiver);
}
}
@@ -1809,9 +1801,13 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
if (mProvidersByName.get(name) != null) {
throw new IllegalArgumentException("Provider \"" + name + "\" already exists");
}
+
+ // clear calling identity so INSTALL_LOCATION_PROVIDER permission is not required
+ long identity = Binder.clearCallingIdentity();
addProvider(new LocationProviderProxy(name, provider));
mMockProviders.put(name, provider);
updateProvidersLocked();
+ Binder.restoreCallingIdentity(identity);
}
}
@@ -1835,7 +1831,10 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
if (mockProvider == null) {
throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
}
+ // clear calling identity so INSTALL_LOCATION_PROVIDER permission is not required
+ long identity = Binder.clearCallingIdentity();
mockProvider.setLocation(loc);
+ Binder.restoreCallingIdentity(identity);
}
}