[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:
@@ -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> =
|
||||
|
||||
@@ -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> =
|
||||
|
||||
Reference in New Issue
Block a user