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

Commit 5cfa23e4 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Request focus on recents animation input consumers

When setting up the recents animation input consumer,
provide focus to the input consumer. While we are
animating into recents, SystemUI needs to intercept
all input directed towards the app. Without intercepting
keys, the system will ANR the app going into recents.
This was the original behavior but regressed because of
the focus request change.

Test: go/wm-smoke
Test: atest FlickerTest
Fixes: 177923822
Change-Id: If9ac76fcb81a72f2c57407ce4a218f0954545abb
parent 04501d56
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -811,6 +811,12 @@
      "group": "WM_DEBUG_STATES",
      "at": "com\/android\/server\/wm\/Task.java"
    },
    "-1159577965": {
      "message": "Focus requested for input consumer=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/InputMonitor.java"
    },
    "-1156118957": {
      "message": "Updated config=%s",
      "level": "DEBUG",
@@ -823,12 +829,6 @@
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "at": "com\/android\/server\/wm\/NonAppWindowAnimationAdapter.java"
    },
    "-1144293044": {
      "message": "SURFACE SET FREEZE LAYER: %s",
      "level": "INFO",
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowStateAnimator.java"
    },
    "-1142279614": {
      "message": "Looking for focus: %s, flags=%d, canReceive=%b, reason=%s",
      "level": "VERBOSE",
+18 −5
Original line number Diff line number Diff line
@@ -410,15 +410,19 @@ final class InputMonitor {
            return;
        }

        requestFocus(focusToken, focus.getName());
    }

    private void requestFocus(IBinder focusToken, String windowName) {
        if (focusToken == mInputFocus) {
            return;
        }

        mInputFocus = focusToken;
        mInputTransaction.setFocusedWindow(mInputFocus, focus.getName(), mDisplayId);
        EventLog.writeEvent(LOGTAG_INPUT_FOCUS, "Focus request " + focus,
        mInputTransaction.setFocusedWindow(mInputFocus, windowName, mDisplayId);
        EventLog.writeEvent(LOGTAG_INPUT_FOCUS, "Focus request " + windowName,
                "reason=UpdateInputWindows");
        ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "Focus requested for window=%s", focus);
        ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "Focus requested for window=%s", windowName);
    }

    void setFocusedAppLw(ActivityRecord newApp) {
@@ -470,6 +474,8 @@ final class InputMonitor {

        boolean mInDrag;

        private boolean mRecentsAnimationFocusOverride;

        private void updateInputWindows(boolean inDrag) {
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "updateInputWindows");

@@ -485,10 +491,16 @@ final class InputMonitor {
            mInDrag = inDrag;

            resetInputConsumers(mInputTransaction);

            mRecentsAnimationFocusOverride = false;
            mDisplayContent.forAllWindows(this, true /* traverseTopToBottom */);

            if (mRecentsAnimationFocusOverride) {
                requestFocus(mRecentsAnimationInputConsumer.mWindowHandle.token,
                        mRecentsAnimationInputConsumer.mName);
            } else {
                updateInputFocusRequest();
            }


            if (!mUpdateInputWindowsImmediately) {
                mDisplayContent.getPendingTransaction().merge(mInputTransaction);
@@ -526,6 +538,7 @@ final class InputMonitor {
                        mRecentsAnimationInputConsumer.mWindowHandle)) {
                    mRecentsAnimationInputConsumer.show(mInputTransaction, w.mActivityRecord);
                    mAddRecentsAnimationInputConsumerHandle = false;
                    mRecentsAnimationFocusOverride = true;
                }
            }