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

Commit b9594ce9 authored by Kenny Root's avatar Kenny Root
Browse files

KeyStore: stop using state()

Change-Id: I721974fd95f8d1ab06a3fd1bbb4c9b4d9d1d7752
parent 37edbbc6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -74,6 +74,10 @@ public class KeyStore {
        }
    }

    public boolean isUnlocked() {
        return state() == State.UNLOCKED;
    }

    public byte[] get(String key) {
        try {
            return mBinder.get(key);
+2 −3
Original line number Diff line number Diff line
@@ -62,11 +62,10 @@ public class AndroidKeyPairGeneratorTest extends AndroidTestCase {

        assertTrue(mAndroidKeyStore.reset());

        assertEquals(android.security.KeyStore.State.UNINITIALIZED, mAndroidKeyStore.state());
        assertFalse(mAndroidKeyStore.isUnlocked());

        assertTrue(mAndroidKeyStore.password("1111"));

        assertEquals(android.security.KeyStore.State.UNLOCKED, mAndroidKeyStore.state());
        assertTrue(mAndroidKeyStore.isUnlocked());

        assertEquals(0, mAndroidKeyStore.saw("").length);

+2 −4
Original line number Diff line number Diff line
@@ -467,12 +467,10 @@ public class AndroidKeyStoreTest extends AndroidTestCase {
        mAndroidKeyStore = android.security.KeyStore.getInstance();

        assertTrue(mAndroidKeyStore.reset());

        assertEquals(android.security.KeyStore.State.UNINITIALIZED, mAndroidKeyStore.state());
        assertFalse(mAndroidKeyStore.isUnlocked());

        assertTrue(mAndroidKeyStore.password("1111"));

        assertEquals(android.security.KeyStore.State.UNLOCKED, mAndroidKeyStore.state());
        assertTrue(mAndroidKeyStore.isUnlocked());

        assertEquals(0, mAndroidKeyStore.saw("").length);

+1 −1
Original line number Diff line number Diff line
@@ -3384,7 +3384,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        // Tear down existing lockdown if profile was removed
        mLockdownEnabled = LockdownVpnTracker.isEnabled();
        if (mLockdownEnabled) {
            if (mKeyStore.state() != KeyStore.State.UNLOCKED) {
            if (!mKeyStore.isUnlocked()) {
                Slog.w(TAG, "KeyStore locked; unable to create LockdownTracker");
                return false;
            }
+1 −1
Original line number Diff line number Diff line
@@ -462,7 +462,7 @@ public class Vpn extends BaseNetworkStateTracker {
     * secondary thread to perform connection work, returning quickly.
     */
    public void startLegacyVpn(VpnProfile profile, KeyStore keyStore, LinkProperties egress) {
        if (keyStore.state() != KeyStore.State.UNLOCKED) {
        if (!keyStore.isUnlocked()) {
            throw new IllegalStateException("KeyStore isn't unlocked");
        }