Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 912f6588 authored by Eric Biggers's avatar Eric Biggers
Browse files

Simplify invalidation of lockscreen credential type cache

There's no need to bubble up notifications from individual operations on
the storage.  Instead, LockSettingsService can simply invalidate the
cache when it changes the lockscreen credential.

Bug: 238658408
Change-Id: I94bc583184b2c8361d33f3f439040da5917d78ee
parent bfd0db18
Loading
Loading
Loading
Loading
+1 −19
Original line number Diff line number Diff line
@@ -144,8 +144,6 @@ import com.android.server.locksettings.SyntheticPasswordManager.AuthenticationTo
import com.android.server.locksettings.SyntheticPasswordManager.TokenType;
import com.android.server.locksettings.recoverablekeystore.RecoverableKeyStoreManager;
import com.android.server.pm.UserManagerInternal;
import com.android.server.utils.Watchable;
import com.android.server.utils.Watcher;
import com.android.server.wm.WindowManagerInternal;

import libcore.util.HexEncoding;
@@ -227,7 +225,6 @@ public class LockSettingsService extends ILockSettings.Stub {
    protected final Handler mHandler;
    @VisibleForTesting
    protected final LockSettingsStorage mStorage;
    private final Watcher mStorageWatcher;
    private final LockSettingsStrongAuth mStrongAuth;
    private final SynchronizedStrongAuthTracker mStrongAuthTracker;
    private final BiometricDeferredQueue mBiometricDeferredQueue;
@@ -564,12 +561,6 @@ public class LockSettingsService extends ILockSettings.Stub {
        }
    }

    private class StorageWatcher extends Watcher {
        public void onChange(Watchable what) {
            LockSettingsService.this.onChange();
        }
    }

    public LockSettingsService(Context context) {
        this(new Injector(context));
    }
@@ -609,16 +600,6 @@ public class LockSettingsService extends ILockSettings.Stub {
                mStorage);

        LocalServices.addService(LockSettingsInternal.class, new LocalService());

        mStorageWatcher = new StorageWatcher();
        mStorage.registerObserver(mStorageWatcher);
    }

    /**
     * Invalidate caches if the storage has changed.
     */
    private void onChange() {
        LockPatternUtils.invalidateCredentialTypeCache();
    }

    /**
@@ -2868,6 +2849,7 @@ public class LockSettingsService extends ILockSettings.Stub {
            removeBiometricsForUser(userId);
        }
        setSyntheticPasswordHandleLocked(newHandle, userId);
        LockPatternUtils.invalidateCredentialTypeCache();
        synchronizeUnifiedWorkChallengeForProfiles(userId, profilePasswords);

        setUserPasswordMetrics(credential, userId);
+1 −8
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import com.android.internal.util.Preconditions;
import com.android.internal.widget.LockPatternUtils;
import com.android.server.LocalServices;
import com.android.server.PersistentDataBlockManagerInternal;
import com.android.server.utils.WatchableImpl;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -66,7 +65,7 @@ import java.util.Map;
/**
 * Storage for the lock settings service.
 */
class LockSettingsStorage extends WatchableImpl {
class LockSettingsStorage {

    private static final String TAG = "LockSettingsStorage";
    private static final String TABLE = "locksettings";
@@ -136,7 +135,6 @@ class LockSettingsStorage extends WatchableImpl {
        } finally {
            db.endTransaction();
        }
        dispatchChange(this);
    }

    @VisibleForTesting
@@ -194,7 +192,6 @@ class LockSettingsStorage extends WatchableImpl {
        } finally {
            db.endTransaction();
        }
        dispatchChange(this);
    }

    public void prefetchUser(int userId) {
@@ -337,7 +334,6 @@ class LockSettingsStorage extends WatchableImpl {
                }
            }
            mCache.putFile(path, data);
            dispatchChange(this);
        }
    }

@@ -353,7 +349,6 @@ class LockSettingsStorage extends WatchableImpl {
                    Slog.w(TAG, "Failed to zeroize " + path, e);
                }
                path.delete();
                dispatchChange(this);
                mCache.putFile(path, null);
            }
        }
@@ -472,7 +467,6 @@ class LockSettingsStorage extends WatchableImpl {
        } finally {
            db.endTransaction();
        }
        dispatchChange(this);
    }

    public void setBoolean(String key, boolean value, int userId) {
@@ -551,7 +545,6 @@ class LockSettingsStorage extends WatchableImpl {
        }
        persistentDataBlock.setFrpCredentialHandle(PersistentData.toBytes(
                persistentType, userId, qualityForUi, payload));
        dispatchChange(this);
    }

    public PersistentData readPersistentDataBlock() {