Prevent force showing system bars for TaskView

Update the condition of force showing system bars to check adjacent
tasks instead of checking multi-window windowing mode so it can
distinguish from TaskView.

Fix: 273495037
Test: atest TaskDisplayAreaTests DisplayPolicyTests InsetsPolicyTest
Change-Id: Ibc056d4ac1fae7aa82001d815090a5be2cb703e9
This commit is contained in:
Jerry Chang
2023-04-12 17:44:48 +00:00
parent 50135efb7e
commit 6cc26f4ffe
6 changed files with 43 additions and 33 deletions

View File

@@ -2926,8 +2926,7 @@ class ActivityStarter {
// If the matching task is already in the adjacent task of the launch target. Adjust to use
// the adjacent task as its launch target. So the existing task will be launched into the
// closer one and won't be reparent redundantly.
final Task adjacentTargetTask = mTargetRootTask.getAdjacentTaskFragment() != null
? mTargetRootTask.getAdjacentTaskFragment().asTask() : null;
final Task adjacentTargetTask = mTargetRootTask.getAdjacentTask();
if (adjacentTargetTask != null && intentActivity.isDescendantOf(adjacentTargetTask)) {
mTargetRootTask = adjacentTargetTask;
}

View File

@@ -1030,12 +1030,11 @@ public class AppTransitionController {
canPromote = false;
}
// If the current window container is task and it have adjacent task, it means
// both tasks will open or close app toghther but we want get their opening or
// closing animation target independently so do not promote.
// If the current window container is a task with adjacent task set, the both
// adjacent tasks will be opened or closed together. To get their opening or
// closing animation target independently, skip promoting their animation targets.
if (current.asTask() != null
&& current.asTask().getAdjacentTaskFragment() != null
&& current.asTask().getAdjacentTaskFragment().asTask() != null) {
&& current.asTask().getAdjacentTask() != null) {
canPromote = false;
}

View File

@@ -17,7 +17,6 @@
package com.android.server.wm;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.view.Display.TYPE_INTERNAL;
import static android.view.InsetsFrameProvider.SOURCE_ARBITRARY_RECTANGLE;
import static android.view.InsetsFrameProvider.SOURCE_CONTAINER_BOUNDS;
@@ -2208,16 +2207,15 @@ public class DisplayPolicy {
private int updateSystemBarsLw(WindowState win, int disableFlags) {
final TaskDisplayArea defaultTaskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea();
final boolean multiWindowTaskVisible =
final boolean adjacentTasksVisible =
defaultTaskDisplayArea.getRootTask(task -> task.isVisible()
&& task.getTopLeafTask().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW)
&& task.getTopLeafTask().getAdjacentTask() != null)
!= null;
final boolean freeformRootTaskVisible =
defaultTaskDisplayArea.isRootTaskVisible(WINDOWING_MODE_FREEFORM);
// We need to force showing system bars when the multi-window or freeform root task is
// visible.
mForceShowSystemBars = multiWindowTaskVisible || freeformRootTaskVisible;
// We need to force showing system bars when adjacent tasks or freeform roots visible.
mForceShowSystemBars = adjacentTasksVisible || freeformRootTaskVisible;
// We need to force the consumption of the system bars if they are force shown or if they
// are controlled by a remote insets controller.
mForceConsumeSystemBars = mForceShowSystemBars
@@ -2238,7 +2236,7 @@ public class DisplayPolicy {
int appearance = APPEARANCE_OPAQUE_NAVIGATION_BARS | APPEARANCE_OPAQUE_STATUS_BARS;
appearance = configureStatusBarOpacity(appearance);
appearance = configureNavBarOpacity(appearance, multiWindowTaskVisible,
appearance = configureNavBarOpacity(appearance, adjacentTasksVisible,
freeformRootTaskVisible);
// Show immersive mode confirmation if needed.

View File

@@ -2362,6 +2362,22 @@ class Task extends TaskFragment {
return parentTask == null ? null : parentTask.getCreatedByOrganizerTask();
}
/** @return the first adjacent task of this task or its parent. */
@Nullable
Task getAdjacentTask() {
final TaskFragment adjacentTaskFragment = getAdjacentTaskFragment();
if (adjacentTaskFragment != null && adjacentTaskFragment.asTask() != null) {
return adjacentTaskFragment.asTask();
}
final WindowContainer parent = getParent();
if (parent == null || parent.asTask() == null) {
return null;
}
return parent.asTask().getAdjacentTask();
}
// TODO(task-merge): Figure out what's the right thing to do for places that used it.
boolean isRootTask() {
return getRootTask() == this;
@@ -2747,7 +2763,7 @@ class Task extends TaskFragment {
Rect outSurfaceInsets) {
// If this task has its adjacent task, it means they should animate together. Use display
// bounds for them could move same as full screen task.
if (getAdjacentTaskFragment() != null && getAdjacentTaskFragment().asTask() != null) {
if (getAdjacentTask() != null) {
super.getAnimationFrames(outFrame, outInsets, outStableInsets, outSurfaceInsets);
return;
}

View File

@@ -1081,12 +1081,12 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
if (sourceTask != null && sourceTask == candidateTask) {
// Do nothing when task that is getting opened is same as the source.
} else if (sourceTask != null
&& mLaunchAdjacentFlagRootTask.getAdjacentTaskFragment() != null
&& mLaunchAdjacentFlagRootTask.getAdjacentTask() != null
&& (sourceTask == mLaunchAdjacentFlagRootTask
|| sourceTask.isDescendantOf(mLaunchAdjacentFlagRootTask))) {
// If the adjacent launch is coming from the same root, launch to
// adjacent root instead.
return mLaunchAdjacentFlagRootTask.getAdjacentTaskFragment().asTask();
return mLaunchAdjacentFlagRootTask.getAdjacentTask();
} else {
return mLaunchAdjacentFlagRootTask;
}
@@ -1095,10 +1095,8 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
for (int i = mLaunchRootTasks.size() - 1; i >= 0; --i) {
if (mLaunchRootTasks.get(i).contains(windowingMode, activityType)) {
final Task launchRootTask = mLaunchRootTasks.get(i).task;
final TaskFragment adjacentTaskFragment = launchRootTask != null
? launchRootTask.getAdjacentTaskFragment() : null;
final Task adjacentRootTask =
adjacentTaskFragment != null ? adjacentTaskFragment.asTask() : null;
final Task adjacentRootTask = launchRootTask != null
? launchRootTask.getAdjacentTask() : null;
if (sourceTask != null && adjacentRootTask != null
&& (sourceTask == adjacentRootTask
|| sourceTask.isDescendantOf(adjacentRootTask))) {
@@ -1116,16 +1114,14 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
// A pinned task relaunching should be handled by its task organizer. Skip fallback
// launch target of a pinned task from source task.
|| candidateTask.getWindowingMode() != WINDOWING_MODE_PINNED)) {
Task launchTarget = sourceTask.getCreatedByOrganizerTask();
if (launchTarget != null && launchTarget.getAdjacentTaskFragment() != null) {
if (candidateTask != null) {
final Task candidateRoot = candidateTask.getCreatedByOrganizerTask();
if (candidateRoot != null && candidateRoot != launchTarget
&& launchTarget == candidateRoot.getAdjacentTaskFragment()) {
launchTarget = candidateRoot;
}
final Task adjacentTarget = sourceTask.getAdjacentTask();
if (adjacentTarget != null) {
if (candidateTask != null
&& (candidateTask == adjacentTarget
|| candidateTask.isDescendantOf(adjacentTarget))) {
return adjacentTarget;
}
return launchTarget;
return sourceTask.getCreatedByOrganizerTask();
}
}

View File

@@ -84,12 +84,14 @@ public class InsetsPolicyTest extends WindowTestsBase {
}
@Test
public void testControlsForDispatch_multiWindowTaskVisible() {
public void testControlsForDispatch_adjacentTasksVisible() {
addStatusBar();
addNavigationBar();
final WindowState win = createWindow(null, WINDOWING_MODE_MULTI_WINDOW,
ACTIVITY_TYPE_STANDARD, TYPE_APPLICATION, mDisplayContent, "app");
final Task task1 = createTask(mDisplayContent);
final Task task2 = createTask(mDisplayContent);
task1.setAdjacentTaskFragment(task2);
final WindowState win = createAppWindow(task1, WINDOWING_MODE_MULTI_WINDOW, "app");
final InsetsSourceControl[] controls = addWindowAndGetControlsForDispatch(win);
// The app must not control any system bars.