diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java index 6a0ec3368f19c..c198098cb6ff0 100644 --- a/core/java/android/view/InsetsState.java +++ b/core/java/android/view/InsetsState.java @@ -90,8 +90,10 @@ public class InsetsState implements Parcelable { ITYPE_IME, ITYPE_CLIMATE_BAR, ITYPE_EXTRA_NAVIGATION_BAR, - ITYPE_LOCAL_NAVIGATION_BAR_1, - ITYPE_LOCAL_NAVIGATION_BAR_2 + ITYPE_LEFT_GENERIC_OVERLAY, + ITYPE_TOP_GENERIC_OVERLAY, + ITYPE_RIGHT_GENERIC_OVERLAY, + ITYPE_BOTTOM_GENERIC_OVERLAY }) public @interface InternalInsetsType {} @@ -135,10 +137,12 @@ public class InsetsState implements Parcelable { public static final int ITYPE_EXTRA_NAVIGATION_BAR = 21; /** Additional types for local insets. **/ - public static final int ITYPE_LOCAL_NAVIGATION_BAR_1 = 22; - public static final int ITYPE_LOCAL_NAVIGATION_BAR_2 = 23; + public static final int ITYPE_LEFT_GENERIC_OVERLAY = 22; + public static final int ITYPE_TOP_GENERIC_OVERLAY = 23; + public static final int ITYPE_RIGHT_GENERIC_OVERLAY = 24; + public static final int ITYPE_BOTTOM_GENERIC_OVERLAY = 25; - static final int LAST_TYPE = ITYPE_LOCAL_NAVIGATION_BAR_2; + static final int LAST_TYPE = ITYPE_BOTTOM_GENERIC_OVERLAY; public static final int SIZE = LAST_TYPE + 1; // Derived types @@ -698,8 +702,12 @@ public class InsetsState implements Parcelable { if ((types & Type.NAVIGATION_BARS) != 0) { result.add(ITYPE_NAVIGATION_BAR); result.add(ITYPE_EXTRA_NAVIGATION_BAR); - result.add(ITYPE_LOCAL_NAVIGATION_BAR_1); - result.add(ITYPE_LOCAL_NAVIGATION_BAR_2); + } + if ((types & Type.GENERIC_OVERLAYS) != 0) { + result.add(ITYPE_LEFT_GENERIC_OVERLAY); + result.add(ITYPE_TOP_GENERIC_OVERLAY); + result.add(ITYPE_RIGHT_GENERIC_OVERLAY); + result.add(ITYPE_BOTTOM_GENERIC_OVERLAY); } if ((types & Type.CAPTION_BAR) != 0) { result.add(ITYPE_CAPTION_BAR); @@ -740,9 +748,12 @@ public class InsetsState implements Parcelable { return Type.STATUS_BARS; case ITYPE_NAVIGATION_BAR: case ITYPE_EXTRA_NAVIGATION_BAR: - case ITYPE_LOCAL_NAVIGATION_BAR_1: - case ITYPE_LOCAL_NAVIGATION_BAR_2: return Type.NAVIGATION_BARS; + case ITYPE_LEFT_GENERIC_OVERLAY: + case ITYPE_TOP_GENERIC_OVERLAY: + case ITYPE_RIGHT_GENERIC_OVERLAY: + case ITYPE_BOTTOM_GENERIC_OVERLAY: + return Type.GENERIC_OVERLAYS; case ITYPE_CAPTION_BAR: return Type.CAPTION_BAR; case ITYPE_IME: @@ -861,10 +872,14 @@ public class InsetsState implements Parcelable { return "ITYPE_CLIMATE_BAR"; case ITYPE_EXTRA_NAVIGATION_BAR: return "ITYPE_EXTRA_NAVIGATION_BAR"; - case ITYPE_LOCAL_NAVIGATION_BAR_1: - return "ITYPE_LOCAL_NAVIGATION_BAR_1"; - case ITYPE_LOCAL_NAVIGATION_BAR_2: - return "ITYPE_LOCAL_NAVIGATION_BAR_2"; + case ITYPE_LEFT_GENERIC_OVERLAY: + return "ITYPE_LEFT_GENERIC_OVERLAY"; + case ITYPE_TOP_GENERIC_OVERLAY: + return "ITYPE_TOP_GENERIC_OVERLAY"; + case ITYPE_RIGHT_GENERIC_OVERLAY: + return "ITYPE_RIGHT_GENERIC_OVERLAY"; + case ITYPE_BOTTOM_GENERIC_OVERLAY: + return "ITYPE_BOTTOM_GENERIC_OVERLAY"; default: return "ITYPE_UNKNOWN_" + type; } diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java index c846175699f2a..c1dddbee408f7 100644 --- a/core/java/android/view/WindowInsets.java +++ b/core/java/android/view/WindowInsets.java @@ -1423,9 +1423,11 @@ public final class WindowInsets { static final int DISPLAY_CUTOUT = 1 << 7; - static final int LAST = 1 << 8; - static final int SIZE = 9; - static final int WINDOW_DECOR = LAST; + static final int WINDOW_DECOR = 1 << 8; + + static final int GENERIC_OVERLAYS = 1 << 9; + static final int LAST = GENERIC_OVERLAYS; + static final int SIZE = 10; static int indexOf(@InsetsType int type) { switch (type) { @@ -1447,6 +1449,8 @@ public final class WindowInsets { return 7; case WINDOW_DECOR: return 8; + case GENERIC_OVERLAYS: + return 9; default: throw new IllegalArgumentException("type needs to be >= FIRST and <= LAST," + " type=" + type); @@ -1482,6 +1486,9 @@ public final class WindowInsets { if ((types & WINDOW_DECOR) != 0) { result.append("windowDecor |"); } + if ((types & GENERIC_OVERLAYS) != 0) { + result.append("genericOverlays |"); + } if (result.length() > 0) { result.delete(result.length() - 2, result.length()); } @@ -1494,7 +1501,8 @@ public final class WindowInsets { /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, value = {STATUS_BARS, NAVIGATION_BARS, CAPTION_BAR, IME, WINDOW_DECOR, - SYSTEM_GESTURES, MANDATORY_SYSTEM_GESTURES, TAPPABLE_ELEMENT, DISPLAY_CUTOUT}) + SYSTEM_GESTURES, MANDATORY_SYSTEM_GESTURES, TAPPABLE_ELEMENT, DISPLAY_CUTOUT, + GENERIC_OVERLAYS}) public @interface InsetsType { } @@ -1586,7 +1594,7 @@ public final class WindowInsets { * {@link #navigationBars()}, but not {@link #ime()}. */ public static @InsetsType int systemBars() { - return STATUS_BARS | NAVIGATION_BARS | CAPTION_BAR; + return STATUS_BARS | NAVIGATION_BARS | CAPTION_BAR | GENERIC_OVERLAYS; } /** 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 1715a295ded3f..c8ea70c5d6504 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java @@ -22,8 +22,8 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; -import static android.view.InsetsState.ITYPE_LOCAL_NAVIGATION_BAR_1; -import static android.view.InsetsState.ITYPE_LOCAL_NAVIGATION_BAR_2; +import static android.view.InsetsState.ITYPE_BOTTOM_GENERIC_OVERLAY; +import static android.view.InsetsState.ITYPE_TOP_GENERIC_OVERLAY; 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; @@ -1302,40 +1302,42 @@ public class WindowContainerTests extends WindowTestsBase { TYPE_BASE_APPLICATION); attrs2.setTitle("AppWindow2"); activity2.addWindow(createWindowState(attrs2, activity2)); - Rect navigationBarInsetsRect1 = new Rect(0, 200, 1080, 700); - Rect navigationBarInsetsRect2 = new Rect(0, 0, 1080, 200); + Rect genericOverlayInsetsRect1 = new Rect(0, 200, 1080, 700); + Rect genericOverlayInsetsRect2 = new Rect(0, 0, 1080, 200); - rootTask.addLocalRectInsetsSourceProvider(navigationBarInsetsRect1, - new int[]{ITYPE_LOCAL_NAVIGATION_BAR_1}); - container.addLocalRectInsetsSourceProvider(navigationBarInsetsRect2, - new int[]{ITYPE_LOCAL_NAVIGATION_BAR_2}); + rootTask.addLocalRectInsetsSourceProvider(genericOverlayInsetsRect1, + new int[]{ITYPE_TOP_GENERIC_OVERLAY}); + container.addLocalRectInsetsSourceProvider(genericOverlayInsetsRect2, + new int[]{ITYPE_BOTTOM_GENERIC_OVERLAY}); - InsetsSource navigationBarInsetsProvider1Source = new InsetsSource( - ITYPE_LOCAL_NAVIGATION_BAR_1); - navigationBarInsetsProvider1Source.setFrame(navigationBarInsetsRect1); - navigationBarInsetsProvider1Source.setVisible(true); - InsetsSource navigationBarInsetsProvider2Source = new InsetsSource( - ITYPE_LOCAL_NAVIGATION_BAR_2); - navigationBarInsetsProvider2Source.setFrame(navigationBarInsetsRect2); - navigationBarInsetsProvider2Source.setVisible(true); + InsetsSource genericOverlayInsetsProvider1Source = new InsetsSource( + ITYPE_TOP_GENERIC_OVERLAY); + genericOverlayInsetsProvider1Source.setFrame(genericOverlayInsetsRect1); + genericOverlayInsetsProvider1Source.setVisible(true); + InsetsSource genericOverlayInsetsProvider2Source = new InsetsSource( + ITYPE_BOTTOM_GENERIC_OVERLAY); + genericOverlayInsetsProvider2Source.setFrame(genericOverlayInsetsRect2); + genericOverlayInsetsProvider2Source.setVisible(true); activity0.forAllWindows(window -> { - assertEquals(navigationBarInsetsRect1, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_1).getFrame()); + assertEquals(genericOverlayInsetsRect1, + window.getInsetsState().peekSource(ITYPE_TOP_GENERIC_OVERLAY).getFrame()); assertEquals(null, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_2)); + window.getInsetsState().peekSource(ITYPE_BOTTOM_GENERIC_OVERLAY)); }, true); activity1.forAllWindows(window -> { - assertEquals(navigationBarInsetsRect1, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_1).getFrame()); - assertEquals(navigationBarInsetsRect2, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_2).getFrame()); + assertEquals(genericOverlayInsetsRect1, + window.getInsetsState().peekSource(ITYPE_TOP_GENERIC_OVERLAY).getFrame()); + assertEquals(genericOverlayInsetsRect2, + window.getInsetsState().peekSource(ITYPE_BOTTOM_GENERIC_OVERLAY) + .getFrame()); }, true); activity2.forAllWindows(window -> { - assertEquals(navigationBarInsetsRect1, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_1).getFrame()); - assertEquals(navigationBarInsetsRect2, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_2).getFrame()); + assertEquals(genericOverlayInsetsRect1, + window.getInsetsState().peekSource(ITYPE_TOP_GENERIC_OVERLAY).getFrame()); + assertEquals(genericOverlayInsetsRect2, + window.getInsetsState().peekSource(ITYPE_BOTTOM_GENERIC_OVERLAY) + .getFrame()); }, true); } @@ -1344,7 +1346,7 @@ public class WindowContainerTests extends WindowTestsBase { /* ___ rootTask ________________________________________ | | | - activity0 navigationBarInsetsProvider1 navigationBarInsetsProvider2 + activity0 genericOverlayInsetsProvider1 genericOverlayInsetsProvider2 */ final Task rootTask = createTask(mDisplayContent); @@ -1355,22 +1357,22 @@ public class WindowContainerTests extends WindowTestsBase { attrs.setTitle("AppWindow0"); activity0.addWindow(createWindowState(attrs, activity0)); - Rect navigationBarInsetsRect1 = new Rect(0, 200, 1080, 700); - Rect navigationBarInsetsRect2 = new Rect(0, 0, 1080, 200); + Rect genericOverlayInsetsRect1 = new Rect(0, 200, 1080, 700); + Rect genericOverlayInsetsRect2 = new Rect(0, 0, 1080, 200); - rootTask.addLocalRectInsetsSourceProvider(navigationBarInsetsRect1, - new int[]{ITYPE_LOCAL_NAVIGATION_BAR_1}); + rootTask.addLocalRectInsetsSourceProvider(genericOverlayInsetsRect1, + new int[]{ITYPE_TOP_GENERIC_OVERLAY}); activity0.forAllWindows(window -> { - assertEquals(navigationBarInsetsRect1, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_1).getFrame()); + assertEquals(genericOverlayInsetsRect1, + window.getInsetsState().peekSource(ITYPE_TOP_GENERIC_OVERLAY).getFrame()); }, true); - rootTask.addLocalRectInsetsSourceProvider(navigationBarInsetsRect2, - new int[]{ITYPE_LOCAL_NAVIGATION_BAR_1}); + rootTask.addLocalRectInsetsSourceProvider(genericOverlayInsetsRect2, + new int[]{ITYPE_TOP_GENERIC_OVERLAY}); activity0.forAllWindows(window -> { - assertEquals(navigationBarInsetsRect2, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_1).getFrame()); + assertEquals(genericOverlayInsetsRect2, + window.getInsetsState().peekSource(ITYPE_TOP_GENERIC_OVERLAY).getFrame()); }, true); } @@ -1412,30 +1414,32 @@ public class WindowContainerTests extends WindowTestsBase { Rect navigationBarInsetsRect2 = new Rect(0, 0, 1080, 200); rootTask.addLocalRectInsetsSourceProvider(navigationBarInsetsRect1, - new int[]{ITYPE_LOCAL_NAVIGATION_BAR_1}); + new int[]{ITYPE_TOP_GENERIC_OVERLAY}); container.addLocalRectInsetsSourceProvider(navigationBarInsetsRect2, - new int[]{ITYPE_LOCAL_NAVIGATION_BAR_2}); + new int[]{ITYPE_BOTTOM_GENERIC_OVERLAY}); mDisplayContent.getInsetsStateController().onPostLayout(); - rootTask.removeLocalInsetsSourceProvider(new int[]{ITYPE_LOCAL_NAVIGATION_BAR_1}); + rootTask.removeLocalInsetsSourceProvider(new int[]{ITYPE_TOP_GENERIC_OVERLAY}); mDisplayContent.getInsetsStateController().onPostLayout(); activity0.forAllWindows(window -> { assertEquals(null, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_1)); + window.getInsetsState().peekSource(ITYPE_TOP_GENERIC_OVERLAY)); assertEquals(null, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_2)); + window.getInsetsState().peekSource(ITYPE_BOTTOM_GENERIC_OVERLAY)); }, true); activity1.forAllWindows(window -> { assertEquals(null, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_1)); + window.getInsetsState().peekSource(ITYPE_TOP_GENERIC_OVERLAY)); assertEquals(navigationBarInsetsRect2, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_2).getFrame()); + window.getInsetsState().peekSource(ITYPE_BOTTOM_GENERIC_OVERLAY) + .getFrame()); }, true); activity2.forAllWindows(window -> { assertEquals(null, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_1)); + window.getInsetsState().peekSource(ITYPE_TOP_GENERIC_OVERLAY)); assertEquals(navigationBarInsetsRect2, - window.getInsetsState().peekSource(ITYPE_LOCAL_NAVIGATION_BAR_2).getFrame()); + window.getInsetsState().peekSource(ITYPE_BOTTOM_GENERIC_OVERLAY) + .getFrame()); }, 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 540741217ae8d..84c2c551de85f 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java @@ -30,7 +30,7 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.content.res.Configuration.SCREEN_HEIGHT_DP_UNDEFINED; import static android.content.res.Configuration.SCREEN_WIDTH_DP_UNDEFINED; -import static android.view.InsetsState.ITYPE_LOCAL_NAVIGATION_BAR_1; +import static android.view.InsetsState.ITYPE_TOP_GENERIC_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; @@ -779,11 +779,11 @@ public class WindowOrganizerTests extends WindowTestsBase { final WindowContainerTransaction wct = new WindowContainerTransaction(); wct.addRectInsetsProvider(navigationBarInsetsReceiverTask.mRemoteToken .toWindowContainerToken(), navigationBarInsetsProviderRect, - new int[]{ITYPE_LOCAL_NAVIGATION_BAR_1}); + new int[]{ITYPE_TOP_GENERIC_OVERLAY}); mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct); assertThat(navigationBarInsetsReceiverTask.mLocalInsetsSourceProviders - .valueAt(0).getSource().getType()).isEqualTo(ITYPE_LOCAL_NAVIGATION_BAR_1); + .valueAt(0).getSource().getType()).isEqualTo(ITYPE_TOP_GENERIC_OVERLAY); } @Test @@ -799,12 +799,12 @@ public class WindowOrganizerTests extends WindowTestsBase { final WindowContainerTransaction wct = new WindowContainerTransaction(); wct.addRectInsetsProvider(navigationBarInsetsReceiverTask.mRemoteToken .toWindowContainerToken(), navigationBarInsetsProviderRect, - new int[]{ITYPE_LOCAL_NAVIGATION_BAR_1}); + new int[]{ITYPE_TOP_GENERIC_OVERLAY}); mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct); final WindowContainerTransaction wct2 = new WindowContainerTransaction(); wct2.removeInsetsProvider(navigationBarInsetsReceiverTask.mRemoteToken - .toWindowContainerToken(), new int[]{ITYPE_LOCAL_NAVIGATION_BAR_1}); + .toWindowContainerToken(), new int[]{ITYPE_TOP_GENERIC_OVERLAY}); mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct2); assertThat(navigationBarInsetsReceiverTask.mLocalInsetsSourceProviders.size()).isEqualTo(0);