Loading services/core/java/com/android/server/am/UserController.java +0 −13 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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(); } } } services/tests/servicestests/src/com/android/server/am/UserControllerTest.java +0 −23 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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<>(); Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading
services/core/java/com/android/server/am/UserController.java +0 −13 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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(); } } }
services/tests/servicestests/src/com/android/server/am/UserControllerTest.java +0 −23 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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<>(); Loading Loading @@ -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); Loading Loading @@ -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); Loading