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.data.model 18 19 import android.telephony.Annotation.NetworkType 20 import android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN 21 import com.android.settingslib.SignalIcon 22 import com.android.settingslib.mobile.MobileMappings 23 import com.android.settingslib.mobile.TelephonyIcons 24 import com.android.systemui.log.table.Diffable 25 import com.android.systemui.log.table.TableRowLogger 26 import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy 27 28 /** 29 * A SysUI type to represent the [NetworkType] that we pull out of [TelephonyDisplayInfo]. Depending 30 * on whether or not the display info contains an override type, we may have to call different 31 * methods on [MobileMappingsProxy] to generate an icon lookup key. 32 */ 33 sealed interface ResolvedNetworkType : Diffable<ResolvedNetworkType> { 34 val lookupKey: String 35 logDiffsnull36 override fun logDiffs(prevVal: ResolvedNetworkType, row: TableRowLogger) { 37 if (prevVal != this) { 38 row.logChange(COL_NETWORK_TYPE, this.toString()) 39 } 40 } 41 42 object UnknownNetworkType : ResolvedNetworkType { 43 override val lookupKey: String = MobileMappings.toIconKey(NETWORK_TYPE_UNKNOWN) 44 toStringnull45 override fun toString(): String = "Unknown" 46 } 47 48 data class DefaultNetworkType( 49 override val lookupKey: String, 50 ) : ResolvedNetworkType 51 52 data class OverrideNetworkType( 53 override val lookupKey: String, 54 ) : ResolvedNetworkType 55 56 /** Represents the carrier merged network. See [CarrierMergedConnectionRepository]. */ 57 object CarrierMergedNetworkType : ResolvedNetworkType { 58 // Effectively unused since [iconGroupOverride] is used instead. 59 override val lookupKey: String = "cwf" 60 61 val iconGroupOverride: SignalIcon.MobileIconGroup = TelephonyIcons.CARRIER_MERGED_WIFI 62 63 override fun toString(): String = "CarrierMerged" 64 } 65 66 companion object { 67 private const val COL_NETWORK_TYPE = "networkType" 68 } 69 } 70