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

Commit aa1ed584 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Remove key from adb_keys if user forgets the key." into rvc-dev am:...

Merge "Remove key from adb_keys if user forgets the key." into rvc-dev am: b76d7aa6 am: 903113eb

Change-Id: I4ea87f6d4bb9886a710f098ad3a519522c188c3d
parents d036bebf 903113eb
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -1853,6 +1853,7 @@ public class AdbDebuggingManager {
        public void removeKey(String key) {
        public void removeKey(String key) {
            if (mKeyMap.containsKey(key)) {
            if (mKeyMap.containsKey(key)) {
                mKeyMap.remove(key);
                mKeyMap.remove(key);
                writeKeys(mKeyMap.keySet());
                sendPersistKeyStoreMessage();
                sendPersistKeyStoreMessage();
            }
            }
        }
        }
+25 −0
Original line number Original line Diff line number Diff line
@@ -696,6 +696,31 @@ public final class AdbDebuggingManagerTest {
                mAdbKeyXmlFile.exists());
                mAdbKeyXmlFile.exists());
    }
    }


    @Test
    public void testAdbKeyStore_removeKey() throws Exception {
        // Accept the test key with the 'Always allow' option selected.
        runAdbTest(TEST_KEY_1, true, true, false);
        runAdbTest(TEST_KEY_2, true, true, false);

        // Set the connection time to 0 to restore the original behavior.
        setAllowedConnectionTime(0);

        // Verify that the key is in the adb_keys file to ensure subsequent connections are
        // automatically allowed by adbd.
        persistKeyStore();
        assertTrue("The key was not in the adb_keys file after persisting the keystore",
                isKeyInFile(TEST_KEY_1, mAdbKeyFile));
        assertTrue("The key was not in the adb_keys file after persisting the keystore",
                isKeyInFile(TEST_KEY_2, mAdbKeyFile));

        // Now remove one of the keys and make sure the other key is still there
        mKeyStore.removeKey(TEST_KEY_1);
        assertFalse("The key was still in the adb_keys file after removing the key",
                isKeyInFile(TEST_KEY_1, mAdbKeyFile));
        assertTrue("The key was not in the adb_keys file after removing a different key",
                isKeyInFile(TEST_KEY_2, mAdbKeyFile));
    }

    /**
    /**
     * Runs an adb test with the provided configuration.
     * Runs an adb test with the provided configuration.
     *
     *