Merge "Revert "Clean up alwaysConsumeSystemBars"" into udc-qpr-dev

This commit is contained in:
Dmitrii Ishcheikin
2023-07-04 13:10:35 +00:00
committed by Android (Google) Code Review
24 changed files with 141 additions and 66 deletions

View File

@@ -432,7 +432,8 @@ public abstract class WallpaperService extends Service {
@Override
public void resized(ClientWindowFrames frames, boolean reportDraw,
MergedConfiguration mergedConfiguration, InsetsState insetsState,
boolean forceLayout, int displayId, int syncSeqId, boolean dragResizing) {
boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
int syncSeqId, boolean dragResizing) {
Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED,
reportDraw ? 1 : 0,
mergedConfiguration);
@@ -1286,9 +1287,9 @@ public abstract class WallpaperService extends Service {
visibleFrame.intersect(mInsetsState.getDisplayFrame());
WindowInsets windowInsets = mInsetsState.calculateInsets(visibleFrame,
null /* ignoringVisibilityState */, config.isScreenRound(),
mLayout.softInputMode, mLayout.flags, SYSTEM_UI_FLAG_VISIBLE,
mLayout.type, config.windowConfiguration.getWindowingMode(),
null /* idSideMap */);
false /* alwaysConsumeSystemBars */, mLayout.softInputMode,
mLayout.flags, SYSTEM_UI_FLAG_VISIBLE, mLayout.type,
config.windowConfiguration.getWindowingMode(), null /* idSideMap */);
if (!fixedSize) {
final Rect padding = mIWallpaperEngine.mDisplayPadding;

View File

@@ -56,7 +56,8 @@ oneway interface IWindow {
void resized(in ClientWindowFrames frames, boolean reportDraw,
in MergedConfiguration newMergedConfiguration, in InsetsState insetsState,
boolean forceLayout, int displayId, int syncSeqId, boolean dragResizing);
boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
int syncSeqId, boolean dragResizing);
/**
* Called when this window retrieved control over a specified set of insets sources.

View File

@@ -737,8 +737,10 @@ interface IWindowManager
/**
* Called to get the expected window insets.
*
* @return {@code true} if system bars are always consumed.
*/
void getWindowInsets(int displayId, in IBinder token, out InsetsState outInsetsState);
boolean getWindowInsets(int displayId, in IBinder token, out InsetsState outInsetsState);
/**
* Returns a list of {@link android.view.DisplayInfo} for the logical display. This is not

View File

@@ -40,7 +40,6 @@ import static android.view.InsetsState.ISIDE_LEFT;
import static android.view.InsetsState.ISIDE_RIGHT;
import static android.view.InsetsState.ISIDE_TOP;
import static android.view.WindowInsets.Type.ime;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.inputmethod.ImeTracker.DEBUG_IME_VISIBILITY;
import static android.view.inputmethod.ImeTracker.TOKEN_NONE;
@@ -64,6 +63,7 @@ import android.view.InsetsState.InternalInsetsSide;
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowInsetsAnimation.Bounds;
import android.view.WindowManager.LayoutParams;
import android.view.animation.Interpolator;
import android.view.inputmethod.ImeTracker;
@@ -401,7 +401,8 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro
private Insets getInsetsFromState(InsetsState state, Rect frame,
@Nullable @InternalInsetsSide SparseIntArray idSideMap) {
return state.calculateInsets(frame, null /* ignoringVisibilityState */,
false /* isScreenRound */, SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode */,
false /* isScreenRound */, false /* alwaysConsumeSystemBars */,
LayoutParams.SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode*/,
0 /* legacyWindowFlags */, 0 /* legacySystemUiFlags */, TYPE_APPLICATION,
WINDOWING_MODE_UNDEFINED, idSideMap).getInsets(mTypes);
}

View File

