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

Commit 242a4f6e authored by Bryce Lee's avatar Bryce Lee Committed by android-build-merger
Browse files

Merge "Don't allow stacks above pinned stack." into oc-dev am: 22d4ef00

am: e7ac364a

Change-Id: I2c8daf0f23090fedf2ed0b24f743a50efd4d3a54
parents 71483a89 e7ac364a
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ import android.view.Surface;
import android.view.SurfaceControl;
import android.view.WindowManagerPolicy;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ToBooleanFunction;
import com.android.internal.view.IInputMethodClient;

@@ -1396,6 +1397,22 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        return null;
    }

    @VisibleForTesting
    int getStackCount() {
        return mTaskStackContainers.size();
    }

    @VisibleForTesting
    int getStaskPosById(int stackId) {
        for (int i = mTaskStackContainers.size() - 1; i >= 0; --i) {
            final TaskStack stack = mTaskStackContainers.get(i);
            if (stack.mStackId == stackId) {
                return i;
            }
        }
        return -1;
    }

    @Override
    void onConfigurationChanged(Configuration newParentConfig) {
        super.onConfigurationChanged(newParentConfig);
@@ -3274,8 +3291,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                    : requestedPosition >= topChildPosition;
            int targetPosition = requestedPosition;

            if (toTop && isStackVisible(PINNED_STACK_ID) && stack.mStackId != PINNED_STACK_ID) {
                // The pinned stack is always the top most stack (always-on-top) when it is visible.
            if (toTop && stack.mStackId != PINNED_STACK_ID
                    && getStackById(PINNED_STACK_ID) != null) {
                // The pinned stack is always the top most stack (always-on-top) when it is present.
                TaskStack topStack = mChildren.get(topChildPosition);
                if (topStack.mStackId != PINNED_STACK_ID) {
                    throw new IllegalStateException("Pinned stack isn't top stack??? " + mChildren);
+19 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
@@ -289,6 +290,24 @@ public class DisplayContentTests extends WindowTestsBase {
        verifySizes(sDisplayContent, smallerWidth, smallerHeight, smallerDensity);
    }

    /**
     * This test enforces that the pinned stack is always kept as the top stack.
     */
    @Test
    public void testPinnedStackLocation() {
        createStackControllerOnStackOnDisplay(PINNED_STACK_ID, sDisplayContent);
        final int initialStackCount = sDisplayContent.getStackCount();
        // Ensure that the pinned stack was placed at the end
        assertEquals(initialStackCount - 1, sDisplayContent.getStaskPosById(PINNED_STACK_ID));
        // By default, this should try to create a new stack on top
        createTaskStackOnDisplay(sDisplayContent);
        final int afterStackCount = sDisplayContent.getStackCount();
        // Make sure the stack count has increased
        assertEquals(initialStackCount + 1, afterStackCount);
        // Ensure that the pinned stack is still on top
        assertEquals(afterStackCount - 1, sDisplayContent.getStaskPosById(PINNED_STACK_ID));
    }

    private static void verifySizes(DisplayContent displayContent, int expectedBaseWidth,
                             int expectedBaseHeight, int expectedBaseDensity) {
        assertEquals(displayContent.mBaseDisplayWidth, expectedBaseWidth);