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

Commit e8372308 authored by Shawn Lee's avatar Shawn Lee
Browse files

Deprecate ShadeFoldAnimator and ShadeViewStateProvider

These two interfaces are made redundant by migrateClocksToBlueprint and migrate_keyguard_status_bar_view flags, respectively. Since both are prereqs for Flexiglass, these are effectively dead. There is a single usage of ShadeFoldAnimator.view whose side effect may or may not need to be preserved - this will be added to the shade integration doc. The other remaining usage of view was able to be cleaned up.

Bug: 303267342
Test: existing tests
Test: manually verified isDozing value is the same when folding + locking device.
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: Iacd8f23265e00d4df41c7ab1c9eb6cb650160dd7
parent 2f1213a1
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ interface ShadeViewController {
    val shadeHeadsUpTracker: ShadeHeadsUpTracker

    /** Returns the ShadeFoldAnimator. */
    @Deprecated("This interface is deprecated in Scene Container")
    val shadeFoldAnimator: ShadeFoldAnimator

    companion object {
@@ -183,9 +184,10 @@ interface ShadeHeadsUpTracker {
}

/** Handles the lifecycle of the shade's animation that happens when folding a foldable. */
@Deprecated("This interface should not be used in scene container.")
interface ShadeFoldAnimator {
    /** Updates the views to the initial state for the fold to AOD animation. */
    fun prepareFoldToAodAnimation()
    @Deprecated("Not used when migrateClocksToBlueprint enabled") fun prepareFoldToAodAnimation()

    /**
     * Starts fold to AOD animation.
@@ -194,21 +196,24 @@ interface ShadeFoldAnimator {
     * @param endAction invoked when the animation finishes, also if it was cancelled.
     * @param cancelAction invoked when the animation is cancelled, before endAction.
     */
    @Deprecated("Not used when migrateClocksToBlueprint enabled")
    fun startFoldToAodAnimation(startAction: Runnable, endAction: Runnable, cancelAction: Runnable)

    /** Cancels fold to AOD transition and resets view state. */
    fun cancelFoldToAodAnimation()
    @Deprecated("Not used when migrateClocksToBlueprint enabled") fun cancelFoldToAodAnimation()

    /** Returns the main view of the shade. */
    val view: ViewGroup?
    @Deprecated("Not used in Scene Container") val view: ViewGroup?
}

/**
 * An interface that provides the current state of the notification panel and related views, which
 * is needed to calculate [KeyguardStatusBarView]'s state in [KeyguardStatusBarViewController].
 */
@Deprecated("This interface should not be used in scene container.")
interface ShadeViewStateProvider {
    /** Returns the expanded height of the panel view. */
    @Deprecated("deprecated by migrate_keyguard_status_bar_view flag")
    val panelViewExpandedHeight: Float

    /**
@@ -217,8 +222,9 @@ interface ShadeViewStateProvider {
     * TODO(b/138786270): If HeadsUpAppearanceController was injectable, we could inject it into
     *   [KeyguardStatusBarViewController] and remove this method.
     */
    fun shouldHeadsUpBeVisible(): Boolean
    @Deprecated("deprecated in Flexiglass.") fun shouldHeadsUpBeVisible(): Boolean

    /** Return the fraction of the shade that's expanded, when in lockscreen. */
    @Deprecated("deprecated by migrate_keyguard_status_bar_view flag")
    val lockscreenShadeDragProgress: Float
}
+7 −21
Original line number Diff line number Diff line
@@ -21,15 +21,12 @@ import android.content.Context
import android.hardware.devicestate.DeviceStateManager
import android.os.PowerManager
import android.provider.Settings
import androidx.annotation.VisibleForTesting
import androidx.core.view.OneShotPreDrawListener
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.internal.util.LatencyTracker
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.shade.ShadeFoldAnimator
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.statusbar.LightRevealScrim
@@ -40,9 +37,6 @@ import com.android.systemui.unfold.FoldAodAnimationController.FoldAodAnimationSt
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.settings.GlobalSettings
import dagger.Lazy
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import java.util.function.Consumer
import javax.inject.Inject

@@ -69,7 +63,6 @@ constructor(
    private var isFoldHandled = true

    private var alwaysOnEnabled: Boolean = false
    private var isDozing: Boolean = false
    private var isScrimOpaque: Boolean = false
    private var pendingScrimReadyCallback: Runnable? = null

@@ -97,11 +90,6 @@ constructor(

        deviceStateManager.registerCallback(mainExecutor, FoldListener())
        wakefulnessLifecycle.addObserver(this)

        // TODO(b/254878364): remove this call to NPVC.getView()
        getShadeFoldAnimator().view?.repeatWhenAttached {
            repeatOnLifecycle(Lifecycle.State.STARTED) { listenForDozing(this) }
        }
    }

    /** Returns true if we should run fold to AOD animation */
@@ -158,7 +146,8 @@ constructor(
            } else {
                pendingScrimReadyCallback = onReady
            }
        } else if (isFolded && !isFoldHandled && alwaysOnEnabled && isDozing) {
        } else if (isFolded && !isFoldHandled && alwaysOnEnabled &&
                keyguardInteractor.get().isDozing.value) {
            setAnimationState(playing = true)
            getShadeFoldAnimator().prepareFoldToAodAnimation()

@@ -166,9 +155,11 @@ constructor(
            // but we should wait for the initial animation preparations to be drawn
            // (setting initial alpha/translation)
            // TODO(b/254878364): remove this call to NPVC.getView()
            if (!migrateClocksToBlueprint()) {
                getShadeFoldAnimator().view?.let {
                    OneShotPreDrawListener.add(it, onReady)
                }
            }
        } else {
            // No animation, call ready callback immediately
            onReady.run()
@@ -233,11 +224,6 @@ constructor(
        statusListeners.remove(listener)
    }

    @VisibleForTesting
    internal suspend fun listenForDozing(scope: CoroutineScope): Job {
        return scope.launch { keyguardInteractor.get().isDozing.collect { isDozing = it } }
    }

    interface FoldAodAnimationStatus {
        fun onFoldToAodAnimationChanged()
    }
+0 −25
Original line number Diff line number Diff line
@@ -133,47 +133,34 @@ class FoldAodAnimationControllerTest : SysuiTestCase() {
    @Test
    fun onFolded_aodDisabled_doesNotLogLatency() =
        runBlocking(IMMEDIATE) {
            val job = underTest.listenForDozing(this)
            keyguardRepository.setIsDozing(true)
            setAodEnabled(enabled = false)

            yield()

            fold()
            simulateScreenTurningOn()

            verifyNoMoreInteractions(latencyTracker)

            job.cancel()
        }

    @Test
    fun onFolded_aodEnabled_logsLatency() =
        runBlocking(IMMEDIATE) {
            val job = underTest.listenForDozing(this)
            keyguardRepository.setIsDozing(true)
            setAodEnabled(enabled = true)

            yield()

            fold()
            simulateScreenTurningOn()

            verify(latencyTracker).onActionStart(any())
            verify(latencyTracker).onActionEnd(any())

            job.cancel()
        }

    @Test
    fun onFolded_onScreenTurningOnInvokedTwice_doesNotLogLatency() =
        runBlocking(IMMEDIATE) {
            val job = underTest.listenForDozing(this)
            keyguardRepository.setIsDozing(true)
            setAodEnabled(enabled = true)

            yield()

            fold()
            simulateScreenTurningOn()
            reset(latencyTracker)
@@ -183,19 +170,14 @@ class FoldAodAnimationControllerTest : SysuiTestCase() {

            verify(latencyTracker, never()).onActionStart(any())
            verify(latencyTracker, never()).onActionEnd(any())

            job.cancel()
        }

    @Test
    fun onFolded_onScreenTurningOnWithoutDozingThenWithDozing_doesNotLogLatency() =
        runBlocking(IMMEDIATE) {
            val job = underTest.listenForDozing(this)
            keyguardRepository.setIsDozing(false)
            setAodEnabled(enabled = true)

            yield()

            fold()
            simulateScreenTurningOn()
            reset(latencyTracker)
@@ -208,19 +190,14 @@ class FoldAodAnimationControllerTest : SysuiTestCase() {

            verify(latencyTracker, never()).onActionStart(any())
            verify(latencyTracker, never()).onActionEnd(any())

            job.cancel()
        }

    @Test
    fun onFolded_animationCancelled_doesNotLogLatency() =
        runBlocking(IMMEDIATE) {
            val job = underTest.listenForDozing(this)
            keyguardRepository.setIsDozing(true)
            setAodEnabled(enabled = true)

            yield()

            fold()
            underTest.onScreenTurningOn({})
            // The body of onScreenTurningOn is executed on fakeExecutor,
@@ -230,8 +207,6 @@ class FoldAodAnimationControllerTest : SysuiTestCase() {

            verify(latencyTracker).onActionStart(any())
            verify(latencyTracker).onActionCancel(any())

            job.cancel()
        }

    private fun simulateScreenTurningOn() {