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

Commit 23560758 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Always set correct policy visibility

Windows without a surface didn't get the correct policy visibility
applied after dismissing lockscreen. Thus, when launching something
from lockscreen, home activity was hidden but never set to visible
again. Before executing the transition to home, we didn't consider
home as a wallpaper target because it was still invisible, and thus
we picked the wrong transition.

Always applying policy visibility when lockscreen changes fixes this
outdated state.

Bug: 18369599
Change-Id: I2933eaf0ab55fe31cb382c46c411033e33a756e0
parent 8c8d8b10
Loading
Loading
Loading
Loading
+32 −18
Original line number Original line Diff line number Diff line
@@ -221,6 +221,24 @@ 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;

        final WindowState winShowWhenLocked = (WindowState) mPolicy.getWinShowWhenLockedLw();
        final AppWindowToken appShowWhenLocked = winShowWhenLocked == null ?
                null : winShowWhenLocked.mAppToken;
        final boolean hideWhenLocked =
                !(((win.mIsImWindow || imeTarget == win) && showImeOverKeyguard)
                        || (appShowWhenLocked != null && (appShowWhenLocked == win.mAppToken ||
                        // Show error dialogs over apps that dismiss keyguard.
                        (win.mAttrs.privateFlags & PRIVATE_FLAG_SYSTEM_ERROR) != 0)));
        return ((mForceHiding == KEYGUARD_ANIMATING_IN)
                && (!win.mWinAnimator.isAnimating() || hideWhenLocked))
                || ((mForceHiding == KEYGUARD_SHOWN) && hideWhenLocked);
    }

    private void updateWindowsLocked(final int displayId) {
    private void updateWindowsLocked(final int displayId) {
        ++mAnimTransactionSequence;
        ++mAnimTransactionSequence;


@@ -256,14 +274,6 @@ public class WindowAnimator {


        mForceHiding = KEYGUARD_NOT_SHOWN;
        mForceHiding = KEYGUARD_NOT_SHOWN;


        final WindowState imeTarget = mService.mInputMethodTarget;
        final boolean showImeOverKeyguard = imeTarget != null && imeTarget.isVisibleNow() &&
                (imeTarget.getAttrs().flags & FLAG_SHOW_WHEN_LOCKED) != 0;

        final WindowState winShowWhenLocked = (WindowState) mPolicy.getWinShowWhenLockedLw();
        final AppWindowToken appShowWhenLocked = winShowWhenLocked == null ?
                null : winShowWhenLocked.mAppToken;

        boolean wallpaperInUnForceHiding = false;
        boolean wallpaperInUnForceHiding = false;
        boolean startingInUnForceHiding = false;
        boolean startingInUnForceHiding = false;
        ArrayList<WindowStateAnimator> unForceHiding = null;
        ArrayList<WindowStateAnimator> unForceHiding = null;
@@ -272,7 +282,8 @@ public class WindowAnimator {
            WindowState win = windows.get(i);
            WindowState win = windows.get(i);
            WindowStateAnimator winAnimator = win.mWinAnimator;
            WindowStateAnimator winAnimator = win.mWinAnimator;
            final int flags = win.mAttrs.flags;
            final int flags = win.mAttrs.flags;

            boolean canBeForceHidden = mPolicy.canBeForceHidden(win, win.mAttrs);
            boolean shouldBeForceHidden = shouldForceHide(win);
            if (winAnimator.mSurfaceControl != null) {
            if (winAnimator.mSurfaceControl != null) {
                final boolean wasAnimating = winAnimator.mWasAnimating;
                final boolean wasAnimating = winAnimator.mWasAnimating;
                final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
                final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
@@ -332,15 +343,8 @@ public class WindowAnimator {
                            + " vis=" + win.mViewVisibility
                            + " vis=" + win.mViewVisibility
                            + " hidden=" + win.mRootToken.hidden
                            + " hidden=" + win.mRootToken.hidden
                            + " anim=" + win.mWinAnimator.mAnimation);
                            + " anim=" + win.mWinAnimator.mAnimation);
                } else if (mPolicy.canBeForceHidden(win, win.mAttrs)) {
                } else if (canBeForceHidden) {
                    final boolean hideWhenLocked =
                    if (shouldBeForceHidden) {
                            !(((win.mIsImWindow || imeTarget == win) && showImeOverKeyguard)
                            || (appShowWhenLocked != null && (appShowWhenLocked == win.mAppToken ||
                            // Show error dialogs over apps that dismiss keyguard.
                            (win.mAttrs.privateFlags & PRIVATE_FLAG_SYSTEM_ERROR) != 0)));
                    if (((mForceHiding == KEYGUARD_ANIMATING_IN)
                                && (!winAnimator.isAnimating() || hideWhenLocked))
                            || ((mForceHiding == KEYGUARD_SHOWN) && hideWhenLocked)) {
                        if (!win.hideLw(false, false)) {
                        if (!win.hideLw(false, false)) {
                            // Was already hidden
                            // Was already hidden
                            continue;
                            continue;
@@ -411,6 +415,16 @@ public class WindowAnimator {
                }
                }
            }
            }


            // If the window doesn't have a surface, the only thing we care about is the correct
            // policy visibility.
            else if (canBeForceHidden) {
                if (shouldBeForceHidden) {
                    win.hideLw(false, false);
                } else {
                    win.showLw(false, false);
                }
            }

            final AppWindowToken atoken = win.mAppToken;
            final AppWindowToken atoken = win.mAppToken;
            if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) {
            if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) {
                if (atoken == null || atoken.allDrawn) {
                if (atoken == null || atoken.allDrawn) {