1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar.pipeline.mobile.domain.interactor 18 19 import android.telephony.TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO 20 import android.telephony.TelephonyManager.NETWORK_TYPE_GSM 21 import android.telephony.TelephonyManager.NETWORK_TYPE_LTE 22 import android.telephony.TelephonyManager.NETWORK_TYPE_UMTS 23 import com.android.settingslib.SignalIcon.MobileIconGroup 24 import com.android.settingslib.mobile.TelephonyIcons 25 import com.android.systemui.log.table.TableLogBuffer 26 import com.android.systemui.statusbar.pipeline.mobile.data.model.MobileConnectivityModel 27 import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel 28 import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy 29 import kotlinx.coroutines.flow.MutableStateFlow 30 31 class FakeMobileIconsInteractor( 32 mobileMappings: MobileMappingsProxy, 33 val tableLogBuffer: TableLogBuffer, 34 ) : MobileIconsInteractor { 35 val THREE_G_KEY = mobileMappings.toIconKey(THREE_G) 36 val LTE_KEY = mobileMappings.toIconKey(LTE) 37 val FOUR_G_KEY = mobileMappings.toIconKey(FOUR_G) 38 val FIVE_G_OVERRIDE_KEY = mobileMappings.toIconKeyOverride(FIVE_G_OVERRIDE) 39 40 /** 41 * To avoid a reliance on [MobileMappings], we'll build a simpler map from network type to 42 * mobile icon. See TelephonyManager.NETWORK_TYPES for a list of types and [TelephonyIcons] for 43 * the exhaustive set of icons 44 */ 45 val TEST_MAPPING: Map<String, MobileIconGroup> = 46 mapOf( 47 THREE_G_KEY to TelephonyIcons.THREE_G, 48 LTE_KEY to TelephonyIcons.LTE, 49 FOUR_G_KEY to TelephonyIcons.FOUR_G, 50 FIVE_G_OVERRIDE_KEY to TelephonyIcons.NR_5G, 51 ) 52 53 override val isDefaultConnectionFailed = MutableStateFlow(false) 54 55 override val filteredSubscriptions = MutableStateFlow<List<SubscriptionModel>>(listOf()) 56 57 private val _activeDataConnectionHasDataEnabled = MutableStateFlow(false) 58 override val activeDataConnectionHasDataEnabled = _activeDataConnectionHasDataEnabled 59 60 override val alwaysShowDataRatIcon = MutableStateFlow(false) 61 62 override val alwaysUseCdmaLevel = MutableStateFlow(false) 63 override val defaultDataSubId = MutableStateFlow(DEFAULT_DATA_SUB_ID) 64 65 override val defaultMobileNetworkConnectivity = MutableStateFlow(MobileConnectivityModel()) 66 67 private val _defaultMobileIconMapping = MutableStateFlow(TEST_MAPPING) 68 override val defaultMobileIconMapping = _defaultMobileIconMapping 69 70 private val _defaultMobileIconGroup = MutableStateFlow(DEFAULT_ICON) 71 override val defaultMobileIconGroup = _defaultMobileIconGroup 72 73 private val _isUserSetup = MutableStateFlow(true) 74 override val isUserSetup = _isUserSetup 75 76 override val isForceHidden = MutableStateFlow(false) 77 78 /** Always returns a new fake interactor */ createMobileConnectionInteractorForSubIdnull79 override fun createMobileConnectionInteractorForSubId(subId: Int): MobileIconInteractor { 80 return FakeMobileIconInteractor(tableLogBuffer) 81 } 82 83 companion object { 84 val DEFAULT_ICON = TelephonyIcons.G 85 86 const val DEFAULT_DATA_SUB_ID = 1 87 88 // Use [MobileMappings] to define some simple definitions 89 const val THREE_G = NETWORK_TYPE_GSM 90 const val LTE = NETWORK_TYPE_LTE 91 const val FOUR_G = NETWORK_TYPE_UMTS 92 const val FIVE_G_OVERRIDE = OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO 93 } 94 } 95