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

Commit e29ff090 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge changes from topic "tsuji-wakeup" into tm-qpr-dev

* changes:
  Create AnimatorTestRule2 which avoids the test interaction bugs with the original as it currently exists
  Keep the clock centered until the delayed doze animation plays.
  Delay the dozeAmount change animation.
  Run ktfmt on NotificationWakeUpCoordinator.kt
  Restructure the NotificationWakeUpCoordinator's dozeAmount recalculation.
  Tell NotificationWakeupCoordinator if we're waking from power button w/ SFPS press-to-unlock.
parents 1a033981 6de9be16
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -254,6 +254,7 @@ public final class NotificationPanelViewController implements Dumpable {
    public static final float FLING_SPEED_UP_FACTOR = 0.6f;
    public static final float FLING_CLOSING_MAX_LENGTH_SECONDS = 0.6f;
    public static final float FLING_CLOSING_SPEED_UP_FACTOR = 0.6f;
    public static final int WAKEUP_ANIMATION_DELAY_MS = 250;
    private static final boolean DEBUG_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.DEBUG);
    private static final boolean SPEW_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE);
    private static final boolean DEBUG_DRAWABLE = false;
@@ -276,6 +277,7 @@ public final class NotificationPanelViewController implements Dumpable {
    private static final int NO_FIXED_DURATION = -1;
    private static final long SHADE_OPEN_SPRING_OUT_DURATION = 350L;
    private static final long SHADE_OPEN_SPRING_BACK_DURATION = 400L;

    /**
     * The factor of the usual high velocity that is needed in order to reach the maximum overshoot
     * when flinging. A low value will make it that most flings will reach the maximum overshoot.
@@ -588,6 +590,12 @@ public final class NotificationPanelViewController implements Dumpable {
    private boolean mGestureWaitForTouchSlop;
    private boolean mIgnoreXTouchSlop;
    private boolean mExpandLatencyTracking;
    /**
     * Whether we're waking up and will play the delayed doze animation in
     * {@link NotificationWakeUpCoordinator}. If so, we'll want to keep the clock centered until the
     * delayed doze animation starts.
     */
    private boolean mWillPlayDelayedDozeAmountAnimation = false;
    private final DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel;
    private final OccludedToLockscreenTransitionViewModel mOccludedToLockscreenTransitionViewModel;
    private final LockscreenToDreamingTransitionViewModel mLockscreenToDreamingTransitionViewModel;
@@ -1044,6 +1052,12 @@ public final class NotificationPanelViewController implements Dumpable {
                    requestScrollerTopPaddingUpdate(false /* animate */);
                }
            }

            @Override
            public void onDelayedDozeAmountAnimationRunning(boolean running) {
                // On running OR finished, the animation is no longer waiting to play
                setWillPlayDelayedDozeAmountAnimation(false);
            }
        });

        mView.setRtlChangeListener(layoutDirection -> {
@@ -1640,11 +1654,28 @@ public final class NotificationPanelViewController implements Dumpable {
            // Pulsing notification appears on the right. Move clock left to avoid overlap.
            return false;
        }
        if (mWillPlayDelayedDozeAmountAnimation) {
            return true;
        }
        // "Visible" notifications are actually not visible on AOD (unless pulsing), so it is safe
        // to center the clock without overlap.
        return isOnAod();
    }

    /**
     * Notify us that {@link NotificationWakeUpCoordinator} is going to play the doze wakeup
     * animation after a delay. If so, we'll keep the clock centered until that animation starts.
     */
    public void setWillPlayDelayedDozeAmountAnimation(boolean willPlay) {
        if (mWillPlayDelayedDozeAmountAnimation == willPlay) return;

        mWillPlayDelayedDozeAmountAnimation = willPlay;
        mWakeUpCoordinator.logDelayingClockWakeUpAnimation(willPlay);

        // Once changing this value, see if we should move the clock.
        positionClockAndNotifications();
    }

    private boolean isOnAod() {
        return mDozing && mDozeParameters.getAlwaysOn();
    }
+258 −114

File changed.

Preview size limit exceeded, changes collapsed.

+106 −19
Original line number Diff line number Diff line
@@ -22,50 +22,75 @@ import javax.inject.Inject
class NotificationWakeUpCoordinatorLogger
@Inject
constructor(@NotificationLockscreenLog private val buffer: LogBuffer) {
    private var lastSetDozeAmountLogWasFractional = false
    private var allowThrottle = true
    private var lastSetDozeAmountLogInputWasFractional = false
    private var lastSetDozeAmountLogDelayWasFractional = false
    private var lastSetDozeAmountLogState = -1
    private var lastSetDozeAmountLogSource = "undefined"
    private var lastSetHardOverride: Float? = null
    private var lastOnDozeAmountChangedLogWasFractional = false
    private var lastSetDelayDozeAmountOverrideLogWasFractional = false
    private var lastSetVisibilityAmountLogWasFractional = false
    private var lastSetHideAmountLogWasFractional = false
    private var lastSetHideAmount = -1f

    fun logSetDozeAmount(
        linear: Float,
        eased: Float,
        source: String,
    fun logUpdateDozeAmount(
        inputLinear: Float,
        delayLinear: Float,
        hardOverride: Float?,
        outputLinear: Float,
        state: Int,
        changed: Boolean,
    ) {
        // Avoid logging on every frame of the animation if important values are not changing
        val isFractional = linear != 1f && linear != 0f
        val isInputFractional = inputLinear != 1f && inputLinear != 0f
        val isDelayFractional = delayLinear != 1f && delayLinear != 0f
        if (
            lastSetDozeAmountLogWasFractional &&
                isFractional &&
            (isInputFractional || isDelayFractional) &&
                lastSetDozeAmountLogInputWasFractional == isInputFractional &&
                lastSetDozeAmountLogDelayWasFractional == isDelayFractional &&
                lastSetDozeAmountLogState == state &&
                lastSetDozeAmountLogSource == source
                lastSetHardOverride == hardOverride &&
                allowThrottle
        ) {
            return
        }
        lastSetDozeAmountLogWasFractional = isFractional
        lastSetDozeAmountLogInputWasFractional = isInputFractional
        lastSetDozeAmountLogDelayWasFractional = isDelayFractional
        lastSetDozeAmountLogState = state
        lastSetDozeAmountLogSource = source
        lastSetHardOverride = hardOverride

        buffer.log(
            TAG,
            DEBUG,
            {
                double1 = linear.toDouble()
                str2 = eased.toString()
                str3 = source
                double1 = inputLinear.toDouble()
                str1 = hardOverride.toString()
                str2 = outputLinear.toString()
                str3 = delayLinear.toString()
                int1 = state
                bool1 = changed
            },
            {
                "setDozeAmount(linear=$double1, eased=$str2, source=$str3)" +
                "updateDozeAmount() inputLinear=$double1 delayLinear=$str3" +
                    " hardOverride=$str1 outputLinear=$str2" +
                    " state=${StatusBarState.toString(int1)} changed=$bool1"
            }
        )
    }

    fun logMaybeClearDozeAmountOverrideHidingNotifs(
    fun logSetDozeAmountOverride(dozing: Boolean, source: String) {
        buffer.log(
            TAG,
            DEBUG,
            {
                bool1 = dozing
                str1 = source
            },
            { "setDozeAmountOverride(dozing=$bool1, source=\"$str1\")" }
        )
    }

    fun logMaybeClearHardDozeAmountOverrideHidingNotifs(
        willRemove: Boolean,
        onKeyguard: Boolean,
        dozing: Boolean,
@@ -80,14 +105,14 @@ constructor(@NotificationLockscreenLog private val buffer: LogBuffer) {
                    "willRemove=$willRemove onKeyguard=$onKeyguard dozing=$dozing" +
                        " bypass=$bypass animating=$animating"
            },
            { "maybeClearDozeAmountOverrideHidingNotifs() $str1" }
            { "maybeClearHardDozeAmountOverrideHidingNotifs() $str1" }
        )
    }

    fun logOnDozeAmountChanged(linear: Float, eased: Float) {
        // Avoid logging on every frame of the animation when values are fractional
        val isFractional = linear != 1f && linear != 0f
        if (lastOnDozeAmountChangedLogWasFractional && isFractional) return
        if (lastOnDozeAmountChangedLogWasFractional && isFractional && allowThrottle) return
        lastOnDozeAmountChangedLogWasFractional = isFractional
        buffer.log(
            TAG,
@@ -100,6 +125,47 @@ constructor(@NotificationLockscreenLog private val buffer: LogBuffer) {
        )
    }

    fun logSetDelayDozeAmountOverride(linear: Float) {
        // Avoid logging on every frame of the animation when values are fractional
        val isFractional = linear != 1f && linear != 0f
        if (lastSetDelayDozeAmountOverrideLogWasFractional && isFractional && allowThrottle) return
        lastSetDelayDozeAmountOverrideLogWasFractional = isFractional
        buffer.log(
            TAG,
            DEBUG,
            { double1 = linear.toDouble() },
            { "setDelayDozeAmountOverride($double1)" }
        )
    }

    fun logSetVisibilityAmount(linear: Float) {
        // Avoid logging on every frame of the animation when values are fractional
        val isFractional = linear != 1f && linear != 0f
        if (lastSetVisibilityAmountLogWasFractional && isFractional && allowThrottle) return
        lastSetVisibilityAmountLogWasFractional = isFractional
        buffer.log(TAG, DEBUG, { double1 = linear.toDouble() }, { "setVisibilityAmount($double1)" })
    }

    fun logSetHideAmount(linear: Float) {
        // Avoid logging the same value repeatedly
        if (lastSetHideAmount == linear && allowThrottle) return
        lastSetHideAmount = linear
        // Avoid logging on every frame of the animation when values are fractional
        val isFractional = linear != 1f && linear != 0f
        if (lastSetHideAmountLogWasFractional && isFractional && allowThrottle) return
        lastSetHideAmountLogWasFractional = isFractional
        buffer.log(TAG, DEBUG, { double1 = linear.toDouble() }, { "setHideAmount($double1)" })
    }

    fun logStartDelayedDozeAmountAnimation(alreadyRunning: Boolean) {
        buffer.log(
            TAG,
            DEBUG,
            { bool1 = alreadyRunning },
            { "startDelayedDozeAmountAnimation() alreadyRunning=$bool1" }
        )
    }

    fun logOnStateChanged(newState: Int, storedState: Int) {
        buffer.log(
            TAG,
@@ -114,6 +180,27 @@ constructor(@NotificationLockscreenLog private val buffer: LogBuffer) {
            }
        )
    }

    fun logSetWakingUp(wakingUp: Boolean, requestDelayedAnimation: Boolean) {
        buffer.log(
            TAG,
            DEBUG,
            {
                bool1 = wakingUp
                bool2 = requestDelayedAnimation
            },
            { "setWakingUp(wakingUp=$bool1, requestDelayedAnimation=$bool2)" }
        )
    }

    fun logDelayingClockWakeUpAnimation(delayingAnimation: Boolean) {
        buffer.log(
            TAG,
            DEBUG,
            { bool1 = delayingAnimation },
            { "logDelayingClockWakeUpAnimation($bool1)" }
        )
    }
}

private const val TAG = "NotificationWakeUpCoordinator"
+1 −0
Original line number Diff line number Diff line
@@ -5565,6 +5565,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    public void setDozeAmount(float dozeAmount) {
        mAmbientState.setDozeAmount(dozeAmount);
        updateContinuousBackgroundDrawing();
        updateStackPosition();
        requestChildrenUpdate();
    }

+4 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.systemui.shade.NotificationShadeWindowView;
import com.android.systemui.shade.NotificationShadeWindowViewController;
import com.android.systemui.statusbar.LightRevealScrim;
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.util.Compile;

import java.io.PrintWriter;

@@ -71,6 +72,7 @@ public interface CentralSurfaces extends Dumpable, ActivityStarter, LifecycleOwn
    boolean DEBUG_MEDIA_FAKE_ARTWORK = false;
    boolean DEBUG_CAMERA_LIFT = false;
    boolean DEBUG_WINDOW_STATE = false;
    boolean DEBUG_WAKEUP_DELAY = Compile.IS_DEBUG;
    // additional instrumentation for testing purposes; intended to be left on during development
    boolean CHATTY = DEBUG;
    boolean SHOW_LOCKSCREEN_MEDIA_ARTWORK = true;
@@ -536,6 +538,8 @@ public interface CentralSurfaces extends Dumpable, ActivityStarter, LifecycleOwn

    void extendDozePulse();

    boolean shouldDelayWakeUpAnimation();

    public static class KeyboardShortcutsMessage {
        final int mDeviceId;

Loading