From 75a4e742f8c1b69ff3db4fdd03c56f0f2c791699 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Sun, 18 Apr 2021 23:16:11 +0800 Subject: [PATCH] Update IME window status when KeyguardController#setKeyguardShown As in IMMS#handleSetInteractive handles the IME icon status (e.g. Back-key arror or IME picker icon on navigation bar) when the interactive changed and setting IME icon as invisible when the keyguard is not the IME client and in shown state. However, the keyguard state is independent of the screen going non-interactive and the transition to locked can happen much later (e.g.the brief flow will be starting from triggering dream service to notify KeyguardService to update keyguard shown state to WM side), or even never depens on user settings. Add InputMethodManagerInternal#setImeWindowState for KeyguardController to update IME icon status directly to fix the timing issue that in IMMS side expects to set IME icon as IME_INVISIBLE when KeyguardManager#isKeyguardLocked is true but sometimes may return false and still see the IME icon is visible even the Lockscreen is shown. Bug: 185763794 Test: manual as below steps 0) setup PIN lock for the device 1) launch an app (e.g. Messaging) and show IME 2) turn-off the screen and then turn-on quickly 3) verify if the IME icon is invisible when the keyguard shown Change-Id: Ic12baae9fd7886d2d96a049c8067a79360088549 --- .../InputMethodManagerInternal.java | 9 +++++++++ .../InputMethodManagerService.java | 19 +++++++++++++++++++ .../MultiClientInputMethodManagerService.java | 4 ++++ .../android/server/wm/KeyguardController.java | 2 ++ 4 files changed, 34 insertions(+) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java index 3ac95d71de3d8..bfb9db8281318 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java @@ -124,6 +124,11 @@ public abstract class InputMethodManagerInternal { */ public abstract void removeImeSurface(); + /** + * Updates the IME visibility, back disposition and show IME picker status for SystemUI. + */ + public abstract void updateImeWindowStatus(); + /** * Fake implementation of {@link InputMethodManagerInternal}. All the methods do nothing. */ @@ -175,6 +180,10 @@ public abstract class InputMethodManagerInternal { @Override public void removeImeSurface() { } + + @Override + public void updateImeWindowStatus() { + } }; /** diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 94a5099b45dad..254243f7167c1 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -248,6 +248,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub static final int MSG_CREATE_SESSION = 1050; static final int MSG_REMOVE_IME_SURFACE = 1060; static final int MSG_REMOVE_IME_SURFACE_FROM_WINDOW = 1061; + static final int MSG_UPDATE_IME_WINDOW_STATUS = 1070; static final int MSG_START_INPUT = 2000; @@ -2940,6 +2941,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } + private void updateImeWindowStatus() { + synchronized (mMethodMap) { + updateSystemUiLocked(); + } + } + void updateSystemUiLocked() { updateSystemUiLocked(mImeWindowVis, mBackDisposition); } @@ -4537,6 +4544,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } return true; } + case MSG_UPDATE_IME_WINDOW_STATUS: { + synchronized (mMethodMap) { + updateSystemUiLocked(); + } + return true; + } // --------------------------------------------------------- case MSG_START_INPUT: { @@ -5202,6 +5215,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub public void removeImeSurface() { mService.mHandler.sendMessage(mService.mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE)); } + + @Override + public void updateImeWindowStatus() { + mService.mHandler.sendMessage( + mService.mHandler.obtainMessage(MSG_UPDATE_IME_WINDOW_STATUS)); + } } @BinderThread diff --git a/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java index 885093d614868..fcaf6d8fe4003 100644 --- a/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java @@ -241,6 +241,10 @@ public final class MultiClientInputMethodManagerService { public void removeImeSurface() { reportNotSupported(); } + + @Override + public void updateImeWindowStatus() { + } }); } diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java index 8ff9fbaa39952..df4f2a91a8a5d 100644 --- a/services/core/java/com/android/server/wm/KeyguardController.java +++ b/services/core/java/com/android/server/wm/KeyguardController.java @@ -50,6 +50,7 @@ import android.util.SparseArray; import android.util.proto.ProtoOutputStream; import com.android.internal.policy.IKeyguardDismissCallback; +import com.android.server.inputmethod.InputMethodManagerInternal; import com.android.server.policy.WindowManagerPolicy; import java.io.PrintWriter; @@ -191,6 +192,7 @@ class KeyguardController { // state when evaluating visibilities. updateKeyguardSleepToken(); mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); + InputMethodManagerInternal.get().updateImeWindowStatus(); } /**