Fixes few corner issues of multi-window windowing mode split-screen

- Updates the preferred top focused root task when a root task was
  added on top.

- Also updates the resumed activity (so as the focused app) while
  root task position changed.

- Do not resume the top activities of the tasks that are visible, but is
  behind other visible tasks (TASK_VISIBILITY_VISIBLE_BEHIND_TRANSLUCENT).

Bug: 177190100
Test: ActivityLifecycleLegacySplitScreenTests
Test: MultiWindowTests#testLaunchToSideAndBringToFront
Change-Id: Ied5041f3987a964931cdab508955759671336af4
This commit is contained in:
Louis Chang
2021-03-22 11:39:57 +08:00
parent 2b434b28b0
commit 1192afbc0d
3 changed files with 18 additions and 5 deletions

View File

@@ -6060,12 +6060,10 @@ class Task extends WindowContainer<WindowContainer> {
int idx = mChildren.size() - 1;
while (idx >= 0) {
final Task child = (Task) getChildAt(idx--);
if (!child.isFocusableAndVisible()) {
break;
if (!child.isTopActivityFocusable()) {
continue;
}
// Only allow one activity to be resumed among sibling tasks in split-screen.
if (inSplitScreenWindowingMode() && someActivityResumed) {
if (child.getVisibility(null /* starting */) != TASK_VISIBILITY_VISIBLE) {
break;
}

View File

@@ -346,6 +346,12 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
position = findPositionForRootTask(position, task, true /* adding */);
super.addChild(task, position);
if (mPreferredTopFocusableRootTask != null
&& task.isFocusable()
&& mPreferredTopFocusableRootTask.compareTo(task) < 0) {
// Clear preferred top because the adding focusable task has a higher z-order.
mPreferredTopFocusableRootTask = null;
}
mAtmService.updateSleepIfNeededLocked();
onRootTaskOrderChanged(task);
}
@@ -439,6 +445,11 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
// Update the top resumed activity because the preferred top focusable task may be changed.
mAtmService.mTaskSupervisor.updateTopResumedActivityIfNeeded();
final ActivityRecord r = child.getResumedActivity();
if (r != null && r == mRootWindowContainer.getTopResumedActivity()) {
mAtmService.setResumedActivityUncheckLocked(r, "positionChildAt");
}
if (mChildren.indexOf(child) != oldPosition) {
onRootTaskOrderChanged(child);
}

View File

@@ -2157,6 +2157,8 @@ public class ActivityRecordTests extends WindowTestsBase {
attrs.setTitle("AppWindow");
final TestWindowState appWindow = createWindowState(attrs, activity);
activity.addWindow(appWindow);
spyOn(appWindow);
doNothing().when(appWindow).onStartFreezingScreen();
// Set initial orientation and update.
activity.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
@@ -2193,6 +2195,8 @@ public class ActivityRecordTests extends WindowTestsBase {
attrs.setTitle("RotationByPolicy");
final TestWindowState appWindow = createWindowState(attrs, activity);
activity.addWindow(appWindow);
spyOn(appWindow);
doNothing().when(appWindow).onStartFreezingScreen();
// Set initial orientation and update.
performRotation(displayRotation, Surface.ROTATION_90);