From 8b19369a4bea5c0c2c2546e095aff1a52ad95f33 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Mon, 13 Mar 2023 13:03:28 -0700 Subject: [PATCH] Fix sidefps visibility. In ag/21915461, there seems to be a regression where the side fps does not hide when the bouncer hides. This is likely caused by a race condition between the visibility and when startingToHide is called. We can fix this by updating the side fps visibility when hide is called instead of startingToHide. Fixes: 273563764 Bug: 263924084 Test: added a unit test. Test: Show bouncer with side fps and hide the bouncer. Change-Id: Idacf9e74ed3c0f7c2a03d5dd6ffa128b49c50c05 --- .../ui/viewmodel/KeyguardBouncerViewModel.kt | 2 +- .../ui/viewmodel/KeyguardBouncerViewModelTest.kt | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBouncerViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBouncerViewModel.kt index 68910c65e5084..0656c9baa9210 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBouncerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBouncerViewModel.kt @@ -70,7 +70,7 @@ constructor( /** Observe whether we should update fps is showing. */ val shouldUpdateSideFps: Flow = merge( - interactor.startingToHide, + interactor.hide, interactor.show, interactor.startingDisappearAnimation.filterNotNull().map {} ) diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBouncerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBouncerViewModelTest.kt index e66be08426a52..2ab1b99b7feef 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBouncerViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBouncerViewModelTest.kt @@ -93,7 +93,7 @@ class KeyguardBouncerViewModelTest : SysuiTestCase() { } @Test - fun shouldUpdateSideFps() = runTest { + fun shouldUpdateSideFps_show() = runTest { var count = 0 val job = underTest.shouldUpdateSideFps.onEach { count++ }.launchIn(this) repository.setPrimaryShow(true) @@ -103,6 +103,18 @@ class KeyguardBouncerViewModelTest : SysuiTestCase() { job.cancel() } + @Test + fun shouldUpdateSideFps_hide() = runTest { + repository.setPrimaryShow(true) + var count = 0 + val job = underTest.shouldUpdateSideFps.onEach { count++ }.launchIn(this) + repository.setPrimaryShow(false) + // Run the tasks that are pending at this point of virtual time. + runCurrent() + assertThat(count).isEqualTo(1) + job.cancel() + } + @Test fun sideFpsShowing() = runTest { var sideFpsIsShowing = false