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:
lumark
2019-01-10 20:48:18 +08:00
parent 560e9f2713
commit 31e4f8ec21
3 changed files with 14 additions and 4 deletions

View File

@@ -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;
}

View File

@@ -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.
*/

View File

@@ -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