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

Commit ada6ce94 authored by Eric Biggers's avatar Eric Biggers
Browse files

Sync tieProfileLockIfNecessary() with internal main

The internal-first commit ab75d2ce (http://ag/23150174) modified
tieProfileLockIfNecessary(), which is now causing conflicts.  As the
modification to tieProfileLockIfNecessary() (which simply made it not
crash when called with a profile that does not have a parent) does not
depend on the rest of the change, cherry-pick it separately.

Test: atest com.android.server.locksettings
Merged-In: Ib0e4e52c10f0e95913ddfde606d6995de3538f27
Change-Id: I323811363d8801d4f0bc84f241ad042f45bb3358
parent 91755c24
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -433,11 +433,14 @@ public class LockSettingsService extends ILockSettings.Stub {
        if (mStorage.hasChildProfileLock(profileUserId)) {
            return;
        }
        final UserInfo parent = mUserManager.getProfileParent(profileUserId);
        if (parent == null) {
            return;
        }
        // If parent does not have a screen lock, simply clear credential from the profile,
        // to maintain the invariant that unified profile should always have the same secure state
        // as its parent.
        final int parentId = mUserManager.getProfileParent(profileUserId).id;
        if (!isUserSecure(parentId) && !profileUserPassword.isNone()) {
        if (!isUserSecure(parent.id) && !profileUserPassword.isNone()) {
            Slogf.i(TAG, "Clearing password for profile user %d to match parent", profileUserId);
            setLockCredentialInternal(LockscreenCredential.createNone(), profileUserPassword,
                    profileUserId, /* isLockTiedToParent= */ true);
@@ -448,7 +451,7 @@ public class LockSettingsService extends ILockSettings.Stub {
        // This can only happen during an upgrade path where SID is yet to be
        // generated when the user unlocks for the first time.
        try {
            parentSid = getGateKeeperService().getSecureUserId(parentId);
            parentSid = getGateKeeperService().getSecureUserId(parent.id);
            if (parentSid == 0) {
                return;
            }
@@ -459,7 +462,7 @@ public class LockSettingsService extends ILockSettings.Stub {
        try (LockscreenCredential unifiedProfilePassword = generateRandomProfilePassword()) {
            setLockCredentialInternal(unifiedProfilePassword, profileUserPassword, profileUserId,
                    /* isLockTiedToParent= */ true);
            tieProfileLockToParent(profileUserId, parentId, unifiedProfilePassword);
            tieProfileLockToParent(profileUserId, parent.id, unifiedProfilePassword);
            mManagedProfilePasswordCache.storePassword(profileUserId, unifiedProfilePassword,
                    parentSid);
        }