Fix ActivityOption#setTaskOverlay can be covered by other activity.

Although ActivityRecord#setTaskOverlay has set setAlwaysOnTop, but it
is not useful in Task#getAdjustedChildPosition, because when sorting
activities in a task, it is meanless to check the windowing mode for
an activity. A simple solution is to override the isAlwaysOnTop method.

And because Task#showToCurrentUser will depends on current top task,
so we cannot add the task before adjusting the position.

Bug: 181721787
Test: atest RootTaskTests StartActivityAsUserTests StartActivityTests
Change-Id: I7fdf19d04bf71fa97a841223c06fad9a7e0b2ee4
This commit is contained in:
wilsonshih
2021-04-22 18:22:46 +08:00
parent 05555262dd
commit dec663653f
2 changed files with 10 additions and 2 deletions

View File

@@ -8242,6 +8242,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
return mTaskOverlay;
}
@Override
public boolean isAlwaysOnTop() {
return mTaskOverlay || super.isAlwaysOnTop();
}
@Override
boolean showToCurrentUser() {
return mShowForAllUsers || mWmService.isCurrentProfile(mUserId);

View File

@@ -3150,11 +3150,14 @@ class Task extends WindowContainer<WindowContainer> {
// Figure-out min/max possible position depending on if child can show for current user.
int minPosition = (canShowChild) ? computeMinUserPosition(0, size) : 0;
int maxPosition = (canShowChild) ? size : computeMaxUserPosition(size - 1);
int maxPosition = (canShowChild) ? size - 1 : computeMaxUserPosition(size - 1);
if (!hasChild(wc)) {
// Increase the maxPosition because children size will grow once wc is added.
++maxPosition;
}
// Factor in always-on-top children in max possible position.
if (!wc.isAlwaysOnTop()) {
// We want to place all non-always-on-top containers below always-on-top ones.
while (maxPosition > minPosition) {
if (!mChildren.get(maxPosition - 1).isAlwaysOnTop()) break;