diff options
| author | 2022-09-07 17:20:37 -0700 | |
|---|---|---|
| committer | 2022-09-08 12:23:59 -0700 | |
| commit | d2a99344b0ab098c835d5bb24bd20955a418d6eb (patch) | |
| tree | 7e5126a8cf8f9611e6880fda79a2a99cf293ff8d | |
| parent | e964963e7496fae49fccd85488c628c845cde48f (diff) | |
Fixes bug where home controls would show up before first unlock.
Based on the attached bug, there is an issue where the quick affordance
for home controls shows up on the lock-screen before the lock-screen is
unlocked for the first time. This is a problem that only exists with the
new implementation of the refactord KeyguardBottomAreaView and not in
the original code.
The fix is to take the visibility from ControlsComponent.getVisibility
into account. This CL does that. This is what the old implementation is
doing.
Bug: 244296596
Test: CL was written in a test-driven development (TDD) format. The
failing test was written first, then the production code was written and
that failing test passed. In addition to that, manually verified that
(1) the home controls affordance no longer appears on the lock-screren
after a reboot and before unlocking for the first time and (2) it does
appear normally and behaves normally when clicked after unlocking and
locking again.
Change-Id: I49ef150514cd46d387a94a499d56c18ef2c7e0ba
3 files changed, 30 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt index 8f32ff9db50c..ac2c9b1d7ff2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt @@ -94,6 +94,7 @@ constructor( hasFavorites = favorites?.isNotEmpty() == true, hasServiceInfos = serviceInfos.isNotEmpty(), iconResourceId = component.getTileImageId(), + visibility = component.getVisibility(), ), TAG, ) @@ -110,9 +111,16 @@ constructor( isFeatureEnabled: Boolean, hasFavorites: Boolean, hasServiceInfos: Boolean, + visibility: ControlsComponent.Visibility, @DrawableRes iconResourceId: Int?, ): KeyguardQuickAffordanceConfig.State { - return if (isFeatureEnabled && hasFavorites && hasServiceInfos && iconResourceId != null) { + return if ( + isFeatureEnabled && + hasFavorites && + hasServiceInfos && + iconResourceId != null && + visibility == ControlsComponent.Visibility.AVAILABLE + ) { KeyguardQuickAffordanceConfig.State.Visible( icon = ContainedDrawable.WithResource(iconResourceId), contentDescriptionResourceId = component.getTileTitleId(), diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt index 9acd21cc6398..9a91ea91f3a2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt @@ -51,18 +51,19 @@ class HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest : SysuiTes @Parameters( name = "feature enabled = {0}, has favorites = {1}, has service infos = {2}, can show" + - " while locked = {3} - expected visible = {4}" + " while locked = {3}, visibility is AVAILABLE {4} - expected visible = {5}" ) @JvmStatic fun data() = - (0 until 16) + (0 until 32) .map { combination -> arrayOf( - /* isFeatureEnabled= */ combination and 0b1000 != 0, - /* hasFavorites= */ combination and 0b0100 != 0, - /* hasServiceInfos= */ combination and 0b0010 != 0, - /* canShowWhileLocked= */ combination and 0b0001 != 0, - /* isVisible= */ combination == 0b1111, + /* isFeatureEnabled= */ combination and 0b10000 != 0, + /* hasFavorites= */ combination and 0b01000 != 0, + /* hasServiceInfos= */ combination and 0b00100 != 0, + /* canShowWhileLocked= */ combination and 0b00010 != 0, + /* visibilityAvailable= */ combination and 0b00001 != 0, + /* isVisible= */ combination == 0b11111, ) } .toList() @@ -81,7 +82,8 @@ class HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest : SysuiTes @JvmField @Parameter(1) var hasFavorites: Boolean = false @JvmField @Parameter(2) var hasServiceInfos: Boolean = false @JvmField @Parameter(3) var canShowWhileLocked: Boolean = false - @JvmField @Parameter(4) var isVisible: Boolean = false + @JvmField @Parameter(4) var isVisibilityAvailable: Boolean = false + @JvmField @Parameter(5) var isVisibleExpected: Boolean = false @Before fun setUp() { @@ -93,6 +95,14 @@ class HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest : SysuiTes .thenReturn(Optional.of(controlsListingController)) whenever(component.canShowWhileLockedSetting) .thenReturn(MutableStateFlow(canShowWhileLocked)) + whenever(component.getVisibility()) + .thenReturn( + if (isVisibilityAvailable) { + ControlsComponent.Visibility.AVAILABLE + } else { + ControlsComponent.Visibility.UNAVAILABLE + } + ) underTest = HomeControlsKeyguardQuickAffordanceConfig( @@ -128,7 +138,7 @@ class HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest : SysuiTes assertThat(values.last()) .isInstanceOf( - if (isVisible) { + if (isVisibleExpected) { KeyguardQuickAffordanceConfig.State.Visible::class.java } else { KeyguardQuickAffordanceConfig.State.Hidden::class.java diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt index 059487dfdbc8..dede4ec0210c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt @@ -69,6 +69,7 @@ class HomeControlsKeyguardQuickAffordanceConfigTest : SysuiTestCase() { val controlsController = mock<ControlsController>() whenever(component.getControlsController()).thenReturn(Optional.of(controlsController)) whenever(component.getControlsListingController()).thenReturn(Optional.empty()) + whenever(component.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE) whenever(controlsController.getFavorites()).thenReturn(listOf(mock())) val values = mutableListOf<KeyguardQuickAffordanceConfig.State>() @@ -87,6 +88,7 @@ class HomeControlsKeyguardQuickAffordanceConfigTest : SysuiTestCase() { val controlsController = mock<ControlsController>() whenever(component.getControlsController()).thenReturn(Optional.of(controlsController)) whenever(component.getControlsListingController()).thenReturn(Optional.empty()) + whenever(component.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE) whenever(controlsController.getFavorites()).thenReturn(listOf(mock())) val values = mutableListOf<KeyguardQuickAffordanceConfig.State>() |