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

Commit 735a5e14 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Show recents at correct time when starting activity in docked stack" into oc-dev

parents 1a199ba7 cd501ecd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ class ActivityMetricsLogger {
        mLastLogTimeSecs = now;

        ActivityStack stack = mSupervisor.getStack(DOCKED_STACK_ID);
        if (stack != null && stack.getStackVisibilityLocked(null) != STACK_INVISIBLE) {
        if (stack != null && stack.shouldBeVisible(null) != STACK_INVISIBLE) {
            mWindowState = WINDOW_STATE_SIDE_BY_SIDE;
            return;
        }
+12 −6
Original line number Diff line number Diff line
@@ -1559,12 +1559,18 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        return true;
    }

    /** Returns true if the stack is currently considered visible. */
    boolean isVisible() {
        return mWindowContainerController != null && mWindowContainerController.isVisible();
    }

    /**
     * Returns stack's visibility: {@link #STACK_INVISIBLE}, {@link #STACK_VISIBLE} or
     * {@link #STACK_VISIBLE_ACTIVITY_BEHIND}.
     * Returns what the stack visibility should be: {@link #STACK_INVISIBLE}, {@link #STACK_VISIBLE}
     * or {@link #STACK_VISIBLE_ACTIVITY_BEHIND}.
     *
     * @param starting The currently starting activity or null if there is none.
     */
    int getStackVisibilityLocked(ActivityRecord starting) {
    int shouldBeVisible(ActivityRecord starting) {
        if (!isAttached()) {
            return STACK_INVISIBLE;
        }
@@ -1714,7 +1720,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            // If the top activity is not fullscreen, then we need to
            // make sure any activities under it are now visible.
            boolean aboveTop = top != null;
            final int stackVisibility = getStackVisibilityLocked(starting);
            final int stackVisibility = shouldBeVisible(starting);
            final boolean stackInvisible = stackVisibility != STACK_VISIBLE;
            final boolean stackVisibleBehind = stackVisibility == STACK_VISIBLE_ACTIVITY_BEHIND;
            boolean behindFullscreenActivity = stackInvisible;
@@ -2096,7 +2102,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        // activities as we need to display their starting window until they are done initializing.
        boolean behindFullscreenActivity = false;

        if (getStackVisibilityLocked(null) == STACK_INVISIBLE) {
        if (shouldBeVisible(null) == STACK_INVISIBLE) {
            // The stack is not visible, so no activity in it should be displaying a starting
            // window. Mark all activities below top and behind fullscreen.
            aboveTop = false;
@@ -4181,7 +4187,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        if (hasVisibleBehindActivity() &&
                !mHandler.hasMessages(RELEASE_BACKGROUND_RESOURCES_TIMEOUT_MSG)) {
            if (r == topRunningActivityLocked()
                    && getStackVisibilityLocked(null) == STACK_VISIBLE) {
                    && shouldBeVisible(null) == STACK_VISIBLE) {
                // Don't release the top activity if it has requested to run behind the next
                // activity and the stack is currently visible.
                return;
+6 −6
Original line number Diff line number Diff line
@@ -2204,7 +2204,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            for (int j = stacks.size() - 1; j >= 0; --j) {
                final ActivityStack stack = stacks.get(j);
                if (stack != currentFocus && stack.isFocusable()
                        && stack.getStackVisibilityLocked(null) != STACK_INVISIBLE) {
                        && stack.shouldBeVisible(null) != STACK_INVISIBLE) {
                    return stack;
                }
            }
@@ -2365,7 +2365,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            }
            ActivityStack fullscreenStack = getStack(FULLSCREEN_WORKSPACE_STACK_ID);
            final boolean isFullscreenStackVisible = fullscreenStack != null &&
                    fullscreenStack.getStackVisibilityLocked(null) == STACK_VISIBLE;
                    fullscreenStack.shouldBeVisible(null) == STACK_VISIBLE;
            // If we are moving from the pinned stack, then the animation takes care of updating
            // the picture-in-picture mode.
            final boolean schedulePictureInPictureModeChange = (fromStackId != PINNED_STACK_ID);
@@ -2540,7 +2540,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            final ActivityStack fullscreenStack = getStack(FULLSCREEN_WORKSPACE_STACK_ID);
            if (fullscreenStack != null) {
                final boolean isFullscreenStackVisible =
                        fullscreenStack.getStackVisibilityLocked(null) == STACK_VISIBLE;
                        fullscreenStack.shouldBeVisible(null) == STACK_VISIBLE;
                for (int i = 0; i < tasks.size(); i++) {
                    // Insert the task either at the top of the fullscreen stack if it is hidden,
                    // or to the bottom if it is currently visible
@@ -3579,7 +3579,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
                for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) {
                    ActivityStack stack = stacks.get(stackNdx);
                    if (!dumpVisibleStacksOnly ||
                            stack.getStackVisibilityLocked(null) == STACK_VISIBLE) {
                            stack.shouldBeVisible(null) == STACK_VISIBLE) {
                        activities.addAll(stack.getDumpActivitiesLocked(name));
                    }
                }
@@ -3886,7 +3886,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        info.displayId = DEFAULT_DISPLAY;
        info.stackId = stack.mStackId;
        info.userId = stack.mCurrentUser;
        info.visible = stack.getStackVisibilityLocked(null) == STACK_VISIBLE;
        info.visible = stack.shouldBeVisible(null) == STACK_VISIBLE;
        info.position = display != null
                ? display.mStacks.indexOf(stack)
                : 0;
@@ -5005,7 +5005,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            for (int j = display.mStacks.size() - 1; j >= 0; j--) {
                final ActivityStack stack = display.mStacks.get(j);
                // Get top activity from a visible stack and add it to the list.
                if (stack.getStackVisibilityLocked(null /* starting */)
                if (stack.shouldBeVisible(null /* starting */)
                        == ActivityStack.STACK_VISIBLE) {
                    final ActivityRecord top = stack.topActivity();
                    if (top != null) {
+5 −20
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@ import static com.android.server.am.ActivityManagerService.ANIMATE;
import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.ASSISTANT_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.RECENTS_ACTIVITY_TYPE;
import static com.android.server.am.ActivityStack.ActivityState.RESUMED;
import static com.android.server.am.ActivityStack.STACK_INVISIBLE;
import static com.android.server.am.ActivityStackSupervisor.CREATE_IF_NEEDED;
@@ -558,31 +557,17 @@ class ActivityStarter {
            startedActivityStackId = targetStack.mStackId;
        }

        // If we launched the activity from a no display activity that was launched from the home
        // screen, we also need to start recents to un-minimize the docked stack, since the
        // noDisplay activity will be finished shortly after.
        // Note that some apps have trampoline activities without noDisplay being set. In that case,
        // we have another heuristic in DockedStackDividerController.notifyAppTransitionStarting
        // that tries to detect that case.
        // TODO: We should prevent noDisplay activities from affecting task/stack ordering and
        // visibility instead of using this flag.
        final boolean noDisplayActivityOverHome = sourceRecord != null
                && sourceRecord.noDisplay
                && sourceRecord.getTask().getTaskToReturnTo() == HOME_ACTIVITY_TYPE;
        if (startedActivityStackId == DOCKED_STACK_ID
                && (prevFocusedStackId == HOME_STACK_ID || noDisplayActivityOverHome)) {
        if (startedActivityStackId == DOCKED_STACK_ID) {
            final ActivityStack homeStack = mSupervisor.getStack(HOME_STACK_ID);
            final ActivityRecord topActivityHomeStack = homeStack != null
                    ? homeStack.topRunningActivityLocked() : null;
            if (topActivityHomeStack == null
                    || topActivityHomeStack.mActivityType != RECENTS_ACTIVITY_TYPE) {
            final boolean homeStackVisible = homeStack != null && homeStack.isVisible();
            if (homeStackVisible) {
                // We launch an activity while being in home stack, which means either launcher or
                // recents into docked stack. We don't want the launched activity to be alone in a
                // docked stack, so we want to immediately launch recents too.
                if (DEBUG_RECENTS) Slog.d(TAG, "Scheduling recents launch.");
                mWindowManager.showRecentApps(true /* fromHome */);
                return;
            }
            return;
        }

        if (startedActivityStackId == PINNED_STACK_ID
@@ -2153,7 +2138,7 @@ class ActivityStarter {
                // activity into parent's stack, because we can't find a better place.
                final ActivityStack dockedStack = mSupervisor.getStack(DOCKED_STACK_ID);
                if (dockedStack != null
                        && dockedStack.getStackVisibilityLocked(r) == STACK_INVISIBLE) {
                        && dockedStack.shouldBeVisible(r) == STACK_INVISIBLE) {
                    // There is a docked stack, but it isn't visible, so we can't launch into that.
                    return null;
                } else {
+7 −1
Original line number Diff line number Diff line
@@ -94,6 +94,12 @@ public class StackWindowController
        }
    }

    public boolean isVisible() {
        synchronized (mWindowMap) {
            return mContainer != null && mContainer.isVisible();
        }
    }

    public void reparent(int displayId, Rect outStackBounds) {
        synchronized (mWindowMap) {
            if (mContainer == null) {
@@ -363,7 +369,7 @@ public class StackWindowController
    }

    /** Calls directly into activity manager so window manager lock shouldn't held. */
    public void updatePictureInPictureModeForPinnedStackAnimation(Rect targetStackBounds) {
    void updatePictureInPictureModeForPinnedStackAnimation(Rect targetStackBounds) {
        if (mListener != null) {
            mListener.updatePictureInPictureModeForPinnedStackAnimation(targetStackBounds);
        }