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

Commit 6e5897b3 authored by Merissa Mitchell's avatar Merissa Mitchell
Browse files

Don't handle touch events if WindowDecoration is null

This CL adds null checks for the WindowDecoration for motion and click
listeners in DesktopModeWindowDecorViewModel. If the WindowDecor is
null, we shouldn't handle any more touch/hover/click events.

This is a short term fix for the issue where decoration.close triggers motion events, which when handled tries to get a reference to a WindowDecor that has been removed from the map (b/327664694). In the long term we should move event handling closer to the Decor.

Bug: 412749075
Test: atest DesktopModeWindowDecorViewModelTests
Flag: EXEMPT bugfix
Change-Id: I53b724234e238b86ae0220cdfeeb5651a6e8012a
parent 3dc09e3e
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1094,6 +1094,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                return;
            }
            final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId);
            if (decoration == null) {
                return;
            }
            final int id = v.getId();
            if (id == R.id.close_window) {
                if (isTaskInSplitScreen(mTaskId)) {
@@ -1255,6 +1258,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
            final int id = v.getId();
            if (id == R.id.maximize_window && !mLongClickDisabled) {
                final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId);
                if (decoration == null) {
                    return false;
                }
                moveTaskToFront(decoration.mTaskInfo);
                if (!decoration.isMaximizeMenuActive()) {
                    decoration.createMaximizeMenu();
@@ -1272,6 +1278,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        public boolean onGenericMotion(View v, MotionEvent ev) {
            mMotionEvent = ev;
            final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId);
            if (decoration == null) {
                return false;
            }
            final int id = v.getId();
            if (ev.getAction() == ACTION_HOVER_ENTER && id == R.id.maximize_window) {
                decoration.setAppHeaderMaximizeButtonHovered(true);
@@ -1312,6 +1321,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        @Override
        public boolean handleMotionEvent(@Nullable View v, MotionEvent e) {
            final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId);
            if (decoration == null) {
                return false;
            }
            final RunningTaskInfo taskInfo = decoration.mTaskInfo;
            if (mShellDesktopState.canEnterDesktopModeOrShowAppHandle()
                    && !taskInfo.isFreeform()) {