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

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

Merge "Move home stack behind top fullscreen stack when split-screen is dismissed"

parents 895d7310 1dbc5c87
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -409,15 +409,16 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
                otherStack.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
            }
        } finally {
            if (mHomeStack != null && !isTopStack(mHomeStack)) {
            final ActivityStack topFullscreenStack =
                    getStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
            if (topFullscreenStack != null && mHomeStack != null && !isTopStack(mHomeStack)) {
                // Whenever split-screen is dismissed we want the home stack directly behind the
                // currently top stack so it shows up when the top stack is finished.
                final ActivityStack topStack = getTopStack();
                // current top fullscreen stack so it shows up when the top stack is finished.
                // TODO: Would be better to use ActivityDisplay.positionChildAt() for this, however
                // ActivityDisplay doesn't have a direct controller to WM side yet. We can switch
                // once we have that.
                mHomeStack.moveToFront("onSplitScreenModeDismissed");
                topStack.moveToFront("onSplitScreenModeDismissed");
                topFullscreenStack.moveToFront("onSplitScreenModeDismissed");
            }
            mSupervisor.mWindowManager.continueSurfaceLayout();
        }
@@ -435,7 +436,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
                }
                otherStack.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_SECONDARY,
                        false /* animate */, false /* showRecents */,
                        false /* sendNonResizeableNotification */);
                        true /* enteringSplitScreenMode */);
            }
        } finally {
            mSupervisor.mWindowManager.continueSurfaceLayout();
+1 −1
Original line number Diff line number Diff line
@@ -10591,7 +10591,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    stack.moveToFront("setTaskWindowingModeSplitScreenPrimary", task);
                }
                stack.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, animate, showRecents,
                        true /* sendNonResizeableNotification */);
                        false /* enteringSplitScreenMode */);
                return windowingMode != task.getWindowingMode();
            } finally {
                Binder.restoreCallingIdentity(ident);
+32 −17
Original line number Diff line number Diff line
@@ -484,19 +484,23 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
    @Override
    public void setWindowingMode(int windowingMode) {
        setWindowingMode(windowingMode, false /* animate */, true /* showRecents */,
                true /* sendNonResizeableNotification */);
                false /* enteringSplitScreenMode */);
    }

    void setWindowingMode(int preferredWindowingMode, boolean animate, boolean showRecents,
            boolean sendNonResizeableNotification) {
            boolean enteringSplitScreenMode) {
        final boolean creating = mWindowContainerController == null;
        final int currentMode = getWindowingMode();
        final ActivityDisplay display = getDisplay();
        final TaskRecord topTask = topTask();
        final ActivityStack splitScreenStack = display.getSplitScreenPrimaryStack();
        mTmpOptions.setLaunchWindowingMode(preferredWindowingMode);

        // Need to make sure windowing mode is supported.
        int windowingMode = display.resolveWindowingMode(
        // Need to make sure windowing mode is supported. If we in the process of creating the stack
        // no need to resolve the windowing mode again as it is already resolved to the right mode.
        int windowingMode = creating
                ? preferredWindowingMode
                : display.resolveWindowingMode(
                        null /* ActivityRecord */, mTmpOptions, topTask, getActivityType());
        if (splitScreenStack == this && windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) {
            // Resolution to split-screen secondary for the primary split-screen stack means we want
@@ -506,14 +510,19 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai

        final boolean alreadyInSplitScreenMode = display.hasSplitScreenPrimaryStack();

        // Don't send non-resizeable notifications if the windowing mode changed was a side effect
        // of us entering split-screen mode.
        final boolean sendNonResizeableNotification = !enteringSplitScreenMode;
        // Take any required action due to us not supporting the preferred windowing mode.
        if (sendNonResizeableNotification
                && windowingMode != preferredWindowingMode && isActivityTypeStandardOrUndefined()) {
            if (alreadyInSplitScreenMode
                    && (preferredWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY
                    || preferredWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY)) {
                // Looks like we can't launch in split screen mode, go ahead an dismiss split-screen
                // and display a warning toast about it.
        if (alreadyInSplitScreenMode && windowingMode == WINDOWING_MODE_FULLSCREEN
                && sendNonResizeableNotification && isActivityTypeStandardOrUndefined()) {
            final boolean preferredSplitScreen =
                    preferredWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY
                    || preferredWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
            if (preferredSplitScreen || creating) {
                // Looks like we can't launch in split screen mode or the stack we are launching
                // doesn't support split-screen mode, go ahead an dismiss split-screen and display a
                // warning toast about it.
                mService.mTaskChangeNotificationController.notifyActivityDismissingDockedStack();
                display.getSplitScreenPrimaryStack().setWindowingMode(WINDOWING_MODE_FULLSCREEN);
            }
@@ -544,7 +553,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            }
            super.setWindowingMode(windowingMode);

            if (mWindowContainerController == null) {
            if (creating) {
                // Nothing else to do if we don't have a window container yet. E.g. call from ctor.
                return;
            }
@@ -594,17 +603,23 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                // the one where the home stack is visible since recents isn't visible yet, but the
                // divider will be off. I think we should just make the initial bounds that of home
                // so that the divider matches and remove this logic.
                display.getOrCreateStack(WINDOWING_MODE_SPLIT_SCREEN_SECONDARY,
                        ACTIVITY_TYPE_RECENTS, true /* onTop */);
                final ActivityStack recentStack = display.getOrCreateStack(
                        WINDOWING_MODE_SPLIT_SCREEN_SECONDARY, ACTIVITY_TYPE_RECENTS,
                        true /* onTop */);
                recentStack.moveToFront("setWindowingMode");
                // If task moved to docked stack - show recents if needed.
                mService.mWindowManager.showRecentApps(false /* fromHome */);
            }
            wm.continueSurfaceLayout();
        }

        // Don't ensure visible activities if the windowing mode change was a side effect of us
        // entering split-screen mode.
        if (!enteringSplitScreenMode) {
            mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, PRESERVE_WINDOWS);
            mStackSupervisor.resumeFocusedStackTopActivityLocked();
        }
    }

    @Override
    public boolean isCompatible(int windowingMode, int activityType) {