summaryrefslogtreecommitdiff
path: root/location/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'location/java/android')
-rw-r--r--location/java/android/location/ILocationManager.aidl15
-rw-r--r--location/java/android/location/LocationManager.java34
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