diff options
| author | 2019-09-27 17:06:25 -0700 | |
|---|---|---|
| committer | 2019-10-14 10:55:52 -0700 | |
| commit | bc8b48a97b98c71898dfa735543a32944d8a232f (patch) | |
| tree | 343fc43de663adfff9b621154d245eaf10ec8843 /location/java/android | |
| parent | e0d74cdf2ee6befe8a3e9ce2ade837993267f353 (diff) | |
Add useful app-op-note message to async Location deliveries
Test: atest CtsAppOpsTestCases
Bug: 136505050
Change-Id: I1a34cd993132cc4fdf87c92625595240bb8ec4a7
Diffstat (limited to 'location/java/android')
| -rw-r--r-- | location/java/android/location/ILocationManager.aidl | 15 | ||||
| -rw-r--r-- | location/java/android/location/LocationManager.java | 34 |
2 files changed, 35 insertions, 14 deletions
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl index d06ba12f5e2a..17e8d04a3e57 100644 --- a/location/java/android/location/ILocationManager.aidl +++ b/location/java/android/location/ILocationManager.aidl @@ -42,11 +42,11 @@ import com.android.internal.location.ProviderProperties; interface ILocationManager { void requestLocationUpdates(in LocationRequest request, in ILocationListener listener, - in PendingIntent intent, String packageName); + in PendingIntent intent, String packageName, String listenerIdentifier); void removeUpdates(in ILocationListener listener, in PendingIntent intent, String packageName); void requestGeofence(in LocationRequest request, in Geofence geofence, - in PendingIntent intent, String packageName); + in PendingIntent intent, String packageName, String listenerIdentifier); void removeGeofence(in Geofence fence, in PendingIntent intent, String packageName); Location getLastLocation(in LocationRequest request, String packageName); @@ -64,22 +64,23 @@ interface ILocationManager boolean sendNiResponse(int notifId, int userResponse); - boolean addGnssMeasurementsListener(in IGnssMeasurementsListener listener, in String packageName); + boolean addGnssMeasurementsListener(in IGnssMeasurementsListener listener, + String packageName, String listenerIdentifier); void injectGnssMeasurementCorrections(in GnssMeasurementCorrections corrections, in String packageName); long getGnssCapabilities(in String packageName); void removeGnssMeasurementsListener(in IGnssMeasurementsListener listener); - boolean addGnssNavigationMessageListener( - in IGnssNavigationMessageListener listener, - in String packageName); + boolean addGnssNavigationMessageListener(in IGnssNavigationMessageListener listener, + String packageName, String listenerIdentifier); void removeGnssNavigationMessageListener(in IGnssNavigationMessageListener listener); int getGnssYearOfHardware(); String getGnssHardwareModelName(); int getGnssBatchSize(String packageName); - boolean addGnssBatchingCallback(in IBatchedLocationCallback callback, String packageName); + boolean addGnssBatchingCallback(in IBatchedLocationCallback callback, String packageName, + String listenerIdentifier); void removeGnssBatchingCallback(); boolean startGnssBatch(long periodNanos, boolean wakeOnFifoFull, String packageName); void flushGnssBatch(String packageName); diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 90e29df45e51..738d85b0b324 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -542,6 +542,23 @@ public class LocationManager { } /** + * Create a string that allows an app to identify a listener + * + * @param listener The listener + * + * @return A identifying string + */ + private static String getListenerIdentifier(@NonNull Object listener) { + StringBuilder sb = new StringBuilder(); + + sb.append(listener.getClass().getName()); + sb.append('@'); + sb.append(Integer.toHexString(System.identityHashCode(listener))); + + return sb.toString(); + } + + /** * Register for a single location update using the named provider and * a callback. * @@ -981,7 +998,7 @@ public class LocationManager { boolean registered = false; try { mService.requestLocationUpdates(locationRequest, transport, null, - mContext.getPackageName()); + mContext.getPackageName(), getListenerIdentifier(listener)); registered = true; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); @@ -1026,7 +1043,7 @@ public class LocationManager { try { mService.requestLocationUpdates(locationRequest, null, pendingIntent, - mContext.getPackageName()); + mContext.getPackageName(), getListenerIdentifier(pendingIntent)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1471,7 +1488,8 @@ public class LocationManager { Geofence fence = Geofence.createCircle(latitude, longitude, radius); LocationRequest request = new LocationRequest().setExpireIn(expiration); try { - mService.requestGeofence(request, fence, intent, mContext.getPackageName()); + mService.requestGeofence(request, fence, intent, mContext.getPackageName(), + getListenerIdentifier(intent)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1548,7 +1566,8 @@ public class LocationManager { Preconditions.checkArgument(fence != null, "invalid null geofence"); try { - mService.requestGeofence(request, fence, intent, mContext.getPackageName()); + mService.requestGeofence(request, fence, intent, mContext.getPackageName(), + getListenerIdentifier(intent)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -2538,7 +2557,7 @@ public class LocationManager { mListenerTransport = new GnssMeasurementsListener(); return mService.addGnssMeasurementsListener(mListenerTransport, - mContext.getPackageName()); + mContext.getPackageName(), "gnss measurement callback"); } @Override @@ -2574,7 +2593,7 @@ public class LocationManager { mListenerTransport = new GnssNavigationMessageListener(); return mService.addGnssNavigationMessageListener(mListenerTransport, - mContext.getPackageName()); + mContext.getPackageName(), "gnss navigation callback"); } @Override @@ -2609,7 +2628,8 @@ public class LocationManager { Preconditions.checkState(mListenerTransport == null); mListenerTransport = new BatchedLocationCallback(); - return mService.addGnssBatchingCallback(mListenerTransport, mContext.getPackageName()); + return mService.addGnssBatchingCallback(mListenerTransport, mContext.getPackageName(), + "batched location callback"); } @Override |