From 61274aba371c2d28075a424c34d917748e37a4b7 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Fri, 21 Oct 2022 12:19:59 -0700 Subject: [PATCH 1/2] Changes quick affordance key to string. Before this change, the key that uniquely identifies each quick affordance was the class of that key. Since we're about to embark on a project where we'll have many implementations that share the same class, this is no longer sufficient. Previously, I was reluctant to use a string because there was no easy way to guarantee uniqueness. Now that we see that we can't guarantee uniqueness through the class typing system, we have to compromise. Bug: 254858696 Test: unit tests updated and all passing. Manually verified that affordances work and that clicking on one doesn't trigger the other. Change-Id: I2d1ec382c04604c8478737720eb92410eec479f8 --- .../KeyguardQuickAffordanceInteractor.kt | 7 ++--- .../model/KeyguardQuickAffordanceModel.kt | 4 +-- .../BuiltInKeyguardQuickAffordanceKeys.kt | 31 +++++++++++++++++++ ...meControlsKeyguardQuickAffordanceConfig.kt | 2 ++ .../KeyguardQuickAffordanceConfig.kt | 10 ++++++ .../KeyguardQuickAffordanceRegistry.kt | 11 +++---- ...odeScannerKeyguardQuickAffordanceConfig.kt | 2 ++ ...cessWalletKeyguardQuickAffordanceConfig.kt | 2 ++ .../KeyguardQuickAffordanceViewModel.kt | 6 ++-- ...ckAffordanceInteractorParameterizedTest.kt | 19 +++++++++--- .../KeyguardQuickAffordanceInteractorTest.kt | 23 +++++++++++--- .../FakeKeyguardQuickAffordanceConfig.kt | 4 ++- .../FakeKeyguardQuickAffordanceRegistry.kt | 8 ++--- .../KeyguardBottomAreaViewModelTest.kt | 26 +++++++++++----- 14 files changed, 115 insertions(+), 40 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt 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 f663b0dd23cd5..3c11a80e6242b 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 @@ -29,7 +29,6 @@ import com.android.systemui.plugins.ActivityStarter import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.policy.KeyguardStateController import javax.inject.Inject -import kotlin.reflect.KClass import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.onStart @@ -70,10 +69,10 @@ constructor( * @param expandable An optional [Expandable] for the activity- or dialog-launch animation */ fun onQuickAffordanceClicked( - configKey: KClass, + configKey: String, expandable: Expandable?, ) { - @Suppress("UNCHECKED_CAST") val config = registry.get(configKey as KClass) + @Suppress("UNCHECKED_CAST") val config = registry.get(configKey) when (val result = config.onQuickAffordanceClicked(expandable)) { is KeyguardQuickAffordanceConfig.OnClickedResult.StartActivity -> launchQuickAffordance( @@ -102,7 +101,7 @@ constructor( if (index != -1) { val visibleState = states[index] as KeyguardQuickAffordanceConfig.State.Visible KeyguardQuickAffordanceModel.Visible( - configKey = configs[index]::class, + configKey = configs[index].key, icon = visibleState.icon, toggle = visibleState.toggle, ) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/model/KeyguardQuickAffordanceModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/model/KeyguardQuickAffordanceModel.kt index e56b259679106..fc644a9e6067e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/model/KeyguardQuickAffordanceModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/model/KeyguardQuickAffordanceModel.kt @@ -18,9 +18,7 @@ package com.android.systemui.keyguard.domain.model import com.android.systemui.common.shared.model.Icon -import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordanceToggleState -import kotlin.reflect.KClass /** * Models a "quick affordance" in the keyguard bottom area (for example, a button on the @@ -33,7 +31,7 @@ sealed class KeyguardQuickAffordanceModel { /** A affordance is visible. */ data class Visible( /** Identifier for the affordance this is modeling. */ - val configKey: KClass, + val configKey: String, /** An icon for the affordance. */ val icon: Icon, /** The toggle state for the affordance. */ diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt new file mode 100644 index 0000000000000..587721d2196c5 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.android.systemui.keyguard.domain.quickaffordance + +/** + * Unique identifier keys for all known built-in quick affordances. + * + * Please ensure uniqueness by never associating more than one class with each key. + */ +object BuiltInKeyguardQuickAffordanceKeys { + // Please keep alphabetical order of const names to simplify future maintenance. + const val HOME_CONTROLS = "home" + const val QR_CODE_SCANNER = "qr_code_scanner" + const val QUICK_ACCESS_WALLET = "wallet" + // Please keep alphabetical order of const names to simplify future maintenance. +} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt index 83842602cbee1..8ef8e1ba87f7e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt @@ -51,6 +51,8 @@ constructor( private val appContext = context.applicationContext + override val key: String = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS + override val state: Flow = component.canShowWhileLockedSetting.flatMapLatest { canShowWhileLocked -> if (canShowWhileLocked) { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceConfig.kt index 95027d00c46cb..67c4afad73805 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceConfig.kt @@ -26,8 +26,18 @@ import kotlinx.coroutines.flow.Flow /** Defines interface that can act as data source for a single quick affordance model. */ interface KeyguardQuickAffordanceConfig { + /** Unique identifier for this quick affordance. It must be globally unique. */ + val key: String + + /** The observable [State] of the affordance. */ val state: Flow + /** + * Notifies that the affordance was clicked by the user. + * + * @param expandable An [Expandable] to use when animating dialogs or activities + * @return An [OnClickedResult] telling the caller what to do next + */ fun onQuickAffordanceClicked(expandable: Expandable?): OnClickedResult /** diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceRegistry.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceRegistry.kt index ad40ee7a01830..4ea1e1fdff02d 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceRegistry.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceRegistry.kt @@ -19,12 +19,11 @@ package com.android.systemui.keyguard.domain.quickaffordance import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition import javax.inject.Inject -import kotlin.reflect.KClass /** Central registry of all known quick affordance configs. */ interface KeyguardQuickAffordanceRegistry { fun getAll(position: KeyguardQuickAffordancePosition): List - fun get(configClass: KClass): T + fun get(key: String): T } class KeyguardQuickAffordanceRegistryImpl @@ -46,8 +45,8 @@ constructor( qrCodeScanner, ), ) - private val configByClass = - configsByPosition.values.flatten().associateBy { config -> config::class } + private val configByKey = + configsByPosition.values.flatten().associateBy { config -> config.key } override fun getAll( position: KeyguardQuickAffordancePosition, @@ -56,8 +55,8 @@ constructor( } override fun get( - configClass: KClass + key: String, ): KeyguardQuickAffordanceConfig { - return configByClass.getValue(configClass) + return configByKey.getValue(key) } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt index 502a6070a422c..ac94e1beb0d52 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt @@ -37,6 +37,8 @@ constructor( private val controller: QRCodeScannerController, ) : KeyguardQuickAffordanceConfig { + override val key: String = BuiltInKeyguardQuickAffordanceKeys.QR_CODE_SCANNER + override val state: Flow = conflatedCallbackFlow { val callback = object : QRCodeScannerController.Callback { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt index a24a0d62465f6..e0bf921edabff 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt @@ -44,6 +44,8 @@ constructor( private val activityStarter: ActivityStarter, ) : KeyguardQuickAffordanceConfig { + override val key: String = BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET + override val state: Flow = conflatedCallbackFlow { val callback = object : QuickAccessWalletClient.OnWalletCardsRetrievedCallback { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordanceViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordanceViewModel.kt index bf598ba859322..44f48f97b62e2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordanceViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordanceViewModel.kt @@ -18,12 +18,10 @@ package com.android.systemui.keyguard.ui.viewmodel import com.android.systemui.animation.Expandable import com.android.systemui.common.shared.model.Icon -import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig -import kotlin.reflect.KClass /** Models the UI state of a keyguard quick affordance button. */ data class KeyguardQuickAffordanceViewModel( - val configKey: KClass? = null, + val configKey: String? = null, val isVisible: Boolean = false, /** Whether to animate the transition of the quick affordance from invisible to visible. */ val animateReveal: Boolean = false, @@ -33,7 +31,7 @@ data class KeyguardQuickAffordanceViewModel( val isActivated: Boolean = false, ) { data class OnClickedParameters( - val configKey: KClass, + val configKey: String, val expandable: Expandable?, ) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt index b4d5464d11777..8993107f7c96a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt @@ -27,6 +27,7 @@ import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition +import com.android.systemui.keyguard.domain.quickaffordance.BuiltInKeyguardQuickAffordanceKeys import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceConfig import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig @@ -211,7 +212,11 @@ class KeyguardQuickAffordanceInteractorParameterizedTest : SysuiTestCase() { MockitoAnnotations.initMocks(this) whenever(expandable.activityLaunchController()).thenReturn(animationController) - homeControls = object : FakeKeyguardQuickAffordanceConfig() {} + homeControls = + object : + FakeKeyguardQuickAffordanceConfig( + BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS + ) {} underTest = KeyguardQuickAffordanceInteractor( keyguardInteractor = KeyguardInteractor(repository = FakeKeyguardRepository()), @@ -224,8 +229,14 @@ class KeyguardQuickAffordanceInteractorParameterizedTest : SysuiTestCase() { ), KeyguardQuickAffordancePosition.BOTTOM_END to listOf( - object : FakeKeyguardQuickAffordanceConfig() {}, - object : FakeKeyguardQuickAffordanceConfig() {}, + object : + FakeKeyguardQuickAffordanceConfig( + BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET + ) {}, + object : + FakeKeyguardQuickAffordanceConfig( + BuiltInKeyguardQuickAffordanceKeys.QR_CODE_SCANNER + ) {}, ), ), ), @@ -260,7 +271,7 @@ class KeyguardQuickAffordanceInteractorParameterizedTest : SysuiTestCase() { } underTest.onQuickAffordanceClicked( - configKey = homeControls::class, + configKey = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS, expandable = expandable, ) 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 65fd6e5766500..503f41b60d068 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 @@ -25,6 +25,7 @@ import com.android.systemui.common.shared.model.Icon import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordanceModel import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition +import com.android.systemui.keyguard.domain.quickaffordance.BuiltInKeyguardQuickAffordanceKeys import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceConfig import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig @@ -69,9 +70,21 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { repository = FakeKeyguardRepository() repository.setKeyguardShowing(true) - homeControls = object : FakeKeyguardQuickAffordanceConfig() {} - quickAccessWallet = object : FakeKeyguardQuickAffordanceConfig() {} - qrCodeScanner = object : FakeKeyguardQuickAffordanceConfig() {} + homeControls = + object : + FakeKeyguardQuickAffordanceConfig( + BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS + ) {} + quickAccessWallet = + object : + FakeKeyguardQuickAffordanceConfig( + BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET + ) {} + qrCodeScanner = + object : + FakeKeyguardQuickAffordanceConfig( + BuiltInKeyguardQuickAffordanceKeys.QR_CODE_SCANNER + ) {} underTest = KeyguardQuickAffordanceInteractor( @@ -99,7 +112,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { @Test fun `quickAffordance - bottom start affordance is visible`() = runBlockingTest { - val configKey = homeControls::class + val configKey = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS homeControls.setState( KeyguardQuickAffordanceConfig.State.Visible( icon = ICON, @@ -130,7 +143,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { @Test fun `quickAffordance - bottom end affordance is visible`() = runBlockingTest { - val configKey = quickAccessWallet::class + val configKey = BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET quickAccessWallet.setState( KeyguardQuickAffordanceConfig.State.Visible( icon = ICON, diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt index e99c139e9e7ec..3cb5cf5222631 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt @@ -29,7 +29,9 @@ import kotlinx.coroutines.yield * This class is abstract to force tests to provide extensions of it as the system that references * these configs uses each implementation's class type to refer to them. */ -abstract class FakeKeyguardQuickAffordanceConfig : KeyguardQuickAffordanceConfig { +abstract class FakeKeyguardQuickAffordanceConfig( + override val key: String, +) : KeyguardQuickAffordanceConfig { var onClickedResult: OnClickedResult = OnClickedResult.Handled diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceRegistry.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceRegistry.kt index e68c43f4abd7f..ec3b0cefd7f83 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceRegistry.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceRegistry.kt @@ -18,7 +18,6 @@ package com.android.systemui.keyguard.domain.quickaffordance import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition -import kotlin.reflect.KClass /** Fake implementation of [FakeKeyguardQuickAffordanceRegistry], for tests. */ class FakeKeyguardQuickAffordanceRegistry( @@ -33,11 +32,8 @@ class FakeKeyguardQuickAffordanceRegistry( } override fun get( - configClass: KClass + key: String, ): FakeKeyguardQuickAffordanceConfig { - return configsByPosition.values - .flatten() - .associateBy { config -> config::class } - .getValue(configClass) + return configsByPosition.values.flatten().associateBy { config -> config.key }.getValue(key) } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt index d674c89c0e14d..eb8fb67280a7e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt @@ -28,6 +28,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInterac import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition +import com.android.systemui.keyguard.domain.quickaffordance.BuiltInKeyguardQuickAffordanceKeys import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceConfig import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig @@ -40,7 +41,6 @@ import com.android.systemui.util.mockito.mock import com.google.common.truth.Truth.assertThat import kotlin.math.max import kotlin.math.min -import kotlin.reflect.KClass import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.test.runBlockingTest @@ -81,9 +81,21 @@ class KeyguardBottomAreaViewModelTest : SysuiTestCase() { whenever(burnInHelperWrapper.burnInOffset(anyInt(), any())) .thenReturn(RETURNED_BURN_IN_OFFSET) - homeControlsQuickAffordanceConfig = object : FakeKeyguardQuickAffordanceConfig() {} - quickAccessWalletAffordanceConfig = object : FakeKeyguardQuickAffordanceConfig() {} - qrCodeScannerAffordanceConfig = object : FakeKeyguardQuickAffordanceConfig() {} + homeControlsQuickAffordanceConfig = + object : + FakeKeyguardQuickAffordanceConfig( + BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS + ) {} + quickAccessWalletAffordanceConfig = + object : + FakeKeyguardQuickAffordanceConfig( + BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET + ) {} + qrCodeScannerAffordanceConfig = + object : + FakeKeyguardQuickAffordanceConfig( + BuiltInKeyguardQuickAffordanceKeys.QR_CODE_SCANNER + ) {} registry = FakeKeyguardQuickAffordanceRegistry( mapOf( @@ -489,7 +501,7 @@ class KeyguardBottomAreaViewModelTest : SysuiTestCase() { private suspend fun setUpQuickAffordanceModel( position: KeyguardQuickAffordancePosition, testConfig: TestConfig, - ): KClass { + ): String { val config = when (position) { KeyguardQuickAffordancePosition.BOTTOM_START -> homeControlsQuickAffordanceConfig @@ -518,13 +530,13 @@ class KeyguardBottomAreaViewModelTest : SysuiTestCase() { KeyguardQuickAffordanceConfig.State.Hidden } config.setState(state) - return config::class + return config.key } private fun assertQuickAffordanceViewModel( viewModel: KeyguardQuickAffordanceViewModel?, testConfig: TestConfig, - configKey: KClass, + configKey: String, ) { checkNotNull(viewModel) assertThat(viewModel.isVisible).isEqualTo(testConfig.isVisible) From 7237112d22d8412bbbcea5ebe43dbfd383f14bc3 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Fri, 21 Oct 2022 12:46:47 -0700 Subject: [PATCH 2/2] Moves quick affordances to data layer. Because we need to implement a data layer repository that will access quick affordance configs, we need the latter to be moved to the data layer as well (since currently they are in the domain layer and code in the data layer is not allowed to depend on code in the domain layer). This CL has no changes, only moves and renames. Bug: 254858696 Test: All tests still pass. Bottom area affordances still work. Change-Id: Ibe1f0387886950ef7e9ef11a8716603aa547493e --- .../docs/device-entry/quickaffordance.md | 2 +- .../BuiltInKeyguardQuickAffordanceKeys.kt | 2 +- ...meControlsKeyguardQuickAffordanceConfig.kt | 22 ++++++++--------- .../KeyguardQuickAffordanceConfig.kt | 22 ++++++++--------- ...odeScannerKeyguardQuickAffordanceConfig.kt | 22 ++++++++--------- ...cessWalletKeyguardQuickAffordanceConfig.kt | 22 ++++++++--------- .../KeyguardQuickAffordanceInteractor.kt | 4 ++-- .../KeyguardQuickAffordanceModule.kt | 1 + .../KeyguardQuickAffordanceRegistry.kt | 6 ++++- .../KeyguardQuickAffordancePosition.kt | 2 +- .../viewmodel/KeyguardBottomAreaViewModel.kt | 2 +- .../FakeKeyguardQuickAffordanceConfig.kt | 4 ++-- ...kAffordanceConfigParameterizedStateTest.kt | 22 ++++++++--------- ...ntrolsKeyguardQuickAffordanceConfigTest.kt | 24 +++++++++---------- ...cannerKeyguardQuickAffordanceConfigTest.kt | 24 +++++++++---------- ...WalletKeyguardQuickAffordanceConfigTest.kt | 22 ++++++++--------- ...ckAffordanceInteractorParameterizedTest.kt | 8 +++---- .../KeyguardQuickAffordanceInteractorTest.kt | 8 +++---- .../FakeKeyguardQuickAffordanceRegistry.kt | 3 ++- .../KeyguardBottomAreaViewModelTest.kt | 8 +++---- 20 files changed, 118 insertions(+), 112 deletions(-) rename packages/SystemUI/src/com/android/systemui/keyguard/{domain => data}/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt (94%) rename packages/SystemUI/src/com/android/systemui/keyguard/{domain => data}/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt (88%) rename packages/SystemUI/src/com/android/systemui/keyguard/{domain => data}/quickaffordance/KeyguardQuickAffordanceConfig.kt (76%) rename packages/SystemUI/src/com/android/systemui/keyguard/{domain => data}/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt (82%) rename packages/SystemUI/src/com/android/systemui/keyguard/{domain => data}/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt (86%) rename packages/SystemUI/src/com/android/systemui/keyguard/{domain/model => shared/quickaffordance}/KeyguardQuickAffordancePosition.kt (92%) rename packages/SystemUI/tests/src/com/android/systemui/keyguard/{domain => data}/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt (92%) rename packages/SystemUI/tests/src/com/android/systemui/keyguard/{domain => data}/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt (88%) rename packages/SystemUI/tests/src/com/android/systemui/keyguard/{domain => data}/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt (85%) rename packages/SystemUI/tests/src/com/android/systemui/keyguard/{domain => data}/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfigTest.kt (86%) rename packages/SystemUI/tests/src/com/android/systemui/keyguard/{domain => data}/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt (89%) diff --git a/packages/SystemUI/docs/device-entry/quickaffordance.md b/packages/SystemUI/docs/device-entry/quickaffordance.md index 38d636d7ff82f..95b986faebb48 100644 --- a/packages/SystemUI/docs/device-entry/quickaffordance.md +++ b/packages/SystemUI/docs/device-entry/quickaffordance.md @@ -8,7 +8,7 @@ credit card, etc. ### Step 1: create a new quick affordance config * Create a new class under the [systemui/keyguard/domain/quickaffordance](../../src/com/android/systemui/keyguard/domain/quickaffordance) directory * Please make sure that the class is injected through the Dagger dependency injection system by using the `@Inject` annotation on its main constructor and the `@SysUISingleton` annotation at class level, to make sure only one instance of the class is ever instantiated -* Have the class implement the [KeyguardQuickAffordanceConfig](../../src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceConfig.kt) interface, notes: +* Have the class implement the [KeyguardQuickAffordanceConfig](../../src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceConfig.kt) interface, notes: * The `state` Flow property must emit `State.Hidden` when the feature is not enabled! * It is safe to assume that `onQuickAffordanceClicked` will not be invoked if-and-only-if the previous rule is followed * When implementing `onQuickAffordanceClicked`, the implementation can do something or it can ask the framework to start an activity using an `Intent` provided by the implementation diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt similarity index 94% rename from packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt rename to packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt index 587721d2196c5..a069582f6692f 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/BuiltInKeyguardQuickAffordanceKeys.kt @@ -15,7 +15,7 @@ * */ -package com.android.systemui.keyguard.domain.quickaffordance +package com.android.systemui.keyguard.data.quickaffordance /** * Unique identifier keys for all known built-in quick affordances. diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt similarity index 88% rename from packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt rename to packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt index 8ef8e1ba87f7e..d3bb34cd29d4e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/HomeControlsKeyguardQuickAffordanceConfig.kt @@ -1,21 +1,21 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2022 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ -package com.android.systemui.keyguard.domain.quickaffordance +package com.android.systemui.keyguard.data.quickaffordance import android.content.Context import android.content.Intent diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceConfig.kt similarity index 76% rename from packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceConfig.kt rename to packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceConfig.kt index 67c4afad73805..0dd0ad7974110 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceConfig.kt @@ -1,21 +1,21 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2022 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ -package com.android.systemui.keyguard.domain.quickaffordance +package com.android.systemui.keyguard.data.quickaffordance import android.content.Intent import com.android.systemui.animation.Expandable diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt similarity index 82% rename from packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt rename to packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt index ac94e1beb0d52..9a441392aa07b 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt @@ -1,21 +1,21 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2022 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ -package com.android.systemui.keyguard.domain.quickaffordance +package com.android.systemui.keyguard.data.quickaffordance import com.android.systemui.R import com.android.systemui.animation.Expandable diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt similarity index 86% rename from packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt rename to packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt index e0bf921edabff..8a1267ebadd15 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt @@ -1,21 +1,21 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2022 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ -package com.android.systemui.keyguard.domain.quickaffordance +package com.android.systemui.keyguard.data.quickaffordance import android.graphics.drawable.Drawable import android.service.quickaccesswallet.GetWalletCardsError 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 3c11a80e6242b..914b9fc52c1ac 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 @@ -21,10 +21,10 @@ import android.content.Intent import com.android.internal.widget.LockPatternUtils import com.android.systemui.animation.Expandable import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordanceModel -import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition -import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceRegistry +import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition import com.android.systemui.plugins.ActivityStarter import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.policy.KeyguardStateController diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceModule.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceModule.kt index 94024d4a0ace7..b48acb65849ed 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceModule.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceModule.kt @@ -17,6 +17,7 @@ package com.android.systemui.keyguard.domain.quickaffordance +import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig import dagger.Binds import dagger.Module diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceRegistry.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceRegistry.kt index 4ea1e1fdff02d..8526ada69569a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceRegistry.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceRegistry.kt @@ -17,7 +17,11 @@ package com.android.systemui.keyguard.domain.quickaffordance -import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition +import com.android.systemui.keyguard.data.quickaffordance.HomeControlsKeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.data.quickaffordance.QrCodeScannerKeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.data.quickaffordance.QuickAccessWalletKeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition import javax.inject.Inject /** Central registry of all known quick affordance configs. */ diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/model/KeyguardQuickAffordancePosition.kt b/packages/SystemUI/src/com/android/systemui/keyguard/shared/quickaffordance/KeyguardQuickAffordancePosition.kt similarity index 92% rename from packages/SystemUI/src/com/android/systemui/keyguard/domain/model/KeyguardQuickAffordancePosition.kt rename to packages/SystemUI/src/com/android/systemui/keyguard/shared/quickaffordance/KeyguardQuickAffordancePosition.kt index 581dafa33df70..a18b036c51897 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/model/KeyguardQuickAffordancePosition.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/shared/quickaffordance/KeyguardQuickAffordancePosition.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.keyguard.domain.model +package com.android.systemui.keyguard.shared.quickaffordance /** Enumerates all possible positions for quick affordances that can appear on the lock-screen. */ enum class KeyguardQuickAffordancePosition { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModel.kt index 535ca72102440..6aac9124bab9a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModel.kt @@ -22,7 +22,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInterac import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordanceModel -import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition +import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordanceToggleState import javax.inject.Inject import kotlinx.coroutines.flow.Flow diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt similarity index 92% rename from packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt rename to packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt index 3cb5cf5222631..ce110084dbc48 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/FakeKeyguardQuickAffordanceConfig.kt @@ -15,10 +15,10 @@ * */ -package com.android.systemui.keyguard.domain.quickaffordance +package com.android.systemui.keyguard.data.quickaffordance import com.android.systemui.animation.Expandable -import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig.OnClickedResult +import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig.OnClickedResult import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.yield diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt similarity index 88% rename from packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt rename to packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt index 9a91ea91f3a2e..b120303d4c045 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest.kt @@ -1,21 +1,21 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2022 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ -package com.android.systemui.keyguard.domain.quickaffordance +package com.android.systemui.keyguard.data.quickaffordance import androidx.test.filters.SmallTest import com.android.systemui.R diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt similarity index 85% rename from packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt rename to packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt index a809f0547ee64..ce8d36d5012a6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/HomeControlsKeyguardQuickAffordanceConfigTest.kt @@ -1,21 +1,21 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2022 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ -package com.android.systemui.keyguard.domain.quickaffordance +package com.android.systemui.keyguard.data.quickaffordance import androidx.test.filters.SmallTest import com.android.systemui.R @@ -23,7 +23,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.animation.Expandable import com.android.systemui.controls.controller.ControlsController import com.android.systemui.controls.dagger.ControlsComponent -import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig.OnClickedResult +import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig.OnClickedResult import com.android.systemui.util.mockito.mock import com.google.common.truth.Truth.assertThat import java.util.Optional diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfigTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfigTest.kt similarity index 86% rename from packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfigTest.kt rename to packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfigTest.kt index 329c4db0a75c5..93464400d1abd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfigTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfigTest.kt @@ -1,26 +1,26 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2022 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ -package com.android.systemui.keyguard.domain.quickaffordance +package com.android.systemui.keyguard.data.quickaffordance import android.content.Intent import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig.OnClickedResult +import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig.OnClickedResult import com.android.systemui.qrcodescanner.controller.QRCodeScannerController import com.android.systemui.util.mockito.argumentCaptor import com.android.systemui.util.mockito.mock diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt similarity index 89% rename from packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt rename to packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt index 98dc4c4f6f76b..ae9e3c7a6f04f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt @@ -1,21 +1,21 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * Copyright (C) 2022 The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ -package com.android.systemui.keyguard.domain.quickaffordance +package com.android.systemui.keyguard.data.quickaffordance import android.graphics.drawable.Drawable import android.service.quickaccesswallet.GetWalletCardsResponse diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt index 8993107f7c96a..114cf19d08377 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt @@ -25,12 +25,12 @@ import com.android.systemui.animation.ActivityLaunchAnimator import com.android.systemui.animation.Expandable import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon +import com.android.systemui.keyguard.data.quickaffordance.BuiltInKeyguardQuickAffordanceKeys +import com.android.systemui.keyguard.data.quickaffordance.FakeKeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition -import com.android.systemui.keyguard.domain.quickaffordance.BuiltInKeyguardQuickAffordanceKeys -import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceConfig import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry -import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition import com.android.systemui.plugins.ActivityStarter import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.policy.KeyguardStateController 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 503f41b60d068..1a1ee8aca0992 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 @@ -22,13 +22,13 @@ import com.android.internal.widget.LockPatternUtils import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon +import com.android.systemui.keyguard.data.quickaffordance.BuiltInKeyguardQuickAffordanceKeys +import com.android.systemui.keyguard.data.quickaffordance.FakeKeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordanceModel -import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition -import com.android.systemui.keyguard.domain.quickaffordance.BuiltInKeyguardQuickAffordanceKeys -import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceConfig import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry -import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordanceToggleState import com.android.systemui.plugins.ActivityStarter import com.android.systemui.settings.UserTracker diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceRegistry.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceRegistry.kt index ec3b0cefd7f83..13e2768e1fd0a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceRegistry.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/quickaffordance/FakeKeyguardQuickAffordanceRegistry.kt @@ -17,7 +17,8 @@ package com.android.systemui.keyguard.domain.quickaffordance -import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition +import com.android.systemui.keyguard.data.quickaffordance.FakeKeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition /** Fake implementation of [FakeKeyguardQuickAffordanceRegistry], for tests. */ class FakeKeyguardQuickAffordanceRegistry( diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt index eb8fb67280a7e..f9be067362d3b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt @@ -23,15 +23,15 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.animation.Expandable import com.android.systemui.common.shared.model.Icon import com.android.systemui.doze.util.BurnInHelperWrapper +import com.android.systemui.keyguard.data.quickaffordance.BuiltInKeyguardQuickAffordanceKeys +import com.android.systemui.keyguard.data.quickaffordance.FakeKeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor -import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordancePosition -import com.android.systemui.keyguard.domain.quickaffordance.BuiltInKeyguardQuickAffordanceKeys -import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceConfig import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry -import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceConfig +import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordanceToggleState import com.android.systemui.plugins.ActivityStarter import com.android.systemui.settings.UserTracker