Skip to content

Commit e4abc45

Browse files
Jerry ChangAndroid Build Coastguard Worker
authored andcommitted
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. Bug: 273495037 Test: atest TaskDisplayAreaTests DisplayPolicyTests InsetsPolicyTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2bd0fe76a6b4ef566386e1949e4db0cf0db16430) Merged-In: I1c51c6f66cd6967651068de1ffc2e6e8566f5a46 Change-Id: I1c51c6f66cd6967651068de1ffc2e6e8566f5a46
1 parent c98b289 commit e4abc45

3 files changed

Lines changed: 25 additions & 8 deletions

File tree

services/core/java/com/android/server/wm/DisplayPolicy.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.android.server.wm;
1818

1919
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
20-
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
2120
import static android.view.Display.TYPE_INTERNAL;
2221
import static android.view.InsetsState.ITYPE_BOTTOM_MANDATORY_GESTURES;
2322
import static android.view.InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
@@ -2382,16 +2381,16 @@ int updateLightNavigationBarLw(int appearance, WindowState navColorWin) {
23822381

23832382
private int updateSystemBarsLw(WindowState win, int disableFlags) {
23842383
final TaskDisplayArea defaultTaskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea();
2385-
final boolean multiWindowTaskVisible =
2384+
final boolean adjacentTasksVisible =
23862385
defaultTaskDisplayArea.getRootTask(task -> task.isVisible()
2387-
&& task.getTopLeafTask().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW)
2386+
&& task.getAdjacentTask() != null)
23882387
!= null;
23892388
final boolean freeformRootTaskVisible =
23902389
defaultTaskDisplayArea.isRootTaskVisible(WINDOWING_MODE_FREEFORM);
23912390

23922391
// We need to force showing system bars when the multi-window or freeform root task is
23932392
// visible.
2394-
mForceShowSystemBars = multiWindowTaskVisible || freeformRootTaskVisible;
2393+
mForceShowSystemBars = adjacentTasksVisible || freeformRootTaskVisible;
23952394
// We need to force the consumption of the system bars if they are force shown or if they
23962395
// are controlled by a remote insets controller.
23972396
mForceConsumeSystemBars = mForceShowSystemBars
@@ -2412,7 +2411,7 @@ private int updateSystemBarsLw(WindowState win, int disableFlags) {
24122411

24132412
int appearance = APPEARANCE_OPAQUE_NAVIGATION_BARS | APPEARANCE_OPAQUE_STATUS_BARS;
24142413
appearance = configureStatusBarOpacity(appearance);
2415-
appearance = configureNavBarOpacity(appearance, multiWindowTaskVisible,
2414+
appearance = configureNavBarOpacity(appearance, adjacentTasksVisible,
24162415
freeformRootTaskVisible);
24172416

24182417
final boolean requestHideNavBar = !win.getRequestedVisibility(ITYPE_NAVIGATION_BAR);

services/core/java/com/android/server/wm/Task.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,22 @@ Task getCreatedByOrganizerTask() {
23852385
return parentTask == null ? null : parentTask.getCreatedByOrganizerTask();
23862386
}
23872387

2388+
/** @return the first adjacent task of this task or its parent. */
2389+
@Nullable
2390+
Task getAdjacentTask() {
2391+
final TaskFragment adjacentTaskFragment = getAdjacentTaskFragment();
2392+
if (adjacentTaskFragment != null && adjacentTaskFragment.asTask() != null) {
2393+
return adjacentTaskFragment.asTask();
2394+
}
2395+
2396+
final WindowContainer parent = getParent();
2397+
if (parent == null || parent.asTask() == null) {
2398+
return null;
2399+
}
2400+
2401+
return parent.asTask().getAdjacentTask();
2402+
}
2403+
23882404
// TODO(task-merge): Figure out what's the right thing to do for places that used it.
23892405
boolean isRootTask() {
23902406
return getRootTask() == this;

services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,14 @@ public void testControlsForDispatch_regular() {
8181
}
8282

8383
@Test
84-
public void testControlsForDispatch_multiWindowTaskVisible() {
84+
public void testControlsForDispatch_adjacentTasksVisible() {
8585
addWindow(TYPE_STATUS_BAR, "statusBar");
8686
addWindow(TYPE_NAVIGATION_BAR, "navBar");
8787

88-
final WindowState win = createWindow(null, WINDOWING_MODE_MULTI_WINDOW,
89-
ACTIVITY_TYPE_STANDARD, TYPE_APPLICATION, mDisplayContent, "app");
88+
final Task task1 = createTask(mDisplayContent);
89+
final Task task2 = createTask(mDisplayContent);
90+
task1.setAdjacentTaskFragment(task2);
91+
final WindowState win = createAppWindow(task1, WINDOWING_MODE_MULTI_WINDOW, "app");
9092
final InsetsSourceControl[] controls = addWindowAndGetControlsForDispatch(win);
9193

9294
// The app must not control any system bars.

0 commit comments

Comments
 (0)