Merge "Add featureId to LocationManager app-op notes"
This commit is contained in:
committed by
Android (Google) Code Review
commit
f94dcc87e1
@@ -42,20 +42,23 @@ import com.android.internal.location.ProviderProperties;
|
||||
*/
|
||||
interface ILocationManager
|
||||
{
|
||||
Location getLastLocation(in LocationRequest request, String packageName);
|
||||
Location getLastLocation(in LocationRequest request, String packageName, String featureId);
|
||||
boolean getCurrentLocation(in LocationRequest request,
|
||||
in ICancellationSignal cancellationSignal, in ILocationListener listener,
|
||||
String packageName, String listenerIdentifier);
|
||||
String packageName, String featureId, String listenerIdentifier);
|
||||
|
||||
void requestLocationUpdates(in LocationRequest request, in ILocationListener listener,
|
||||
in PendingIntent intent, String packageName, String listenerIdentifier);
|
||||
in PendingIntent intent, String packageName, String featureId,
|
||||
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, String listenerIdentifier);
|
||||
in PendingIntent intent, String packageName, String featureId,
|
||||
String listenerIdentifier);
|
||||
void removeGeofence(in Geofence fence, in PendingIntent intent, String packageName);
|
||||
|
||||
boolean registerGnssStatusCallback(IGnssStatusListener callback, String packageName);
|
||||
boolean registerGnssStatusCallback(IGnssStatusListener callback, String packageName,
|
||||
String featureId);
|
||||
void unregisterGnssStatusCallback(IGnssStatusListener callback);
|
||||
|
||||
boolean geocoderIsPresent();
|
||||
@@ -69,14 +72,14 @@ interface ILocationManager
|
||||
boolean sendNiResponse(int notifId, int userResponse);
|
||||
|
||||
boolean addGnssMeasurementsListener(in IGnssMeasurementsListener listener,
|
||||
String packageName, String listenerIdentifier);
|
||||
String packageName, String featureId, 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,
|
||||
String packageName, String listenerIdentifier);
|
||||
String packageName, String featureId, String listenerIdentifier);
|
||||
void removeGnssNavigationMessageListener(in IGnssNavigationMessageListener listener);
|
||||
|
||||
int getGnssYearOfHardware();
|
||||
@@ -84,7 +87,7 @@ interface ILocationManager
|
||||
|
||||
int getGnssBatchSize(String packageName);
|
||||
boolean addGnssBatchingCallback(in IBatchedLocationCallback callback, String packageName,
|
||||
String listenerIdentifier);
|
||||
String featureId, String listenerIdentifier);
|
||||
void removeGnssBatchingCallback();
|
||||
boolean startGnssBatch(long periodNanos, boolean wakeOnFifoFull, String packageName);
|
||||
void flushGnssBatch(String packageName);
|
||||
|
||||
@@ -515,7 +515,8 @@ public class LocationManager {
|
||||
@RequiresPermission(anyOf = {ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION})
|
||||
public Location getLastLocation() {
|
||||
try {
|
||||
return mService.getLastLocation(null, mContext.getPackageName());
|
||||
return mService.getLastLocation(null, mContext.getPackageName(),
|
||||
mContext.getFeatureId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -547,7 +548,8 @@ public class LocationManager {
|
||||
provider, 0, 0, true);
|
||||
|
||||
try {
|
||||
return mService.getLastLocation(request, mContext.getPackageName());
|
||||
return mService.getLastLocation(request, mContext.getPackageName(),
|
||||
mContext.getFeatureId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -641,7 +643,7 @@ public class LocationManager {
|
||||
|
||||
try {
|
||||
if (mService.getCurrentLocation(currentLocationRequest, remoteCancellationSignal,
|
||||
listenerTransport, mContext.getPackageName(),
|
||||
listenerTransport, mContext.getPackageName(), mContext.getFeatureId(),
|
||||
getListenerIdentifier(consumer))) {
|
||||
listenerTransport.register(mContext.getSystemService(AlarmManager.class),
|
||||
remoteCancellationSignal);
|
||||
@@ -1085,7 +1087,8 @@ public class LocationManager {
|
||||
boolean registered = false;
|
||||
try {
|
||||
mService.requestLocationUpdates(locationRequest, transport, null,
|
||||
mContext.getPackageName(), getListenerIdentifier(listener));
|
||||
mContext.getPackageName(), mContext.getFeatureId(),
|
||||
getListenerIdentifier(listener));
|
||||
registered = true;
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -1130,7 +1133,8 @@ public class LocationManager {
|
||||
|
||||
try {
|
||||
mService.requestLocationUpdates(locationRequest, null, pendingIntent,
|
||||
mContext.getPackageName(), getListenerIdentifier(pendingIntent));
|
||||
mContext.getPackageName(), mContext.getFeatureId(),
|
||||
getListenerIdentifier(pendingIntent));
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1594,7 +1598,7 @@ public class LocationManager {
|
||||
LocationRequest request = new LocationRequest().setExpireIn(expiration);
|
||||
try {
|
||||
mService.requestGeofence(request, fence, intent, mContext.getPackageName(),
|
||||
getListenerIdentifier(intent));
|
||||
mContext.getFeatureId(), getListenerIdentifier(intent));
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1672,7 +1676,7 @@ public class LocationManager {
|
||||
|
||||
try {
|
||||
mService.requestGeofence(request, fence, intent, mContext.getPackageName(),
|
||||
getListenerIdentifier(intent));
|
||||
mContext.getFeatureId(), getListenerIdentifier(intent));
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -2748,7 +2752,7 @@ public class LocationManager {
|
||||
|
||||
mListenerTransport = new GnssStatusListener();
|
||||
return mService.registerGnssStatusCallback(mListenerTransport,
|
||||
mContext.getPackageName());
|
||||
mContext.getPackageName(), mContext.getFeatureId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2808,7 +2812,8 @@ public class LocationManager {
|
||||
|
||||
mListenerTransport = new GnssMeasurementsListener();
|
||||
return mService.addGnssMeasurementsListener(mListenerTransport,
|
||||
mContext.getPackageName(), "gnss measurement callback");
|
||||
mContext.getPackageName(), mContext.getFeatureId(),
|
||||
"gnss measurement callback");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2844,7 +2849,8 @@ public class LocationManager {
|
||||
|
||||
mListenerTransport = new GnssNavigationMessageListener();
|
||||
return mService.addGnssNavigationMessageListener(mListenerTransport,
|
||||
mContext.getPackageName(), "gnss navigation callback");
|
||||
mContext.getPackageName(), mContext.getFeatureId(),
|
||||
"gnss navigation callback");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2880,7 +2886,7 @@ public class LocationManager {
|
||||
|
||||
mListenerTransport = new BatchedLocationCallback();
|
||||
return mService.addGnssBatchingCallback(mListenerTransport, mContext.getPackageName(),
|
||||
"batched location callback");
|
||||
mContext.getFeatureId(), "batched location callback");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.server;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
@@ -300,7 +301,7 @@ public class GnssManagerService {
|
||||
* @return true if callback is successfully added, false otherwise
|
||||
*/
|
||||
public boolean addGnssBatchingCallback(IBatchedLocationCallback callback, String packageName,
|
||||
@NonNull String listenerIdentity) {
|
||||
@Nullable String featureId, @NonNull String listenerIdentity) {
|
||||
mContext.enforceCallingPermission(
|
||||
android.Manifest.permission.LOCATION_HARDWARE,
|
||||
"Location Hardware permission not granted to access hardware batching");
|
||||
@@ -319,7 +320,7 @@ public class GnssManagerService {
|
||||
|
||||
CallerIdentity callerIdentity =
|
||||
new CallerIdentity(Binder.getCallingUid(), Binder.getCallingPid(), packageName,
|
||||
listenerIdentity);
|
||||
featureId, listenerIdentity);
|
||||
synchronized (mGnssBatchingLock) {
|
||||
mGnssBatchingCallback = callback;
|
||||
mGnssBatchingDeathCallback =
|
||||
@@ -497,6 +498,7 @@ public class GnssManagerService {
|
||||
private <TListener extends IInterface> boolean addGnssDataListenerLocked(
|
||||
TListener listener,
|
||||
String packageName,
|
||||
@Nullable String featureId,
|
||||
@NonNull String listenerIdentifier,
|
||||
RemoteListenerHelper<TListener> gnssDataProvider,
|
||||
ArrayMap<IBinder,
|
||||
@@ -517,7 +519,7 @@ public class GnssManagerService {
|
||||
|
||||
CallerIdentity callerIdentity =
|
||||
new CallerIdentity(Binder.getCallingUid(), Binder.getCallingPid(), packageName,
|
||||
listenerIdentifier);
|
||||
featureId, listenerIdentifier);
|
||||
LinkedListener<TListener> linkedListener =
|
||||
new LocationManagerServiceUtils.LinkedListener<>(
|
||||
listener, listenerIdentifier, callerIdentity, binderDeathCallback);
|
||||
@@ -605,11 +607,13 @@ public class GnssManagerService {
|
||||
* @param packageName name of requesting package
|
||||
* @return true if listener is successfully registered, false otherwise
|
||||
*/
|
||||
public boolean registerGnssStatusCallback(IGnssStatusListener listener, String packageName) {
|
||||
public boolean registerGnssStatusCallback(IGnssStatusListener listener, String packageName,
|
||||
@Nullable String featureId) {
|
||||
synchronized (mGnssStatusListeners) {
|
||||
return addGnssDataListenerLocked(
|
||||
listener,
|
||||
packageName,
|
||||
featureId,
|
||||
"Gnss status",
|
||||
mGnssStatusProvider,
|
||||
mGnssStatusListeners,
|
||||
@@ -636,12 +640,13 @@ public class GnssManagerService {
|
||||
* @return true if listener is successfully added, false otherwise
|
||||
*/
|
||||
public boolean addGnssMeasurementsListener(
|
||||
IGnssMeasurementsListener listener, String packageName,
|
||||
IGnssMeasurementsListener listener, String packageName, @Nullable String featureId,
|
||||
@NonNull String listenerIdentifier) {
|
||||
synchronized (mGnssMeasurementsListeners) {
|
||||
return addGnssDataListenerLocked(
|
||||
listener,
|
||||
packageName,
|
||||
featureId,
|
||||
listenerIdentifier,
|
||||
mGnssMeasurementsProvider,
|
||||
mGnssMeasurementsListeners,
|
||||
@@ -695,11 +700,12 @@ public class GnssManagerService {
|
||||
*/
|
||||
public boolean addGnssNavigationMessageListener(
|
||||
IGnssNavigationMessageListener listener, String packageName,
|
||||
@NonNull String listenerIdentifier) {
|
||||
@Nullable String featureId, @NonNull String listenerIdentifier) {
|
||||
synchronized (mGnssNavigationMessageListeners) {
|
||||
return addGnssDataListenerLocked(
|
||||
listener,
|
||||
packageName,
|
||||
featureId,
|
||||
listenerIdentifier,
|
||||
mGnssNavigationMessageProvider,
|
||||
mGnssNavigationMessageListeners,
|
||||
|
||||
@@ -1233,9 +1233,9 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
PowerManager.WakeLock mWakeLock;
|
||||
|
||||
private Receiver(ILocationListener listener, PendingIntent intent, int pid, int uid,
|
||||
String packageName, WorkSource workSource, boolean hideFromAppOps,
|
||||
@NonNull String listenerIdentifier) {
|
||||
super(new CallerIdentity(uid, pid, packageName, listenerIdentifier),
|
||||
String packageName, @Nullable String featureId, WorkSource workSource,
|
||||
boolean hideFromAppOps, @NonNull String listenerIdentifier) {
|
||||
super(new CallerIdentity(uid, pid, packageName, featureId, listenerIdentifier),
|
||||
"LocationListener");
|
||||
mListener = listener;
|
||||
mPendingIntent = intent;
|
||||
@@ -1360,7 +1360,8 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
if (!currentlyMonitoring) {
|
||||
if (allowMonitoring) {
|
||||
return mAppOps.startOpNoThrow(op, mCallerIdentity.mUid,
|
||||
mCallerIdentity.mPackageName) == AppOpsManager.MODE_ALLOWED;
|
||||
mCallerIdentity.mPackageName, false, mCallerIdentity.mFeatureId, null)
|
||||
== AppOpsManager.MODE_ALLOWED;
|
||||
}
|
||||
} else {
|
||||
if (!allowMonitoring
|
||||
@@ -1545,11 +1546,11 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
@Override
|
||||
public boolean addGnssBatchingCallback(IBatchedLocationCallback callback, String packageName,
|
||||
String listenerIdentifier) {
|
||||
String featureId, String listenerIdentifier) {
|
||||
Preconditions.checkNotNull(listenerIdentifier);
|
||||
|
||||
return mGnssManagerService == null ? false : mGnssManagerService.addGnssBatchingCallback(
|
||||
callback, packageName, listenerIdentifier);
|
||||
callback, packageName, featureId, listenerIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1712,10 +1713,10 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
}
|
||||
|
||||
private boolean reportLocationAccessNoThrow(int pid, int uid, String packageName,
|
||||
int allowedResolutionLevel, @Nullable String message) {
|
||||
@Nullable String featureId, int allowedResolutionLevel, @Nullable String message) {
|
||||
int op = resolutionLevelToOp(allowedResolutionLevel);
|
||||
if (op >= 0) {
|
||||
if (mAppOps.noteOpNoThrow(op, uid, packageName, null, message)
|
||||
if (mAppOps.noteOpNoThrow(op, uid, packageName, featureId, message)
|
||||
!= AppOpsManager.MODE_ALLOWED) {
|
||||
return false;
|
||||
}
|
||||
@@ -2149,12 +2150,12 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
@GuardedBy("mLock")
|
||||
private Receiver getReceiverLocked(ILocationListener listener, int pid, int uid,
|
||||
String packageName, WorkSource workSource, boolean hideFromAppOps,
|
||||
@NonNull String listenerIdentifier) {
|
||||
String packageName, @Nullable String featureId, WorkSource workSource,
|
||||
boolean hideFromAppOps, @NonNull String listenerIdentifier) {
|
||||
IBinder binder = listener.asBinder();
|
||||
Receiver receiver = mReceivers.get(binder);
|
||||
if (receiver == null) {
|
||||
receiver = new Receiver(listener, null, pid, uid, packageName, workSource,
|
||||
receiver = new Receiver(listener, null, pid, uid, packageName, featureId, workSource,
|
||||
hideFromAppOps, listenerIdentifier);
|
||||
if (!receiver.linkToListenerDeathNotificationLocked(
|
||||
receiver.getListener().asBinder())) {
|
||||
@@ -2167,10 +2168,11 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
@GuardedBy("mLock")
|
||||
private Receiver getReceiverLocked(PendingIntent intent, int pid, int uid, String packageName,
|
||||
WorkSource workSource, boolean hideFromAppOps, @NonNull String listenerIdentifier) {
|
||||
@Nullable String featureId, WorkSource workSource, boolean hideFromAppOps,
|
||||
@NonNull String listenerIdentifier) {
|
||||
Receiver receiver = mReceivers.get(intent);
|
||||
if (receiver == null) {
|
||||
receiver = new Receiver(null, intent, pid, uid, packageName, workSource,
|
||||
receiver = new Receiver(null, intent, pid, uid, packageName, featureId, workSource,
|
||||
hideFromAppOps, listenerIdentifier);
|
||||
mReceivers.put(intent, receiver);
|
||||
}
|
||||
@@ -2233,7 +2235,8 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
@Override
|
||||
public void requestLocationUpdates(LocationRequest request, ILocationListener listener,
|
||||
PendingIntent intent, String packageName, String listenerIdentifier) {
|
||||
PendingIntent intent, String packageName, String featureId,
|
||||
String listenerIdentifier) {
|
||||
Preconditions.checkNotNull(listenerIdentifier);
|
||||
|
||||
synchronized (mLock) {
|
||||
@@ -2289,11 +2292,11 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
Receiver receiver;
|
||||
if (intent != null) {
|
||||
receiver = getReceiverLocked(intent, pid, uid, packageName, workSource,
|
||||
hideFromAppOps, listenerIdentifier);
|
||||
receiver = getReceiverLocked(intent, pid, uid, packageName, featureId,
|
||||
workSource, hideFromAppOps, listenerIdentifier);
|
||||
} else {
|
||||
receiver = getReceiverLocked(listener, pid, uid, packageName, workSource,
|
||||
hideFromAppOps, listenerIdentifier);
|
||||
receiver = getReceiverLocked(listener, pid, uid, packageName, featureId,
|
||||
workSource, hideFromAppOps, listenerIdentifier);
|
||||
}
|
||||
requestLocationUpdatesLocked(sanitizedRequest, receiver, uid, packageName);
|
||||
} finally {
|
||||
@@ -2362,9 +2365,10 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
synchronized (mLock) {
|
||||
Receiver receiver;
|
||||
if (intent != null) {
|
||||
receiver = getReceiverLocked(intent, pid, uid, packageName, null, false, "");
|
||||
receiver = getReceiverLocked(intent, pid, uid, packageName, null, null, false, "");
|
||||
} else {
|
||||
receiver = getReceiverLocked(listener, pid, uid, packageName, null, false, "");
|
||||
receiver = getReceiverLocked(listener, pid, uid, packageName, null, null, false,
|
||||
"");
|
||||
}
|
||||
|
||||
long identity = Binder.clearCallingIdentity();
|
||||
@@ -2408,7 +2412,7 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLastLocation(LocationRequest r, String packageName) {
|
||||
public Location getLastLocation(LocationRequest r, String packageName, String featureId) {
|
||||
synchronized (mLock) {
|
||||
LocationRequest request = r != null ? r : DEFAULT_LOCATION_REQUEST;
|
||||
int allowedResolutionLevel = getCallerAllowedResolutionLevel();
|
||||
@@ -2483,8 +2487,8 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
}
|
||||
// Don't report location access if there is no last location to deliver.
|
||||
if (lastLocation != null) {
|
||||
if (!reportLocationAccessNoThrow(pid, uid, packageName, allowedResolutionLevel,
|
||||
null)) {
|
||||
if (!reportLocationAccessNoThrow(pid, uid, packageName, featureId,
|
||||
allowedResolutionLevel, null)) {
|
||||
if (D) {
|
||||
Log.d(TAG, "not returning last loc for no op app: " + packageName);
|
||||
}
|
||||
@@ -2501,9 +2505,9 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
@Override
|
||||
public boolean getCurrentLocation(LocationRequest locationRequest,
|
||||
ICancellationSignal remoteCancellationSignal, ILocationListener listener,
|
||||
String packageName, String listenerIdentifier) {
|
||||
String packageName, String featureId, String listenerIdentifier) {
|
||||
// side effect of validating locationRequest and packageName
|
||||
Location lastLocation = getLastLocation(locationRequest, packageName);
|
||||
Location lastLocation = getLastLocation(locationRequest, packageName, featureId);
|
||||
if (lastLocation != null) {
|
||||
long locationAgeMs = TimeUnit.NANOSECONDS.toMillis(
|
||||
SystemClock.elapsedRealtimeNanos() - lastLocation.getElapsedRealtimeNanos());
|
||||
@@ -2538,7 +2542,8 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
requestLocationUpdates(locationRequest, listener, null, packageName, listenerIdentifier);
|
||||
requestLocationUpdates(locationRequest, listener, null, packageName, featureId,
|
||||
listenerIdentifier);
|
||||
CancellationSignal cancellationSignal = CancellationSignal.fromTransport(
|
||||
remoteCancellationSignal);
|
||||
if (cancellationSignal != null) {
|
||||
@@ -2588,7 +2593,7 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
@Override
|
||||
public void requestGeofence(LocationRequest request, Geofence geofence, PendingIntent intent,
|
||||
String packageName, String listenerIdentifier) {
|
||||
String packageName, String featureId, String listenerIdentifier) {
|
||||
Preconditions.checkNotNull(listenerIdentifier);
|
||||
|
||||
if (request == null) request = DEFAULT_LOCATION_REQUEST;
|
||||
@@ -2636,7 +2641,7 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
}
|
||||
|
||||
mGeofenceManager.addFence(sanitizedRequest, geofence, intent, allowedResolutionLevel,
|
||||
uid, packageName, listenerIdentifier);
|
||||
uid, packageName, featureId, listenerIdentifier);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
@@ -2672,9 +2677,10 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerGnssStatusCallback(IGnssStatusListener listener, String packageName) {
|
||||
public boolean registerGnssStatusCallback(IGnssStatusListener listener, String packageName,
|
||||
String featureId) {
|
||||
return mGnssManagerService == null ? false : mGnssManagerService.registerGnssStatusCallback(
|
||||
listener, packageName);
|
||||
listener, packageName, featureId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2684,12 +2690,12 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
@Override
|
||||
public boolean addGnssMeasurementsListener(IGnssMeasurementsListener listener,
|
||||
String packageName, String listenerIdentifier) {
|
||||
String packageName, String featureId, String listenerIdentifier) {
|
||||
Preconditions.checkNotNull(listenerIdentifier);
|
||||
|
||||
return mGnssManagerService == null ? false
|
||||
: mGnssManagerService.addGnssMeasurementsListener(listener, packageName,
|
||||
listenerIdentifier);
|
||||
: mGnssManagerService.addGnssMeasurementsListener(listener, packageName, featureId,
|
||||
listenerIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2717,12 +2723,12 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
@Override
|
||||
public boolean addGnssNavigationMessageListener(IGnssNavigationMessageListener listener,
|
||||
String packageName, String listenerIdentifier) {
|
||||
String packageName, String featureId, String listenerIdentifier) {
|
||||
Preconditions.checkNotNull(listenerIdentifier);
|
||||
|
||||
return mGnssManagerService == null ? false
|
||||
: mGnssManagerService.addGnssNavigationMessageListener(listener, packageName,
|
||||
listenerIdentifier);
|
||||
featureId, listenerIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3028,6 +3034,7 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
receiver.mCallerIdentity.mPid,
|
||||
receiver.mCallerIdentity.mUid,
|
||||
receiver.mCallerIdentity.mPackageName,
|
||||
receiver.mCallerIdentity.mFeatureId,
|
||||
receiver.mAllowedResolutionLevel,
|
||||
"Location sent to " + receiver.mCallerIdentity.mListenerIdentifier)) {
|
||||
if (D) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.server.location;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents the calling process's uid, pid, and package name.
|
||||
@@ -25,13 +26,15 @@ public class CallerIdentity {
|
||||
public final int mUid;
|
||||
public final int mPid;
|
||||
public final String mPackageName;
|
||||
public final @Nullable String mFeatureId;
|
||||
public final @NonNull String mListenerIdentifier;
|
||||
|
||||
public CallerIdentity(int uid, int pid, String packageName,
|
||||
public CallerIdentity(int uid, int pid, String packageName, @Nullable String featureId,
|
||||
@NonNull String listenerIdentifier) {
|
||||
mUid = uid;
|
||||
mPid = pid;
|
||||
mPackageName = packageName;
|
||||
mFeatureId = featureId;
|
||||
mListenerIdentifier = listenerIdentifier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.server.location;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ContentResolver;
|
||||
@@ -152,7 +153,7 @@ public class GeofenceManager implements LocationListener, PendingIntent.OnFinish
|
||||
}
|
||||
|
||||
public void addFence(LocationRequest request, Geofence geofence, PendingIntent intent,
|
||||
int allowedResolutionLevel, int uid, String packageName,
|
||||
int allowedResolutionLevel, int uid, String packageName, @Nullable String featureId,
|
||||
@NonNull String listenerIdentifier) {
|
||||
if (D) {
|
||||
Slog.d(TAG, "addFence: request=" + request + ", geofence=" + geofence
|
||||
@@ -160,8 +161,8 @@ public class GeofenceManager implements LocationListener, PendingIntent.OnFinish
|
||||
}
|
||||
|
||||
GeofenceState state = new GeofenceState(geofence,
|
||||
request.getExpireAt(), allowedResolutionLevel, uid, packageName, listenerIdentifier,
|
||||
intent);
|
||||
request.getExpireAt(), allowedResolutionLevel, uid, packageName, featureId,
|
||||
listenerIdentifier, intent);
|
||||
synchronized (mLock) {
|
||||
// first make sure it doesn't already exist
|
||||
for (int i = mFences.size() - 1; i >= 0; i--) {
|
||||
@@ -304,7 +305,7 @@ public class GeofenceManager implements LocationListener, PendingIntent.OnFinish
|
||||
int op = LocationManagerService.resolutionLevelToOp(state.mAllowedResolutionLevel);
|
||||
if (op >= 0) {
|
||||
if (mAppOps.noteOpNoThrow(AppOpsManager.OP_FINE_LOCATION, state.mUid,
|
||||
state.mPackageName, null, state.mListenerIdentifier)
|
||||
state.mPackageName, state.mFeatureId, state.mListenerIdentifier)
|
||||
!= AppOpsManager.MODE_ALLOWED) {
|
||||
if (D) {
|
||||
Slog.d(TAG, "skipping geofence processing for no op app: "
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package com.android.server.location;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.PendingIntent;
|
||||
import android.location.Geofence;
|
||||
import android.location.Location;
|
||||
@@ -39,6 +40,7 @@ public class GeofenceState {
|
||||
public final int mAllowedResolutionLevel;
|
||||
public final int mUid;
|
||||
public final String mPackageName;
|
||||
public final @Nullable String mFeatureId;
|
||||
public final @NonNull String mListenerIdentifier;
|
||||
public final PendingIntent mIntent;
|
||||
|
||||
@@ -46,7 +48,8 @@ public class GeofenceState {
|
||||
double mDistanceToCenter; // current distance to center of fence
|
||||
|
||||
public GeofenceState(Geofence fence, long expireAt, int allowedResolutionLevel, int uid,
|
||||
String packageName, @NonNull String listenerIdentifier, PendingIntent intent) {
|
||||
String packageName, @Nullable String featureId, @NonNull String listenerIdentifier,
|
||||
PendingIntent intent) {
|
||||
mState = STATE_UNKNOWN;
|
||||
mDistanceToCenter = Double.MAX_VALUE;
|
||||
|
||||
@@ -55,6 +58,7 @@ public class GeofenceState {
|
||||
mAllowedResolutionLevel = allowedResolutionLevel;
|
||||
mUid = uid;
|
||||
mPackageName = packageName;
|
||||
mFeatureId = featureId;
|
||||
mListenerIdentifier = listenerIdentifier;
|
||||
mIntent = intent;
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ public abstract class RemoteListenerHelper<TListener extends IInterface> {
|
||||
}
|
||||
|
||||
return mAppOps.noteOpNoThrow(AppOpsManager.OP_FINE_LOCATION, callerIdentity.mUid,
|
||||
callerIdentity.mPackageName, null,
|
||||
callerIdentity.mPackageName, callerIdentity.mFeatureId,
|
||||
"Location sent to " + callerIdentity.mListenerIdentifier)
|
||||
== AppOpsManager.MODE_ALLOWED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user