Loading core/java/android/app/admin/DevicePolicyManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -7000,7 +7000,7 @@ public class DevicePolicyManager { throwIfParentInstance("isProfileOwnerApp"); if (mService != null) { try { ComponentName profileOwner = mService.getProfileOwner(myUserId()); ComponentName profileOwner = mService.getProfileOwnerAsUser(myUserId()); return profileOwner != null && profileOwner.getPackageName().equals(packageName); } catch (RemoteException re) { Loading core/java/android/app/admin/IDevicePolicyManager.aidl +0 −1 Original line number Diff line number Diff line Loading @@ -156,7 +156,6 @@ interface IDevicePolicyManager { boolean setProfileOwner(in ComponentName who, String ownerName, int userHandle); ComponentName getProfileOwnerAsUser(int userHandle); ComponentName getProfileOwner(int userHandle); ComponentName getProfileOwnerOrDeviceOwnerSupervisionComponent(in UserHandle userHandle); String getProfileOwnerName(int userHandle); void setProfileEnabled(in ComponentName who); Loading services/devicepolicy/java/com/android/server/devicepolicy/CertificateMonitor.java +1 −1 Original line number Diff line number Diff line Loading @@ -177,7 +177,7 @@ public class CertificateMonitor { int parentUserId = userHandle.getIdentifier(); if (mService.getProfileOwner(userHandle.getIdentifier()) != null) { if (mService.getProfileOwnerAsUser(userHandle.getIdentifier()) != null) { contentText = resources.getString(R.string.ssl_ca_cert_noti_managed, mService.getProfileOwnerName(userHandle.getIdentifier())); smallIconId = R.drawable.stat_sys_certificate_info; Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +12 −18 Original line number Diff line number Diff line Loading @@ -4722,7 +4722,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { public boolean isSeparateProfileChallengeAllowed(int userHandle) { enforceSystemCaller("query separate challenge support"); ComponentName profileOwner = getProfileOwner(userHandle); ComponentName profileOwner = getProfileOwnerAsUser(userHandle); // Profile challenge is supported on N or newer release. return profileOwner != null && getTargetSdk(profileOwner.getPackageName(), userHandle) > Build.VERSION_CODES.M; Loading Loading @@ -6637,7 +6637,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { final UserHandle caller = mInjector.binderGetCallingUserHandle(); // If there is a profile owner, redirect to that; otherwise query the device owner. ComponentName aliasChooser = getProfileOwner(caller.getIdentifier()); ComponentName aliasChooser = getProfileOwnerAsUser(caller.getIdentifier()); if (aliasChooser == null && caller.isSystem()) { synchronized (getLockObject()) { final ActiveAdmin deviceOwnerAdmin = getDeviceOwnerAdminLocked(); Loading Loading @@ -8759,7 +8759,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } public boolean isProfileOwner(ComponentName who, int userId) { final ComponentName profileOwner = getProfileOwner(userId); final ComponentName profileOwner = getProfileOwnerAsUser(userId); return who != null && who.equals(profileOwner); } Loading Loading @@ -9317,16 +9317,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { @Override public ComponentName getProfileOwnerAsUser(int userHandle) { enforceCrossUsersPermission(userHandle); return getProfileOwner(userHandle); } @Override public ComponentName getProfileOwner(int userHandle) { if (!mHasFeature) { return null; } enforceCrossUsersPermission(userHandle); synchronized (getLockObject()) { return mOwners.getProfileOwnerComponent(userHandle); } Loading Loading @@ -9369,9 +9363,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return mInjector.binderWithCleanCallingIdentity(() -> { for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) { if (userInfo.isManagedProfile()) { if (getProfileOwner(userInfo.id) != null if (getProfileOwnerAsUser(userInfo.id) != null && isProfileOwnerOfOrganizationOwnedDevice(userInfo.id)) { ComponentName who = getProfileOwner(userInfo.id); ComponentName who = getProfileOwnerAsUser(userInfo.id); return getActiveAdminUncheckedLocked(who, userInfo.id); } } Loading Loading @@ -9411,7 +9405,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return null; } enforceManageUsers(); ComponentName profileOwner = getProfileOwner(userHandle); ComponentName profileOwner = getProfileOwnerAsUser(userHandle); if (profileOwner == null) { return null; } Loading Loading @@ -9808,7 +9802,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return false; } final ComponentName profileOwner = getProfileOwner(userId); final ComponentName profileOwner = getProfileOwnerAsUser(userId); if (profileOwner == null) { return false; } Loading Loading @@ -13425,7 +13419,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { // Managed-profiles cannot be setup on the system user. return CODE_SPLIT_SYSTEM_USER_DEVICE_SYSTEM_USER; } if (getProfileOwner(callingUserId) != null) { if (getProfileOwnerAsUser(callingUserId) != null) { // Managed user cannot have a managed profile. return CODE_USER_HAS_PROFILE_OWNER; } Loading Loading @@ -14079,7 +14073,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return true; } final ComponentName profileOwner = getProfileOwner(userId); final ComponentName profileOwner = getProfileOwnerAsUser(userId); if (profileOwner == null) { return false; } Loading Loading @@ -14289,7 +14283,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { enforceUserUnlocked(userId); final ComponentName profileOwner = getProfileOwner(userId); final ComponentName profileOwner = getProfileOwnerAsUser(userId); if (profileOwner != null && packageName.equals(profileOwner.getPackageName())) { throw new IllegalArgumentException("Cannot uninstall a package with a profile owner"); } Loading Loading @@ -15825,7 +15819,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { final List<ActiveAdmin> admins = new ArrayList<>(); int[] users = mUserManager.getProfileIdsWithDisabled(UserHandle.getCallingUserId()); for (int i = 0; i < users.length; i++) { final ComponentName componentName = getProfileOwner(users[i]); final ComponentName componentName = getProfileOwnerAsUser(users[i]); if (componentName != null) { ActiveAdmin admin = getActiveAdminUncheckedLocked(componentName, users[i]); if (admin != null) { services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -666,6 +666,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { */ public void testRemoveActiveAdmin_fromDifferentUserWithINTERACT_ACROSS_USERS_FULL() { mContext.callerPermissions.add(android.Manifest.permission.MANAGE_DEVICE_ADMINS); mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); // Add admin1. Loading Loading @@ -2684,6 +2685,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { mContext.callerPermissions.add(permission.MANAGE_DEVICE_ADMINS); mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS); mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS_FULL); mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); // Check that the system user is unaffiliated. mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID; Loading Loading @@ -4220,6 +4222,8 @@ public class DevicePolicyManagerTest extends DpmTestBase { } public void testGetBindDeviceAdminTargetUsers() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); // Setup device owner. mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID; setupDeviceOwner(); Loading Loading @@ -6051,6 +6055,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { } public void testGetAllCrossProfilePackages_notSet_returnsEmpty() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); addManagedProfile(admin1, mServiceContext.binder.callingUid, admin1); mContext.packageName = admin1.getPackageName(); Loading @@ -6062,6 +6067,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { public void testGetAllCrossProfilePackages_notSet_dpmsReinitialized_returnsEmpty() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); addManagedProfile(admin1, mServiceContext.binder.callingUid, admin1); mContext.packageName = admin1.getPackageName(); Loading @@ -6073,6 +6079,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { } public void testGetAllCrossProfilePackages_whenSet_returnsCombinedSet() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); addManagedProfile(admin1, mServiceContext.binder.callingUid, admin1); final Set<String> packages = Sets.newSet("TEST_PACKAGE", "TEST_COMMON_PACKAGE"); mContext.packageName = admin1.getPackageName(); Loading @@ -6090,6 +6097,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { public void testGetAllCrossProfilePackages_whenSet_dpmsReinitialized_returnsCombinedSet() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); addManagedProfile(admin1, mServiceContext.binder.callingUid, admin1); final Set<String> packages = Sets.newSet("TEST_PACKAGE", "TEST_COMMON_PACKAGE"); mContext.packageName = admin1.getPackageName(); Loading Loading @@ -6261,6 +6269,8 @@ public class DevicePolicyManagerTest extends DpmTestBase { public void testSetAccountTypesWithManagementDisabledOnOrgOwnedManagedProfile() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); final int managedProfileUserId = 15; final int managedProfileAdminUid = UserHandle.getUid(managedProfileUserId, 19436); Loading Loading
core/java/android/app/admin/DevicePolicyManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -7000,7 +7000,7 @@ public class DevicePolicyManager { throwIfParentInstance("isProfileOwnerApp"); if (mService != null) { try { ComponentName profileOwner = mService.getProfileOwner(myUserId()); ComponentName profileOwner = mService.getProfileOwnerAsUser(myUserId()); return profileOwner != null && profileOwner.getPackageName().equals(packageName); } catch (RemoteException re) { Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +0 −1 Original line number Diff line number Diff line Loading @@ -156,7 +156,6 @@ interface IDevicePolicyManager { boolean setProfileOwner(in ComponentName who, String ownerName, int userHandle); ComponentName getProfileOwnerAsUser(int userHandle); ComponentName getProfileOwner(int userHandle); ComponentName getProfileOwnerOrDeviceOwnerSupervisionComponent(in UserHandle userHandle); String getProfileOwnerName(int userHandle); void setProfileEnabled(in ComponentName who); Loading
services/devicepolicy/java/com/android/server/devicepolicy/CertificateMonitor.java +1 −1 Original line number Diff line number Diff line Loading @@ -177,7 +177,7 @@ public class CertificateMonitor { int parentUserId = userHandle.getIdentifier(); if (mService.getProfileOwner(userHandle.getIdentifier()) != null) { if (mService.getProfileOwnerAsUser(userHandle.getIdentifier()) != null) { contentText = resources.getString(R.string.ssl_ca_cert_noti_managed, mService.getProfileOwnerName(userHandle.getIdentifier())); smallIconId = R.drawable.stat_sys_certificate_info; Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +12 −18 Original line number Diff line number Diff line Loading @@ -4722,7 +4722,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { public boolean isSeparateProfileChallengeAllowed(int userHandle) { enforceSystemCaller("query separate challenge support"); ComponentName profileOwner = getProfileOwner(userHandle); ComponentName profileOwner = getProfileOwnerAsUser(userHandle); // Profile challenge is supported on N or newer release. return profileOwner != null && getTargetSdk(profileOwner.getPackageName(), userHandle) > Build.VERSION_CODES.M; Loading Loading @@ -6637,7 +6637,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { final UserHandle caller = mInjector.binderGetCallingUserHandle(); // If there is a profile owner, redirect to that; otherwise query the device owner. ComponentName aliasChooser = getProfileOwner(caller.getIdentifier()); ComponentName aliasChooser = getProfileOwnerAsUser(caller.getIdentifier()); if (aliasChooser == null && caller.isSystem()) { synchronized (getLockObject()) { final ActiveAdmin deviceOwnerAdmin = getDeviceOwnerAdminLocked(); Loading Loading @@ -8759,7 +8759,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } public boolean isProfileOwner(ComponentName who, int userId) { final ComponentName profileOwner = getProfileOwner(userId); final ComponentName profileOwner = getProfileOwnerAsUser(userId); return who != null && who.equals(profileOwner); } Loading Loading @@ -9317,16 +9317,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { @Override public ComponentName getProfileOwnerAsUser(int userHandle) { enforceCrossUsersPermission(userHandle); return getProfileOwner(userHandle); } @Override public ComponentName getProfileOwner(int userHandle) { if (!mHasFeature) { return null; } enforceCrossUsersPermission(userHandle); synchronized (getLockObject()) { return mOwners.getProfileOwnerComponent(userHandle); } Loading Loading @@ -9369,9 +9363,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return mInjector.binderWithCleanCallingIdentity(() -> { for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) { if (userInfo.isManagedProfile()) { if (getProfileOwner(userInfo.id) != null if (getProfileOwnerAsUser(userInfo.id) != null && isProfileOwnerOfOrganizationOwnedDevice(userInfo.id)) { ComponentName who = getProfileOwner(userInfo.id); ComponentName who = getProfileOwnerAsUser(userInfo.id); return getActiveAdminUncheckedLocked(who, userInfo.id); } } Loading Loading @@ -9411,7 +9405,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return null; } enforceManageUsers(); ComponentName profileOwner = getProfileOwner(userHandle); ComponentName profileOwner = getProfileOwnerAsUser(userHandle); if (profileOwner == null) { return null; } Loading Loading @@ -9808,7 +9802,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return false; } final ComponentName profileOwner = getProfileOwner(userId); final ComponentName profileOwner = getProfileOwnerAsUser(userId); if (profileOwner == null) { return false; } Loading Loading @@ -13425,7 +13419,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { // Managed-profiles cannot be setup on the system user. return CODE_SPLIT_SYSTEM_USER_DEVICE_SYSTEM_USER; } if (getProfileOwner(callingUserId) != null) { if (getProfileOwnerAsUser(callingUserId) != null) { // Managed user cannot have a managed profile. return CODE_USER_HAS_PROFILE_OWNER; } Loading Loading @@ -14079,7 +14073,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return true; } final ComponentName profileOwner = getProfileOwner(userId); final ComponentName profileOwner = getProfileOwnerAsUser(userId); if (profileOwner == null) { return false; } Loading Loading @@ -14289,7 +14283,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { enforceUserUnlocked(userId); final ComponentName profileOwner = getProfileOwner(userId); final ComponentName profileOwner = getProfileOwnerAsUser(userId); if (profileOwner != null && packageName.equals(profileOwner.getPackageName())) { throw new IllegalArgumentException("Cannot uninstall a package with a profile owner"); } Loading Loading @@ -15825,7 +15819,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { final List<ActiveAdmin> admins = new ArrayList<>(); int[] users = mUserManager.getProfileIdsWithDisabled(UserHandle.getCallingUserId()); for (int i = 0; i < users.length; i++) { final ComponentName componentName = getProfileOwner(users[i]); final ComponentName componentName = getProfileOwnerAsUser(users[i]); if (componentName != null) { ActiveAdmin admin = getActiveAdminUncheckedLocked(componentName, users[i]); if (admin != null) {
services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -666,6 +666,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { */ public void testRemoveActiveAdmin_fromDifferentUserWithINTERACT_ACROSS_USERS_FULL() { mContext.callerPermissions.add(android.Manifest.permission.MANAGE_DEVICE_ADMINS); mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); // Add admin1. Loading Loading @@ -2684,6 +2685,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { mContext.callerPermissions.add(permission.MANAGE_DEVICE_ADMINS); mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS); mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS_FULL); mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); // Check that the system user is unaffiliated. mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID; Loading Loading @@ -4220,6 +4222,8 @@ public class DevicePolicyManagerTest extends DpmTestBase { } public void testGetBindDeviceAdminTargetUsers() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); // Setup device owner. mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID; setupDeviceOwner(); Loading Loading @@ -6051,6 +6055,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { } public void testGetAllCrossProfilePackages_notSet_returnsEmpty() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); addManagedProfile(admin1, mServiceContext.binder.callingUid, admin1); mContext.packageName = admin1.getPackageName(); Loading @@ -6062,6 +6067,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { public void testGetAllCrossProfilePackages_notSet_dpmsReinitialized_returnsEmpty() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); addManagedProfile(admin1, mServiceContext.binder.callingUid, admin1); mContext.packageName = admin1.getPackageName(); Loading @@ -6073,6 +6079,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { } public void testGetAllCrossProfilePackages_whenSet_returnsCombinedSet() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); addManagedProfile(admin1, mServiceContext.binder.callingUid, admin1); final Set<String> packages = Sets.newSet("TEST_PACKAGE", "TEST_COMMON_PACKAGE"); mContext.packageName = admin1.getPackageName(); Loading @@ -6090,6 +6097,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { public void testGetAllCrossProfilePackages_whenSet_dpmsReinitialized_returnsCombinedSet() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); addManagedProfile(admin1, mServiceContext.binder.callingUid, admin1); final Set<String> packages = Sets.newSet("TEST_PACKAGE", "TEST_COMMON_PACKAGE"); mContext.packageName = admin1.getPackageName(); Loading Loading @@ -6261,6 +6269,8 @@ public class DevicePolicyManagerTest extends DpmTestBase { public void testSetAccountTypesWithManagementDisabledOnOrgOwnedManagedProfile() throws Exception { mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS); final int managedProfileUserId = 15; final int managedProfileAdminUid = UserHandle.getUid(managedProfileUserId, 19436); Loading