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

Commit bc193b47 authored by Alex Stetson's avatar Alex Stetson
Browse files

Allow remote inset transient bar configuration

Allow an OEM to configure the show transient behavior when using a
RemoteInsetsControlTarget.

Bug: 231351266
Test: manual, atest
com.android.server.wm.DisplayPolicyTests#testCanSystemBarsBeShownByUser

Change-Id: I2555b437ed62ea26f85dade6faa9c3a3cbc24593
Merged-In: I2555b437ed62ea26f85dade6faa9c3a3cbc24593
parent eec7bcb1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -757,6 +757,15 @@
         bar for all apps. -->
    <bool name="config_remoteInsetsControllerControlsSystemBars">false</bool>

    <!-- Control whether the system bars can be requested when using a remote insets control target.
         This allows for specifying whether or not system bars can be shown by the user (via swipe
         or other means) when they are hidden by the logic defined by the remote insets controller.
         This is useful for cases where the system provides alternative affordances for showing and
         hiding the bars or for cases in which it's desired the bars not be shown for any reason.
         This configuration will only apply when config_remoteInsetsControllerControlsSystemBars.
         is set to true. -->
    <bool name="config_remoteInsetsControllerSystemBarsCanBeShownByUserAction">false</bool>

    <!-- HDMI behavior -->

    <!-- The number of degrees to rotate the display when the device has HDMI connected
+1 −0
Original line number Diff line number Diff line
@@ -1731,6 +1731,7 @@
  <java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" />
  <java-symbol type="bool" name="config_enableLockScreenRotation" />
  <java-symbol type="bool" name="config_remoteInsetsControllerControlsSystemBars" />
  <java-symbol type="bool" name="config_remoteInsetsControllerSystemBarsCanBeShownByUserAction" />
  <java-symbol type="bool" name="config_lidControlsScreenLock" />
  <java-symbol type="bool" name="config_lidControlsSleep" />
  <java-symbol type="bool" name="config_lockDayNightMode" />
+13 −4
Original line number Diff line number Diff line
@@ -228,6 +228,7 @@ import android.window.DisplayWindowPolicyController;
import android.window.IDisplayAreaOrganizer;
import android.window.TransitionRequestInfo;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -1073,7 +1074,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        mDisplayPolicy = new DisplayPolicy(mWmService, this);
        mDisplayRotation = new DisplayRotation(mWmService, this);
        mCloseToSquareMaxAspectRatio = mWmService.mContext.getResources().getFloat(
                com.android.internal.R.dimen.config_closeToSquareDisplayMaxAspectRatio);
                R.dimen.config_closeToSquareDisplayMaxAspectRatio);
        if (isDefaultDisplay) {
            // The policy may be invoked right after here, so it requires the necessary default
            // fields of this display content.
@@ -1565,7 +1566,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                mAtmService.mContext.createConfigurationContext(getConfiguration());
        final float minimalSize =
                displayConfigurationContext.getResources().getDimension(
                                com.android.internal.R.dimen.default_minimal_size_resizable_task);
                        R.dimen.default_minimal_size_resizable_task);
        if (Double.compare(mDisplayMetrics.density, 0.0) == 0) {
            throw new IllegalArgumentException("Display with ID=" + getDisplayId() + "has invalid "
                + "DisplayMetrics.density= 0.0");
@@ -4549,9 +4550,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        // if the wallpaper service is disabled on the device, we're never going to have
        // wallpaper, don't bother waiting for it
        boolean wallpaperEnabled = mWmService.mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_enableWallpaperService)
                R.bool.config_enableWallpaperService)
                && mWmService.mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_checkWallpaperAtBoot)
                R.bool.config_checkWallpaperAtBoot)
                && !mWmService.mOnlyCore;

        final boolean haveBootMsg = drawnWindowTypes.get(TYPE_BOOT_PROGRESS);
