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

Commit a491ff68 authored by Felipe Leme's avatar Felipe Leme
Browse files

Revert "Fixed DPMS.setDeviceOwner() permission check."

That change broke `dpm set-device-owner` on headless system user
because when the identiy was cleared, 'isAdb()` would return false.

Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDelegation
Bug: 200810234

This reverts commit 1b7f9845.

Change-Id: Ie12a58466af5fbfd834478aec98e0aef9384121f
parent a59f1a8a
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -8414,19 +8414,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            mDeviceAdminServiceController.startServiceForOwner(
                    admin.getPackageName(), userId, "set-device-owner");
            Slogf.i(LOG_TAG, "Device owner set: %s on user %d", admin.flattenToShortString(),
                    userId);
            Slogf.i(LOG_TAG, "Device owner set: " + admin + " on user " + userId);
            if (mInjector.userManagerIsHeadlessSystemUserMode()) {
                int currentForegroundUser = getCurrentForegroundUserId();
                Slogf.i(LOG_TAG, "setDeviceOwner(): setting %s as profile owner on user %d",
                        admin.flattenToShortString(), currentForegroundUser);
                Slogf.i(LOG_TAG, "setDeviceOwner(): setting " + admin
                        + " as profile owner on user " + currentForegroundUser);
                // Sets profile owner on current foreground user since
                // the human user will complete the DO setup workflow from there.
                mInjector.binderWithCleanCallingIdentity(() -> manageUserUnchecked(
                        /* deviceOwner= */ admin, /* profileOwner= */ admin,
                manageUserUnchecked(/* deviceOwner= */ admin, /* profileOwner= */ admin,
                        /* managedUser= */ currentForegroundUser, /* adminExtras= */ null,
                        /* showDisclaimer= */ false));
                        /* showDisclaimer= */ false);
            }
            return true;
        }