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

Commit 42d04db4 authored by Craig Mautner's avatar Craig Mautner
Browse files

More fixes for keyguard animations.

Add a state machine for calling comeOutOfSleepIfNeededLocked() so
that it is only called after the lockscreen has started dismissing
but not before resumeTopActivityLocked(). Also keep
resumeTopActivityLocked() from being called from
comeOutOfSleepIfNeededLocked() recursively.

Have starting windows count towards notifying the keyguard that a
window has been drawn.

Do not update wallpaper animations based on their not being included
in the windows being animated if there are no windows being animated.

And always improve logging.

Fixes bug 15991916.

Change-Id: I0d21c5337f0e89d9eacc8dab2cdaa52fec43ac0b
parent 8161ed81
Loading
Loading
Loading
Loading
+21 −10
Original line number Diff line number Diff line
@@ -952,10 +952,13 @@ public final class ActivityManagerService extends ActivityManagerNative
     */
    private boolean mWentToSleep = false;
    static final int LOCK_SCREEN_HIDDEN = 0;
    static final int LOCK_SCREEN_LEAVING = 1;
    static final int LOCK_SCREEN_SHOWN = 2;
    /**
     * State of external call telling us if the lock screen is shown.
     */
    private boolean mLockScreenShown = false;
    int mLockScreenShown = LOCK_SCREEN_HIDDEN;
    /**
     * Set if we are shutting down the system, similar to sleeping.
@@ -6118,9 +6121,8 @@ public final class ActivityManagerService extends ActivityManagerNative
            synchronized (this) {
                if (DEBUG_LOCKSCREEN) logLockScreen("");
                mWindowManager.keyguardWaitingForActivityDrawn();
                if (mLockScreenShown) {
                    mLockScreenShown = false;
                    comeOutOfSleepIfNeededLocked();
                if (mLockScreenShown == LOCK_SCREEN_SHOWN) {
                    mLockScreenShown = LOCK_SCREEN_LEAVING;
                }
            }
        } finally {
@@ -9957,14 +9959,23 @@ public final class ActivityManagerService extends ActivityManagerNative
        Binder.restoreCallingIdentity(origId);
    }
    private String lockScreenShownToString() {
        switch (mLockScreenShown) {
            case LOCK_SCREEN_HIDDEN: return "LOCK_SCREEN_HIDDEN";
            case LOCK_SCREEN_LEAVING: return "LOCK_SCREEN_LEAVING";
            case LOCK_SCREEN_SHOWN: return "LOCK_SCREEN_SHOWN";
            default: return "Unknown=" + mLockScreenShown;
        }
    }
    void logLockScreen(String msg) {
        if (DEBUG_LOCKSCREEN) Slog.d(TAG, Debug.getCallers(2) + ":" + msg +
                " mLockScreenShown=" + mLockScreenShown + " mWentToSleep=" +
                " mLockScreenShown=" + lockScreenShownToString() + " mWentToSleep=" +
                mWentToSleep + " mSleeping=" + mSleeping);
    }
    private void comeOutOfSleepIfNeededLocked() {
        if ((!mWentToSleep && !mLockScreenShown) || mRunningVoice) {
    void comeOutOfSleepIfNeededLocked() {
        if ((!mWentToSleep && mLockScreenShown == LOCK_SCREEN_HIDDEN) || mRunningVoice) {
            if (mSleeping) {
                mSleeping = false;
                mStackSupervisor.comeOutOfSleepIfNeededLocked();
@@ -10001,7 +10012,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            long ident = Binder.clearCallingIdentity();
            try {
                if (DEBUG_LOCKSCREEN) logLockScreen(" shown=" + shown);
                mLockScreenShown = shown;
                mLockScreenShown = shown ? LOCK_SCREEN_SHOWN : LOCK_SCREEN_HIDDEN;
                comeOutOfSleepIfNeededLocked();
            } finally {
                Binder.restoreCallingIdentity(ident);
@@ -12767,9 +12778,9 @@ public final class ActivityManagerService extends ActivityManagerNative
            }
        }
        if (dumpPackage == null) {
            if (mSleeping || mWentToSleep || mLockScreenShown) {
            if (mSleeping || mWentToSleep || mLockScreenShown != LOCK_SCREEN_HIDDEN) {
                pw.println("  mSleeping=" + mSleeping + " mWentToSleep=" + mWentToSleep
                        + " mLockScreenShown " + mLockScreenShown);
                        + " mLockScreenShown " + lockScreenShownToString());
            }
            if (mShuttingDown || mRunningVoice) {
                pw.print("  mShuttingDown=" + mShuttingDown + " mRunningVoice=" + mRunningVoice);
+7 −6
Original line number Diff line number Diff line
@@ -241,9 +241,6 @@ final class ActivityStack {
    /** Run all ActivityStacks through this */
    final ActivityStackSupervisor mStackSupervisor;

    /** Used to keep resumeTopActivityLocked() from being entered recursively */
    private boolean inResumeTopActivity;

    static final int PAUSE_TIMEOUT_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 1;
    static final int DESTROY_TIMEOUT_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 2;
    static final int LAUNCH_TICK_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 3;
