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

Commit aa2b620c authored by Matthew Ng's avatar Matthew Ng
Browse files

Fixes minimized state to match task and stack bounds for cts test

Fixes minimized state for its task and stack bounds to always match
inline with the cts test that was failing.

This also fixes multiple state issues related to splitting home and
recents into different stacks when recents incorrectly reads home stack
bounds to determine bounds for recents.

Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test
CtsServicesHostTestCases
android.server.cts.ActivityManagerActivityVisibilityTests or
ActivityManagerDockedStackTests
Fixes: 35351074, 35145587
Change-Id: I6417a567e937c647818ff26dc08df463e6ef4257
parent 7446235e
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.HOME_STACK_ID;
import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.app.ActivityManager.StackId.RECENTS_STACK_ID;
import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT;

import android.annotation.NonNull;
@@ -1057,15 +1058,18 @@ public class SystemServicesProxy {
    }

    /**
     * Returns the window rect for the RecentsActivity, based on the dimensions of the home stack.
     * Returns the window rect for the RecentsActivity, based on the dimensions of the recents stack
     */
    public Rect getWindowRect() {
        Rect windowRect = new Rect();
        if (mIam == null) return windowRect;

        try {
            // Use the home stack bounds
            ActivityManager.StackInfo stackInfo = mIam.getStackInfo(HOME_STACK_ID);
            // Use the recents stack bounds, fallback to fullscreen stack if it is null
            ActivityManager.StackInfo stackInfo = mIam.getStackInfo(RECENTS_STACK_ID);
            if (stackInfo == null) {
                stackInfo = mIam.getStackInfo(FULLSCREEN_WORKSPACE_STACK_ID);
            }
            if (stackInfo != null) {
                windowRect.set(stackInfo.bounds);
            }
+7 −4
Original line number Diff line number Diff line
@@ -746,15 +746,18 @@ public class DividerView extends FrameLayout implements OnTouchListener,
            if (mStableInsets.isEmpty()) {
                SystemServicesProxy.getInstance(mContext).getStableInsets(mStableInsets);
            }
            mMinimizedSnapAlgorithm = null;
            mDockedStackMinimized = minimized;
            initializeSnapAlgorithm();
            if (!mIsInMinimizeInteraction && minimized) {
                mIsInMinimizeInteraction = true;
                mDividerPositionBeforeMinimized = DockedDividerUtils.calculateMiddlePosition(
                        isHorizontalDivision(), mStableInsets, mDisplayWidth, mDisplayHeight,
                        mDividerSize);

                int position = mMinimizedSnapAlgorithm.getMiddleTarget().position;
                resizeStack(position, position, mMinimizedSnapAlgorithm.getMiddleTarget());
            }
            mMinimizedSnapAlgorithm = null;
            mDockedStackMinimized = minimized;
            initializeSnapAlgorithm();
        }
    }

@@ -1140,7 +1143,7 @@ public class DividerView extends FrameLayout implements OnTouchListener,
                        && dockSideBottomRight(mDockSide))) {
            return StackId.DOCKED_STACK_ID;
        } else {
            return StackId.HOME_STACK_ID;
            return StackId.RECENTS_STACK_ID;
        }
    }

