Loading packages/SystemUI/shared/src/com/android/systemui/shared/clocks/DefaultClockController.kt +3 −0 Original line number Diff line number Diff line Loading @@ -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) Loading packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +23 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -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)) Loading Loading @@ -224,6 +228,7 @@ open class ClockEventController @Inject constructor( listenForDozing(this) if (featureFlags.isEnabled(DOZING_MIGRATION_1)) { listenForDozeAmountTransition(this) listenForGoneToAodTransition(this) } else { listenForDozeAmount(this) } Loading Loading @@ -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 { Loading packages/SystemUI/src/com/android/keyguard/logging/KeyguardLogger.kt +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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" }) Loading packages/SystemUI/src/com/android/systemui/flags/Flags.kt +2 −1 Original line number Diff line number Diff line Loading @@ -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 Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +51 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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. * Loading Loading @@ -118,6 +124,7 @@ constructor( statusBarStateController: StatusBarStateController, private val keyguardStateController: KeyguardStateController, dozeHost: DozeHost, wakefulnessLifecycle: WakefulnessLifecycle, ) : KeyguardRepository { private val _animateBottomAreaDozingTransitions = MutableStateFlow(false) override val animateBottomAreaDozingTransitions = Loading Loading @@ -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 } Loading @@ -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 Loading
packages/SystemUI/shared/src/com/android/systemui/shared/clocks/DefaultClockController.kt +3 −0 Original line number Diff line number Diff line Loading @@ -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) Loading
packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +23 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -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)) Loading Loading @@ -224,6 +228,7 @@ open class ClockEventController @Inject constructor( listenForDozing(this) if (featureFlags.isEnabled(DOZING_MIGRATION_1)) { listenForDozeAmountTransition(this) listenForGoneToAodTransition(this) } else { listenForDozeAmount(this) } Loading Loading @@ -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 { Loading
packages/SystemUI/src/com/android/keyguard/logging/KeyguardLogger.kt +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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" }) Loading
packages/SystemUI/src/com/android/systemui/flags/Flags.kt +2 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +51 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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. * Loading Loading @@ -118,6 +124,7 @@ constructor( statusBarStateController: StatusBarStateController, private val keyguardStateController: KeyguardStateController, dozeHost: DozeHost, wakefulnessLifecycle: WakefulnessLifecycle, ) : KeyguardRepository { private val _animateBottomAreaDozingTransitions = MutableStateFlow(false) override val animateBottomAreaDozingTransitions = Loading Loading @@ -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 } Loading @@ -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