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

Commit 0ccf42c8 authored by Eric Biggers's avatar Eric Biggers
Browse files

Don't try to lock/unlock already locked/unlocked users

Now that isUserKeyUnlocked() works correctly (even after a userspace
reboot), we can make unlockUserKey() and lockUserKey() be no-ops if the
user is already unlocked/locked.  This avoids misleading log messages.

Bug: 146206679
Test: see I482ed8017f7bbc8f7d4fd5a2c0f58629317ce4ed
Change-Id: I125770c3fa238cb15de9dafb5163e874b4f79cf2
parent 270db90c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3269,6 +3269,11 @@ class StorageManagerService extends IStorageManager.Stub
                + " hasSecret: " + (secret != null));
        enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);

        if (isUserKeyUnlocked(userId)) {
            Slog.d(TAG, "User " + userId + "'s CE storage is already unlocked");
            return;
        }

        if (isFsEncrypted) {
            // When a user has secure lock screen, require secret to actually unlock.
            // This check is mostly in place for emulation mode.
@@ -3303,6 +3308,11 @@ class StorageManagerService extends IStorageManager.Stub

        enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);

        if (!isUserKeyUnlocked(userId)) {
            Slog.d(TAG, "User " + userId + "'s CE storage is already locked");
            return;
        }

        try {
            mVold.lockUserKey(userId);
        } catch (Exception e) {