diff options
24 files changed, 141 insertions, 66 deletions
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 8eb02a16350d..dbc1be141571 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -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; diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl index 33edc27118f2..d554514349c3 100644 --- a/core/java/android/view/IWindow.aidl +++ b/core/java/android/view/IWindow.aidl @@ -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. diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 8813c397b1e4..6d96bb9423c5 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -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 diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java index 4c50858b13b2..6c5f195ba2a0 100644 --- a/core/java/android/view/InsetsAnimationControlImpl.java +++ b/core/java/android/view/InsetsAnimationControlImpl.java @@ -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); } diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index e5d031b7a51c..0abad6c76c2e 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -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) { @@ -955,20 +955,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; } diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java index 828938b99e8f..c13b9ab0abd1 100644 --- a/core/java/android/view/InsetsState.java +++ b/core/java/android/view/InsetsState.java @@ -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]; diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index f51e3a369e9b..f1cde3b4bb7e 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -30744,6 +30744,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 * {@link ViewTreeObserver.OnComputeInternalInsetsListener}) and will diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 5ff995ca4944..9316dbf8a458 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -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; } @@ -8281,6 +8293,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( @@ -8903,7 +8918,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()); @@ -8922,9 +8937,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); @@ -10318,11 +10334,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); } } diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java index 7757c256164e..57a41619ff8d 100644 --- a/core/java/android/view/WindowInsets.java +++ b/core/java/android/view/WindowInsets.java @@ -1429,6 +1429,14 @@ public final class WindowInsets { /** @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) { mForceConsumingTypes = forceConsumingTypes; return this; diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java index c9368f16f0ed..99a4f6b41ef3 100644 --- a/core/java/android/view/WindowManagerGlobal.java +++ b/core/java/android/view/WindowManagerGlobal.java @@ -79,9 +79,16 @@ 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; diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java index 1efac4d2927f..7d3d283a45f2 100644 --- a/core/java/android/view/WindowlessWindowManager.java +++ b/core/java/android/view/WindowlessWindowManager.java @@ -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 } diff --git a/core/java/android/window/WindowMetricsController.java b/core/java/android/window/WindowMetricsController.java index ceda9cd8e6e9..954f68633e57 100644 --- a/core/java/android/window/WindowMetricsController.java +++ b/core/java/android/window/WindowMetricsController.java @@ -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) { diff --git a/core/java/com/android/internal/view/BaseIWindow.java b/core/java/com/android/internal/view/BaseIWindow.java index 0ac7765d4550..600058e88e4b 100644 --- a/core/java/com/android/internal/view/BaseIWindow.java +++ b/core/java/com/android/internal/view/BaseIWindow.java @@ -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); diff --git a/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java b/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java index a9c0e41b23bd..f45db23ace76 100644 --- a/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java +++ b/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java @@ -81,6 +81,7 @@ public class ImeInsetsSourceConsumerTest { 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); mImeConsumer = mController.getImeSourceConsumer(); diff --git a/core/tests/coretests/src/android/view/InsetsControllerTest.java b/core/tests/coretests/src/android/view/InsetsControllerTest.java index 76e4a6bfe2c7..06920524acfc 100644 --- a/core/tests/coretests/src/android/view/InsetsControllerTest.java +++ b/core/tests/coretests/src/android/view/InsetsControllerTest.java @@ -171,6 +171,7 @@ public class InsetsControllerTest { mController.onStateChanged(state); mController.calculateInsets( false, + false, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, SOFT_INPUT_ADJUST_RESIZE, 0, 0); mController.onFrameChanged(new Rect(0, 0, 100, 100)); diff --git a/core/tests/coretests/src/android/view/InsetsStateTest.java b/core/tests/coretests/src/android/view/InsetsStateTest.java index 6b32350c42ed..fde1a6d7b04c 100644 --- a/core/tests/coretests/src/android/view/InsetsStateTest.java +++ b/core/tests/coretests/src/android/view/InsetsStateTest.java @@ -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 = diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java index 586a794d5020..5e42782431fd 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java @@ -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, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java index 16a0318fb4fa..c964df1452e0 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java @@ -206,7 +206,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; diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 98c15dd26013..2717a6a8ab04 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -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 diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 50abfa0898e0..bb3d10912724 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -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; } @@ -9075,7 +9081,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) { @@ -9086,6 +9092,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); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index e33de4993723..cf1e51fb4e94 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -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()) { diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 2e055e8a665e..3db53eb08ea1 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -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())); } diff --git a/services/tests/wmtests/src/com/android/server/wm/TestIWindow.java b/services/tests/wmtests/src/com/android/server/wm/TestIWindow.java index 40f86ddb611c..3f8acc651110 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TestIWindow.java +++ b/services/tests/wmtests/src/com/android/server/wm/TestIWindow.java @@ -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 diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java index c13c2c3e35d0..0ddd3135506e 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java @@ -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(); |