1 /* 2 * Copyright (C) 2017 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.googlecode.android_scripting.facade.telephony; 18 19 import android.telecom.TelecomManager; 20 import android.telephony.DataConnectionRealTimeInfo; 21 import android.telephony.PreciseCallState; 22 import android.telephony.ServiceState; 23 import android.telephony.TelephonyDisplayInfo; 24 import android.telephony.TelephonyManager; 25 import android.telephony.VoLteServiceState; 26 27 import com.android.ims.ImsConfig; 28 import com.android.internal.telephony.RILConstants; 29 30 import com.googlecode.android_scripting.Log; 31 32 /** 33 * Telephony utility functions 34 */ 35 public class TelephonyUtils { 36 getWfcModeString(int mode)37 public static String getWfcModeString(int mode) { 38 switch(mode) { 39 case ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED: 40 return TelephonyConstants.WFC_MODE_WIFI_PREFERRED; 41 case ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED: 42 return TelephonyConstants.WFC_MODE_CELLULAR_PREFERRED; 43 case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY: 44 return TelephonyConstants.WFC_MODE_WIFI_ONLY; 45 } 46 Log.d("getWfcModeStringfromInt error. int: " + mode); 47 return TelephonyConstants.WFC_MODE_UNKNOWN; 48 } 49 getTtyModeString(int mode)50 public static String getTtyModeString(int mode) { 51 switch (mode) { 52 case TelecomManager.TTY_MODE_FULL: 53 return TelephonyConstants.TTY_MODE_FULL; 54 case TelecomManager.TTY_MODE_HCO: 55 return TelephonyConstants.TTY_MODE_HCO; 56 case TelecomManager.TTY_MODE_OFF: 57 return TelephonyConstants.TTY_MODE_OFF; 58 case TelecomManager.TTY_MODE_VCO: 59 return TelephonyConstants.TTY_MODE_VCO; 60 } 61 Log.d("getTtyModeString error. int: " + mode); 62 return null; 63 } 64 getPhoneTypeString(int type)65 public static String getPhoneTypeString(int type) { 66 switch (type) { 67 case TelephonyManager.PHONE_TYPE_GSM: 68 return TelephonyConstants.PHONE_TYPE_GSM; 69 case TelephonyManager.PHONE_TYPE_NONE: 70 return TelephonyConstants.PHONE_TYPE_NONE; 71 case TelephonyManager.PHONE_TYPE_CDMA: 72 return TelephonyConstants.PHONE_TYPE_CDMA; 73 case TelephonyManager.PHONE_TYPE_SIP: 74 return TelephonyConstants.PHONE_TYPE_SIP; 75 } 76 Log.d("getPhoneTypeString error. int: " + type); 77 return null; 78 } 79 getSimStateString(int state)80 public static String getSimStateString(int state) { 81 switch (state) { 82 case TelephonyManager.SIM_STATE_UNKNOWN: 83 return TelephonyConstants.SIM_STATE_UNKNOWN; 84 case TelephonyManager.SIM_STATE_ABSENT: 85 return TelephonyConstants.SIM_STATE_ABSENT; 86 case TelephonyManager.SIM_STATE_PIN_REQUIRED: 87 return TelephonyConstants.SIM_STATE_PIN_REQUIRED; 88 case TelephonyManager.SIM_STATE_PUK_REQUIRED: 89 return TelephonyConstants.SIM_STATE_PUK_REQUIRED; 90 case TelephonyManager.SIM_STATE_NETWORK_LOCKED: 91 return TelephonyConstants.SIM_STATE_NETWORK_LOCKED; 92 case TelephonyManager.SIM_STATE_READY: 93 return TelephonyConstants.SIM_STATE_READY; 94 case TelephonyManager.SIM_STATE_NOT_READY: 95 return TelephonyConstants.SIM_STATE_NOT_READY; 96 case TelephonyManager.SIM_STATE_PERM_DISABLED: 97 return TelephonyConstants.SIM_STATE_PERM_DISABLED; 98 case TelephonyManager.SIM_STATE_CARD_IO_ERROR: 99 return TelephonyConstants.SIM_STATE_CARD_IO_ERROR; 100 } 101 Log.d("getSimStateString error. int: " + state); 102 return TelephonyConstants.SIM_STATE_UNKNOWN; 103 } 104 formatIncomingNumber(String incomingNumber)105 public static String formatIncomingNumber(String incomingNumber) { 106 String mIncomingNumber = null; 107 int len = 0; 108 if (incomingNumber != null) { 109 len = incomingNumber.length(); 110 } 111 if (len > 0) { 112 /** 113 * Currently this incomingNumber modification is specific for 114 * US numbers. 115 */ 116 if ((12 == len) && ('+' == incomingNumber.charAt(0))) { 117 mIncomingNumber = incomingNumber.substring(1); 118 } else if (10 == len) { 119 mIncomingNumber = '1' + incomingNumber; 120 } else { 121 mIncomingNumber = incomingNumber; 122 } 123 } 124 return mIncomingNumber; 125 } 126 getTelephonyCallStateString(int callState)127 public static String getTelephonyCallStateString(int callState) { 128 switch (callState) { 129 case TelephonyManager.CALL_STATE_IDLE: 130 return TelephonyConstants.TELEPHONY_STATE_IDLE; 131 case TelephonyManager.CALL_STATE_OFFHOOK: 132 return TelephonyConstants.TELEPHONY_STATE_OFFHOOK; 133 case TelephonyManager.CALL_STATE_RINGING: 134 return TelephonyConstants.TELEPHONY_STATE_RINGING; 135 } 136 Log.d("getTelephonyCallStateString error. int: " + callState); 137 return TelephonyConstants.TELEPHONY_STATE_UNKNOWN; 138 } 139 getPreciseCallStateString(int state)140 public static String getPreciseCallStateString(int state) { 141 switch (state) { 142 case PreciseCallState.PRECISE_CALL_STATE_ACTIVE: 143 return TelephonyConstants.PRECISE_CALL_STATE_ACTIVE; 144 case PreciseCallState.PRECISE_CALL_STATE_HOLDING: 145 return TelephonyConstants.PRECISE_CALL_STATE_HOLDING; 146 case PreciseCallState.PRECISE_CALL_STATE_DIALING: 147 return TelephonyConstants.PRECISE_CALL_STATE_DIALING; 148 case PreciseCallState.PRECISE_CALL_STATE_ALERTING: 149 return TelephonyConstants.PRECISE_CALL_STATE_ALERTING; 150 case PreciseCallState.PRECISE_CALL_STATE_INCOMING: 151 return TelephonyConstants.PRECISE_CALL_STATE_INCOMING; 152 case PreciseCallState.PRECISE_CALL_STATE_WAITING: 153 return TelephonyConstants.PRECISE_CALL_STATE_WAITING; 154 case PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED: 155 return TelephonyConstants.PRECISE_CALL_STATE_DISCONNECTED; 156 case PreciseCallState.PRECISE_CALL_STATE_DISCONNECTING: 157 return TelephonyConstants.PRECISE_CALL_STATE_DISCONNECTING; 158 case PreciseCallState.PRECISE_CALL_STATE_IDLE: 159 return TelephonyConstants.PRECISE_CALL_STATE_IDLE; 160 case PreciseCallState.PRECISE_CALL_STATE_NOT_VALID: 161 return TelephonyConstants.PRECISE_CALL_STATE_INVALID; 162 } 163 Log.d("getPreciseCallStateString error. int: " + state); 164 return TelephonyConstants.PRECISE_CALL_STATE_UNKNOWN; 165 } 166 getDcPowerStateString(int state)167 public static String getDcPowerStateString(int state) { 168 if (state == DataConnectionRealTimeInfo.DC_POWER_STATE_LOW) { 169 return TelephonyConstants.DC_POWER_STATE_LOW; 170 } else if (state == DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH) { 171 return TelephonyConstants.DC_POWER_STATE_HIGH; 172 } else if (state == DataConnectionRealTimeInfo.DC_POWER_STATE_MEDIUM) { 173 return TelephonyConstants.DC_POWER_STATE_MEDIUM; 174 } else { 175 return TelephonyConstants.DC_POWER_STATE_UNKNOWN; 176 } 177 } 178 getDataConnectionStateString(int state)179 public static String getDataConnectionStateString(int state) { 180 switch (state) { 181 case TelephonyManager.DATA_DISCONNECTED: 182 return TelephonyConstants.DATA_STATE_DISCONNECTED; 183 case TelephonyManager.DATA_CONNECTING: 184 return TelephonyConstants.DATA_STATE_CONNECTING; 185 case TelephonyManager.DATA_CONNECTED: 186 return TelephonyConstants.DATA_STATE_CONNECTED; 187 case TelephonyManager.DATA_SUSPENDED: 188 return TelephonyConstants.DATA_STATE_SUSPENDED; 189 case TelephonyManager.DATA_UNKNOWN: 190 return TelephonyConstants.DATA_STATE_UNKNOWN; 191 } 192 Log.d("getDataConnectionStateString error. int: " + state); 193 return TelephonyConstants.DATA_STATE_UNKNOWN; 194 } 195 getDisplayInfoString(int state)196 public static String getDisplayInfoString(int state) { 197 switch (state) { 198 case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE: 199 return TelephonyConstants.OVERRIDE_NETWORK_TYPE_NONE; 200 case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA: 201 return TelephonyConstants.OVERRIDE_NETWORK_TYPE_LTE_CA; 202 case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO: 203 return TelephonyConstants.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO; 204 case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA: 205 return TelephonyConstants.OVERRIDE_NETWORK_TYPE_NR_NSA; 206 case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED: 207 return TelephonyConstants.OVERRIDE_NETWORK_TYPE_NR_ADVANCED; 208 } 209 Log.d("getDisplayInfoStateString error. int: " + state); 210 return TelephonyConstants.OVERRIDE_NETWORK_TYPE_NONE; 211 } 212 getNetworkModeIntfromString(String networkMode)213 public static int getNetworkModeIntfromString(String networkMode) { 214 switch (networkMode) { 215 case TelephonyConstants.NETWORK_MODE_WCDMA_PREF: 216 return RILConstants.NETWORK_MODE_WCDMA_PREF; 217 case TelephonyConstants.NETWORK_MODE_GSM_ONLY: 218 return RILConstants.NETWORK_MODE_GSM_ONLY; 219 case TelephonyConstants.NETWORK_MODE_WCDMA_ONLY: 220 return RILConstants.NETWORK_MODE_WCDMA_ONLY; 221 case TelephonyConstants.NETWORK_MODE_GSM_UMTS: 222 return RILConstants.NETWORK_MODE_GSM_UMTS; 223 case TelephonyConstants.NETWORK_MODE_CDMA: 224 return RILConstants.NETWORK_MODE_CDMA; 225 case TelephonyConstants.NETWORK_MODE_CDMA_NO_EVDO: 226 return RILConstants.NETWORK_MODE_CDMA_NO_EVDO; 227 case TelephonyConstants.NETWORK_MODE_EVDO_NO_CDMA: 228 return RILConstants.NETWORK_MODE_EVDO_NO_CDMA; 229 case TelephonyConstants.NETWORK_MODE_GLOBAL: 230 return RILConstants.NETWORK_MODE_GLOBAL; 231 case TelephonyConstants.NETWORK_MODE_LTE_CDMA_EVDO: 232 return RILConstants.NETWORK_MODE_LTE_CDMA_EVDO; 233 case TelephonyConstants.NETWORK_MODE_LTE_GSM_WCDMA: 234 return RILConstants.NETWORK_MODE_LTE_GSM_WCDMA; 235 case TelephonyConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA: 236 return RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA; 237 case TelephonyConstants.NETWORK_MODE_LTE_ONLY: 238 return RILConstants.NETWORK_MODE_LTE_ONLY; 239 case TelephonyConstants.NETWORK_MODE_LTE_WCDMA: 240 return RILConstants.NETWORK_MODE_LTE_WCDMA; 241 case TelephonyConstants.NETWORK_MODE_TDSCDMA_ONLY: 242 return RILConstants.NETWORK_MODE_TDSCDMA_ONLY; 243 case TelephonyConstants.NETWORK_MODE_TDSCDMA_WCDMA: 244 return RILConstants.NETWORK_MODE_TDSCDMA_WCDMA; 245 case TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA: 246 return RILConstants.NETWORK_MODE_LTE_TDSCDMA; 247 case TelephonyConstants.NETWORK_MODE_TDSCDMA_GSM: 248 return RILConstants.NETWORK_MODE_TDSCDMA_GSM; 249 case TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA_GSM: 250 return RILConstants.NETWORK_MODE_LTE_TDSCDMA_GSM; 251 case TelephonyConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA: 252 return RILConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA; 253 case TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA_WCDMA: 254 return RILConstants.NETWORK_MODE_LTE_TDSCDMA_WCDMA; 255 case TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA: 256 return RILConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA; 257 case TelephonyConstants.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: 258 return RILConstants.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; 259 case TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: 260 return RILConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; 261 case TelephonyConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA: 262 return RILConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA; 263 case TelephonyConstants.NETWORK_MODE_NR_ONLY: 264 return RILConstants.NETWORK_MODE_NR_ONLY; 265 case TelephonyConstants.NETWORK_MODE_NR_LTE: 266 return RILConstants.NETWORK_MODE_NR_LTE; 267 case TelephonyConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO: 268 return RILConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO; 269 case TelephonyConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA: 270 return RILConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA; 271 case TelephonyConstants.NETWORK_MODE_NR_LTE_WCDMA: 272 return RILConstants.NETWORK_MODE_NR_LTE_WCDMA; 273 case TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA: 274 return RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA; 275 case TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM: 276 return RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM; 277 case TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA: 278 return RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA; 279 case TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA: 280 return RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA; 281 case TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: 282 return RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; 283 } 284 Log.d("getNetworkModeIntfromString error. String: " + networkMode); 285 return RILConstants.RIL_ERRNO_INVALID_RESPONSE; 286 } 287 getNetworkModeStringfromInt(int networkMode)288 public static String getNetworkModeStringfromInt(int networkMode) { 289 switch (networkMode) { 290 case RILConstants.NETWORK_MODE_WCDMA_PREF: 291 return TelephonyConstants.NETWORK_MODE_WCDMA_PREF; 292 case RILConstants.NETWORK_MODE_GSM_ONLY: 293 return TelephonyConstants.NETWORK_MODE_GSM_ONLY; 294 case RILConstants.NETWORK_MODE_WCDMA_ONLY: 295 return TelephonyConstants.NETWORK_MODE_WCDMA_ONLY; 296 case RILConstants.NETWORK_MODE_GSM_UMTS: 297 return TelephonyConstants.NETWORK_MODE_GSM_UMTS; 298 case RILConstants.NETWORK_MODE_CDMA: 299 return TelephonyConstants.NETWORK_MODE_CDMA; 300 case RILConstants.NETWORK_MODE_CDMA_NO_EVDO: 301 return TelephonyConstants.NETWORK_MODE_CDMA_NO_EVDO; 302 case RILConstants.NETWORK_MODE_EVDO_NO_CDMA: 303 return TelephonyConstants.NETWORK_MODE_EVDO_NO_CDMA; 304 case RILConstants.NETWORK_MODE_GLOBAL: 305 return TelephonyConstants.NETWORK_MODE_GLOBAL; 306 case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO: 307 return TelephonyConstants.NETWORK_MODE_LTE_CDMA_EVDO; 308 case RILConstants.NETWORK_MODE_LTE_GSM_WCDMA: 309 return TelephonyConstants.NETWORK_MODE_LTE_GSM_WCDMA; 310 case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA: 311 return TelephonyConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA; 312 case RILConstants.NETWORK_MODE_LTE_ONLY: 313 return TelephonyConstants.NETWORK_MODE_LTE_ONLY; 314 case RILConstants.NETWORK_MODE_LTE_WCDMA: 315 return TelephonyConstants.NETWORK_MODE_LTE_WCDMA; 316 case RILConstants.NETWORK_MODE_TDSCDMA_ONLY: 317 return TelephonyConstants.NETWORK_MODE_TDSCDMA_ONLY; 318 case RILConstants.NETWORK_MODE_TDSCDMA_WCDMA: 319 return TelephonyConstants.NETWORK_MODE_TDSCDMA_WCDMA; 320 case RILConstants.NETWORK_MODE_LTE_TDSCDMA: 321 return TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA; 322 case RILConstants.NETWORK_MODE_TDSCDMA_GSM: 323 return TelephonyConstants.NETWORK_MODE_TDSCDMA_GSM; 324 case RILConstants.NETWORK_MODE_LTE_TDSCDMA_GSM: 325 return TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA_GSM; 326 case RILConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA: 327 return TelephonyConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA; 328 case RILConstants.NETWORK_MODE_LTE_TDSCDMA_WCDMA: 329 return TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA_WCDMA; 330 case RILConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA: 331 return TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA; 332 case RILConstants.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: 333 return TelephonyConstants.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; 334 case RILConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: 335 return TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; 336 case RILConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA: 337 return TelephonyConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA; 338 case RILConstants.NETWORK_MODE_NR_ONLY: 339 return TelephonyConstants.NETWORK_MODE_NR_ONLY; 340 case RILConstants.NETWORK_MODE_NR_LTE: 341 return TelephonyConstants.NETWORK_MODE_NR_LTE; 342 case RILConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO: 343 return TelephonyConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO; 344 case RILConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA: 345 return TelephonyConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA; 346 case RILConstants.NETWORK_MODE_NR_LTE_WCDMA: 347 return TelephonyConstants.NETWORK_MODE_NR_LTE_WCDMA; 348 case RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA: 349 return TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA; 350 case RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM: 351 return TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM; 352 case RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA: 353 return TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA; 354 case RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA: 355 return TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA; 356 case RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: 357 return TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; 358 } 359 Log.d("getNetworkModeStringfromInt error. Int: " + networkMode); 360 return TelephonyConstants.NETWORK_MODE_INVALID; 361 } 362 getNetworkTypeString(int type)363 public static String getNetworkTypeString(int type) { 364 switch(type) { 365 case TelephonyManager.NETWORK_TYPE_GPRS: 366 return TelephonyConstants.RAT_GPRS; 367 case TelephonyManager.NETWORK_TYPE_EDGE: 368 return TelephonyConstants.RAT_EDGE; 369 case TelephonyManager.NETWORK_TYPE_UMTS: 370 return TelephonyConstants.RAT_UMTS; 371 case TelephonyManager.NETWORK_TYPE_HSDPA: 372 return TelephonyConstants.RAT_HSDPA; 373 case TelephonyManager.NETWORK_TYPE_HSUPA: 374 return TelephonyConstants.RAT_HSUPA; 375 case TelephonyManager.NETWORK_TYPE_HSPA: 376 return TelephonyConstants.RAT_HSPA; 377 case TelephonyManager.NETWORK_TYPE_CDMA: 378 return TelephonyConstants.RAT_CDMA; 379 case TelephonyManager.NETWORK_TYPE_1xRTT: 380 return TelephonyConstants.RAT_1XRTT; 381 case TelephonyManager.NETWORK_TYPE_EVDO_0: 382 return TelephonyConstants.RAT_EVDO_0; 383 case TelephonyManager.NETWORK_TYPE_EVDO_A: 384 return TelephonyConstants.RAT_EVDO_A; 385 case TelephonyManager.NETWORK_TYPE_EVDO_B: 386 return TelephonyConstants.RAT_EVDO_B; 387 case TelephonyManager.NETWORK_TYPE_EHRPD: 388 return TelephonyConstants.RAT_EHRPD; 389 case TelephonyManager.NETWORK_TYPE_LTE: 390 return TelephonyConstants.RAT_LTE; 391 case TelephonyManager.NETWORK_TYPE_HSPAP: 392 return TelephonyConstants.RAT_HSPAP; 393 case TelephonyManager.NETWORK_TYPE_GSM: 394 return TelephonyConstants.RAT_GSM; 395 case TelephonyManager. NETWORK_TYPE_TD_SCDMA: 396 return TelephonyConstants.RAT_TD_SCDMA; 397 case TelephonyManager.NETWORK_TYPE_IWLAN: 398 return TelephonyConstants.RAT_IWLAN; 399 case TelephonyManager.NETWORK_TYPE_IDEN: 400 return TelephonyConstants.RAT_IDEN; 401 case TelephonyManager.NETWORK_TYPE_LTE_CA: 402 return TelephonyConstants.RAT_LTE_CA; 403 case TelephonyManager.NETWORK_TYPE_NR: 404 return TelephonyConstants.RAT_NR; 405 } 406 return TelephonyConstants.RAT_UNKNOWN; 407 } 408 getNetworkStateString(int state)409 public static String getNetworkStateString(int state) { 410 switch(state) { 411 case ServiceState.STATE_EMERGENCY_ONLY: 412 return TelephonyConstants.SERVICE_STATE_EMERGENCY_ONLY; 413 case ServiceState.STATE_IN_SERVICE: 414 return TelephonyConstants.SERVICE_STATE_IN_SERVICE; 415 case ServiceState.STATE_OUT_OF_SERVICE: 416 return TelephonyConstants.SERVICE_STATE_OUT_OF_SERVICE; 417 case ServiceState.STATE_POWER_OFF: 418 return TelephonyConstants.SERVICE_STATE_POWER_OFF; 419 default: 420 return TelephonyConstants.SERVICE_STATE_UNKNOWN; 421 } 422 } 423 getSrvccStateString(int srvccState)424 public static String getSrvccStateString(int srvccState) { 425 switch (srvccState) { 426 case VoLteServiceState.HANDOVER_STARTED: 427 return TelephonyConstants.VOLTE_SERVICE_STATE_HANDOVER_STARTED; 428 case VoLteServiceState.HANDOVER_COMPLETED: 429 return TelephonyConstants.VOLTE_SERVICE_STATE_HANDOVER_COMPLETED; 430 case VoLteServiceState.HANDOVER_FAILED: 431 return TelephonyConstants.VOLTE_SERVICE_STATE_HANDOVER_FAILED; 432 case VoLteServiceState.HANDOVER_CANCELED: 433 return TelephonyConstants.VOLTE_SERVICE_STATE_HANDOVER_CANCELED; 434 default: 435 Log.e(String.format("getSrvccStateString():" 436 + "unknown state %d", srvccState)); 437 return TelephonyConstants.VOLTE_SERVICE_STATE_HANDOVER_UNKNOWN; 438 } 439 }; 440 } 441