Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3a17cad authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge "Fix qs_new_tiles flag assert" into main

parents f917eaec a1995923
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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:
+2 −2
Original line number Diff line number Diff line
@@ -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
            )
+2 −2
Original line number Diff line number Diff line
@@ -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
            }