LockSettingsService: clear gatekeeper state when removing user

On some devices gatekeeper would fail after certain enrollments due to
some persistent state left around when removing users.

Bug: 224397241
Fixes: 224397241
Test: atest com.android.server.locksettings
Change-Id: I49861e11b265b56c395cdb25eef13c8b3a33ef19
(cherry picked from commit 6a5deda4b3)
This commit is contained in:
Alain Vongsouvanh
2022-03-23 11:23:22 -07:00
parent b07646b6e3
commit 91f6bfe7db
2 changed files with 9 additions and 2 deletions

View File

@@ -2473,7 +2473,7 @@ public class LockSettingsService extends ILockSettings.Stub {
private void removeUser(int userId, boolean unknownUser) {
Slog.i(TAG, "RemoveUser: " + userId);
removeBiometricsForUser(userId);
mSpManager.removeUser(userId);
mSpManager.removeUser(getGateKeeperService(), userId);
mStrongAuth.removeUser(userId);
AndroidKeyStoreMaintenance.onUserRemoved(userId);

View File

@@ -565,11 +565,18 @@ public class SyntheticPasswordManager {
return response[0];
}
public void removeUser(int userId) {
public void removeUser(IGateKeeperService gatekeeper, int userId) {
for (long handle : mStorage.listSyntheticPasswordHandlesForUser(SP_BLOB_NAME, userId)) {
destroyWeaverSlot(handle, userId);
destroySPBlobKey(getKeyName(handle));
}
// Remove potential persistent state (in RPMB), to prevent them from accumulating and
// causing problems.
try {
gatekeeper.clearSecureUserId(fakeUid(userId));
} catch (RemoteException ignore) {
Slog.w(TAG, "Failed to clear SID from gatekeeper");
}
}
int getCredentialType(long handle, int userId) {