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

Commit a8853fe2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add unit tests for AttentionManagerService. Make sure it won't crash...

Merge "Add unit tests for AttentionManagerService. Make sure it won't crash when OnSwitchUser() is invoked while the bound service is null." into qt-dev
parents eaf1f8fd fa323e7d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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);
+7 −0
Original line number Diff line number Diff line
@@ -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);