summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Anton Potapov <apotapov@google.com> 2023-10-26 17:19:34 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-10-26 17:19:34 +0000
commit70d7562b9e3daddd218c29e1281818c013f556c1 (patch)
treec94eb7b85e233e379bdc4aa18c43727d1e54426a
parent84256a77cab042a9a7bf5ec2ea5e5723ab14d808 (diff)
parenta7d2f458c59f603de1f9893a6d698eb36295e92a (diff)
Merge "Rework config to support absence of label and icon in CustomTile" into main
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/dagger/QSModule.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelFactory.kt15
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImpl.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/di/NewQSTileFactory.kt9
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/di/QSTilesModule.kt21
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/di/QSTileComponent.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfig.kt35
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProvider.kt49
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt8
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProviderTest.kt58
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelInterfaceComplianceTest.kt12
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/FakeQSTileConfigProvider.kt32
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigTestBuilder.kt9
13 files changed, 221 insertions, 42 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/dagger/QSModule.java b/packages/SystemUI/src/com/android/systemui/qs/dagger/QSModule.java
index 8f26e694a067..bd4c6e1930ba 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/dagger/QSModule.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/dagger/QSModule.java
@@ -32,7 +32,6 @@ import com.android.systemui.qs.external.QSExternalModule;
import com.android.systemui.qs.pipeline.dagger.QSPipelineModule;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.qs.tiles.di.QSTilesModule;
-import com.android.systemui.qs.tiles.viewmodel.QSTileViewModel;
import com.android.systemui.statusbar.phone.AutoTileManager;
import com.android.systemui.statusbar.phone.ManagedProfileController;
import com.android.systemui.statusbar.policy.CastController;
@@ -73,13 +72,6 @@ public interface QSModule {
@Multibinds
Map<String, QSTileImpl<?>> tileMap();
- /**
- * A map of internal QS tile ViewModels. Ensures that this can be injected even if
- * it is empty
- */
- @Multibinds
- Map<String, QSTileViewModel> tileViewModelMap();
-
@Provides
@SysUISingleton
static AutoTileManager provideAutoTileManager(
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelFactory.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelFactory.kt
index 936bf9c8f4da..736f7cfbfce9 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelFactory.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelFactory.kt
@@ -18,6 +18,7 @@ package com.android.systemui.qs.tiles.base.viewmodel
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.plugins.FalsingManager
+import com.android.systemui.qs.pipeline.shared.TileSpec
import com.android.systemui.qs.tiles.base.analytics.QSTileAnalytics
import com.android.systemui.qs.tiles.base.interactor.DisabledByPolicyInteractor
import com.android.systemui.qs.tiles.base.interactor.QSTileDataInteractor
@@ -25,7 +26,7 @@ import com.android.systemui.qs.tiles.base.interactor.QSTileDataToStateMapper
import com.android.systemui.qs.tiles.base.interactor.QSTileUserActionInteractor
import com.android.systemui.qs.tiles.base.logging.QSTileLogger
import com.android.systemui.qs.tiles.impl.di.QSTileComponent
-import com.android.systemui.qs.tiles.viewmodel.QSTileConfig
+import com.android.systemui.qs.tiles.viewmodel.QSTileConfigProvider
import com.android.systemui.qs.tiles.viewmodel.QSTileState
import com.android.systemui.user.data.repository.UserRepository
import com.android.systemui.util.time.SystemClock
@@ -53,6 +54,7 @@ sealed interface QSTileViewModelFactory<T> {
private val falsingManager: FalsingManager,
private val qsTileAnalytics: QSTileAnalytics,
private val qsTileLogger: QSTileLogger,
+ private val qsTileConfigProvider: QSTileConfigProvider,
private val systemClock: SystemClock,
@Background private val backgroundDispatcher: CoroutineDispatcher,
) : QSTileViewModelFactory<T> {
@@ -61,9 +63,9 @@ sealed interface QSTileViewModelFactory<T> {
* Creates [QSTileViewModelImpl] based on the interactors obtained from [component].
* Reference of that [component] is then stored along the view model.
*/
- fun create(component: QSTileComponent<T>): QSTileViewModelImpl<T> =
+ fun create(tileSpec: TileSpec, component: QSTileComponent<T>): QSTileViewModelImpl<T> =
QSTileViewModelImpl(
- component::config,
+ qsTileConfigProvider.getConfig(tileSpec.spec),
component::userActionInteractor,
component::dataInteractor,
component::dataToStateMapper,
@@ -89,12 +91,13 @@ sealed interface QSTileViewModelFactory<T> {
private val falsingManager: FalsingManager,
private val qsTileAnalytics: QSTileAnalytics,
private val qsTileLogger: QSTileLogger,
+ private val qsTileConfigProvider: QSTileConfigProvider,
private val systemClock: SystemClock,
@Background private val backgroundDispatcher: CoroutineDispatcher,
) : QSTileViewModelFactory<T> {
/**
- * @param config contains all the static information (like TileSpec) about the tile.
+ * @param tileSpec of the created tile.
* @param userActionInteractor encapsulates user input processing logic. Use it to start
* activities, show dialogs or otherwise update the tile state.
* @param tileDataInteractor provides [DATA_TYPE] and its availability.
@@ -103,13 +106,13 @@ sealed interface QSTileViewModelFactory<T> {
* operations there.
*/
fun create(
- config: QSTileConfig,
+ tileSpec: TileSpec,
userActionInteractor: QSTileUserActionInteractor<T>,
tileDataInteractor: QSTileDataInteractor<T>,
mapper: QSTileDataToStateMapper<T>,
): QSTileViewModelImpl<T> =
QSTileViewModelImpl(
- { config },
+ qsTileConfigProvider.getConfig(tileSpec.spec),
{ userActionInteractor },
{ tileDataInteractor },
{ mapper },
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImpl.kt
index bbb74453abbd..0bee48fd01ab 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImpl.kt
@@ -67,7 +67,7 @@ import kotlinx.coroutines.flow.stateIn
*/
@OptIn(ExperimentalCoroutinesApi::class)
class QSTileViewModelImpl<DATA_TYPE>(
- val tileConfig: () -> QSTileConfig,
+ override val config: QSTileConfig,
private val userActionInteractor: () -> QSTileUserActionInteractor<DATA_TYPE>,
private val tileDataInteractor: () -> QSTileDataInteractor<DATA_TYPE>,
private val mapper: () -> QSTileDataToStateMapper<DATA_TYPE>,
@@ -92,8 +92,6 @@ class QSTileViewModelImpl<DATA_TYPE>(
private val tileData: SharedFlow<DATA_TYPE> = createTileDataFlow()
- override val config
- get() = tileConfig()
override val state: SharedFlow<QSTileState> =
tileData
.map { data ->
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/di/NewQSTileFactory.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/di/NewQSTileFactory.kt
index 0a6becd6e4ca..7d7af64a3038 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/di/NewQSTileFactory.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/di/NewQSTileFactory.kt
@@ -19,6 +19,7 @@ package com.android.systemui.qs.tiles.di
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.plugins.qs.QSFactory
import com.android.systemui.plugins.qs.QSTile
+import com.android.systemui.qs.tiles.viewmodel.QSTileConfigProvider
import com.android.systemui.qs.tiles.viewmodel.QSTileViewModel
import com.android.systemui.qs.tiles.viewmodel.QSTileViewModelAdapter
import javax.inject.Inject
@@ -29,11 +30,19 @@ import javax.inject.Provider
class NewQSTileFactory
@Inject
constructor(
+ qsTileConfigProvider: QSTileConfigProvider,
private val adapterFactory: QSTileViewModelAdapter.Factory,
private val tileMap:
Map<String, @JvmSuppressWildcards Provider<@JvmSuppressWildcards QSTileViewModel>>,
) : QSFactory {
+ init {
+ for (viewModelTileSpec in tileMap.keys) {
+ // throws an exception when there is no config for a tileSpec of an injected viewModel
+ qsTileConfigProvider.getConfig(viewModelTileSpec)
+ }
+ }
+
override fun createTile(tileSpec: String): QSTile? =
tileMap[tileSpec]?.let {
val tile = it.get()
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/di/QSTilesModule.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/di/QSTilesModule.kt
index 94b39b6db9d2..32522ad66626 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/di/QSTilesModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/di/QSTilesModule.kt
@@ -17,7 +17,13 @@
package com.android.systemui.qs.tiles.di
import com.android.systemui.qs.tiles.impl.custom.di.CustomTileComponent
+import com.android.systemui.qs.tiles.viewmodel.QSTileConfig
+import com.android.systemui.qs.tiles.viewmodel.QSTileConfigProvider
+import com.android.systemui.qs.tiles.viewmodel.QSTileConfigProviderImpl
+import com.android.systemui.qs.tiles.viewmodel.QSTileViewModel
+import dagger.Binds
import dagger.Module
+import dagger.multibindings.Multibinds
/** Module listing subcomponents */
@Module(
@@ -26,4 +32,17 @@ import dagger.Module
CustomTileComponent::class,
]
)
-interface QSTilesModule
+interface QSTilesModule {
+
+ /**
+ * A map of internal QS tile ViewModels. Ensures that this can be injected even if it is empty
+ */
+ @Multibinds fun tileViewModelConfigs(): Map<String, QSTileConfig>
+
+ /**
+ * A map of internal QS tile ViewModels. Ensures that this can be injected even if it is empty
+ */
+ @Multibinds fun tileViewModelMap(): Map<String, QSTileViewModel>
+
+ @Binds fun bindQSTileConfigProvider(impl: QSTileConfigProviderImpl): QSTileConfigProvider
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/di/QSTileComponent.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/di/QSTileComponent.kt
index 6f351cdb9b33..b3d916a86144 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/di/QSTileComponent.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/di/QSTileComponent.kt
@@ -19,7 +19,6 @@ package com.android.systemui.qs.tiles.impl.di
import com.android.systemui.qs.tiles.base.interactor.QSTileDataInteractor
import com.android.systemui.qs.tiles.base.interactor.QSTileDataToStateMapper
import com.android.systemui.qs.tiles.base.interactor.QSTileUserActionInteractor
-import com.android.systemui.qs.tiles.viewmodel.QSTileConfig
/**
* Base QS tile component. It should be used with [QSTileScope] to create a custom tile scoped
@@ -32,7 +31,5 @@ interface QSTileComponent<T> {
fun userActionInteractor(): QSTileUserActionInteractor<T>
- fun config(): QSTileConfig
-
fun dataToStateMapper(): QSTileDataToStateMapper<T>
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfig.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfig.kt
index 4a3bcae17fd0..c4d7dfba23bf 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfig.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfig.kt
@@ -16,20 +16,49 @@
package com.android.systemui.qs.tiles.viewmodel
+import android.content.res.Resources
+import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import com.android.internal.logging.InstanceId
-import com.android.systemui.common.shared.model.Icon
import com.android.systemui.qs.pipeline.shared.TileSpec
data class QSTileConfig(
val tileSpec: TileSpec,
- val tileIcon: Icon,
- @StringRes val tileLabelRes: Int,
+ val uiConfig: QSTileUIConfig,
val instanceId: InstanceId,
val metricsSpec: String = tileSpec.spec,
val policy: QSTilePolicy = QSTilePolicy.NoRestrictions,
)
+/**
+ * Static tile icon and label to be used when the fully operational tile isn't needed (ex. in edit
+ * mode). Icon and label are resources to better support config/locale changes.
+ */
+sealed interface QSTileUIConfig {
+
+ val tileIconRes: Int
+ @DrawableRes get
+ val tileLabelRes: Int
+ @StringRes get
+
+ /**
+ * Represents the absence of static UI state. This should be avoided by platform tiles in favour
+ * of [Resource]. Returns [Resources.ID_NULL] for each field.
+ */
+ data object Empty : QSTileUIConfig {
+ override val tileIconRes: Int
+ get() = Resources.ID_NULL
+ override val tileLabelRes: Int
+ get() = Resources.ID_NULL
+ }
+
+ /** Config containing actual icon and label resources. */
+ data class Resource(
+ @StringRes override val tileIconRes: Int,
+ @StringRes override val tileLabelRes: Int,
+ ) : QSTileUIConfig
+}
+
/** Represents policy restrictions that may be imposed on the tile. */
sealed interface QSTilePolicy {
/** Tile has no policy restrictions */
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProvider.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProvider.kt
new file mode 100644
index 000000000000..3f3b94e65294
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProvider.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2023 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.qs.tiles.viewmodel
+
+import com.android.internal.util.Preconditions
+import com.android.systemui.dagger.SysUISingleton
+import javax.inject.Inject
+
+interface QSTileConfigProvider {
+
+ /**
+ * Returns a [QSTileConfig] for a [tileSpec] or throws [IllegalArgumentException] if there is no
+ * config for such [tileSpec].
+ */
+ fun getConfig(tileSpec: String): QSTileConfig
+}
+
+@SysUISingleton
+class QSTileConfigProviderImpl @Inject constructor(private val configs: Map<String, QSTileConfig>) :
+ QSTileConfigProvider {
+
+ init {
+ for (entry in configs.entries) {
+ val configTileSpec = entry.value.tileSpec.spec
+ val keyTileSpec = entry.key
+ Preconditions.checkArgument(
+ configTileSpec == keyTileSpec,
+ "A wrong config is injected keySpec=$keyTileSpec configSpec=$configTileSpec"
+ )
+ }
+ }
+
+ override fun getConfig(tileSpec: String): QSTileConfig =
+ configs[tileSpec] ?: throw IllegalArgumentException("There is no config for spec=$tileSpec")
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt
index 28536f5b19a7..efa6da764e6e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt
@@ -189,7 +189,13 @@ constructor(
override fun getInstanceId(): InstanceId = qsTileViewModel.config.instanceId
override fun getTileLabel(): CharSequence =
- context.getString(qsTileViewModel.config.tileLabelRes)
+ with(qsTileViewModel.config.uiConfig) {
+ when (this) {
+ is QSTileUIConfig.Empty -> qsTileViewModel.currentState?.label ?: ""
+ is QSTileUIConfig.Resource -> context.getString(tileLabelRes)
+ }
+ }
+
override fun getTileSpec(): String = qsTileViewModel.config.tileSpec.spec
private companion object {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProviderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProviderTest.kt
new file mode 100644
index 000000000000..682b2d0d3983
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProviderTest.kt
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2023 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.qs.tiles.viewmodel
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class QSTileConfigProviderTest : SysuiTestCase() {
+
+ private val underTest =
+ QSTileConfigProviderImpl(
+ mapOf(VALID_SPEC.spec to QSTileConfigTestBuilder.build { tileSpec = VALID_SPEC })
+ )
+
+ @Test
+ fun providerReturnsConfig() {
+ assertThat(underTest.getConfig(VALID_SPEC.spec)).isNotNull()
+ }
+
+ @Test(expected = IllegalArgumentException::class)
+ fun throwsForInvalidSpec() {
+ underTest.getConfig(INVALID_SPEC.spec)
+ }
+
+ @Test(expected = IllegalArgumentException::class)
+ fun validatesSpecUponCreation() {
+ QSTileConfigProviderImpl(
+ mapOf(VALID_SPEC.spec to QSTileConfigTestBuilder.build { tileSpec = INVALID_SPEC })
+ )
+ }
+
+ private companion object {
+
+ val VALID_SPEC = TileSpec.create("valid_tile_spec")
+ val INVALID_SPEC = TileSpec.create("invalid_tile_spec")
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelInterfaceComplianceTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelInterfaceComplianceTest.kt
index 1a4553558e28..9bf4a759a1f2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelInterfaceComplianceTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelInterfaceComplianceTest.kt
@@ -20,12 +20,10 @@ import android.os.UserHandle
import android.testing.TestableLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
-import com.android.internal.logging.InstanceId
import com.android.systemui.SysuiTestCase
import com.android.systemui.classifier.FalsingManagerFake
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.common.shared.model.Icon
-import com.android.systemui.qs.pipeline.shared.TileSpec
import com.android.systemui.qs.tiles.base.analytics.QSTileAnalytics
import com.android.systemui.qs.tiles.base.interactor.FakeDisabledByPolicyInteractor
import com.android.systemui.qs.tiles.base.interactor.FakeQSTileDataInteractor
@@ -93,7 +91,7 @@ class QSTileViewModelInterfaceComplianceTest : SysuiTestCase() {
config: QSTileConfig = TEST_QS_TILE_CONFIG,
): QSTileViewModel =
QSTileViewModelImpl(
- { config },
+ config,
{ fakeQSTileUserActionInteractor },
{ fakeQSTileDataInteractor },
{
@@ -114,12 +112,6 @@ class QSTileViewModelInterfaceComplianceTest : SysuiTestCase() {
private companion object {
- val TEST_QS_TILE_CONFIG =
- QSTileConfig(
- TileSpec.create("default"),
- Icon.Resource(0, null),
- 0,
- InstanceId.fakeInstanceId(0),
- )
+ val TEST_QS_TILE_CONFIG = QSTileConfigTestBuilder.build {}
}
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/FakeQSTileConfigProvider.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/FakeQSTileConfigProvider.kt
new file mode 100644
index 000000000000..de72a7dc30d7
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/FakeQSTileConfigProvider.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2023 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.qs.tiles.viewmodel
+
+import com.android.systemui.qs.pipeline.shared.TileSpec
+
+class FakeQSTileConfigProvider : QSTileConfigProvider {
+
+ private val configs: MutableMap<String, QSTileConfig> = mutableMapOf()
+
+ override fun getConfig(tileSpec: String): QSTileConfig = configs.getValue(tileSpec)
+
+ fun putConfig(tileSpec: TileSpec, config: QSTileConfig) {
+ configs[tileSpec.spec] = config
+ }
+
+ fun removeConfig(tileSpec: TileSpec): QSTileConfig? = configs.remove(tileSpec.spec)
+}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigTestBuilder.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigTestBuilder.kt
index 201926df5a5c..2a0ee888db35 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigTestBuilder.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigTestBuilder.kt
@@ -16,10 +16,7 @@
package com.android.systemui.qs.tiles.viewmodel
-import androidx.annotation.StringRes
import com.android.internal.logging.InstanceId
-import com.android.systemui.common.shared.model.ContentDescription
-import com.android.systemui.common.shared.model.Icon
import com.android.systemui.qs.pipeline.shared.TileSpec
object QSTileConfigTestBuilder {
@@ -29,8 +26,7 @@ object QSTileConfigTestBuilder {
class BuildingScope {
var tileSpec: TileSpec = TileSpec.create("test_spec")
- var tileIcon: Icon = Icon.Resource(0, ContentDescription.Resource(0))
- @StringRes var tileLabel: Int = 0
+ var uiConfig: QSTileUIConfig = QSTileUIConfig.Empty
var instanceId: InstanceId = InstanceId.fakeInstanceId(0)
var metricsSpec: String = tileSpec.spec
var policy: QSTilePolicy = QSTilePolicy.NoRestrictions
@@ -38,8 +34,7 @@ object QSTileConfigTestBuilder {
fun build() =
QSTileConfig(
tileSpec,
- tileIcon,
- tileLabel,
+ uiConfig,
instanceId,
metricsSpec,
policy,