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

Commit 54eab3b3 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

Fix issue with lifecycle of Activities launched from Lockscreen

ActivityManager still thinks the device is going to sleep, so
any Activity started while the lockscreen is showing is immediately
stopped. When Keyguard calls ActivityManager.keyguardWaitingForActivityDraw(),
then we must make sure that the ActivityManager thinks we are not sleeping.

Bug:17459745
Change-Id: I5c45c88e3a72e1f08e1b32101d0d0b4675f7a5ff
parent 689d491d
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -936,6 +936,13 @@ public final class ActivityManagerService extends ActivityManagerNative
     */
    private boolean mRunningVoice = false;
    /**
     * Set while the keyguard is waiting for an activity to draw.
     * In this state, if we are sleeping, we allow Activities to launch
     * so that they can draw before Keyguard dismisses itself.
     */
    private boolean mKeyguardWaitingForDraw = false;
    /**
     * State of external calls telling us if the device is asleep.
     */
@@ -6204,6 +6211,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            synchronized (this) {
                if (DEBUG_LOCKSCREEN) logLockScreen("");
                mWindowManager.keyguardWaitingForActivityDrawn();
                mKeyguardWaitingForDraw = true;
            }
        } finally {
            Binder.restoreCallingIdentity(token);
@@ -9897,11 +9905,11 @@ public final class ActivityManagerService extends ActivityManagerNative
    // Actually is sleeping or shutting down or whatever else in the future
    // is an inactive state.
    public boolean isSleepingOrShuttingDown() {
        return mSleeping || mShuttingDown;
        return isSleeping() || mShuttingDown;
    }
    public boolean isSleeping() {
        return mSleeping;
        return mSleeping && !mKeyguardWaitingForDraw;
    }
    void goingToSleep() {
@@ -9923,6 +9931,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        if (mWentToSleep && !mRunningVoice) {
            if (!mSleeping) {
                mSleeping = true;
                mKeyguardWaitingForDraw = false;
                mStackSupervisor.goingToSleepLocked();
                // Initialize the wake times of all processes.
@@ -10032,6 +10041,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            try {
                if (DEBUG_LOCKSCREEN) logLockScreen(" shown=" + shown);
                mLockScreenShown = shown;
                mKeyguardWaitingForDraw = false;
                comeOutOfSleepIfNeededLocked();
            } finally {
                Binder.restoreCallingIdentity(ident);