Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a107680e authored by arangelov's avatar arangelov
Browse files

Check the managed profile for PO

Fixes: 225938013
Test: manual
Test: CTS test to be added in a follow-up CL
Change-Id: Ic43bf774d89f89947f7377bae47b6dfbd1e62ea1
parent 5423eb46
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -18842,14 +18842,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    public List<UserHandle> getPolicyManagedProfiles(@NonNull UserHandle user) {
        Preconditions.checkCallAuthorization(hasCallingOrSelfPermission(
                android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS));
        int userId = user.getIdentifier();
        return mInjector.binderWithCleanCallingIdentity(() -> {
            List<UserInfo> userProfiles = mUserManager.getProfiles(userId);
            List<UserHandle> result = new ArrayList<>();
            for (int i = 0; i < userProfiles.size(); i++) {
                if (userProfiles.get(i).isManagedProfile() && hasProfileOwner(userId)) {
                    result.add(new UserHandle(userProfiles.get(i).id));
                UserInfo userInfo = userProfiles.get(i);
                if (userInfo.isManagedProfile() && hasProfileOwner(userInfo.id)) {
                    result.add(new UserHandle(userInfo.id));
                }
            }
            return result;