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
This commit is contained in:
Eric Biggers
2022-07-07 19:00:49 +00:00
parent bbc8dbe965
commit 3d79cd1bb1

View File

@@ -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);
}
}