1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ENUM_CONVERT_H 17 #define ENUM_CONVERT_H 18 19 #include <map> 20 #include <stdint.h> 21 #include <string> 22 23 #include "iosfwd" 24 25 namespace OHOS { 26 namespace Telephony { 27 /** 28 * @brief Indicates the SIM card types. 29 */ 30 enum class TelephonyCardType { 31 /** 32 * Icc card type: unknown type Card. 33 */ 34 UNKNOWN_CARD = -1, 35 /** 36 * Icc card type: Single sim card type. 37 */ 38 SINGLE_MODE_SIM_CARD = 10, 39 /** 40 * Icc card type: Single usim card type. 41 */ 42 SINGLE_MODE_USIM_CARD = 20, 43 /** 44 * Icc card type: Single ruim card type. 45 */ 46 SINGLE_MODE_RUIM_CARD = 30, 47 /** 48 * Icc card type: Double card C+G. 49 */ 50 DUAL_MODE_CG_CARD = 40, 51 /** 52 * Icc card type: China Telecom Internal Roaming Card (Dual Mode). 53 */ 54 CT_NATIONAL_ROAMING_CARD = 41, 55 /** 56 * Icc card type: China Unicom Dual Mode Card. 57 */ 58 CU_DUAL_MODE_CARD = 42, 59 /** 60 * Icc card type: China Telecom LTE Card (Dual Mode). 61 */ 62 DUAL_MODE_TELECOM_LTE_CARD = 43, 63 /** 64 * Icc card type: Double card U+G. 65 */ 66 DUAL_MODE_UG_CARD = 50, 67 /** 68 * Icc card type: Single isim card type. 69 */ 70 SINGLE_MODE_ISIM_CARD = 60, 71 }; 72 73 /** 74 * @brief Indicates the SIM card states. 75 */ 76 enum class TelephonySimState { 77 /** 78 * Indicates unknown SIM card state, the accurate status cannot be obtained. 79 */ 80 SIM_STATE_UNKNOWN, 81 /** 82 * Indicates the SIM card is in not present state, no SIM card is inserted into the card slot. 83 */ 84 SIM_STATE_NOT_PRESENT, 85 /** 86 * Indicates the SIM card is in locked state, the SIM card is locked by 87 * the personal identification number (PIN)/PIN unblocking key (PUK) or network. 88 */ 89 SIM_STATE_LOCKED, 90 /** 91 * Indicates the SIM card is in not ready state, the SIM card is in position but cannot work properly. 92 */ 93 SIM_STATE_NOT_READY, 94 /** 95 * Indicates the SIM card is in the ready state, the SIM card is in position and is working properly. 96 */ 97 SIM_STATE_READY, 98 /** 99 * Indicates the SIM card is in the loaded state, the SIM card is in position and is working properly. 100 */ 101 SIM_STATE_LOADED 102 }; 103 104 /** 105 * @brief Indicates the cellular data link connection state. 106 */ 107 enum class TelephonyDataConnectionStatus { 108 /** 109 * Indicates that a cellular data link is disconnected. 110 */ 111 DATA_STATE_DISCONNECTED = 11, 112 /** 113 * Indicates that a cellular data link is being connected. 114 */ 115 DATA_STATE_CONNECTING = 12, 116 /** 117 * Indicates that a cellular data link is connected. 118 */ 119 DATA_STATE_CONNECTED = 13, 120 /** 121 * Indicates that a cellular data link is suspended. 122 */ 123 DATA_STATE_SUSPENDED = 14 124 }; 125 126 /** 127 * @brief Indicates the state of call. 128 */ 129 enum class TelephonyCallState { 130 /** 131 * Indicates the call is active. 132 */ 133 CALL_STATUS_ACTIVE = 0, 134 /** 135 * Indicates the call is holding. 136 */ 137 CALL_STATUS_HOLDING, 138 /** 139 * Indicates the call is dialing. 140 */ 141 CALL_STATUS_DIALING, 142 /** 143 * Indicates the call is alerting. 144 */ 145 CALL_STATUS_ALERTING, 146 /** 147 * Indicates the call is incoming. 148 */ 149 CALL_STATUS_INCOMING, 150 /** 151 * Indicates the call is waiting. 152 */ 153 CALL_STATUS_WAITING, 154 /** 155 * Indicates the call is disconnected. 156 */ 157 CALL_STATUS_DISCONNECTED, 158 /** 159 * Indicates the call is disconnecting. 160 */ 161 CALL_STATUS_DISCONNECTING, 162 /** 163 * Indicates the call is idle. 164 */ 165 CALL_STATUS_IDLE, 166 }; 167 168 /** 169 * @brief Indicates the radio access technology. 170 */ 171 enum class TelephonyRadioTech { 172 /** 173 * Indicates unknown radio access technology (RAT). 174 */ 175 RADIO_TECHNOLOGY_UNKNOWN = 0, 176 /** 177 * Indicates that RAT is global system for mobile communications (GSM), including GSM, general packet 178 * radio system (GPRS), and enhanced data rates for GSM evolution (EDGE). 179 */ 180 RADIO_TECHNOLOGY_GSM = 1, 181 /** 182 * Indicates that RAT is code division multiple access (CDMA), including Interim Standard 95 (IS95) and 183 * Single-Carrier Radio Transmission Technology (1xRTT). 184 */ 185 RADIO_TECHNOLOGY_1XRTT = 2, 186 /** 187 * Indicates that RAT is wideband code division multiple address (WCDMA). 188 */ 189 RADIO_TECHNOLOGY_WCDMA = 3, 190 /** 191 * Indicates that RAT is high-speed packet access (HSPA), including HSPA, high-speed downlink packet 192 * access (HSDPA), and high-speed uplink packet access (HSUPA). 193 */ 194 RADIO_TECHNOLOGY_HSPA = 4, 195 /** 196 * Indicates that RAT is evolved high-speed packet access (HSPA+), including HSPA+ and dual-carrier 197 * HSPA+ (DC-HSPA+). 198 */ 199 RADIO_TECHNOLOGY_HSPAP = 5, 200 /** 201 * Indicates that RAT is time division-synchronous code division multiple access (TD-SCDMA). 202 */ 203 RADIO_TECHNOLOGY_TD_SCDMA = 6, 204 /** 205 * Indicates that RAT is evolution data only (EVDO), including EVDO Rev.0, EVDO Rev.A, and EVDO Rev.B. 206 */ 207 RADIO_TECHNOLOGY_EVDO = 7, 208 /** 209 * Indicates that RAT is evolved high rate packet data (EHRPD). 210 */ 211 RADIO_TECHNOLOGY_EHRPD = 8, 212 /** 213 * Indicates that RAT is long term evolution (LTE). 214 */ 215 RADIO_TECHNOLOGY_LTE = 9, 216 /** 217 * Indicates that RAT is LTE carrier aggregation (LTE-CA). 218 */ 219 RADIO_TECHNOLOGY_LTE_CA = 10, 220 /** 221 * Indicates that RAT is interworking WLAN (I-WLAN). 222 */ 223 RADIO_TECHNOLOGY_IWLAN = 11, 224 /** 225 * Indicates that RAT is 5G new radio (NR). 226 */ 227 RADIO_TECHNOLOGY_NR = 12 228 }; 229 230 /** 231 * @brief Indicates the cellular data flow type. 232 */ 233 enum class TelephonyCellDataFlowType { 234 /** 235 * Indicates that there is no uplink or downlink data. 236 */ 237 DATA_FLOW_TYPE_NONE = 0, 238 /** 239 * Indicates that there is only downlink data. 240 */ 241 DATA_FLOW_TYPE_DOWN = 1, 242 /** 243 * Indicates that there is only uplink data. 244 */ 245 DATA_FLOW_TYPE_UP = 2, 246 /** 247 * Indicates that there is uplink and downlink data. 248 */ 249 DATA_FLOW_TYPE_UP_DOWN = 3, 250 /** 251 * Indicates that there is no uplink or downlink data, and the bottom-layer link is in the dormant state. 252 */ 253 DATA_FLOW_TYPE_DORMANT = 4 254 }; 255 256 /** 257 * @brief Indicates SIM card lock type. 258 */ 259 enum class TelephonyLockReason { 260 /** 261 * Indicates no SIM lock. 262 */ 263 SIM_NONE, 264 /** 265 * Indicates the PIN lock. 266 */ 267 SIM_PIN, 268 /** 269 * Indicates the PUK lock. 270 */ 271 SIM_PUK, 272 /** 273 * Indicates network personalization of PIN lock(refer 3GPP TS 22.022 [33]). 274 */ 275 SIM_PN_PIN, 276 /** 277 * Indicates network personalization of PUK lock(refer 3GPP TS 22.022 [33]). 278 */ 279 SIM_PN_PUK, 280 /** 281 * Indicates network subset personalization of PIN lock(refer 3GPP TS 22.022 [33]). 282 */ 283 SIM_PU_PIN, 284 /** 285 * Indicates network subset personalization of PUK lock(refer 3GPP TS 22.022 [33]). 286 */ 287 SIM_PU_PUK, 288 /** 289 * Indicates service provider personalization of PIN lock(refer 3GPP TS 22.022 [33]). 290 */ 291 SIM_PP_PIN, 292 /** 293 * Indicates service provider personalization of PUK lock(refer 3GPP TS 22.022 [33]). 294 */ 295 SIM_PP_PUK, 296 /** 297 * Indicates corporate personalization of PIN lock(refer 3GPP TS 22.022 [33]). 298 */ 299 SIM_PC_PIN, 300 /** 301 * Indicates corporate personalization of PUK lock(refer 3GPP TS 22.022 [33]). 302 */ 303 SIM_PC_PUK, 304 /** 305 * Indicates SIM/USIM personalization of PIN lock(refer 3GPP TS 22.022 [33]). 306 */ 307 SIM_SIM_PIN, 308 /** 309 * Indicates SIM/USIM personalization of PUK lock(refer 3GPP TS 22.022 [33]). 310 */ 311 SIM_SIM_PUK, 312 }; 313 314 /** 315 * @brief Indicates the reg service states. 316 */ 317 enum class TelephonyRegServiceState { 318 REG_STATE_UNKNOWN, 319 REG_STATE_IN_SERVICE, 320 REG_STATE_NO_SERVICE, 321 REG_STATE_EMERGENCY_ONLY, 322 REG_STATE_SEARCH, 323 REG_STATE_POWER_OFF 324 }; 325 326 /** 327 * @brief Indicates the ril register states. 328 */ 329 enum class TelephonyRilRegisterState { 330 REG_STATE_NOT_REG = 0, 331 REG_STATE_HOME_ONLY = 1, 332 REG_STATE_SEARCH = 2, 333 REG_STATE_NO_SERVICE = 3, 334 REG_STATE_INVALID = 4, 335 REG_STATE_ROAMING = 5, 336 REG_STATE_EMERGENCY_ONLY = 6 337 }; 338 339 /** 340 * @brief Indicates the sim Icc state. 341 */ 342 enum class TelephonySimIccState { 343 ICC_CONTENT_UNKNOWN = -1, 344 ICC_CARD_ABSENT, 345 ICC_CONTENT_READY, 346 ICC_CONTENT_PIN, 347 ICC_CONTENT_PUK 348 }; 349 350 const std::map<int32_t, std::string> simIccStatusMap_ = { 351 { static_cast<int32_t>(TelephonySimIccState::ICC_CONTENT_UNKNOWN), "ICC_CONTENT_UNKNOWN" }, 352 { static_cast<int32_t>(TelephonySimIccState::ICC_CARD_ABSENT), "ICC_CARD_ABSENT" }, 353 { static_cast<int32_t>(TelephonySimIccState::ICC_CONTENT_READY), "ICC_CONTENT_READY" }, 354 { static_cast<int32_t>(TelephonySimIccState::ICC_CONTENT_PIN), "ICC_CONTENT_PIN" }, 355 { static_cast<int32_t>(TelephonySimIccState::ICC_CONTENT_PUK), "ICC_CONTENT_PUK" }, 356 }; 357 358 const std::map<int32_t, std::string> regServiceStateMap_ = { 359 { static_cast<int32_t>(TelephonyRegServiceState::REG_STATE_UNKNOWN), "REG_STATE_UNKNOWN" }, 360 { static_cast<int32_t>(TelephonyRegServiceState::REG_STATE_IN_SERVICE), "REG_STATE_IN_SERVICE" }, 361 { static_cast<int32_t>(TelephonyRegServiceState::REG_STATE_NO_SERVICE), "REG_STATE_NO_SERVICE" }, 362 { static_cast<int32_t>(TelephonyRegServiceState::REG_STATE_EMERGENCY_ONLY), "REG_STATE_EMERGENCY_ONLY" }, 363 { static_cast<int32_t>(TelephonyRegServiceState::REG_STATE_SEARCH), "REG_STATE_SEARCH" }, 364 { static_cast<int32_t>(TelephonyRegServiceState::REG_STATE_POWER_OFF), "REG_STATE_POWER_OFF" }, 365 }; 366 367 const std::map<int32_t, std::string> rilRegisterStateMap_ = { 368 { static_cast<int32_t>(TelephonyRilRegisterState::REG_STATE_NOT_REG), "REG_STATE_NOT_REG" }, 369 { static_cast<int32_t>(TelephonyRilRegisterState::REG_STATE_HOME_ONLY), "REG_STATE_HOME_ONLY" }, 370 { static_cast<int32_t>(TelephonyRilRegisterState::REG_STATE_SEARCH), "REG_STATE_SEARCH" }, 371 { static_cast<int32_t>(TelephonyRilRegisterState::REG_STATE_NO_SERVICE), "REG_STATE_NO_SERVICE" }, 372 { static_cast<int32_t>(TelephonyRilRegisterState::REG_STATE_INVALID), "REG_STATE_INVALID" }, 373 { static_cast<int32_t>(TelephonyRilRegisterState::REG_STATE_ROAMING), "REG_STATE_ROAMING" }, 374 { static_cast<int32_t>(TelephonyRilRegisterState::REG_STATE_EMERGENCY_ONLY), "REG_STATE_EMERGENCY_ONLY" }, 375 }; 376 377 /** 378 * @brief Get the string of bool value. 379 * 380 * @param value 381 * @return Return "FALSE" if the value is {@code 0}, return "TRUE" otherwise. 382 */ 383 std::string GetBoolValue(int32_t value); 384 385 /** 386 * @brief Get the string of SIM state. 387 * 388 * @param state Indicates the state of SIM. 389 * @return Return the string of SIM state. 390 */ 391 std::string GetSimState(int32_t state); 392 393 /** 394 * @brief Get the string of call state. 395 * 396 * @param state Indicates the state of call. 397 * @return Return the string of call state. 398 */ 399 std::string GetCallState(int32_t state); 400 401 /** 402 * @brief Get the string of SIM card type. 403 * 404 * @param type Indicates the type of SIM card. 405 * @return Return the string of SIM card type. 406 */ 407 std::string GetCardType(int32_t type); 408 409 /** 410 * @brief Get the string of cellular data connection state. 411 * 412 * @param state Indicates the state of cellular data connection. 413 * @return Return the string of cellular data connection state. 414 */ 415 std::string GetCellularDataConnectionState(int32_t state); 416 417 /** 418 * @brief Get the string of cellular data flow type. 419 * 420 * @param flowData Indicates the cellular data flow type. 421 * @return Return the string of cellular data flow type. 422 */ 423 std::string GetCellularDataFlow(int32_t flowData); 424 425 /** 426 * @brief Get the string of radio access technology for cellular data. 427 * 428 * @param type Indicates the radio access technology. 429 * @return Return the string of radio access technology. 430 */ 431 std::string GetCellularDataConnectionNetworkType(int32_t type); 432 433 /** 434 * @brief Get the string of SIM lock reason. 435 * 436 * @param reason Indicates the the SIM lock reason. 437 * @return Return the string of SIM lock reason. 438 */ 439 std::string GetLockReason(int32_t reason); 440 } // namespace Telephony 441 } // namespace OHOS 442 443 #endif // ENUM_CONVERT_H 444