diff options
| author | 2024-02-01 14:51:37 +0000 | |
|---|---|---|
| committer | 2024-02-06 13:30:07 +0000 | |
| commit | df39b4913778bf13e8a94cb82b2db06b44666fa8 (patch) | |
| tree | 18ccafd1c3ea5368c647c11cd269047f7c65ce18 | |
| parent | 70bc7fb10a800bec1cdbb6f83a4cfa341f7f64a2 (diff) | |
Fix AOD icon flicker during GONE->AOD
Visibility was being changed during GONE-AOD transition. Disallow this
and make sure the alpha/visibility states are consistent
Fixes: 322157767
Test: atest KeyguardRootViewModelTest
Test: use GONE->AOD and observe notif icons state changes
Flag: ACONFIG com.android.systemui.keyguard_shade_migration_nssl
DEVELOPMENT
Change-Id: I321d80232799bc649840a35feba598c8281c454e
3 files changed, 40 insertions, 6 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt index 2de013bc7abc..c23ec2290d6a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt @@ -116,6 +116,23 @@ class KeyguardRootViewModelTest : SysuiTestCase() { } @Test + fun iconContainer_isNotVisible_onKeyguard_dontShowWhenGoneToAodTransitionRunning() = + testScope.runTest { + val isVisible by collectLastValue(underTest.isNotifIconContainerVisible) + runCurrent() + keyguardTransitionRepository.sendTransitionSteps( + from = KeyguardState.GONE, + to = KeyguardState.AOD, + testScope, + ) + whenever(screenOffAnimationController.shouldShowAodIconsWhenShade()).thenReturn(false) + runCurrent() + + assertThat(isVisible?.value).isFalse() + assertThat(isVisible?.isAnimating).isFalse() + } + + @Test fun iconContainer_isVisible_bypassEnabled() = testScope.runTest { val isVisible by collectLastValue(underTest.isNotifIconContainerVisible) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt index 789d30ff1a31..eb11c3f6c457 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt @@ -145,9 +145,7 @@ object KeyguardRootViewBinder { launch { viewModel.burnInLayerVisibility.collect { visibility -> childViews[burnInLayerId]?.visibility = visibility - // Reset alpha only for the icons, as they currently have their - // own animator - childViews[aodNotificationIconContainerId]?.alpha = 0f + childViews[aodNotificationIconContainerId]?.visibility = visibility } } @@ -435,11 +433,17 @@ object KeyguardRootViewBinder { } when { !isVisible.isAnimating -> { - alpha = 1f if (!KeyguardShadeMigrationNssl.isEnabled) { translationY = 0f } - visibility = if (isVisible.value) View.VISIBLE else View.INVISIBLE + visibility = + if (isVisible.value) { + alpha = 1f + View.VISIBLE + } else { + alpha = 0f + View.INVISIBLE + } } newAodTransition() -> { animateInIconTranslation() diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt index f8a12bd226ad..ec13228c6216 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt @@ -30,6 +30,8 @@ import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.KeyguardState.AOD import com.android.systemui.keyguard.shared.model.KeyguardState.GONE import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN +import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING +import com.android.systemui.keyguard.shared.model.TransitionState.STARTED import com.android.systemui.statusbar.notification.domain.interactor.NotificationsKeyguardInteractor import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.ScreenOffAnimationController @@ -48,6 +50,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.merge +import kotlinx.coroutines.flow.onStart @OptIn(ExperimentalCoroutinesApi::class) @SysUISingleton @@ -78,6 +81,12 @@ constructor( val goneToAodTransition = keyguardTransitionInteractor.transition(from = GONE, to = AOD) + private val goneToAodTransitionRunning: Flow<Boolean> = + goneToAodTransition + .map { it.transitionState == STARTED || it.transitionState == RUNNING } + .onStart { emit(false) } + .distinctUntilChanged() + /** Last point that the root view was tapped */ val lastRootViewTapPosition: Flow<Point?> = keyguardInteractor.lastRootViewTapPosition @@ -138,6 +147,7 @@ constructor( /** Is the notification icon container visible? */ val isNotifIconContainerVisible: Flow<AnimatedValue<Boolean>> = combine( + goneToAodTransitionRunning, keyguardTransitionInteractor.finishedKeyguardState.map { KeyguardState.lockscreenVisibleInState(it) }, @@ -145,6 +155,7 @@ constructor( areNotifsFullyHiddenAnimated(), isPulseExpandingAnimated(), ) { + goneToAodTransitionRunning: Boolean, onKeyguard: Boolean, isBypassEnabled: Boolean, notifsFullyHidden: AnimatedValue<Boolean>, @@ -154,7 +165,9 @@ constructor( // Hide the AOD icons if we're not in the KEYGUARD state unless the screen off // animation is playing, in which case we want them to be visible if we're // animating in the AOD UI and will be switching to KEYGUARD shortly. - !onKeyguard && !screenOffAnimationController.shouldShowAodIconsWhenShade() -> + goneToAodTransitionRunning || + (!onKeyguard && + !screenOffAnimationController.shouldShowAodIconsWhenShade()) -> AnimatedValue.NotAnimating(false) else -> zip(notifsFullyHidden, pulseExpanding) { |