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

Commit 0db7f8df authored by Jian-Yang Liu's avatar Jian-Yang Liu Committed by Automerger Merge Worker
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 am: 41db36ec am: 08a1dcd4 am: 1fad2bfb

Change-Id: Ifdeb2acb0328f20fc4f745e1478e8b2f2c34e806
parents a50aa0c8 1fad2bfb
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -696,6 +696,10 @@ public class DisplayPolicy {
        mForceShowSystemBarsFromExternal = forceShowSystemBars;
        mForceShowSystemBarsFromExternal = forceShowSystemBars;
    }
    }


    boolean getForceShowSystemBars() {
        return mForceShowSystemBarsFromExternal;
    }

    public boolean hasNavigationBar() {
    public boolean hasNavigationBar() {
        return mHasNavigationBar;
        return mHasNavigationBar;
    }
    }
+4 −1
Original line number Original line 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
        // 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
        // is visible but also when we are resizing for the transitions when docked stack
        // visibility changes.
        // visibility changes.
        return isDockedStackVisible || isFreeformStackVisible || isResizing;
        return isDockedStackVisible
                || isFreeformStackVisible
                || isResizing
                || mPolicy.getForceShowSystemBars();
    }
    }


    @VisibleForTesting
    @VisibleForTesting
+12 −3
Original line number Original line 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_NOTIFICATION_SHADE;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
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.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
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.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;


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


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


import org.junit.AfterClass;
import org.junit.AfterClass;
@@ -167,6 +164,18 @@ public class InsetsPolicyTest extends WindowTestsBase {
        assertEquals(1, controls.length);
        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
    @Test
    public void testShowTransientBars_bothCanBeTransient_appGetsBothFakeControls() {
    public void testShowTransientBars_bothCanBeTransient_appGetsBothFakeControls() {
        addNonFocusableWindow(TYPE_STATUS_BAR, "statusBar")
        addNonFocusableWindow(TYPE_STATUS_BAR, "statusBar")
+1 −0
Original line number Original line Diff line number Diff line
@@ -134,6 +134,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
                mChildAppWindowBelow = createCommonWindow(mAppWindow,
                mChildAppWindowBelow = createCommonWindow(mAppWindow,
                        TYPE_APPLICATION_MEDIA_OVERLAY,
                        TYPE_APPLICATION_MEDIA_OVERLAY,
                        "mChildAppWindowBelow");
                        "mChildAppWindowBelow");
                mDisplayContent.getDisplayPolicy().setForceShowSystemBars(false);
            }
            }


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