OSDN Git Service

Expose API to hide the IME during a recents animation
authorWinson Chung <winsonc@google.com>
Fri, 20 Apr 2018 22:58:18 +0000 (15:58 -0700)
committerWinson Chung <winsonc@google.com>
Mon, 23 Apr 2018 23:20:27 +0000 (16:20 -0700)
Bug: 73285089
Test: Swipe up from app with IME open, ensure that it closes
Change-Id: I95ce59291f11285c853e8b3029638119c21f7e38

core/java/android/view/IRecentsAnimationController.aidl
packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationControllerCompat.java
services/core/java/com/android/server/wm/RecentsAnimationController.java

index c0b40c8..94b9bc0 100644 (file)
@@ -64,4 +64,9 @@ interface IRecentsAnimationController {
      * Informs the system that the primary split-screen stack should be minimized.
      */
     void setSplitScreenMinimized(boolean minimized);
+
+    /**
+     * Hides the current input method if one is showing.
+     */
+    void hideCurrentInputMethod();
 }
index 80e226d..9bebb14 100644 (file)
@@ -69,6 +69,14 @@ public class RecentsAnimationControllerCompat {
         }
     }
 
+    public void hideCurrentInputMethod() {
+        try {
+            mAnimationController.hideCurrentInputMethod();
+        } catch (RemoteException e) {
+            Log.e(TAG, "Failed to set hide input method", e);
+        }
+    }
+
     public void finish(boolean toHome) {
         try {
             mAnimationController.finish(toHome);
index 79b230d..b057b1d 100644 (file)
@@ -47,7 +47,9 @@ import android.view.IRecentsAnimationRunner;
 import android.view.RemoteAnimationTarget;
 import android.view.SurfaceControl;
 import android.view.SurfaceControl.Transaction;
+import android.view.inputmethod.InputMethodManagerInternal;
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.LocalServices;
 import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
 import com.android.server.wm.utils.InsetUtils;
 import com.google.android.collect.Sets;
@@ -220,6 +222,20 @@ public class RecentsAnimationController implements DeathRecipient {
                 Binder.restoreCallingIdentity(token);
             }
         }
+
+        @Override
+        public void hideCurrentInputMethod() {
+            final long token = Binder.clearCallingIdentity();
+            try {
+                final InputMethodManagerInternal inputMethodManagerInternal =
+                        LocalServices.getService(InputMethodManagerInternal.class);
+                if (inputMethodManagerInternal != null) {
+                    inputMethodManagerInternal.hideCurrentInputMethod();
+                }
+            } finally {
+                Binder.restoreCallingIdentity(token);
+            }
+        }
     };
 
     /**