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

Commit bb1d2a93 authored by Alex Johnston's avatar Alex Johnston
Browse files

Fix testScreenCaptureDisabled

* A SecurityException was being thrown because getProfiles
  in UserManager cannot be called by the COPE PO for user 0
  without permission MANAGE_USERS or CREATE_USERS.
* Added binderWithCleanCallingIdentity to this method.

Bug: 149941985
Test: atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testScreenCaptureDisabled
Change-Id: Iccc60233baaeaa732f197d7aaf31acc9d75a247b
Merged-In: Iccc60233baaeaa732f197d7aaf31acc9d75a247b
(cherry picked from commit 27975949)
parent 7bee686e
Loading
Loading
Loading
Loading
+15 −13
Original line number Diff line number Diff line
@@ -4674,6 +4674,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            return getUserDataUnchecked(userHandle).mAdminList;
        }
        ArrayList<ActiveAdmin> admins = new ArrayList<>();
        mInjector.binderWithCleanCallingIdentity(() -> {
            for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) {
                DevicePolicyData policy = getUserDataUnchecked(userInfo.id);
                if (userInfo.id == userHandle) {
@@ -4690,6 +4691,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                    Slog.w(LOG_TAG, "Unknown user type: " + userInfo);
                }
            }
        });
        return admins;
    }