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

Commit 71320ed0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[kairos] enable kairos repo dumps" into main

parents 8bd17796 9184e14d
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.android.systemui.KairosBuilder
import com.android.systemui.kairos.BuildSpec
import com.android.systemui.kairos.ExperimentalKairosApi
import com.android.systemui.kairos.State
import com.android.systemui.kairos.combine
import com.android.systemui.kairos.flatMap
import com.android.systemui.kairosBuilder
import com.android.systemui.log.table.TableLogBuffer
@@ -55,9 +56,15 @@ constructor(
    @Assisted private val isCarrierMerged: State<Boolean>,
) : MobileConnectionRepositoryKairos, KairosBuilder by kairosBuilder() {

    private var dumpCache: DumpCache? = null

    init {
        onActivated {
            logDiffsForTable(isCarrierMerged, tableLogBuffer, columnName = "isCarrierMerged")
            combine(isCarrierMerged, activeRepo) { isCarrierMerged, activeRepo ->
                    DumpCache(isCarrierMerged, activeRepo)
                }
                .observe { dumpCache = it }
        }
    }

@@ -198,13 +205,6 @@ constructor(

    override val isInEcmMode: State<Boolean> = activeRepo.flatMap { it.isInEcmMode }

    private var dumpCache: DumpCache? = null

    private data class DumpCache(
        val isCarrierMerged: Boolean,
        val activeRepo: MobileConnectionRepositoryKairos,
    )

    fun dump(pw: PrintWriter) {
        val cache = dumpCache ?: return
        val ipw = IndentingPrintWriter(pw, "  ")
@@ -227,6 +227,11 @@ constructor(
        ipw.decreaseIndent()
    }

    private data class DumpCache(
        val isCarrierMerged: Boolean,
        val activeRepo: MobileConnectionRepositoryKairos,
    )

    @AssistedFactory
    interface Factory {
        fun create(
+10 −5
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ constructor(
    private val mobileRepoFactory: Lazy<ConnectionRepoFactory>,
) : MobileConnectionsRepositoryKairos, Dumpable, KairosBuilder by kairosBuilder() {

    private var dumpCache: DumpCache? = null

    init {
        dumpManager.registerNormalDumpable("MobileConnectionsRepositoryKairos", this)
    }
@@ -253,6 +255,7 @@ constructor(
                .asIncremental()
                .mapValues { (subId, sub) -> mobileRepoFactory.get().create(subId) }
                .applyLatestSpecForKey()
                .apply { observe { dumpCache = DumpCache(it) } }
        }

    private val telephonyManagerState: State<Pair<Int?, Set<Int>>> = buildState {
@@ -479,10 +482,6 @@ constructor(
            profileClass = profileClass,
        )

    private var dumpCache: DumpCache? = null

    private data class DumpCache(val repos: Map<Int, FullMobileConnectionRepositoryKairos>)

    override fun dump(pw: PrintWriter, args: Array<String>) {
        val cache = dumpCache ?: return
        val ipw = IndentingPrintWriter(pw, " ")
@@ -494,10 +493,16 @@ constructor(

        ipw.println("Connections (${cache.repos.size} total):")
        ipw.increaseIndent()
        cache.repos.values.forEach { it.dump(ipw) }
        cache.repos.values.forEach {
            if (it is FullMobileConnectionRepositoryKairos) {
                it.dump(ipw)
            }
        }
        ipw.decreaseIndent()
    }

    private data class DumpCache(val repos: Map<Int, MobileConnectionRepositoryKairos>)

    fun interface ConnectionRepoFactory {
        fun create(subId: Int): BuildSpec<MobileConnectionRepositoryKairos>
    }