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
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>()
|
||||
|
||||
Reference in New Issue
Block a user