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

Commit 41db36ec authored by Jian-Yang Liu's avatar Jian-Yang Liu Committed by Android (Google) Code Review
Browse files

Merge "Updated InsetsPolicy to read config_forceShowSystemBars and prevent...

Merge "Updated InsetsPolicy to read config_forceShowSystemBars and prevent system bars from being hidden by applications if true." into rvc-dev
parents 0bd76726 ae86b3f1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -696,6 +696,10 @@ public class DisplayPolicy {
        mForceShowSystemBarsFromExternal = forceShowSystemBars;
    }

    boolean getForceShowSystemBars() {
        return mForceShowSystemBarsFromExternal;
    }

    public boolean hasNavigationBar() {
        return mHasNavigationBar;
    }
+4 −1
Original line number Diff line number Diff line
@@ -304,7 +304,10 @@ class InsetsPolicy {
        // We need to force system bars when the docked stack is visible, when the freeform stack
        // is visible but also when we are resizing for the transitions when docked stack
        // visibility changes.
        return isDockedStackVisible || isFreeformStackVisible || isResizing;
        return isDockedStackVisible
                || isFreeformStackVisible
                || isResizing
                || mPolicy.getForceShowSystemBars();
    }

    @VisibleForTesting
+12 −3
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -41,7 +40,6 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import android.platform.test.annotations.Presubmit;
import android.util.IntArray;
@@ -49,7 +47,6 @@ import android.view.InsetsSourceControl;
import android.view.InsetsState;
import android.view.test.InsetsModeSession;

import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;

import org.junit.AfterClass;
@@ -167,6 +164,18 @@ public class InsetsPolicyTest extends WindowTestsBase {
        assertEquals(1, controls.length);
    }

    @Test
    public void testControlsForDispatch_forceShowSystemBarsFromExternal_appHasNoControl() {
        mDisplayContent.getDisplayPolicy().setForceShowSystemBars(true);
        addWindow(TYPE_STATUS_BAR, "statusBar");
        addWindow(TYPE_NAVIGATION_BAR, "navBar");

        final InsetsSourceControl[] controls = addAppWindowAndGetControlsForDispatch();

        // The focused app window cannot control system bars.
        assertNull(controls);
    }

    @Test
    public void testShowTransientBars_bothCanBeTransient_appGetsBothFakeControls() {
        addNonFocusableWindow(TYPE_STATUS_BAR, "statusBar")
+1 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
                mChildAppWindowBelow = createCommonWindow(mAppWindow,
                        TYPE_APPLICATION_MEDIA_OVERLAY,
                        "mChildAppWindowBelow");
                mDisplayContent.getDisplayPolicy().setForceShowSystemBars(false);
            }

            // Adding a display will cause freezing the display. Make sure to wait until it's