@@ -797,9 +797,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
}
WindowInsets insets = state.calculateInsets(mFrame, mState /* ignoringVisibilityState*/,
mLastInsets.isRound(), mLastLegacySoftInputMode, mLastLegacyWindowFlags,
mLastLegacySystemUiFlags, mWindowType, mLastWindowingMode,
null /* idSideMap */);
mLastInsets.isRound(), false /* alwaysConsumeSystemBars */,
mLastLegacySoftInputMode, mLastLegacyWindowFlags, mLastLegacySystemUiFlags,
mWindowType, mLastWindowingMode, null /* idSideMap */);
mHost.dispatchWindowInsetsAnimationProgress(insets,
Collections.unmodifiableList(runningAnimations));
if (DEBUG) {
@@ -954,20 +954,21 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
}
/**
* @see InsetsState#calculateInsets(Rect, InsetsState, boolean, int, int, int, int, int,
* android.util.SparseIntArray)
* @see InsetsState#calculateInsets(Rect, InsetsState, boolean, boolean, int, int, int, int,
* int, android.util.SparseIntArray)
*/
@VisibleForTesting
public WindowInsets calculateInsets(boolean isScreenRound, int windowType, int windowingMode,
int legacySoftInputMode, int legacyWindowFlags, int legacySystemUiFlags) {
public WindowInsets calculateInsets(boolean isScreenRound, boolean alwaysConsumeSystemBars,
int windowType, int windowingMode, int legacySoftInputMode, int legacyWindowFlags,
int legacySystemUiFlags) {
mWindowType = windowType;
mLastWindowingMode = windowingMode;
mLastLegacySoftInputMode = legacySoftInputMode;
mLastLegacyWindowFlags = legacyWindowFlags;
mLastLegacySystemUiFlags = legacySystemUiFlags;
mLastInsets = mState.calculateInsets(mFrame, null /* ignoringVisibilityState*/,
isScreenRound, legacySoftInputMode, legacyWindowFlags, legacySystemUiFlags,
windowType, windowingMode, null /* idSideMap */);
isScreenRound, alwaysConsumeSystemBars, legacySoftInputMode, legacyWindowFlags,
legacySystemUiFlags, windowType, windowingMode, null /* idSideMap */);
return mLastInsets;
}

View File

