diff options
| author | 2025-01-29 05:28:25 -0800 | |
|---|---|---|
| committer | 2025-01-29 05:28:25 -0800 | |
| commit | 7e6a7855470e5aa7621780959e95bc66b4dc025f (patch) | |
| tree | a297c0855a4b55d3847d2514cf248fa5498a8446 /libs | |
| parent | c51923ac781a8eda28483acba93574c97cbe48ba (diff) | |
| parent | 7b80be55a357d8e9f75927a607caf6a0a1c4eb7a (diff) | |
Merge "Fix IME visibility issue when device is locked" into main
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java | 28 | ||||
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java | 6 |
2 files changed, 32 insertions, 2 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 5cd04b11bbfd..e3f8e0c321a4 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -640,6 +640,14 @@ public class BubbleController implements ConfigurationChangeListener, mOnImeHidden = onImeHidden; mBubblePositioner.setImeVisible(false /* visible */, 0 /* height */); int displayId = mWindowManager.getDefaultDisplay().getDisplayId(); + // if the device is locked we can't use the status bar service to hide the IME because + // the IME state is frozen and it will lead to internal IME state going out of sync. This + // will make the IME visible when the device is unlocked. Instead we use + // DisplayImeController directly to make sure the state is correct when the device unlocks. + if (isDeviceLocked()) { + mDisplayImeController.hideImeForBubblesWhenLocked(displayId); + return; + } try { mBarService.hideCurrentInputMethodForBubbles(displayId); } catch (RemoteException e) { @@ -679,8 +687,20 @@ public class BubbleController implements ConfigurationChangeListener, ? mNotifEntryToExpandOnShadeUnlock.getKey() : "null")); mIsStatusBarShade = isShade; if (!mIsStatusBarShade && didChange) { - // Only collapse stack on change - collapseStack(); + if (mBubbleData.isExpanded()) { + // If the IME is visible, hide it first and then collapse. + if (mBubblePositioner.isImeVisible()) { + hideCurrentInputMethod(this::collapseStack); + } else { + collapseStack(); + } + } else if (mOnImeHidden != null) { + // a request to collapse started before we're notified that the device is locking. + // we're currently waiting for the IME to collapse, before mOnImeHidden can be + // executed, which may not happen since the screen may already be off. hide the IME + // immediately now that we're locked and pass the same runnable so it can complete. + hideCurrentInputMethod(mOnImeHidden); + } } if (mNotifEntryToExpandOnShadeUnlock != null) { @@ -2483,6 +2503,10 @@ public class BubbleController implements ConfigurationChangeListener, mBubbleData.setSelectedBubbleAndExpandStack(bubbleToSelect); } + private boolean isDeviceLocked() { + return !mIsStatusBarShade; + } + /** * Description of current bubble state. */ diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java index 94e629a6887f..8377a35a9e7d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java @@ -224,6 +224,12 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged } } + /** Hides the IME for Bubbles when the device is locked. */ + public void hideImeForBubblesWhenLocked(int displayId) { + PerDisplay pd = mImePerDisplay.get(displayId); + pd.setImeInputTargetRequestedVisibility(false, pd.getImeSourceControl().getImeStatsToken()); + } + /** An implementation of {@link IDisplayWindowInsetsController} for a given display id. */ public class PerDisplay implements DisplayInsetsController.OnInsetsChangedListener { final int mDisplayId; |