diff options
14 files changed, 53 insertions, 65 deletions
diff --git a/core/java/android/view/InsetsFrameProvider.java b/core/java/android/view/InsetsFrameProvider.java index 470c2801d838..a47f34f4125e 100644 --- a/core/java/android/view/InsetsFrameProvider.java +++ b/core/java/android/view/InsetsFrameProvider.java @@ -164,6 +164,10 @@ public class InsetsFrameProvider implements Parcelable { return mFlags; } + public boolean hasFlags(@Flags int mask) { + return (mFlags & mask) == mask; + } + public InsetsFrameProvider setInsetsSize(Insets insetsSize) { mInsetsSize = insetsSize; return this; diff --git a/core/java/android/view/InsetsSource.java b/core/java/android/view/InsetsSource.java index 9fc42fff7084..e10184976abe 100644 --- a/core/java/android/view/InsetsSource.java +++ b/core/java/android/view/InsetsSource.java @@ -58,9 +58,20 @@ public class InsetsSource implements Parcelable { */ public static final int FLAG_SUPPRESS_SCRIM = 1; + /** + * Controls whether the insets frame will be used to move {@link RoundedCorner} inward with the + * insets frame size when calculating the rounded corner insets to other windows. + * + * For example, task bar will draw fake rounded corners above itself, so we need to move the + * rounded corner up by the task bar insets size to make other windows see a rounded corner + * above the task bar. + */ + public static final int FLAG_INSETS_ROUNDED_CORNER = 1 << 1; + @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, prefix = "FLAG_", value = { FLAG_SUPPRESS_SCRIM, + FLAG_INSETS_ROUNDED_CORNER, }) public @interface Flags {} @@ -78,7 +89,6 @@ public class InsetsSource implements Parcelable { private @Nullable Rect mVisibleFrame; private boolean mVisible; - private boolean mInsetsRoundedCornerFrame; private final Rect mTmpFrame = new Rect(); @@ -98,7 +108,6 @@ public class InsetsSource implements Parcelable { ? new Rect(other.mVisibleFrame) : null; mFlags = other.mFlags; - mInsetsRoundedCornerFrame = other.mInsetsRoundedCornerFrame; } public void set(InsetsSource other) { @@ -108,7 +117,6 @@ public class InsetsSource implements Parcelable { ? new Rect(other.mVisibleFrame) : null; mFlags = other.mFlags; - mInsetsRoundedCornerFrame = other.mInsetsRoundedCornerFrame; } public InsetsSource setFrame(int left, int top, int right, int bottom) { @@ -136,6 +144,11 @@ public class InsetsSource implements Parcelable { return this; } + public InsetsSource setFlags(@Flags int flags, @Flags int mask) { + mFlags = (mFlags & ~mask) | (flags & mask); + return this; + } + public int getId() { return mId; } @@ -160,20 +173,15 @@ public class InsetsSource implements Parcelable { return mFlags; } + public boolean hasFlags(int flags) { + return (mFlags & flags) == flags; + } + boolean isUserControllable() { // If mVisibleFrame is null, it will be the same area as mFrame. return mVisibleFrame == null || !mVisibleFrame.isEmpty(); } - public boolean insetsRoundedCornerFrame() { - return mInsetsRoundedCornerFrame; - } - - public InsetsSource setInsetsRoundedCornerFrame(boolean insetsRoundedCornerFrame) { - mInsetsRoundedCornerFrame = insetsRoundedCornerFrame; - return this; - } - /** * Calculates the insets this source will cause to a client window. * @@ -317,6 +325,9 @@ public class InsetsSource implements Parcelable { if ((flags & FLAG_SUPPRESS_SCRIM) != 0) { joiner.add("SUPPRESS_SCRIM"); } + if ((flags & FLAG_INSETS_ROUNDED_CORNER) != 0) { + joiner.add("INSETS_ROUNDED_CORNER"); + } return joiner.toString(); } @@ -347,7 +358,6 @@ public class InsetsSource implements Parcelable { } pw.print(" visible="); pw.print(mVisible); pw.print(" flags="); pw.print(flagsToString(mFlags)); - pw.print(" insetsRoundedCornerFrame="); pw.print(mInsetsRoundedCornerFrame); pw.println(); } @@ -372,14 +382,12 @@ public class InsetsSource implements Parcelable { if (mFlags != that.mFlags) return false; if (excludeInvisibleImeFrames && !mVisible && mType == WindowInsets.Type.ime()) return true; if (!Objects.equals(mVisibleFrame, that.mVisibleFrame)) return false; - if (mInsetsRoundedCornerFrame != that.mInsetsRoundedCornerFrame) return false; return mFrame.equals(that.mFrame); } @Override public int hashCode() { - return Objects.hash(mId, mType, mFrame, mVisibleFrame, mVisible, mFlags, - mInsetsRoundedCornerFrame); + return Objects.hash(mId, mType, mFrame, mVisibleFrame, mVisible, mFlags); } public InsetsSource(Parcel in) { @@ -393,7 +401,6 @@ public class InsetsSource implements Parcelable { } mVisible = in.readBoolean(); mFlags = in.readInt(); - mInsetsRoundedCornerFrame = in.readBoolean(); } @Override @@ -414,7 +421,6 @@ public class InsetsSource implements Parcelable { } dest.writeBoolean(mVisible); dest.writeInt(mFlags); - dest.writeBoolean(mInsetsRoundedCornerFrame); } @Override @@ -424,7 +430,6 @@ public class InsetsSource implements Parcelable { + " mFrame=" + mFrame.toShortString() + " mVisible=" + mVisible + " mFlags=[" + flagsToString(mFlags) + "]" - + (mInsetsRoundedCornerFrame ? " insetsRoundedCornerFrame" : "") + "}"; } diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java index 5b974cdb2bca..61a72772200c 100644 --- a/core/java/android/view/InsetsState.java +++ b/core/java/android/view/InsetsState.java @@ -16,6 +16,7 @@ package android.view; +import static android.view.InsetsSource.FLAG_INSETS_ROUNDED_CORNER; import static android.view.InsetsStateProto.DISPLAY_CUTOUT; import static android.view.InsetsStateProto.DISPLAY_FRAME; import static android.view.InsetsStateProto.SOURCES; @@ -219,7 +220,7 @@ public class InsetsState implements Parcelable { final Rect roundedCornerFrame = new Rect(mRoundedCornerFrame); for (int i = mSources.size() - 1; i >= 0; i--) { final InsetsSource source = mSources.valueAt(i); - if (source.insetsRoundedCornerFrame()) { + if (source.hasFlags(FLAG_INSETS_ROUNDED_CORNER)) { final Insets insets = source.calculateInsets(roundedCornerFrame, false); roundedCornerFrame.inset(insets); } diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index e95ba797a985..0e72ea8622e2 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -4244,17 +4244,6 @@ public interface WindowManager extends ViewManager { public InsetsFrameProvider[] providedInsets; /** - * If specified, the frame that used to calculate relative {@link RoundedCorner} will be - * the window frame of this window minus the insets that this window provides. - * - * Task bar will draw fake rounded corners above itself, so we need this insets to calculate - * correct rounded corners for this window. - * - * @hide - */ - public boolean insetsRoundedCornerFrame = false; - - /** * {@link LayoutParams} to be applied to the window when layout with a assigned rotation. * This will make layout during rotation change smoothly. * @@ -4710,7 +4699,6 @@ public interface WindowManager extends ViewManager { out.writeBoolean(mFitInsetsIgnoringVisibility); out.writeBoolean(preferMinimalPostProcessing); out.writeInt(mBlurBehindRadius); - out.writeBoolean(insetsRoundedCornerFrame); out.writeBoolean(mWallpaperTouchEventsEnabled); out.writeTypedArray(providedInsets, 0 /* parcelableFlags */); checkNonRecursiveParams(); @@ -4782,7 +4770,6 @@ public interface WindowManager extends ViewManager { mFitInsetsIgnoringVisibility = in.readBoolean(); preferMinimalPostProcessing = in.readBoolean(); mBlurBehindRadius = in.readInt(); - insetsRoundedCornerFrame = in.readBoolean(); mWallpaperTouchEventsEnabled = in.readBoolean(); providedInsets = in.createTypedArray(InsetsFrameProvider.CREATOR); paramsForRotation = in.createTypedArray(LayoutParams.CREATOR); @@ -5090,11 +5077,6 @@ public interface WindowManager extends ViewManager { changes |= LAYOUT_CHANGED; } - if (insetsRoundedCornerFrame != o.insetsRoundedCornerFrame) { - insetsRoundedCornerFrame = o.insetsRoundedCornerFrame; - changes |= LAYOUT_CHANGED; - } - if (paramsForRotation != o.paramsForRotation) { if ((changes & LAYOUT_CHANGED) == 0) { if (paramsForRotation != null && o.paramsForRotation != null @@ -5332,10 +5314,6 @@ public interface WindowManager extends ViewManager { sb.append(prefix).append(" ").append(providedInsets[i]); } } - if (insetsRoundedCornerFrame) { - sb.append(" insetsRoundedCornerFrame="); - sb.append(insetsRoundedCornerFrame); - } if (paramsForRotation != null && paramsForRotation.length != 0) { sb.append(System.lineSeparator()); sb.append(prefix).append(" paramsForRotation:"); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java index 69f0bad4fb45..7f362f3e2ab7 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java @@ -222,7 +222,7 @@ public class DividerView extends FrameLayout implements View.OnTouchListener { for (int i = insetsState.sourceSize() - 1; i >= 0; i--) { final InsetsSource source = insetsState.sourceAt(i); if (source.getType() == WindowInsets.Type.navigationBars() - && source.insetsRoundedCornerFrame()) { + && source.hasFlags(InsetsSource.FLAG_INSETS_ROUNDED_CORNER)) { mTempRect.inset(source.calculateVisibleInsets(mTempRect)); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/animation/FullscreenUnfoldTaskAnimator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/animation/FullscreenUnfoldTaskAnimator.java index f81fc6fbea49..6bba0d1386fb 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/animation/FullscreenUnfoldTaskAnimator.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/animation/FullscreenUnfoldTaskAnimator.java @@ -110,7 +110,7 @@ public class FullscreenUnfoldTaskAnimator implements UnfoldTaskAnimator, for (int i = state.sourceSize() - 1; i >= 0; i--) { final InsetsSource source = state.sourceAt(i); if (source.getType() == WindowInsets.Type.navigationBars() - && source.insetsRoundedCornerFrame()) { + && source.hasFlags(InsetsSource.FLAG_INSETS_ROUNDED_CORNER)) { return source; } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/animation/SplitTaskUnfoldAnimator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/animation/SplitTaskUnfoldAnimator.java index a4cf149cc3b5..21994a997be5 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/animation/SplitTaskUnfoldAnimator.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/animation/SplitTaskUnfoldAnimator.java @@ -50,11 +50,11 @@ import com.android.wm.shell.sysui.ShellController; import com.android.wm.shell.unfold.UnfoldAnimationController; import com.android.wm.shell.unfold.UnfoldBackgroundController; +import dagger.Lazy; + import java.util.Optional; import java.util.concurrent.Executor; -import dagger.Lazy; - /** * This helper class contains logic that calculates scaling and cropping parameters * for the folding/unfolding animation. As an input it receives TaskInfo objects and @@ -149,7 +149,7 @@ public class SplitTaskUnfoldAnimator implements UnfoldTaskAnimator, for (int i = state.sourceSize() - 1; i >= 0; i--) { final InsetsSource source = state.sourceAt(i); if (source.getType() == WindowInsets.Type.navigationBars() - && source.insetsRoundedCornerFrame()) { + && source.hasFlags(InsetsSource.FLAG_INSETS_ROUNDED_CORNER)) { return source; } } diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index d0ca8e3ed3e7..df35402e7320 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -961,12 +961,6 @@ public class DisplayPolicy { if (!win.mSession.mCanSetUnrestrictedGestureExclusion) { attrs.privateFlags &= ~PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION; } - - final InsetsSourceProvider provider = win.getControllableInsetProvider(); - if (provider != null && provider.getSource().insetsRoundedCornerFrame() - != attrs.insetsRoundedCornerFrame) { - provider.getSource().setInsetsRoundedCornerFrame(attrs.insetsRoundedCornerFrame); - } } /** @@ -1104,9 +1098,11 @@ public class DisplayPolicy { } else { overrideProviders = null; } - mDisplayContent.getInsetsStateController().getOrCreateSourceProvider( - provider.getId(), provider.getType()).setWindowContainer( - win, frameProvider, overrideProviders); + final InsetsSourceProvider sourceProvider = mDisplayContent + .getInsetsStateController().getOrCreateSourceProvider(provider.getId(), + provider.getType()); + sourceProvider.getSource().setFlags(provider.getFlags()); + sourceProvider.setWindowContainer(win, frameProvider, overrideProviders); mInsetsSourceWindowsExceptIme.add(win); } } diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index b7eaf259ea7a..7f845e6c1ead 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -175,7 +175,7 @@ class InsetsSourceProvider { if (windowContainer == null) { setServerVisible(false); mSource.setVisibleFrame(null); - mSource.setInsetsRoundedCornerFrame(false); + mSource.setFlags(0, 0xffffffff); mSourceFrame.setEmpty(); } else { mWindowContainer.getInsetsSourceProviders().put(mSource.getId(), this); diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java index d83c8612b9e9..c2439888db43 100644 --- a/services/core/java/com/android/server/wm/LetterboxUiController.java +++ b/services/core/java/com/android/server/wm/LetterboxUiController.java @@ -1428,7 +1428,8 @@ final class LetterboxUiController { for (int i = state.sourceSize() - 1; i >= 0; i--) { final InsetsSource source = state.sourceAt(i); if (source.getType() == WindowInsets.Type.navigationBars() - && source.insetsRoundedCornerFrame() && source.isVisible()) { + && source.hasFlags(InsetsSource.FLAG_INSETS_ROUNDED_CORNER) + && source.isVisible()) { return source; } } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index bb6f8056acda..9ce788686e85 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -49,6 +49,7 @@ import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import static android.provider.Settings.Secure.USER_SETUP_COMPLETE; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; +import static android.view.InsetsSource.FLAG_INSETS_ROUNDED_CORNER; import static android.view.SurfaceControl.METADATA_TASK_ID; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; @@ -2858,7 +2859,7 @@ class Task extends TaskFragment { getDisplayContent().getInsetsStateController().getRawInsetsState(); for (int i = state.sourceSize() - 1; i >= 0; i--) { final InsetsSource source = state.sourceAt(i); - if (source.insetsRoundedCornerFrame()) { + if (source.hasFlags(FLAG_INSETS_ROUNDED_CORNER)) { animationBounds.inset(source.calculateVisibleInsets(animationBounds)); } } diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 0152666a830d..4bc4c266c114 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -4141,7 +4141,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< getDisplayContent().getInsetsStateController().getSourceProviders(); for (int i = providers.size(); i >= 0; i--) { final InsetsSourceProvider insetProvider = providers.valueAt(i); - if (!insetProvider.getSource().insetsRoundedCornerFrame()) { + if (!insetProvider.getSource().hasFlags(InsetsSource.FLAG_INSETS_ROUNDED_CORNER)) { return; } diff --git a/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java index 7d507e9150e8..34a13bfa855c 100644 --- a/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java @@ -38,6 +38,7 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCA import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; +import static android.view.InsetsSource.FLAG_INSETS_ROUNDED_CORNER; import static android.view.WindowManager.PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION; import static android.view.WindowManager.PROPERTY_CAMERA_COMPAT_ALLOW_REFRESH; import static android.view.WindowManager.PROPERTY_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE; @@ -461,7 +462,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testGetCropBoundsIfNeeded_handleCropForTransparentActivityBasedOnOpaqueBounds() { final InsetsSource taskbar = new InsetsSource(/*id=*/ 0, WindowInsets.Type.navigationBars()); - taskbar.setInsetsRoundedCornerFrame(true); + taskbar.setFlags(FLAG_INSETS_ROUNDED_CORNER, FLAG_INSETS_ROUNDED_CORNER); final WindowState mainWindow = mockForGetCropBoundsAndRoundedCorners(taskbar); final Rect opaqueBounds = new Rect(0, 0, 500, 300); doReturn(opaqueBounds).when(mActivity).getBounds(); @@ -505,7 +506,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testGetCropBoundsIfNeeded_appliesCrop() { final InsetsSource taskbar = new InsetsSource(/*id=*/ 0, WindowInsets.Type.navigationBars()); - taskbar.setInsetsRoundedCornerFrame(true); + taskbar.setFlags(FLAG_INSETS_ROUNDED_CORNER, FLAG_INSETS_ROUNDED_CORNER); final WindowState mainWindow = mockForGetCropBoundsAndRoundedCorners(taskbar); // Apply crop if taskbar is expanded @@ -528,7 +529,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testGetCropBoundsIfNeeded_appliesCropWithSizeCompatScaling() { final InsetsSource taskbar = new InsetsSource(/*id=*/ 0, WindowInsets.Type.navigationBars()); - taskbar.setInsetsRoundedCornerFrame(true); + taskbar.setFlags(FLAG_INSETS_ROUNDED_CORNER, FLAG_INSETS_ROUNDED_CORNER); final WindowState mainWindow = mockForGetCropBoundsAndRoundedCorners(taskbar); final float scaling = 2.0f; diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index 2dd34eb5ac4d..d91be16f2538 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -30,6 +30,7 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.provider.DeviceConfig.NAMESPACE_CONSTRAIN_DISPLAY_APIS; +import static android.view.InsetsSource.FLAG_INSETS_ROUNDED_CORNER; import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; @@ -3483,7 +3484,7 @@ public class SizeCompatTests extends WindowTestsBase { final InsetsSource navSource = new InsetsSource( InsetsSource.createId(null, 0, navigationBars()), navigationBars()); - navSource.setInsetsRoundedCornerFrame(true); + navSource.setFlags(FLAG_INSETS_ROUNDED_CORNER, FLAG_INSETS_ROUNDED_CORNER); navSource.setFrame(new Rect(0, screenHeight - taskbarHeight, screenWidth, screenHeight)); mActivity.mWmService.mLetterboxConfiguration.setLetterboxActivityCornersRadius(15); @@ -3531,7 +3532,7 @@ public class SizeCompatTests extends WindowTestsBase { final InsetsSource navSource = new InsetsSource( InsetsSource.createId(null, 0, navigationBars()), navigationBars()); - navSource.setInsetsRoundedCornerFrame(true); + navSource.setFlags(FLAG_INSETS_ROUNDED_CORNER, FLAG_INSETS_ROUNDED_CORNER); // Immersive activity has transient navbar navSource.setVisible(!immersive); navSource.setFrame(new Rect(0, screenHeight - taskbarHeight, screenWidth, screenHeight)); |