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

Commit 8ac43ebe authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix crashed reportSystemGestureExclusionChanged" into main

parents 68b689a6 9f970266
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -4648,7 +4648,14 @@ public class WindowManagerService extends IWindowManager.Stub
    void reportSystemGestureExclusionChanged(Session session, IWindow window,
            List<Rect> exclusionRects) {
        synchronized (mGlobalLock) {
            final WindowState win = windowForClientLocked(session, window, true);
            final WindowState win = windowForClientLocked(session, window,
                    false /* throwOnError */);
            if (win == null) {
                Slog.i(TAG_WM,
                        "reportSystemGestureExclusionChanged(): No window state for package:"
                                + session.mPackageName);
                return;
            }
            if (win.setSystemGestureExclusion(exclusionRects)) {
                win.getDisplayContent().updateSystemGestureExclusion();
            }
@@ -4658,7 +4665,14 @@ public class WindowManagerService extends IWindowManager.Stub
    void reportKeepClearAreasChanged(Session session, IWindow window,
            List<Rect> restricted, List<Rect> unrestricted) {
        synchronized (mGlobalLock) {
            final WindowState win = windowForClientLocked(session, window, true);
            final WindowState win = windowForClientLocked(session, window,
                    false /* throwOnError */);
            if (win == null) {
                Slog.i(TAG_WM,
                        "reportKeepClearAreasChanged(): No window state for package:"
                                + session.mPackageName);
                return;
            }
            if (win.setKeepClearAreas(restricted, unrestricted)) {
                win.getDisplayContent().updateKeepClearAreas();
            }
+24 −0
Original line number Diff line number Diff line
@@ -107,6 +107,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;

import java.util.ArrayList;

/**
 * Build/Install/Run:
 * atest WmTests:WindowManagerServiceTests
@@ -975,6 +977,28 @@ public class WindowManagerServiceTests extends WindowTestsBase {
        verify(window, times(2)).requestAppKeyboardShortcuts(receiver, 0);
    }

    @Test
    public void testReportSystemGestureExclusionChanged_invalidWindow() {
        final Session session = mock(Session.class);
        final IWindow window = mock(IWindow.class);
        final IBinder binder = mock(IBinder.class);
        doReturn(binder).when(window).asBinder();

        // No exception even if the window doesn't exist
        mWm.reportSystemGestureExclusionChanged(session, window, new ArrayList<>());
    }

    @Test
    public void testReportKeepClearAreasChanged_invalidWindow() {
        final Session session = mock(Session.class);
        final IWindow window = mock(IWindow.class);
        final IBinder binder = mock(IBinder.class);
        doReturn(binder).when(window).asBinder();

        // No exception even if the window doesn't exist
        mWm.reportKeepClearAreasChanged(session, window, new ArrayList<>(), new ArrayList<>());
    }

    class TestResultReceiver implements IResultReceiver {
        public android.os.Bundle resultData;
        private final IBinder mBinder = mock(IBinder.class);