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

Commit 123e07a4 authored by Winson Chung's avatar Winson Chung
Browse files

Fix issue with stack order positioning when ending recents animation.

- When moving the home stack from a higher index to behind a stack with a
  lower index, the position does not need to be adjusted in order to move
  the stack (since positionChildAt first removes the stack before adding
  it). Updated the existing tests with a case to move the stack to a
  non-bottom index to verify this.

Bug: 73901604
Test: atest ActivityStackTests

Change-Id: If1d3af0f35d60569d8a3d86898483bacaaa98bb9
parent fc7c7498
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -158,6 +158,8 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
    }

    private void positionChildAt(ActivityStack stack, int position) {
        // TODO: Keep in sync with WindowContainer.positionChildAt(), once we change that to adjust
        //       the position internally, also update the logic here
        mStacks.remove(stack);
        final int insertPosition = getTopInsertPosition(stack, position);
        mStacks.add(insertPosition, stack);
@@ -750,7 +752,15 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
            return;
        }

        positionChildAt(mHomeStack, Math.max(0, mStacks.indexOf(behindStack) - 1));
        // Note that positionChildAt will first remove the given stack before inserting into the
        // list, so we need to adjust the insertion index to account for the removed index
        // TODO: Remove this logic when WindowContainer.positionChildAt() is updated to adjust the
        //       position internally
        final int homeStackIndex = mStacks.indexOf(mHomeStack);
        final int behindStackIndex = mStacks.indexOf(behindStack);
        final int insertIndex = homeStackIndex <= behindStackIndex
                ? behindStackIndex - 1 : behindStackIndex;
        positionChildAt(mHomeStack, Math.max(0, insertIndex));
    }

    boolean isSleeping() {
+4 −0
Original line number Diff line number Diff line
@@ -406,6 +406,10 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
                }
                break;
            default:
                // TODO: Removing the child before reinserting requires the caller to provide a
                //       position that takes into account the removed child (if the index of the
                //       child < position, then the position should be adjusted). We should consider
                //       doing this adjustment here and remove any adjustments in the callers.
                mChildren.remove(child);
                mChildren.add(position, child);
        }
+8 −0
Original line number Diff line number Diff line
@@ -408,6 +408,10 @@ public class ActivityStackTests extends ActivityTestsBase {
                WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
        final TestActivityStack fullscreenStack2 = createStackForShouldBeVisibleTest(display,
                WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
        final TestActivityStack fullscreenStack3 = createStackForShouldBeVisibleTest(display,
                WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
        final TestActivityStack fullscreenStack4 = createStackForShouldBeVisibleTest(display,
                WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
        final TestActivityStack homeStack = createStackForShouldBeVisibleTest(display,
                WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, true /* onTop */);

@@ -415,6 +419,10 @@ public class ActivityStackTests extends ActivityTestsBase {
        assertTrue(display.getStackAboveHome() == fullscreenStack1);
        display.moveHomeStackBehindStack(fullscreenStack2);
        assertTrue(display.getStackAboveHome() == fullscreenStack2);
        display.moveHomeStackBehindStack(fullscreenStack4);
        assertTrue(display.getStackAboveHome() == fullscreenStack4);
        display.moveHomeStackBehindStack(fullscreenStack2);
        assertTrue(display.getStackAboveHome() == fullscreenStack2);
    }

    private <T extends ActivityStack> T createStackForShouldBeVisibleTest(