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

Commit a47512cc authored by Brad Hinegardner's avatar Brad Hinegardner Committed by Android (Google) Code Review
Browse files

Merge "Respect device policy for shortcuts in wallpaper picker preview" into main

parents e54ebaad 4f341251
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -343,6 +343,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
@@ -120,10 +120,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)
        }
    }

    /**