Fix Color Clock on AOD

When region sampling text protection was enabled, AOD clock was changing
from white clock to lockscreen's colored clock because
animateAppearOnLockscreen() was being triggered by
onRegionDarknessChanged(). To remedy this, we now ensure that
animateAppearOnLockscreen() cannot be called when animation doze state
is active (AOD mode). Since animateDoze() already handles the clock
color change when going from lockscreen to AOD mode, there is no need
for animateAppearOnLockscreen() to be called since the clock color
never changes in AOD mode.

Test: atest test_aodClock_always_whiteColor
Fixes: 258852242
Change-Id: I45484db37c7a728b1c71eacd8c162b580e59f820
This commit is contained in:
Florence Yang
2022-11-15 00:51:13 +00:00
parent b67434ebea
commit cb59b0b7f4
2 changed files with 14 additions and 3 deletions

View File

@@ -128,7 +128,9 @@ class DefaultClockController(
currentColor = color
view.setColors(DOZE_COLOR, color)
view.animateAppearOnLockscreen()
if (!animations.dozeState.isActive) {
view.animateAppearOnLockscreen()
}
}
}
@@ -188,7 +190,7 @@ class DefaultClockController(
dozeFraction: Float,
foldFraction: Float,
) : ClockAnimations {
private val dozeState = AnimationState(dozeFraction)
internal val dozeState = AnimationState(dozeFraction)
private val foldState = AnimationState(foldFraction)
init {
@@ -229,7 +231,7 @@ class DefaultClockController(
get() = true
}
private class AnimationState(
class AnimationState(
var fraction: Float,
) {
var isActive: Boolean = fraction > 0.5f

View File

@@ -43,6 +43,7 @@ import org.mockito.ArgumentMatchers.anyFloat
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.notNull
import org.mockito.Mock
import org.mockito.Mockito.never
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when` as whenever
@@ -171,4 +172,12 @@ class DefaultClockProviderTest : SysuiTestCase() {
verify(mockSmallClockView, times(2)).refreshFormat()
verify(mockLargeClockView, times(2)).refreshFormat()
}
@Test
fun test_aodClock_always_whiteColor() {
val clock = provider.createClock(DEFAULT_CLOCK_ID)
clock.animations.doze(0.9f) // set AOD mode to active
clock.smallClock.events.onRegionDarknessChanged(true)
verify((clock.smallClock.view as AnimatableClockView), never()).animateAppearOnLockscreen()
}
}