Merge "Prevent IME from showing when AOD shown or windows not drawn." into pi-dev
am: cf5514257f
Change-Id: I0bc09f864a5971eca059bdf559d91793bb9bba08
diff --git a/services/core/java/com/android/server/am/KeyguardController.java b/services/core/java/com/android/server/am/KeyguardController.java
index ddf9552..30fa72f 100644
--- a/services/core/java/com/android/server/am/KeyguardController.java
+++ b/services/core/java/com/android/server/am/KeyguardController.java
@@ -129,6 +129,7 @@
mKeyguardShowing = keyguardShowing;
mAodShowing = aodShowing;
mSecondaryDisplayShowing = secondaryDisplayShowing;
+ mWindowManager.setAodShowing(aodShowing);
if (showingChanged) {
dismissDockedStackIfNeeded();
setKeyguardGoingAway(false);
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 7f13b88..dfb6179 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -816,6 +816,8 @@
private final MutableBoolean mTmpBoolean = new MutableBoolean(false);
+ private boolean mAodShowing;
+
private static final int MSG_ENABLE_POINTER_LOCATION = 1;
private static final int MSG_DISABLE_POINTER_LOCATION = 2;
private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3;
@@ -3058,8 +3060,15 @@
boolean keyguardLocked = isKeyguardLocked();
boolean hideDockDivider = attrs.type == TYPE_DOCK_DIVIDER
&& !mWindowManagerInternal.isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
+ // If AOD is showing, the IME should be hidden. However, sometimes the AOD is considered
+ // hidden because it's in the process of hiding, but it's still being shown on screen.
+ // In that case, we want to continue hiding the IME until the windows have completed
+ // drawing. This way, we know that the IME can be safely shown since the other windows are
+ // now shown.
+ final boolean hideIme =
+ win.isInputMethodWindow() && (mAodShowing || !mWindowManagerDrawComplete);
return (keyguardLocked && !allowWhenLocked && win.getDisplayId() == DEFAULT_DISPLAY)
- || hideDockDivider;
+ || hideDockDivider || hideIme;
}
/** {@inheritDoc} */
@@ -8980,4 +8989,13 @@
public void onLockTaskStateChangedLw(int lockTaskState) {
mImmersiveModeConfirmation.onLockTaskModeChangedLw(lockTaskState);
}
+
+ @Override
+ public boolean setAodShowing(boolean aodShowing) {
+ if (mAodShowing != aodShowing) {
+ mAodShowing = aodShowing;
+ return true;
+ }
+ return false;
+ }
}
diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
index 02dd6e6..a02ee22 100644
--- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java
+++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
@@ -1774,4 +1774,11 @@
* {@link ActivityManager#LOCK_TASK_MODE_PINNED}.
*/
void onLockTaskStateChangedLw(int lockTaskState);
+
+ /**
+ * Updates the flag about whether AOD is showing.
+ *
+ * @return whether the value was changed.
+ */
+ boolean setAodShowing(boolean aodShowing);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 2885b6f..7a2c28b 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -7588,4 +7588,17 @@
mPolicy.onLockTaskStateChangedLw(lockTaskState);
}
}
+
+ /**
+ * Updates {@link WindowManagerPolicy} with new value about whether AOD is showing. If AOD
+ * has changed, this will trigger a {@link WindowSurfacePlacer#performSurfacePlacement} to
+ * ensure the new value takes effect.
+ */
+ public void setAodShowing(boolean aodShowing) {
+ synchronized (mWindowMap) {
+ if (mPolicy.setAodShowing(aodShowing)) {
+ mWindowPlacerLocked.performSurfacePlacement();
+ }
+ }
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
index 50f3fbe..ee028ba 100644
--- a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
+++ b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
@@ -598,4 +598,9 @@
@Override
public void onLockTaskStateChangedLw(int lockTaskState) {
}
+
+ @Override
+ public boolean setAodShowing(boolean aodShowing) {
+ return false;
+ }
}