Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 461829d6 authored by Adrian Roos's avatar Adrian Roos
Browse files

Prevent windows below the keyguard from showing

Fixes a bug where windows below the lock screen
could become visible if a SHOW_WHEN_LOCKED activity
hides the status bar.

Bug: 21450145
Change-Id: Ie660394cb96d7e6839bd4fb7c2729133bac2dfc5
parent d3c9df1a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1057,6 +1057,13 @@ public interface WindowManagerPolicy {
     */
    public boolean isKeyguardSecure();

    /**
     * Return whether the keyguard is on.
     *
     * @return true if in keyguard is on.
     */
    public boolean isKeyguardShowingOrOccluded();

    /**
     * inKeyguardRestrictedKeyInputMode
     *
+9 −1
Original line number Diff line number Diff line
@@ -2116,7 +2116,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case TYPE_KEYGUARD_SCRIM:
                return false;
            default:
                return true;
                // Hide only windows below the keyguard host window.
                return windowTypeToLayerLw(win.getBaseType())
                        < windowTypeToLayerLw(TYPE_STATUS_BAR);
        }
    }

@@ -5515,6 +5517,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return mKeyguardDelegate.isSecure();
    }

    /** {@inheritDoc} */
    @Override
    public boolean isKeyguardShowingOrOccluded() {
        return mKeyguardDelegate == null ? false : mKeyguardDelegate.isShowing();
    }

    /** {@inheritDoc} */
    @Override
    public boolean inKeyguardRestrictedKeyInputMode() {
+9 −3
Original line number Diff line number Diff line
@@ -191,7 +191,8 @@ public class WindowAnimator {
    private boolean shouldForceHide(WindowState win) {
        final WindowState imeTarget = mService.mInputMethodTarget;
        final boolean showImeOverKeyguard = imeTarget != null && imeTarget.isVisibleNow() &&
                (imeTarget.getAttrs().flags & FLAG_SHOW_WHEN_LOCKED) != 0;
                ((imeTarget.getAttrs().flags & FLAG_SHOW_WHEN_LOCKED) != 0
                        || !mPolicy.canBeForceHidden(imeTarget, imeTarget.mAttrs));

        final WindowState winShowWhenLocked = (WindowState) mPolicy.getWinShowWhenLockedLw();
        final AppWindowToken appShowWhenLocked = winShowWhenLocked == null ?
@@ -203,7 +204,11 @@ public class WindowAnimator {
                        || (win.mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0 && win.isAnimatingLw()
                        // Show error dialogs over apps that dismiss keyguard.
                        || (win.mAttrs.privateFlags & PRIVATE_FLAG_SYSTEM_ERROR) != 0)));
        return (mForceHiding == KEYGUARD_SHOWN) && hideWhenLocked;

        // Only hide windows if the keyguard is active and not animating away.
        boolean keyguardOn = mPolicy.isKeyguardShowingOrOccluded()
                && mForceHiding != KEYGUARD_ANIMATING_OUT;
        return keyguardOn && hideWhenLocked;
    }

    private void updateWindowsLocked(final int displayId) {
@@ -228,6 +233,7 @@ public class WindowAnimator {
                        winAnimator.mAnimation.setDuration(KEYGUARD_ANIM_TIMEOUT_MS);
                        winAnimator.mAnimationIsEntrance = false;
                        winAnimator.mAnimationStartTime = -1;
                        winAnimator.mKeyguardGoingAwayAnimation = true;
                    }
                } else {
                    if (DEBUG_KEYGUARD) Slog.d(TAG,
@@ -310,7 +316,7 @@ public class WindowAnimator {
                        mKeyguardGoingAway = false;
                    }
                    if (win.isReadyForDisplay()) {
                        if (nowAnimating) {
                        if (nowAnimating && win.mWinAnimator.mKeyguardGoingAwayAnimation) {
                            mForceHiding = KEYGUARD_ANIMATING_OUT;
                        } else {
                            mForceHiding = win.isDrawnLw() ? KEYGUARD_SHOWN : KEYGUARD_NOT_SHOWN;