diff options
author | Nick Pelly <npelly@google.com> | 2012-07-29 21:23:08 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2012-07-30 13:17:30 -0700 |
commit | 48c5eb018b1731bd47caccd43cda2cd36ebc271f (patch) | |
tree | 8d4161bddb28cb388d875e9639e1c7c53d41f5d3 /location/java | |
parent | 47db02bad8fed67025669c41ef0c0dd9cafe7ed2 (diff) | |
download | frameworks_base-48c5eb018b1731bd47caccd43cda2cd36ebc271f.zip frameworks_base-48c5eb018b1731bd47caccd43cda2cd36ebc271f.tar.gz frameworks_base-48c5eb018b1731bd47caccd43cda2cd36ebc271f.tar.bz2 |
DO NOT MERGE. Add package-name-prefix blacklist for location updates.
The Settings.Secure value locationPackagePrefixBlacklist and
locationPackagePrefixWhitelist contains comma seperated package-name
prefixes.
Location & geo-fence updates are silently dropped if the receiving
package name has a prefix on the blacklist. Status updates are
not affected. All other API's work as before.
A content observer is used so run-time updates to the blacklist
apply immediately. There is both a blacklist and a whitelist.
The blacklist applies first, and then exemptions are allowed
from the whitelist. In other words, if your package name prefix
matches both the black AND white list, then it is allowed.
Change-Id: I4ea2ad56fa6bd75d32151bc250ac25c26a5777c4
Diffstat (limited to 'location/java')
-rw-r--r-- | location/java/android/location/ILocationManager.aidl | 12 | ||||
-rw-r--r-- | location/java/android/location/LocationManager.java | 20 |
2 files changed, 19 insertions, 13 deletions
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl index 2255bf2..38a29d3 100644 --- a/location/java/android/location/ILocationManager.aidl +++ b/location/java/android/location/ILocationManager.aidl @@ -39,11 +39,11 @@ interface ILocationManager boolean providerMeetsCriteria(String provider, in Criteria criteria); void requestLocationUpdates(String provider, in Criteria criteria, long minTime, float minDistance, - boolean singleShot, in ILocationListener listener); + boolean singleShot, in ILocationListener listener, String packageName); void requestLocationUpdatesPI(String provider, in Criteria criteria, long minTime, float minDistance, - boolean singleShot, in PendingIntent intent); - void removeUpdates(in ILocationListener listener); - void removeUpdatesPI(in PendingIntent intent); + boolean singleShot, in PendingIntent intent, String packageName); + void removeUpdates(in ILocationListener listener, String packageName); + void removeUpdatesPI(in PendingIntent intent, String packageName); boolean addGpsStatusListener(IGpsStatusListener listener); void removeGpsStatusListener(IGpsStatusListener listener); @@ -54,13 +54,13 @@ interface ILocationManager boolean sendExtraCommand(String provider, String command, inout Bundle extras); void addProximityAlert(double latitude, double longitude, float distance, - long expiration, in PendingIntent intent); + long expiration, in PendingIntent intent, String packageName); void removeProximityAlert(in PendingIntent intent); Bundle getProviderInfo(String provider); boolean isProviderEnabled(String provider); - Location getLastKnownLocation(String provider); + Location getLastKnownLocation(String provider, String packageName); // Used by location providers to tell the location manager when it has a new location. // Passive is true if the location is coming from the passive provider, in which case diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 1299574..5c256a3 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -17,6 +17,7 @@ package android.location; import android.app.PendingIntent; +import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Looper; @@ -160,6 +161,8 @@ public class LocationManager { */ public static final String EXTRA_GPS_ENABLED = "enabled"; + private final Context mContext; + // Map from LocationListeners to their associated ListenerTransport objects private HashMap<LocationListener,ListenerTransport> mListeners = new HashMap<LocationListener,ListenerTransport>(); @@ -260,8 +263,9 @@ public class LocationManager { * right way to create an instance of this class is using the * factory Context.getSystemService. */ - public LocationManager(ILocationManager service) { + public LocationManager(Context context, ILocationManager service) { mService = service; + mContext = context; } private LocationProvider createProvider(String name, Bundle info) { @@ -657,7 +661,8 @@ public class LocationManager { transport = new ListenerTransport(listener, looper); } mListeners.put(listener, transport); - mService.requestLocationUpdates(provider, criteria, minTime, minDistance, singleShot, transport); + mService.requestLocationUpdates(provider, criteria, minTime, minDistance, + singleShot, transport, mContext.getPackageName()); } } catch (RemoteException ex) { Log.e(TAG, "requestLocationUpdates: DeadObjectException", ex); @@ -837,7 +842,8 @@ public class LocationManager { } try { - mService.requestLocationUpdatesPI(provider, criteria, minTime, minDistance, singleShot, intent); + mService.requestLocationUpdatesPI(provider, criteria, minTime, minDistance, singleShot, + intent, mContext.getPackageName()); } catch (RemoteException ex) { Log.e(TAG, "requestLocationUpdates: RemoteException", ex); } @@ -1005,7 +1011,7 @@ public class LocationManager { try { ListenerTransport transport = mListeners.remove(listener); if (transport != null) { - mService.removeUpdates(transport); + mService.removeUpdates(transport, mContext.getPackageName()); } } catch (RemoteException ex) { Log.e(TAG, "removeUpdates: DeadObjectException", ex); @@ -1028,7 +1034,7 @@ public class LocationManager { Log.d(TAG, "removeUpdates: intent = " + intent); } try { - mService.removeUpdatesPI(intent); + mService.removeUpdatesPI(intent, mContext.getPackageName()); } catch (RemoteException ex) { Log.e(TAG, "removeUpdates: RemoteException", ex); } @@ -1087,7 +1093,7 @@ public class LocationManager { } try { mService.addProximityAlert(latitude, longitude, radius, - expiration, intent); + expiration, intent, mContext.getPackageName()); } catch (RemoteException ex) { Log.e(TAG, "addProximityAlert: RemoteException", ex); } @@ -1153,7 +1159,7 @@ public class LocationManager { throw new IllegalArgumentException("provider==null"); } try { - return mService.getLastKnownLocation(provider); + return mService.getLastKnownLocation(provider, mContext.getPackageName()); } catch (RemoteException ex) { Log.e(TAG, "getLastKnowLocation: RemoteException", ex); return null; |