[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
This commit is contained in:
Caitlin Shkuratov
2023-02-02 21:03:56 +00:00
parent b209bdeff0
commit a8cd6d353f
2 changed files with 28 additions and 17 deletions

View File

@@ -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> =

View File

@@ -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. */
@@ -124,14 +123,22 @@ constructor(
private val showNetworkTypeIcon: Flow<Boolean> =
combine(
iconInteractor.isDataConnected,
iconInteractor.isDataEnabled,
iconInteractor.isDefaultConnectionFailed,
iconInteractor.alwaysShowDataRatIcon,
iconInteractor.isConnected,
) { dataConnected, dataEnabled, failedConnection, alwaysShow, connected ->
alwaysShow || (dataConnected && dataEnabled && !failedConnection && connected)
}
iconInteractor.isDataConnected,
iconInteractor.isDataEnabled,
iconInteractor.isDefaultConnectionFailed,
iconInteractor.alwaysShowDataRatIcon,
iconInteractor.isConnected,
) { 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> =