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

Commit 4f341251 authored by Brad Hinegardner's avatar Brad Hinegardner
Browse files

Respect device policy for shortcuts in wallpaper picker preview

Fixes: 305000330
Test: atest KeyguardQuickAffordanceInteractorTest.kt
Flag: NONE
Change-Id: I36036bfc85d1bfae841838ecaf87ad127c566ca6
parent 0d90b895
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -338,6 +338,31 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
            assertThat(collectedValue()).isEqualTo(KeyguardQuickAffordanceModel.Hidden)
        }

    @Test
    fun quickAffordanceAlwaysVisible_notVisible_restrictedByPolicyManager() =
        testScope.runTest {
            whenever(devicePolicyManager.getKeyguardDisabledFeatures(null, userTracker.userId))
                .thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_SHORTCUTS_ALL)

            repository.setKeyguardShowing(false)
            repository.setIsDozing(true)
            homeControls.setState(
                KeyguardQuickAffordanceConfig.LockScreenState.Visible(
                    icon = ICON,
                    activationState = ActivationState.Active,
                )
            )

            val collectedValue by
                collectLastValue(
                    underTest.quickAffordanceAlwaysVisible(
                        KeyguardQuickAffordancePosition.BOTTOM_START
                    )
                )

            assertThat(collectedValue).isInstanceOf(KeyguardQuickAffordanceModel.Hidden::class.java)
        }

    @Test
    fun quickAffordanceAlwaysVisible_evenWhenLockScreenNotShowingAndDozing() =
        testScope.runTest {
+6 −2
Original line number Diff line number Diff line
@@ -117,10 +117,14 @@ constructor(
     * This is useful for experiences like the lock screen preview mode, where the affordances must
     * always be visible.
     */
    fun quickAffordanceAlwaysVisible(
    suspend fun quickAffordanceAlwaysVisible(
        position: KeyguardQuickAffordancePosition,
    ): Flow<KeyguardQuickAffordanceModel> {
        return quickAffordanceInternal(position)
        return if (isFeatureDisabledByDevicePolicy()) {
            flowOf(KeyguardQuickAffordanceModel.Hidden)
        } else {
            quickAffordanceInternal(position)
        }
    }

    /**