Loading location/java/android/location/util/identity/CallerIdentity.java +2 −2 Original line number Diff line number Diff line Loading @@ -150,8 +150,8 @@ public final class CallerIdentity { return mListenerId; } /** Returns true if this represents a system identity. */ public boolean isSystem() { /** Returns true if this represents a system server identity. */ public boolean isSystemServer() { return mUid == Process.SYSTEM_UID; } Loading services/core/java/com/android/server/location/geofence/GeofenceManager.java +22 −6 Original line number Diff line number Diff line Loading @@ -322,12 +322,28 @@ public class GeofenceManager extends @Override protected boolean isActive(GeofenceRegistration registration) { CallerIdentity identity = registration.getIdentity(); return registration.isPermitted() && (identity.isSystem() || mUserInfoHelper.isCurrentUserId(identity.getUserId())) && mSettingsHelper.isLocationEnabled(identity.getUserId()) && !mSettingsHelper.isLocationPackageBlacklisted(identity.getUserId(), identity.getPackageName()); return registration.isPermitted() && isActive(registration.getIdentity()); } private boolean isActive(CallerIdentity identity) { if (identity.isSystemServer()) { if (!mSettingsHelper.isLocationEnabled(mUserInfoHelper.getCurrentUserId())) { return false; } } else { if (!mSettingsHelper.isLocationEnabled(identity.getUserId())) { return false; } if (!mUserInfoHelper.isCurrentUserId(identity.getUserId())) { return false; } if (mSettingsHelper.isLocationPackageBlacklisted(identity.getUserId(), identity.getPackageName())) { return false; } } return true; } @Override Loading services/core/java/com/android/server/location/gnss/GnssListenerMultiplexer.java +24 −5 Original line number Diff line number Diff line Loading @@ -266,11 +266,30 @@ public abstract class GnssListenerMultiplexer<TRequest, TListener extends IInter CallerIdentity identity = registration.getIdentity(); return registration.isPermitted() && (registration.isForeground() || isBackgroundRestrictionExempt(identity)) && (identity.isSystem() || mUserInfoHelper.isCurrentUserId(identity.getUserId())) && mLocationManagerInternal.isProviderEnabledForUser(GPS_PROVIDER, identity.getUserId()) && !mSettingsHelper.isLocationPackageBlacklisted(identity.getUserId(), identity.getPackageName()); && isActive(identity); } private boolean isActive(CallerIdentity identity) { if (identity.isSystemServer()) { if (!mLocationManagerInternal.isProviderEnabledForUser(GPS_PROVIDER, mUserInfoHelper.getCurrentUserId())) { return false; } } else { if (!mLocationManagerInternal.isProviderEnabledForUser(GPS_PROVIDER, identity.getUserId())) { return false; } if (!mUserInfoHelper.isCurrentUserId(identity.getUserId())) { return false; } if (mSettingsHelper.isLocationPackageBlacklisted(identity.getUserId(), identity.getPackageName())) { return false; } } return true; } private boolean isBackgroundRestrictionExempt(CallerIdentity identity) { Loading services/core/java/com/android/server/location/injector/SystemUserInfoHelper.java +15 −9 Original line number Diff line number Diff line Loading @@ -88,11 +88,6 @@ public class SystemUserInfoHelper extends UserInfoHelper { return mUserManager; } /** * Returns an array of running user ids. This will include all running users, and will also * include any profiles of the running users. The caller must never mutate the returned * array. */ @Override public int[] getRunningUserIds() { IActivityManager activityManager = getActivityManager(); Loading @@ -110,10 +105,6 @@ public class SystemUserInfoHelper extends UserInfoHelper { } } /** * Returns true if the given user id is either the current user or a profile of the current * user. */ @Override public boolean isCurrentUserId(@UserIdInt int userId) { ActivityManagerInternal activityManagerInternal = getActivityManagerInternal(); Loading @@ -129,6 +120,21 @@ public class SystemUserInfoHelper extends UserInfoHelper { } } @Override public @UserIdInt int getCurrentUserId() { ActivityManagerInternal activityManagerInternal = getActivityManagerInternal(); if (activityManagerInternal != null) { final long identity = Binder.clearCallingIdentity(); try { return activityManagerInternal.getCurrentUserId(); } finally { Binder.restoreCallingIdentity(identity); } } else { return UserHandle.USER_NULL; } } @Override protected int[] getProfileIds(@UserIdInt int userId) { UserManager userManager = getUserManager(); Loading services/core/java/com/android/server/location/injector/UserInfoHelper.java +6 −0 Original line number Diff line number Diff line Loading @@ -132,6 +132,12 @@ public abstract class UserInfoHelper { */ public abstract boolean isCurrentUserId(@UserIdInt int userId); /** * Returns the current user id. Where possible, prefer to use {@link #isCurrentUserId(int)} * instead, as that method has more flexibility. */ public abstract @UserIdInt int getCurrentUserId(); protected abstract int[] getProfileIds(@UserIdInt int userId); /** Loading Loading
location/java/android/location/util/identity/CallerIdentity.java +2 −2 Original line number Diff line number Diff line Loading @@ -150,8 +150,8 @@ public final class CallerIdentity { return mListenerId; } /** Returns true if this represents a system identity. */ public boolean isSystem() { /** Returns true if this represents a system server identity. */ public boolean isSystemServer() { return mUid == Process.SYSTEM_UID; } Loading
services/core/java/com/android/server/location/geofence/GeofenceManager.java +22 −6 Original line number Diff line number Diff line Loading @@ -322,12 +322,28 @@ public class GeofenceManager extends @Override protected boolean isActive(GeofenceRegistration registration) { CallerIdentity identity = registration.getIdentity(); return registration.isPermitted() && (identity.isSystem() || mUserInfoHelper.isCurrentUserId(identity.getUserId())) && mSettingsHelper.isLocationEnabled(identity.getUserId()) && !mSettingsHelper.isLocationPackageBlacklisted(identity.getUserId(), identity.getPackageName()); return registration.isPermitted() && isActive(registration.getIdentity()); } private boolean isActive(CallerIdentity identity) { if (identity.isSystemServer()) { if (!mSettingsHelper.isLocationEnabled(mUserInfoHelper.getCurrentUserId())) { return false; } } else { if (!mSettingsHelper.isLocationEnabled(identity.getUserId())) { return false; } if (!mUserInfoHelper.isCurrentUserId(identity.getUserId())) { return false; } if (mSettingsHelper.isLocationPackageBlacklisted(identity.getUserId(), identity.getPackageName())) { return false; } } return true; } @Override Loading
services/core/java/com/android/server/location/gnss/GnssListenerMultiplexer.java +24 −5 Original line number Diff line number Diff line Loading @@ -266,11 +266,30 @@ public abstract class GnssListenerMultiplexer<TRequest, TListener extends IInter CallerIdentity identity = registration.getIdentity(); return registration.isPermitted() && (registration.isForeground() || isBackgroundRestrictionExempt(identity)) && (identity.isSystem() || mUserInfoHelper.isCurrentUserId(identity.getUserId())) && mLocationManagerInternal.isProviderEnabledForUser(GPS_PROVIDER, identity.getUserId()) && !mSettingsHelper.isLocationPackageBlacklisted(identity.getUserId(), identity.getPackageName()); && isActive(identity); } private boolean isActive(CallerIdentity identity) { if (identity.isSystemServer()) { if (!mLocationManagerInternal.isProviderEnabledForUser(GPS_PROVIDER, mUserInfoHelper.getCurrentUserId())) { return false; } } else { if (!mLocationManagerInternal.isProviderEnabledForUser(GPS_PROVIDER, identity.getUserId())) { return false; } if (!mUserInfoHelper.isCurrentUserId(identity.getUserId())) { return false; } if (mSettingsHelper.isLocationPackageBlacklisted(identity.getUserId(), identity.getPackageName())) { return false; } } return true; } private boolean isBackgroundRestrictionExempt(CallerIdentity identity) { Loading
services/core/java/com/android/server/location/injector/SystemUserInfoHelper.java +15 −9 Original line number Diff line number Diff line Loading @@ -88,11 +88,6 @@ public class SystemUserInfoHelper extends UserInfoHelper { return mUserManager; } /** * Returns an array of running user ids. This will include all running users, and will also * include any profiles of the running users. The caller must never mutate the returned * array. */ @Override public int[] getRunningUserIds() { IActivityManager activityManager = getActivityManager(); Loading @@ -110,10 +105,6 @@ public class SystemUserInfoHelper extends UserInfoHelper { } } /** * Returns true if the given user id is either the current user or a profile of the current * user. */ @Override public boolean isCurrentUserId(@UserIdInt int userId) { ActivityManagerInternal activityManagerInternal = getActivityManagerInternal(); Loading @@ -129,6 +120,21 @@ public class SystemUserInfoHelper extends UserInfoHelper { } } @Override public @UserIdInt int getCurrentUserId() { ActivityManagerInternal activityManagerInternal = getActivityManagerInternal(); if (activityManagerInternal != null) { final long identity = Binder.clearCallingIdentity(); try { return activityManagerInternal.getCurrentUserId(); } finally { Binder.restoreCallingIdentity(identity); } } else { return UserHandle.USER_NULL; } } @Override protected int[] getProfileIds(@UserIdInt int userId) { UserManager userManager = getUserManager(); Loading
services/core/java/com/android/server/location/injector/UserInfoHelper.java +6 −0 Original line number Diff line number Diff line Loading @@ -132,6 +132,12 @@ public abstract class UserInfoHelper { */ public abstract boolean isCurrentUserId(@UserIdInt int userId); /** * Returns the current user id. Where possible, prefer to use {@link #isCurrentUserId(int)} * instead, as that method has more flexibility. */ public abstract @UserIdInt int getCurrentUserId(); protected abstract int[] getProfileIds(@UserIdInt int userId); /** Loading