From 6e4fea576cfd1190317d0b898b769885988acde5 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 13 Jul 2023 18:41:31 +0000 Subject: [PATCH] Ensure the getCredentialType cache gets enabled Invalidate the getCredentialType cache at boot time. This works around an issue in PropertyInvalidatedCache where caches don't work until they are invalidated for the first time. This workaround can be removed if the underlying issue in PropertyInvalidatedCache is fixed, but that will require a bit more discussion and will be riskier than this workaround. This fixes a performance regression introduced by ag/19284361 ("Simplify invalidation of lockscreen credential type cache"). That CL eliminated unnecessary cache invalidations, which should have improved performance. Unfortunately, due to the unexpected PropertyInvalidatedCache behavior, it actually made the cache stop working entirely in the common case where no user's lockscreen credential has changed since boot. Bug: 268192609 Test: Set DEBUG=true in PropertyInvalidatedCache.java. Build and flash. Run 'adb logcat | grep getCredentialType', and turn screen off and on. Verified that "cache hit" messages are logged, whereas before this CL "cache getCredentialType unset" messages were logged. Change-Id: Ie826bdb163288e5741a33e26209d3175de426bd1 (cherry picked from commit d91457a155c99bb4506e8c70c0129b634f3e1247) Merged-In: Ie826bdb163288e5741a33e26209d3175de426bd1 --- core/java/com/android/internal/widget/LockPatternUtils.java | 2 +- .../com/android/server/locksettings/LockSettingsService.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index e0183931777bc..1b1efeed5ff2b 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -1035,7 +1035,7 @@ public class LockPatternUtils { CREDENTIAL_TYPE_API, CREDENTIAL_TYPE_API, mCredentialTypeQuery); /** - * Invalidate the credential cache + * Invalidate the credential type cache * @hide */ public final static void invalidateCredentialTypeCache() { diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index a96e4adf1fee9..0616f4e9d5ace 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -844,6 +844,10 @@ public class LockSettingsService extends ILockSettings.Stub { getAuthSecretHal(); mDeviceProvisionedObserver.onSystemReady(); + // Work around an issue in PropertyInvalidatedCache where the cache doesn't work until the + // first invalidation. This can be removed if PropertyInvalidatedCache is fixed. + LockPatternUtils.invalidateCredentialTypeCache(); + // TODO: maybe skip this for split system user mode. mStorage.prefetchUser(UserHandle.USER_SYSTEM); mBiometricDeferredQueue.systemReady(mInjector.getFingerprintManager(),