Avoid redundant unlock of newly created key

IVold.createUserKey unlocks the key that it creates, so the later call
to IVold.unlockUserKey is unnecessary and just triggers a warning:

    W vold    : Tried to unlock already-unlocked key for user 10

Avoid this by making the createUserKey and destroyUserKey methods of
StorageManagerService update the mLocalUnlockedUsers array, so that the
StorageManagerService state stays in sync with the vold state.

Test: pm create-user 10; am start-user 10; checked logcat
Bug: 232452368
Change-Id: I238b2b218582e2791b25998e8ebaa1004ca0466d
This commit is contained in:
Eric Biggers
2022-08-12 02:41:44 +00:00
parent 7d532c8d10
commit 361674de4e

View File

@@ -3047,6 +3047,10 @@ class StorageManagerService extends IStorageManager.Stub
try {
mVold.createUserKey(userId, serialNumber, ephemeral);
// New keys are always unlocked.
synchronized (mLock) {
mLocalUnlockedUsers.append(userId);
}
} catch (Exception e) {
Slog.wtf(TAG, e);
}
@@ -3058,6 +3062,10 @@ class StorageManagerService extends IStorageManager.Stub
try {
mVold.destroyUserKey(userId);
// Destroying a key also locks it.
synchronized (mLock) {
mLocalUnlockedUsers.remove(userId);
}
} catch (Exception e) {
Slog.wtf(TAG, e);
}