@@ -40,7 +40,6 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.WindowConfiguration;
import android.app.WindowConfiguration.WindowingMode;
import android.graphics.Insets;
import android.graphics.Rect;
import android.os.Parcel;
@@ -137,8 +136,9 @@ public class InsetsState implements Parcelable {
* @return The calculated insets.
*/
public WindowInsets calculateInsets(Rect frame, @Nullable InsetsState ignoringVisibilityState,
boolean isScreenRound, int legacySoftInputMode, int legacyWindowFlags,
int legacySystemUiFlags, int windowType, @WindowingMode int windowingMode,
boolean isScreenRound, boolean alwaysConsumeSystemBars,
int legacySoftInputMode, int legacyWindowFlags, int legacySystemUiFlags,
int windowType, @WindowConfiguration.WindowingMode int windowingMode,
@Nullable @InternalInsetsSide SparseIntArray idSideMap) {
Insets[] typeInsetsMap = new Insets[Type.SIZE];
Insets[] typeMaxInsetsMap = new Insets[Type.SIZE];

View File

@@ -30743,6 +30743,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/
final Rect mCaptionInsets = new Rect();
/**
* In multi-window we force show the system bars. Because we don't want that the surface
* size changes in this mode, we instead have a flag whether the system bars sizes should
* always be consumed, so the app is treated like there are no virtual system bars at all.
*/
boolean mAlwaysConsumeSystemBars;
/**
* The internal insets given by this window. This value is
* supplied by the client (through

View File

@@ -82,6 +82,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_SANDBOXING_VIEW_BOUNDS_APIS;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_CANCEL_AND_REDRAW;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.IME_FOCUS_CONTROLLER;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.INSETS_CONTROLLER;
@@ -740,6 +741,7 @@ public final class ViewRootImpl implements ViewParent,
final Rect mPendingBackDropFrame = new Rect();
boolean mPendingAlwaysConsumeSystemBars;
private int mRelayoutSeq;
private final Rect mWinFrameInScreen = new Rect();
private final InsetsState mTempInsets = new InsetsState();
@@ -1364,6 +1366,9 @@ public final class ViewRootImpl implements ViewParent,
}
}
mAttachInfo.mAlwaysConsumeSystemBars =
(res & WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_SYSTEM_BARS) != 0;
mPendingAlwaysConsumeSystemBars = mAttachInfo.mAlwaysConsumeSystemBars;
mInsetsController.onStateChanged(mTempInsets);
mInsetsController.onControlsChanged(mTempControls.get());
final InsetsState state = mInsetsController.getState();
@@ -1877,8 +1882,8 @@ public final class ViewRootImpl implements ViewParent,
final MergedConfiguration mergedConfiguration = (MergedConfiguration) args.arg2;
CompatibilityInfo.applyOverrideScaleIfNeeded(mergedConfiguration);
final boolean forceNextWindowRelayout = args.argi1 != 0;
final int displayId = args.argi2;
final boolean dragResizing = args.argi4 != 0;
final int displayId = args.argi3;
final boolean dragResizing = args.argi5 != 0;
final Rect frame = frames.frame;
final Rect displayFrame = frames.displayFrame;
@@ -1930,7 +1935,8 @@ public final class ViewRootImpl implements ViewParent,
}
mForceNextWindowRelayout |= forceNextWindowRelayout;
mSyncSeqId = args.argi3 > mSyncSeqId ? args.argi3 : mSyncSeqId;
mPendingAlwaysConsumeSystemBars = args.argi2 != 0;
mSyncSeqId = args.argi4 > mSyncSeqId ? args.argi4 : mSyncSeqId;
if (msg == MSG_RESIZED_REPORT) {
reportNextDraw("resized");
@@ -2815,8 +2821,8 @@ public final class ViewRootImpl implements ViewParent,
if (mLastWindowInsets == null || forceConstruct) {
final Configuration config = getConfiguration();
mLastWindowInsets = mInsetsController.calculateInsets(
config.isScreenRound(), mWindowAttributes.type,
config.windowConfiguration.getWindowingMode(),
config.isScreenRound(), mAttachInfo.mAlwaysConsumeSystemBars,
mWindowAttributes.type, config.windowConfiguration.getWindowingMode(),
mWindowAttributes.softInputMode, mWindowAttributes.flags,
(mWindowAttributes.systemUiVisibility
| mWindowAttributes.subtreeSystemUiVisibility));
@@ -3278,6 +3284,8 @@ public final class ViewRootImpl implements ViewParent,
surfaceSizeChanged = true;
mLastSurfaceSize.set(mSurfaceSize.x, mSurfaceSize.y);
}
final boolean alwaysConsumeSystemBarsChanged =
mPendingAlwaysConsumeSystemBars != mAttachInfo.mAlwaysConsumeSystemBars;
updateColorModeIfNeeded(lp.getColorMode());
surfaceCreated = !hadSurface && mSurface.isValid();
surfaceDestroyed = hadSurface && !mSurface.isValid();
@@ -3291,6 +3299,10 @@ public final class ViewRootImpl implements ViewParent,
if (surfaceReplaced) {
mSurfaceSequenceId++;
}
if (alwaysConsumeSystemBarsChanged) {
mAttachInfo.mAlwaysConsumeSystemBars = mPendingAlwaysConsumeSystemBars;
dispatchApplyInsets = true;
}
if (updateCaptionInsets()) {
dispatchApplyInsets = true;
}
@@ -8289,6 +8301,9 @@ public final class ViewRootImpl implements ViewParent,
CompatibilityInfo.applyOverrideScaleIfNeeded(mPendingMergedConfiguration);
mInsetsController.onStateChanged(mTempInsets);
mInsetsController.onControlsChanged(mTempControls.get());
mPendingAlwaysConsumeSystemBars =
(relayoutResult & RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS) != 0;
}
final int transformHint = SurfaceControl.rotationToBufferTransform(
@@ -8911,7 +8926,7 @@ public final class ViewRootImpl implements ViewParent,
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private void dispatchResized(ClientWindowFrames frames, boolean reportDraw,
MergedConfiguration mergedConfiguration, InsetsState insetsState, boolean forceLayout,
int displayId, int syncSeqId, boolean dragResizing) {
boolean alwaysConsumeSystemBars, int displayId, int syncSeqId, boolean dragResizing) {
Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT : MSG_RESIZED);
SomeArgs args = SomeArgs.obtain();
final boolean sameProcessCall = (Binder.getCallingPid() == android.os.Process.myPid());
@@ -8930,9 +8945,10 @@ public final class ViewRootImpl implements ViewParent,
? new MergedConfiguration(mergedConfiguration) : mergedConfiguration;
args.arg3 = insetsState;
args.argi1 = forceLayout ? 1 : 0;
args.argi2 = displayId;
args.argi3 = syncSeqId;
args.argi4 = dragResizing ? 1 : 0;
args.argi2 = alwaysConsumeSystemBars ? 1 : 0;
args.argi3 = displayId;
args.argi4 = syncSeqId;
args.argi5 = dragResizing ? 1 : 0;
msg.obj = args;
mHandler.sendMessage(msg);
@@ -10326,11 +10342,12 @@ public final class ViewRootImpl implements ViewParent,
@Override
public void resized(ClientWindowFrames frames, boolean reportDraw,
MergedConfiguration mergedConfiguration, InsetsState insetsState,
boolean forceLayout, int displayId, int syncSeqId, boolean dragResizing) {
boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId, int syncSeqId,
boolean dragResizing) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
viewAncestor.dispatchResized(frames, reportDraw, mergedConfiguration, insetsState,
forceLayout, displayId, syncSeqId, dragResizing);
forceLayout, alwaysConsumeSystemBars, displayId, syncSeqId, dragResizing);
}
}

View File

@@ -1427,6 +1427,14 @@ public final class WindowInsets {
return this;
}
/** @hide */
@NonNull
public Builder setAlwaysConsumeSystemBars(boolean alwaysConsumeSystemBars) {
// TODO (b/277891341): Remove this and related usages. This has been replaced by
// #setForceConsumingTypes.
return this;
}
/** @hide */
@NonNull
public Builder setForceConsumingTypes(@InsetsType int forceConsumingTypes) {

View File

@@ -78,10 +78,17 @@ public final class WindowManagerGlobal {
*/
public static final int RELAYOUT_RES_SURFACE_RESIZED = 1 << 2;
/**
* In multi-window we force show the system bars. Because we don't want that the surface size
* changes in this mode, we instead have a flag whether the system bar sizes should always be
* consumed, so the app is treated like there is no virtual system bars at all.
*/
public static final int RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS = 1 << 3;
/**
* The window manager has told the window it cannot draw this frame and should retry again.
*/
public static final int RELAYOUT_RES_CANCEL_AND_REDRAW = 1 << 3;
public static final int RELAYOUT_RES_CANCEL_AND_REDRAW = 1 << 4;
/**
* Flag for relayout: the client will be later giving
@@ -92,7 +99,13 @@ public final class WindowManagerGlobal {
public static final int ADD_FLAG_IN_TOUCH_MODE = 0x1;
public static final int ADD_FLAG_APP_VISIBLE = 0x2;
public static final int ADD_FLAG_USE_BLAST = 0x4;
public static final int ADD_FLAG_USE_BLAST = 0x8;
/**
* Like {@link #RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS}, but as a "hint" when adding the
* window.
*/
public static final int ADD_FLAG_ALWAYS_CONSUME_SYSTEM_BARS = 0x4;
public static final int ADD_OKAY = 0;
public static final int ADD_BAD_APP_TOKEN = -1;

View File

@@ -631,8 +631,8 @@ public class WindowlessWindowManager implements IWindowSession {
mTmpFrames.displayFrame.set(mTmpFrames.frame);
mTmpConfig.setConfiguration(mConfiguration, mConfiguration);
s.mClient.resized(mTmpFrames, false /* reportDraw */, mTmpConfig, state,
false /* forceLayout */, s.mDisplayId, Integer.MAX_VALUE,
false /* dragResizing */);
false /* forceLayout */, false /* alwaysConsumeSystemBars */, s.mDisplayId,
Integer.MAX_VALUE, false /* dragResizing */);
} catch (RemoteException e) {
// Too bad
}

View File

@@ -112,14 +112,15 @@ public final class WindowMetricsController {
Rect bounds, boolean isScreenRound, int windowingMode) {
try {
final InsetsState insetsState = new InsetsState();
WindowManagerGlobal.getWindowManagerService().getWindowInsets(
displayId, token, insetsState);
final boolean alwaysConsumeSystemBars = WindowManagerGlobal.getWindowManagerService()
.getWindowInsets(displayId, token, insetsState);
final float overrideInvScale = CompatibilityInfo.getOverrideInvertedScale();
if (overrideInvScale != 1f) {
insetsState.scale(overrideInvScale);
}
return insetsState.calculateInsets(bounds, null /* ignoringVisibilityState */,
isScreenRound, SOFT_INPUT_ADJUST_NOTHING, 0 /* flags */, SYSTEM_UI_FLAG_VISIBLE,
isScreenRound, alwaysConsumeSystemBars, SOFT_INPUT_ADJUST_NOTHING,
0 /* flags */, SYSTEM_UI_FLAG_VISIBLE,
WindowManager.LayoutParams.INVALID_WINDOW_TYPE, windowingMode,
null /* idSideMap */);
} catch (RemoteException e) {

View File

@@ -53,7 +53,7 @@ public class BaseIWindow extends IWindow.Stub {
@Override
public void resized(ClientWindowFrames frames, boolean reportDraw,
MergedConfiguration mergedConfiguration, InsetsState insetsState, boolean forceLayout,
int displayId, int seqId, boolean dragResizing) {
boolean alwaysConsumeSystemBars, int displayId, int seqId, boolean dragResizing) {
if (reportDraw) {
try {
mSession.finishDrawing(this, null /* postDrawTransaction */, seqId);

View File

@@ -80,6 +80,7 @@ public class ImeInsetsSourceConsumerTest {
mController.getState().setDisplayCutout(new DisplayCutout(
Insets.of(10, 10, 10, 10), rect, rect, rect, rect));
mController.calculateInsets(
false,
false,
TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED,
SOFT_INPUT_ADJUST_RESIZE, 0, 0);

View File

@@ -170,6 +170,7 @@ public class InsetsControllerTest {
Insets.of(10, 10, 10, 10), rect, rect, rect, rect));
mController.onStateChanged(state);
mController.calculateInsets(
false,
false,
TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED,
SOFT_INPUT_ADJUST_RESIZE, 0, 0);

View File

@@ -100,7 +100,7 @@ public class InsetsStateTest {
.setVisible(true);
SparseIntArray typeSideMap = new SparseIntArray();
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
SOFT_INPUT_ADJUST_RESIZE, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED,
false, SOFT_INPUT_ADJUST_RESIZE, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED,
typeSideMap);
assertEquals(Insets.of(0, 100, 0, 100), insets.getSystemWindowInsets());
assertEquals(Insets.of(0, 100, 0, 100), insets.getInsets(Type.all()));
@@ -119,7 +119,8 @@ public class InsetsStateTest {
.setFrame(new Rect(0, 100, 100, 300))
.setVisible(true);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
SOFT_INPUT_ADJUST_RESIZE, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
false, SOFT_INPUT_ADJUST_RESIZE, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED,
null);
assertEquals(100, insets.getStableInsetBottom());
assertEquals(Insets.of(0, 0, 0, 100), insets.getInsetsIgnoringVisibility(systemBars()));
assertEquals(Insets.of(0, 0, 0, 200), insets.getSystemWindowInsets());
@@ -137,7 +138,7 @@ public class InsetsStateTest {
.setFrame(new Rect(80, 0, 100, 300))
.setVisible(true);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
0, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
false, 0, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(statusBars()));
assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(navigationBars()));
@@ -152,7 +153,7 @@ public class InsetsStateTest {
.setFrame(new Rect(80, 0, 100, 300))
.setVisible(true);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
0, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
false, 0, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.statusBars()));
assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(Type.navigationBars()));
@@ -167,7 +168,8 @@ public class InsetsStateTest {
.setFrame(new Rect(0, 200, 100, 300))
.setVisible(true);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
SOFT_INPUT_ADJUST_NOTHING, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
false, SOFT_INPUT_ADJUST_NOTHING, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED,
null);
assertEquals(0, insets.getSystemWindowInsetBottom());
assertEquals(100, insets.getInsets(ime()).bottom);
assertTrue(insets.isVisible(ime()));
@@ -182,10 +184,10 @@ public class InsetsStateTest {
.setFrame(new Rect(0, 200, 100, 300))
.setVisible(true);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
SOFT_INPUT_ADJUST_NOTHING, 0, SYSTEM_UI_FLAG_LAYOUT_STABLE, TYPE_APPLICATION,
false, SOFT_INPUT_ADJUST_NOTHING, 0, SYSTEM_UI_FLAG_LAYOUT_STABLE, TYPE_APPLICATION,
WINDOWING_MODE_UNDEFINED, null);
assertEquals(100, insets.getSystemWindowInsetTop());
insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false, false,
SOFT_INPUT_ADJUST_NOTHING, 0, 0 /* legacySystemUiFlags */, TYPE_APPLICATION,
WINDOWING_MODE_UNDEFINED, null);
assertEquals(0, insets.getSystemWindowInsetTop());
@@ -197,10 +199,10 @@ public class InsetsStateTest {
.setFrame(new Rect(0, 0, 100, 100))
.setVisible(false);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
SOFT_INPUT_ADJUST_NOTHING, FLAG_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_STABLE,
false, SOFT_INPUT_ADJUST_NOTHING, FLAG_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_STABLE,
TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
assertEquals(0, insets.getSystemWindowInsetTop());
insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false, false,
SOFT_INPUT_ADJUST_NOTHING, 0, 0 /* legacySystemUiFlags */, TYPE_APPLICATION,
WINDOWING_MODE_UNDEFINED, null);
assertEquals(0, insets.getSystemWindowInsetTop());
@@ -212,19 +214,19 @@ public class InsetsStateTest {
.setFrame(new Rect(0, 0, 100, 100))
.setVisible(true);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
SOFT_INPUT_ADJUST_NOTHING, FLAG_LAYOUT_NO_LIMITS,
false, SOFT_INPUT_ADJUST_NOTHING, FLAG_LAYOUT_NO_LIMITS,
0 /* legacySystemUiFlags */, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
assertEquals(0, insets.getSystemWindowInsetTop());
insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
SOFT_INPUT_ADJUST_NOTHING, FLAG_LAYOUT_NO_LIMITS,
false, SOFT_INPUT_ADJUST_NOTHING, FLAG_LAYOUT_NO_LIMITS,
0 /* legacySystemUiFlags */, TYPE_SYSTEM_ERROR, WINDOWING_MODE_UNDEFINED, null);
assertEquals(100, insets.getSystemWindowInsetTop());
insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
SOFT_INPUT_ADJUST_NOTHING, FLAG_LAYOUT_NO_LIMITS,
false, SOFT_INPUT_ADJUST_NOTHING, FLAG_LAYOUT_NO_LIMITS,
0 /* legacySystemUiFlags */, TYPE_WALLPAPER, WINDOWING_MODE_UNDEFINED, null);
assertEquals(100, insets.getSystemWindowInsetTop());
insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
SOFT_INPUT_ADJUST_NOTHING, FLAG_LAYOUT_NO_LIMITS,
false, SOFT_INPUT_ADJUST_NOTHING, FLAG_LAYOUT_NO_LIMITS,
0 /* legacySystemUiFlags */, TYPE_APPLICATION, WINDOWING_MODE_FREEFORM, null);
assertEquals(100, insets.getSystemWindowInsetTop());
}
@@ -266,7 +268,7 @@ public class InsetsStateTest {
.setFrame(new Rect(80, 0, 100, 300))
.setVisible(true);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
0, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
false, 0, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(statusBars()));
assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(navigationBars()));
@@ -281,7 +283,7 @@ public class InsetsStateTest {
.setFrame(new Rect(80, 0, 100, 300))
.setVisible(true);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
0, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
false, 0, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(statusBars()));
assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(navigationBars()));
@@ -296,7 +298,7 @@ public class InsetsStateTest {
.setFrame(new Rect(0, 200, 100, 300))
.setVisible(true);
mState.removeSource(ID_IME);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false, false,
SOFT_INPUT_ADJUST_RESIZE, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
assertEquals(0, insets.getSystemWindowInsetBottom());
}
@@ -528,7 +530,7 @@ public class InsetsStateTest {
new Rect(0, 0, 1, 2),
new Rect(197, 296, 200, 300),
new Rect(197, 296, 200, 300)));
DisplayCutout cutout = mState.calculateInsets(new Rect(1, 1, 199, 300), null, false,
DisplayCutout cutout = mState.calculateInsets(new Rect(1, 1, 199, 300), null, false, false,
SOFT_INPUT_ADJUST_UNSPECIFIED, 0, 0, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED,
new SparseIntArray()).getDisplayCutout();
assertEquals(0, cutout.getSafeInsetLeft());
@@ -554,7 +556,7 @@ public class InsetsStateTest {
new RoundedCorner(POSITION_BOTTOM_RIGHT, 20, 180, 380),
new RoundedCorner(POSITION_BOTTOM_LEFT, 20, 20, 380)));
WindowInsets windowInsets = mState.calculateInsets(new Rect(1, 2, 197, 396), null, false,
SOFT_INPUT_ADJUST_UNSPECIFIED, 0, 0, TYPE_APPLICATION,
false, SOFT_INPUT_ADJUST_UNSPECIFIED, 0, 0, TYPE_APPLICATION,
WINDOWING_MODE_UNDEFINED, new SparseIntArray());
assertEquals(new RoundedCorner(POSITION_TOP_LEFT, 10, 9, 8),
windowInsets.getRoundedCorner(POSITION_TOP_LEFT));
@@ -571,7 +573,7 @@ public class InsetsStateTest {
mState.setDisplayFrame(new Rect(0, 0, 200, 400));
mState.setDisplayShape(DisplayShape.createDefaultDisplayShape(200, 400, false));
WindowInsets windowInsets = mState.calculateInsets(new Rect(10, 20, 200, 400), null, false,
SOFT_INPUT_ADJUST_UNSPECIFIED, 0, 0, TYPE_APPLICATION,
false, SOFT_INPUT_ADJUST_UNSPECIFIED, 0, 0, TYPE_APPLICATION,
WINDOWING_MODE_UNDEFINED, new SparseIntArray());
final DisplayShape expect =

View File

@@ -347,7 +347,8 @@ public class SystemWindows {
@Override
public void resized(ClientWindowFrames frames, boolean reportDraw,
MergedConfiguration newMergedConfiguration, InsetsState insetsState,
boolean forceLayout, int displayId, int syncSeqId, boolean dragResizing) {}
boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId, int syncSeqId,
boolean dragResizing) {}
@Override
public void insetsControlChanged(InsetsState insetsState,

View File

@@ -214,7 +214,8 @@ public class TaskSnapshotWindow {
@Override
public void resized(ClientWindowFrames frames, boolean reportDraw,
MergedConfiguration mergedConfiguration, InsetsState insetsState,
boolean forceLayout, int displayId, int seqId, boolean dragResizing) {
boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId, int seqId,
boolean dragResizing) {
final TaskSnapshotWindow snapshot = mOuter.get();
if (snapshot == null) {
return;

View File

@@ -1284,6 +1284,12 @@ public class DisplayPolicy {
return ANIMATION_STYLEABLE;
}
// TODO (b/277891341): Remove this and related usages. This has been replaced by
// InsetsSource#FLAG_FORCE_CONSUMING.
public boolean areSystemBarsForcedConsumedLw() {
return false;
}
/**
* Computes the frames of display (its logical size, rotation and cutout should already be set)
* used to layout window. This method only changes the given display frames, insets state and

View File

@@ -1789,6 +1789,9 @@ public class WindowManagerService extends IWindowManager.Stub
winAnimator.mEnterAnimationPending = true;
winAnimator.mEnteringAnimation = true;
if (displayPolicy.areSystemBarsForcedConsumedLw()) {
res |= WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_SYSTEM_BARS;
}
if (displayContent.isInTouchMode()) {
res |= WindowManagerGlobal.ADD_FLAG_IN_TOUCH_MODE;
}
@@ -2491,6 +2494,9 @@ public class WindowManagerService extends IWindowManager.Stub
if (win.mActivityRecord != null) {
win.mActivityRecord.updateReportedVisibilityLocked();
}
if (displayPolicy.areSystemBarsForcedConsumedLw()) {
result |= WindowManagerGlobal.RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS;
}
if (!win.isGoneForLayout()) {
win.mResizedWhileGone = false;
}
@@ -9064,7 +9070,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
@Override
public void getWindowInsets(int displayId, IBinder token, InsetsState outInsetsState) {
public boolean getWindowInsets(int displayId, IBinder token, InsetsState outInsetsState) {
final long origId = Binder.clearCallingIdentity();
try {
synchronized (mGlobalLock) {
@@ -9075,6 +9081,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
final WindowToken winToken = dc.getWindowToken(token);
dc.getInsetsPolicy().getInsetsForWindowMetrics(winToken, outInsetsState);
return dc.getDisplayPolicy().areSystemBarsForcedConsumedLw();
}
} finally {
Binder.restoreCallingIdentity(origId);

View File

@@ -3732,6 +3732,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
final boolean isDragResizeChanged = isDragResizeChanged();
final boolean forceRelayout = syncWithBuffers || isDragResizeChanged;
final DisplayContent displayContent = getDisplayContent();
final boolean alwaysConsumeSystemBars =
displayContent.getDisplayPolicy().areSystemBarsForcedConsumedLw();
final int displayId = displayContent.getDisplayId();
if (isDragResizeChanged) {
@@ -3743,7 +3745,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
try {
mClient.resized(mClientWindowFrames, reportDraw, mLastReportedConfiguration,
getCompatInsetsState(), forceRelayout, displayId,
getCompatInsetsState(), forceRelayout, alwaysConsumeSystemBars, displayId,
syncWithBuffers ? mSyncSeqId : -1, isDragResizing);
if (drawPending && prevRotation >= 0 && prevRotation != mLastReportedConfiguration
.getMergedConfiguration().windowConfiguration.getRotation()) {

View File

@@ -3354,7 +3354,8 @@ public class ActivityRecordTests extends WindowTestsBase {
// to client if the app didn't request IME visible.
assertFalse(app2.mActivityRecord.mImeInsetsFrozenUntilStartInput);
verify(app2.mClient, atLeastOnce()).resized(any(), anyBoolean(), any(),
insetsStateCaptor.capture(), anyBoolean(), anyInt(), anyInt(), anyBoolean());
insetsStateCaptor.capture(), anyBoolean(), anyBoolean(), anyInt(), anyInt(),
anyBoolean());
assertFalse(app2.getInsetsState().isSourceOrDefaultVisible(ID_IME, ime()));
}

View File

@@ -46,7 +46,8 @@ public class TestIWindow extends IWindow.Stub {
@Override
public void resized(ClientWindowFrames frames, boolean reportDraw,
MergedConfiguration mergedConfig, InsetsState insetsState, boolean forceLayout,
int displayId, int seqId, boolean dragResizing) throws RemoteException {
boolean alwaysConsumeSystemBars, int displayId, int seqId, boolean dragResizing)
throws RemoteException {
}
@Override

View File

@@ -778,8 +778,8 @@ public class WindowStateTests extends WindowTestsBase {
doThrow(new RemoteException("test")).when(win.mClient).resized(any() /* frames */,
anyBoolean() /* reportDraw */, any() /* mergedConfig */,
any() /* insetsState */, anyBoolean() /* forceLayout */,
anyInt() /* displayId */, anyInt() /* seqId */,
anyBoolean() /* dragResizing */);
anyBoolean() /* alwaysConsumeSystemBars */, anyInt() /* displayId */,
anyInt() /* seqId */, anyBoolean() /* dragResizing */);
} catch (RemoteException ignored) {
}
win.reportResized();