Merge "Fix qs_new_tiles flag assert" into main
diff --git a/packages/SystemUI/src/com/android/systemui/flags/RefactorFlagUtils.kt b/packages/SystemUI/src/com/android/systemui/flags/RefactorFlagUtils.kt
index ae67e60..4d89a82 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/RefactorFlagUtils.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/RefactorFlagUtils.kt
@@ -79,6 +79,22 @@
check(!isEnabled) { "Legacy code path not supported when $flagName is enabled." }
/**
+ * Called to ensure the new code is only run when the flag is enabled. This will throw an
+ * exception if the flag is disabled to ensure that the refactor author catches issues in
+ * testing.
+ *
+ * Example usage:
+ * ```
+ * public void setSomeNewController(SomeController someController) {
+ * SomeRefactor.assertInNewMode();
+ * mSomeController = someController;
+ * }
+ * ````
+ */
+ inline fun assertInNewMode(isEnabled: Boolean, flagName: Any) =
+ check(isEnabled) { "New code path not supported when $flagName is disabled." }
+
+ /**
* This will [Log.wtf] with the given message, assuming [ASSERT_TAG] is loggable at that level.
* This means an engineer can prevent this from crashing by running the command:
* ```
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 935d072..42bee3c 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
@@ -22,8 +22,8 @@
AconfigFlags.FLAG_QS_NEW_PIPELINE
)
- fun assertNewTilesInLegacyMode() =
- RefactorFlagUtils.assertInLegacyMode(
+ fun assertNewTiles() =
+ RefactorFlagUtils.assertInNewMode(
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 52e49f9..382cfe2 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
@@ -45,7 +45,7 @@
) : QSFactory {
init {
- QSPipelineFlagsRepository.assertNewTilesInLegacyMode()
+ QSPipelineFlagsRepository.assertNewTiles()
for (viewModelTileSpec in tileMap.keys) {
require(qsTileConfigProvider.hasConfig(viewModelTileSpec)) {
"No config for $viewModelTileSpec"
@@ -56,7 +56,7 @@
override fun createTile(tileSpec: String): QSTile? {
val viewModel: QSTileViewModel =
when (val spec = TileSpec.create(tileSpec)) {
- is TileSpec.CustomTileSpec -> createCustomTileViewModel(spec)
+ is TileSpec.CustomTileSpec -> null
is TileSpec.PlatformTileSpec -> tileMap[tileSpec]?.get()
is TileSpec.Invalid -> null
}