From 35ff45dab416e93d99b4d1b21f0a2d39baaa3b56 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Thu, 2 Jul 2020 15:40:31 +0800 Subject: Fix Keyboard stays on while startSeamlessRotation InsetsSourceProvider#startSemlessRotation will be called and cancel on-going insets animation to revoke the insets control. The idea is preventing the frame of insets animation will be drawn while the rotation is not yet stable, and re-apply the revoked control again once the rotation finished. However, since the IME insets control / control target / leash has been cleared after animation cancelled, there is no way to update the revoked IME control target again, and also cannot have a direct signal to request visible for client side after finished rotation, that will casue IME surface stays on and client can't control the IME inets visiblity. As the issue case which seamless rotation happens during launch fixed portrait rotation app from launcher in landscape mode, since seamless rotation animation doesn't well support the target window which controlled IME insets is animating, we should skip seamless rotation for this case. Fix: 158924696 Test: manual as below steps: 1. Enable "Allow Home screen rotation" from Launcher -> Home Settings and "Auto-rotate" from quick settings. 2. Open Snapchat in portrait > open a conversation > open keyboard. 3. Tap Home button > rotate device from portrait to landscape. 4. Tap Snapchat icon in landscape > the keyboard is automatically displayed 5. Tap the back key in the lower left corner of the device. 6. Expect keyboard should hide after the back key pressed. Change-Id: I7d4685a0b85ec3db9b7e1c266030817da3dde812 --- services/core/java/com/android/server/wm/WindowState.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index f1acee5031d8..47e035567152 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -26,6 +26,7 @@ import static android.app.WindowConfiguration.isSplitScreenWindowingMode; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.os.PowerManager.DRAW_WAKE_LOCK; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; +import static android.view.InsetsState.ITYPE_IME; import static android.view.SurfaceControl.Transaction; import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; @@ -756,6 +757,12 @@ class WindowState extends WindowContainer implements WindowManagerP oldRotation = mPendingSeamlessRotate.getOldRotation(); } + // Skip performing seamless rotation when the controlled insets is IME with visible state. + if (mControllableInsetProvider != null + && mControllableInsetProvider.getSource().getType() == ITYPE_IME) { + return; + } + if (mForceSeamlesslyRotate || requested) { if (mControllableInsetProvider != null) { mControllableInsetProvider.startSeamlessRotation(); -- cgit v1.2.3-59-g8ed1b