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

Commit 0c89f330 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Fixed issue with focusing on minimized split-screen stack" into pi-dev

parents 04782e27 e1f68ce4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3422,8 +3422,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
     * @param allowFocusSelf Is the focus allowed to remain on the same stack.
     */
    private boolean adjustFocusToNextFocusableStack(String reason, boolean allowFocusSelf) {
        final ActivityStack stack = mStackSupervisor.getNextFocusableStackLocked(
                allowFocusSelf ? null : this);
        final ActivityStack stack =
                mStackSupervisor.getNextFocusableStackLocked(this, !allowFocusSelf);
        final String myReason = reason + " adjustFocusToNextFocusableStack";
        if (stack == null) {
            return false;
+31 −8
Original line number Diff line number Diff line
@@ -679,7 +679,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
    void setFocusStackUnchecked(String reason, ActivityStack focusCandidate) {
        if (!focusCandidate.isFocusable()) {
            // The focus candidate isn't focusable. Move focus to the top stack that is focusable.
            focusCandidate = getNextFocusableStackLocked(focusCandidate);
            focusCandidate = getNextFocusableStackLocked(focusCandidate, false /* ignoreCurrent */);
        }

        if (focusCandidate != mFocusedStack) {
@@ -2429,27 +2429,50 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
     * Get next focusable stack in the system. This will search across displays and stacks
     * in last-focused order for a focusable and visible stack, different from the target stack.
     *
     * @param currentFocus The stack that previously had focus and thus needs to be ignored when
     *                     searching for next candidate.
     * @param currentFocus The stack that previously had focus.
     * @param ignoreCurrent If we should ignore {@param currentFocus} when searching for next
     *                     candidate.
     * @return Next focusable {@link ActivityStack}, null if not found.
     */
    ActivityStack getNextFocusableStackLocked(ActivityStack currentFocus) {
    ActivityStack getNextFocusableStackLocked(ActivityStack currentFocus, boolean ignoreCurrent) {
        mWindowManager.getDisplaysInFocusOrder(mTmpOrderedDisplayIds);

        final int currentWindowingMode = currentFocus != null
                ? currentFocus.getWindowingMode() : WINDOWING_MODE_UNDEFINED;
        ActivityStack candidate = null;
        for (int i = mTmpOrderedDisplayIds.size() - 1; i >= 0; --i) {
            final int displayId = mTmpOrderedDisplayIds.get(i);
            // If a display is registered in WM, it must also be available in AM.
            final ActivityDisplay display = getActivityDisplayOrCreateLocked(displayId);
            for (int j = display.getChildCount() - 1; j >= 0; --j) {
                final ActivityStack stack = display.getChildAt(j);
                if (stack != currentFocus && stack.isFocusable()
                        && stack.shouldBeVisible(null)) {
                    return stack;
                if (ignoreCurrent && stack == currentFocus) {
                    continue;
                }
                if (!stack.isFocusable() || !stack.shouldBeVisible(null)) {
                    continue;
                }

                if (currentWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY
                        && candidate == null && stack.inSplitScreenPrimaryWindowingMode()) {
                    // If the currently focused stack is in split-screen secondary we would prefer
                    // the focus to move to another split-screen secondary stack or fullscreen stack
                    // over the primary split screen stack to avoid:
                    // - Moving the focus to the primary split-screen stack when it can't be focused
                    //   because it will be minimized, but AM doesn't know that yet
                    // - primary split-screen stack overlapping with a fullscreen stack when a
                    //   fullscreen stack is higher in z than the next split-screen stack. Assistant
                    //   stack, I am looking at you...
                    // We only move the focus to the primary-split screen stack if there isn't a
                    // better alternative.
                    candidate = stack;
                    continue;
                }
                return stack;
            }
        }

        return null;
        return candidate;
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -373,7 +373,8 @@ public class ActivityTestsBase {

        // Just return the current front task. This is called internally so we cannot use spy to mock this out.
        @Override
        ActivityStack getNextFocusableStackLocked(ActivityStack currentFocus) {
        ActivityStack getNextFocusableStackLocked(ActivityStack currentFocus,
                boolean ignoreCurrent) {
            return mFocusedStack;
        }
    }