Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8867b014 authored by Chris Li's avatar Chris Li Committed by Android (Google) Code Review
Browse files

Merge "Make sure system bar is not hidden when Bubble is open" into main

parents c3682c70 2c95be34
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -210,3 +210,14 @@ flag {
    description: "Experiment to allow apps to request Bubbles actions in WM Shell"
    bug: "407149510"
}

flag {
    namespace: "windowing_sdk"
    name: "force_show_system_bar_for_bubble"
    description: "Ensure system bar are shown for Bubble"
    bug: "329124127"
    is_fixed_read_only: true
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+11 −3
Original line number Diff line number Diff line
@@ -2623,6 +2623,8 @@ public class DisplayPolicy {

    private int updateSystemBarsLw(WindowState win, int disableFlags) {
        final TaskDisplayArea defaultTaskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea();
        // TODO(b/407898759): Migrate to have WM Shell to override the insets visibility based on
        // top focused Task.
        final boolean adjacentTasksVisible =
                defaultTaskDisplayArea.getRootTask(task -> task.isVisible()
                        && task.getTopLeafTask().hasAdjacentTask())
@@ -2633,14 +2635,20 @@ public class DisplayPolicy {
                && topFreeformTask.isVisible();
        final boolean inNonFullscreenFreeformMode = freeformRootTaskVisible
                && !topFreeformTask.getBounds().equals(mDisplayContent.getBounds());
        // Always show status/nav bar for non-fullscreen multi window (excluding PiP).
        boolean showSystemBarsByLegacyPolicy = adjacentTasksVisible
                || (DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue()
                ? inNonFullscreenFreeformMode : freeformRootTaskVisible);
        if (com.android.window.flags.Flags.forceShowSystemBarForBubble()) {
            showSystemBarsByLegacyPolicy |= defaultTaskDisplayArea.getRootTask(
                    task -> task.isVisible() && task.isNonFullscreenMultiWindow()) != null;
        }

        getInsetsPolicy().updateSystemBars(
                win,
                mShowingPermanentInsetsTypes,
                mHidingPermanentInsetsTypes,
                adjacentTasksVisible,
                DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue()
                        ? inNonFullscreenFreeformMode : freeformRootTaskVisible);
                showSystemBarsByLegacyPolicy);

        final boolean topAppHidesStatusBar = topAppHidesSystemBar(Type.statusBars());
        if (getStatusBar() != null) {
+2 −3
Original line number Diff line number Diff line
@@ -673,8 +673,7 @@ class InsetsPolicy {
    }

    void updateSystemBars(WindowState win, @InsetsType int displayForciblyShowingTypes,
            @InsetsType int displayForciblyHidingTypes, boolean inSplitScreenMode,
            boolean inNonFullscreenFreeformMode) {
            @InsetsType int displayForciblyHidingTypes, boolean showSystemBarsByLegacyPolicy) {
        final boolean hasDisplayOverride = displayForciblyShowingTypes != 0
                || displayForciblyHidingTypes != 0;
        mForciblyShowingTypes =
@@ -686,7 +685,7 @@ class InsetsPolicy {
                        // Add types forcibly shown by the display if there is any.
                        ? displayForciblyShowingTypes
                        // Otherwise, fallback to the legacy policy.
                        : (inSplitScreenMode || inNonFullscreenFreeformMode)
                        : showSystemBarsByLegacyPolicy
                                ? (Type.statusBars() | Type.navigationBars())
                                : 0);
        mForciblyHidingTypes = displayForciblyHidingTypes;
+7 −0
Original line number Diff line number Diff line
@@ -5000,6 +5000,13 @@ class Task extends TaskFragment {
        return mDisplayContent != null && this == mDisplayContent.getFocusedRootTask();
    }

    /** Whether this Task is multi window (exclude PiP) and not filling parent. */
    boolean isNonFullscreenMultiWindow() {
        final int windowingMode = getWindowingMode();
        return windowingMode != WINDOWING_MODE_FULLSCREEN && windowingMode != WINDOWING_MODE_PINNED
                && !fillsParent();
    }

    /**
     * Make sure that all activities that need to be visible in the root task (that is, they
     * currently can be seen by the user) actually are and update their configuration.
+28 −12
Original line number Diff line number Diff line
@@ -67,6 +67,12 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
 * Tests for the {@link InsetsPolicy} class.
 *
 * Build/Install/Run:
 *  atest WmTests:InsetsPolicyTest
 */
@SmallTest
@Presubmit
@RunWith(WindowTestRunner.class)
@@ -152,6 +158,22 @@ public class InsetsPolicyTest extends WindowTestsBase {
        assertNull(controls);
    }

    @Test
    @EnableFlags(Flags.FLAG_FORCE_SHOW_SYSTEM_BAR_FOR_BUBBLE)
    public void testControlsForDispatch_nonFullscreenMultiWindowTaskVisible() {
        addStatusBar();
        addNavigationBar();

        final WindowState win = newWindowBuilder("app", TYPE_APPLICATION).setActivityType(
                ACTIVITY_TYPE_STANDARD).setWindowingMode(WINDOWING_MODE_MULTI_WINDOW).setDisplay(
                mDisplayContent).build();
        win.getTask().setBounds(new Rect(1, 1, 10, 10));
        final InsetsSourceControl[] controls = addWindowAndGetControlsForDispatch(win);

        // The non fullscreen multi window app window must not control any system bars.
        assertNull(controls);
    }

    @Test
    public void testControlsForDispatch_forceStatusBarVisible() {
        addStatusBar().mAttrs.forciblyShownTypes |= statusBars();
@@ -319,8 +341,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
                app,
                0 /* displayForciblyShowingTypes */,
                0 /* displayForciblyHidingTypes */,
                false /* inSplitScreenMode */,
                false /* inNonFullscreenFreeformMode */);
                false /* showSystemBarsByLegacyPolicy */);

        statusBarProvider.updateClientVisibility(statusBarProvider.getControlTarget(), null);
        navBarProvider.updateClientVisibility(navBarProvider.getControlTarget(), null);
@@ -371,8 +392,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
                app,
                statusBars() /* displayForciblyShowingTypes */,
                0 /* displayForciblyHidingTypes */,
                false /* inSplitScreenMode */,
                false /* inNonFullscreenFreeformMode */);
                false /* showSystemBarsByLegacyPolicy */);

        statusBarProvider.updateClientVisibility(statusBarProvider.getControlTarget(), null);
        navBarProvider.updateClientVisibility(navBarProvider.getControlTarget(), null);
@@ -424,8 +444,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
                app,
                0 /* displayForciblyShowingTypes */,
                statusBars() /* displayForciblyHidingTypes */,
                false /* inSplitScreenMode */,
                false /* inNonFullscreenFreeformMode */);
                false /* showSystemBarsByLegacyPolicy */);

        statusBarProvider.updateClientVisibility(statusBarProvider.getControlTarget(), null);
        navBarProvider.updateClientVisibility(navBarProvider.getControlTarget(), null);
