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

Commit 66fc5b3c authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Transitions - Add GONE state" into tm-qpr-dev

parents 247c1260 02dc8128
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -237,6 +237,9 @@ class DefaultClockController(
    ) {
        var isActive: Boolean = fraction < 0.5f
        fun update(newFraction: Float): Pair<Boolean, Boolean> {
            if (newFraction == fraction) {
                return Pair(isActive, false)
            }
            val wasActive = isActive
            val hasJumped =
                (fraction == 0f && newFraction == 1f) || (fraction == 1f && newFraction == 0f)
+23 −2
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.systemui.flags.Flags.DOZING_MIGRATION_1
import com.android.systemui.flags.Flags.REGION_SAMPLING
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.log.dagger.KeyguardClockLog
import com.android.systemui.plugins.ClockController
@@ -47,6 +48,7 @@ import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.launch
import java.io.PrintWriter
import java.util.Locale
@@ -186,10 +188,12 @@ open class ClockEventController @Inject constructor(
    private val keyguardUpdateMonitorCallback = object : KeyguardUpdateMonitorCallback() {
        override fun onKeyguardVisibilityChanged(visible: Boolean) {
            isKeyguardVisible = visible
            if (!featureFlags.isEnabled(DOZING_MIGRATION_1)) {
                if (!isKeyguardVisible) {
                    clock?.animations?.doze(if (isDozing) 1f else 0f)
                }
            }
        }

        override fun onTimeFormatChanged(timeFormat: String) {
            clock?.events?.onTimeFormatChanged(DateFormat.is24HourFormat(context))
@@ -224,6 +228,7 @@ open class ClockEventController @Inject constructor(
                listenForDozing(this)
                if (featureFlags.isEnabled(DOZING_MIGRATION_1)) {
                    listenForDozeAmountTransition(this)
                    listenForGoneToAodTransition(this)
                } else {
                    listenForDozeAmount(this)
                }
@@ -276,6 +281,22 @@ open class ClockEventController @Inject constructor(
        }
    }

    /**
     * When keyguard is displayed again after being gone, the clock must be reset to full
     * dozing.
     */
    @VisibleForTesting
    internal fun listenForGoneToAodTransition(scope: CoroutineScope): Job {
        return scope.launch {
            keyguardTransitionInteractor.goneToAodTransition.filter {
                it.transitionState == TransitionState.STARTED
            }.collect {
                dozeAmount = 1f
                clock?.animations?.doze(dozeAmount)
            }
        }
    }

    @VisibleForTesting
    internal fun listenForDozing(scope: CoroutineScope): Job {
        return scope.launch {
+9 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel
import com.android.systemui.plugins.log.LogLevel.DEBUG
import com.android.systemui.plugins.log.LogLevel.ERROR
import com.android.systemui.plugins.log.LogLevel.INFO
import com.android.systemui.plugins.log.LogLevel.VERBOSE
import com.android.systemui.plugins.log.LogLevel.WARNING
import com.android.systemui.plugins.log.MessageInitializer
@@ -50,6 +51,14 @@ class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuf
        buffer.log(TAG, DEBUG, messageInitializer, messagePrinter)
    }

    fun v(msg: String, arg: Any) {
        buffer.log(TAG, VERBOSE, { str1 = arg.toString() }, { "$msg: $str1" })
    }

    fun i(msg: String, arg: Any) {
        buffer.log(TAG, INFO, { str1 = arg.toString() }, { "$msg: $str1" })
    }

    // TODO: remove after b/237743330 is fixed
    fun logStatusBarCalculatedAlpha(alpha: Float) {
        debugLog({ double1 = alpha.toDouble() }, { "Calculated new alpha: $double1" })
+2 −1
Original line number Diff line number Diff line
@@ -122,7 +122,8 @@ object Flags {
     * Migration from the legacy isDozing/dozeAmount paths to the new KeyguardTransitionRepository
     * will occur in stages. This is one stage of many to come.
     */
    @JvmField val DOZING_MIGRATION_1 = UnreleasedFlag(213, teamfood = true)
    // TODO(b/255607168): Tracking Bug
    @JvmField val DOZING_MIGRATION_1 = UnreleasedFlag(213)

    // 300 - power menu
    // TODO(b/254512600): Tracking Bug
+51 −0
Original line number Diff line number Diff line
@@ -21,7 +21,10 @@ import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCall
import com.android.systemui.common.shared.model.Position
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.doze.DozeHost
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.keyguard.WakefulnessLifecycle.Wakefulness
import com.android.systemui.keyguard.shared.model.StatusBarState
import com.android.systemui.keyguard.shared.model.WakefulnessModel
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.policy.KeyguardStateController
import javax.inject.Inject
@@ -89,6 +92,9 @@ interface KeyguardRepository {
    /** Observable for the [StatusBarState] */
    val statusBarState: Flow<StatusBarState>

    /** Observable for device wake/sleep state */
    val wakefulnessState: Flow<WakefulnessModel>

    /**
     * Returns `true` if the keyguard is showing; `false` otherwise.
     *
@@ -118,6 +124,7 @@ constructor(
    statusBarStateController: StatusBarStateController,
    private val keyguardStateController: KeyguardStateController,
    dozeHost: DozeHost,
    wakefulnessLifecycle: WakefulnessLifecycle,
) : KeyguardRepository {
    private val _animateBottomAreaDozingTransitions = MutableStateFlow(false)
    override val animateBottomAreaDozingTransitions =
@@ -207,6 +214,40 @@ constructor(
        awaitClose { statusBarStateController.removeCallback(callback) }
    }

    override val wakefulnessState: Flow<WakefulnessModel> = conflatedCallbackFlow {
        val callback =
            object : WakefulnessLifecycle.Observer {
                override fun onStartedWakingUp() {
                    trySendWithFailureLogging(
                        WakefulnessModel.STARTING_TO_WAKE,
                        TAG,
                        "Wakefulness: starting to wake"
                    )
                }
                override fun onFinishedWakingUp() {
                    trySendWithFailureLogging(WakefulnessModel.AWAKE, TAG, "Wakefulness: awake")
                }
                override fun onStartedGoingToSleep() {
                    trySendWithFailureLogging(
                        WakefulnessModel.STARTING_TO_SLEEP,
                        TAG,
                        "Wakefulness: starting to sleep"
                    )
                }
                override fun onFinishedGoingToSleep() {
                    trySendWithFailureLogging(WakefulnessModel.ASLEEP, TAG, "Wakefulness: asleep")
                }
            }
        wakefulnessLifecycle.addObserver(callback)
        trySendWithFailureLogging(
            wakefulnessIntToObject(wakefulnessLifecycle.getWakefulness()),
            TAG,
            "initial wakefulness state"
        )

        awaitClose { wakefulnessLifecycle.removeObserver(callback) }
    }

    override fun setAnimateDozingTransitions(animate: Boolean) {
        _animateBottomAreaDozingTransitions.value = animate
    }
@@ -228,6 +269,16 @@ constructor(
        }
    }

    private fun wakefulnessIntToObject(@Wakefulness value: Int): WakefulnessModel {
        return when (value) {
            0 -> WakefulnessModel.ASLEEP
            1 -> WakefulnessModel.STARTING_TO_WAKE
            2 -> WakefulnessModel.AWAKE
            3 -> WakefulnessModel.STARTING_TO_SLEEP
            else -> throw IllegalArgumentException("Invalid Wakefulness value: $value")
        }
    }

    companion object {
        private const val TAG = "KeyguardRepositoryImpl"
    }
Loading