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 Diff line number Diff line
@@ -3896,6 +3896,15 @@ public class NotificationPanelViewController extends PanelViewController {
        mKeyguardStatusViewController.animateFoldToAod();
    }

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

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

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

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

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

package com.android.systemui.unfold

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

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

    private var isAnimationPlaying = false

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

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

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

    fun onScreenTurnedOn() {
        if (shouldPlayAnimation) {
            statusBar.notificationPanelViewController.startFoldToAodAnimation {
                // End action
                isAnimationPlaying = false
                keyguardViewMediatorLazy.get().maybeHandlePendingLock()
            }
            handler.removeCallbacks(startAnimationRunnable)

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