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

Commit d9cc54df authored by Tianjie Xu's avatar Tianjie Xu
Browse files

Revert "UserController: avoid misleading log messages about failed to find key"

This reverts commit b0a72e22.

Reason for revert: b/183786247. It breaks resume on reboot & block droidfood

Change-Id: Id4170c7050d34d0289183e606718ad0e2ea58529
parent b0a72e22
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -1635,13 +1635,6 @@ class UserController implements Handler.Callback {
     * PIN or pattern.
     */
    private boolean maybeUnlockUser(final @UserIdInt int userId) {
        if (mInjector.isFileEncryptedNativeOnly() && mLockPatternUtils.isSecure(userId)) {
            // A token is needed, so don't bother trying to unlock without one.
            // This keeps misleading error messages from being logged.
            Slog.d(TAG, "Not unlocking user " + userId
                    + "'s CE storage yet because a credential token is needed");
            return false;
        }
        // Try unlocking storage using empty token
        return unlockUserCleared(userId, null, null, null);
    }
@@ -3092,11 +3085,5 @@ class UserController implements Handler.Callback {
        protected IStorageManager getStorageManager() {
            return IStorageManager.Stub.asInterface(ServiceManager.getService("mount"));
        }

        // This is needed because isFileEncryptedNativeOnly is a static method,
        // but it needs to be mocked out in tests.
        protected boolean isFileEncryptedNativeOnly() {
            return StorageManager.isFileEncryptedNativeOnly();
        }
    }
}
+0 −23
Original line number Diff line number Diff line
@@ -80,7 +80,6 @@ import android.util.Log;

import androidx.test.filters.SmallTest;

import com.android.internal.widget.LockPatternUtils;
import com.android.server.FgThread;
import com.android.server.am.UserState.KeyEvictedCallback;
import com.android.server.pm.UserManagerInternal;
@@ -124,7 +123,6 @@ public class UserControllerTest {
    private static final long HANDLER_WAIT_TIME_MS = 100;

    private UserController mUserController;
    private LockPatternUtils mLockPatternUtils;
    private TestInjector mInjector;
    private final HashMap<Integer, UserState> mUserStates = new HashMap<>();

@@ -163,13 +161,6 @@ public class UserControllerTest {
            doNothing().when(mInjector).activityManagerOnUserStopped(anyInt());
            doNothing().when(mInjector).clearBroadcastQueueForUser(anyInt());
            doNothing().when(mInjector).taskSupervisorRemoveUser(anyInt());

            // Make it appear that calling unlockUserKey() is needed.
            doReturn(true).when(mInjector).isFileEncryptedNativeOnly();
            mLockPatternUtils = mock(LockPatternUtils.class);
            when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
            doReturn(mLockPatternUtils).when(mInjector).getLockPatternUtils();

            // All UserController params are set to default.
            mUserController = new UserController(mInjector);
            setUpUser(TEST_USER_ID, NO_USERINFO_FLAGS);
@@ -561,20 +552,6 @@ public class UserControllerTest {
                /* keyEvictedCallback= */ mKeyEvictedCallback, /* expectLocking= */ true);
    }

    /**
     * Test that if a user has a lock screen credential set, then UserController
     * doesn't bother trying to unlock their storage key without a credential
     * token, as it will never work.
     */
    @Test
    public void testSecureUserUnlockNotAttempted() throws Exception {
        when(mLockPatternUtils.isSecure(eq(TEST_USER_ID1))).thenReturn(true);
        setUpUser(TEST_USER_ID1, 0);
        mUserController.startUser(TEST_USER_ID1, /* foreground= */ false);
        verify(mInjector.mStorageManagerMock, times(0))
                .unlockUserKey(eq(TEST_USER_ID1), anyInt(), any(), any());
    }

    @Test
    public void testStartProfile_fullUserFails() {
        setUpUser(TEST_USER_ID1, 0);