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

Commit a8cd6d35 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB Refactor] Add better logging for the network type icon.

Instead of logging `networkTypeIcon|Resource(res=2131232263,
contentDescription=Resource(res=2131952280))`, it'll now log:

showNetworkTypeIcon|false
networkTypeIcon|LTE

Bug: 238425913
Test: manual: dumped logs for MobileConnectionLog[3] (my local sub ID)
Change-Id: I385e205017dd46c9047f308f45e6ef45f46f0f26
parent b209bdef
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -33,7 +33,9 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.stateIn

interface MobileIconInteractor {
@@ -181,6 +183,16 @@ class MobileIconInteractorImpl(
                    else -> mapping[info.resolvedNetworkType.lookupKey] ?: defaultGroup
                }
            }
            .distinctUntilChanged()
            .onEach {
                // Doesn't use [logDiffsForTable] because [MobileIconGroup] can't implement the
                // [Diffable] interface.
                tableLogBuffer.logChange(
                    prefix = "",
                    columnName = "networkTypeIcon",
                    value = it.name
                )
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), defaultMobileIconGroup.value)

    override val isEmergencyOnly: StateFlow<Boolean> =
+16 −17
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.stateIn

/** Common interface for all of the location-based mobile icon view models. */
@@ -132,6 +131,14 @@ constructor(
            ) { dataConnected, dataEnabled, failedConnection, alwaysShow, connected ->
                alwaysShow || (dataConnected && dataEnabled && !failedConnection && connected)
            }
            .distinctUntilChanged()
            .logDiffsForTable(
                iconInteractor.tableLogBuffer,
                columnPrefix = "",
                columnName = "showNetworkTypeIcon",
                initialValue = false,
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)

    override val networkTypeIcon: Flow<Icon?> =
        combine(
@@ -149,14 +156,6 @@ constructor(
                }
            }
            .distinctUntilChanged()
            .onEach {
                // This is done as an onEach side effect since Icon is not Diffable (yet)
                iconInteractor.tableLogBuffer.logChange(
                    prefix = "",
                    columnName = "networkTypeIcon",
                    value = it.toString(),
                )
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), null)

    override val roaming: StateFlow<Boolean> =