Merge "Prevent force showing system bars for TaskView" into tm-qpr-dev

This commit is contained in:
Jerry Chang
2023-05-10 16:05:08 +00:00
committed by Android (Google) Code Review
3 changed files with 25 additions and 8 deletions

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.InsetsState.ITYPE_BOTTOM_MANDATORY_GESTURES;
import static android.view.InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
@@ -2382,16 +2381,16 @@ 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.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;
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
@@ -2412,7 +2411,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);
final boolean requestHideNavBar = !win.getRequestedVisibility(ITYPE_NAVIGATION_BAR);

View File

@@ -2385,6 +2385,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;

View File

@@ -81,12 +81,14 @@ public class InsetsPolicyTest extends WindowTestsBase {
}
@Test
public void testControlsForDispatch_multiWindowTaskVisible() {
public void testControlsForDispatch_adjacentTasksVisible() {
addWindow(TYPE_STATUS_BAR, "statusBar");
addWindow(TYPE_NAVIGATION_BAR, "navBar");
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.