diff --git a/location/java/android/location/util/identity/CallerIdentity.java b/location/java/android/location/util/identity/CallerIdentity.java index e023aa1dcd224..9dbdedeb8a030 100644 --- a/location/java/android/location/util/identity/CallerIdentity.java +++ b/location/java/android/location/util/identity/CallerIdentity.java @@ -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; } diff --git a/services/core/java/com/android/server/location/geofence/GeofenceManager.java b/services/core/java/com/android/server/location/geofence/GeofenceManager.java index 4a8534292eaf0..5a90fa7a271cd 100644 --- a/services/core/java/com/android/server/location/geofence/GeofenceManager.java +++ b/services/core/java/com/android/server/location/geofence/GeofenceManager.java @@ -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 diff --git a/services/core/java/com/android/server/location/gnss/GnssListenerMultiplexer.java b/services/core/java/com/android/server/location/gnss/GnssListenerMultiplexer.java index e68f595c3c43e..7e848e03c3a0f 100644 --- a/services/core/java/com/android/server/location/gnss/GnssListenerMultiplexer.java +++ b/services/core/java/com/android/server/location/gnss/GnssListenerMultiplexer.java @@ -266,11 +266,30 @@ public abstract class GnssListenerMultiplexer