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

Commit 33211a43 authored by Jonathan Scott's avatar Jonathan Scott Committed by Android (Google) Code Review
Browse files

Merge "DPMS: fixes calls to getMainUser()"

parents e28177e9 e46f4690
Loading
Loading
Loading
Loading
+11 −2
Original line number Original line Diff line number Diff line
@@ -1095,13 +1095,13 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                // (ACTION_DATE_CHANGED), or when manual clock adjustment is made
                // (ACTION_DATE_CHANGED), or when manual clock adjustment is made
                // (ACTION_TIME_CHANGED)
                // (ACTION_TIME_CHANGED)
                updateSystemUpdateFreezePeriodsRecord(/* saveIfChanged */ true);
                updateSystemUpdateFreezePeriodsRecord(/* saveIfChanged */ true);
                final int userId = getManagedUserId(mUserManager.getMainUser().getIdentifier());
                final int userId = getManagedUserId(getMainUserId());
                if (userId >= 0) {
                if (userId >= 0) {
                    updatePersonalAppsSuspension(userId, mUserManager.isUserUnlocked(userId));
                    updatePersonalAppsSuspension(userId, mUserManager.isUserUnlocked(userId));
                }
                }
            } else if (ACTION_PROFILE_OFF_DEADLINE.equals(action)) {
            } else if (ACTION_PROFILE_OFF_DEADLINE.equals(action)) {
                Slogf.i(LOG_TAG, "Profile off deadline alarm was triggered");
                Slogf.i(LOG_TAG, "Profile off deadline alarm was triggered");
                final int userId = getManagedUserId(mUserManager.getMainUser().getIdentifier());
                final int userId = getManagedUserId(getMainUserId());
                if (userId >= 0) {
                if (userId >= 0) {
                    updatePersonalAppsSuspension(userId, mUserManager.isUserUnlocked(userId));
                    updatePersonalAppsSuspension(userId, mUserManager.isUserUnlocked(userId));
                } else {
                } else {
@@ -8879,6 +8879,15 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        }
    }
    }
    private @UserIdInt int getMainUserId() {
        UserHandle mainUser = mUserManager.getMainUser();
        if (mainUser == null) {
            Slogf.d(LOG_TAG, "getMainUserId(): no main user, returning USER_SYSTEM");
            return UserHandle.USER_SYSTEM;
        }
        return mainUser.getIdentifier();
    }
    // TODO(b/240562946): Remove api as owner name is not used.
    // TODO(b/240562946): Remove api as owner name is not used.
    /**
    /**
     * Returns the "name" of the device owner.  It'll work for non-DO users too, but requires
     * Returns the "name" of the device owner.  It'll work for non-DO users too, but requires