IME transitions without pre-rendering.

Support new IME inset api transitions without using pre-rendering.
This would be the default behavior when ViewRootImpl#sNewInsetsMode > 0
and pre-rendering is not enabled.

Bug: 111084606
Bug: 118599175
Test: Manually verify by just enabling Insets API and keeping
    pre-rendering off.
     1. Build and flash
     2. adb shell setprop persist.wm.new_insets 1
     3. adb reboot
     4. Make sure tapping on edit text brings keyboard up with new
     transition and back closes IME with various apps.
     5. Make sure IME behavior is unchanged for apps with
        ADJUST_RESIZE like whatsapp.
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases

Change-Id: If33e9dd45e549e49757237fa66051351b858875d
diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java
index a780158..9edccb3 100644
--- a/core/java/android/view/InsetsSourceConsumer.java
+++ b/core/java/android/view/InsetsSourceConsumer.java
@@ -58,6 +58,7 @@
     private final @InternalInsetType int mType;
     private final InsetsState mState;
     private @Nullable InsetsSourceControl mSourceControl;
+    private boolean mHasWindowFocus;
 
     public InsetsSourceConsumer(@InternalInsetType int type, InsetsState state,
             Supplier<Transaction> transactionSupplier, InsetsController controller) {
@@ -104,12 +105,20 @@
     /**
      * Called when current window gains focus
      */
-    public void onWindowFocusGained() {}
+    public void onWindowFocusGained() {
+        mHasWindowFocus = true;
+    }
 
     /**
      * Called when current window loses focus.
      */
-    public void onWindowFocusLost() {}
+    public void onWindowFocusLost() {
+        mHasWindowFocus = false;
+    }
+
+    boolean hasWindowFocus() {
+        return mHasWindowFocus;
+    }
 
     boolean applyLocalVisibilityOverride() {
 
@@ -153,7 +162,6 @@
             return;
         }
         mVisible = visible;
-        applyHiddenToControl();
         applyLocalVisibilityOverride();
         mController.notifyVisibilityChanged();
     }