summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/am/ActivityDisplay.java12
-rw-r--r--services/core/java/com/android/server/wm/WindowContainer.java4
-rw-r--r--services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java8
3 files changed, 23 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/am/ActivityDisplay.java b/services/core/java/com/android/server/am/ActivityDisplay.java
index 56ed6c8a3f56..bac81e7cd4a2 100644
--- a/services/core/java/com/android/server/am/ActivityDisplay.java
+++ b/services/core/java/com/android/server/am/ActivityDisplay.java
@@ -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() {
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 1f7caffd1916..42f606531cc2 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -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);
}
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java
index ce3528b57d27..c62820e8e3c3 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java
@@ -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(