1 /* 2 * Copyright (C) 2024 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.data.repository 18 19 import android.telephony.CellSignalStrength 20 import android.telephony.TelephonyManager 21 import com.android.systemui.kairos.ExperimentalKairosApi 22 import com.android.systemui.kairos.State 23 import com.android.systemui.log.table.TableLogBuffer 24 import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionState 25 import com.android.systemui.statusbar.pipeline.mobile.data.model.NetworkNameModel 26 import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType 27 import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel 28 29 /** 30 * Every mobile line of service can be identified via a [SubscriptionInfo] object. We set up a 31 * repository for each individual, tracked subscription via [MobileConnectionsRepository], and this 32 * repository is responsible for setting up a [TelephonyManager] object tied to its subscriptionId 33 * 34 * There should only ever be one [MobileConnectionRepository] per subscription, since 35 * [TelephonyManager] limits the number of callbacks that can be registered per process. 36 * 37 * This repository should have all of the relevant information for a single line of service, which 38 * eventually becomes a single icon in the status bar. 39 */ 40 @ExperimentalKairosApi 41 interface MobileConnectionRepositoryKairos { 42 /** The subscriptionId that this connection represents */ 43 val subId: Int 44 45 /** The carrierId for this connection. See [TelephonyManager.getSimCarrierId] */ 46 val carrierId: State<Int> 47 48 /** Reflects the value from the carrier config INFLATE_SIGNAL_STRENGTH for this connection */ 49 val inflateSignalStrength: State<Boolean> 50 51 /** Carrier config KEY_SHOW_5G_SLICE_ICON_BOOL for this connection */ 52 val allowNetworkSliceIndicator: State<Boolean> 53 54 /** 55 * The table log buffer created for this connection. Will have the name "MobileConnectionLog 56 * [subId]" 57 */ 58 val tableLogBuffer: TableLogBuffer 59 60 /** True if the [android.telephony.ServiceState] says this connection is emergency calls only */ 61 val isEmergencyOnly: State<Boolean> 62 63 /** True if [android.telephony.ServiceState] says we are roaming */ 64 val isRoaming: State<Boolean> 65 66 /** 67 * See [android.telephony.ServiceState.getOperatorAlphaShort], this value is defined as the 68 * current registered operator name in short alphanumeric format. In some cases this name might 69 * be preferred over other methods of calculating the network name 70 */ 71 val operatorAlphaShort: State<String?> 72 73 /** 74 * TODO (b/263167683): Clarify this field 75 * 76 * This check comes from [com.android.settingslib.Utils.isInService]. It is intended to be a 77 * mapping from a ServiceState to a notion of connectivity. Notably, it will consider a 78 * connection to be in-service if either the voice registration state is IN_SERVICE or the data 79 * registration state is IN_SERVICE and NOT IWLAN. 80 */ 81 val isInService: State<Boolean> 82 83 /** 84 * True if this subscription is actively connected to a non-terrestrial network and false 85 * otherwise. Reflects [android.telephony.ServiceState.isUsingNonTerrestrialNetwork]. 86 * 87 * Notably: This value reflects that this subscription is **currently** using a non-terrestrial 88 * network, because some subscriptions can switch between terrestrial and non-terrestrial 89 * networks. [SubscriptionModel.isExclusivelyNonTerrestrial] reflects whether a subscription is 90 * configured to exclusively connect to non-terrestrial networks. [isNonTerrestrial] can change 91 * during the lifetime of a subscription but [SubscriptionModel.isExclusivelyNonTerrestrial] 92 * will stay constant. 93 */ 94 val isNonTerrestrial: State<Boolean> 95 96 /** True if [android.telephony.SignalStrength] told us that this connection is using GSM */ 97 val isGsm: State<Boolean> 98 99 /** 100 * There is still specific logic in the pipeline that calls out CDMA level explicitly. This 101 * field is not completely orthogonal to [primaryLevel], because CDMA could be primary. 102 */ 103 // @IntRange(from = 0, to = 4) 104 val cdmaLevel: State<Int> 105 106 /** [android.telephony.SignalStrength]'s concept of the overall signal level */ 107 // @IntRange(from = 0, to = 4) 108 val primaryLevel: State<Int> 109 110 /** 111 * This level can be used to reflect the signal strength when in carrier roaming NTN mode 112 * (carrier-based satellite) 113 */ 114 val satelliteLevel: State<Int> 115 116 /** The current data connection state. See [DataConnectionState] */ 117 val dataConnectionState: State<DataConnectionState> 118 119 /** The current data activity direction. See [DataActivityModel] */ 120 val dataActivityDirection: State<DataActivityModel> 121 122 /** True if there is currently a carrier network change in process */ 123 val carrierNetworkChangeActive: State<Boolean> 124 125 /** 126 * [resolvedNetworkType] is the [TelephonyDisplayInfo.getOverrideNetworkType] if it exists or 127 * [TelephonyDisplayInfo.getNetworkType]. This is used to look up the proper network type icon 128 */ 129 val resolvedNetworkType: State<ResolvedNetworkType> 130 131 /** The total number of levels. Used with [SignalDrawable]. */ 132 val numberOfLevels: State<Int> 133 134 /** Observable tracking [TelephonyManager.isDataConnectionAllowed] */ 135 val dataEnabled: State<Boolean> 136 137 /** 138 * See [TelephonyManager.getCdmaEnhancedRoamingIndicatorDisplayNumber]. This bit only matters if 139 * the connection type is CDMA. 140 * 141 * True if the Enhanced Roaming Indicator (ERI) display number is not [TelephonyManager.ERI_OFF] 142 */ 143 val cdmaRoaming: State<Boolean> 144 145 /** The service provider name for this network connection, or the default name. */ 146 val networkName: State<NetworkNameModel> 147 148 /** 149 * The service provider name for this network connection, or the default name. 150 * 151 * TODO(b/296600321): De-duplicate this field with [networkName] after determining the data 152 * provided is identical 153 */ 154 val carrierName: State<NetworkNameModel> 155 156 /** 157 * True if this type of connection is allowed while airplane mode is on, and false otherwise. 158 */ 159 val isAllowedDuringAirplaneMode: State<Boolean> 160 161 /** 162 * True if this network has NET_CAPABILITIY_PRIORITIZE_LATENCY, and can be considered to be a 163 * network slice 164 */ 165 val hasPrioritizedNetworkCapabilities: State<Boolean> 166 167 /** 168 * True if this connection is in emergency callback mode. 169 * 170 * @see [TelephonyManager.getEmergencyCallbackMode] 171 */ 172 val isInEcmMode: State<Boolean> 173 174 companion object { 175 /** The default number of levels to use for [numberOfLevels]. */ 176 val DEFAULT_NUM_LEVELS = CellSignalStrength.getNumSignalStrengthLevels() 177 } 178 } 179