Fix IME window can't show on keyguard with setShowWhenLocked.
For new API android:showWhenLocked and Activity#setShowWhenLocked has a bug that didn't sync window side, caused IME target window will still be treated no show when locked flag in PhoneWindowManager#shouldBeHiddenByKeyguard() and then the IME window will be hidden. Thanks to AM / WM unification, leverage this to call ActivityRecord#canShowWhenLocked in WM side rather then just checking FLAG_SHOW_WHEN_LOCKED. Bug: 119629545 Test: atest KeyguardLockedTests Change-Id: I59b01c24b54fb512c5ef4c107274fc36bb3c948e
This commit is contained in:
@@ -2270,9 +2270,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
|
||||
final LayoutParams attrs = win.getAttrs();
|
||||
final boolean showImeOverKeyguard = imeTarget != null && imeTarget.isVisibleLw() &&
|
||||
((imeTarget.getAttrs().flags & FLAG_SHOW_WHEN_LOCKED) != 0
|
||||
|| !canBeHiddenByKeyguardLw(imeTarget));
|
||||
final boolean showImeOverKeyguard = imeTarget != null && imeTarget.isVisibleLw()
|
||||
&& (imeTarget.canShowWhenLocked() || !canBeHiddenByKeyguardLw(imeTarget));
|
||||
|
||||
// Show IME over the keyguard if the target allows it
|
||||
boolean allowWhenLocked = (win.isInputMethodWindow() || imeTarget == this)
|
||||
@@ -2280,7 +2279,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
|
||||
if (isKeyguardLocked() && isKeyguardOccluded()) {
|
||||
// Show SHOW_WHEN_LOCKED windows if Keyguard is occluded.
|
||||
allowWhenLocked |= (attrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0
|
||||
allowWhenLocked |= win.canShowWhenLocked()
|
||||
// Show error dialogs over apps that are shown on lockscreen
|
||||
|| (attrs.privateFlags & PRIVATE_FLAG_SYSTEM_ERROR) != 0;
|
||||
}
|
||||
|
||||
@@ -468,6 +468,9 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
|
||||
/** @return true if this window desires key events. */
|
||||
boolean canReceiveKeys();
|
||||
|
||||
/** @return true if the window can show over keyguard. */
|
||||
boolean canShowWhenLocked();
|
||||
|
||||
/**
|
||||
* Writes {@link com.android.server.wm.IdentifierProto} to stream.
|
||||
*/
|
||||
|
||||
@@ -2405,6 +2405,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
&& !cantReceiveTouchInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShowWhenLocked() {
|
||||
final boolean showBecauseOfActivity =
|
||||
mAppToken != null && mAppToken.mActivityRecord.canShowWhenLocked();
|
||||
final boolean showBecauseOfWindow = (getAttrs().flags & FLAG_SHOW_WHEN_LOCKED) != 0;
|
||||
return showBecauseOfActivity || showBecauseOfWindow;
|
||||
}
|
||||
|
||||
/** @return false if this window desires touch events. */
|
||||
boolean cantReceiveTouchInput() {
|
||||
return mAppToken != null && mAppToken.getTask() != null
|
||||
|
||||
Reference in New Issue
Block a user