+3 −6
Original line number Diff line number Diff line
@@ -19890,14 +19890,11 @@ public class ActivityManagerService extends IActivityManager.Stub
    /** Helper method that requests bounds from WM and applies them to stack. */
    private void resizeStackWithBoundsFromWindowManager(int stackId, boolean deferResume) {
        final Rect newStackBounds = new Rect();
        final Rect newTempTaskBounds = new Rect();
        mStackSupervisor.getStack(stackId).getBoundsForNewConfiguration(newStackBounds,
                newTempTaskBounds);
        mStackSupervisor.getStack(stackId).getBoundsForNewConfiguration(newStackBounds);
        mStackSupervisor.resizeStackLocked(
                stackId, !newStackBounds.isEmpty() ? newStackBounds : null /* bounds */,
                !newTempTaskBounds.isEmpty() ? newTempTaskBounds : null /* tempTaskBounds */,
                null /* tempTaskInsetBounds */, false /* preserveWindows */,
                false /* allowResizeInDockedMode */, deferResume);
                null /* tempTaskBounds */, null /* tempTaskInsetBounds */,
                false /* preserveWindows */, false /* allowResizeInDockedMode */, deferResume);
    }
    /**
+10 −6
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ import com.android.server.am.ActivityManagerService.ItemMatcher;
import com.android.server.am.ActivityStackSupervisor.ActivityContainer;
import com.android.server.wm.StackWindowController;
import com.android.server.wm.StackWindowListener;
import com.android.server.wm.TaskStack;
import com.android.server.wm.WindowManagerService;

import java.io.FileDescriptor;
@@ -544,10 +545,13 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        mActivityContainer.mActivityDisplay.mDisplay.getSize(out);
    }

    void getStackDockedModeBounds(Rect outBounds, Rect outTempBounds, Rect outTempInsetBounds,
            boolean ignoreVisibility) {
        mWindowContainerController.getStackDockedModeBounds(outBounds, outTempBounds,
                outTempInsetBounds, ignoreVisibility);
    /**
     * @see ActivityStack.getStackDockedModeBounds(Rect, Rect, Rect, boolean)
     */
    void getStackDockedModeBounds(Rect currentTempTaskBounds, Rect outStackBounds,
            Rect outTempTaskBounds, boolean ignoreVisibility) {
        mWindowContainerController.getStackDockedModeBounds(currentTempTaskBounds,
                outStackBounds, outTempTaskBounds, ignoreVisibility);
    }

    void prepareFreezingTaskBounds() {
@@ -562,8 +566,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        outBounds.setEmpty();
    }

    void getBoundsForNewConfiguration(Rect outBounds, Rect outTempBounds) {
        mWindowContainerController.getBoundsForNewConfiguration(outBounds, outTempBounds);
    void getBoundsForNewConfiguration(Rect outBounds) {
        mWindowContainerController.getBoundsForNewConfiguration(outBounds);
    }

    void positionChildWindowContainerAtTop(TaskRecord child) {
+9 −9
Original line number Diff line number Diff line
@@ -2375,19 +2375,19 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
                // static stacks need to be adjusted so they don't overlap with the docked stack.
                // We get the bounds to use from window manager which has been adjusted for any
                // screen controls and is also the same for all stacks.
                final Rect tempOtherTaskRect = new Rect();
                final Rect tempOtherTaskInsetRect = new Rect();
                final Rect otherTaskRect = new Rect();
                for (int i = FIRST_STATIC_STACK_ID; i <= LAST_STATIC_STACK_ID; i++) {
                    final ActivityStack current = getStack(i);
                    if (current != null && StackId.isResizeableByDockedStack(i)) {
                        current.getStackDockedModeBounds(tempRect, tempOtherTaskRect,
                                tempOtherTaskInsetRect, true /* ignoreVisibility */);
                        current.getStackDockedModeBounds(
                                tempOtherTaskBounds /* currentTempTaskBounds */,
                                tempRect /* outStackBounds */,
                                otherTaskRect /* outTempTaskBounds */, true /* ignoreVisibility */);

                        resizeStackLocked(i, tempRect,
                                !tempOtherTaskRect.isEmpty() ? tempOtherTaskRect :
                                        tempOtherTaskBounds,
                                !tempOtherTaskInsetRect.isEmpty() ? tempOtherTaskInsetRect :
                                        tempOtherTaskInsetBounds,
                                preserveWindows, true /* allowResizeInDockedMode */, deferResume);
                                !otherTaskRect.isEmpty() ? otherTaskRect : tempOtherTaskBounds,
                                tempOtherTaskInsetBounds, preserveWindows,
                                true /* allowResizeInDockedMode */, deferResume);
                    }
                }
            }
Loading