Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit faabf08e authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Automerger Merge Worker
Browse files

Merge "Fixes bug where home controls would show up before first unlock." into...

Merge "Fixes bug where home controls would show up before first unlock." into tm-qpr-dev am: e00464ef

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19888470



Change-Id: I237f628db752592d42506ff83f3ed3a9df00951c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 89fe4216 e00464ef
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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(),
+19 −9
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -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>()