Merge "Fixes bug where home controls would show up before first unlock." into tm-qpr-dev
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