From 10e56aca36f357fd9acea71c16d28aad35391487 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Sun, 20 Nov 2022 08:59:31 -0800 Subject: [PATCH] [Bouncer] ensure that bouncer expansion callback.. Will accept setVisibilityChanged#isNotVisible. When dream appears, for whatever reason, expansion is set to 0 which is BOUNCER_VISIBLE. This propagates FULLY_SHOWN to callback listeners (for both with feature flag off and on). In the same code path, bouncer#hide is called. The difference between the old bouncer and the new bouncer is that visibility was conflated so because the bouncer was already invisible, we did not propagate this data to the callback listener that visibility is hidden. I have separated this callback from when we set visibility with the actual state flow. Instead, call setVisibiltyChanged whenever show() or hide() is called for the interactor. Fixes: b/259081158 Test: Added a unit test. Test: Set screen saver and show screen saver when charging. Open screen saver a bunch of times from unlocked state and locked state to observe that touches are not lost. I have observed the bug behavior without my change. Change-Id: I56d535c0422337f09f009960d8e4117ec30ae9c1 --- .../domain/interactor/PrimaryBouncerInteractor.kt | 8 +++----- .../keyguard/ui/binder/KeyguardBouncerViewBinder.kt | 1 - .../keyguard/ui/viewmodel/KeyguardBouncerViewModel.kt | 4 ---- .../statusbar/phone/StatusBarKeyguardViewManager.java | 2 +- .../domain/interactor/PrimaryBouncerInteractorTest.kt | 3 +++ 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt index 3b31dcfc43495..84a80744185ec 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt @@ -21,6 +21,7 @@ import android.os.Handler import android.os.Trace import android.os.UserHandle import android.os.UserManager +import android.view.View import com.android.keyguard.KeyguardSecurityModel import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.DejankUtils @@ -84,6 +85,7 @@ constructor( ) ) repository.setPrimaryShowingSoon(false) + primaryBouncerCallbackInteractor.dispatchVisibilityChanged(View.VISIBLE) } val keyguardAuthenticated: Flow = repository.keyguardAuthenticated.filterNotNull() @@ -182,6 +184,7 @@ constructor( repository.setPrimaryVisible(false) repository.setPrimaryHide(true) repository.setPrimaryShow(null) + primaryBouncerCallbackInteractor.dispatchVisibilityChanged(View.INVISIBLE) Trace.endSection() } @@ -276,11 +279,6 @@ constructor( repository.setShowMessage(null) } - /** Notify that view visibility has changed. */ - fun notifyBouncerVisibilityHasChanged(visibility: Int) { - primaryBouncerCallbackInteractor.dispatchVisibilityChanged(visibility) - } - /** Notify that the resources have been updated */ fun notifyUpdatedResources() { repository.setResourceUpdateRequests(false) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt index 3c927ee08494a..59b4adccc27f4 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt @@ -152,7 +152,6 @@ object KeyguardBouncerViewBinder { val visibility = if (isVisible) View.VISIBLE else View.INVISIBLE view.visibility = visibility hostViewController.onBouncerVisibilityChanged(visibility) - viewModel.notifyBouncerVisibilityHasChanged(visibility) } } 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 503c8ba2ca43c..e5d4e4971baaf 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 @@ -72,10 +72,6 @@ constructor( /** Observe whether screen is turned off. */ val screenTurnedOff: Flow = interactor.screenTurnedOff - /** Notify that view visibility has changed. */ - fun notifyBouncerVisibilityHasChanged(visibility: Int) { - return interactor.notifyBouncerVisibilityHasChanged(visibility) - } /** Observe whether we want to update resources. */ fun notifyUpdateResources() { interactor.notifyUpdatedResources() diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 6eed711645a72..4760dc511a597 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -476,7 +476,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } else { mPrimaryBouncerInteractor.setPanelExpansion(KeyguardBouncer.EXPANSION_VISIBLE); } - } else if (mKeyguardStateController.isShowing() && !hideBouncerOverDream) { + } else if (mKeyguardStateController.isShowing() && !hideBouncerOverDream) { if (!isWakeAndUnlocking() && !(mBiometricUnlockController.getMode() == MODE_DISMISS_BOUNCER) && !(mBiometricUnlockController.getMode() == MODE_SHOW_BOUNCER) diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractorTest.kt index 559f183717df9..a6fc13bcb0113 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractorTest.kt @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.domain.interactor import android.os.Looper import android.testing.AndroidTestingRunner import android.testing.TestableLooper.RunWithLooper +import android.view.View import androidx.test.filters.SmallTest import com.android.keyguard.KeyguardSecurityModel import com.android.keyguard.KeyguardUpdateMonitor @@ -106,6 +107,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { verify(repository).setPrimaryVisible(true) verify(repository).setPrimaryShow(any(KeyguardBouncerModel::class.java)) verify(repository).setPrimaryShowingSoon(false) + verify(mPrimaryBouncerCallbackInteractor).dispatchVisibilityChanged(View.VISIBLE) } @Test @@ -129,6 +131,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { verify(repository).setPrimaryVisible(false) verify(repository).setPrimaryHide(true) verify(repository).setPrimaryShow(null) + verify(mPrimaryBouncerCallbackInteractor).dispatchVisibilityChanged(View.INVISIBLE) } @Test