diff options
| author | 2022-11-16 20:11:58 +0800 | |
|---|---|---|
| committer | 2022-12-19 16:48:21 +0800 | |
| commit | 71713dd50e0691df66e180b334b4b6d23d12abf5 (patch) | |
| tree | c2ab91009a5c0f5a9770a4659c592ca23dfff2b7 | |
| parent | 39f6ecbec60cc61920c0b6327272d265afc2fa91 (diff) | |
Split InternalInsetsType into InsetsType and the ID of InsetsSource
The is a step to remove InternalInsetsType which is used to categorize
insets sources and is also used to identify the corresponding objects
like InsetsSourceControl, InsetsSourceConsumer, ..., etc.
This CL migrates the usage of categorizing to the public types, and uses
the internal type as the identifier for now. Eventually, the ID will be
specified by the source producer, and we won't need the pre-defined ID
then.
Bug: 234093736
Test: atest InsetsSourceConsumerTest InsetsSourceTest
DisplayImeControllerTest CompatUIControllerTest
CompatUIWindowManagerTest ActivityRecordTests DisplayPolicyTests
ImeInsetsSourceProviderTest SizeCompatTests
WindowContainerInsetsSourceProviderTest WindowContainerTests
WindowOrganizerTests WindowStateTests
Change-Id: Id574f98af18ab95b11fed13a09e08bc6a7929957
25 files changed, 148 insertions, 186 deletions
diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java index e775969238a0..81a696a3ad72 100644 --- a/core/java/android/view/InsetsAnimationControlImpl.java +++ b/core/java/android/view/InsetsAnimationControlImpl.java @@ -455,8 +455,8 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro : inset != 0; if (outState != null) { - outState.getSource(source.getType()).setVisible(visible); - outState.getSource(source.getType()).setFrame(mTmpFrame); + outState.getSource(source.getId()).setVisible(visible); + outState.getSource(source.getId()).setFrame(mTmpFrame); } // If the system is controlling the insets source, the leash can be null. diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index fbd82266246b..31e82a3e3dea 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -835,7 +835,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation && !fromSource.getFrame().equals(toSource.getFrame()) && (Rect.intersects(mFrame, fromSource.getFrame()) || Rect.intersects(mFrame, toSource.getFrame()))) { - types |= InsetsState.toPublicType(toSource.getType()); + types |= toSource.getType(); if (toState == null) { toState = new InsetsState(); } diff --git a/core/java/android/view/InsetsResizeAnimationRunner.java b/core/java/android/view/InsetsResizeAnimationRunner.java index 778c677c58bd..cf64eedf6e14 100644 --- a/core/java/android/view/InsetsResizeAnimationRunner.java +++ b/core/java/android/view/InsetsResizeAnimationRunner.java @@ -155,7 +155,7 @@ public class InsetsResizeAnimationRunner implements InsetsAnimationControlRunner (int) (fromFrame.top + fraction * (toFrame.top - fromFrame.top)), (int) (fromFrame.right + fraction * (toFrame.right - fromFrame.right)), (int) (fromFrame.bottom + fraction * (toFrame.bottom - fromFrame.bottom))); - final InsetsSource source = new InsetsSource(type); + final InsetsSource source = new InsetsSource(type, fromSource.getType()); source.setFrame(frame); source.setVisible(toSource.isVisible()); outState.addSource(source); diff --git a/core/java/android/view/InsetsSource.java b/core/java/android/view/InsetsSource.java index c8c941a220f0..f6b063d6cdc2 100644 --- a/core/java/android/view/InsetsSource.java +++ b/core/java/android/view/InsetsSource.java @@ -20,8 +20,6 @@ import static android.view.InsetsSourceProto.FRAME; import static android.view.InsetsSourceProto.TYPE; import static android.view.InsetsSourceProto.VISIBLE; import static android.view.InsetsSourceProto.VISIBLE_FRAME; -import static android.view.InsetsState.ITYPE_CAPTION_BAR; -import static android.view.InsetsState.ITYPE_IME; import static android.view.ViewRootImpl.CAPTION_ON_SHELL; import android.annotation.NonNull; @@ -31,34 +29,42 @@ import android.graphics.Rect; import android.os.Parcel; import android.os.Parcelable; import android.util.proto.ProtoOutputStream; -import android.view.InsetsState.InternalInsetsType; +import android.view.WindowInsets.Type.InsetsType; import java.io.PrintWriter; import java.util.Objects; /** - * Represents the state of a single window generating insets for clients. + * Represents the state of a single entity generating insets for clients. * @hide */ public class InsetsSource implements Parcelable { - private final @InternalInsetsType int mType; + /** + * An unique integer to identify this source across processes. + */ + private final int mId; + + private final @InsetsType int mType; /** Frame of the source in screen coordinate space */ private final Rect mFrame; private @Nullable Rect mVisibleFrame; + private boolean mVisible; private boolean mInsetsRoundedCornerFrame; private final Rect mTmpFrame = new Rect(); - public InsetsSource(@InternalInsetsType int type) { + public InsetsSource(int id, @InsetsType int type) { + mId = id; mType = type; mFrame = new Rect(); - mVisible = InsetsState.getDefaultVisibility(type); + mVisible = (WindowInsets.Type.defaultVisible() & type) != 0; } public InsetsSource(InsetsSource other) { + mId = other.mId; mType = other.mType; mFrame = new Rect(other.mFrame); mVisible = other.mVisible; @@ -86,14 +92,18 @@ public class InsetsSource implements Parcelable { } public void setVisibleFrame(@Nullable Rect visibleFrame) { - mVisibleFrame = visibleFrame != null ? new Rect(visibleFrame) : visibleFrame; + mVisibleFrame = visibleFrame != null ? new Rect(visibleFrame) : null; } public void setVisible(boolean visible) { mVisible = visible; } - public @InternalInsetsType int getType() { + public int getId() { + return mId; + } + + public @InsetsType int getType() { return mType; } @@ -149,7 +159,7 @@ public class InsetsSource implements Parcelable { // During drag-move and drag-resizing, the caption insets position may not get updated // before the app frame get updated. To layout the app content correctly during drag events, // we always return the insets with the corresponding height covering the top. - if (!CAPTION_ON_SHELL && getType() == ITYPE_CAPTION_BAR) { + if (!CAPTION_ON_SHELL && getType() == WindowInsets.Type.captionBar()) { return Insets.of(0, frame.height(), 0, 0); } // Checks for whether there is shared edge with insets for 0-width/height window. @@ -162,7 +172,7 @@ public class InsetsSource implements Parcelable { // TODO: Currently, non-floating IME always intersects at bottom due to issues with cutout. // However, we should let the policy decide from the server. - if (getType() == ITYPE_IME) { + if (getType() == WindowInsets.Type.ime()) { return Insets.of(0, 0, 0, mTmpFrame.height()); } @@ -220,7 +230,7 @@ public class InsetsSource implements Parcelable { */ public void dumpDebug(ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); - proto.write(TYPE, InsetsState.typeToString(mType)); + proto.write(TYPE, WindowInsets.Type.toString(mType)); mFrame.dumpDebug(proto, FRAME); if (mVisibleFrame != null) { mVisibleFrame.dumpDebug(proto, VISIBLE_FRAME); @@ -231,7 +241,8 @@ public class InsetsSource implements Parcelable { public void dump(String prefix, PrintWriter pw) { pw.print(prefix); - pw.print("InsetsSource type="); pw.print(InsetsState.typeToString(mType)); + pw.print("InsetsSource id="); pw.print(mId); + pw.print(" type="); pw.print(WindowInsets.Type.toString(mType)); pw.print(" frame="); pw.print(mFrame.toShortString()); if (mVisibleFrame != null) { pw.print(" visibleFrame="); pw.print(mVisibleFrame.toShortString()); @@ -256,9 +267,10 @@ public class InsetsSource implements Parcelable { InsetsSource that = (InsetsSource) o; + if (mId != that.mId) return false; if (mType != that.mType) return false; if (mVisible != that.mVisible) return false; - if (excludeInvisibleImeFrames && !mVisible && mType == ITYPE_IME) return true; + 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); @@ -266,15 +278,11 @@ public class InsetsSource implements Parcelable { @Override public int hashCode() { - int result = mType; - result = 31 * result + mFrame.hashCode(); - result = 31 * result + (mVisibleFrame != null ? mVisibleFrame.hashCode() : 0); - result = 31 * result + (mVisible ? 1 : 0); - result = 31 * result + (mInsetsRoundedCornerFrame ? 1 : 0); - return result; + return Objects.hash(mId, mType, mFrame, mVisibleFrame, mVisible, mInsetsRoundedCornerFrame); } public InsetsSource(Parcel in) { + mId = in.readInt(); mType = in.readInt(); mFrame = Rect.CREATOR.createFromParcel(in); if (in.readInt() != 0) { @@ -293,6 +301,7 @@ public class InsetsSource implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(mId); dest.writeInt(mType); mFrame.writeToParcel(dest, 0); if (mVisibleFrame != null) { @@ -308,14 +317,15 @@ public class InsetsSource implements Parcelable { @Override public String toString() { return "InsetsSource: {" - + "mType=" + InsetsState.typeToString(mType) - + ", mFrame=" + mFrame.toShortString() - + ", mVisible=" + mVisible - + ", mInsetsRoundedCornerFrame=" + mInsetsRoundedCornerFrame + + "mId=" + mId + + " mType=" + WindowInsets.Type.toString(mType) + + " mFrame=" + mFrame.toShortString() + + " mVisible=" + mVisible + + (mInsetsRoundedCornerFrame ? " insetsRoundedCornerFrame" : "") + "}"; } - public static final @android.annotation.NonNull Creator<InsetsSource> CREATOR = new Creator<InsetsSource>() { + public static final @NonNull Creator<InsetsSource> CREATOR = new Creator<>() { public InsetsSource createFromParcel(Parcel in) { return new InsetsSource(in); diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java index c56d61808665..054d17722277 100644 --- a/core/java/android/view/InsetsState.java +++ b/core/java/android/view/InsetsState.java @@ -245,7 +245,7 @@ public class InsetsState implements Parcelable { // IME won't be reported in max insets as the size depends on the EditorInfo of the IME // target. - if (source.getType() != ITYPE_IME) { + if (source.getType() != WindowInsets.Type.ime()) { InsetsSource ignoringVisibilitySource = ignoringVisibilityState != null ? ignoringVisibilityState.getSource(type) : source; @@ -442,7 +442,7 @@ public class InsetsState implements Parcelable { @Nullable boolean[] typeVisibilityMap) { Insets insets = source.calculateInsets(relativeFrame, ignoreVisibility); - int type = toPublicType(source.getType()); + final int type = source.getType(); processSourceAsPublicType(source, typeInsetsMap, typeSideMap, typeVisibilityMap, insets, type); @@ -486,7 +486,7 @@ public class InsetsState implements Parcelable { if (typeSideMap != null) { @InternalInsetsSide int insetSide = getInsetSide(insets); if (insetSide != ISIDE_UNKNOWN) { - typeSideMap.put(source.getType(), insetSide); + typeSideMap.put(source.getId(), insetSide); } } } @@ -519,7 +519,7 @@ public class InsetsState implements Parcelable { if (source != null) { return source; } - source = new InsetsSource(type); + source = new InsetsSource(type, toPublicType(type)); mSources[type] = source; return source; } @@ -708,7 +708,7 @@ public class InsetsState implements Parcelable { } public void addSource(InsetsSource source) { - mSources[source.getType()] = source; + mSources[source.getId()] = source; } public static boolean clearsCompatInsets(int windowType, int windowFlags, int windowingMode) { diff --git a/core/tests/benchmarks/src/android/os/ParcelableBenchmark.java b/core/tests/benchmarks/src/android/os/ParcelableBenchmark.java index 372bca4664a2..b1991c25bbbb 100644 --- a/core/tests/benchmarks/src/android/os/ParcelableBenchmark.java +++ b/core/tests/benchmarks/src/android/os/ParcelableBenchmark.java @@ -61,7 +61,7 @@ public class ParcelableBenchmark { public void timeReadWriteInsetsState(int reps) { final InsetsState insetsState = new InsetsState(); for (int i = 0; i < InsetsState.SIZE; i++) { - insetsState.addSource(new InsetsSource(i)); + insetsState.addSource(new InsetsSource(i, InsetsState.toPublicType(i))); } for (int i = 0; i < reps; i++) { insetsState.writeToParcel(mParcel, 0); diff --git a/core/tests/coretests/src/android/view/InsetsSourceConsumerTest.java b/core/tests/coretests/src/android/view/InsetsSourceConsumerTest.java index 125327852984..672252f6c750 100644 --- a/core/tests/coretests/src/android/view/InsetsSourceConsumerTest.java +++ b/core/tests/coretests/src/android/view/InsetsSourceConsumerTest.java @@ -97,7 +97,7 @@ public class InsetsSourceConsumerTest { // activity isn't running, lets ignore BadTokenException. } mState = new InsetsState(); - mSpyInsetsSource = Mockito.spy(new InsetsSource(ITYPE_STATUS_BAR)); + mSpyInsetsSource = Mockito.spy(new InsetsSource(ITYPE_STATUS_BAR, statusBars())); mState.addSource(mSpyInsetsSource); mController = new InsetsController(new ViewRootInsetsControllerHost(mViewRoot)); @@ -146,7 +146,7 @@ public class InsetsSourceConsumerTest { InsetsSourceConsumer consumer = new InsetsSourceConsumer( ITYPE_IME, state, null, controller); - InsetsSource source = new InsetsSource(ITYPE_IME); + InsetsSource source = new InsetsSource(ITYPE_IME, ime()); source.setFrame(0, 1, 2, 3); consumer.updateSource(new InsetsSource(source), ANIMATION_TYPE_NONE); diff --git a/core/tests/coretests/src/android/view/InsetsSourceTest.java b/core/tests/coretests/src/android/view/InsetsSourceTest.java index 2106b4bc5be9..e01440cfb45a 100644 --- a/core/tests/coretests/src/android/view/InsetsSourceTest.java +++ b/core/tests/coretests/src/android/view/InsetsSourceTest.java @@ -16,9 +16,9 @@ package android.view; -import static android.view.InsetsState.ITYPE_CAPTION_BAR; -import static android.view.InsetsState.ITYPE_IME; -import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; +import static android.view.WindowInsets.Type.captionBar; +import static android.view.WindowInsets.Type.ime; +import static android.view.WindowInsets.Type.navigationBars; import static org.junit.Assert.assertEquals; @@ -45,9 +45,9 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class InsetsSourceTest { - private InsetsSource mSource = new InsetsSource(ITYPE_NAVIGATION_BAR); - private InsetsSource mImeSource = new InsetsSource(ITYPE_IME); - private InsetsSource mCaptionSource = new InsetsSource(ITYPE_CAPTION_BAR); + private final InsetsSource mSource = new InsetsSource(0 /* id */, navigationBars()); + private final InsetsSource mImeSource = new InsetsSource(1 /* id */, ime()); + private final InsetsSource mCaptionSource = new InsetsSource(2 /* id */, captionBar()); @Before public void setUp() { diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayImeControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayImeControllerTest.java index 40f2e88f34fd..a92fbd2c847a 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayImeControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayImeControllerTest.java @@ -133,7 +133,7 @@ public class DisplayImeControllerTest extends ShellTestCase { private InsetsState insetsStateWithIme(boolean visible) { InsetsState state = new InsetsState(); - state.addSource(new InsetsSource(ITYPE_IME)); + state.addSource(new InsetsSource(ITYPE_IME, ime())); state.setSourceVisible(ITYPE_IME, visible); return state; } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java index 2fc0914acbd4..d4408d78eba1 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java @@ -19,6 +19,7 @@ package com.android.wm.shell.compatui; import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN; import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED; import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR; +import static android.view.WindowInsets.Type.navigationBars; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; @@ -291,7 +292,7 @@ public class CompatUIControllerTest extends ShellTestCase { mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); InsetsState insetsState = new InsetsState(); - InsetsSource insetsSource = new InsetsSource(ITYPE_EXTRA_NAVIGATION_BAR); + InsetsSource insetsSource = new InsetsSource(ITYPE_EXTRA_NAVIGATION_BAR, navigationBars()); insetsSource.setFrame(0, 0, 1000, 1000); insetsState.addSource(insetsSource); diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java index e79b803b4304..c4d78bbb2004 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java @@ -21,6 +21,7 @@ import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_HIDDEN; import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED; import static android.app.TaskInfo.CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED; import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR; +import static android.view.WindowInsets.Type.navigationBars; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; @@ -328,7 +329,7 @@ public class CompatUIWindowManagerTest extends ShellTestCase { // Update if the insets change on the existing display layout clearInvocations(mWindowManager); InsetsState insetsState = new InsetsState(); - InsetsSource insetsSource = new InsetsSource(ITYPE_EXTRA_NAVIGATION_BAR); + InsetsSource insetsSource = new InsetsSource(ITYPE_EXTRA_NAVIGATION_BAR, navigationBars()); insetsSource.setFrame(0, 0, 1000, 1000); insetsState.addSource(insetsSource); displayLayout.setInsets(mContext.getResources(), insetsState); diff --git a/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java b/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java index 7fd093fffe95..90d0f16e6478 100644 --- a/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java @@ -35,7 +35,6 @@ import android.util.proto.ProtoOutputStream; import android.view.InsetsSource; import android.view.InsetsSourceConsumer; import android.view.InsetsSourceControl; -import android.view.InsetsState; import android.view.WindowInsets; import android.view.inputmethod.ImeTracker; import android.window.TaskSnapshot; @@ -58,7 +57,7 @@ final class ImeInsetsSourceProvider extends WindowContainerInsetsSourceProvider private Runnable mShowImeRunner; private boolean mIsImeLayoutDrawn; private boolean mImeShowing; - private final InsetsSource mLastSource = new InsetsSource(ITYPE_IME); + private final InsetsSource mLastSource = new InsetsSource(ITYPE_IME, WindowInsets.Type.ime()); /** @see #setFrozen(boolean) */ private boolean mFrozen; @@ -142,7 +141,7 @@ final class ImeInsetsSourceProvider extends WindowContainerInsetsSourceProvider @Override protected boolean updateClientVisibility(InsetsControlTarget caller) { boolean changed = super.updateClientVisibility(caller); - if (changed && caller.isRequestedVisible(InsetsState.toPublicType(mSource.getType()))) { + if (changed && caller.isRequestedVisible(mSource.getType())) { reportImeDrawnForOrganizer(caller); } return changed; diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java index 67cab10463e5..059c81e4d755 100644 --- a/services/core/java/com/android/server/wm/InsetsPolicy.java +++ b/services/core/java/com/android/server/wm/InsetsPolicy.java @@ -26,11 +26,7 @@ import static android.view.InsetsController.ANIMATION_TYPE_HIDE; import static android.view.InsetsController.ANIMATION_TYPE_SHOW; import static android.view.InsetsController.LAYOUT_INSETS_DURING_ANIMATION_HIDDEN; import static android.view.InsetsController.LAYOUT_INSETS_DURING_ANIMATION_SHOWN; -import static android.view.InsetsState.ITYPE_CAPTION_BAR; -import static android.view.InsetsState.ITYPE_CLIMATE_BAR; -import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_IME; -import static android.view.InsetsState.ITYPE_INVALID; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.SyncRtSurfaceTransactionApplier.applyParams; @@ -38,8 +34,6 @@ import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_B import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; -import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; -import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; import android.annotation.NonNull; import android.annotation.Nullable; @@ -66,6 +60,7 @@ import android.view.SurfaceControl; import android.view.SyncRtSurfaceTransactionApplier; import android.view.WindowInsets; import android.view.WindowInsets.Type; +import android.view.WindowInsets.Type.InsetsType; import android.view.WindowInsetsAnimation; import android.view.WindowInsetsAnimation.Bounds; import android.view.WindowInsetsAnimationControlListener; @@ -81,6 +76,10 @@ import com.android.server.statusbar.StatusBarManagerInternal; */ class InsetsPolicy { + public static final int CONTROLLABLE_TYPES = WindowInsets.Type.statusBars() + | WindowInsets.Type.navigationBars() + | WindowInsets.Type.ime(); + private final InsetsStateController mStateController; private final DisplayContent mDisplayContent; private final DisplayPolicy mPolicy; @@ -278,7 +277,6 @@ class InsetsPolicy { * @see WindowState#getInsetsState() */ InsetsState getInsetsForWindowMetrics(@NonNull WindowManager.LayoutParams attrs) { - final @InternalInsetsType int type = getInsetsTypeForLayoutParams(attrs); final WindowToken token = mDisplayContent.getWindowToken(attrs.token); if (token != null) { final InsetsState rotatedState = token.getFixedRotationTransformInsetsState(); @@ -289,109 +287,62 @@ class InsetsPolicy { final boolean alwaysOnTop = token != null && token.isAlwaysOnTop(); // Always use windowing mode fullscreen when get insets for window metrics to make sure it // contains all insets types. - final InsetsState originalState = mDisplayContent.getInsetsPolicy() - .enforceInsetsPolicyForTarget(type, WINDOWING_MODE_FULLSCREEN, alwaysOnTop, - attrs.type, mStateController.getRawInsetsState()); + final InsetsState originalState = enforceInsetsPolicyForTarget(attrs, + WINDOWING_MODE_FULLSCREEN, alwaysOnTop, mStateController.getRawInsetsState()); InsetsState state = adjustVisibilityForTransientTypes(originalState); return adjustInsetsForRoundedCorners(token, state, state == originalState); } /** - * @param type the internal type of the insets. - * @return {@code true} if the given type is controllable, {@code false} otherwise. - */ - static boolean isInsetsTypeControllable(@InternalInsetsType int type) { - switch (type) { - case ITYPE_STATUS_BAR: - case ITYPE_NAVIGATION_BAR: - case ITYPE_IME: - case ITYPE_CLIMATE_BAR: - case ITYPE_EXTRA_NAVIGATION_BAR: - return true; - default: - return false; - } - } - - private static @InternalInsetsType int getInsetsTypeForLayoutParams( - WindowManager.LayoutParams attrs) { - @WindowManager.LayoutParams.WindowType int type = attrs.type; - switch (type) { - case TYPE_STATUS_BAR: - return ITYPE_STATUS_BAR; - case TYPE_NAVIGATION_BAR: - return ITYPE_NAVIGATION_BAR; - case TYPE_INPUT_METHOD: - return ITYPE_IME; - } - - // If not one of the types above, check whether an internal inset mapping is specified. - if (attrs.providedInsets != null) { - for (InsetsFrameProvider provider : attrs.providedInsets) { - switch (provider.type) { - case ITYPE_STATUS_BAR: - case ITYPE_NAVIGATION_BAR: - case ITYPE_CLIMATE_BAR: - case ITYPE_EXTRA_NAVIGATION_BAR: - return provider.type; - } - } - } - - return ITYPE_INVALID; - } - - - /** - * Modifies the given {@code state} according to the {@code type} (Inset type) provided by - * the target. - * When performing layout of the target or dispatching insets to the target, we need to exclude - * sources which should not be visible to the target. e.g., the source which represents the - * target window itself, and the IME source when the target is above IME. We also need to - * exclude certain types of insets source for client within specific windowing modes. + * Modifies the given {@code state} according to insets provided by the target. When performing + * layout of the target or dispatching insets to the target, we need to exclude sources which + * should not be received by the target. e.g., the visible (non-gesture-wise) source provided by + * the target window itself. + * + * We also need to exclude certain types of insets source for client within specific windowing + * modes. * - * @param type the inset type provided by the target + * @param attrs the LayoutParams of the target * @param windowingMode the windowing mode of the target * @param isAlwaysOnTop is the target always on top - * @param windowType the type of the target * @param state the input inset state containing all the sources * @return The state stripped of the necessary information. */ - InsetsState enforceInsetsPolicyForTarget(@InternalInsetsType int type, + InsetsState enforceInsetsPolicyForTarget(WindowManager.LayoutParams attrs, @WindowConfiguration.WindowingMode int windowingMode, boolean isAlwaysOnTop, - int windowType, InsetsState state) { - boolean stateCopied = false; + InsetsState state) { + final InsetsState originalState = state; - if (type != ITYPE_INVALID) { + // The caller should not receive the visible insets provided by itself. + if (attrs.type == TYPE_INPUT_METHOD) { state = new InsetsState(state); - stateCopied = true; - state.removeSource(type); - - // Navigation bar doesn't get influenced by anything else - if (type == ITYPE_NAVIGATION_BAR || type == ITYPE_EXTRA_NAVIGATION_BAR) { - state.removeSource(ITYPE_STATUS_BAR); - state.removeSource(ITYPE_CLIMATE_BAR); - state.removeSource(ITYPE_CAPTION_BAR); - state.removeSource(ITYPE_NAVIGATION_BAR); - state.removeSource(ITYPE_EXTRA_NAVIGATION_BAR); - } - - // Status bar doesn't get influenced by caption bar - if (type == ITYPE_STATUS_BAR || type == ITYPE_CLIMATE_BAR) { - state.removeSource(ITYPE_CAPTION_BAR); + state.removeSource(ITYPE_IME); + } else if (attrs.providedInsets != null) { + for (InsetsFrameProvider provider : attrs.providedInsets) { + // TODO(b/234093736): Let InsetsFrameProvider return the public type and the ID. + final int sourceId = provider.type; + final @InsetsType int type = InsetsState.toPublicType(sourceId); + if ((type & WindowInsets.Type.systemBars()) == 0) { + continue; + } + if (state == originalState) { + state = new InsetsState(state); + } + state.removeSource(sourceId); } } - ArrayMap<Integer, WindowContainerInsetsSourceProvider> providers = mStateController + + final ArrayMap<Integer, WindowContainerInsetsSourceProvider> providers = mStateController .getSourceProviders(); + final int windowType = attrs.type; for (int i = providers.size() - 1; i >= 0; i--) { - WindowContainerInsetsSourceProvider otherProvider = providers.valueAt(i); + final WindowContainerInsetsSourceProvider otherProvider = providers.valueAt(i); if (otherProvider.overridesFrame(windowType)) { - if (!stateCopied) { + if (state == originalState) { state = new InsetsState(state); - stateCopied = true; } - InsetsSource override = - new InsetsSource(state.getSource(otherProvider.getSource().getType())); + final InsetsSource override = + new InsetsSource(state.getSource(otherProvider.getSource().getId())); override.setFrame(otherProvider.getOverriddenFrame(windowType)); state.addSource(override); } @@ -404,10 +355,9 @@ class InsetsPolicy { if (windowingMode != WINDOWING_MODE_PINNED) { types |= WindowInsets.Type.ime(); } - InsetsState newState = new InsetsState(); + final InsetsState newState = new InsetsState(); newState.set(state, types); state = newState; - stateCopied = true; } return state; @@ -628,7 +578,7 @@ class InsetsPolicy { return focusedWin; } - private boolean isShowingTransientTypes(@Type.InsetsType int types) { + private boolean isShowingTransientTypes(@InsetsType int types) { final IntArray showingTransientTypes = mShowingTransientTypes; for (int i = showingTransientTypes.size() - 1; i >= 0; i--) { if ((InsetsState.toPublicType(showingTransientTypes.get(i)) & types) != 0) { @@ -733,7 +683,7 @@ class InsetsPolicy { } private void updateVisibility(@Nullable InsetsControlTarget controlTarget, - @Type.InsetsType int type) { + @InsetsType int type) { setVisible(controlTarget == null || controlTarget.isRequestedVisible(type)); } diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index 5b205f0bf59d..b1ac8e2df463 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -45,7 +45,6 @@ import android.util.proto.ProtoOutputStream; import android.view.InsetsFrameProvider; import android.view.InsetsSource; import android.view.InsetsSourceControl; -import android.view.InsetsState; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; import android.view.WindowInsets; @@ -121,14 +120,14 @@ abstract class InsetsSourceProvider { InsetsSourceProvider(InsetsSource source, InsetsStateController stateController, DisplayContent displayContent) { - mClientVisible = InsetsState.getDefaultVisibility(source.getType()); + mClientVisible = (WindowInsets.Type.defaultVisible() & source.getType()) != 0; mSource = source; mDisplayContent = displayContent; mStateController = stateController; mFakeControl = new InsetsSourceControl( - source.getType(), null /* leash */, false /* initialVisible */, new Point(), + source.getId(), null /* leash */, false /* initialVisible */, new Point(), Insets.NONE); - mControllable = InsetsPolicy.isInsetsTypeControllable(source.getType()); + mControllable = (InsetsPolicy.CONTROLLABLE_TYPES & source.getType()) != 0; } InsetsSource getSource() { @@ -166,11 +165,11 @@ abstract class InsetsSourceProvider { // TODO: Ideally, we should wait for the animation to finish so previous window can // animate-out as new one animates-in. mWindowContainer.cancelAnimation(); - mWindowContainer.getProvidedInsetsSources().remove(mSource.getType()); + mWindowContainer.getProvidedInsetsSources().remove(mSource.getId()); mSeamlessRotating = false; } ProtoLog.d(WM_DEBUG_WINDOW_INSETS, "InsetsSource setWin %s for type %s", - windowContainer, InsetsState.typeToString(mSource.getType())); + windowContainer, WindowInsets.Type.toString(mSource.getType())); mWindowContainer = windowContainer; // TODO: remove the frame provider for non-WindowState container. mFrameProvider = frameProvider; @@ -182,7 +181,7 @@ abstract class InsetsSourceProvider { mSource.setInsetsRoundedCornerFrame(false); mSourceFrame.setEmpty(); } else { - mWindowContainer.getProvidedInsetsSources().put(mSource.getType(), mSource); + mWindowContainer.getProvidedInsetsSources().put(mSource.getId(), mSource); if (mControllable) { mWindowContainer.setControllableInsetProvider(this); if (mPendingControlTarget != null) { @@ -284,7 +283,7 @@ abstract class InsetsSourceProvider { InsetsSource createSimulatedSource(DisplayFrames displayFrames, Rect frame) { // Don't copy visible frame because it might not be calculated in the provided display // frames and it is not significant for this usage. - final InsetsSource source = new InsetsSource(mSource.getType()); + final InsetsSource source = new InsetsSource(mSource.getId(), mSource.getType()); source.setVisible(mSource.isVisible()); mTmpRect.set(frame); if (mFrameProvider != null) { @@ -454,13 +453,12 @@ abstract class InsetsSourceProvider { if (target == null) { // Cancelling the animation will invoke onAnimationCancelled, resetting all the fields. mWindowContainer.cancelAnimation(); - setClientVisible(InsetsState.getDefaultVisibility(mSource.getType())); + setClientVisible((WindowInsets.Type.defaultVisible() & mSource.getType()) != 0); return; } final Point surfacePosition = getWindowFrameSurfacePosition(); mAdapter = new ControlAdapter(surfacePosition); - final int type = getSource().getType(); - if (type == ITYPE_IME) { + if (mSource.getType() == WindowInsets.Type.ime()) { setClientVisible(target.isRequestedVisible(WindowInsets.Type.ime())); } final Transaction t = mDisplayContent.getSyncTransaction(); @@ -474,7 +472,7 @@ abstract class InsetsSourceProvider { final SurfaceControl leash = mAdapter.mCapturedLeash; mControlTarget = target; updateVisibility(); - mControl = new InsetsSourceControl(type, leash, mClientVisible, surfacePosition, + mControl = new InsetsSourceControl(mSource.getId(), leash, mClientVisible, surfacePosition, mInsetsHint); ProtoLog.d(WM_DEBUG_WINDOW_INSETS, @@ -493,8 +491,7 @@ abstract class InsetsSourceProvider { } boolean updateClientVisibility(InsetsControlTarget caller) { - final boolean requestedVisible = - caller.isRequestedVisible(InsetsState.toPublicType(mSource.getType())); + final boolean requestedVisible = caller.isRequestedVisible(mSource.getType()); if (caller != mControlTarget || requestedVisible == mClientVisible) { return false; } @@ -530,7 +527,7 @@ abstract class InsetsSourceProvider { mSource.setVisible(mServerVisible && (isMirroredSource() || mClientVisible)); ProtoLog.d(WM_DEBUG_WINDOW_INSETS, "InsetsSource updateVisibility for %s, serverVisible: %s clientVisible: %s", - InsetsState.typeToString(mSource.getType()), + WindowInsets.Type.toString(mSource.getType()), mServerVisible, mClientVisible); } @@ -673,7 +670,7 @@ abstract class InsetsSourceProvider { public void startAnimation(SurfaceControl animationLeash, Transaction t, @AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback) { // TODO(b/166736352): Check if we still need to control the IME visibility here. - if (mSource.getType() == ITYPE_IME) { + if (mSource.getType() == WindowInsets.Type.ime()) { // TODO: use 0 alpha and remove t.hide() once b/138459974 is fixed. t.setAlpha(animationLeash, 1 /* alpha */); t.hide(animationLeash); @@ -698,7 +695,7 @@ abstract class InsetsSourceProvider { mControl = null; mControlTarget = null; mAdapter = null; - setClientVisible(InsetsState.getDefaultVisibility(mSource.getType())); + setClientVisible((WindowInsets.Type.defaultVisible() & mSource.getType()) != 0); ProtoLog.i(WM_DEBUG_WINDOW_INSETS, "ControlAdapter onAnimationCancelled mSource: %s mControlTarget: %s", mSource, mControlTarget); diff --git a/services/core/java/com/android/server/wm/InsetsStateController.java b/services/core/java/com/android/server/wm/InsetsStateController.java index ac1fbc35325a..cad32c5fac44 100644 --- a/services/core/java/com/android/server/wm/InsetsStateController.java +++ b/services/core/java/com/android/server/wm/InsetsStateController.java @@ -246,7 +246,7 @@ class InsetsStateController { void notifyControlRevoked(@NonNull InsetsControlTarget previousControlTarget, InsetsSourceProvider provider) { - removeFromControlMaps(previousControlTarget, provider.getSource().getType(), + removeFromControlMaps(previousControlTarget, provider.getSource().getId(), false /* fake */); } diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index df8886d76c48..345fa3466a24 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -442,15 +442,17 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< mLocalInsetsSourceProviders = new SparseArray<>(); } for (int i = 0; i < insetsTypes.length; i++) { + final @InsetsState.InternalInsetsType int type = insetsTypes[i]; InsetsSourceProvider insetsSourceProvider = - mLocalInsetsSourceProviders.get(insetsTypes[i]); + mLocalInsetsSourceProviders.get(type); if (insetsSourceProvider != null) { if (DEBUG) { - Slog.d(TAG, "The local insets provider for this type " + insetsTypes[i] + Slog.d(TAG, "The local insets provider for this type " + type + " already exists. Overwriting"); } } - insetsSourceProvider = new RectInsetsSourceProvider(new InsetsSource(insetsTypes[i]), + insetsSourceProvider = new RectInsetsSourceProvider( + new InsetsSource(type, InsetsState.toPublicType(type)), mDisplayContent.getInsetsStateController(), mDisplayContent); mLocalInsetsSourceProviders.put(insetsTypes[i], insetsSourceProvider); ((RectInsetsSourceProvider) insetsSourceProvider).setRect(providerFrame); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 1b7bd9e1f36f..ab9e1304f1c8 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -27,8 +27,6 @@ import static android.graphics.GraphicsProtos.dumpPointProto; import static android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS; import static android.os.PowerManager.DRAW_WAKE_LOCK; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; -import static android.view.InsetsState.ITYPE_IME; -import static android.view.InsetsState.ITYPE_INVALID; import static android.view.SurfaceControl.Transaction; import static android.view.SurfaceControl.getGlobalTransaction; import static android.view.ViewRootImpl.LOCAL_LAYOUT; @@ -915,7 +913,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // Skip performing seamless rotation when the controlled insets is IME with visible state. if (mControllableInsetProvider != null - && mControllableInsetProvider.getSource().getType() == ITYPE_IME) { + && mControllableInsetProvider.getSource().getType() == WindowInsets.Type.ime()) { return; } @@ -1677,14 +1675,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP if (rotatedState != null) { return insetsPolicy.adjustInsetsForWindow(this, rotatedState); } - final InsetsSourceProvider provider = getControllableInsetProvider(); - final @InternalInsetsType int insetTypeProvidedByWindow = provider != null - ? provider.getSource().getType() : ITYPE_INVALID; final InsetsState rawInsetsState = mFrozenInsetsState != null ? mFrozenInsetsState : getMergedInsetsState(); - final InsetsState insetsStateForWindow = insetsPolicy - .enforceInsetsPolicyForTarget(insetTypeProvidedByWindow, - getWindowingMode(), isAlwaysOnTop(), mAttrs.type, rawInsetsState); + final InsetsState insetsStateForWindow = insetsPolicy.enforceInsetsPolicyForTarget( + mAttrs, getWindowingMode(), isAlwaysOnTop(), rawInsetsState); return insetsPolicy.adjustInsetsForWindow(this, insetsStateForWindow, includeTransient); } 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 f983fa9b49e3..e369e098fc48 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -3212,14 +3212,14 @@ public class ActivityRecordTests extends WindowTestsBase { public void testImeInsetsFrozenFlag_resetWhenReportedToBeImeInputTarget() { final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); - InsetsSource imeSource = new InsetsSource(ITYPE_IME); + InsetsSource imeSource = new InsetsSource(ITYPE_IME, ime()); app.mAboveInsetsState.addSource(imeSource); mDisplayContent.setImeLayeringTarget(app); mDisplayContent.updateImeInputAndControlTarget(app); InsetsState state = app.getInsetsState(); - assertFalse(state.getSource(ITYPE_IME).isVisible()); - assertTrue(state.getSource(ITYPE_IME).getFrame().isEmpty()); + assertFalse(state.getSource(imeSource.getId()).isVisible()); + assertTrue(state.getSource(imeSource.getId()).getFrame().isEmpty()); // Simulate app is closing and expect IME insets is frozen. mDisplayContent.mOpeningApps.clear(); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java index 10f2270db19e..cf9ec81176c7 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java @@ -24,6 +24,7 @@ import static android.view.RoundedCorners.NO_ROUNDED_CORNERS; import static android.view.Surface.ROTATION_0; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; +import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND; @@ -184,7 +185,7 @@ public class DisplayPolicyTests extends WindowTestsBase { mDisplayContent.setLayoutNeeded(); mDisplayContent.performLayout(true /* initial */, false /* updateImeWindows */); - final InsetsSource navSource = new InsetsSource(ITYPE_NAVIGATION_BAR); + final InsetsSource navSource = new InsetsSource(ITYPE_NAVIGATION_BAR, navigationBars()); navSource.setFrame(mNavBarWindow.getFrame()); opaqueDarkNavBar.mAboveInsetsState.addSource(navSource); opaqueLightNavBar.mAboveInsetsState.addSource(navSource); @@ -254,14 +255,15 @@ public class DisplayPolicyTests extends WindowTestsBase { @Test public void testOverlappingWithNavBar() { - final InsetsSource navSource = new InsetsSource(ITYPE_NAVIGATION_BAR); + final InsetsSource navSource = new InsetsSource(ITYPE_NAVIGATION_BAR, navigationBars()); navSource.setFrame(new Rect(100, 200, 200, 300)); testOverlappingWithNavBarType(navSource); } @Test public void testOverlappingWithExtraNavBar() { - final InsetsSource navSource = new InsetsSource(ITYPE_EXTRA_NAVIGATION_BAR); + final InsetsSource navSource = + new InsetsSource(ITYPE_EXTRA_NAVIGATION_BAR, navigationBars()); navSource.setFrame(new Rect(100, 200, 200, 300)); testOverlappingWithNavBarType(navSource); } diff --git a/services/tests/wmtests/src/com/android/server/wm/ImeInsetsSourceProviderTest.java b/services/tests/wmtests/src/com/android/server/wm/ImeInsetsSourceProviderTest.java index a26cad98f4d2..d4e860e5ef21 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ImeInsetsSourceProviderTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/ImeInsetsSourceProviderTest.java @@ -17,6 +17,7 @@ package com.android.server.wm; import static android.view.InsetsState.ITYPE_IME; +import static android.view.WindowInsets.Type.ime; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; @@ -38,7 +39,7 @@ import org.junit.runner.RunWith; @RunWith(WindowTestRunner.class) public class ImeInsetsSourceProviderTest extends WindowTestsBase { - private InsetsSource mImeSource = new InsetsSource(ITYPE_IME); + private InsetsSource mImeSource = new InsetsSource(ITYPE_IME, ime()); private ImeInsetsSourceProvider mImeProvider; @Before 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 13ea99ae6fec..f8025ecaa6e6 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -33,6 +33,7 @@ import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; +import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; @@ -2388,7 +2389,8 @@ public class SizeCompatTests extends WindowTestsBase { organizer.mPrimary.setBounds(0, screenHeight / 2, screenWidth, screenHeight); organizer.putTaskToPrimary(mTask, true); - final InsetsSource navSource = new InsetsSource(ITYPE_EXTRA_NAVIGATION_BAR); + final InsetsSource navSource = + new InsetsSource(ITYPE_EXTRA_NAVIGATION_BAR, navigationBars()); navSource.setFrame(new Rect(0, screenHeight - taskbarHeight, screenWidth, screenHeight)); mActivity.mWmService.mLetterboxConfiguration.setLetterboxActivityCornersRadius(15); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerInsetsSourceProviderTest.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerInsetsSourceProviderTest.java index 383722a556bb..19da7183a257 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerInsetsSourceProviderTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerInsetsSourceProviderTest.java @@ -18,6 +18,7 @@ package com.android.server.wm; import static android.view.InsetsState.ITYPE_IME; import static android.view.InsetsState.ITYPE_STATUS_BAR; +import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.statusBars; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; @@ -44,9 +45,9 @@ import org.junit.runner.RunWith; @RunWith(WindowTestRunner.class) public class WindowContainerInsetsSourceProviderTest extends WindowTestsBase { - private InsetsSource mSource = new InsetsSource(ITYPE_STATUS_BAR); + private InsetsSource mSource = new InsetsSource(ITYPE_STATUS_BAR, statusBars()); private WindowContainerInsetsSourceProvider mProvider; - private InsetsSource mImeSource = new InsetsSource(ITYPE_IME); + private InsetsSource mImeSource = new InsetsSource(ITYPE_IME, ime()); private WindowContainerInsetsSourceProvider mImeProvider; @Before diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java index 50fcafca5273..79735df00879 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java @@ -24,6 +24,7 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.view.InsetsState.ITYPE_BOTTOM_GENERIC_OVERLAY; import static android.view.InsetsState.ITYPE_TOP_GENERIC_OVERLAY; +import static android.view.WindowInsets.Type.systemOverlays; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.TRANSIT_CLOSE; @@ -1311,11 +1312,11 @@ public class WindowContainerTests extends WindowTestsBase { new int[]{ITYPE_BOTTOM_GENERIC_OVERLAY}); InsetsSource genericOverlayInsetsProvider1Source = new InsetsSource( - ITYPE_TOP_GENERIC_OVERLAY); + ITYPE_TOP_GENERIC_OVERLAY, systemOverlays()); genericOverlayInsetsProvider1Source.setFrame(genericOverlayInsetsRect1); genericOverlayInsetsProvider1Source.setVisible(true); InsetsSource genericOverlayInsetsProvider2Source = new InsetsSource( - ITYPE_BOTTOM_GENERIC_OVERLAY); + ITYPE_BOTTOM_GENERIC_OVERLAY, systemOverlays()); genericOverlayInsetsProvider2Source.setFrame(genericOverlayInsetsRect2); genericOverlayInsetsProvider2Source.setVisible(true); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java index e5e9f54626e3..f24318bb1116 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java @@ -802,7 +802,7 @@ public class WindowOrganizerTests extends WindowTestsBase { mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct); assertThat(navigationBarInsetsReceiverTask.mLocalInsetsSourceProviders - .valueAt(0).getSource().getType()).isEqualTo(ITYPE_TOP_GENERIC_OVERLAY); + .valueAt(0).getSource().getId()).isEqualTo(ITYPE_TOP_GENERIC_OVERLAY); } @Test 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 69e3244af1b6..99d17729cc71 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java @@ -27,6 +27,7 @@ import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; import static android.view.WindowInsets.Type.ime; +import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowInsets.Type.statusBars; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; @@ -1017,7 +1018,7 @@ public class WindowStateTests extends WindowTestsBase { @SetupWindows(addWindows = { W_INPUT_METHOD, W_ACTIVITY }) @Test public void testImeAlwaysReceivesVisibleNavigationBarInsets() { - final InsetsSource navSource = new InsetsSource(ITYPE_NAVIGATION_BAR); + final InsetsSource navSource = new InsetsSource(ITYPE_NAVIGATION_BAR, navigationBars()); mImeWindow.mAboveInsetsState.addSource(navSource); mAppWindow.mAboveInsetsState.addSource(navSource); |