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

Commit 8cf30ff9 authored by Felipe Leme's avatar Felipe Leme
Browse files

Fixed mark-profile-owner-on-organization-owned-device for non-profile users

It was throwing a NPE as such users are "orphan".

Test: adb shell dpm mark-profile-owner-on-organization-owned-device com.afwsamples.testdpc/.DeviceAdminReceiver
Fixes: 182189140
Change-Id: Ib02d767a23c53c1c2886728c2f338628149f7868
parent fd8f4ae2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -13639,6 +13639,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        mInjector.binderWithCleanCallingIdentity(() -> {
            // Clear restriction as user.
            final UserHandle parentUser = mUserManager.getProfileParent(UserHandle.of(userId));
            if (parentUser == null) {
                throw new IllegalStateException(String.format("User %d is not a profile", userId));
            }
            if (!parentUser.isSystem()) {
                throw new IllegalStateException(
                        String.format("Only the profile owner of a managed profile on the"