Merge "Allow remote inset transient bar configuration" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-07-29 01:17:04 +00:00
committed by Android (Google) Code Review
7 changed files with 72 additions and 8 deletions

View File

@@ -757,6 +757,15 @@
bar for all apps. --> bar for all apps. -->
<bool name="config_remoteInsetsControllerControlsSystemBars">false</bool> <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 --> <!-- HDMI behavior -->
<!-- The number of degrees to rotate the display when the device has HDMI connected <!-- The number of degrees to rotate the display when the device has HDMI connected

View File

@@ -1732,6 +1732,7 @@
<java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" /> <java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" />
<java-symbol type="bool" name="config_enableLockScreenRotation" /> <java-symbol type="bool" name="config_enableLockScreenRotation" />
<java-symbol type="bool" name="config_remoteInsetsControllerControlsSystemBars" /> <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_lidControlsScreenLock" />
<java-symbol type="bool" name="config_lidControlsSleep" /> <java-symbol type="bool" name="config_lidControlsSleep" />
<java-symbol type="bool" name="config_lockDayNightMode" /> <java-symbol type="bool" name="config_lockDayNightMode" />

View File

@@ -230,6 +230,7 @@ import android.window.DisplayWindowPolicyController;
import android.window.IDisplayAreaOrganizer; import android.window.IDisplayAreaOrganizer;
import android.window.TransitionRequestInfo; import android.window.TransitionRequestInfo;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -1075,7 +1076,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
mDisplayPolicy = new DisplayPolicy(mWmService, this); mDisplayPolicy = new DisplayPolicy(mWmService, this);
mDisplayRotation = new DisplayRotation(mWmService, this); mDisplayRotation = new DisplayRotation(mWmService, this);
mCloseToSquareMaxAspectRatio = mWmService.mContext.getResources().getFloat( mCloseToSquareMaxAspectRatio = mWmService.mContext.getResources().getFloat(
com.android.internal.R.dimen.config_closeToSquareDisplayMaxAspectRatio); R.dimen.config_closeToSquareDisplayMaxAspectRatio);
if (isDefaultDisplay) { if (isDefaultDisplay) {
// The policy may be invoked right after here, so it requires the necessary default // The policy may be invoked right after here, so it requires the necessary default
// fields of this display content. // fields of this display content.
@@ -1567,7 +1568,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
mAtmService.mContext.createConfigurationContext(getConfiguration()); mAtmService.mContext.createConfigurationContext(getConfiguration());
final float minimalSize = final float minimalSize =
displayConfigurationContext.getResources().getDimension( 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) { if (Double.compare(mDisplayMetrics.density, 0.0) == 0) {
throw new IllegalArgumentException("Display with ID=" + getDisplayId() + "has invalid " throw new IllegalArgumentException("Display with ID=" + getDisplayId() + "has invalid "
+ "DisplayMetrics.density= 0.0"); + "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 // if the wallpaper service is disabled on the device, we're never going to have
// wallpaper, don't bother waiting for it // wallpaper, don't bother waiting for it
boolean wallpaperEnabled = mWmService.mContext.getResources().getBoolean( boolean wallpaperEnabled = mWmService.mContext.getResources().getBoolean(
com.android.internal.R.bool.config_enableWallpaperService) R.bool.config_enableWallpaperService)
&& mWmService.mContext.getResources().getBoolean( && mWmService.mContext.getResources().getBoolean(
com.android.internal.R.bool.config_checkWallpaperAtBoot) R.bool.config_checkWallpaperAtBoot)
&& !mWmService.mOnlyCore; && !mWmService.mOnlyCore;
final boolean haveBootMsg = drawnWindowTypes.get(TYPE_BOOT_PROGRESS); final boolean haveBootMsg = drawnWindowTypes.get(TYPE_BOOT_PROGRESS);
@@ -6534,9 +6535,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
class RemoteInsetsControlTarget implements InsetsControlTarget { class RemoteInsetsControlTarget implements InsetsControlTarget {
private final IDisplayWindowInsetsController mRemoteInsetsController; private final IDisplayWindowInsetsController mRemoteInsetsController;
private final InsetsVisibilities mRequestedVisibilities = new InsetsVisibilities(); private final InsetsVisibilities mRequestedVisibilities = new InsetsVisibilities();
private final boolean mCanShowTransient;
RemoteInsetsControlTarget(IDisplayWindowInsetsController controller) { RemoteInsetsControlTarget(IDisplayWindowInsetsController controller) {
mRemoteInsetsController = 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 @Override
public boolean getRequestedVisibility(@InternalInsetsType int type) { public boolean getRequestedVisibility(@InternalInsetsType int type) {
if (type == ITYPE_IME) { if (type == ITYPE_IME) {

View File

@@ -220,6 +220,7 @@ public class DisplayPolicy {
@Px @Px
private int mRightGestureInset; private int mRightGestureInset;
private boolean mCanSystemBarsBeShownByUser;
private boolean mNavButtonForcedVisible; private boolean mNavButtonForcedVisible;
StatusBarManagerInternal getStatusBarManagerInternal() { StatusBarManagerInternal getStatusBarManagerInternal() {
@@ -425,6 +426,9 @@ public class DisplayPolicy {
final Resources r = mContext.getResources(); final Resources r = mContext.getResources();
mCarDockEnablesAccelerometer = r.getBoolean(R.bool.config_carDockEnablesAccelerometer); mCarDockEnablesAccelerometer = r.getBoolean(R.bool.config_carDockEnablesAccelerometer);
mDeskDockEnablesAccelerometer = r.getBoolean(R.bool.config_deskDockEnablesAccelerometer); mDeskDockEnablesAccelerometer = r.getBoolean(R.bool.config_deskDockEnablesAccelerometer);
mCanSystemBarsBeShownByUser = !r.getBoolean(
R.bool.config_remoteInsetsControllerControlsSystemBars) || r.getBoolean(
R.bool.config_remoteInsetsControllerSystemBarsCanBeShownByUserAction);
mAccessibilityManager = (AccessibilityManager) mContext.getSystemService( mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(
Context.ACCESSIBILITY_SERVICE); Context.ACCESSIBILITY_SERVICE);
@@ -617,7 +621,7 @@ public class DisplayPolicy {
displayContent.mAppTransition.registerListenerLocked(mAppTransitionListener); displayContent.mAppTransition.registerListenerLocked(mAppTransitionListener);
displayContent.mTransitionController.registerLegacyListener(mAppTransitionListener); displayContent.mTransitionController.registerLegacyListener(mAppTransitionListener);
mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext, looper, mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext, looper,
mService.mVrModeEnabled); mService.mVrModeEnabled, mCanSystemBarsBeShownByUser);
// TODO: Make it can take screenshot on external display // TODO: Make it can take screenshot on external display
mScreenshotHelper = displayContent.isDefaultDisplay mScreenshotHelper = displayContent.isDefaultDisplay
@@ -2024,6 +2028,11 @@ public class DisplayPolicy {
return lp.width; return lp.width;
} }
@VisibleForTesting
void setCanSystemBarsBeShownByUser(boolean canBeShown) {
mCanSystemBarsBeShownByUser = canBeShown;
}
void notifyDisplayReady() { void notifyDisplayReady() {
mHandler.post(() -> { mHandler.post(() -> {
final int displayId = getDisplayId(); final int displayId = getDisplayId();
@@ -2261,11 +2270,17 @@ public class DisplayPolicy {
updateSystemBarAttributes(); updateSystemBarAttributes();
} }
private void requestTransientBars(WindowState swipeTarget, boolean isGestureOnSystemBar) { @VisibleForTesting
void requestTransientBars(WindowState swipeTarget, boolean isGestureOnSystemBar) {
if (swipeTarget == null || !mService.mPolicy.isUserSetupComplete()) { if (swipeTarget == null || !mService.mPolicy.isUserSetupComplete()) {
// Swipe-up for navigation bar is disabled during setup // Swipe-up for navigation bar is disabled during setup
return; return;
} }
if (!mCanSystemBarsBeShownByUser) {
Slog.d(TAG, "Remote insets controller disallows showing system bars - ignoring "
+ "request");
return;
}
final InsetsSourceProvider provider = swipeTarget.getControllableInsetProvider(); final InsetsSourceProvider provider = swipeTarget.getControllableInsetProvider();
final InsetsControlTarget controlTarget = provider != null final InsetsControlTarget controlTarget = provider != null
? provider.getControlTarget() : null; ? provider.getControlTarget() : null;

View File

@@ -99,9 +99,11 @@ public class ImmersiveModeConfirmation {
// Local copy of vr mode enabled state, to avoid calling into VrManager with // Local copy of vr mode enabled state, to avoid calling into VrManager with
// the lock held. // the lock held.
private boolean mVrModeEnabled; private boolean mVrModeEnabled;
private boolean mCanSystemBarsBeShownByUser;
private int mLockTaskState = LOCK_TASK_MODE_NONE; 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 Display display = context.getDisplay();
final Context uiContext = ActivityThread.currentActivityThread().getSystemUiContext(); final Context uiContext = ActivityThread.currentActivityThread().getSystemUiContext();
mContext = display.getDisplayId() == DEFAULT_DISPLAY mContext = display.getDisplayId() == DEFAULT_DISPLAY
@@ -111,6 +113,7 @@ public class ImmersiveModeConfirmation {
mPanicThresholdMs = context.getResources() mPanicThresholdMs = context.getResources()
.getInteger(R.integer.config_immersive_mode_confirmation_panic); .getInteger(R.integer.config_immersive_mode_confirmation_panic);
mVrModeEnabled = vrModeEnabled; mVrModeEnabled = vrModeEnabled;
mCanSystemBarsBeShownByUser = canSystemBarsBeShownByUser;
} }
private long getNavBarExitDuration() { private long getNavBarExitDuration() {
@@ -171,6 +174,7 @@ public class ImmersiveModeConfirmation {
if ((DEBUG_SHOW_EVERY_TIME || !sConfirmed) if ((DEBUG_SHOW_EVERY_TIME || !sConfirmed)
&& userSetupComplete && userSetupComplete
&& !mVrModeEnabled && !mVrModeEnabled
&& mCanSystemBarsBeShownByUser
&& !navBarEmpty && !navBarEmpty
&& !UserManager.isDeviceInDemoMode(mContext) && !UserManager.isDeviceInDemoMode(mContext)
&& (mLockTaskState != LOCK_TASK_MODE_LOCKED)) { && (mLockTaskState != LOCK_TASK_MODE_LOCKED)) {

View File

@@ -45,7 +45,12 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; 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.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
@@ -344,4 +349,24 @@ public class DisplayPolicyTests extends WindowTestsBase {
final InsetsSource navBarSource = state.peekSource(ITYPE_NAVIGATION_BAR); final InsetsSource navBarSource = state.peekSource(ITYPE_NAVIGATION_BAR);
assertEquals(attrs.height - 10, navBarSource.getFrame().height()); 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());
}
} }

View File

@@ -40,6 +40,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
boolean mKeyguardShowingAndNotOccluded = false; boolean mKeyguardShowingAndNotOccluded = false;
boolean mOkToAnimate = true; boolean mOkToAnimate = true;
boolean mIsUserSetupComplete = false;
TestWindowManagerPolicy() { TestWindowManagerPolicy() {
} }
@@ -284,7 +285,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
@Override @Override
public boolean isUserSetupComplete() { public boolean isUserSetupComplete() {
return false; return mIsUserSetupComplete;
} }
@Override @Override