Migrate to new tiles aconfig flags
Bug: b/311147395
Test: atest QSPipelineFlagsRepositoryTest
Test: atest CurrentTilesInteractorImplTest
Test: atest QSTileHostTest
Flag: ACONFIG com.android.systemui.qs_new_pipeline DISABLED
Change-Id: I60606b6f7edd0ed08dbd7dfef0bd3a0d2f230ad2
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 77c4aa6..7404860 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -138,6 +138,13 @@
}
flag {
+ name: "qs_new_tiles"
+ namespace: "systemui"
+ description: "Use the new tiles in the Quick Settings. Should have no behavior changes."
+ bug: "241772429"
+}
+
+flag {
name: "coroutine_tracing"
namespace: "systemui"
description: "Adds thread-local data to System UI's global coroutine scopes to "
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/CurrentTilesInteractorImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/CurrentTilesInteractorImplTest.kt
index 8c896a6..1e2784a 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/CurrentTilesInteractorImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/interactor/CurrentTilesInteractorImplTest.kt
@@ -25,11 +25,10 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_QS_NEW_PIPELINE
+import com.android.systemui.Flags.FLAG_QS_NEW_TILES
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.dump.nano.SystemUIProtoDump
-import com.android.systemui.flags.FakeFeatureFlags
-import com.android.systemui.flags.Flags
import com.android.systemui.plugins.qs.QSTile
import com.android.systemui.plugins.qs.QSTile.BooleanState
import com.android.systemui.qs.FakeQSFactory
@@ -81,8 +80,7 @@
private val tileFactory = FakeQSFactory(::tileCreator)
private val customTileAddedRepository: CustomTileAddedRepository =
FakeCustomTileAddedRepository()
- private val featureFlags = FakeFeatureFlags()
- private val pipelineFlags = QSPipelineFlagsRepository(featureFlags)
+ private val pipelineFlags = QSPipelineFlagsRepository()
private val tileLifecycleManagerFactory = TLMFactory()
@Mock private lateinit var customTileStatePersister: CustomTileStatePersister
@@ -100,14 +98,12 @@
private lateinit var underTest: CurrentTilesInteractorImpl
- @OptIn(ExperimentalCoroutinesApi::class)
@Before
fun setup() {
MockitoAnnotations.initMocks(this)
mSetFlagsRule.enableFlags(FLAG_QS_NEW_PIPELINE)
- // TODO(b/299909337): Add test checking the new factory is used when the flag is on
- featureFlags.set(Flags.QS_PIPELINE_NEW_TILES, true)
+ mSetFlagsRule.enableFlags(FLAG_QS_NEW_TILES)
userRepository.setUserInfos(listOf(USER_INFO_0, USER_INFO_1))
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
index ff65b31..d7e63e6 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
@@ -289,10 +289,6 @@
"qs_user_detail_shortcut"
)
- // TODO(b/296357483): Tracking Bug
- @JvmField
- val QS_PIPELINE_NEW_TILES = unreleasedFlag("qs_pipeline_new_tiles")
-
// TODO(b/254512383): Tracking Bug
@JvmField
val FULL_SCREEN_USER_SWITCHER =
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
index 0b3bbb5..99054a4 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
@@ -188,7 +188,7 @@
LogBufferFactory factory,
QSPipelineFlagsRepository flags
) {
- if (flags.getPipelineTilesEnabled()) {
+ if (flags.getTilesEnabled()) {
// we use
return factory.create("QSLog", 450 /* maxSize */, false /* systrace */);
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
index 1fab58e..828d6ed 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
@@ -57,6 +57,8 @@
import com.android.systemui.tuner.TunerService.Tunable;
import com.android.systemui.util.settings.SecureSettings;
+import dagger.Lazy;
+
import org.jetbrains.annotations.NotNull;
import java.io.PrintWriter;
@@ -73,8 +75,6 @@
import javax.inject.Inject;
import javax.inject.Provider;
-import dagger.Lazy;
-
/** Platform implementation of the quick settings tile host
*
* This class keeps track of the set of current tiles and is the in memory source of truth
@@ -151,7 +151,7 @@
mShadeController = shadeController;
- if (featureFlags.getPipelineTilesEnabled()) {
+ if (featureFlags.getTilesEnabled()) {
mQsFactories.add(newQsTileFactoryProvider.get());
}
mQsFactories.add(defaultFactory);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/domain/interactor/CurrentTilesInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/domain/interactor/CurrentTilesInteractor.kt
index 4bda730..5d28c8c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/pipeline/domain/interactor/CurrentTilesInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/domain/interactor/CurrentTilesInteractor.kt
@@ -336,7 +336,7 @@
private suspend fun createTile(spec: TileSpec): QSTile? {
val tile =
withContext(mainDispatcher) {
- if (featureFlags.pipelineTilesEnabled) {
+ if (featureFlags.tilesEnabled) {
newQSTileFactory.get().createTile(spec.spec)
} else {
null
diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/QSPipelineFlagsRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/QSPipelineFlagsRepository.kt
index 5c7420c..935d072 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/QSPipelineFlagsRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/QSPipelineFlagsRepository.kt
@@ -2,24 +2,18 @@
import com.android.systemui.Flags as AconfigFlags
import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.flags.FeatureFlagsClassic
-import com.android.systemui.flags.Flags
import com.android.systemui.flags.RefactorFlagUtils
import javax.inject.Inject
/** Encapsulate the different QS pipeline flags and their dependencies */
@SysUISingleton
-class QSPipelineFlagsRepository
-@Inject
-constructor(
- private val featureFlags: FeatureFlagsClassic,
-) {
+class QSPipelineFlagsRepository @Inject constructor() {
+
val pipelineEnabled: Boolean
get() = AconfigFlags.qsNewPipeline()
- /** @see Flags.QS_PIPELINE_NEW_TILES */
- val pipelineTilesEnabled: Boolean
- get() = featureFlags.isEnabled(Flags.QS_PIPELINE_NEW_TILES)
+ val tilesEnabled: Boolean
+ get() = AconfigFlags.qsNewTiles()
companion object Utils {
fun assertInLegacyMode() =
@@ -27,5 +21,11 @@
AconfigFlags.qsNewPipeline(),
AconfigFlags.FLAG_QS_NEW_PIPELINE
)
+
+ fun assertNewTilesInLegacyMode() =
+ RefactorFlagUtils.assertInLegacyMode(
+ AconfigFlags.qsNewTiles(),
+ AconfigFlags.FLAG_QS_NEW_TILES
+ )
}
}
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 27007bb..52e49f9 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 @@
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.pipeline.shared.QSPipelineFlagsRepository
import com.android.systemui.qs.pipeline.shared.TileSpec
import com.android.systemui.qs.tiles.base.viewmodel.QSTileViewModelFactory
import com.android.systemui.qs.tiles.impl.custom.di.CustomTileComponent
@@ -44,6 +45,7 @@
) : QSFactory {
init {
+ QSPipelineFlagsRepository.assertNewTilesInLegacyMode()
for (viewModelTileSpec in tileMap.keys) {
require(qsTileConfigProvider.hasConfig(viewModelTileSpec)) {
"No config for $viewModelTileSpec"
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
index 5245b22..5e2423a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
@@ -18,6 +18,7 @@
import static com.android.systemui.Flags.FLAG_QS_NEW_PIPELINE;
+import static com.android.systemui.Flags.FLAG_QS_NEW_TILES;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
@@ -53,7 +54,6 @@
import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.dump.nano.SystemUIProtoDump;
import com.android.systemui.flags.FakeFeatureFlags;
-import com.android.systemui.flags.Flags;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.PluginManager;
import com.android.systemui.plugins.qs.QSFactory;
@@ -79,6 +79,8 @@
import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.util.time.FakeSystemClock;
+import dagger.Lazy;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -93,8 +95,6 @@
import javax.inject.Provider;
-import dagger.Lazy;
-
@RunWith(AndroidTestingRunner.class)
@SmallTest
public class QSTileHostTest extends SysuiTestCase {
@@ -147,9 +147,8 @@
mFeatureFlags = new FakeFeatureFlags();
mSetFlagsRule.disableFlags(FLAG_QS_NEW_PIPELINE);
- // TODO(b/299909337): Add test checking the new factory is used when the flag is on
- mFeatureFlags.set(Flags.QS_PIPELINE_NEW_TILES, false);
- mQSPipelineFlagsRepository = new QSPipelineFlagsRepository(mFeatureFlags);
+ mSetFlagsRule.disableFlags(FLAG_QS_NEW_TILES);
+ mQSPipelineFlagsRepository = new QSPipelineFlagsRepository();
mMainExecutor = new FakeExecutor(new FakeSystemClock());
@@ -704,7 +703,7 @@
TileLifecycleManager.Factory tileLifecycleManagerFactory,
UserFileManager userFileManager, QSPipelineFlagsRepository featureFlags) {
super(context, newQSTileFactoryProvider, defaultFactory, mainExecutor, pluginManager,
- tunerService, autoTiles, shadeController, qsLogger,
+ tunerService, autoTiles, shadeController, qsLogger,
userTracker, secureSettings, customTileStatePersister,
tileLifecycleManagerFactory, userFileManager, featureFlags);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/pipeline/shared/QSPipelineFlagsRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/pipeline/shared/QSPipelineFlagsRepositoryTest.kt
index 2e63708..970cd17 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/pipeline/shared/QSPipelineFlagsRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/pipeline/shared/QSPipelineFlagsRepositoryTest.kt
@@ -4,7 +4,6 @@
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
-import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@@ -13,9 +12,7 @@
@RunWith(AndroidJUnit4::class)
class QSPipelineFlagsRepositoryTest : SysuiTestCase() {
- private val fakeFeatureFlagsClassic = FakeFeatureFlagsClassic()
-
- private val underTest = QSPipelineFlagsRepository(fakeFeatureFlagsClassic)
+ private val underTest = QSPipelineFlagsRepository()
@Test
fun pipelineFlagDisabled() {
@@ -30,4 +27,18 @@
assertThat(underTest.pipelineEnabled).isTrue()
}
+
+ @Test
+ fun tilesFlagDisabled() {
+ mSetFlagsRule.disableFlags(Flags.FLAG_QS_NEW_TILES)
+
+ assertThat(underTest.tilesEnabled).isFalse()
+ }
+
+ @Test
+ fun tilesFlagEnabled() {
+ mSetFlagsRule.enableFlags(Flags.FLAG_QS_NEW_TILES)
+
+ assertThat(underTest.tilesEnabled).isTrue()
+ }
}