diff options
-rw-r--r-- | services/core/java/com/android/server/attention/AttentionManagerService.java | 3 | ||||
-rw-r--r-- | services/tests/servicestests/src/com/android/server/attention/AttentionManagerServiceTest.java | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/attention/AttentionManagerService.java b/services/core/java/com/android/server/attention/AttentionManagerService.java index d7d4851bf33f..b50af28b12b3 100644 --- a/services/core/java/com/android/server/attention/AttentionManagerService.java +++ b/services/core/java/com/android/server/attention/AttentionManagerService.java @@ -309,7 +309,8 @@ public class AttentionManagerService extends SystemService { } @GuardedBy("mLock") - private UserState getOrCreateUserStateLocked(int userId) { + @VisibleForTesting + protected UserState getOrCreateUserStateLocked(int userId) { UserState result = mUserStates.get(userId); if (result == null) { result = new UserState(userId, mContext, mLock, mComponentName); diff --git a/services/tests/servicestests/src/com/android/server/attention/AttentionManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/attention/AttentionManagerServiceTest.java index 8426a0bb2c11..bb9f49e6f37f 100644 --- a/services/tests/servicestests/src/com/android/server/attention/AttentionManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/attention/AttentionManagerServiceTest.java @@ -132,6 +132,13 @@ public class AttentionManagerServiceTest { verify(callback).onSuccess(anyInt(), anyLong()); } + @Test + public void testOnSwitchUser_noCrashCurrentServiceIsNull() { + final int userId = 10; + mSpyAttentionManager.getOrCreateUserStateLocked(userId); + mSpyAttentionManager.onSwitchUser(userId); + } + private class MockIAttentionService implements IAttentionService { public void checkAttention(IAttentionCallback callback) throws RemoteException { callback.onSuccess(0, 0); |