Loading packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceLocalUserSelectionManager.kt +6 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ import kotlinx.coroutines.flow.onStart class KeyguardQuickAffordanceLocalUserSelectionManager @Inject constructor( @Application context: Context, @Application private val context: Context, private val userFileManager: UserFileManager, private val userTracker: UserTracker, broadcastDispatcher: BroadcastDispatcher, Loading Loading @@ -126,6 +126,11 @@ constructor( } override fun getSelections(): Map<String, List<String>> { // If the custom shortcuts feature is not enabled, ignore prior selections and use defaults if (!context.resources.getBoolean(R.bool.custom_lockscreen_shortcuts_enabled)) { return defaults } val slotKeys = sharedPrefs.all.keys.filter { it.startsWith(KEY_PREFIX_SLOT) } val result = slotKeys Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceLegacySettingSyncerTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,8 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { val resources: Resources = mock() whenever(resources.getStringArray(R.array.config_keyguardQuickAffordanceDefaults)) .thenReturn(emptyArray()) whenever(resources.getBoolean(R.bool.custom_lockscreen_shortcuts_enabled)) .thenReturn(true) whenever(context.resources).thenReturn(resources) testDispatcher = UnconfinedTestDispatcher() Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceLocalUserSelectionManagerTest.kt +24 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ class KeyguardQuickAffordanceLocalUserSelectionManagerTest : SysuiTestCase() { @Before fun setUp() { MockitoAnnotations.initMocks(this) overrideResource(R.bool.custom_lockscreen_shortcuts_enabled, true) sharedPrefs = mutableMapOf() whenever(userFileManager.getSharedPreferences(anyString(), anyInt(), anyInt())).thenAnswer { val userId = it.arguments[2] as Int Loading @@ -86,6 +87,13 @@ class KeyguardQuickAffordanceLocalUserSelectionManagerTest : SysuiTestCase() { @After fun tearDown() { mContext .getOrCreateTestableResources() .removeOverride(R.bool.custom_lockscreen_shortcuts_enabled) mContext .getOrCreateTestableResources() .removeOverride(R.array.config_keyguardQuickAffordanceDefaults) Dispatchers.resetMain() } Loading Loading @@ -358,6 +366,22 @@ class KeyguardQuickAffordanceLocalUserSelectionManagerTest : SysuiTestCase() { job.cancel() } @Test fun getSelections_alwaysReturnsDefaultsIfCustomShortcutsFeatureDisabled() { overrideResource(R.bool.custom_lockscreen_shortcuts_enabled, false) overrideResource( R.array.config_keyguardQuickAffordanceDefaults, arrayOf("leftTest:testShortcut1", "rightTest:testShortcut2") ) assertThat(underTest.getSelections()).isEqualTo( mapOf( "leftTest" to listOf("testShortcut1"), "rightTest" to listOf("testShortcut2"), ) ) } private fun assertSelections( observed: Map<String, List<String>>?, expected: Map<String, List<String>>, Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepositoryTest.kt +9 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -70,6 +71,7 @@ class KeyguardQuickAffordanceRepositoryTest : SysuiTestCase() { @Before fun setUp() { overrideResource(R.bool.custom_lockscreen_shortcuts_enabled, true) context.resources.configuration.setLayoutDirection(Locale.US) config1 = FakeKeyguardQuickAffordanceConfig(FakeCustomizationProviderClient.AFFORDANCE_1) config2 = FakeKeyguardQuickAffordanceConfig(FakeCustomizationProviderClient.AFFORDANCE_2) Loading Loading @@ -137,6 +139,13 @@ class KeyguardQuickAffordanceRepositoryTest : SysuiTestCase() { ) } @After fun tearDown() { mContext .getOrCreateTestableResources() .removeOverride(R.bool.custom_lockscreen_shortcuts_enabled) } @Test fun setSelections() = testScope.runTest { Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt +3 −1 Original line number Diff line number Diff line Loading @@ -102,6 +102,8 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { fun setUp() { MockitoAnnotations.initMocks(this) overrideResource(R.bool.custom_lockscreen_shortcuts_enabled, true) repository = FakeKeyguardRepository() repository.setKeyguardShowing(true) Loading Loading @@ -200,7 +202,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { devicePolicyManager = devicePolicyManager, dockManager = dockManager, backgroundDispatcher = testDispatcher, appContext = mContext, appContext = context, ) } Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceLocalUserSelectionManager.kt +6 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ import kotlinx.coroutines.flow.onStart class KeyguardQuickAffordanceLocalUserSelectionManager @Inject constructor( @Application context: Context, @Application private val context: Context, private val userFileManager: UserFileManager, private val userTracker: UserTracker, broadcastDispatcher: BroadcastDispatcher, Loading Loading @@ -126,6 +126,11 @@ constructor( } override fun getSelections(): Map<String, List<String>> { // If the custom shortcuts feature is not enabled, ignore prior selections and use defaults if (!context.resources.getBoolean(R.bool.custom_lockscreen_shortcuts_enabled)) { return defaults } val slotKeys = sharedPrefs.all.keys.filter { it.startsWith(KEY_PREFIX_SLOT) } val result = slotKeys Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceLegacySettingSyncerTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,8 @@ class KeyguardQuickAffordanceLegacySettingSyncerTest : SysuiTestCase() { val resources: Resources = mock() whenever(resources.getStringArray(R.array.config_keyguardQuickAffordanceDefaults)) .thenReturn(emptyArray()) whenever(resources.getBoolean(R.bool.custom_lockscreen_shortcuts_enabled)) .thenReturn(true) whenever(context.resources).thenReturn(resources) testDispatcher = UnconfinedTestDispatcher() Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceLocalUserSelectionManagerTest.kt +24 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ class KeyguardQuickAffordanceLocalUserSelectionManagerTest : SysuiTestCase() { @Before fun setUp() { MockitoAnnotations.initMocks(this) overrideResource(R.bool.custom_lockscreen_shortcuts_enabled, true) sharedPrefs = mutableMapOf() whenever(userFileManager.getSharedPreferences(anyString(), anyInt(), anyInt())).thenAnswer { val userId = it.arguments[2] as Int Loading @@ -86,6 +87,13 @@ class KeyguardQuickAffordanceLocalUserSelectionManagerTest : SysuiTestCase() { @After fun tearDown() { mContext .getOrCreateTestableResources() .removeOverride(R.bool.custom_lockscreen_shortcuts_enabled) mContext .getOrCreateTestableResources() .removeOverride(R.array.config_keyguardQuickAffordanceDefaults) Dispatchers.resetMain() } Loading Loading @@ -358,6 +366,22 @@ class KeyguardQuickAffordanceLocalUserSelectionManagerTest : SysuiTestCase() { job.cancel() } @Test fun getSelections_alwaysReturnsDefaultsIfCustomShortcutsFeatureDisabled() { overrideResource(R.bool.custom_lockscreen_shortcuts_enabled, false) overrideResource( R.array.config_keyguardQuickAffordanceDefaults, arrayOf("leftTest:testShortcut1", "rightTest:testShortcut2") ) assertThat(underTest.getSelections()).isEqualTo( mapOf( "leftTest" to listOf("testShortcut1"), "rightTest" to listOf("testShortcut2"), ) ) } private fun assertSelections( observed: Map<String, List<String>>?, expected: Map<String, List<String>>, Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepositoryTest.kt +9 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -70,6 +71,7 @@ class KeyguardQuickAffordanceRepositoryTest : SysuiTestCase() { @Before fun setUp() { overrideResource(R.bool.custom_lockscreen_shortcuts_enabled, true) context.resources.configuration.setLayoutDirection(Locale.US) config1 = FakeKeyguardQuickAffordanceConfig(FakeCustomizationProviderClient.AFFORDANCE_1) config2 = FakeKeyguardQuickAffordanceConfig(FakeCustomizationProviderClient.AFFORDANCE_2) Loading Loading @@ -137,6 +139,13 @@ class KeyguardQuickAffordanceRepositoryTest : SysuiTestCase() { ) } @After fun tearDown() { mContext .getOrCreateTestableResources() .removeOverride(R.bool.custom_lockscreen_shortcuts_enabled) } @Test fun setSelections() = testScope.runTest { Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt +3 −1 Original line number Diff line number Diff line Loading @@ -102,6 +102,8 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { fun setUp() { MockitoAnnotations.initMocks(this) overrideResource(R.bool.custom_lockscreen_shortcuts_enabled, true) repository = FakeKeyguardRepository() repository.setKeyguardShowing(true) Loading Loading @@ -200,7 +202,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { devicePolicyManager = devicePolicyManager, dockManager = dockManager, backgroundDispatcher = testDispatcher, appContext = mContext, appContext = context, ) } Loading