summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/MobileInputLog.kt (renamed from packages/SystemUI/src/com/android/systemui/log/dagger/StatusBarConnectivityLog.java)24
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/shared/MobileInputLogger.kt135
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconsViewModel.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ConnectivityConstants.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepository.kt68
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/shared/WifiConstants.kt3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractorTest.kt1
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/shared/MobileInputLoggerTest.kt83
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconsViewModelTest.kt3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepositoryImplTest.kt307
14 files changed, 251 insertions, 408 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
index 41774800c527..5341cd53b2a5 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
@@ -265,16 +265,6 @@ public class LogModule {
return factory.create("MediaCarouselCtlrLog", 20);
}
- /**
- * Provides a {@link LogBuffer} for use in the status bar connectivity pipeline
- */
- @Provides
- @SysUISingleton
- @StatusBarConnectivityLog
- public static LogBuffer provideStatusBarConnectivityBuffer(LogBufferFactory factory) {
- return factory.create("SbConnectivity", 64);
- }
-
/** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */
@Provides
@SysUISingleton
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/StatusBarConnectivityLog.java b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/MobileInputLog.kt
index 67cdb722055b..d1aa79e2233a 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/StatusBarConnectivityLog.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/MobileInputLog.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,22 +14,12 @@
* limitations under the License.
*/
-package com.android.systemui.log.dagger;
+package com.android.systemui.statusbar.pipeline.dagger
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import javax.inject.Qualifier
-import com.android.systemui.plugins.log.LogBuffer;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-
-import javax.inject.Qualifier;
-
-/**
- * A {@link LogBuffer} for status bar connectivity events.
- */
+/** Logs for inputs into the mobile pipeline. */
@Qualifier
-@Documented
-@Retention(RUNTIME)
-public @interface StatusBarConnectivityLog {
-}
+@MustBeDocumented
+@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
+annotation class MobileInputLog
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt
index 0b9903de70d3..44647515a6e5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt
@@ -141,5 +141,12 @@ abstract class StatusBarPipelineModule {
fun provideMobileSummaryLogBuffer(factory: TableLogBufferFactory): TableLogBuffer {
return factory.create("MobileSummaryLog", 100)
}
+
+ @Provides
+ @SysUISingleton
+ @MobileInputLog
+ fun provideMobileInputLogBuffer(factory: LogBufferFactory): LogBuffer {
+ return factory.create("MobileInputLog", 100)
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt
index 55cf86450751..a80e1eb85d46 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt
@@ -50,7 +50,6 @@ import com.android.systemui.statusbar.pipeline.mobile.data.model.NetworkNameMode
import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionsRepository
import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger
-import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger.Companion.logInputChange
import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy
import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepository
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel
@@ -222,13 +221,13 @@ constructor(
private val carrierConfigChangedEvent =
broadcastDispatcher
.broadcastFlow(IntentFilter(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED))
- .logInputChange(logger, "ACTION_CARRIER_CONFIG_CHANGED")
+ .onEach { logger.logActionCarrierConfigChanged() }
override val defaultDataSubRatConfig: StateFlow<Config> =
merge(defaultDataSubIdChangeEvent, carrierConfigChangedEvent)
.mapLatest { Config.readConfig(context) }
.distinctUntilChanged()
- .logInputChange(logger, "defaultDataSubRatConfig")
+ .onEach { logger.logDefaultDataSubRatConfig(it) }
.stateIn(
scope,
SharingStarted.WhileSubscribed(),
@@ -239,13 +238,13 @@ constructor(
defaultDataSubRatConfig
.map { mobileMappingsProxy.mapIconSets(it) }
.distinctUntilChanged()
- .logInputChange(logger, "defaultMobileIconMapping")
+ .onEach { logger.logDefaultMobileIconMapping(it) }
override val defaultMobileIconGroup: Flow<MobileIconGroup> =
defaultDataSubRatConfig
.map { mobileMappingsProxy.getDefaultIcons(it) }
.distinctUntilChanged()
- .logInputChange(logger, "defaultMobileIconGroup")
+ .onEach { logger.logDefaultMobileIconGroup(it) }
override fun getRepoForSubId(subId: Int): FullMobileConnectionRepository {
if (!isValidSubId(subId)) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt
index 02b08537c61b..4e5fc07ba3a3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt
@@ -30,7 +30,6 @@ import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionMod
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionsRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.UserSetupRepository
-import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger
import com.android.systemui.statusbar.pipeline.shared.data.model.ConnectivitySlot
import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepository
import com.android.systemui.util.CarrierConfigTracker
@@ -111,7 +110,6 @@ class MobileIconsInteractorImpl
constructor(
private val mobileConnectionsRepo: MobileConnectionsRepository,
private val carrierConfigTracker: CarrierConfigTracker,
- private val logger: MobileInputLogger,
@MobileSummaryLog private val tableLogger: TableLogBuffer,
connectivityRepository: ConnectivityRepository,
userSetupRepo: UserSetupRepository,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/shared/MobileInputLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/shared/MobileInputLogger.kt
index f7fff70711e6..3cbd2b76c248 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/shared/MobileInputLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/shared/MobileInputLogger.kt
@@ -21,57 +21,22 @@ import android.net.NetworkCapabilities
import android.telephony.ServiceState
import android.telephony.SignalStrength
import android.telephony.TelephonyDisplayInfo
+import com.android.settingslib.SignalIcon
+import com.android.settingslib.mobile.MobileMappings
import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.log.dagger.StatusBarConnectivityLog
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel
-import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger.Companion.toString
+import com.android.systemui.statusbar.pipeline.dagger.MobileInputLog
import com.android.systemui.statusbar.pipeline.shared.LoggerHelper
import javax.inject.Inject
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.onEach
+/** Logs for inputs into the mobile pipeline. */
@SysUISingleton
class MobileInputLogger
@Inject
constructor(
- @StatusBarConnectivityLog private val buffer: LogBuffer,
+ @MobileInputLog private val buffer: LogBuffer,
) {
- /**
- * Logs a change in one of the **raw inputs** to the connectivity pipeline.
- *
- * Use this method for inputs that don't have any extra information besides their callback name.
- */
- fun logInputChange(callbackName: String) {
- buffer.log(SB_LOGGING_TAG, LogLevel.INFO, { str1 = callbackName }, { "Input: $str1" })
- }
-
- /** Logs a change in one of the **raw inputs** to the connectivity pipeline. */
- fun logInputChange(callbackName: String, changeInfo: String?) {
- buffer.log(
- SB_LOGGING_TAG,
- LogLevel.INFO,
- {
- str1 = callbackName
- str2 = changeInfo
- },
- { "Input: $str1: $str2" }
- )
- }
-
- /** Logs a change in one of the **outputs** to the connectivity pipeline. */
- fun logOutputChange(outputParamName: String, changeInfo: String) {
- buffer.log(
- SB_LOGGING_TAG,
- LogLevel.INFO,
- {
- str1 = outputParamName
- str2 = changeInfo
- },
- { "Output: $str1: $str2" }
- )
- }
-
fun logOnCapabilitiesChanged(
network: Network,
networkCapabilities: NetworkCapabilities,
@@ -79,7 +44,7 @@ constructor(
) {
LoggerHelper.logOnCapabilitiesChanged(
buffer,
- SB_LOGGING_TAG,
+ TAG,
network,
networkCapabilities,
isDefaultNetworkCallback,
@@ -87,12 +52,12 @@ constructor(
}
fun logOnLost(network: Network) {
- LoggerHelper.logOnLost(buffer, SB_LOGGING_TAG, network)
+ LoggerHelper.logOnLost(buffer, TAG, network)
}
fun logOnServiceStateChanged(serviceState: ServiceState, subId: Int) {
buffer.log(
- SB_LOGGING_TAG,
+ TAG,
LogLevel.INFO,
{
int1 = subId
@@ -109,7 +74,7 @@ constructor(
fun logOnSignalStrengthsChanged(signalStrength: SignalStrength, subId: Int) {
buffer.log(
- SB_LOGGING_TAG,
+ TAG,
LogLevel.INFO,
{
int1 = subId
@@ -121,7 +86,7 @@ constructor(
fun logOnDataConnectionStateChanged(dataState: Int, networkType: Int, subId: Int) {
buffer.log(
- SB_LOGGING_TAG,
+ TAG,
LogLevel.INFO,
{
int1 = subId
@@ -134,7 +99,7 @@ constructor(
fun logOnDataActivity(direction: Int, subId: Int) {
buffer.log(
- SB_LOGGING_TAG,
+ TAG,
LogLevel.INFO,
{
int1 = subId
@@ -146,7 +111,7 @@ constructor(
fun logOnCarrierNetworkChange(active: Boolean, subId: Int) {
buffer.log(
- SB_LOGGING_TAG,
+ TAG,
LogLevel.INFO,
{
int1 = subId
@@ -158,7 +123,7 @@ constructor(
fun logOnDisplayInfoChanged(displayInfo: TelephonyDisplayInfo, subId: Int) {
buffer.log(
- SB_LOGGING_TAG,
+ TAG,
LogLevel.INFO,
{
int1 = subId
@@ -168,11 +133,9 @@ constructor(
)
}
- // TODO(b/238425913): We should split this class into mobile-specific and wifi-specific loggers.
-
fun logUiAdapterSubIdsUpdated(subs: List<Int>) {
buffer.log(
- SB_LOGGING_TAG,
+ TAG,
LogLevel.INFO,
{ str1 = subs.toString() },
{ "Sub IDs in MobileUiAdapter updated internally: $str1" },
@@ -181,7 +144,7 @@ constructor(
fun logUiAdapterSubIdsSentToIconController(subs: List<Int>) {
buffer.log(
- SB_LOGGING_TAG,
+ TAG,
LogLevel.INFO,
{ str1 = subs.toString() },
{ "Sub IDs in MobileUiAdapter being sent to icon controller: $str1" },
@@ -190,7 +153,7 @@ constructor(
fun logCarrierConfigChanged(subId: Int) {
buffer.log(
- SB_LOGGING_TAG,
+ TAG,
LogLevel.INFO,
{ int1 = subId },
{ "onCarrierConfigChanged: subId=$int1" },
@@ -199,7 +162,7 @@ constructor(
fun logOnDataEnabledChanged(enabled: Boolean, subId: Int) {
buffer.log(
- SB_LOGGING_TAG,
+ TAG,
LogLevel.INFO,
{
int1 = subId
@@ -209,43 +172,31 @@ constructor(
)
}
- companion object {
- const val SB_LOGGING_TAG = "SbConnectivity"
-
- /** Log a change in one of the **inputs** to the connectivity pipeline. */
- fun Flow<Unit>.logInputChange(
- logger: MobileInputLogger,
- inputParamName: String,
- ): Flow<Unit> {
- return this.onEach { logger.logInputChange(inputParamName) }
- }
-
- /**
- * Log a change in one of the **inputs** to the connectivity pipeline.
- *
- * @param prettyPrint an optional function to transform the value into a readable string.
- * [toString] is used if no custom function is provided.
- */
- fun <T> Flow<T>.logInputChange(
- logger: MobileInputLogger,
- inputParamName: String,
- prettyPrint: (T) -> String = { it.toString() }
- ): Flow<T> {
- return this.onEach { logger.logInputChange(inputParamName, prettyPrint(it)) }
- }
-
- /**
- * Log a change in one of the **outputs** to the connectivity pipeline.
- *
- * @param prettyPrint an optional function to transform the value into a readable string.
- * [toString] is used if no custom function is provided.
- */
- fun <T> Flow<T>.logOutputChange(
- logger: MobileInputLogger,
- outputParamName: String,
- prettyPrint: (T) -> String = { it.toString() }
- ): Flow<T> {
- return this.onEach { logger.logOutputChange(outputParamName, prettyPrint(it)) }
- }
+ fun logActionCarrierConfigChanged() {
+ buffer.log(TAG, LogLevel.INFO, {}, { "Intent received: ACTION_CARRIER_CONFIG_CHANGED" })
+ }
+
+ fun logDefaultDataSubRatConfig(config: MobileMappings.Config) {
+ buffer.log(
+ TAG,
+ LogLevel.INFO,
+ { str1 = config.toString() },
+ { "defaultDataSubRatConfig: $str1" }
+ )
+ }
+
+ fun logDefaultMobileIconMapping(mapping: Map<String, SignalIcon.MobileIconGroup>) {
+ buffer.log(
+ TAG,
+ LogLevel.INFO,
+ { str1 = mapping.toString() },
+ { "defaultMobileIconMapping: $str1" }
+ )
+ }
+
+ fun logDefaultMobileIconGroup(group: SignalIcon.MobileIconGroup) {
+ buffer.log(TAG, LogLevel.INFO, { str1 = group.name }, { "defaultMobileIconGroup: $str1" })
}
}
+
+private const val TAG = "MobileInputLog"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconsViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconsViewModel.kt
index f3c491de6efb..8cb52af336da 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconsViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconsViewModel.kt
@@ -25,7 +25,6 @@ import com.android.systemui.statusbar.pipeline.airplane.domain.interactor.Airpla
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor
import com.android.systemui.statusbar.pipeline.mobile.ui.view.ModernStatusBarMobileView
import com.android.systemui.statusbar.pipeline.shared.ConnectivityConstants
-import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.StateFlow
@@ -42,7 +41,6 @@ constructor(
val subscriptionIdsFlow: StateFlow<List<Int>>,
private val interactor: MobileIconsInteractor,
private val airplaneModeInteractor: AirplaneModeInteractor,
- private val logger: MobileInputLogger,
private val constants: ConnectivityConstants,
@Application private val scope: CoroutineScope,
private val statusBarPipelineFlags: StatusBarPipelineFlags,
@@ -83,7 +81,6 @@ constructor(
constructor(
private val interactor: MobileIconsInteractor,
private val airplaneModeInteractor: AirplaneModeInteractor,
- private val logger: MobileInputLogger,
private val constants: ConnectivityConstants,
@Application private val scope: CoroutineScope,
private val statusBarPipelineFlags: StatusBarPipelineFlags,
@@ -93,7 +90,6 @@ constructor(
subscriptionIdsFlow,
interactor,
airplaneModeInteractor,
- logger,
constants,
scope,
statusBarPipelineFlags,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ConnectivityConstants.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ConnectivityConstants.kt
index a6caf76c03e2..0fe53294fa7d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ConnectivityConstants.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ConnectivityConstants.kt
@@ -22,7 +22,6 @@ import com.android.systemui.Dumpable
import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
-import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger.Companion.SB_LOGGING_TAG
import java.io.PrintWriter
import javax.inject.Inject
@@ -40,7 +39,7 @@ constructor(
telephonyManager: TelephonyManager,
) : Dumpable {
init {
- dumpManager.registerNormalDumpable("${SB_LOGGING_TAG}Constants", this)
+ dumpManager.registerNormalDumpable("ConnectivityConstants", this)
}
/** True if this device has the capability for data connections and false otherwise. */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepository.kt
index a216db88103d..5d9ba018822d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepository.kt
@@ -27,7 +27,6 @@ import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dump.DumpManager
import com.android.systemui.statusbar.phone.StatusBarIconController
import com.android.systemui.statusbar.pipeline.shared.ConnectivityInputLogger
-import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger.Companion.SB_LOGGING_TAG
import com.android.systemui.statusbar.pipeline.shared.data.model.ConnectivitySlot
import com.android.systemui.statusbar.pipeline.shared.data.model.ConnectivitySlots
import com.android.systemui.tuner.TunerService
@@ -45,15 +44,15 @@ import kotlinx.coroutines.flow.stateIn
* types of connectivity (wifi, mobile, ethernet, etc.)
*/
interface ConnectivityRepository {
- /**
- * Observable for the current set of connectivity icons that should be force-hidden.
- */
+ /** Observable for the current set of connectivity icons that should be force-hidden. */
val forceHiddenSlots: StateFlow<Set<ConnectivitySlot>>
}
@OptIn(ExperimentalCoroutinesApi::class)
@SysUISingleton
-class ConnectivityRepositoryImpl @Inject constructor(
+class ConnectivityRepositoryImpl
+@Inject
+constructor(
private val connectivitySlots: ConnectivitySlots,
context: Context,
dumpManager: DumpManager,
@@ -62,42 +61,44 @@ class ConnectivityRepositoryImpl @Inject constructor(
tunerService: TunerService,
) : ConnectivityRepository, Dumpable {
init {
- dumpManager.registerDumpable("${SB_LOGGING_TAG}Repository", this)
+ dumpManager.registerDumpable("ConnectivityRepository", this)
}
// The default set of hidden icons to use if we don't get any from [TunerService].
private val defaultHiddenIcons: Set<ConnectivitySlot> =
- context.resources.getStringArray(DEFAULT_HIDDEN_ICONS_RESOURCE)
- .asList()
- .toSlotSet(connectivitySlots)
+ context.resources
+ .getStringArray(DEFAULT_HIDDEN_ICONS_RESOURCE)
+ .asList()
+ .toSlotSet(connectivitySlots)
- override val forceHiddenSlots: StateFlow<Set<ConnectivitySlot>> = conflatedCallbackFlow {
- val callback = object : TunerService.Tunable {
- override fun onTuningChanged(key: String, newHideList: String?) {
- if (key != HIDDEN_ICONS_TUNABLE_KEY) {
- return
- }
- logger.logTuningChanged(newHideList)
+ override val forceHiddenSlots: StateFlow<Set<ConnectivitySlot>> =
+ conflatedCallbackFlow {
+ val callback =
+ object : TunerService.Tunable {
+ override fun onTuningChanged(key: String, newHideList: String?) {
+ if (key != HIDDEN_ICONS_TUNABLE_KEY) {
+ return
+ }
+ logger.logTuningChanged(newHideList)
- val outputList = newHideList?.split(",")?.toSlotSet(connectivitySlots)
- ?: defaultHiddenIcons
- trySend(outputList)
- }
- }
- tunerService.addTunable(callback, HIDDEN_ICONS_TUNABLE_KEY)
+ val outputList =
+ newHideList?.split(",")?.toSlotSet(connectivitySlots)
+ ?: defaultHiddenIcons
+ trySend(outputList)
+ }
+ }
+ tunerService.addTunable(callback, HIDDEN_ICONS_TUNABLE_KEY)
- awaitClose { tunerService.removeTunable(callback) }
- }
- .stateIn(
- scope,
- started = SharingStarted.WhileSubscribed(),
- initialValue = defaultHiddenIcons
- )
+ awaitClose { tunerService.removeTunable(callback) }
+ }
+ .stateIn(
+ scope,
+ started = SharingStarted.WhileSubscribed(),
+ initialValue = defaultHiddenIcons
+ )
override fun dump(pw: PrintWriter, args: Array<out String>) {
- pw.apply {
- println("defaultHiddenIcons=$defaultHiddenIcons")
- }
+ pw.apply { println("defaultHiddenIcons=$defaultHiddenIcons") }
}
companion object {
@@ -111,8 +112,7 @@ class ConnectivityRepositoryImpl @Inject constructor(
private fun List<String>.toSlotSet(
connectivitySlots: ConnectivitySlots
): Set<ConnectivitySlot> {
- return this
- .filter { it.isNotBlank() }
+ return this.filter { it.isNotBlank() }
.mapNotNull { connectivitySlots.getSlotFromName(it) }
.toSet()
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/shared/WifiConstants.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/shared/WifiConstants.kt
index 00459e94e9e5..8bea7728170f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/shared/WifiConstants.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/shared/WifiConstants.kt
@@ -21,7 +21,6 @@ import com.android.systemui.Dumpable
import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
-import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger.Companion.SB_LOGGING_TAG
import java.io.PrintWriter
import javax.inject.Inject
@@ -37,7 +36,7 @@ constructor(
dumpManager: DumpManager,
) : Dumpable {
init {
- dumpManager.registerDumpable("${SB_LOGGING_TAG}WifiConstants", this)
+ dumpManager.registerNormalDumpable("WifiConstants", this)
}
/** True if we should always show the wifi icon when wifi is enabled and false otherwise. */
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractorTest.kt
index f8a978300dd3..ee4e496fcf3a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractorTest.kt
@@ -83,7 +83,6 @@ class MobileIconsInteractorTest : SysuiTestCase() {
MobileIconsInteractorImpl(
connectionsRepository,
carrierConfigTracker,
- logger = mock(),
tableLogger = mock(),
connectivityRepository,
userSetupRepository,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/shared/MobileInputLoggerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/shared/MobileInputLoggerTest.kt
index 7c2b7a651994..86529dce948a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/shared/MobileInputLoggerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/shared/MobileInputLoggerTest.kt
@@ -23,24 +23,17 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.dump.DumpManager
import com.android.systemui.log.LogBufferFactory
import com.android.systemui.plugins.log.LogcatEchoTracker
-import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger.Companion.logInputChange
-import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger.Companion.logOutputChange
import com.google.common.truth.Truth.assertThat
import java.io.PrintWriter
import java.io.StringWriter
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.flowOf
-import kotlinx.coroutines.flow.launchIn
-import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.mockito.Mockito
import org.mockito.Mockito.mock
@SmallTest
class MobileInputLoggerTest : SysuiTestCase() {
- private val buffer = LogBufferFactory(DumpManager(), mock(LogcatEchoTracker::class.java))
- .create("buffer", 10)
+ private val buffer =
+ LogBufferFactory(DumpManager(), mock(LogcatEchoTracker::class.java)).create("buffer", 10)
private val logger = MobileInputLogger(buffer)
@Test
@@ -72,70 +65,16 @@ class MobileInputLoggerTest : SysuiTestCase() {
assertThat(actualString).contains(expectedNetId)
}
- @Test
- fun logOutputChange_printsValuesAndNulls() = runBlocking(IMMEDIATE) {
- val flow: Flow<Int?> = flowOf(1, null, 3)
-
- val job = flow
- .logOutputChange(logger, "testInts")
- .launchIn(this)
-
- val stringWriter = StringWriter()
- buffer.dump(PrintWriter(stringWriter), tailLength = 0)
- val actualString = stringWriter.toString()
-
- assertThat(actualString).contains("1")
- assertThat(actualString).contains("null")
- assertThat(actualString).contains("3")
-
- job.cancel()
- }
-
- @Test
- fun logInputChange_unit_printsInputName() = runBlocking(IMMEDIATE) {
- val flow: Flow<Unit> = flowOf(Unit, Unit)
-
- val job = flow
- .logInputChange(logger, "testInputs")
- .launchIn(this)
-
- val stringWriter = StringWriter()
- buffer.dump(PrintWriter(stringWriter), tailLength = 0)
- val actualString = stringWriter.toString()
-
- assertThat(actualString).contains("testInputs")
-
- job.cancel()
- }
-
- @Test
- fun logInputChange_any_printsValuesAndNulls() = runBlocking(IMMEDIATE) {
- val flow: Flow<Any?> = flowOf(null, 2, "threeString")
-
- val job = flow
- .logInputChange(logger, "testInputs")
- .launchIn(this)
-
- val stringWriter = StringWriter()
- buffer.dump(PrintWriter(stringWriter), tailLength = 0)
- val actualString = stringWriter.toString()
-
- assertThat(actualString).contains("null")
- assertThat(actualString).contains("2")
- assertThat(actualString).contains("threeString")
-
- job.cancel()
- }
-
companion object {
private const val NET_1_ID = 100
- private val NET_1 = com.android.systemui.util.mockito.mock<Network>().also {
- Mockito.`when`(it.getNetId()).thenReturn(NET_1_ID)
- }
- private val NET_1_CAPS = NetworkCapabilities.Builder()
- .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
- .addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
- .build()
- private val IMMEDIATE = Dispatchers.Main.immediate
+ private val NET_1 =
+ com.android.systemui.util.mockito.mock<Network>().also {
+ Mockito.`when`(it.getNetId()).thenReturn(NET_1_ID)
+ }
+ private val NET_1_CAPS =
+ NetworkCapabilities.Builder()
+ .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
+ .addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
+ .build()
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconsViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconsViewModelTest.kt
index 69bae5dad5ed..4628f8410245 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconsViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconsViewModelTest.kt
@@ -24,7 +24,6 @@ import com.android.systemui.statusbar.pipeline.airplane.data.repository.FakeAirp
import com.android.systemui.statusbar.pipeline.airplane.domain.interactor.AirplaneModeInteractor
import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.FakeMobileIconsInteractor
-import com.android.systemui.statusbar.pipeline.mobile.shared.MobileInputLogger
import com.android.systemui.statusbar.pipeline.mobile.util.FakeMobileMappingsProxy
import com.android.systemui.statusbar.pipeline.shared.ConnectivityConstants
import com.android.systemui.statusbar.pipeline.shared.data.repository.FakeConnectivityRepository
@@ -51,7 +50,6 @@ class MobileIconsViewModelTest : SysuiTestCase() {
private lateinit var airplaneModeInteractor: AirplaneModeInteractor
@Mock private lateinit var statusBarPipelineFlags: StatusBarPipelineFlags
- @Mock private lateinit var logger: MobileInputLogger
@Mock private lateinit var constants: ConnectivityConstants
private val testDispatcher = UnconfinedTestDispatcher()
@@ -77,7 +75,6 @@ class MobileIconsViewModelTest : SysuiTestCase() {
subscriptionIdsFlow,
interactor,
airplaneModeInteractor,
- logger,
constants,
testScope.backgroundScope,
statusBarPipelineFlags,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepositoryImplTest.kt
index b0a41ce2d349..496f090da25c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepositoryImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/data/repository/ConnectivityRepositoryImplTest.kt
@@ -61,14 +61,15 @@ class ConnectivityRepositoryImplTest : SysuiTestCase() {
MockitoAnnotations.initMocks(this)
scope = CoroutineScope(IMMEDIATE)
- underTest = ConnectivityRepositoryImpl(
- connectivitySlots,
- context,
- dumpManager,
- logger,
- scope,
- tunerService,
- )
+ underTest =
+ ConnectivityRepositoryImpl(
+ connectivitySlots,
+ context,
+ dumpManager,
+ logger,
+ scope,
+ tunerService,
+ )
}
@After
@@ -77,199 +78,179 @@ class ConnectivityRepositoryImplTest : SysuiTestCase() {
}
@Test
- fun forceHiddenSlots_initiallyGetsDefault() = runBlocking(IMMEDIATE) {
- setUpEthernetWifiMobileSlotNames()
- context.getOrCreateTestableResources().addOverride(
- DEFAULT_HIDDEN_ICONS_RESOURCE,
- arrayOf(SLOT_WIFI, SLOT_ETHERNET)
- )
- // Re-create our [ConnectivityRepositoryImpl], since it fetches
- // config_statusBarIconsToExclude when it's first constructed
- underTest = ConnectivityRepositoryImpl(
- connectivitySlots,
- context,
- dumpManager,
- logger,
- scope,
- tunerService,
- )
-
- var latest: Set<ConnectivitySlot>? = null
- val job = underTest
- .forceHiddenSlots
- .onEach { latest = it }
- .launchIn(this)
-
- assertThat(latest).containsExactly(ConnectivitySlot.ETHERNET, ConnectivitySlot.WIFI)
-
- job.cancel()
- }
+ fun forceHiddenSlots_initiallyGetsDefault() =
+ runBlocking(IMMEDIATE) {
+ setUpEthernetWifiMobileSlotNames()
+ context
+ .getOrCreateTestableResources()
+ .addOverride(DEFAULT_HIDDEN_ICONS_RESOURCE, arrayOf(SLOT_WIFI, SLOT_ETHERNET))
+ // Re-create our [ConnectivityRepositoryImpl], since it fetches
+ // config_statusBarIconsToExclude when it's first constructed
+ underTest =
+ ConnectivityRepositoryImpl(
+ connectivitySlots,
+ context,
+ dumpManager,
+ logger,
+ scope,
+ tunerService,
+ )
+
+ var latest: Set<ConnectivitySlot>? = null
+ val job = underTest.forceHiddenSlots.onEach { latest = it }.launchIn(this)
+
+ assertThat(latest).containsExactly(ConnectivitySlot.ETHERNET, ConnectivitySlot.WIFI)
+
+ job.cancel()
+ }
@Test
- fun forceHiddenSlots_slotNamesAdded_flowHasSlots() = runBlocking(IMMEDIATE) {
- setUpEthernetWifiMobileSlotNames()
+ fun forceHiddenSlots_slotNamesAdded_flowHasSlots() =
+ runBlocking(IMMEDIATE) {
+ setUpEthernetWifiMobileSlotNames()
- var latest: Set<ConnectivitySlot>? = null
- val job = underTest
- .forceHiddenSlots
- .onEach { latest = it }
- .launchIn(this)
+ var latest: Set<ConnectivitySlot>? = null
+ val job = underTest.forceHiddenSlots.onEach { latest = it }.launchIn(this)
- getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, SLOT_MOBILE)
+ getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, SLOT_MOBILE)
- assertThat(latest).containsExactly(ConnectivitySlot.MOBILE)
+ assertThat(latest).containsExactly(ConnectivitySlot.MOBILE)
- job.cancel()
- }
+ job.cancel()
+ }
@Test
- fun forceHiddenSlots_wrongKey_doesNotUpdate() = runBlocking(IMMEDIATE) {
- setUpEthernetWifiMobileSlotNames()
+ fun forceHiddenSlots_wrongKey_doesNotUpdate() =
+ runBlocking(IMMEDIATE) {
+ setUpEthernetWifiMobileSlotNames()
- var latest: Set<ConnectivitySlot>? = null
- val job = underTest
- .forceHiddenSlots
- .onEach { latest = it }
- .launchIn(this)
+ var latest: Set<ConnectivitySlot>? = null
+ val job = underTest.forceHiddenSlots.onEach { latest = it }.launchIn(this)
- getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, SLOT_MOBILE)
+ getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, SLOT_MOBILE)
- // WHEN onTuningChanged with the wrong key
- getTunable().onTuningChanged("wrongKey", SLOT_WIFI)
- yield()
+ // WHEN onTuningChanged with the wrong key
+ getTunable().onTuningChanged("wrongKey", SLOT_WIFI)
+ yield()
- // THEN we didn't update our value and still have the old one
- assertThat(latest).containsExactly(ConnectivitySlot.MOBILE)
+ // THEN we didn't update our value and still have the old one
+ assertThat(latest).containsExactly(ConnectivitySlot.MOBILE)
- job.cancel()
- }
+ job.cancel()
+ }
@Test
- fun forceHiddenSlots_slotNamesAddedThenNull_flowHasDefault() = runBlocking(IMMEDIATE) {
- setUpEthernetWifiMobileSlotNames()
- context.getOrCreateTestableResources().addOverride(
- DEFAULT_HIDDEN_ICONS_RESOURCE,
- arrayOf(SLOT_WIFI, SLOT_ETHERNET)
- )
- // Re-create our [ConnectivityRepositoryImpl], since it fetches
- // config_statusBarIconsToExclude when it's first constructed
- underTest = ConnectivityRepositoryImpl(
- connectivitySlots,
- context,
- dumpManager,
- logger,
- scope,
- tunerService,
- )
-
- var latest: Set<ConnectivitySlot>? = null
- val job = underTest
- .forceHiddenSlots
- .onEach { latest = it }
- .launchIn(this)
-
- // First, update the slots
- getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, SLOT_MOBILE)
- assertThat(latest).containsExactly(ConnectivitySlot.MOBILE)
-
- // WHEN we update to a null value
- getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, null)
- yield()
-
- // THEN we go back to our default value
- assertThat(latest).containsExactly(ConnectivitySlot.ETHERNET, ConnectivitySlot.WIFI)
-
- job.cancel()
- }
+ fun forceHiddenSlots_slotNamesAddedThenNull_flowHasDefault() =
+ runBlocking(IMMEDIATE) {
+ setUpEthernetWifiMobileSlotNames()
+ context
+ .getOrCreateTestableResources()
+ .addOverride(DEFAULT_HIDDEN_ICONS_RESOURCE, arrayOf(SLOT_WIFI, SLOT_ETHERNET))
+ // Re-create our [ConnectivityRepositoryImpl], since it fetches
+ // config_statusBarIconsToExclude when it's first constructed
+ underTest =
+ ConnectivityRepositoryImpl(
+ connectivitySlots,
+ context,
+ dumpManager,
+ logger,
+ scope,
+ tunerService,
+ )
+
+ var latest: Set<ConnectivitySlot>? = null
+ val job = underTest.forceHiddenSlots.onEach { latest = it }.launchIn(this)
+
+ // First, update the slots
+ getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, SLOT_MOBILE)
+ assertThat(latest).containsExactly(ConnectivitySlot.MOBILE)
+
+ // WHEN we update to a null value
+ getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, null)
+ yield()
+
+ // THEN we go back to our default value
+ assertThat(latest).containsExactly(ConnectivitySlot.ETHERNET, ConnectivitySlot.WIFI)
+
+ job.cancel()
+ }
@Test
- fun forceHiddenSlots_someInvalidSlotNames_flowHasValidSlotsOnly() = runBlocking(IMMEDIATE) {
- var latest: Set<ConnectivitySlot>? = null
- val job = underTest
- .forceHiddenSlots
- .onEach { latest = it }
- .launchIn(this)
+ fun forceHiddenSlots_someInvalidSlotNames_flowHasValidSlotsOnly() =
+ runBlocking(IMMEDIATE) {
+ var latest: Set<ConnectivitySlot>? = null
+ val job = underTest.forceHiddenSlots.onEach { latest = it }.launchIn(this)
- whenever(connectivitySlots.getSlotFromName(SLOT_WIFI))
- .thenReturn(ConnectivitySlot.WIFI)
- whenever(connectivitySlots.getSlotFromName(SLOT_MOBILE)).thenReturn(null)
+ whenever(connectivitySlots.getSlotFromName(SLOT_WIFI)).thenReturn(ConnectivitySlot.WIFI)
+ whenever(connectivitySlots.getSlotFromName(SLOT_MOBILE)).thenReturn(null)
- getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, "$SLOT_WIFI,$SLOT_MOBILE")
+ getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, "$SLOT_WIFI,$SLOT_MOBILE")
- assertThat(latest).containsExactly(ConnectivitySlot.WIFI)
+ assertThat(latest).containsExactly(ConnectivitySlot.WIFI)
- job.cancel()
- }
+ job.cancel()
+ }
@Test
- fun forceHiddenSlots_someEmptySlotNames_flowHasValidSlotsOnly() = runBlocking(IMMEDIATE) {
- setUpEthernetWifiMobileSlotNames()
+ fun forceHiddenSlots_someEmptySlotNames_flowHasValidSlotsOnly() =
+ runBlocking(IMMEDIATE) {
+ setUpEthernetWifiMobileSlotNames()
- var latest: Set<ConnectivitySlot>? = null
- val job = underTest
- .forceHiddenSlots
- .onEach { latest = it }
- .launchIn(this)
+ var latest: Set<ConnectivitySlot>? = null
+ val job = underTest.forceHiddenSlots.onEach { latest = it }.launchIn(this)
- // WHEN there's empty and blank slot names
- getTunable().onTuningChanged(
- HIDDEN_ICONS_TUNABLE_KEY, "$SLOT_MOBILE, ,,$SLOT_WIFI"
- )
+ // WHEN there's empty and blank slot names
+ getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, "$SLOT_MOBILE, ,,$SLOT_WIFI")
- // THEN we skip that slot but still process the other ones
- assertThat(latest).containsExactly(ConnectivitySlot.WIFI, ConnectivitySlot.MOBILE)
+ // THEN we skip that slot but still process the other ones
+ assertThat(latest).containsExactly(ConnectivitySlot.WIFI, ConnectivitySlot.MOBILE)
- job.cancel()
- }
+ job.cancel()
+ }
@Test
- fun forceHiddenSlots_allInvalidOrEmptySlotNames_flowHasEmpty() = runBlocking(IMMEDIATE) {
- var latest: Set<ConnectivitySlot>? = null
- val job = underTest
- .forceHiddenSlots
- .onEach { latest = it }
- .launchIn(this)
+ fun forceHiddenSlots_allInvalidOrEmptySlotNames_flowHasEmpty() =
+ runBlocking(IMMEDIATE) {
+ var latest: Set<ConnectivitySlot>? = null
+ val job = underTest.forceHiddenSlots.onEach { latest = it }.launchIn(this)
- whenever(connectivitySlots.getSlotFromName(SLOT_WIFI)).thenReturn(null)
- whenever(connectivitySlots.getSlotFromName(SLOT_ETHERNET)).thenReturn(null)
- whenever(connectivitySlots.getSlotFromName(SLOT_MOBILE)).thenReturn(null)
+ whenever(connectivitySlots.getSlotFromName(SLOT_WIFI)).thenReturn(null)
+ whenever(connectivitySlots.getSlotFromName(SLOT_ETHERNET)).thenReturn(null)
+ whenever(connectivitySlots.getSlotFromName(SLOT_MOBILE)).thenReturn(null)
- getTunable().onTuningChanged(
- HIDDEN_ICONS_TUNABLE_KEY, "$SLOT_MOBILE,,$SLOT_WIFI,$SLOT_ETHERNET,,,"
- )
+ getTunable()
+ .onTuningChanged(
+ HIDDEN_ICONS_TUNABLE_KEY,
+ "$SLOT_MOBILE,,$SLOT_WIFI,$SLOT_ETHERNET,,,"
+ )
- assertThat(latest).isEmpty()
+ assertThat(latest).isEmpty()
- job.cancel()
- }
+ job.cancel()
+ }
@Test
- fun forceHiddenSlots_newSubscriberGetsCurrentValue() = runBlocking(IMMEDIATE) {
- setUpEthernetWifiMobileSlotNames()
+ fun forceHiddenSlots_newSubscriberGetsCurrentValue() =
+ runBlocking(IMMEDIATE) {
+ setUpEthernetWifiMobileSlotNames()
- var latest1: Set<ConnectivitySlot>? = null
- val job1 = underTest
- .forceHiddenSlots
- .onEach { latest1 = it }
- .launchIn(this)
+ var latest1: Set<ConnectivitySlot>? = null
+ val job1 = underTest.forceHiddenSlots.onEach { latest1 = it }.launchIn(this)
- getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, "$SLOT_WIFI,$SLOT_ETHERNET")
+ getTunable().onTuningChanged(HIDDEN_ICONS_TUNABLE_KEY, "$SLOT_WIFI,$SLOT_ETHERNET")
- assertThat(latest1).containsExactly(ConnectivitySlot.WIFI, ConnectivitySlot.ETHERNET)
+ assertThat(latest1).containsExactly(ConnectivitySlot.WIFI, ConnectivitySlot.ETHERNET)
- // WHEN we add a second subscriber after having already emitted a value
- var latest2: Set<ConnectivitySlot>? = null
- val job2 = underTest
- .forceHiddenSlots
- .onEach { latest2 = it }
- .launchIn(this)
+ // WHEN we add a second subscriber after having already emitted a value
+ var latest2: Set<ConnectivitySlot>? = null
+ val job2 = underTest.forceHiddenSlots.onEach { latest2 = it }.launchIn(this)
- // THEN the second subscribe receives the already-emitted value
- assertThat(latest2).containsExactly(ConnectivitySlot.WIFI, ConnectivitySlot.ETHERNET)
+ // THEN the second subscribe receives the already-emitted value
+ assertThat(latest2).containsExactly(ConnectivitySlot.WIFI, ConnectivitySlot.ETHERNET)
- job1.cancel()
- job2.cancel()
- }
+ job1.cancel()
+ job2.cancel()
+ }
private fun getTunable(): TunerService.Tunable {
val callbackCaptor = argumentCaptor<TunerService.Tunable>()
@@ -280,10 +261,8 @@ class ConnectivityRepositoryImplTest : SysuiTestCase() {
private fun setUpEthernetWifiMobileSlotNames() {
whenever(connectivitySlots.getSlotFromName(SLOT_ETHERNET))
.thenReturn(ConnectivitySlot.ETHERNET)
- whenever(connectivitySlots.getSlotFromName(SLOT_WIFI))
- .thenReturn(ConnectivitySlot.WIFI)
- whenever(connectivitySlots.getSlotFromName(SLOT_MOBILE))
- .thenReturn(ConnectivitySlot.MOBILE)
+ whenever(connectivitySlots.getSlotFromName(SLOT_WIFI)).thenReturn(ConnectivitySlot.WIFI)
+ whenever(connectivitySlots.getSlotFromName(SLOT_MOBILE)).thenReturn(ConnectivitySlot.MOBILE)
}
companion object {