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

Commit 0950ca8a authored by Nick Chameyev's avatar Nick Chameyev
Browse files

Reset NotificationPanelView when pressing power button before fold to AOD animation

When we hit power button during folding: before
fold to AOD transition starts but after we prepared
the starting params of NotificationPanelView it remained
in this state (alpha = 0, translation = -x). So it led
to an issue that user don't see the keyguard.

Added logic that resets this view to its original
state when we are waking up and the animation hasn't
started yet.

Bug: 215703534
Test: fold and quickly press power button
 => check that keyguard is visible
Test: fold to AOD and press power button => keyguard visible
Test: lock/unlock using power button
Change-Id: I88b79aca462137723e174f2f4196cbd08d71f664
parent 615951d1
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -3896,6 +3896,15 @@ public class NotificationPanelViewController extends PanelViewController {
        mKeyguardStatusViewController.animateFoldToAod();
        mKeyguardStatusViewController.animateFoldToAod();
    }
    }


    /**
     * Cancels fold to AOD transition and resets view state
     */
    public void cancelFoldToAodAnimation() {
        cancelAnimation();
        resetAlpha();
        resetTranslation();
    }

    /** */
    /** */
    public void setImportantForAccessibility(int mode) {
    public void setImportantForAccessibility(int mode) {
        mView.setImportantForAccessibility(mode);
        mView.setImportantForAccessibility(mode);
@@ -4014,6 +4023,10 @@ public class NotificationPanelViewController extends PanelViewController {
        mView.setTranslationX(0f);
        mView.setTranslationX(0f);
    }
    }


    public void resetAlpha() {
        mView.setAlpha(1f);
    }

    public ViewPropertyAnimator fadeOut(long startDelayMs, long durationMs, Runnable endAction) {
    public ViewPropertyAnimator fadeOut(long startDelayMs, long durationMs, Runnable endAction) {
        return mView.animate().alpha(0).setStartDelay(startDelayMs).setDuration(
        return mView.animate().alpha(0).setStartDelay(startDelayMs).setDuration(
                durationMs).setInterpolator(Interpolators.ALPHA_OUT).withLayer().withEndAction(
                durationMs).setInterpolator(Interpolators.ALPHA_OUT).withLayer().withEndAction(
+3 −3
Original line number Original line Diff line number Diff line
@@ -3001,7 +3001,7 @@ public class StatusBar extends CoreStartable implements
    }
    }


    private void onLaunchTransitionFadingEnded() {
    private void onLaunchTransitionFadingEnded() {
        mNotificationPanelViewController.setAlpha(1.0f);
        mNotificationPanelViewController.resetAlpha();
        mNotificationPanelViewController.onAffordanceLaunchEnded();
        mNotificationPanelViewController.onAffordanceLaunchEnded();
        releaseGestureWakeLock();
        releaseGestureWakeLock();
        runLaunchTransitionEndRunnable();
        runLaunchTransitionEndRunnable();
@@ -3032,7 +3032,7 @@ public class StatusBar extends CoreStartable implements
            }
            }
            updateScrimController();
            updateScrimController();
            mPresenter.updateMediaMetaData(false, true);
            mPresenter.updateMediaMetaData(false, true);
            mNotificationPanelViewController.setAlpha(1);
            mNotificationPanelViewController.resetAlpha();
            mNotificationPanelViewController.fadeOut(
            mNotificationPanelViewController.fadeOut(
                    FADE_KEYGUARD_START_DELAY, FADE_KEYGUARD_DURATION,
                    FADE_KEYGUARD_START_DELAY, FADE_KEYGUARD_DURATION,
                    this::onLaunchTransitionFadingEnded);
                    this::onLaunchTransitionFadingEnded);
@@ -3133,7 +3133,7 @@ public class StatusBar extends CoreStartable implements
        releaseGestureWakeLock();
        releaseGestureWakeLock();
        mNotificationPanelViewController.onAffordanceLaunchEnded();
        mNotificationPanelViewController.onAffordanceLaunchEnded();
        mNotificationPanelViewController.cancelAnimation();
        mNotificationPanelViewController.cancelAnimation();
        mNotificationPanelViewController.setAlpha(1f);
        mNotificationPanelViewController.resetAlpha();
        mNotificationPanelViewController.resetTranslation();
        mNotificationPanelViewController.resetTranslation();
        mNotificationPanelViewController.resetViewGroupFade();
        mNotificationPanelViewController.resetViewGroupFade();
        updateDozingState();
        updateDozingState();
+20 −5
Original line number Original line Diff line number Diff line
@@ -16,8 +16,10 @@


package com.android.systemui.unfold
package com.android.systemui.unfold


import android.os.Handler
import android.os.PowerManager
import android.os.PowerManager
import android.provider.Settings
import android.provider.Settings
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.KeyguardViewMediator
import com.android.systemui.keyguard.KeyguardViewMediator
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.statusbar.LightRevealScrim
import com.android.systemui.statusbar.LightRevealScrim
@@ -37,6 +39,7 @@ import javax.inject.Inject
class FoldAodAnimationController
class FoldAodAnimationController
@Inject
@Inject
constructor(
constructor(
    @Main private val handler: Handler,
    private val keyguardViewMediatorLazy: Lazy<KeyguardViewMediator>,
    private val keyguardViewMediatorLazy: Lazy<KeyguardViewMediator>,
    private val wakefulnessLifecycle: WakefulnessLifecycle,
    private val wakefulnessLifecycle: WakefulnessLifecycle,
    private val globalSettings: GlobalSettings
    private val globalSettings: GlobalSettings
@@ -50,6 +53,14 @@ constructor(
    private var shouldPlayAnimation = false
    private var shouldPlayAnimation = false
    private val statusListeners = arrayListOf<FoldAodAnimationStatus>()
    private val statusListeners = arrayListOf<FoldAodAnimationStatus>()


    private val startAnimationRunnable = Runnable {
        statusBar.notificationPanelViewController.startFoldToAodAnimation {
            // End action
            isAnimationPlaying = false
            keyguardViewMediatorLazy.get().maybeHandlePendingLock()
        }
    }

    private var isAnimationPlaying = false
    private var isAnimationPlaying = false


    override fun initialize(statusBar: StatusBar, lightRevealScrim: LightRevealScrim) {
    override fun initialize(statusBar: StatusBar, lightRevealScrim: LightRevealScrim) {
@@ -79,6 +90,11 @@ constructor(
        }
        }


    override fun onStartedWakingUp() {
    override fun onStartedWakingUp() {
        if (isAnimationPlaying) {
            handler.removeCallbacks(startAnimationRunnable)
            statusBar.notificationPanelViewController.cancelFoldToAodAnimation();
        }

        shouldPlayAnimation = false
        shouldPlayAnimation = false
        isAnimationPlaying = false
        isAnimationPlaying = false
    }
    }
@@ -115,11 +131,10 @@ constructor(


    fun onScreenTurnedOn() {
    fun onScreenTurnedOn() {
        if (shouldPlayAnimation) {
        if (shouldPlayAnimation) {
            statusBar.notificationPanelViewController.startFoldToAodAnimation {
            handler.removeCallbacks(startAnimationRunnable)
                // End action

                isAnimationPlaying = false
            // Post starting the animation to the next frame to avoid junk due to inset changes
                keyguardViewMediatorLazy.get().maybeHandlePendingLock()
            handler.post(startAnimationRunnable)
            }
            shouldPlayAnimation = false
            shouldPlayAnimation = false
        }
        }
    }
    }