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

Commit 6a974fad authored by Ashley Holton's avatar Ashley Holton Committed by Android (Google) Code Review
Browse files

Merge "Update native input manager when display group removed" into main

parents 1fc4c2d8 131ac775
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -771,6 +771,10 @@ public class Notifier {
    public void onGroupRemoved(int groupId) {
        mInteractivityByGroupId.remove(groupId);
        mWakefulnessSessionObserver.removePowerGroup(groupId);
        if (mFlags.isPerDisplayWakeByTouchEnabled()) {
            resetDisplayInteractivities();
            mInputManagerInternal.setDisplayInteractivities(mDisplayInteractivities);
        }
    }

    /**
+27 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import android.os.test.TestLooper;
import android.provider.Settings;
import android.testing.TestableContext;
import android.util.IntArray;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.view.Display;
import android.view.DisplayAddress;
@@ -383,6 +384,32 @@ public class NotifierTest {
        verify(mInputManagerInternal).setDisplayInteractivities(expectedDisplayInteractivities);
    }

    @Test
    public void testOnGroupRemoved_perDisplayWakeByTouchEnabled() {
        createNotifier();
        // GIVEN per-display wake by touch is enabled and one display group has been defined
        when(mPowerManagerFlags.isPerDisplayWakeByTouchEnabled()).thenReturn(true);
        final int groupId = 313;
        final int displayId1 = 3113;
        final int displayId2 = 4114;
        final int[] displays = new int[]{displayId1, displayId2};
        when(mDisplayManagerInternal.getDisplayIds()).thenReturn(IntArray.wrap(displays));
        when(mDisplayManagerInternal.getDisplayIdsForGroup(groupId)).thenReturn(displays);
        mNotifier.onGroupWakefulnessChangeStarted(
                groupId, WAKEFULNESS_AWAKE, PowerManager.WAKE_REASON_TAP, /* eventTime= */ 1000);
        final SparseBooleanArray expectedDisplayInteractivities = new SparseBooleanArray();
        expectedDisplayInteractivities.put(displayId1, true);
        expectedDisplayInteractivities.put(displayId2, true);
        verify(mInputManagerInternal).setDisplayInteractivities(expectedDisplayInteractivities);

        // WHEN display group is removed
        when(mDisplayManagerInternal.getDisplayIdsByGroupsIds()).thenReturn(new SparseArray<>());
        mNotifier.onGroupRemoved(groupId);

        // THEN native input manager is informed that displays in that group no longer exist
        verify(mInputManagerInternal).setDisplayInteractivities(new SparseBooleanArray());
    }

    @Test
    public void testOnWakeLockListener_RemoteException_NoRethrow() throws RemoteException {
        when(mPowerManagerFlags.improveWakelockLatency()).thenReturn(true);