diff options
author | 2023-12-14 14:45:44 +0000 | |
---|---|---|
committer | 2023-12-14 14:45:44 +0000 | |
commit | a3a17cada56111c4782c549b505dc3ba4e44314c (patch) | |
tree | 5766ad925fc6379cc693c1fe4b362c1f58ac21f4 | |
parent | f917eaec7924bc37300c78fc6b04c0f0f242930e (diff) | |
parent | a1995923a9f0e4c8704da8f181b9a290f5b8b117 (diff) |
Merge "Fix qs_new_tiles flag assert" into main
3 files changed, 20 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/flags/RefactorFlagUtils.kt b/packages/SystemUI/src/com/android/systemui/flags/RefactorFlagUtils.kt index ae67e60b75f7..4d89a826b60a 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 @@ object RefactorFlagUtils { 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 935d07229ae5..42bee3c8f877 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 @@ class QSPipelineFlagsRepository @Inject constructor() { 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 52e49f9d2653..382cfe267aae 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 @@ constructor( ) : QSFactory { init { - QSPipelineFlagsRepository.assertNewTilesInLegacyMode() + QSPipelineFlagsRepository.assertNewTiles() for (viewModelTileSpec in tileMap.keys) { require(qsTileConfigProvider.hasConfig(viewModelTileSpec)) { "No config for $viewModelTileSpec" @@ -56,7 +56,7 @@ constructor( 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 } |