diff options
| author | 2025-01-17 19:33:47 +0000 | |
|---|---|---|
| committer | 2025-01-17 21:24:03 +0000 | |
| commit | b13098414f40ac577a643fbccd35a0cf5246d2ff (patch) | |
| tree | 60b2cfb74ee2e2a71e01af953f234ac14179e5a2 | |
| parent | d096f4ce6a0f5a9e38cd34d0f543fa23a9f65d1f (diff) | |
Listen for screen power changes in ClockEventController
To reduce impact this only refreshes the clock, instead of all elements
of the AOD display. The remaining elements may not update until the
minute rolls over.
Bug: 390191659
Test: Manually reproduced issue
Flag: NONE Targetted minimal bug fix
Change-Id: I3a3329d9b9a29f5452572ec23812b3e4edd2a378
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/ClockEventController.kt | 25 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt | 3 |
2 files changed, 23 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt index 71b622aa0608..9b852df88604 100644 --- a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +++ b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt @@ -61,6 +61,8 @@ import com.android.systemui.plugins.clocks.ClockTickRate import com.android.systemui.plugins.clocks.WeatherData import com.android.systemui.plugins.clocks.ZenData import com.android.systemui.plugins.clocks.ZenData.ZenMode +import com.android.systemui.power.domain.interactor.PowerInteractor +import com.android.systemui.power.shared.model.ScreenPowerState import com.android.systemui.res.R as SysuiR import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.settings.UserTracker @@ -106,6 +108,7 @@ constructor( private val zenModeController: ZenModeController, private val zenModeInteractor: ZenModeInteractor, private val userTracker: UserTracker, + private val powerInteractor: PowerInteractor, ) { var loggers = listOf( @@ -377,13 +380,13 @@ constructor( override fun onTimeChanged() { refreshTime() } - - private fun refreshTime() { - clock?.smallClock?.events?.onTimeTick() - clock?.largeClock?.events?.onTimeTick() - } } + private fun refreshTime() { + clock?.smallClock?.events?.onTimeTick() + clock?.largeClock?.events?.onTimeTick() + } + @VisibleForTesting internal fun listenForDnd(scope: CoroutineScope): Job { ModesUi.assertInNewMode() @@ -474,6 +477,7 @@ constructor( listenForAnyStateToAodTransition(this) listenForAnyStateToLockscreenTransition(this) listenForAnyStateToDozingTransition(this) + listenForScreenPowerOn(this) } } smallTimeListener?.update(shouldTimeListenerRun) @@ -643,6 +647,17 @@ constructor( } } + @VisibleForTesting + internal fun listenForScreenPowerOn(scope: CoroutineScope): Job { + return scope.launch { + powerInteractor.screenPowerState.collect { powerState -> + if (powerState != ScreenPowerState.SCREEN_OFF) { + refreshTime() + } + } + } + } + class TimeListener(val clockFace: ClockFaceController, val executor: DelayableExecutor) { val predrawListener = ViewTreeObserver.OnPreDrawListener { diff --git a/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt index bac2c47f51c7..1729a4dfa945 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt @@ -55,6 +55,7 @@ import com.android.systemui.plugins.clocks.ClockTickRate import com.android.systemui.plugins.clocks.ThemeConfig import com.android.systemui.plugins.clocks.ZenData import com.android.systemui.plugins.clocks.ZenData.ZenMode +import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.res.R import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.policy.BatteryController @@ -131,6 +132,7 @@ class ClockEventControllerTest : SysuiTestCase() { @Mock private lateinit var parentView: View @Mock private lateinit var keyguardTransitionInteractor: KeyguardTransitionInteractor @Mock private lateinit var userTracker: UserTracker + @Mock private lateinit var powerInteractor: PowerInteractor @Mock private lateinit var zenModeController: ZenModeController private var zenModeControllerCallback: ZenModeController.Callback? = null @@ -178,6 +180,7 @@ class ClockEventControllerTest : SysuiTestCase() { zenModeController, zenModeInteractor, userTracker, + powerInteractor, ) underTest.clock = clock |