Loading location/java/android/location/ILocationManager.aidl +14 −14 Original line number Diff line number Diff line Loading @@ -45,17 +45,17 @@ import com.android.internal.location.ProviderProperties; */ interface ILocationManager { Location getLastLocation(in LocationRequest request, String packageName, String featureId); Location getLastLocation(in LocationRequest request, String packageName, String attributionTag); boolean getCurrentLocation(in LocationRequest request, in ICancellationSignal cancellationSignal, in ILocationListener listener, String packageName, String featureId); String packageName, String attributionTag); void requestLocationUpdates(in LocationRequest request, in ILocationListener listener, in PendingIntent intent, String packageName, String featureId); in PendingIntent intent, String packageName, String attributionTag); void removeUpdates(in ILocationListener listener, in PendingIntent intent); void requestGeofence(in LocationRequest request, in Geofence geofence, in PendingIntent intent, String packageName, String featureId); in PendingIntent intent, String packageName, String attributionTag); void removeGeofence(in Geofence fence, in PendingIntent intent, String packageName); boolean geocoderIsPresent(); Loading @@ -70,24 +70,24 @@ interface ILocationManager int getGnssYearOfHardware(); String getGnssHardwareModelName(); void registerGnssStatusCallback(in IGnssStatusListener callback, String packageName, String featureId); void registerGnssStatusCallback(in IGnssStatusListener callback, String packageName, String attributionTag); void unregisterGnssStatusCallback(in IGnssStatusListener callback); void addGnssMeasurementsListener(in GnssRequest request, in IGnssMeasurementsListener listener, String packageName, String featureId); void addGnssMeasurementsListener(in GnssRequest request, in IGnssMeasurementsListener listener, String packageName, String attributionTag); void removeGnssMeasurementsListener(in IGnssMeasurementsListener listener); void addGnssAntennaInfoListener(in IGnssAntennaInfoListener listener, String packageName, String featureId); void addGnssAntennaInfoListener(in IGnssAntennaInfoListener listener, String packageName, String attributionTag); void removeGnssAntennaInfoListener(in IGnssAntennaInfoListener listener); void addGnssNavigationMessageListener(in IGnssNavigationMessageListener listener, String packageName, String featureId); void addGnssNavigationMessageListener(in IGnssNavigationMessageListener listener, String packageName, String attributionTag); void removeGnssNavigationMessageListener(in IGnssNavigationMessageListener listener); void injectGnssMeasurementCorrections(in GnssMeasurementCorrections corrections, String packageName); int getGnssBatchSize(String packageName); void addGnssBatchingCallback(in IBatchedLocationCallback callback, String packageName, String featureId); void addGnssBatchingCallback(in IBatchedLocationCallback callback, String packageName, String attributionTag); void removeGnssBatchingCallback(); void startGnssBatch(long periodNanos, boolean wakeOnFifoFull, String packageName, String featureId); void startGnssBatch(long periodNanos, boolean wakeOnFifoFull, String packageName, String attributionTag); void flushGnssBatch(String packageName); void stopGnssBatch(); void injectLocation(in Location location); Loading @@ -107,10 +107,10 @@ interface ILocationManager boolean isProviderEnabledForUser(String provider, int userId); boolean isLocationEnabledForUser(int userId); void setLocationEnabledForUser(boolean enabled, int userId); void addTestProvider(String name, in ProviderProperties properties, String packageName, String featureId); void removeTestProvider(String provider, String packageName, String featureId); void setTestProviderLocation(String provider, in Location location, String packageName, String featureId); void setTestProviderEnabled(String provider, boolean enabled, String packageName, String featureId); void addTestProvider(String name, in ProviderProperties properties, String packageName, String attributionTag); void removeTestProvider(String provider, String packageName, String attributionTag); void setTestProviderLocation(String provider, in Location location, String packageName, String attributionTag); void setTestProviderEnabled(String provider, boolean enabled, String packageName, String attributionTag); List<LocationRequest> getTestProviderCurrentRequests(String provider); LocationTime getGnssTimeMillis(); Loading location/java/android/location/util/identity/CallerIdentity.java +18 −18 Original line number Diff line number Diff line Loading @@ -84,9 +84,9 @@ public final class CallerIdentity { */ @VisibleForTesting public static CallerIdentity forTest(int uid, int pid, String packageName, @Nullable String featureId, @PermissionLevel int permissionLevel) { @Nullable String attributionTag, @PermissionLevel int permissionLevel) { return new CallerIdentity(uid, pid, packageName, featureId, return new CallerIdentity(uid, pid, packageName, attributionTag, permissionLevel); } Loading @@ -105,13 +105,13 @@ public final class CallerIdentity { * security exception will be thrown if it is invalid. */ public static CallerIdentity fromBinder(Context context, String packageName, @Nullable String featureId) { @Nullable String attributionTag) { int uid = Binder.getCallingUid(); if (!ArrayUtils.contains(context.getPackageManager().getPackagesForUid(uid), packageName)) { throw new SecurityException("invalid package \"" + packageName + "\" for uid " + uid); } return fromBinderUnsafe(context, packageName, featureId); return fromBinderUnsafe(context, packageName, attributionTag); } /** Loading @@ -121,9 +121,9 @@ public final class CallerIdentity { * an appops call. */ public static CallerIdentity fromBinderUnsafe(Context context, String packageName, @Nullable String featureId) { @Nullable String attributionTag) { return new CallerIdentity(Binder.getCallingUid(), Binder.getCallingPid(), packageName, featureId, packageName, attributionTag, getPermissionLevel(context, Binder.getCallingPid(), Binder.getCallingUid())); } Loading Loading @@ -190,8 +190,8 @@ public final class CallerIdentity { /** The calling package name. */ public final String packageName; /** The calling feature id. */ public final @Nullable String featureId; /** The calling attribution tag. */ public final @Nullable String attributionTag; /** * The calling location permission level. This field should only be used for validating Loading @@ -201,12 +201,12 @@ public final class CallerIdentity { public final @PermissionLevel int permissionLevel; private CallerIdentity(int uid, int pid, String packageName, @Nullable String featureId, @PermissionLevel int permissionLevel) { @Nullable String attributionTag, @PermissionLevel int permissionLevel) { this.uid = uid; this.pid = pid; this.userId = UserHandle.getUserId(uid); this.packageName = Objects.requireNonNull(packageName); this.featureId = featureId; this.attributionTag = attributionTag; this.permissionLevel = Preconditions.checkArgumentInRange(permissionLevel, PERMISSION_NONE, PERMISSION_FINE, "permissionLevel"); } Loading @@ -221,18 +221,18 @@ public final class CallerIdentity { @Override public String toString() { int length = 10 + packageName.length(); if (featureId != null) { length += featureId.length(); if (attributionTag != null) { length += attributionTag.length(); } StringBuilder builder = new StringBuilder(length); builder.append(pid).append("/").append(packageName); if (featureId != null) { if (attributionTag != null) { builder.append("["); if (featureId.startsWith(packageName)) { builder.append(featureId.substring(packageName.length())); if (attributionTag.startsWith(packageName)) { builder.append(attributionTag.substring(packageName.length())); } else { builder.append(featureId); builder.append(attributionTag); } builder.append("]"); } Loading @@ -251,11 +251,11 @@ public final class CallerIdentity { return uid == that.uid && pid == that.pid && packageName.equals(that.packageName) && Objects.equals(featureId, that.featureId); && Objects.equals(attributionTag, that.attributionTag); } @Override public int hashCode() { return Objects.hash(uid, pid, packageName, featureId); return Objects.hash(uid, pid, packageName, attributionTag); } } services/core/java/com/android/server/location/AppOpsHelper.java +4 −4 Original line number Diff line number Diff line Loading @@ -191,7 +191,7 @@ public class AppOpsHelper { AppOpsManager.OP_MOCK_LOCATION, callerIdentity.uid, callerIdentity.packageName, callerIdentity.featureId, callerIdentity.attributionTag, null) == AppOpsManager.MODE_ALLOWED; } finally { Binder.restoreCallingIdentity(identity); Loading @@ -210,7 +210,7 @@ public class AppOpsHelper { callerIdentity.uid, callerIdentity.packageName, false, callerIdentity.featureId, callerIdentity.attributionTag, null) == AppOpsManager.MODE_ALLOWED; } finally { Binder.restoreCallingIdentity(identity); Loading @@ -228,7 +228,7 @@ public class AppOpsHelper { appOp, callerIdentity.uid, callerIdentity.packageName, callerIdentity.featureId); callerIdentity.attributionTag); } finally { Binder.restoreCallingIdentity(identity); } Loading @@ -245,7 +245,7 @@ public class AppOpsHelper { appOp, callerIdentity.uid, callerIdentity.packageName, callerIdentity.featureId, callerIdentity.attributionTag, null) == AppOpsManager.MODE_ALLOWED; } finally { Binder.restoreCallingIdentity(identity); Loading services/core/java/com/android/server/location/GeofenceManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -254,7 +254,7 @@ public class GeofenceManager implements LocationListener, PendingIntent.OnFinish int op = CallerIdentity.asAppOp(identity.permissionLevel); if (op >= 0) { if (mAppOps.noteOpNoThrow(AppOpsManager.OP_FINE_LOCATION, identity.uid, identity.packageName, identity.featureId, null) identity.packageName, identity.attributionTag, null) != AppOpsManager.MODE_ALLOWED) { continue; } Loading services/core/java/com/android/server/location/LocationManagerService.java +41 −32 Original line number Diff line number Diff line Loading @@ -1343,9 +1343,9 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void addGnssBatchingCallback(IBatchedLocationCallback callback, String packageName, String featureId) { String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.addGnssBatchingCallback(callback, packageName, featureId); mGnssManagerService.addGnssBatchingCallback(callback, packageName, attributionTag); } } Loading @@ -1358,9 +1358,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void startGnssBatch(long periodNanos, boolean wakeOnFifoFull, String packageName, String featureId) { String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.startGnssBatch(periodNanos, wakeOnFifoFull, packageName, featureId); mGnssManagerService.startGnssBatch(periodNanos, wakeOnFifoFull, packageName, attributionTag); } } Loading Loading @@ -1687,7 +1688,7 @@ public class LocationManagerService extends ILocationManager.Stub { // Update statistics for historical location requests by package/provider mRequestStatistics.startRequesting( mReceiver.mCallerIdentity.packageName, mReceiver.mCallerIdentity.featureId, mReceiver.mCallerIdentity.packageName, mReceiver.mCallerIdentity.attributionTag, provider, request.getInterval(), mIsForegroundUid); } Loading @@ -1697,7 +1698,7 @@ public class LocationManagerService extends ILocationManager.Stub { private void updateForeground(boolean isForeground) { mIsForegroundUid = isForeground; mRequestStatistics.updateForeground( mReceiver.mCallerIdentity.packageName, mReceiver.mCallerIdentity.featureId, mReceiver.mCallerIdentity.packageName, mReceiver.mCallerIdentity.attributionTag, mProvider, isForeground); } Loading @@ -1706,7 +1707,8 @@ public class LocationManagerService extends ILocationManager.Stub { */ private void disposeLocked(boolean removeReceiver) { CallerIdentity identity = mReceiver.mCallerIdentity; mRequestStatistics.stopRequesting(identity.packageName, identity.featureId, mProvider); mRequestStatistics.stopRequesting(identity.packageName, identity.attributionTag, mProvider); mLocationUsageLogger.logLocationApiUsage( LocationStatsEnums.USAGE_ENDED, Loading Loading @@ -1827,12 +1829,12 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void requestLocationUpdates(LocationRequest request, ILocationListener listener, PendingIntent intent, String packageName, String featureId) { PendingIntent intent, String packageName, String attributionTag) { if (request == null) { request = DEFAULT_LOCATION_REQUEST; } CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, attributionTag); identity.enforceLocationPermission(PERMISSION_COARSE); WorkSource workSource = request.getWorkSource(); Loading Loading @@ -1978,13 +1980,15 @@ public class LocationManagerService extends ILocationManager.Stub { } @Override public Location getLastLocation(LocationRequest request, String packageName, String featureId) { public Location getLastLocation(LocationRequest request, String packageName, String attributionTag) { if (request == null) { request = DEFAULT_LOCATION_REQUEST; } // unsafe is ok because app ops will verify the package name CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, attributionTag); identity.enforceLocationPermission(PERMISSION_COARSE); if (mSettingsHelper.isLocationPackageBlacklisted(identity.userId, identity.packageName)) { Loading Loading @@ -2018,9 +2022,9 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public boolean getCurrentLocation(LocationRequest locationRequest, ICancellationSignal remoteCancellationSignal, ILocationListener listener, String packageName, String featureId) { String packageName, String attributionTag) { // side effect of validating locationRequest and packageName Location lastLocation = getLastLocation(locationRequest, packageName, featureId); Location lastLocation = getLastLocation(locationRequest, packageName, attributionTag); if (lastLocation != null) { long locationAgeMs = NANOSECONDS.toMillis( SystemClock.elapsedRealtimeNanos() - lastLocation.getElapsedRealtimeNanos()); Loading @@ -2043,7 +2047,7 @@ public class LocationManagerService extends ILocationManager.Stub { } } requestLocationUpdates(locationRequest, listener, null, packageName, featureId); requestLocationUpdates(locationRequest, listener, null, packageName, attributionTag); CancellationSignal cancellationSignal = CancellationSignal.fromTransport( remoteCancellationSignal); if (cancellationSignal != null) { Loading Loading @@ -2091,12 +2095,12 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void requestGeofence(LocationRequest request, Geofence geofence, PendingIntent intent, String packageName, String featureId) { String packageName, String attributionTag) { if (request == null) { request = DEFAULT_LOCATION_REQUEST; } CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, attributionTag); identity.enforceLocationPermission(PERMISSION_COARSE); Objects.requireNonNull(intent); Loading Loading @@ -2159,9 +2163,9 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void registerGnssStatusCallback(IGnssStatusListener listener, String packageName, String featureId) { String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.registerGnssStatusCallback(listener, packageName, featureId); mGnssManagerService.registerGnssStatusCallback(listener, packageName, attributionTag); } } Loading @@ -2174,10 +2178,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void addGnssMeasurementsListener(@Nullable GnssRequest request, IGnssMeasurementsListener listener, String packageName, String featureId) { IGnssMeasurementsListener listener, String packageName, String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.addGnssMeasurementsListener(request, listener, packageName, featureId); attributionTag); } } Loading Loading @@ -2206,9 +2210,9 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void addGnssAntennaInfoListener(IGnssAntennaInfoListener listener, String packageName, String featureId) { String packageName, String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.addGnssAntennaInfoListener(listener, packageName, featureId); mGnssManagerService.addGnssAntennaInfoListener(listener, packageName, attributionTag); } } Loading @@ -2221,9 +2225,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void addGnssNavigationMessageListener(IGnssNavigationMessageListener listener, String packageName, String featureId) { String packageName, String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.addGnssNavigationMessageListener(listener, packageName, featureId); mGnssManagerService.addGnssNavigationMessageListener(listener, packageName, attributionTag); } } Loading Loading @@ -2547,9 +2552,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void addTestProvider(String provider, ProviderProperties properties, String packageName, String featureId) { String packageName, String attributionTag) { // unsafe is ok because app ops will verify the package name CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, attributionTag); if (!mAppOpsHelper.noteMockLocationAccess(identity)) { return; } Loading @@ -2566,9 +2572,10 @@ public class LocationManagerService extends ILocationManager.Stub { } @Override public void removeTestProvider(String provider, String packageName, String featureId) { public void removeTestProvider(String provider, String packageName, String attributionTag) { // unsafe is ok because app ops will verify the package name CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, attributionTag); if (!mAppOpsHelper.noteMockLocationAccess(identity)) { return; } Loading @@ -2588,9 +2595,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void setTestProviderLocation(String provider, Location location, String packageName, String featureId) { String attributionTag) { // unsafe is ok because app ops will verify the package name CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, attributionTag); if (!mAppOpsHelper.noteMockLocationAccess(identity)) { return; } Loading @@ -2608,9 +2616,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void setTestProviderEnabled(String provider, boolean enabled, String packageName, String featureId) { String attributionTag) { // unsafe is ok because app ops will verify the package name CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, attributionTag); if (!mAppOpsHelper.noteMockLocationAccess(identity)) { return; } Loading Loading
location/java/android/location/ILocationManager.aidl +14 −14 Original line number Diff line number Diff line Loading @@ -45,17 +45,17 @@ import com.android.internal.location.ProviderProperties; */ interface ILocationManager { Location getLastLocation(in LocationRequest request, String packageName, String featureId); Location getLastLocation(in LocationRequest request, String packageName, String attributionTag); boolean getCurrentLocation(in LocationRequest request, in ICancellationSignal cancellationSignal, in ILocationListener listener, String packageName, String featureId); String packageName, String attributionTag); void requestLocationUpdates(in LocationRequest request, in ILocationListener listener, in PendingIntent intent, String packageName, String featureId); in PendingIntent intent, String packageName, String attributionTag); void removeUpdates(in ILocationListener listener, in PendingIntent intent); void requestGeofence(in LocationRequest request, in Geofence geofence, in PendingIntent intent, String packageName, String featureId); in PendingIntent intent, String packageName, String attributionTag); void removeGeofence(in Geofence fence, in PendingIntent intent, String packageName); boolean geocoderIsPresent(); Loading @@ -70,24 +70,24 @@ interface ILocationManager int getGnssYearOfHardware(); String getGnssHardwareModelName(); void registerGnssStatusCallback(in IGnssStatusListener callback, String packageName, String featureId); void registerGnssStatusCallback(in IGnssStatusListener callback, String packageName, String attributionTag); void unregisterGnssStatusCallback(in IGnssStatusListener callback); void addGnssMeasurementsListener(in GnssRequest request, in IGnssMeasurementsListener listener, String packageName, String featureId); void addGnssMeasurementsListener(in GnssRequest request, in IGnssMeasurementsListener listener, String packageName, String attributionTag); void removeGnssMeasurementsListener(in IGnssMeasurementsListener listener); void addGnssAntennaInfoListener(in IGnssAntennaInfoListener listener, String packageName, String featureId); void addGnssAntennaInfoListener(in IGnssAntennaInfoListener listener, String packageName, String attributionTag); void removeGnssAntennaInfoListener(in IGnssAntennaInfoListener listener); void addGnssNavigationMessageListener(in IGnssNavigationMessageListener listener, String packageName, String featureId); void addGnssNavigationMessageListener(in IGnssNavigationMessageListener listener, String packageName, String attributionTag); void removeGnssNavigationMessageListener(in IGnssNavigationMessageListener listener); void injectGnssMeasurementCorrections(in GnssMeasurementCorrections corrections, String packageName); int getGnssBatchSize(String packageName); void addGnssBatchingCallback(in IBatchedLocationCallback callback, String packageName, String featureId); void addGnssBatchingCallback(in IBatchedLocationCallback callback, String packageName, String attributionTag); void removeGnssBatchingCallback(); void startGnssBatch(long periodNanos, boolean wakeOnFifoFull, String packageName, String featureId); void startGnssBatch(long periodNanos, boolean wakeOnFifoFull, String packageName, String attributionTag); void flushGnssBatch(String packageName); void stopGnssBatch(); void injectLocation(in Location location); Loading @@ -107,10 +107,10 @@ interface ILocationManager boolean isProviderEnabledForUser(String provider, int userId); boolean isLocationEnabledForUser(int userId); void setLocationEnabledForUser(boolean enabled, int userId); void addTestProvider(String name, in ProviderProperties properties, String packageName, String featureId); void removeTestProvider(String provider, String packageName, String featureId); void setTestProviderLocation(String provider, in Location location, String packageName, String featureId); void setTestProviderEnabled(String provider, boolean enabled, String packageName, String featureId); void addTestProvider(String name, in ProviderProperties properties, String packageName, String attributionTag); void removeTestProvider(String provider, String packageName, String attributionTag); void setTestProviderLocation(String provider, in Location location, String packageName, String attributionTag); void setTestProviderEnabled(String provider, boolean enabled, String packageName, String attributionTag); List<LocationRequest> getTestProviderCurrentRequests(String provider); LocationTime getGnssTimeMillis(); Loading
location/java/android/location/util/identity/CallerIdentity.java +18 −18 Original line number Diff line number Diff line Loading @@ -84,9 +84,9 @@ public final class CallerIdentity { */ @VisibleForTesting public static CallerIdentity forTest(int uid, int pid, String packageName, @Nullable String featureId, @PermissionLevel int permissionLevel) { @Nullable String attributionTag, @PermissionLevel int permissionLevel) { return new CallerIdentity(uid, pid, packageName, featureId, return new CallerIdentity(uid, pid, packageName, attributionTag, permissionLevel); } Loading @@ -105,13 +105,13 @@ public final class CallerIdentity { * security exception will be thrown if it is invalid. */ public static CallerIdentity fromBinder(Context context, String packageName, @Nullable String featureId) { @Nullable String attributionTag) { int uid = Binder.getCallingUid(); if (!ArrayUtils.contains(context.getPackageManager().getPackagesForUid(uid), packageName)) { throw new SecurityException("invalid package \"" + packageName + "\" for uid " + uid); } return fromBinderUnsafe(context, packageName, featureId); return fromBinderUnsafe(context, packageName, attributionTag); } /** Loading @@ -121,9 +121,9 @@ public final class CallerIdentity { * an appops call. */ public static CallerIdentity fromBinderUnsafe(Context context, String packageName, @Nullable String featureId) { @Nullable String attributionTag) { return new CallerIdentity(Binder.getCallingUid(), Binder.getCallingPid(), packageName, featureId, packageName, attributionTag, getPermissionLevel(context, Binder.getCallingPid(), Binder.getCallingUid())); } Loading Loading @@ -190,8 +190,8 @@ public final class CallerIdentity { /** The calling package name. */ public final String packageName; /** The calling feature id. */ public final @Nullable String featureId; /** The calling attribution tag. */ public final @Nullable String attributionTag; /** * The calling location permission level. This field should only be used for validating Loading @@ -201,12 +201,12 @@ public final class CallerIdentity { public final @PermissionLevel int permissionLevel; private CallerIdentity(int uid, int pid, String packageName, @Nullable String featureId, @PermissionLevel int permissionLevel) { @Nullable String attributionTag, @PermissionLevel int permissionLevel) { this.uid = uid; this.pid = pid; this.userId = UserHandle.getUserId(uid); this.packageName = Objects.requireNonNull(packageName); this.featureId = featureId; this.attributionTag = attributionTag; this.permissionLevel = Preconditions.checkArgumentInRange(permissionLevel, PERMISSION_NONE, PERMISSION_FINE, "permissionLevel"); } Loading @@ -221,18 +221,18 @@ public final class CallerIdentity { @Override public String toString() { int length = 10 + packageName.length(); if (featureId != null) { length += featureId.length(); if (attributionTag != null) { length += attributionTag.length(); } StringBuilder builder = new StringBuilder(length); builder.append(pid).append("/").append(packageName); if (featureId != null) { if (attributionTag != null) { builder.append("["); if (featureId.startsWith(packageName)) { builder.append(featureId.substring(packageName.length())); if (attributionTag.startsWith(packageName)) { builder.append(attributionTag.substring(packageName.length())); } else { builder.append(featureId); builder.append(attributionTag); } builder.append("]"); } Loading @@ -251,11 +251,11 @@ public final class CallerIdentity { return uid == that.uid && pid == that.pid && packageName.equals(that.packageName) && Objects.equals(featureId, that.featureId); && Objects.equals(attributionTag, that.attributionTag); } @Override public int hashCode() { return Objects.hash(uid, pid, packageName, featureId); return Objects.hash(uid, pid, packageName, attributionTag); } }
services/core/java/com/android/server/location/AppOpsHelper.java +4 −4 Original line number Diff line number Diff line Loading @@ -191,7 +191,7 @@ public class AppOpsHelper { AppOpsManager.OP_MOCK_LOCATION, callerIdentity.uid, callerIdentity.packageName, callerIdentity.featureId, callerIdentity.attributionTag, null) == AppOpsManager.MODE_ALLOWED; } finally { Binder.restoreCallingIdentity(identity); Loading @@ -210,7 +210,7 @@ public class AppOpsHelper { callerIdentity.uid, callerIdentity.packageName, false, callerIdentity.featureId, callerIdentity.attributionTag, null) == AppOpsManager.MODE_ALLOWED; } finally { Binder.restoreCallingIdentity(identity); Loading @@ -228,7 +228,7 @@ public class AppOpsHelper { appOp, callerIdentity.uid, callerIdentity.packageName, callerIdentity.featureId); callerIdentity.attributionTag); } finally { Binder.restoreCallingIdentity(identity); } Loading @@ -245,7 +245,7 @@ public class AppOpsHelper { appOp, callerIdentity.uid, callerIdentity.packageName, callerIdentity.featureId, callerIdentity.attributionTag, null) == AppOpsManager.MODE_ALLOWED; } finally { Binder.restoreCallingIdentity(identity); Loading
services/core/java/com/android/server/location/GeofenceManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -254,7 +254,7 @@ public class GeofenceManager implements LocationListener, PendingIntent.OnFinish int op = CallerIdentity.asAppOp(identity.permissionLevel); if (op >= 0) { if (mAppOps.noteOpNoThrow(AppOpsManager.OP_FINE_LOCATION, identity.uid, identity.packageName, identity.featureId, null) identity.packageName, identity.attributionTag, null) != AppOpsManager.MODE_ALLOWED) { continue; } Loading
services/core/java/com/android/server/location/LocationManagerService.java +41 −32 Original line number Diff line number Diff line Loading @@ -1343,9 +1343,9 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void addGnssBatchingCallback(IBatchedLocationCallback callback, String packageName, String featureId) { String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.addGnssBatchingCallback(callback, packageName, featureId); mGnssManagerService.addGnssBatchingCallback(callback, packageName, attributionTag); } } Loading @@ -1358,9 +1358,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void startGnssBatch(long periodNanos, boolean wakeOnFifoFull, String packageName, String featureId) { String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.startGnssBatch(periodNanos, wakeOnFifoFull, packageName, featureId); mGnssManagerService.startGnssBatch(periodNanos, wakeOnFifoFull, packageName, attributionTag); } } Loading Loading @@ -1687,7 +1688,7 @@ public class LocationManagerService extends ILocationManager.Stub { // Update statistics for historical location requests by package/provider mRequestStatistics.startRequesting( mReceiver.mCallerIdentity.packageName, mReceiver.mCallerIdentity.featureId, mReceiver.mCallerIdentity.packageName, mReceiver.mCallerIdentity.attributionTag, provider, request.getInterval(), mIsForegroundUid); } Loading @@ -1697,7 +1698,7 @@ public class LocationManagerService extends ILocationManager.Stub { private void updateForeground(boolean isForeground) { mIsForegroundUid = isForeground; mRequestStatistics.updateForeground( mReceiver.mCallerIdentity.packageName, mReceiver.mCallerIdentity.featureId, mReceiver.mCallerIdentity.packageName, mReceiver.mCallerIdentity.attributionTag, mProvider, isForeground); } Loading @@ -1706,7 +1707,8 @@ public class LocationManagerService extends ILocationManager.Stub { */ private void disposeLocked(boolean removeReceiver) { CallerIdentity identity = mReceiver.mCallerIdentity; mRequestStatistics.stopRequesting(identity.packageName, identity.featureId, mProvider); mRequestStatistics.stopRequesting(identity.packageName, identity.attributionTag, mProvider); mLocationUsageLogger.logLocationApiUsage( LocationStatsEnums.USAGE_ENDED, Loading Loading @@ -1827,12 +1829,12 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void requestLocationUpdates(LocationRequest request, ILocationListener listener, PendingIntent intent, String packageName, String featureId) { PendingIntent intent, String packageName, String attributionTag) { if (request == null) { request = DEFAULT_LOCATION_REQUEST; } CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, attributionTag); identity.enforceLocationPermission(PERMISSION_COARSE); WorkSource workSource = request.getWorkSource(); Loading Loading @@ -1978,13 +1980,15 @@ public class LocationManagerService extends ILocationManager.Stub { } @Override public Location getLastLocation(LocationRequest request, String packageName, String featureId) { public Location getLastLocation(LocationRequest request, String packageName, String attributionTag) { if (request == null) { request = DEFAULT_LOCATION_REQUEST; } // unsafe is ok because app ops will verify the package name CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, attributionTag); identity.enforceLocationPermission(PERMISSION_COARSE); if (mSettingsHelper.isLocationPackageBlacklisted(identity.userId, identity.packageName)) { Loading Loading @@ -2018,9 +2022,9 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public boolean getCurrentLocation(LocationRequest locationRequest, ICancellationSignal remoteCancellationSignal, ILocationListener listener, String packageName, String featureId) { String packageName, String attributionTag) { // side effect of validating locationRequest and packageName Location lastLocation = getLastLocation(locationRequest, packageName, featureId); Location lastLocation = getLastLocation(locationRequest, packageName, attributionTag); if (lastLocation != null) { long locationAgeMs = NANOSECONDS.toMillis( SystemClock.elapsedRealtimeNanos() - lastLocation.getElapsedRealtimeNanos()); Loading @@ -2043,7 +2047,7 @@ public class LocationManagerService extends ILocationManager.Stub { } } requestLocationUpdates(locationRequest, listener, null, packageName, featureId); requestLocationUpdates(locationRequest, listener, null, packageName, attributionTag); CancellationSignal cancellationSignal = CancellationSignal.fromTransport( remoteCancellationSignal); if (cancellationSignal != null) { Loading Loading @@ -2091,12 +2095,12 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void requestGeofence(LocationRequest request, Geofence geofence, PendingIntent intent, String packageName, String featureId) { String packageName, String attributionTag) { if (request == null) { request = DEFAULT_LOCATION_REQUEST; } CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, attributionTag); identity.enforceLocationPermission(PERMISSION_COARSE); Objects.requireNonNull(intent); Loading Loading @@ -2159,9 +2163,9 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void registerGnssStatusCallback(IGnssStatusListener listener, String packageName, String featureId) { String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.registerGnssStatusCallback(listener, packageName, featureId); mGnssManagerService.registerGnssStatusCallback(listener, packageName, attributionTag); } } Loading @@ -2174,10 +2178,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void addGnssMeasurementsListener(@Nullable GnssRequest request, IGnssMeasurementsListener listener, String packageName, String featureId) { IGnssMeasurementsListener listener, String packageName, String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.addGnssMeasurementsListener(request, listener, packageName, featureId); attributionTag); } } Loading Loading @@ -2206,9 +2210,9 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void addGnssAntennaInfoListener(IGnssAntennaInfoListener listener, String packageName, String featureId) { String packageName, String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.addGnssAntennaInfoListener(listener, packageName, featureId); mGnssManagerService.addGnssAntennaInfoListener(listener, packageName, attributionTag); } } Loading @@ -2221,9 +2225,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void addGnssNavigationMessageListener(IGnssNavigationMessageListener listener, String packageName, String featureId) { String packageName, String attributionTag) { if (mGnssManagerService != null) { mGnssManagerService.addGnssNavigationMessageListener(listener, packageName, featureId); mGnssManagerService.addGnssNavigationMessageListener(listener, packageName, attributionTag); } } Loading Loading @@ -2547,9 +2552,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void addTestProvider(String provider, ProviderProperties properties, String packageName, String featureId) { String packageName, String attributionTag) { // unsafe is ok because app ops will verify the package name CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, attributionTag); if (!mAppOpsHelper.noteMockLocationAccess(identity)) { return; } Loading @@ -2566,9 +2572,10 @@ public class LocationManagerService extends ILocationManager.Stub { } @Override public void removeTestProvider(String provider, String packageName, String featureId) { public void removeTestProvider(String provider, String packageName, String attributionTag) { // unsafe is ok because app ops will verify the package name CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, attributionTag); if (!mAppOpsHelper.noteMockLocationAccess(identity)) { return; } Loading @@ -2588,9 +2595,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void setTestProviderLocation(String provider, Location location, String packageName, String featureId) { String attributionTag) { // unsafe is ok because app ops will verify the package name CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, attributionTag); if (!mAppOpsHelper.noteMockLocationAccess(identity)) { return; } Loading @@ -2608,9 +2616,10 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void setTestProviderEnabled(String provider, boolean enabled, String packageName, String featureId) { String attributionTag) { // unsafe is ok because app ops will verify the package name CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, featureId); CallerIdentity identity = CallerIdentity.fromBinderUnsafe(mContext, packageName, attributionTag); if (!mAppOpsHelper.noteMockLocationAccess(identity)) { return; } Loading