Merge "Allow remote inset transient bar configuration" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a3c10df0b9
@@ -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
|
||||
|
||||
@@ -1732,6 +1732,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" />
|
||||
|
||||
@@ -230,6 +230,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;
|
||||
@@ -1075,7 +1076,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.
|
||||
@@ -1567,7 +1568,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");
|
||||
@@ -4571,9 +4572,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);
|
||||
@@ -6534,9 +6535,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6592,6 +6596,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) {
|
||||
|
||||
@@ -220,6 +220,7 @@ public class DisplayPolicy {
|
||||
@Px
|
||||
private int mRightGestureInset;
|
||||
|
||||
private boolean mCanSystemBarsBeShownByUser;
|
||||
private boolean mNavButtonForcedVisible;
|
||||
|
||||
StatusBarManagerInternal getStatusBarManagerInternal() {
|
||||
@@ -425,6 +426,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);
|
||||
@@ -617,7 +621,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
|
||||
@@ -2024,6 +2028,11 @@ public class DisplayPolicy {
|
||||
return lp.width;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setCanSystemBarsBeShownByUser(boolean canBeShown) {
|
||||
mCanSystemBarsBeShownByUser = canBeShown;
|
||||
}
|
||||
|
||||
void notifyDisplayReady() {
|
||||
mHandler.post(() -> {
|
||||
final int displayId = getDisplayId();
|
||||
@@ -2261,11 +2270,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;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -45,7 +45,12 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.graphics.PixelFormat;
|
||||
@@ -344,4 +349,24 @@ public class DisplayPolicyTests extends WindowTestsBase {
|
||||
final InsetsSource navBarSource = state.peekSource(ITYPE_NAVIGATION_BAR);
|
||||
assertEquals(attrs.height - 10, navBarSource.getFrame().height());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCanSystemBarsBeShownByUser() {
|
||||
((TestWindowManagerPolicy) mWm.mPolicy).mIsUserSetupComplete = true;
|
||||
final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
|
||||
final WindowState windowState = mock(WindowState.class);
|
||||
final InsetsSourceProvider provider = mock(InsetsSourceProvider.class);
|
||||
final InsetsControlTarget controlTarget = mock(InsetsControlTarget.class);
|
||||
when(provider.getControlTarget()).thenReturn(controlTarget);
|
||||
when(windowState.getControllableInsetProvider()).thenReturn(provider);
|
||||
when(controlTarget.getRequestedVisibility(anyInt())).thenReturn(true);
|
||||
|
||||
displayPolicy.setCanSystemBarsBeShownByUser(false);
|
||||
displayPolicy.requestTransientBars(windowState, true);
|
||||
verify(controlTarget, never()).showInsets(anyInt(), anyBoolean());
|
||||
|
||||
displayPolicy.setCanSystemBarsBeShownByUser(true);
|
||||
displayPolicy.requestTransientBars(windowState, true);
|
||||
verify(controlTarget).showInsets(anyInt(), anyBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
|
||||
|
||||
boolean mKeyguardShowingAndNotOccluded = false;
|
||||
boolean mOkToAnimate = true;
|
||||
boolean mIsUserSetupComplete = false;
|
||||
|
||||
TestWindowManagerPolicy() {
|
||||
}
|
||||
@@ -284,7 +285,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
|
||||
|
||||
@Override
|
||||
public boolean isUserSetupComplete() {
|
||||
return false;
|
||||
return mIsUserSetupComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user