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

Commit 528c5bc7 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Automerger Merge Worker
Browse files

Merge "Changed task focused to be based on focused app vs. window" into...

Merge "Changed task focused to be based on focused app vs. window" into sc-v2-dev am: c2ee771e am: 3be35ec4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15404412

Change-Id: I8ad5eb4f453407ac907d913b4126041c88fec8ca
parents 88886677 3be35ec4
Loading
Loading
Loading
Loading
+7 −32
Original line number Diff line number Diff line
@@ -501,11 +501,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     */
    WindowState mCurrentFocus = null;

    /**
     * The last focused window that we've notified the client that the focus is changed.
     */
    WindowState mLastFocus = null;

    /**
     * The foreground app of this display. Windows below this app cannot be the focused window. If
     * the user taps on the area outside of the task of the focused app, we will notify AM about the
@@ -1246,12 +1241,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                // removing from parent.
                token.getParent().removeChild(token);
            }
            if (token.hasChild(prevDc.mLastFocus)) {
                // If the reparent window token contains previous display's last focus window, means
                // it will end up to gain window focus on the target display, so it should not be
                // notified that it lost focus from the previous display.
                prevDc.mLastFocus = null;
            }
        }

        addWindowToken(token.token, token);
@@ -3206,9 +3195,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        pw.print(prefix); pw.print("mLayoutSeq="); pw.println(mLayoutSeq);

        pw.print("  mCurrentFocus="); pw.println(mCurrentFocus);
        if (mLastFocus != mCurrentFocus) {
            pw.print("  mLastFocus="); pw.println(mLastFocus);
        }
        pw.print("  mFocusedApp="); pw.println(mFocusedApp);
        if (mFixedRotationLaunchingApp != null) {
            pw.println("  mFixedRotationLaunchingApp=" + mFixedRotationLaunchingApp);
@@ -3439,8 +3425,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }
        }

        onWindowFocusChanged(oldFocus, newFocus);

        int focusChanged = getDisplayPolicy().focusChangedLw(oldFocus, newFocus);

        if (imWindowChanged && oldFocus != mInputMethodWindow) {
@@ -3491,7 +3475,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                    mWmService.mAccessibilityController));
        }

        mLastFocus = mCurrentFocus;
        return true;
    }

@@ -3499,20 +3482,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        accessibilityController.onWindowFocusChangedNot(getDisplayId());
    }

    private static void onWindowFocusChanged(WindowState oldFocus, WindowState newFocus) {
        final Task focusedTask = newFocus != null ? newFocus.getTask() : null;
        final Task unfocusedTask = oldFocus != null ? oldFocus.getTask() : null;
        if (focusedTask == unfocusedTask) {
            return;
        }
        if (focusedTask != null) {
            focusedTask.onWindowFocusChanged(true /* hasFocus */);
        }
        if (unfocusedTask != null) {
            unfocusedTask.onWindowFocusChanged(false /* hasFocus */);
        }
    }

    /**
     * Set the new focused app to this display.
     *
@@ -3536,7 +3505,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }
        ProtoLog.i(WM_DEBUG_FOCUS_LIGHT, "setFocusedApp %s displayId=%d Callers=%s",
                newFocus, getDisplayId(), Debug.getCallers(4));
        final Task oldTask = mFocusedApp != null ? mFocusedApp.getTask() : null;
        final Task newTask = newFocus != null ? newFocus.getTask() : null;
        mFocusedApp = newFocus;
        if (oldTask != newTask) {
            if (oldTask != null) oldTask.onAppFocusChanged(false);
            if (newTask != null) newTask.onAppFocusChanged(true);
        }

        getInputMonitor().setFocusedAppLw(newFocus);
        updateTouchExcludeRegion();
        return true;
@@ -4234,7 +4210,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (DEBUG_INPUT_METHOD) {
            Slog.i(TAG_WM, "Desired input method target: " + imFocus);
            Slog.i(TAG_WM, "Current focus: " + mCurrentFocus + " displayId=" + mDisplayId);
            Slog.i(TAG_WM, "Last focus: " + mLastFocus + " displayId=" + mDisplayId);
        }

        if (DEBUG_INPUT_METHOD) {
+4 −5
Original line number Diff line number Diff line
@@ -4316,10 +4316,10 @@ class Task extends TaskFragment {
     * @return true if the task is currently focused.
     */
    private boolean isFocused() {
        if (mDisplayContent == null || mDisplayContent.mCurrentFocus == null) {
        if (mDisplayContent == null || mDisplayContent.mFocusedApp == null) {
            return false;
        }
        return mDisplayContent.mCurrentFocus.getTask() == this;
        return mDisplayContent.mFocusedApp.getTask() == this;
    }

    /**
@@ -4376,10 +4376,9 @@ class Task extends TaskFragment {
     * Called on the task of a window which gained or lost focus.
     * @param hasFocus
     */
    void onWindowFocusChanged(boolean hasFocus) {
    void onAppFocusChanged(boolean hasFocus) {
        updateShadowsRadius(hasFocus, getSyncTransaction());
        // TODO(b/180525887): Un-comment once there is resolution on the bug.
        // dispatchTaskInfoChangedIfNeeded(false /* force */);
        dispatchTaskInfoChangedIfNeeded(false /* force */);
    }

    void onPictureInPictureParamsChanged() {
+0 −13
Original line number Diff line number Diff line
@@ -873,19 +873,6 @@ public class DisplayContentTests extends WindowTestsBase {
                .setDisplayInfoOverrideFromWindowManager(dc.getDisplayId(), null);
    }

    @UseTestDisplay
    @Test
    public void testClearLastFocusWhenReparentingFocusedWindow() {
        final DisplayContent defaultDisplay = mWm.getDefaultDisplayContentLocked();
        final WindowState window = createWindow(null /* parent */, TYPE_BASE_APPLICATION,
                defaultDisplay, "window");
        defaultDisplay.mLastFocus = window;
        mDisplayContent.mCurrentFocus = window;
        mDisplayContent.reParentWindowToken(window.mToken);

        assertNull(defaultDisplay.mLastFocus);
    }

    @Test
    public void testGetPreferredOptionsPanelGravityFromDifferentDisplays() {
        final DisplayContent portraitDisplay = createNewDisplay();