Change a nullable get to getOrDefault(,false)

Implicitly casting from a Map<,Boolean> to a boolean will cause a
NullPointerException if the map isn't populated yet. The default
should be false because this is more conservative with respect to
how users are allowed to unlock their device if the real information
isn't available yet (or won't be available because the device doesn't
have a keyguard yet still calls this API).

Test: adb reboot; adb logcat | grep NullPointerException
Fix: 231987867
Change-Id: Ie631286a30eaa1d9db36d8a149b9165df292429d
This commit is contained in:
Robin Lee
2022-05-10 08:45:28 +02:00
parent 33350105bc
commit 93a98d862f

View File

@@ -2795,7 +2795,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
* Note: checking fingerprint enrollment directly with the AuthController requires an IPC.
*/
public boolean getCachedIsUnlockWithFingerprintPossible(int userId) {
return mIsUnlockWithFingerprintPossible.get(userId);
return mIsUnlockWithFingerprintPossible.getOrDefault(userId, false);
}
private boolean isUnlockWithFacePossible(int userId) {