diff options
| author | 2023-08-01 16:25:51 +0000 | |
|---|---|---|
| committer | 2023-08-02 13:13:50 +0000 | |
| commit | b4aa1593ace9fb3c0c2750eb112f465da0083e41 (patch) | |
| tree | 41c335e0fa950fb76c4271eecfc7f2f4339edd98 | |
| parent | 8228c296e837a8809e2611c43b22da6e25244dbd (diff) | |
Don't show lockscreen after using bouncer
When the bouncer is programatically invoked, the lockscreen content
will remain visible briefly after unlock. If the user swipes up to
show the bouncer, the animation runs correctly. Ensure the lockscreen
alpha is 0 during the PRIMARY_BOUNCER->GONE transition.
Fixes: 283226063
Test: atest PrimaryBouncerToGoneTransitionViewModelTest
Change-Id: I55257397dde6270c8340b6868c15839d75579ab6
4 files changed, 78 insertions, 26 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt index 44e1fd157cf9..cca96b7830c5 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt @@ -66,6 +66,23 @@ constructor( }, ) + /** Lockscreen alpha */ + val lockscreenAlpha: Flow<Float> = + transitionAnimation.createFlow( + duration = 50.milliseconds, + onStart = { + leaveShadeOpen = statusBarStateController.leaveOpenOnKeyguardHide() + willRunDismissFromKeyguard = primaryBouncerInteractor.willRunDismissFromKeyguard() + }, + onStep = { + if (willRunDismissFromKeyguard || leaveShadeOpen) { + 1f + } else { + 0f + } + }, + ) + /** Scrim alpha values */ val scrimAlpha: Flow<ScrimAlpha> = transitionAnimation diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 2ea63c2a9847..416f147b7429 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -147,6 +147,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel; import com.android.systemui.keyguard.ui.viewmodel.LockscreenToDreamingTransitionViewModel; import com.android.systemui.keyguard.ui.viewmodel.LockscreenToOccludedTransitionViewModel; import com.android.systemui.keyguard.ui.viewmodel.OccludedToLockscreenTransitionViewModel; +import com.android.systemui.keyguard.ui.viewmodel.PrimaryBouncerToGoneTransitionViewModel; import com.android.systemui.media.controls.pipeline.MediaDataManager; import com.android.systemui.media.controls.ui.KeyguardMediaController; import com.android.systemui.media.controls.ui.MediaHierarchyManager; @@ -602,6 +603,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mGoneToDreamingLockscreenHostedTransitionViewModel; private final LockscreenToOccludedTransitionViewModel mLockscreenToOccludedTransitionViewModel; + private final PrimaryBouncerToGoneTransitionViewModel mPrimaryBouncerToGoneTransitionViewModel; private final KeyguardTransitionInteractor mKeyguardTransitionInteractor; private final KeyguardInteractor mKeyguardInteractor; @@ -761,6 +763,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump GoneToDreamingLockscreenHostedTransitionViewModel goneToDreamingLockscreenHostedTransitionViewModel, LockscreenToOccludedTransitionViewModel lockscreenToOccludedTransitionViewModel, + PrimaryBouncerToGoneTransitionViewModel primaryBouncerToGoneTransitionViewModel, @Main CoroutineDispatcher mainDispatcher, KeyguardTransitionInteractor keyguardTransitionInteractor, DumpManager dumpManager, @@ -790,6 +793,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mGoneToDreamingLockscreenHostedTransitionViewModel = goneToDreamingLockscreenHostedTransitionViewModel; mLockscreenToOccludedTransitionViewModel = lockscreenToOccludedTransitionViewModel; + mPrimaryBouncerToGoneTransitionViewModel = primaryBouncerToGoneTransitionViewModel; mKeyguardTransitionInteractor = keyguardTransitionInteractor; mKeyguardInteractor = keyguardInteractor; mKeyguardViewConfigurator = keyguardViewConfigurator; @@ -1172,6 +1176,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump collectFlow(mView, mLockscreenToOccludedTransitionViewModel.lockscreenTranslationY( mLockscreenToOccludedTransitionTranslationY), setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); + + // Primary bouncer->Gone (ensures lockscreen content is not visible on successful auth) + collectFlow(mView, mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha(), + setTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher); } @VisibleForTesting diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt index d8c78ebdca49..904662ed9210 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt @@ -21,6 +21,7 @@ import androidx.test.filters.SmallTest import com.android.systemui.RoboPilotTest import com.android.systemui.SysuiTestCase import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor +import com.android.systemui.coroutines.collectValues import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory import com.android.systemui.keyguard.shared.model.KeyguardState @@ -31,8 +32,6 @@ import com.android.systemui.statusbar.SysuiStatusBarStateController import com.android.systemui.util.mockito.whenever import com.google.common.collect.Range import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runTest @@ -75,9 +74,7 @@ class PrimaryBouncerToGoneTransitionViewModelTest : SysuiTestCase() { @Test fun bouncerAlpha() = runTest(UnconfinedTestDispatcher()) { - val values = mutableListOf<Float>() - - val job = underTest.bouncerAlpha.onEach { values.add(it) }.launchIn(this) + val values by collectValues(underTest.bouncerAlpha) repository.sendTransitionStep(step(0f, TransitionState.STARTED)) repository.sendTransitionStep(step(0.3f)) @@ -85,16 +82,12 @@ class PrimaryBouncerToGoneTransitionViewModelTest : SysuiTestCase() { assertThat(values.size).isEqualTo(3) values.forEach { assertThat(it).isIn(Range.closed(0f, 1f)) } - - job.cancel() } @Test fun bouncerAlpha_runDimissFromKeyguard() = runTest(UnconfinedTestDispatcher()) { - val values = mutableListOf<Float>() - - val job = underTest.bouncerAlpha.onEach { values.add(it) }.launchIn(this) + val values by collectValues(underTest.bouncerAlpha) whenever(primaryBouncerInteractor.willRunDismissFromKeyguard()).thenReturn(true) @@ -104,16 +97,52 @@ class PrimaryBouncerToGoneTransitionViewModelTest : SysuiTestCase() { assertThat(values.size).isEqualTo(3) values.forEach { assertThat(it).isEqualTo(0f) } + } + + @Test + fun lockscreenAlpha() = + runTest(UnconfinedTestDispatcher()) { + val values by collectValues(underTest.lockscreenAlpha) + + repository.sendTransitionStep(step(0f, TransitionState.STARTED)) + repository.sendTransitionStep(step(1f)) - job.cancel() + assertThat(values.size).isEqualTo(2) + values.forEach { assertThat(it).isEqualTo(0f) } } @Test - fun scrimAlpha_runDimissFromKeyguard() = + fun lockscreenAlpha_runDimissFromKeyguard() = runTest(UnconfinedTestDispatcher()) { - val values = mutableListOf<ScrimAlpha>() + val values by collectValues(underTest.lockscreenAlpha) - val job = underTest.scrimAlpha.onEach { values.add(it) }.launchIn(this) + whenever(primaryBouncerInteractor.willRunDismissFromKeyguard()).thenReturn(true) + + repository.sendTransitionStep(step(0f, TransitionState.STARTED)) + repository.sendTransitionStep(step(1f)) + + assertThat(values.size).isEqualTo(2) + values.forEach { assertThat(it).isEqualTo(1f) } + } + + @Test + fun lockscreenAlpha_leaveShadeOpen() = + runTest(UnconfinedTestDispatcher()) { + val values by collectValues(underTest.lockscreenAlpha) + + whenever(statusBarStateController.leaveOpenOnKeyguardHide()).thenReturn(true) + + repository.sendTransitionStep(step(0f, TransitionState.STARTED)) + repository.sendTransitionStep(step(1f)) + + assertThat(values.size).isEqualTo(2) + values.forEach { assertThat(it).isEqualTo(1f) } + } + + @Test + fun scrimAlpha_runDimissFromKeyguard() = + runTest(UnconfinedTestDispatcher()) { + val values by collectValues(underTest.scrimAlpha) whenever(primaryBouncerInteractor.willRunDismissFromKeyguard()).thenReturn(true) @@ -124,16 +153,12 @@ class PrimaryBouncerToGoneTransitionViewModelTest : SysuiTestCase() { assertThat(values.size).isEqualTo(4) values.forEach { assertThat(it).isEqualTo(ScrimAlpha()) } - - job.cancel() } @Test fun scrimBehindAlpha_leaveShadeOpen() = runTest(UnconfinedTestDispatcher()) { - val values = mutableListOf<ScrimAlpha>() - - val job = underTest.scrimAlpha.onEach { values.add(it) }.launchIn(this) + val values by collectValues(underTest.scrimAlpha) whenever(statusBarStateController.leaveOpenOnKeyguardHide()).thenReturn(true) @@ -146,16 +171,12 @@ class PrimaryBouncerToGoneTransitionViewModelTest : SysuiTestCase() { values.forEach { assertThat(it).isEqualTo(ScrimAlpha(notificationsAlpha = 1f, behindAlpha = 1f)) } - - job.cancel() } @Test fun scrimBehindAlpha_doNotLeaveShadeOpen() = runTest(UnconfinedTestDispatcher()) { - val values = mutableListOf<ScrimAlpha>() - - val job = underTest.scrimAlpha.onEach { values.add(it) }.launchIn(this) + val values by collectValues(underTest.scrimAlpha) whenever(statusBarStateController.leaveOpenOnKeyguardHide()).thenReturn(false) @@ -169,8 +190,6 @@ class PrimaryBouncerToGoneTransitionViewModelTest : SysuiTestCase() { values.forEach { assertThat(it.frontAlpha).isEqualTo(0f) } values.forEach { assertThat(it.behindAlpha).isIn(Range.closed(0f, 1f)) } assertThat(values[3].behindAlpha).isEqualTo(0f) - - job.cancel() } private fun step( diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java index 9bcc8aa0ac12..40d9cc7f837c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -106,6 +106,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel; import com.android.systemui.keyguard.ui.viewmodel.LockscreenToDreamingTransitionViewModel; import com.android.systemui.keyguard.ui.viewmodel.LockscreenToOccludedTransitionViewModel; import com.android.systemui.keyguard.ui.viewmodel.OccludedToLockscreenTransitionViewModel; +import com.android.systemui.keyguard.ui.viewmodel.PrimaryBouncerToGoneTransitionViewModel; import com.android.systemui.media.controls.pipeline.MediaDataManager; import com.android.systemui.media.controls.ui.KeyguardMediaController; import com.android.systemui.media.controls.ui.MediaHierarchyManager; @@ -300,6 +301,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected GoneToDreamingTransitionViewModel mGoneToDreamingTransitionViewModel; @Mock protected GoneToDreamingLockscreenHostedTransitionViewModel mGoneToDreamingLockscreenHostedTransitionViewModel; + @Mock protected PrimaryBouncerToGoneTransitionViewModel + mPrimaryBouncerToGoneTransitionViewModel; @Mock protected KeyguardTransitionInteractor mKeyguardTransitionInteractor; @Mock protected KeyguardLongPressViewModel mKeyuardLongPressViewModel; @Mock protected AlternateBouncerInteractor mAlternateBouncerInteractor; @@ -502,6 +505,10 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { when(mLockscreenToOccludedTransitionViewModel.lockscreenTranslationY(anyInt())) .thenReturn(emptyFlow()); + // Primary Bouncer->Gone + when(mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha()) + .thenReturn(emptyFlow()); + NotificationWakeUpCoordinator coordinator = new NotificationWakeUpCoordinator( mDumpManager, @@ -631,6 +638,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mGoneToDreamingTransitionViewModel, mGoneToDreamingLockscreenHostedTransitionViewModel, mLockscreenToOccludedTransitionViewModel, + mPrimaryBouncerToGoneTransitionViewModel, mMainDispatcher, mKeyguardTransitionInteractor, mDumpManager, |