Loading core/java/android/app/admin/DeviceStateCache.java +8 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,14 @@ public abstract class DeviceStateCache { */ public abstract boolean isUserOrganizationManaged(@UserIdInt int userHandle); /** * Returns whether a user has affiliated IDs. */ public boolean hasAffiliationWithDevice(int userId) { return false; } /** * Empty implementation. */ Loading services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +5 −0 Original line number Diff line number Diff line Loading @@ -584,6 +584,11 @@ public abstract class ActivityTaskManagerInternal { */ public abstract void setDeviceOwnerUid(int uid); /** * Called by DevicePolicyManagerService to set the uids of the profile owners. */ public abstract void setProfileOwnerUids(Set<Integer> uids); /** * Set all associated companion app that belongs to a userId. * @param userId Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +19 −0 Original line number Diff line number Diff line Loading @@ -158,6 +158,7 @@ import android.app.PictureInPictureUiState; import android.app.ProfilerInfo; import android.app.WaitResult; import android.app.admin.DevicePolicyCache; import android.app.admin.DeviceStateCache; import android.app.assist.ActivityId; import android.app.assist.AssistContent; import android.app.assist.AssistStructure; Loading Loading @@ -783,6 +784,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { private int mDeviceOwnerUid = Process.INVALID_UID; private Set<Integer> mProfileOwnerUids = new ArraySet<Integer>(); private final class SettingObserver extends ContentObserver { private final Uri mFontScaleUri = Settings.System.getUriFor(FONT_SCALE); private final Uri mHideErrorDialogsUri = Settings.Global.getUriFor(HIDE_ERROR_DIALOGS); Loading Loading @@ -5360,6 +5363,15 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mDeviceOwnerUid = uid; } boolean isAffiliatedProfileOwner(int uid) { return uid >= 0 && mProfileOwnerUids.contains(uid) && DeviceStateCache.getInstance().hasAffiliationWithDevice(UserHandle.getUserId(uid)); } void setProfileOwnerUids(Set<Integer> uids) { mProfileOwnerUids = uids; } /** * Saves the current activity manager state and includes the saved state in the next dump of * activity manager. Loading Loading @@ -6915,6 +6927,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } @Override public void setProfileOwnerUids(Set<Integer> uids) { synchronized (mGlobalLock) { ActivityTaskManagerService.this.setProfileOwnerUids(uids); } } @Override public void setCompanionAppUids(int userId, Set<Integer> companionAppUids) { synchronized (mGlobalLock) { Loading services/core/java/com/android/server/wm/BackgroundActivityStartController.java +8 −0 Original line number Diff line number Diff line Loading @@ -342,6 +342,14 @@ public class BackgroundActivityStartController { /*background*/ true, callingUid, realCallingUid, intent, "Device Owner"); } // don't abort if the callingUid is a affiliated profile owner if (mService.isAffiliatedProfileOwner(callingUid)) { return logStartAllowedAndReturnCode( BAL_ALLOW_ALLOWLISTED_COMPONENT, resultIfPiSenderAllowsBal, balAllowedByPiSender, /*background*/ true, callingUid, realCallingUid, intent, "Affiliated Profile Owner"); } // don't abort if the callingUid has companion device final int callingUserId = UserHandle.getUserId(callingUid); if (mService.isAssociatedCompanionApp(callingUserId, callingUid)) { Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +17 −1 Original line number Diff line number Diff line Loading @@ -10329,6 +10329,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { policy.mSecondaryLockscreenEnabled = false; policy.mUserProvisioningState = DevicePolicyManager.STATE_USER_UNMANAGED; policy.mAffiliationIds.clear(); resetAffiliationCacheLocked(); policy.mLockTaskPackages.clear(); if (!isPolicyEngineForFinanceFlagEnabled()) { updateLockTaskPackagesLocked(mContext, policy.mLockTaskPackages, userId); Loading Loading @@ -18022,10 +18023,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (getLockObject()) { getUserData(callingUserId).mAffiliationIds = affiliationIds; saveSettingsLocked(callingUserId); if (callingUserId != UserHandle.USER_SYSTEM && isDeviceOwner(admin, callingUserId)) { mStateCache.setHasAffiliationWithDevice(callingUserId, isUserAffiliatedWithDeviceLocked(callingUserId)); if (callingUserId == UserHandle.USER_SYSTEM) { resetAffiliationCacheLocked(); } else if (callingUserId != UserHandle.USER_SYSTEM && isDeviceOwner(admin, callingUserId)) { // Affiliation ids specified by the device owner are additionally stored in // UserHandle.USER_SYSTEM's DevicePolicyData. getUserData(UserHandle.USER_SYSTEM).mAffiliationIds = affiliationIds; mStateCache.setHasAffiliationWithDevice(UserHandle.USER_SYSTEM, true); saveSettingsLocked(UserHandle.USER_SYSTEM); } Loading @@ -18039,6 +18046,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } } private void resetAffiliationCacheLocked() { mInjector.binderWithCleanCallingIdentity(() -> { for (UserInfo user : mUserManager.getUsers()) { mStateCache.setHasAffiliationWithDevice(user.id, isUserAffiliatedWithDeviceLocked(user.id)); } }); } @Override public List<String> getAffiliationIds(ComponentName admin) { if (!mHasFeature) { Loading
core/java/android/app/admin/DeviceStateCache.java +8 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,14 @@ public abstract class DeviceStateCache { */ public abstract boolean isUserOrganizationManaged(@UserIdInt int userHandle); /** * Returns whether a user has affiliated IDs. */ public boolean hasAffiliationWithDevice(int userId) { return false; } /** * Empty implementation. */ Loading
services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +5 −0 Original line number Diff line number Diff line Loading @@ -584,6 +584,11 @@ public abstract class ActivityTaskManagerInternal { */ public abstract void setDeviceOwnerUid(int uid); /** * Called by DevicePolicyManagerService to set the uids of the profile owners. */ public abstract void setProfileOwnerUids(Set<Integer> uids); /** * Set all associated companion app that belongs to a userId. * @param userId Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +19 −0 Original line number Diff line number Diff line Loading @@ -158,6 +158,7 @@ import android.app.PictureInPictureUiState; import android.app.ProfilerInfo; import android.app.WaitResult; import android.app.admin.DevicePolicyCache; import android.app.admin.DeviceStateCache; import android.app.assist.ActivityId; import android.app.assist.AssistContent; import android.app.assist.AssistStructure; Loading Loading @@ -783,6 +784,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { private int mDeviceOwnerUid = Process.INVALID_UID; private Set<Integer> mProfileOwnerUids = new ArraySet<Integer>(); private final class SettingObserver extends ContentObserver { private final Uri mFontScaleUri = Settings.System.getUriFor(FONT_SCALE); private final Uri mHideErrorDialogsUri = Settings.Global.getUriFor(HIDE_ERROR_DIALOGS); Loading Loading @@ -5360,6 +5363,15 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mDeviceOwnerUid = uid; } boolean isAffiliatedProfileOwner(int uid) { return uid >= 0 && mProfileOwnerUids.contains(uid) && DeviceStateCache.getInstance().hasAffiliationWithDevice(UserHandle.getUserId(uid)); } void setProfileOwnerUids(Set<Integer> uids) { mProfileOwnerUids = uids; } /** * Saves the current activity manager state and includes the saved state in the next dump of * activity manager. Loading Loading @@ -6915,6 +6927,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } @Override public void setProfileOwnerUids(Set<Integer> uids) { synchronized (mGlobalLock) { ActivityTaskManagerService.this.setProfileOwnerUids(uids); } } @Override public void setCompanionAppUids(int userId, Set<Integer> companionAppUids) { synchronized (mGlobalLock) { Loading
services/core/java/com/android/server/wm/BackgroundActivityStartController.java +8 −0 Original line number Diff line number Diff line Loading @@ -342,6 +342,14 @@ public class BackgroundActivityStartController { /*background*/ true, callingUid, realCallingUid, intent, "Device Owner"); } // don't abort if the callingUid is a affiliated profile owner if (mService.isAffiliatedProfileOwner(callingUid)) { return logStartAllowedAndReturnCode( BAL_ALLOW_ALLOWLISTED_COMPONENT, resultIfPiSenderAllowsBal, balAllowedByPiSender, /*background*/ true, callingUid, realCallingUid, intent, "Affiliated Profile Owner"); } // don't abort if the callingUid has companion device final int callingUserId = UserHandle.getUserId(callingUid); if (mService.isAssociatedCompanionApp(callingUserId, callingUid)) { Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +17 −1 Original line number Diff line number Diff line Loading @@ -10329,6 +10329,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { policy.mSecondaryLockscreenEnabled = false; policy.mUserProvisioningState = DevicePolicyManager.STATE_USER_UNMANAGED; policy.mAffiliationIds.clear(); resetAffiliationCacheLocked(); policy.mLockTaskPackages.clear(); if (!isPolicyEngineForFinanceFlagEnabled()) { updateLockTaskPackagesLocked(mContext, policy.mLockTaskPackages, userId); Loading Loading @@ -18022,10 +18023,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (getLockObject()) { getUserData(callingUserId).mAffiliationIds = affiliationIds; saveSettingsLocked(callingUserId); if (callingUserId != UserHandle.USER_SYSTEM && isDeviceOwner(admin, callingUserId)) { mStateCache.setHasAffiliationWithDevice(callingUserId, isUserAffiliatedWithDeviceLocked(callingUserId)); if (callingUserId == UserHandle.USER_SYSTEM) { resetAffiliationCacheLocked(); } else if (callingUserId != UserHandle.USER_SYSTEM && isDeviceOwner(admin, callingUserId)) { // Affiliation ids specified by the device owner are additionally stored in // UserHandle.USER_SYSTEM's DevicePolicyData. getUserData(UserHandle.USER_SYSTEM).mAffiliationIds = affiliationIds; mStateCache.setHasAffiliationWithDevice(UserHandle.USER_SYSTEM, true); saveSettingsLocked(UserHandle.USER_SYSTEM); } Loading @@ -18039,6 +18046,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } } private void resetAffiliationCacheLocked() { mInjector.binderWithCleanCallingIdentity(() -> { for (UserInfo user : mUserManager.getUsers()) { mStateCache.setHasAffiliationWithDevice(user.id, isUserAffiliatedWithDeviceLocked(user.id)); } }); } @Override public List<String> getAffiliationIds(ComponentName admin) { if (!mHasFeature) {