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

Commit dc7356a4 authored by Tiger Huang's avatar Tiger Huang
Browse files

Fix an issue which causes back key doesn't work

This issue is caused ag/5777021, which drops keys unexpectedly.

Change-Id: I23122dce9032555385fa1091527317d4bec92326
Fix: 121111244
Test: Manual
parent 860ed7c6
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -2549,12 +2549,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    @Override
    @Override
    public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) {
    public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) {
        final long result = interceptKeyBeforeDispatchingInner(win, event, policyFlags);
        final long result = interceptKeyBeforeDispatchingInner(win, event, policyFlags);
        final int eventDisplayId = event.getDisplayId();
        if (result == 0 && !mPerDisplayFocusEnabled
        if (result == 0 && !mPerDisplayFocusEnabled
                && event.getDisplayId() != mTopFocusedDisplayId) {
                && eventDisplayId != INVALID_DISPLAY && eventDisplayId != mTopFocusedDisplayId) {
            // Someone tries to send a key event to a display which doesn't have a focused window.
            // Someone tries to send a key event to a display which doesn't have a focused window.
            // We drop the event here, or it will cause ANR.
            // We drop the event here, or it will cause ANR.
            // TODO (b/121057974): The user may be confused about why the key doesn't work, so we
            // TODO (b/121057974): The user may be confused about why the key doesn't work, so we
            // may need to deal with this problem.
            // may need to deal with this problem.
            Slog.i(TAG, "Dropping this event targeting display #" + eventDisplayId
                    + " because the focus is on display #" + mTopFocusedDisplayId);
            return -1;
            return -1;
        }
        }
        return result;
        return result;
+1 −0
Original line number Original line Diff line number Diff line
@@ -184,6 +184,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        if (mTopFocusedDisplayId != topFocusedDisplayId) {
        if (mTopFocusedDisplayId != topFocusedDisplayId) {
            mTopFocusedDisplayId = topFocusedDisplayId;
            mTopFocusedDisplayId = topFocusedDisplayId;
            mWmService.mInputManager.setFocusedDisplay(topFocusedDisplayId);
            mWmService.mInputManager.setFocusedDisplay(topFocusedDisplayId);
            mWmService.mPolicy.setTopFocusedDisplay(topFocusedDisplayId);
            if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "New topFocusedDisplayId="
            if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "New topFocusedDisplayId="
                    + topFocusedDisplayId);
                    + topFocusedDisplayId);
        }
        }