Loading packages/SystemUI/src/com/android/systemui/flags/RefactorFlagUtils.kt +16 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,22 @@ object RefactorFlagUtils { inline fun assertInLegacyMode(isEnabled: Boolean, flagName: Any) = 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: Loading packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/QSPipelineFlagsRepository.kt +2 −2 Original line number Diff line number Diff line Loading @@ -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 ) Loading packages/SystemUI/src/com/android/systemui/qs/tiles/di/NewQSTileFactory.kt +2 −2 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ constructor( ) : QSFactory { init { QSPipelineFlagsRepository.assertNewTilesInLegacyMode() QSPipelineFlagsRepository.assertNewTiles() for (viewModelTileSpec in tileMap.keys) { require(qsTileConfigProvider.hasConfig(viewModelTileSpec)) { "No config for $viewModelTileSpec" Loading @@ -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 } Loading Loading
packages/SystemUI/src/com/android/systemui/flags/RefactorFlagUtils.kt +16 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,22 @@ object RefactorFlagUtils { inline fun assertInLegacyMode(isEnabled: Boolean, flagName: Any) = 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: Loading
packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/QSPipelineFlagsRepository.kt +2 −2 Original line number Diff line number Diff line Loading @@ -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 ) Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/di/NewQSTileFactory.kt +2 −2 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ constructor( ) : QSFactory { init { QSPipelineFlagsRepository.assertNewTilesInLegacyMode() QSPipelineFlagsRepository.assertNewTiles() for (viewModelTileSpec in tileMap.keys) { require(qsTileConfigProvider.hasConfig(viewModelTileSpec)) { "No config for $viewModelTileSpec" Loading @@ -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 } Loading