Merge "Revert "UserController: avoid misleading log messages about failed to find key"" into sc-dev

This commit is contained in:
Tianjie Xu
2021-03-30 21:44:17 +00:00
committed by Android (Google) Code Review
2 changed files with 0 additions and 36 deletions

View File

@@ -1641,13 +1641,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);
}
@@ -3108,11 +3101,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();
}
}
}

View File

@@ -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);