1 /* 2 * Copyright (C) 2021 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.connectivity 18 19 import android.telephony.SubscriptionInfo 20 21 /** 22 * SignalCallback contains all of the connectivity updates from [NetworkController]. Implement this 23 * interface to be able to draw iconography for Wi-Fi, mobile data, ethernet, call strength 24 * indicators, etc. 25 * 26 * @deprecated 27 */ 28 @Deprecated( 29 "Use Recommended Architecture classes instead: MobileIconsInteractor, WifiInteractor, " + 30 "AirplaneModeInteractor, and EthernetInteractor" 31 ) 32 interface SignalCallback { 33 /** 34 * Called when the Wi-Fi iconography has been updated. Implement this method to draw Wi-Fi icons 35 * 36 * @param wifiIndicators a box type containing enough information to properly draw a Wi-Fi icon 37 */ setWifiIndicatorsnull38 fun setWifiIndicators(wifiIndicators: WifiIndicators) {} 39 40 /** 41 * Called when the mobile iconography has been updated. Implement this method to draw mobile 42 * indicators 43 * 44 * @param mobileDataIndicators a box type containing enough information to properly draw mobile 45 * data icons 46 * 47 * NOTE: phones can have multiple subscriptions, so this [mobileDataIndicators] object should be 48 * indexed based on its [subId][MobileDataIndicators.subId] 49 */ setMobileDataIndicatorsnull50 fun setMobileDataIndicators(mobileDataIndicators: MobileDataIndicators) {} 51 52 /** 53 * Called when the list of mobile data subscriptions has changed. Use this method as a chance to 54 * remove views that are no longer needed, or to make room for new icons to come in 55 * 56 * @param subs a [SubscriptionInfo] for each subscription that we know about 57 */ setSubsnull58 fun setSubs(subs: List<@JvmSuppressWildcards SubscriptionInfo>) {} 59 60 /** 61 * Called when: 62 * 1. The number of [MobileSignalController]s goes to 0 while mobile data is enabled OR 63 * 2. The presence of any SIM changes 64 * 65 * @param show whether or not to show a "no sim" view 66 * @param simDetected whether any SIM is detected or not 67 */ setNoSimsnull68 fun setNoSims(show: Boolean, simDetected: Boolean) {} 69 70 /** 71 * Called when there is any update to the ethernet iconography. Implement this method to set an 72 * ethernet icon 73 * 74 * @param icon an [IconState] for the current ethernet status 75 */ setEthernetIndicatorsnull76 fun setEthernetIndicators(icon: IconState) {} 77 78 /** 79 * Called whenever airplane mode changes 80 * 81 * @param icon an [IconState] for the current airplane mode status 82 */ setIsAirplaneModenull83 fun setIsAirplaneMode(icon: IconState) {} 84 85 /** 86 * Called whenever the mobile data feature enabled state changes 87 * 88 * @param enabled the current mobile data feature ennabled state 89 */ setMobileDataEnablednull90 fun setMobileDataEnabled(enabled: Boolean) {} 91 92 /** 93 * Callback for listeners to be able to update the connectivity status 94 * 95 * @param noDefaultNetwork whether there is any default network. 96 * @param noValidatedNetwork whether there is any validated network. 97 * @param noNetworksAvailable whether there is any WiFi networks available. 98 */ setConnectivityStatusnull99 fun setConnectivityStatus( 100 noDefaultNetwork: Boolean, 101 noValidatedNetwork: Boolean, 102 noNetworksAvailable: Boolean, 103 ) {} 104 } 105 106 /** Box type for [SignalCallback.setWifiIndicators] */ 107 data class WifiIndicators( 108 @JvmField val enabled: Boolean, 109 @JvmField val statusIcon: IconState?, 110 @JvmField val qsIcon: IconState?, 111 @JvmField val activityIn: Boolean, 112 @JvmField val activityOut: Boolean, 113 @JvmField val description: String?, 114 @JvmField val isTransient: Boolean, 115 @JvmField val statusLabel: String?, 116 ) { toStringnull117 override fun toString(): String { 118 return StringBuilder("WifiIndicators[") 119 .append("enabled=") 120 .append(enabled) 121 .append(",statusIcon=") 122 .append(statusIcon?.toString() ?: "") 123 .append(",qsIcon=") 124 .append(qsIcon?.toString() ?: "") 125 .append(",activityIn=") 126 .append(activityIn) 127 .append(",activityOut=") 128 .append(activityOut) 129 .append(",qsDescription=") 130 .append(description) 131 .append(",isTransient=") 132 .append(isTransient) 133 .append(",statusLabel=") 134 .append(statusLabel) 135 .append(']') 136 .toString() 137 } 138 } 139 140 /** Box type for [SignalCallback.setMobileDataIndicators] */ 141 data class MobileDataIndicators( 142 @JvmField val statusIcon: IconState?, 143 @JvmField val qsIcon: IconState?, 144 @JvmField val statusType: Int, 145 @JvmField val qsType: Int, 146 @JvmField val activityIn: Boolean, 147 @JvmField val activityOut: Boolean, 148 @JvmField val typeContentDescription: CharSequence?, 149 @JvmField val typeContentDescriptionHtml: CharSequence?, 150 @JvmField val qsDescription: CharSequence?, 151 @JvmField val subId: Int, 152 @JvmField val roaming: Boolean, 153 @JvmField val showTriangle: Boolean, 154 ) { toStringnull155 override fun toString(): String { 156 return java.lang 157 .StringBuilder("MobileDataIndicators[") 158 .append("statusIcon=") 159 .append(statusIcon?.toString() ?: "") 160 .append(",qsIcon=") 161 .append(qsIcon?.toString() ?: "") 162 .append(",statusType=") 163 .append(statusType) 164 .append(",qsType=") 165 .append(qsType) 166 .append(",activityIn=") 167 .append(activityIn) 168 .append(",activityOut=") 169 .append(activityOut) 170 .append(",typeContentDescription=") 171 .append(typeContentDescription) 172 .append(",typeContentDescriptionHtml=") 173 .append(typeContentDescriptionHtml) 174 .append(",description=") 175 .append(qsDescription) 176 .append(",subId=") 177 .append(subId) 178 .append(",roaming=") 179 .append(roaming) 180 .append(",showTriangle=") 181 .append(showTriangle) 182 .append(']') 183 .toString() 184 } 185 } 186 187 /** Box for an icon with its visibility and content description */ 188 data class IconState( 189 @JvmField val visible: Boolean, 190 @JvmField val icon: Int, 191 @JvmField val contentDescription: String, 192 ) { toStringnull193 override fun toString(): String { 194 val builder = java.lang.StringBuilder() 195 return builder 196 .append("[visible=") 197 .append(visible) 198 .append(',') 199 .append("icon=") 200 .append(icon) 201 .append(',') 202 .append("contentDescription=") 203 .append(contentDescription) 204 .append(']') 205 .toString() 206 } 207 } 208