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

Commit 012f6bc7 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed an issue where a user could't go to the locked shade from dozing

When waking up, the status bar state was immediately reset, stopping
the transition. We now migrate the behavior from the pulse expansion
to the ls shade transition controller and wait a bit longer.

Fixes: 201341772
Test: click on expand from pulsing
Change-Id: Ie7caa06b45c3fd4c2aec72dfecf82e76e06ff3f2
parent d36f3eb7
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe
        }
        setWakefulness(WAKEFULNESS_AWAKE);
        dispatch(Observer::onFinishedWakingUp);
        dispatch(Observer::onPostFinishedWakingUp);
    }

    public void dispatchStartedGoingToSleep(@PowerManager.GoToSleepReason int pmSleepReason) {
@@ -236,6 +237,12 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe
    public interface Observer {
        default void onStartedWakingUp() {}
        default void onFinishedWakingUp() {}

        /**
         * Called after the finished waking up call, ensuring it's after all the other listeners,
         * reacting to {@link #onFinishedWakingUp()}
         */
        default void onPostFinishedWakingUp() {}
        default void onStartedGoingToSleep() {}
        default void onFinishedGoingToSleep() {}
    }
+20 −1
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@ import android.animation.ValueAnimator
import android.content.Context
import android.content.res.Configuration
import android.os.SystemClock
import android.util.DisplayMetrics
import android.util.IndentingPrintWriter
import android.util.MathUtils
import android.view.MotionEvent
@@ -24,6 +23,7 @@ import com.android.systemui.classifier.Classifier
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.media.MediaHierarchyManager
import com.android.systemui.plugins.ActivityStarter.OnDismissAction
import com.android.systemui.plugins.FalsingManager
@@ -64,6 +64,7 @@ class LockscreenShadeTransitionController @Inject constructor(
    private val scrimController: ScrimController,
    private val depthController: NotificationShadeDepthController,
    private val context: Context,
    wakefulnessLifecycle: WakefulnessLifecycle,
    configurationController: ConfigurationController,
    falsingManager: FalsingManager,
    dumpManager: DumpManager,
@@ -119,6 +120,12 @@ class LockscreenShadeTransitionController @Inject constructor(
     */
    private var nextHideKeyguardNeedsNoAnimation = false

    /**
     * Are we currently waking up to the shade locked
     */
    var isWakingToShadeLocked: Boolean = false
        private set

    /**
     * The distance until we're showing the notifications when pulsing
     */
@@ -160,6 +167,13 @@ class LockscreenShadeTransitionController @Inject constructor(
                }
            }
        })
        wakefulnessLifecycle.addObserver(object : WakefulnessLifecycle.Observer {
            override fun onPostFinishedWakingUp() {
                // when finishing waking up, the UnlockedScreenOffAnimation has another attempt
                // to reset keyguard. Let's do it in post
                isWakingToShadeLocked = false
            }
        })
    }

    private fun updateResources() {
@@ -488,6 +502,10 @@ class LockscreenShadeTransitionController @Inject constructor(
            draggedDownEntry = entry
        } else {
            logger.logGoingToLockedShade(animationHandler != null)
            if (statusBarStateController.isDozing) {
                // Make sure we don't go back to keyguard immediately again after waking up
                isWakingToShadeLocked = true
            }
            statusBarStateController.setState(StatusBarState.SHADE_LOCKED)
            // This call needs to be after updating the shade state since otherwise
            // the scrimstate resets too early
@@ -598,6 +616,7 @@ class LockscreenShadeTransitionController @Inject constructor(
            it.println("dragDownAmount: $dragDownAmount")
            it.println("isDragDownAnywhereEnabled: $isDragDownAnywhereEnabled")
            it.println("isFalsingCheckNeeded: $isFalsingCheckNeeded")
            it.println("isWakingToShadeLocked: $isWakingToShadeLocked")
            it.println("hasPendingHandlerOnKeyguardDismiss: " +
                "${animationHandlerOnKeyguardDismiss != null}")
        }
+0 −8
Original line number Diff line number Diff line
@@ -107,8 +107,6 @@ constructor(
    private var mDraggedFarEnough: Boolean = false
    private var mStartingChild: ExpandableView? = null
    private var mPulsing: Boolean = false
    var isWakingToShadeLocked: Boolean = false
        private set

    private var velocityTracker: VelocityTracker? = null

@@ -235,7 +233,6 @@ constructor(
            mStartingChild = null
        }
        if (statusBarStateController.isDozing) {
            isWakingToShadeLocked = true
            wakeUpCoordinator.willWakeUp = true
            mPowerManager!!.wakeUp(SystemClock.uptimeMillis(), WAKE_REASON_GESTURE,
                    "com.android.systemui:PULSEDRAG")
@@ -333,10 +330,6 @@ constructor(
        mPulsing = pulsing
    }

    fun onStartedWakingUp() {
        isWakingToShadeLocked = false
    }

    override fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array<out String>) {
        IndentingPrintWriter(pw, "  ").let {
            it.println("PulseExpansionHandler:")
@@ -344,7 +337,6 @@ constructor(
            it.println("isExpanding: $isExpanding")
            it.println("leavingLockscreen: $leavingLockscreen")
            it.println("mPulsing: $mPulsing")
            it.println("isWakingToShadeLocked: $isWakingToShadeLocked")
            it.println("qsExpanded: $qsExpanded")
            it.println("bouncerShowing: $bouncerShowing")
        }
+1 −2
Original line number Diff line number Diff line
@@ -2965,7 +2965,7 @@ public class StatusBar extends SystemUI implements
        mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
        if (mUserSwitcherController != null && mUserSwitcherController.useFullscreenUserSwitcher()) {
            mStatusBarStateController.setState(StatusBarState.FULLSCREEN_USER_SWITCHER);
        } else if (!mPulseExpansionHandler.isWakingToShadeLocked()) {
        } else if (!mLockscreenShadeTransitionController.isWakingToShadeLocked()) {
            mStatusBarStateController.setState(StatusBarState.KEYGUARD);
        }
        updatePanelExpansionForKeyguard();
@@ -3570,7 +3570,6 @@ public class StatusBar extends SystemUI implements
            // once we fully woke up.
            updateRevealEffect(true /* wakingUp */);
            updateNotificationPanelTouchState();
            mPulseExpansionHandler.onStartedWakingUp();

            // If we are waking up during the screen off animation, we should undo making the
            // expanded visible (we did that so the LightRevealScrim would be visible).
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ public class WakefulnessLifecycleTest extends SysuiTestCase {
        assertEquals(WakefulnessLifecycle.WAKEFULNESS_AWAKE, mWakefulness.getWakefulness());

        verify(mWakefulnessObserver).onFinishedWakingUp();
        verify(mWakefulnessObserver).onPostFinishedWakingUp();
    }

    @Test
Loading