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

Commit 2798b7bd authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6209883 from 2c4c1f1e to qt-qpr3-release

Change-Id: I01b26bc160d71068053ed4471fe3498da56c960e
parents 92d90249 2c4c1f1e
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;
+7 −1
Original line number Diff line number Diff line
@@ -408,6 +408,7 @@ class UserController implements Handler.Callback {
     */
    private boolean finishUserUnlocking(final UserState uss) {
        final int userId = uss.mHandle.getIdentifier();
        Slog.d(TAG, "UserController event: finishUserUnlocking(" + userId + ")");
        // Only keep marching forward if user is actually unlocked
        if (!StorageManager.isUserKeyUnlocked(userId)) return false;
        synchronized (mLock) {
@@ -452,6 +453,7 @@ class UserController implements Handler.Callback {
     */
    void finishUserUnlocked(final UserState uss) {
        final int userId = uss.mHandle.getIdentifier();
        Slog.d(TAG, "UserController event: finishUserUnlocked(" + userId + ")");
        // Only keep marching forward if user is actually unlocked
        if (!StorageManager.isUserKeyUnlocked(userId)) return;
        synchronized (mLock) {
@@ -522,6 +524,7 @@ class UserController implements Handler.Callback {

    private void finishUserUnlockedCompleted(UserState uss) {
        final int userId = uss.mHandle.getIdentifier();
        Slog.d(TAG, "UserController event: finishUserUnlockedCompleted(" + userId + ")");
        synchronized (mLock) {
            // Bail if we ended up with a stale user
            if (mStartedUsers.get(uss.mHandle.getIdentifier()) != uss) return;
@@ -739,6 +742,7 @@ class UserController implements Handler.Callback {
    }

    void finishUserStopping(final int userId, final UserState uss) {
        Slog.d(TAG, "UserController event: finishUserStopping(" + userId + ")");
        // On to the next.
        final Intent shutdownIntent = new Intent(Intent.ACTION_SHUTDOWN);
        // This is the result receiver for the final shutdown broadcast.
@@ -778,6 +782,7 @@ class UserController implements Handler.Callback {

    void finishUserStopped(UserState uss) {
        final int userId = uss.mHandle.getIdentifier();
        Slog.d(TAG, "UserController event: finishUserStopped(" + userId + ")");
        final boolean stopped;
        boolean lockUser = true;
        final ArrayList<IStopUserCallback> stopCallbacks;
@@ -1259,7 +1264,7 @@ class UserController implements Handler.Callback {
            Slog.w(TAG, msg);
            throw new SecurityException(msg);
        }

        Slog.i(TAG, "unlocking user " + userId);
        final long binderToken = Binder.clearCallingIdentity();
        try {
            return unlockUserCleared(userId, token, secret, listener);
@@ -1344,6 +1349,7 @@ class UserController implements Handler.Callback {

    boolean switchUser(final int targetUserId) {
        enforceShellRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES, targetUserId);
        Slog.i(TAG, "switching to user " + targetUserId);
        int currentUserId = getCurrentUserId();
        UserInfo targetUserInfo = getUserInfo(targetUserId);
        if (targetUserId == currentUserId) {
+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.
     *