Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +12 −11 Original line number Original line Diff line number Diff line Loading @@ -4640,20 +4640,19 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { * </ul> * </ul> * * * @param userHandle the affected user for whom to get the active admins * @param userHandle the affected user for whom to get the active admins * @param parent whether the parent active admins should be included in the list of active * admins or not * @return the list of active admins for the affected user * @return the list of active admins for the affected user */ */ private List<ActiveAdmin> getActiveAdminsForAffectedUser(int userHandle, boolean parent) { @GuardedBy("getLockObject()") if (!parent) { private List<ActiveAdmin> getActiveAdminsForAffectedUserLocked(int userHandle) { if (isManagedProfile(userHandle)) { return getUserDataUnchecked(userHandle).mAdminList; return getUserDataUnchecked(userHandle).mAdminList; } } ArrayList<ActiveAdmin> admins = new ArrayList<>(); ArrayList<ActiveAdmin> admins = new ArrayList<>(); for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) { for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) { DevicePolicyData policy = getUserData(userInfo.id); DevicePolicyData policy = getUserDataUnchecked(userInfo.id); if (!userInfo.isManagedProfile()) { if (userInfo.id == userHandle) { admins.addAll(policy.mAdminList); admins.addAll(policy.mAdminList); } else { } else if (userInfo.isManagedProfile()) { // For managed profiles, policies set on the parent profile will be included // For managed profiles, policies set on the parent profile will be included for (int i = 0; i < policy.mAdminList.size(); i++) { for (int i = 0; i < policy.mAdminList.size(); i++) { ActiveAdmin admin = policy.mAdminList.get(i); ActiveAdmin admin = policy.mAdminList.get(i); Loading @@ -4661,6 +4660,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { admins.add(admin.getParentActiveAdmin()); admins.add(admin.getParentActiveAdmin()); } } } } } else { Slog.w(LOG_TAG, "Unknown user type: " + userInfo); } } } } return admins; return admins; Loading Loading @@ -7640,9 +7641,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return (admin != null) && admin.disableScreenCapture; return (admin != null) && admin.disableScreenCapture; } } boolean includeParent = isOrganizationOwnedDeviceWithManagedProfile() final int affectedUserId = parent ? getProfileParentId(userHandle) : userHandle; && !isManagedProfile(userHandle); List<ActiveAdmin> admins = getActiveAdminsForAffectedUserLocked(affectedUserId); List<ActiveAdmin> admins = getActiveAdminsForAffectedUser(userHandle, includeParent); for (ActiveAdmin admin: admins) { for (ActiveAdmin admin: admins) { if (admin.disableScreenCapture) { if (admin.disableScreenCapture) { return true; return true; Loading Loading @@ -8151,8 +8151,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return true; return true; } } } } final int affectedUserId = parent ? getProfileParentId(userHandle) : userHandle; // Return the strictest policy across all participating admins. // Return the strictest policy across all participating admins. List<ActiveAdmin> admins = getActiveAdminsForAffectedUser(userHandle, parent); List<ActiveAdmin> admins = getActiveAdminsForAffectedUserLocked(affectedUserId); // Determine whether or not the device camera is disabled for any active admins. // Determine whether or not the device camera is disabled for any active admins. for (ActiveAdmin admin: admins) { for (ActiveAdmin admin: admins) { if (admin.disableCamera) { if (admin.disableCamera) { Loading Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +12 −11 Original line number Original line Diff line number Diff line Loading @@ -4640,20 +4640,19 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { * </ul> * </ul> * * * @param userHandle the affected user for whom to get the active admins * @param userHandle the affected user for whom to get the active admins * @param parent whether the parent active admins should be included in the list of active * admins or not * @return the list of active admins for the affected user * @return the list of active admins for the affected user */ */ private List<ActiveAdmin> getActiveAdminsForAffectedUser(int userHandle, boolean parent) { @GuardedBy("getLockObject()") if (!parent) { private List<ActiveAdmin> getActiveAdminsForAffectedUserLocked(int userHandle) { if (isManagedProfile(userHandle)) { return getUserDataUnchecked(userHandle).mAdminList; return getUserDataUnchecked(userHandle).mAdminList; } } ArrayList<ActiveAdmin> admins = new ArrayList<>(); ArrayList<ActiveAdmin> admins = new ArrayList<>(); for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) { for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) { DevicePolicyData policy = getUserData(userInfo.id); DevicePolicyData policy = getUserDataUnchecked(userInfo.id); if (!userInfo.isManagedProfile()) { if (userInfo.id == userHandle) { admins.addAll(policy.mAdminList); admins.addAll(policy.mAdminList); } else { } else if (userInfo.isManagedProfile()) { // For managed profiles, policies set on the parent profile will be included // For managed profiles, policies set on the parent profile will be included for (int i = 0; i < policy.mAdminList.size(); i++) { for (int i = 0; i < policy.mAdminList.size(); i++) { ActiveAdmin admin = policy.mAdminList.get(i); ActiveAdmin admin = policy.mAdminList.get(i); Loading @@ -4661,6 +4660,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { admins.add(admin.getParentActiveAdmin()); admins.add(admin.getParentActiveAdmin()); } } } } } else { Slog.w(LOG_TAG, "Unknown user type: " + userInfo); } } } } return admins; return admins; Loading Loading @@ -7640,9 +7641,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return (admin != null) && admin.disableScreenCapture; return (admin != null) && admin.disableScreenCapture; } } boolean includeParent = isOrganizationOwnedDeviceWithManagedProfile() final int affectedUserId = parent ? getProfileParentId(userHandle) : userHandle; && !isManagedProfile(userHandle); List<ActiveAdmin> admins = getActiveAdminsForAffectedUserLocked(affectedUserId); List<ActiveAdmin> admins = getActiveAdminsForAffectedUser(userHandle, includeParent); for (ActiveAdmin admin: admins) { for (ActiveAdmin admin: admins) { if (admin.disableScreenCapture) { if (admin.disableScreenCapture) { return true; return true; Loading Loading @@ -8151,8 +8151,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return true; return true; } } } } final int affectedUserId = parent ? getProfileParentId(userHandle) : userHandle; // Return the strictest policy across all participating admins. // Return the strictest policy across all participating admins. List<ActiveAdmin> admins = getActiveAdminsForAffectedUser(userHandle, parent); List<ActiveAdmin> admins = getActiveAdminsForAffectedUserLocked(affectedUserId); // Determine whether or not the device camera is disabled for any active admins. // Determine whether or not the device camera is disabled for any active admins. for (ActiveAdmin admin: admins) { for (ActiveAdmin admin: admins) { if (admin.disableCamera) { if (admin.disableCamera) { Loading