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

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

Merge "Make sure keys get flushed when connection falls apart."

parents bb8d5e51 5bbc3013
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect
                return;
            }
            mWasConnectedAndDied = true;
            mSystemSupport.getKeyEventDispatcher().flush(this);
            UserState userState = mUserStateWeakReference.get();
            if (userState != null) {
                userState.serviceDisconnectedLocked(this);
+11 −0
Original line number Diff line number Diff line
@@ -141,4 +141,15 @@ public class AccessibilityServiceConnectionTest {
        when(mMockUserState.getBindingServicesLocked())
                .thenReturn(new HashSet<>(Arrays.asList(componentName)));
    }

    @Test
    public void binderDied_keysGetFlushed() {
        IBinder mockBinder = mock(IBinder.class);
        setServiceBinding(COMPONENT_NAME);
        mConnection.bindLocked();
        mConnection.onServiceConnected(COMPONENT_NAME, mockBinder);
        mConnection.binderDied();
        assertTrue(mConnection.getServiceInfo().crashed);
        verify(mMockKeyEventDispatcher).flush(mConnection);
    }
}