1 /* 2 * Copyright (C) 2022 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 TELEPHONY_HISYSEVENT_H 17 #define TELEPHONY_HISYSEVENT_H 18 19 #include <string> 20 21 #include "hisysevent.h" 22 23 namespace OHOS { 24 namespace Telephony { 25 using EventType = OHOS::HiviewDFX::HiSysEvent::EventType; 26 static constexpr const char *DOMAIN_NAME = OHOS::HiviewDFX::HiSysEvent::Domain::TELEPHONY; 27 static const int32_t INVALID_PARAMETER = -1; 28 29 /** 30 * @brief Indicates the error code of call. 31 */ 32 enum class CallErrorCode { 33 /** 34 * Indicates no error. 35 */ 36 CALL_ERROR_NONE = 0, 37 38 /** 39 * Indicates the permission error. 40 */ 41 CALL_ERROR_PERMISSION_ERR = 1, 42 43 /** 44 * Indicates the phone number is empty. 45 */ 46 CALL_ERROR_PHONE_NUMBER_EMPTY, 47 48 /** 49 * Indicates the phone number is out of range. 50 */ 51 CALL_ERROR_NUMBER_OUT_OF_RANGE, 52 53 /** 54 * Indicates the ptr is null. 55 */ 56 CALL_ERROR_CALL_LOCAL_PTR_NULL, 57 58 /** 59 * Indicates the dial type is unknown, out of CARRIER, VOICE_MAIL or OTT type. 60 */ 61 CALL_ERROR_UNKNOW_DIAL_TYPE, 62 63 /** 64 * Indicates the slot id is invalid. 65 */ 66 CALL_ERROR_INVALID_SLOT_ID, 67 68 /** 69 * Indicates the call type is unknown, out of CS, IMS or OTT type. 70 */ 71 CALL_ERROR_UNKNOW_CALL_TYPE, 72 73 /** 74 * Indicates the dial scene is invalid. 75 */ 76 CALL_ERROR_INVALID_DIAL_SCENE, 77 78 /** 79 * Indicates the video state is invalid. 80 */ 81 CALL_ERROR_INVALID_VIDEO_STATE, 82 83 /** 84 * Indicates the call id is valid. 85 */ 86 CALL_ERROR_INVALID_CALLID, 87 88 /** 89 * Indicates the dial is busy, there is already a new call creating/connecting or dialing. 90 */ 91 CALL_ERROR_DIAL_IS_BUSY = 11, 92 93 /** 94 * Indicates the dial time is out of range. 95 */ 96 CALL_ERROR_DIAL_TIME_OUT, 97 98 /** 99 * Indicates the incoming time is out of range. 100 */ 101 CALL_ERROR_INCOMING_TIME_OUT, 102 103 /** 104 * Indicates the answer time is out of range. 105 */ 106 CALL_ERROR_ANSWER_TIME_OUT, 107 108 /** 109 * Indicates failed to send the event handle. 110 */ 111 CALL_ERROR_SYSTEM_EVENT_HANDLE_FAILURE, 112 113 /** 114 * Indicates the dial number is not a valid FDN number. 115 */ 116 CALL_ERROR_INVALID_FDN_NUMBER, 117 118 /** 119 * Indicates the device is not dialing. 120 */ 121 CALL_ERROR_DEVICE_NOT_DIALING, 122 123 /** 124 * Indicates memset failed. 125 */ 126 CALL_ERROR_MEMSET_FAIL, 127 128 /** 129 * Indicates memcpy failed. 130 */ 131 CALL_ERROR_MEMCPY_FAIL, 132 133 /** 134 * Indicates IPC connect stub failed. 135 */ 136 CALL_ERROR_IPC_CONNECT_STUB_FAIL, 137 138 /** 139 * Indicates IPC write descriptor token failed. 140 */ 141 CALL_ERROR_IPC_WRITE_DESCRIPTOR_TOKEN_FAIL = 21, 142 143 /** 144 * Indicates IPC write data failed. 145 */ 146 CALL_ERROR_IPC_WRITE_DATA_FAIL, 147 148 /** 149 * Indicates IPC send request failed. 150 */ 151 CALL_ERROR_IPC_SEND_REQUEST_FAIL, 152 153 /** 154 * Indicates call operation is illegal. 155 */ 156 CALL_ERROR_ILLEGAL_CALL_OPERATION, 157 158 /** 159 * Indicates notify call state failed. 160 */ 161 CALL_ERROR_PHONE_CALLSTATE_NOTIFY_FAILED, 162 163 /** 164 * Indicates the call already exists. 165 */ 166 CALL_ERROR_CALL_ALREADY_EXISTS, 167 168 /** 169 * Indicates the network type is unsupported. 170 */ 171 CALL_ERROR_UNSUPPORTED_NETWORK_TYPE, 172 173 /** 174 * Indicates create request failed. 175 */ 176 CALL_ERROR_CREATE_REQUEST_FAIL, 177 178 /** 179 * Indicates send request failed. 180 */ 181 CALL_ERROR_SEND_REQUEST_FAIL, 182 183 /** 184 * Indicates call object is null. 185 */ 186 CALL_ERROR_CALL_OBJECT_IS_NULL, 187 188 /** 189 * Indicates the state of SRVCC is unexpecred. 190 */ 191 CALL_ERROR_UNEXPECTED_SRVCC_STATE = 31, 192 193 /** 194 * Indicates the counts of call exceed limit. 195 */ 196 CALL_ERROR_CALL_COUNTS_EXCEED_LIMIT, 197 198 /** 199 * Indicates get radio state failed. 200 */ 201 CALL_ERROR_GET_RADIO_STATE_FAILED, 202 203 /** 204 * Indicates the resource is unavailable. 205 */ 206 CALL_ERROR_RESOURCE_UNAVAILABLE, 207 208 /** 209 * Indicates the call connection does not exist. 210 */ 211 CALL_ERROR_CALL_CONNECTION_NOT_EXIST, 212 213 /** 214 * Indicates the argument is invalid. 215 */ 216 CALL_ERROR_ARGUMENT_INVALID, 217 218 /** 219 * Indicates IMS service does not exist. 220 */ 221 CALL_ERROR_IMS_SERVICE_NOT_EXIST, 222 223 /** 224 * Indicates the radio response info is error. 225 */ 226 CALL_ERROR_RADIO_RESPONSEINFO_ERROR, 227 }; 228 229 /** 230 * @brief Indicates the error code of SmsMms. 231 */ 232 enum class SmsMmsErrorCode { 233 /** 234 * Indicates the permission error. 235 */ 236 SMS_ERROR_PERMISSION_ERROR = 100, 237 238 /** 239 * Indicates the pointer is null. 240 */ 241 SMS_ERROR_NULL_POINTER, 242 243 /** 244 * Indicates the input parameter is empty. 245 */ 246 SMS_ERROR_EMPTY_INPUT_PARAMETER, 247 248 /** 249 * Indicates the network type is unknown. 250 */ 251 SMS_ERROR_UNKNOWN_NETWORK_TYPE, 252 253 /** 254 * Indicates the PDU encoding failed. 255 */ 256 SMS_ERROR_PDU_ENCODEING_FAIL, 257 258 /** 259 * Indicates the message segment exceed the limit. 260 */ 261 SMS_ERROR_EXCEED_MAX_SEGMENT_NUM, 262 263 /** 264 * Indicates send sms when device is not in service. 265 */ 266 SMS_ERROR_SENDSMS_NOT_IN_SERVICE, 267 268 /** 269 * Indicates unsupport SMS capability. 270 */ 271 SMS_ERROR_SMS_CAPABLE_UNSUPPORTED, 272 273 /** 274 * Indicates add message to database failed. 275 */ 276 SMS_ERROR_ADD_TO_DATABASE_FAIL, 277 278 /** 279 * Indicates the message repeated. 280 */ 281 SMS_ERROR_REPEATED_ERROR, 282 283 /** 284 * Indicates publish common event failed. 285 */ 286 SMS_ERROR_PUBLISH_COMMON_EVENT_FAIL, 287 288 /** 289 * Indicates decode PDU failed. 290 */ 291 SMS_ERROR_PDU_DECODE_FAIL, 292 293 /** 294 * Indicates publish cell broadcast event failed. 295 */ 296 SMS_ERROR_CELL_BROADCAST_PUD_ANALYSIS_FAIL, 297 298 /** 299 * Indicates create request failed. 300 */ 301 SMS_ERROR_CREATE_REQUEST_FAIL, 302 303 /** 304 * Indicates send request failed. 305 */ 306 SMS_ERROR_SEND_REQUEST_FAIL, 307 308 /** 309 * Indicates read message failed. 310 */ 311 SMS_ERROR_MESSAGE_READ_FAIL, 312 313 /** 314 * Indicates the time of sms broadcast out of range. 315 */ 316 SMS_ERROR_BROADCAST_TIME_OUT, 317 }; 318 319 /** 320 * @brief Indicates the error code of cellular data. 321 */ 322 enum class CellularDataErrorCode { 323 /** 324 * Indicates permission error. 325 */ 326 DATA_ERROR_PERMISSION_ERROR = 200, 327 328 /** 329 * Indicates write database failed. 330 */ 331 DATA_ERROR_DATABASE_WRITE_ERROR, 332 333 /** 334 * Indicates the PS is not registered . 335 */ 336 DATA_ERROR_PS_NOT_ATTACH, 337 338 /** 339 * Indicates the SIM is not ready. 340 */ 341 DATA_ERROR_SIM_NOT_READY, 342 343 /** 344 * Indicates the solt try to establish data connection is not the default data cellular slot. 345 */ 346 DATA_ERROR_CELLULAR_DATA_SLOT_ID_MISMATCH, 347 348 /** 349 * Indicates the data roaming switch is OFF but current PS is roaming. 350 */ 351 DATA_ERROR_ROAMING_SWITCH_OFF_AND_ROAMING, 352 353 /** 354 * Indicates call and data is not concurrency. 355 */ 356 DATA_ERROR_CALL_AND_DATA_NOT_CONCURRENCY, 357 358 /** 359 * Indicates there is higher priority connection. 360 */ 361 DATA_ERROR_HAS_HIGHER_PRIORITY_CONNECTION, 362 363 /** 364 * Indicates activate PDP context failed. 365 */ 366 DATA_ERROR_PDP_ACTIVATE_FAIL, 367 368 /** 369 * Indicates deactive PDP context failed. 370 */ 371 DATA_ERROR_PDP_DEACTIVATE_FAIL, 372 373 /** 374 * Indicates active PDP context overtime. 375 */ 376 DATA_ERROR_DATA_ACTIVATE_TIME_OUT, 377 378 /** 379 * Indicates radio response info error. 380 */ 381 DATA_ERROR_RADIO_RESPONSEINFO_ERROR, 382 }; 383 384 class TelephonyHiSysEvent { 385 public: 386 template<typename... Types> HiWriteBehaviorEvent(const std::string & eventName,Types...args)387 static void HiWriteBehaviorEvent(const std::string &eventName, Types... args) 388 { 389 HiSysEventWrite(DOMAIN_NAME, eventName, EventType::BEHAVIOR, args...); 390 } 391 392 template<typename... Types> HiWriteFaultEvent(const std::string & eventName,Types...args)393 static void HiWriteFaultEvent(const std::string &eventName, Types... args) 394 { 395 HiSysEventWrite(DOMAIN_NAME, eventName, EventType::FAULT, args...); 396 } 397 }; 398 } // namespace Telephony 399 } // namespace OHOS 400 #endif // TELEPHONY_HISYSEVENT_H 401