@@ -477,8 +496,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
                app,
                0 /* displayForciblyShowingTypes */,
                0 /* displayForciblyHidingTypes */,
                true /* inSplitScreenMode */,
                false /* inNonFullscreenFreeformMode */);
                true /* showSystemBarsByLegacyPolicy */);

        statusBarProvider.updateClientVisibility(statusBarProvider.getControlTarget(), null);
        navBarProvider.updateClientVisibility(navBarProvider.getControlTarget(), null);
@@ -528,8 +546,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
                app,
                0 /* displayForciblyShowingTypes */,
                0 /* displayForciblyHidingTypes */,
                false /* inSplitScreenMode */,
                true /* inNonFullscreenFreeformMode */);
                true /* showSystemBarsByLegacyPolicy */);

        statusBarProvider.updateClientVisibility(statusBarProvider.getControlTarget(), null);
        navBarProvider.updateClientVisibility(navBarProvider.getControlTarget(), null);
@@ -579,8 +596,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
                app,
                0 /* displayForciblyShowingTypes */,
                statusBars() /* displayForciblyHidingTypes */,
                true /* inSplitScreenMode */,
                false /* inNonFullscreenFreeformMode */);
                true /* showSystemBarsByLegacyPolicy */);

        statusBarProvider.updateClientVisibility(statusBarProvider.getControlTarget(), null);
        navBarProvider.updateClientVisibility(navBarProvider.getControlTarget(), null);