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

Commit 141f0688 authored by Eric Biggers's avatar Eric Biggers Committed by Android (Google) Code Review
Browse files

Merge "Delete old failure_counter file when LSKF is changed" into main

parents 02f51033 cc99e0e5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1822,6 +1822,7 @@ class SyntheticPasswordManager {
        destroyProtectorCommon(protectorId, userId);
        destroyState(PASSWORD_DATA_NAME, protectorId, userId);
        destroyState(PASSWORD_METRICS_NAME, protectorId, userId);
        destroyState(FAILURE_COUNTER_NAME, protectorId, userId);
    }

    private void destroyProtectorCommon(long protectorId, int userId) {
+17 −0
Original line number Diff line number Diff line
@@ -956,6 +956,23 @@ public class SyntheticPasswordTests extends BaseLockSettingsServiceTests {
        }
    }

    @Test
    public void testFailureCounterDeletedOnLskfChanged() throws Exception {
        final int userId = PRIMARY_USER_ID;
        final LockscreenCredential pin = newPin("1234");
        initSpAndSetCredential(userId, pin);
        final long oldProtectorId = mService.getCurrentLskfBasedProtectorId(userId);
        final LskfIdentifier oldLskfId = new LskfIdentifier(userId, oldProtectorId);

        mSpManager.writeFailureCounter(oldLskfId, 1);
        assertEquals(1, mSpManager.readFailureCounter(oldLskfId));
        assertTrue(mService.setLockCredential(nonePassword(), pin, userId));

        final long newProtectorId = mService.getCurrentLskfBasedProtectorId(userId);
        assertNotEquals(oldProtectorId, newProtectorId);
        assertEquals(0, mSpManager.readFailureCounter(oldLskfId));
    }

    // b/62213311
    //TODO: add non-migration work profile case, and unify/un-unify transition.
    //TODO: test token after user resets password