Window Manager Flag Migration (4/n)

Wire up the appearance and the transient state of system bars between
WMS and System UI. The derived classes of CommandQueue.Callbacks no
longer listen to setSystemUiVisibility, but listen to showTransient,
abortTransient, and onSystemBarAppearanceChanged instead.

Bug: 118118435
Test: atest InsetsSourceProviderTest InsetsStateControllerTest
            InsetsPolicyTest WindowStateTests CommandQueueTest
            RegisterStatusBarResultTest InsetsFlagsTest
            LightBarControllerTest
Test: build on specific target
Change-Id: Ie35f4b4468bce7ef8c76f091e306610c069fba85
diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java
index a04c39b..99502a6 100644
--- a/core/java/android/view/InsetsState.java
+++ b/core/java/android/view/InsetsState.java
@@ -270,10 +270,23 @@
      *
      * @param type The {@link InternalInsetType} of the source to remove
      */
-    public void removeSource(int type) {
+    public void removeSource(@InternalInsetType int type) {
         mSources.remove(type);
     }
 
+    /**
+     * A shortcut for setting the visibility of the source.
+     *
+     * @param type The {@link InternalInsetType} of the source to set the visibility
+     * @param visible {@code true} for visible
+     */
+    public void setSourceVisible(@InternalInsetType int type, boolean visible) {
+        InsetsSource source = mSources.get(type);
+        if (source != null) {
+            source.setVisible(visible);
+        }
+    }
+
     public void set(InsetsState other) {
         set(other, false /* copySources */);
     }
@@ -357,6 +370,19 @@
         }
     }
 
+    public static boolean containsType(@InternalInsetType int[] types,
+            @InternalInsetType int type) {
+        if (types == null) {
+            return false;
+        }
+        for (int t : types) {
+            if (t == type) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     public void dump(String prefix, PrintWriter pw) {
         pw.println(prefix + "InsetsState");
         for (int i = mSources.size() - 1; i >= 0; i--) {
@@ -364,7 +390,7 @@
         }
     }
 
-    public static String typeToString(int type) {
+    public static String typeToString(@InternalInsetType int type) {
         switch (type) {
             case TYPE_TOP_BAR:
                 return "TYPE_TOP_BAR";