@@ -1468,7 +1465,7 @@ final class ActivityStack {
    }

    final boolean resumeTopActivityLocked(ActivityRecord prev, Bundle options) {
        if (inResumeTopActivity) {
        if (mStackSupervisor.inResumeTopActivity) {
            // Don't even start recursing.
            return false;
        }
@@ -1476,10 +1473,14 @@ final class ActivityStack {
        boolean result = false;
        try {
            // Protect against recursion.
            inResumeTopActivity = true;
            mStackSupervisor.inResumeTopActivity = true;
            if (mService.mLockScreenShown == ActivityManagerService.LOCK_SCREEN_LEAVING) {
                mService.mLockScreenShown = ActivityManagerService.LOCK_SCREEN_HIDDEN;
                mService.comeOutOfSleepIfNeededLocked();
            }
            result = resumeTopActivityInnerLocked(prev, options);
        } finally {
            inResumeTopActivity = false;
            mStackSupervisor.inResumeTopActivity = false;
        }
        return result;
    }
+3 −0
Original line number Diff line number Diff line
@@ -274,6 +274,9 @@ public final class ActivityStackSupervisor implements DisplayListener {
    final ArrayList<PendingActivityLaunch> mPendingActivityLaunches
            = new ArrayList<PendingActivityLaunch>();

    /** Used to keep resumeTopActivityLocked() from being entered recursively */
    boolean inResumeTopActivity;

    /**
     * Description of a request to start a new activity, which has been held
     * due to app switches being disabled.
+14 −12
Original line number Diff line number Diff line
@@ -272,6 +272,7 @@ public class WindowAnimator {
            if (winAnimator.mSurfaceControl != null) {
                final boolean wasAnimating = winAnimator.mWasAnimating;
                final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
                mAnimating |= nowAnimating;

                if (WindowManagerService.DEBUG_WALLPAPER) {
                    Slog.v(TAG, win + ": wasAnimating=" + wasAnimating +
@@ -423,7 +424,8 @@ public class WindowAnimator {
            if (mKeyguardGoingAwayDisableWindowAnimations) {
                if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: skipping anim for windows");
            } else {
                if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: created anim for windows");
                if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: created anim for windows="
                        + unForceHiding);
                mPostKeyguardExitAnimation = mPolicy.createForceHideEnterAnimation(
                        wallpaperInUnForceHiding, mKeyguardGoingAwayToNotificationShade);
            }
@@ -434,6 +436,17 @@ public class WindowAnimator {
                    winAnimator.keyguardGoingAwayAnimation = true;
                }
            }

            // Wallpaper is going away in un-force-hide motion, animate it as well.
            if (!wallpaperInUnForceHiding && wallpaper != null
                    && !mKeyguardGoingAwayDisableWindowAnimations) {
                if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
                Animation a = mPolicy.createForceHideWallpaperExitAnimation(
                        mKeyguardGoingAwayToNotificationShade);
                if (a != null) {
                    wallpaper.mWinAnimator.setAnimation(a);
                }
            }
        }

        if (mPostKeyguardExitAnimation != null) {
@@ -448,17 +461,6 @@ public class WindowAnimator {
                mPostKeyguardExitAnimation = null;
            }
        }

        // Wallpaper is going away in un-force-hide motion, animate it as well.
        if (!wallpaperInUnForceHiding && wallpaper != null
                && !mKeyguardGoingAwayDisableWindowAnimations) {
            if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
            Animation a = mPolicy.createForceHideWallpaperExitAnimation(
                    mKeyguardGoingAwayToNotificationShade);
            if (a != null) {
                wallpaper.mWinAnimator.setAnimation(a);
            }
        }
    }

    private void updateWallpaperLocked(int displayId) {
+7 −4
Original line number Diff line number Diff line
@@ -486,8 +486,9 @@ class WindowStateAnimator {
    }

    boolean finishDrawingLocked() {
        if (DEBUG_STARTING_WINDOW &&
                mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
        final boolean startingWindow =
                mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
        if (DEBUG_STARTING_WINDOW && startingWindow) {
            Slog.v(TAG, "Finishing drawing window " + mWin + ": mDrawState="
                    + drawStateToString());
        }
@@ -495,11 +496,13 @@ class WindowStateAnimator {
            if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION)
                Slog.v(TAG, "finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING " + this + " in "
                        + mSurfaceControl);
            if (DEBUG_STARTING_WINDOW &&
                    mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
            if (DEBUG_STARTING_WINDOW && startingWindow) {
                Slog.v(TAG, "Draw state now committed in " + mWin);
            }
            mDrawState = COMMIT_DRAW_PENDING;
            if (startingWindow) {
                mService.notifyActivityDrawnForKeyguard();
            }
            return true;
        }
        return false;