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

Commit 9a3933b7 authored by Behnam Heydarshahi's avatar Behnam Heydarshahi
Browse files

Cache QSTileViewModelAdapter state on addCallback

Should remove duplicate work from QS open CUJ

Flag: com.android.systemui.qs_new_tiles
Test: Manual. Open QS. Verify that state change slice no
longer shows up in perfetto for platform tiles in the set {QS}-{QQS}.
Test: atest TileQueryHelperTest
Test: atest CtsTileServiceTestCases
Bug: 380532825

Change-Id: I166ff019f7bcff197b2c8c1e00f4e2466fd2d310
parent d5ea09ee
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -118,7 +118,8 @@ constructor(
    override fun addCallback(callback: QSTile.Callback?) {
        callback ?: return
        callbacks.add(callback)
        state?.let(callback::onStateChanged)
        state.copyTo(cachedState)
        state.let(callback::onStateChanged)
    }

    override fun removeCallback(callback: QSTile.Callback?) {
@@ -212,9 +213,9 @@ constructor(
        qsTileViewModel.destroy()
    }

    override fun getState(): QSTile.State =
    override fun getState(): QSTile.AdapterState =
        qsTileViewModel.currentState?.let { mapState(context, it, qsTileViewModel.config) }
            ?: QSTile.State()
            ?: QSTile.AdapterState()

    override fun getInstanceId(): InstanceId = qsTileViewModel.config.instanceId

@@ -241,7 +242,7 @@ constructor(
            context: Context,
            viewModelState: QSTileState,
            config: QSTileConfig,
        ): QSTile.State =
        ): QSTile.AdapterState =
            // we have to use QSTile.BooleanState to support different side icons
            // which are bound to instanceof QSTile.BooleanState in QSTileView.
            QSTile.AdapterState().apply {