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

Commit 930b3854 authored by Cosmin Băieș's avatar Cosmin Băieș Committed by Android (Google) Code Review
Browse files

Merge "Remove IME layering target update deferral" into main

parents f88743fc a885f5e4
Loading
Loading
Loading
Loading
+0 −47
Original line number Diff line number Diff line
@@ -630,11 +630,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     */
    int mLayoutSeq = 0;

    /** The number of deferrals of updating the IME layering target. */
    private int mUpdateImeLayeringTargetDeferCount;
    /** Whether the IME layering target was requested to be updated while being deferred. */
    private boolean mUpdateImeLayeringTargetRequestedWhileDeferred;

    private MagnificationSpec mMagnificationSpec;

    private InputMonitor mInputMonitor;
@@ -4169,14 +4164,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }

        final WindowState curTarget = mImeLayeringTarget;
        if (!canUpdateImeLayeringTarget()) {
            if (DEBUG_INPUT_METHOD) {
                Slog.w(TAG_WM, "Defer updating IME layering target");
            }
            mUpdateImeLayeringTargetRequestedWhileDeferred = true;
            return curTarget;
        }

        // TODO(multidisplay): Needs some serious rethought when the target and IME are not on the
        // same display. Or even when the current IME/target are not on the same screen as the next
        // IME/target. For now only look for input windows on the main screen.
@@ -5640,40 +5627,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }
    }

    /**
     * Defers updating the IME layering target, tracking the number of deferrals in a counter. When
     * all of these are cleared through {@link #continueUpdateImeLayeringTarget} the update will
     * take place.
     */
    void deferUpdateImeLayeringTarget() {
        if (mUpdateImeLayeringTargetDeferCount == 0) {
            mUpdateImeLayeringTargetRequestedWhileDeferred = false;
        }
        mUpdateImeLayeringTargetDeferCount++;
    }

    /**
     * Attempts to continue updating the IME layering target by clearing one deferred update set
     * by {@link #deferUpdateImeLayeringTarget}. If no deferred updates remain, and the update
     * was requested while deferred, then this will trigger the update.
     */
    void continueUpdateImeLayeringTarget() {
        if (mUpdateImeLayeringTargetDeferCount == 0) {
            return;
        }

        mUpdateImeLayeringTargetDeferCount--;
        if (mUpdateImeLayeringTargetDeferCount == 0
                && mUpdateImeLayeringTargetRequestedWhileDeferred) {
            computeImeLayeringTarget(true /* update */);
        }
    }

    /** Checks whether the IME layering target can be updated, or is currently being deferred. */
    private boolean canUpdateImeLayeringTarget() {
        return mUpdateImeLayeringTargetDeferCount == 0;
    }

    InputMonitor getInputMonitor() {
        return mInputMonitor;
    }
+26 −38
Original line number Diff line number Diff line
@@ -5786,12 +5786,6 @@ class Task extends TaskFragment {
            tr.forAllActivities(a -> { a.appTimeTracker = timeTracker; });
        }

        try {
            // Defer updating the IME layering target since the it will try to get computed before
            // updating all closing and opening apps, which can cause it to get calculated
            // incorrectly.
            mDisplayContent.deferUpdateImeLayeringTarget();

        // Don't refocus if invisible to current user
        final ActivityRecord top = tr.getTopNonFinishingActivity();
        if (top == null || !top.showToCurrentUser()) {
@@ -5816,20 +5810,14 @@ class Task extends TaskFragment {
            updateTransitLocked(TRANSIT_TO_FRONT, options);
        }

            // If a new task is moved to the front, then mark the existing top activity as
            // supporting

            // picture-in-picture while paused only if the task would not be considered an oerlay
            // on top
            // of the current activity (eg. not fullscreen, or the assistant)
        // If a new task is moved to the front, then mark the existing top activity as supporting
        // picture-in-picture while paused only if the task would not be considered an overlay on
        // top of the current activity (eg. not fullscreen, or the assistant)
        enableEnterPipOnTaskSwitch(pipCandidate, tr, null /* toFrontActivity */, options);

        if (!deferResume) {
            mRootWindowContainer.resumeFocusedTasksTopActivities();
        }
        } finally {
            mDisplayContent.continueUpdateImeLayeringTarget();
        }
    }

    private boolean canMoveTaskToBack(Task task) {