From 3d79cd1bb1ce5bd0fba605a0f16790a855ee5bdf Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 7 Jul 2022 19:00:49 +0000 Subject: [PATCH] Fix misleading code in sendCredentialsOnUnlockIfRequired() lockScreenSecretAvailable() takes a @NonNull credential, so the code in sendCredentialsOnUnlockIfRequired() that conditionally passes a null credential is incorrect. This doesn't actually matter, since sendCredentialsOnUnlockIfRequired() is never called with CREDENTIAL_TYPE_NONE anyway. But make it do the more logical thing of skipping the call to lockScreenSecretAvailable() in this case. Test: atest com.android.server.locksettings Change-Id: I026f72ccaadef94a2f43cb6c2a70e8c08d21360c --- .../android/server/locksettings/LockSettingsService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index ee8a23c08b4a6..e9ef8a7bfde15 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -1588,6 +1588,11 @@ public class LockSettingsService extends ILockSettings.Stub { return; } + // Don't send empty credentials on unlock. + if (credential.isNone()) { + return; + } + // A profile with a unified lock screen stores a randomly generated credential, so skip it. // Its parent will send credentials for the profile, as it stores the unified lock // credential. @@ -1595,12 +1600,10 @@ public class LockSettingsService extends ILockSettings.Stub { return; } - // RecoverableKeyStoreManager expects null for empty credential. - final byte[] secret = credential.isNone() ? null : credential.getCredential(); // Send credentials for the user and any child profiles that share its lock screen. for (int profileId : getProfilesWithSameLockScreen(userId)) { mRecoverableKeyStoreManager.lockScreenSecretAvailable( - credential.getType(), secret, profileId); + credential.getType(), credential.getCredential(), profileId); } }