diff options
| author | 2023-02-14 10:52:00 -0800 | |
|---|---|---|
| committer | 2023-02-16 15:27:22 +0000 | |
| commit | 4bc95f88aab95fd1615213b0d58b01ebbb9d38f6 (patch) | |
| tree | 13989208d3052d79d8b101b5b8eaa37913d6a9a6 | |
| parent | 9ab0eed73920d7551e26547dc17f22ccce80be73 (diff) | |
Respect KEYGUARD_DISABLE_SHORTCUTS_ALL
When DevicePolicyManager#getKeyguardDisabledFeatures includes a set bit
for the KEYGUARD_DISABLE_SHORTCUTS_ALL flag, we disable lock screen
shortcuts.
Fix: 268218507
Flag: customizable_lock_screen_quick_affordances
Test: faked the returned value and manually verified that the feature is
gone from settings, wallpaper picker, and the lock screen
Test: unit test case added
Change-Id: I6c8a2d1fd2f891c9cd483d395c8175d6e8361b1b
2 files changed, 23 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt index e70899828f3f..dfbe1c216847 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt @@ -415,8 +415,9 @@ constructor( withContext(backgroundDispatcher) { devicePolicyManager.getKeyguardDisabledFeatures(null, userTracker.userId) } - val flagsToCheck = DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_ALL - // TODO(b/268218507): "or" with DevicePolicyManager.KEYGUARD_DISABLE_SHORTCUTS_ALL + val flagsToCheck = + DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_ALL or + DevicePolicyManager.KEYGUARD_DISABLE_SHORTCUTS_ALL return flagsToCheck and flags != 0 } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt index 94044ad6d7ed..62c9e5ffbb51 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt @@ -243,7 +243,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { } @Test - fun `quickAffordance - bottom end affordance is hidden when disabled by device policy`() = + fun `quickAffordance - hidden when all features are disabled by device policy`() = testScope.runTest { whenever(devicePolicyManager.getKeyguardDisabledFeatures(null, userTracker.userId)) .thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_ALL) @@ -262,6 +262,25 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { } @Test + fun `quickAffordance - hidden when shortcuts feature is disabled by device policy`() = + testScope.runTest { + whenever(devicePolicyManager.getKeyguardDisabledFeatures(null, userTracker.userId)) + .thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_SHORTCUTS_ALL) + quickAccessWallet.setState( + KeyguardQuickAffordanceConfig.LockScreenState.Visible( + icon = ICON, + ) + ) + + val collectedValue by + collectLastValue( + underTest.quickAffordance(KeyguardQuickAffordancePosition.BOTTOM_END) + ) + + assertThat(collectedValue).isInstanceOf(KeyguardQuickAffordanceModel.Hidden::class.java) + } + + @Test fun `quickAffordance - bottom start affordance hidden while dozing`() = testScope.runTest { repository.setDozing(true) |