Merge "Fix issue with letterboxing"

This commit is contained in:
TreeHugger Robot
2020-01-07 00:29:30 +00:00
committed by Android (Google) Code Review
9 changed files with 38 additions and 14 deletions

View File

@@ -41,6 +41,7 @@ public class InsetsSource implements Parcelable {
public InsetsSource(@InternalInsetsType int type) {
mType = type;
mFrame = new Rect();
mVisible = InsetsState.getDefaultVisibility(type);
}
public InsetsSource(InsetsSource other) {

View File

@@ -102,8 +102,12 @@ public class InsetsSourceConsumerTest {
@Test
public void testShow() {
// Insets source starts out visible
mConsumer.hide();
mConsumer.show();
assertTrue("Consumer should be visible", mConsumer.isVisible());
verify(mSpyInsetsSource).setVisible(eq(false));
verify(mSpyInsetsSource).setVisible(eq(true));
}

View File

@@ -2192,10 +2192,13 @@ public class DisplayPolicy {
final boolean attachedInParent = attached != null && !layoutInScreen;
final boolean requestedFullscreen = (fl & FLAG_FULLSCREEN) != 0
|| (requestedSysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0
|| !win.getClientInsetsState().getSource(ITYPE_STATUS_BAR).isVisible();
|| (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL
&& !win.getRequestedInsetsState().getSource(ITYPE_STATUS_BAR).isVisible());
final boolean requestedHideNavigation =
(requestedSysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0
|| !win.getClientInsetsState().getSource(ITYPE_NAVIGATION_BAR).isVisible();
|| (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL
&& !win.getRequestedInsetsState().getSource(ITYPE_NAVIGATION_BAR)
.isVisible());
// TYPE_BASE_APPLICATION windows are never considered floating here because they don't get
// cropped / shifted to the displayFrame in WindowState.

View File

@@ -66,10 +66,11 @@ class InsetsPolicy {
}
mStatusBar.setVisible(focusedWin == null
|| focusedWin != getStatusControlTarget(focusedWin)
|| focusedWin.getClientInsetsState().getSource(ITYPE_STATUS_BAR).isVisible());
|| focusedWin.getRequestedInsetsState().getSource(ITYPE_STATUS_BAR).isVisible());
mNavBar.setVisible(focusedWin == null
|| focusedWin != getNavControlTarget(focusedWin)
|| focusedWin.getClientInsetsState().getSource(ITYPE_NAVIGATION_BAR).isVisible());
|| focusedWin.getRequestedInsetsState().getSource(ITYPE_NAVIGATION_BAR)
.isVisible());
}
boolean isHidden(@InternalInsetsType int type) {

View File

@@ -463,7 +463,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
final WindowState windowState = mService.windowForClientLocked(this, window,
false /* throwOnError */);
if (windowState != null) {
windowState.setClientInsetsState(state);
windowState.updateRequestedInsetsState(state);
windowState.getDisplayContent().getInsetsPolicy().onInsetsModified(
windowState, state);
}

View File

@@ -470,7 +470,7 @@ class TaskSnapshotController {
final LayoutParams attrs = mainWindow.getAttrs();
final SystemBarBackgroundPainter decorPainter = new SystemBarBackgroundPainter(attrs.flags,
attrs.privateFlags, attrs.systemUiVisibility, task.getTaskDescription(),
mFullSnapshotScale, mainWindow.getClientInsetsState());
mFullSnapshotScale, mainWindow.getRequestedInsetsState());
final int width = (int) (task.getBounds().width() * mFullSnapshotScale);
final int height = (int) (task.getBounds().height() * mFullSnapshotScale);

View File

@@ -222,7 +222,7 @@ class TaskSnapshotSurface implements StartingSurface {
final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window,
surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, sysUiVis,
windowFlags, windowPrivateFlags, taskBounds,
currentOrientation, topFullscreenOpaqueWindow.getClientInsetsState());
currentOrientation, topFullscreenOpaqueWindow.getRequestedInsetsState());
window.setOuter(snapshotSurface);
try {
session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, -1,

View File

@@ -210,6 +210,7 @@ import android.view.InputChannel;
import android.view.InputEvent;
import android.view.InputEventReceiver;
import android.view.InputWindowHandle;
import android.view.InsetsSource;
import android.view.InsetsState;
import android.view.Surface.Rotation;
import android.view.SurfaceControl;
@@ -650,17 +651,29 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
private boolean mIsDimming = false;
private @Nullable InsetsSourceProvider mControllableInsetProvider;
private InsetsState mClientInsetsState;
private InsetsState mRequestedInsetsState;
private static final float DEFAULT_DIM_AMOUNT_DEAD_WINDOW = 0.5f;
private KeyInterceptionInfo mKeyInterceptionInfo;
InsetsState getClientInsetsState() {
return mClientInsetsState;
/**
* @return The insets state as requested by the client, i.e. the dispatched insets state
* for which the visibilities are overridden with what the client requested.
*/
InsetsState getRequestedInsetsState() {
return mRequestedInsetsState;
}
void setClientInsetsState(InsetsState state) {
mClientInsetsState = state;
/**
* @see #getRequestedInsetsState()
*/
void updateRequestedInsetsState(InsetsState state) {
// Only update the sources the client is actually controlling.
for (int i = state.getSourcesCount(); i >= 0; i--) {
final InsetsSource source = state.sourceAt(i);
mRequestedInsetsState.addSource(source);
}
}
void seamlesslyRotateIfAllowed(Transaction transaction, @Rotation int oldRotation,
@@ -779,7 +792,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mSeq = seq;
mPowerManagerWrapper = powerManagerWrapper;
mForceSeamlesslyRotate = token.mRoundedCornerOverlay;
mClientInsetsState =
mRequestedInsetsState =
getDisplayContent().getInsetsPolicy().getInsetsForDispatch(this);
if (DEBUG) {
Slog.v(TAG, "Window " + this + " client=" + c.asBinder()

View File

@@ -421,8 +421,10 @@ public class WindowStateTests extends WindowTestsBase {
.setWindow(statusBar, null /* frameProvider */);
mDisplayContent.getInsetsStateController().onBarControlTargetChanged(
app, null /* fakeTopControlling */, app, null /* fakeNavControlling */);
final InsetsSource source = new InsetsSource(ITYPE_STATUS_BAR);
source.setVisible(false);
mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_STATUS_BAR)
.onInsetsModified(app, new InsetsSource(ITYPE_STATUS_BAR));
.onInsetsModified(app, source);
waitUntilHandlersIdle();
assertFalse(statusBar.isVisible());
}