Loading core/java/android/app/admin/DevicePolicyManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -6990,7 +6990,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 +15 −20 Original line number Diff line number Diff line Loading @@ -3356,7 +3356,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 @@ -5290,7 +5290,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 @@ -7345,7 +7345,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 @@ -7356,7 +7356,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { */ public boolean isProfileOwner(CallerIdentity caller) { synchronized (getLockObject()) { final ComponentName profileOwner = getProfileOwner(caller.getUserId()); final ComponentName profileOwner = getProfileOwnerAsUser(caller.getUserId()); // No profile owner. if (profileOwner == null) { return false; Loading Loading @@ -7957,19 +7957,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { @Override public ComponentName getProfileOwnerAsUser(int userHandle) { if (!mHasFeature) { return null; } Preconditions.checkArgumentNonnegative(userHandle, "Invalid userId"); final CallerIdentity caller = getCallerIdentity(); Preconditions.checkCallAuthorization(hasCrossUsersPermission(caller, userHandle)); return getProfileOwner(userHandle); } @Override public ComponentName getProfileOwner(int userHandle) { if (!mHasFeature) { return null; } synchronized (getLockObject()) { return mOwners.getProfileOwnerComponent(userHandle); } Loading Loading @@ -8012,9 +8007,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 @@ -8061,7 +8056,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } Preconditions.checkCallAuthorization(canManageUsers(getCallerIdentity())); ComponentName profileOwner = getProfileOwner(userHandle); ComponentName profileOwner = getProfileOwnerAsUser(userHandle); if (profileOwner == null) { return null; } Loading Loading @@ -8391,7 +8386,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 @@ -12064,7 +12059,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 @@ -12740,7 +12735,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 @@ -12949,7 +12944,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { final int userId = caller.getUserId(); 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 @@ -14520,7 +14515,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 @@ -665,6 +665,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 @@ -2683,6 +2684,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 @@ -4217,6 +4219,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 @@ -6041,6 +6045,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 @@ -6052,6 +6057,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 @@ -6063,6 +6069,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 @@ -6080,6 +6087,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 @@ -6251,6 +6259,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 @@ -6990,7 +6990,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 +15 −20 Original line number Diff line number Diff line Loading @@ -3356,7 +3356,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 @@ -5290,7 +5290,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 @@ -7345,7 +7345,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 @@ -7356,7 +7356,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { */ public boolean isProfileOwner(CallerIdentity caller) { synchronized (getLockObject()) { final ComponentName profileOwner = getProfileOwner(caller.getUserId()); final ComponentName profileOwner = getProfileOwnerAsUser(caller.getUserId()); // No profile owner. if (profileOwner == null) { return false; Loading Loading @@ -7957,19 +7957,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { @Override public ComponentName getProfileOwnerAsUser(int userHandle) { if (!mHasFeature) { return null; } Preconditions.checkArgumentNonnegative(userHandle, "Invalid userId"); final CallerIdentity caller = getCallerIdentity(); Preconditions.checkCallAuthorization(hasCrossUsersPermission(caller, userHandle)); return getProfileOwner(userHandle); } @Override public ComponentName getProfileOwner(int userHandle) { if (!mHasFeature) { return null; } synchronized (getLockObject()) { return mOwners.getProfileOwnerComponent(userHandle); } Loading Loading @@ -8012,9 +8007,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 @@ -8061,7 +8056,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } Preconditions.checkCallAuthorization(canManageUsers(getCallerIdentity())); ComponentName profileOwner = getProfileOwner(userHandle); ComponentName profileOwner = getProfileOwnerAsUser(userHandle); if (profileOwner == null) { return null; } Loading Loading @@ -8391,7 +8386,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 @@ -12064,7 +12059,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 @@ -12740,7 +12735,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 @@ -12949,7 +12944,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { final int userId = caller.getUserId(); 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 @@ -14520,7 +14515,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 @@ -665,6 +665,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 @@ -2683,6 +2684,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 @@ -4217,6 +4219,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 @@ -6041,6 +6045,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 @@ -6052,6 +6057,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 @@ -6063,6 +6069,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 @@ -6080,6 +6087,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 @@ -6251,6 +6259,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