Merge "Prevent force showing system bars for TaskView" into udc-dev am: 427967322d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22609156

Change-Id: I3b740fcd59d2a03d6ec600e65c585013a089d0f5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jerry Chang
2023-04-18 10:44:54 +00:00
committed by Automerger Merge Worker
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 // 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 // the adjacent task as its launch target. So the existing task will be launched into the
// closer one and won't be reparent redundantly. // closer one and won't be reparent redundantly.
final Task adjacentTargetTask = mTargetRootTask.getAdjacentTaskFragment() != null final Task adjacentTargetTask = mTargetRootTask.getAdjacentTask();
? mTargetRootTask.getAdjacentTaskFragment().asTask() : null;
if (adjacentTargetTask != null && intentActivity.isDescendantOf(adjacentTargetTask)) { if (adjacentTargetTask != null && intentActivity.isDescendantOf(adjacentTargetTask)) {
mTargetRootTask = adjacentTargetTask; mTargetRootTask = adjacentTargetTask;
} }

View File

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

View File

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

View File

@@ -2362,6 +2362,22 @@ class Task extends TaskFragment {
return parentTask == null ? null : parentTask.getCreatedByOrganizerTask(); 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. // TODO(task-merge): Figure out what's the right thing to do for places that used it.
boolean isRootTask() { boolean isRootTask() {
return getRootTask() == this; return getRootTask() == this;
@@ -2747,7 +2763,7 @@ class Task extends TaskFragment {
Rect outSurfaceInsets) { Rect outSurfaceInsets) {
// If this task has its adjacent task, it means they should animate together. Use display // 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. // 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); super.getAnimationFrames(outFrame, outInsets, outStableInsets, outSurfaceInsets);
return; return;
} }

View File

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

View File

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