Add the systemOverlays() method

- Also rename GENERIC_OVERLAYS to SYSTEM_OVERLAYS

Bug: 232017511
Fix: 244238266
Test: atest WindowInsetsTests
Change-Id: Ib8455f6ae576c7b3f40789de30649d8fc137e3dd
diff --git a/core/api/current.txt b/core/api/current.txt
index e2f2fae..afa0453 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -51898,6 +51898,7 @@
     method public static int statusBars();
     method public static int systemBars();
     method public static int systemGestures();
+    method public static int systemOverlays();
     method public static int tappableElement();
   }
 
diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java
index e91839b..a8cc9b6 100644
--- a/core/java/android/view/InsetsState.java
+++ b/core/java/android/view/InsetsState.java
@@ -702,7 +702,7 @@
             result.add(ITYPE_NAVIGATION_BAR);
             result.add(ITYPE_EXTRA_NAVIGATION_BAR);
         }
-        if ((types & Type.GENERIC_OVERLAYS) != 0) {
+        if ((types & Type.SYSTEM_OVERLAYS) != 0) {
             result.add(ITYPE_LEFT_GENERIC_OVERLAY);
             result.add(ITYPE_TOP_GENERIC_OVERLAY);
             result.add(ITYPE_RIGHT_GENERIC_OVERLAY);
@@ -752,7 +752,7 @@
             case ITYPE_TOP_GENERIC_OVERLAY:
             case ITYPE_RIGHT_GENERIC_OVERLAY:
             case ITYPE_BOTTOM_GENERIC_OVERLAY:
-                return Type.GENERIC_OVERLAYS;
+                return Type.SYSTEM_OVERLAYS;
             case ITYPE_CAPTION_BAR:
                 return Type.CAPTION_BAR;
             case ITYPE_IME:
diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java
index 2a76c4e..d77e499 100644
--- a/core/java/android/view/WindowInsets.java
+++ b/core/java/android/view/WindowInsets.java
@@ -1425,8 +1425,8 @@
 
         static final int WINDOW_DECOR = 1 << 8;
 
-        static final int GENERIC_OVERLAYS = 1 << 9;
-        static final int LAST = GENERIC_OVERLAYS;
+        static final int SYSTEM_OVERLAYS = 1 << 9;
+        static final int LAST = SYSTEM_OVERLAYS;
         static final int SIZE = 10;
 
         static final int DEFAULT_VISIBLE = ~IME;
@@ -1451,7 +1451,7 @@
                     return 7;
                 case WINDOW_DECOR:
                     return 8;
-                case GENERIC_OVERLAYS:
+                case SYSTEM_OVERLAYS:
                     return 9;
                 default:
                     throw new IllegalArgumentException("type needs to be >= FIRST and <= LAST,"
@@ -1489,8 +1489,8 @@
             if ((types & WINDOW_DECOR) != 0) {
                 result.append("windowDecor |");
             }
-            if ((types & GENERIC_OVERLAYS) != 0) {
-                result.append("genericOverlays |");
+            if ((types & SYSTEM_OVERLAYS) != 0) {
+                result.append("systemOverlays |");
             }
             if (result.length() > 0) {
                 result.delete(result.length() - 2, result.length());
@@ -1505,7 +1505,7 @@
         @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,
-                GENERIC_OVERLAYS})
+                SYSTEM_OVERLAYS})
         public @interface InsetsType {
         }
 
@@ -1593,11 +1593,27 @@
         }
 
         /**
+         * System overlays represent the insets caused by the system visible elements. Unlike
+         * {@link #navigationBars()} or {@link #statusBars()}, system overlays might not be
+         * hidden by the client.
+         *
+         * For compatibility reasons, this type is included in {@link #systemBars()}. In this
+         * way, views which fit {@link #systemBars()} fit {@link #systemOverlays()}.
+         *
+         * Examples include climate controls, multi-tasking affordances, etc.
+         *
+         * @return An insets type representing the system overlays.
+         */
+        public static @InsetsType int systemOverlays() {
+            return SYSTEM_OVERLAYS;
+        }
+
+        /**
          * @return All system bars. Includes {@link #statusBars()}, {@link #captionBar()} as well as
-         *         {@link #navigationBars()}, but not {@link #ime()}.
+         *         {@link #navigationBars()}, {@link #systemOverlays()}, but not {@link #ime()}.
          */
         public static @InsetsType int systemBars() {
-            return STATUS_BARS | NAVIGATION_BARS | CAPTION_BAR | GENERIC_OVERLAYS;
+            return STATUS_BARS | NAVIGATION_BARS | CAPTION_BAR | SYSTEM_OVERLAYS;
         }
 
         /**