@@ -6512,9 +6513,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    class RemoteInsetsControlTarget implements InsetsControlTarget {
        private final IDisplayWindowInsetsController mRemoteInsetsController;
        private final InsetsVisibilities mRequestedVisibilities = new InsetsVisibilities();
        private final boolean mCanShowTransient;

        RemoteInsetsControlTarget(IDisplayWindowInsetsController controller) {
            mRemoteInsetsController = controller;
            mCanShowTransient = mWmService.mContext.getResources().getBoolean(
                    R.bool.config_remoteInsetsControllerSystemBarsCanBeShownByUserAction);
        }

        /**
@@ -6569,6 +6573,11 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }
        }

        @Override
        public boolean canShowTransient() {
            return mCanShowTransient;
        }

        @Override
        public boolean getRequestedVisibility(@InternalInsetsType int type) {
            if (type == ITYPE_IME) {
+17 −2
Original line number Diff line number Diff line
@@ -219,6 +219,7 @@ public class DisplayPolicy {
    @Px
    private int mRightGestureInset;

    private boolean mCanSystemBarsBeShownByUser;
    private boolean mNavButtonForcedVisible;

    StatusBarManagerInternal getStatusBarManagerInternal() {
@@ -424,6 +425,9 @@ public class DisplayPolicy {
        final Resources r = mContext.getResources();
        mCarDockEnablesAccelerometer = r.getBoolean(R.bool.config_carDockEnablesAccelerometer);
        mDeskDockEnablesAccelerometer = r.getBoolean(R.bool.config_deskDockEnablesAccelerometer);
        mCanSystemBarsBeShownByUser = !r.getBoolean(
                R.bool.config_remoteInsetsControllerControlsSystemBars) || r.getBoolean(
                R.bool.config_remoteInsetsControllerSystemBarsCanBeShownByUserAction);

        mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(
                Context.ACCESSIBILITY_SERVICE);
@@ -616,7 +620,7 @@ public class DisplayPolicy {
        displayContent.mAppTransition.registerListenerLocked(mAppTransitionListener);
        displayContent.mTransitionController.registerLegacyListener(mAppTransitionListener);
        mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext, looper,
                mService.mVrModeEnabled);
                mService.mVrModeEnabled, mCanSystemBarsBeShownByUser);

        // TODO: Make it can take screenshot on external display
        mScreenshotHelper = displayContent.isDefaultDisplay
@@ -2019,6 +2023,11 @@ public class DisplayPolicy {
        return lp.width;
    }

    @VisibleForTesting
    void setCanSystemBarsBeShownByUser(boolean canBeShown) {
        mCanSystemBarsBeShownByUser = canBeShown;
    }

    void notifyDisplayReady() {
        mHandler.post(() -> {
            final int displayId = getDisplayId();
@@ -2256,11 +2265,17 @@ public class DisplayPolicy {
        updateSystemBarAttributes();
    }

    private void requestTransientBars(WindowState swipeTarget, boolean isGestureOnSystemBar) {
    @VisibleForTesting
    void requestTransientBars(WindowState swipeTarget, boolean isGestureOnSystemBar) {
        if (swipeTarget == null || !mService.mPolicy.isUserSetupComplete()) {
            // Swipe-up for navigation bar is disabled during setup
            return;
        }
        if (!mCanSystemBarsBeShownByUser) {
            Slog.d(TAG, "Remote insets controller disallows showing system bars - ignoring "
                    + "request");
            return;
        }
        final InsetsSourceProvider provider = swipeTarget.getControllableInsetProvider();
        final InsetsControlTarget controlTarget = provider != null
                ? provider.getControlTarget() : null;
+5 −1
Original line number Diff line number Diff line
@@ -99,9 +99,11 @@ public class ImmersiveModeConfirmation {
    // Local copy of vr mode enabled state, to avoid calling into VrManager with
    // the lock held.
    private boolean mVrModeEnabled;
    private boolean mCanSystemBarsBeShownByUser;
    private int mLockTaskState = LOCK_TASK_MODE_NONE;

    ImmersiveModeConfirmation(Context context, Looper looper, boolean vrModeEnabled) {
    ImmersiveModeConfirmation(Context context, Looper looper, boolean vrModeEnabled,
            boolean canSystemBarsBeShownByUser) {
        final Display display = context.getDisplay();
        final Context uiContext = ActivityThread.currentActivityThread().getSystemUiContext();
        mContext = display.getDisplayId() == DEFAULT_DISPLAY
@@ -111,6 +113,7 @@ public class ImmersiveModeConfirmation {
        mPanicThresholdMs = context.getResources()
                .getInteger(R.integer.config_immersive_mode_confirmation_panic);
        mVrModeEnabled = vrModeEnabled;
        mCanSystemBarsBeShownByUser = canSystemBarsBeShownByUser;
    }

    private long getNavBarExitDuration() {
@@ -171,6 +174,7 @@ public class ImmersiveModeConfirmation {
            if ((DEBUG_SHOW_EVERY_TIME || !sConfirmed)
                    && userSetupComplete
                    && !mVrModeEnabled
                    && mCanSystemBarsBeShownByUser
                    && !navBarEmpty
                    && !UserManager.isDeviceInDemoMode(mContext)
                    && (mLockTaskState != LOCK_TASK_MODE_LOCKED)) {
Loading