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

Commit d8830702 authored by Andrii Kulian's avatar Andrii Kulian Committed by Android (Google) Code Review
Browse files

Merge "Look on all displays if can't launch on a source secondary one" into oc-dev

parents accdadae a8fe3dfd
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -2257,6 +2257,31 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        return null;
    }

    /**
     * Get next valid stack for launching provided activity in the system. This will search across
     * displays and stacks in last-focused order for a focusable and visible stack, except those
     * that are on a currently focused display.
     *
     * @param r The activity that is being launched.
     * @param currentFocus The display that previously had focus and thus needs to be ignored when
     *                     searching for the next candidate.
     * @return Next valid {@link ActivityStack}, null if not found.
     */
    ActivityStack getNextValidLaunchStackLocked(@NonNull ActivityRecord r, int currentFocus) {
        mWindowManager.getDisplaysInFocusOrder(mTmpOrderedDisplayIds);
        for (int i = mTmpOrderedDisplayIds.size() - 1; i >= 0; --i) {
            final int displayId = mTmpOrderedDisplayIds.get(i);
            if (displayId == currentFocus) {
                continue;
            }
            final ActivityStack stack = getValidLaunchStackOnDisplay(displayId, r);
            if (stack != null) {
                return stack;
            }
        }
        return null;
    }

    ActivityRecord getHomeActivity() {
        return getHomeActivityForUser(mCurrentUser);
    }
+12 −3
Original line number Diff line number Diff line
@@ -2027,7 +2027,18 @@ class ActivityStarter {
            return mSupervisor.mFocusedStack;
        }

        if (mSourceDisplayId == DEFAULT_DISPLAY) {
        if (mSourceDisplayId != DEFAULT_DISPLAY) {
            // Try to put the activity in a stack on a secondary display.
            stack = mSupervisor.getValidLaunchStackOnDisplay(mSourceDisplayId, r);
            if (stack == null) {
                // If source display is not suitable - look for topmost valid stack in the system.
                if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG_FOCUS,
                        "computeStackFocus: Can't launch on mSourceDisplayId=" + mSourceDisplayId
                                + ", looking on all displays.");
                stack = mSupervisor.getNextValidLaunchStackLocked(r, mSourceDisplayId);
            }
        }
        if (stack == null) {
            // We first try to put the task in the first dynamic stack on home display.
            final ArrayList<ActivityStack> homeDisplayStacks = mSupervisor.mHomeStack.mStacks;
            for (int stackNdx = homeDisplayStacks.size() - 1; stackNdx >= 0; --stackNdx) {
@@ -2043,8 +2054,6 @@ class ActivityStarter {
                    bounds != null ? FREEFORM_WORKSPACE_STACK_ID :
                            FULLSCREEN_WORKSPACE_STACK_ID;
            stack = mSupervisor.getStack(stackId, CREATE_IF_NEEDED, ON_TOP);
        } else {
            stack = mSupervisor.getValidLaunchStackOnDisplay(mSourceDisplayId, r);
        }
        if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG_FOCUS, "computeStackFocus: New stack r="
                + r + " stackId=" + stack.mStackId);