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

Commit 7f74ca73 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Ensure adb key store is instantiated before revoking grants"...

Merge "Merge "Ensure adb key store is instantiated before revoking grants" into qt-qpr1-dev am: b6f974b2" into qt-qpr1-dev-plus-aosp
parents d4a71792 0517675a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -413,6 +413,11 @@ public class AdbDebuggingManager {
                case MESSAGE_ADB_CLEAR: {
                    Slog.d(TAG, "Received a request to clear the adb authorizations");
                    mConnectedKeys.clear();
                    // If the key store has not yet been instantiated then do so now; this avoids
                    // the unnecessary creation of the key store when adb is not enabled.
                    if (mAdbKeyStore == null) {
                        mAdbKeyStore = new AdbKeyStore();
                    }
                    mAdbKeyStore.deleteKeyStore();
                    cancelJobToUpdateAdbKeyStore();
                    break;
+24 −0
Original line number Diff line number Diff line
@@ -672,6 +672,30 @@ public final class AdbDebuggingManagerTest {
                connectionTime2, mKeyStore.getLastConnectionTime(TEST_KEY_2));
    }

    @Test
    public void testClearAuthorizationsBeforeAdbEnabled() throws Exception {
        // The adb key store is not instantiated until adb is enabled; however if the user attempts
        // to clear the adb authorizations when adb is disabled after a boot a NullPointerException
        // was thrown as deleteKeyStore is invoked against the key store. This test ensures the
        // key store can be successfully cleared when adb is disabled.
        mHandler = mManager.new AdbDebuggingHandler(FgThread.get().getLooper());

        clearKeyStore();
    }

    @Test
    public void testClearAuthorizationsDeletesKeyFiles() throws Exception {
        mAdbKeyFile.createNewFile();
        mAdbKeyXmlFile.createNewFile();

        clearKeyStore();

        assertFalse("The adb key file should have been deleted after revocation of the grants",
                mAdbKeyFile.exists());
        assertFalse("The adb xml key file should have been deleted after revocation of the grants",
                mAdbKeyXmlFile.exists());
    }

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