summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java28
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java6
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;