1 /* 2 * Copyright (C) 2023 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 CALL_MANAGER_BASE_H 17 #define CALL_MANAGER_BASE_H 18 19 #include <algorithm> 20 #include <cstdio> 21 #include <ctime> 22 #include <string> 23 #include <vector> 24 25 namespace OHOS { 26 namespace Telephony { 27 /** 28 * @brief Indicates Maximum length of a string. 29 */ 30 constexpr int16_t kMaxNumberLen = 255; 31 /** 32 * @brief Indicates Maximum length of a bundle name. 33 */ 34 constexpr int16_t kMaxBundleNameLen = 100; 35 /** 36 * @brief Indicates Maximum length of a address. 37 */ 38 constexpr int16_t kMaxAddressLen = 225; 39 /** 40 * @brief Indicates Maximum length of a MMI code message. 41 */ 42 constexpr int16_t kMaxMessageLen = 500; 43 /** 44 * @brief Indicates Maximum length of the reject call message. 45 */ 46 constexpr uint16_t REJECT_CALL_MSG_MAX_LEN = 300; 47 /** 48 * @brief Indicates Maximum length of the account number. 49 */ 50 constexpr uint16_t ACCOUNT_NUMBER_MAX_LENGTH = 255; 51 /** 52 * @brief Indicates Maximum duration(ms) when connect service. 53 */ 54 constexpr uint16_t CONNECT_SERVICE_WAIT_TIME = 1000; 55 /** 56 * @brief Indicates the main call id is invalid. 57 */ 58 constexpr int16_t ERR_ID = -1; 59 /** 60 * @brief Indicates the call id is invalid. 61 */ 62 constexpr int16_t INVALID_CALLID = 0; 63 /** 64 * @brief Indicates one second duration. 65 */ 66 constexpr int16_t WAIT_TIME_ONE_SECOND = 1; 67 /** 68 * @brief Indicates No Call Exist. 69 */ 70 constexpr int16_t NO_CALL_EXIST = 0; 71 /** 72 * @brief Indicates One Call Exist. 73 */ 74 constexpr int16_t ONE_CALL_EXIST = 1; 75 /** 76 * @brief The follow hour and minute was use to confirm the set 77 * call transfer beginning and ending time restriction. 78 * 79 * MIN_HOUR: the minimum hour value. 80 * MAX_HOUR: the maximum hour value. 81 * MIN_MINUTE: the minimum minute value. 82 * MAX_MINUTE: the maximum minute value. 83 * INVALID_TIME: the time value is invalid. 84 */ 85 constexpr int16_t MIN_HOUR = 0; 86 constexpr int16_t MAX_HOUR = 24; 87 constexpr int16_t MIN_MINUTE = 0; 88 constexpr int16_t MAX_MINUTE = 60; 89 constexpr int16_t INVALID_TIME = -1; 90 91 /** 92 * @brief Indicates the type of call, includs CS, IMS, OTT, OTHER. 93 */ 94 enum class CallType { 95 /** 96 * Indicates the call type is CS. 97 */ 98 TYPE_CS = 0, 99 /** 100 * Indicates the call type is IMS. 101 */ 102 TYPE_IMS = 1, 103 /** 104 * Indicates the call type is OTT. 105 */ 106 TYPE_OTT = 2, 107 /** 108 * Indicates the call type is OTHER. 109 */ 110 TYPE_ERR_CALL = 3, 111 /** 112 * Indicates the call type is VoIP. 113 */ 114 TYPE_VOIP = 4, 115 /** 116 * Indicates the call type is SATELLITE. 117 */ 118 TYPE_SATELLITE = 5, 119 }; 120 121 /** 122 * @brief Indicates the detailed state of call. 123 */ 124 enum class TelCallState { 125 /** 126 * Indicates the call is unknown. 127 */ 128 CALL_STATUS_UNKNOWN = -1, 129 /** 130 * Indicates the call is active. 131 */ 132 CALL_STATUS_ACTIVE = 0, 133 /** 134 * Indicates the call is holding. 135 */ 136 CALL_STATUS_HOLDING, 137 /** 138 * Indicates the call is dialing. 139 */ 140 CALL_STATUS_DIALING, 141 /** 142 * Indicates the call is alerting. 143 */ 144 CALL_STATUS_ALERTING, 145 /** 146 * Indicates the call is incoming. 147 */ 148 CALL_STATUS_INCOMING, 149 /** 150 * Indicates the call is waiting. 151 */ 152 CALL_STATUS_WAITING, 153 /** 154 * Indicates the call is disconnected. 155 */ 156 CALL_STATUS_DISCONNECTED, 157 /** 158 * Indicates the call is disconnecting. 159 */ 160 CALL_STATUS_DISCONNECTING, 161 /** 162 * Indicates the call is idle. 163 */ 164 CALL_STATUS_IDLE, 165 /** 166 * Indicates the call is answered. 167 */ 168 CALL_STATUS_ANSWERED, 169 }; 170 171 /** 172 * @brief Indicates the state of conference call. 173 */ 174 enum class TelConferenceState { 175 /** 176 * Indicates the state is idle. 177 */ 178 TEL_CONFERENCE_IDLE = 0, 179 /** 180 * Indicates the state is active. 181 */ 182 TEL_CONFERENCE_ACTIVE, 183 /** 184 * Indicates the state is hold. 185 */ 186 TEL_CONFERENCE_HOLDING, 187 /** 188 * Indicates the state is disconnecting. 189 */ 190 TEL_CONFERENCE_DISCONNECTING, 191 /** 192 * Indicates the state is disconnected. 193 */ 194 TEL_CONFERENCE_DISCONNECTED, 195 }; 196 197 /** 198 * @brief Indicates the Network type. 199 */ 200 enum class PhoneNetType { 201 /** 202 * Indicates the Network type is GSM. 203 */ 204 PHONE_TYPE_GSM = 1, 205 /** 206 * Indicates the Network type is CDMA. 207 */ 208 PHONE_TYPE_CDMA = 2, 209 }; 210 211 /** 212 * @brief Indicates the type of video state. 213 */ 214 enum class VideoStateType { 215 /** 216 * Indicates the call is in voice state. 217 */ 218 TYPE_VOICE = 0, 219 /** 220 * Indicates the call is in send only state. 221 */ 222 TYPE_SEND_ONLY, 223 /** 224 * Indicates the call is in send only state. 225 */ 226 TYPE_RECEIVE_ONLY, 227 /** 228 * Indicates the call is in video state. 229 */ 230 TYPE_VIDEO, 231 }; 232 233 /** 234 * @brief Indicates the scenarios of the call to be made. 235 */ 236 enum class DialScene { 237 /** 238 * Indicates this is a common call. 239 */ 240 CALL_NORMAL = 0, 241 /** 242 * Indicates this is a privileged call. 243 */ 244 CALL_PRIVILEGED, 245 /** 246 * Indicates this is an emergency call. 247 */ 248 CALL_EMERGENCY, 249 }; 250 251 /** 252 * @brief Indicates the call is MO or MT. 253 */ 254 enum class CallDirection { 255 /** 256 * Indicates the call is a incoming call. 257 */ 258 CALL_DIRECTION_IN = 0, 259 /** 260 * Indicates the call is a outgoing call. 261 */ 262 CALL_DIRECTION_OUT, 263 /** 264 * Indicates the call is unknown. 265 */ 266 CALL_DIRECTION_UNKNOW, 267 }; 268 269 /** 270 * @brief Indicates the call state in progress. 271 */ 272 enum class CallRunningState { 273 /** 274 * Indicates to create a new call session. 275 */ 276 CALL_RUNNING_STATE_CREATE = 0, 277 /** 278 * Indicates the call state is in connecting. 279 */ 280 CALL_RUNNING_STATE_CONNECTING, 281 /** 282 * Indicates the call state is in dialing. 283 */ 284 CALL_RUNNING_STATE_DIALING, 285 /** 286 * Indicates the call state is in ringing. 287 */ 288 CALL_RUNNING_STATE_RINGING, 289 /** 290 * Indicates the call state is in active. 291 */ 292 CALL_RUNNING_STATE_ACTIVE, 293 /** 294 * Indicates the call state is in hold. 295 */ 296 CALL_RUNNING_STATE_HOLD, 297 /** 298 * Indicates the call state is ended. 299 */ 300 CALL_RUNNING_STATE_ENDED, 301 /** 302 * Indicates the call state is in ending. 303 */ 304 CALL_RUNNING_STATE_ENDING, 305 }; 306 307 /** 308 * @brief Indicates the cause of the ended call. 309 */ 310 enum class CallEndedType { 311 /** 312 * Indicates the cause is unknown. 313 */ 314 UNKNOWN = 0, 315 /** 316 * Indicates the cause is phone busy. 317 */ 318 PHONE_IS_BUSY, 319 /** 320 * Indicates the cause is invalid phone number. 321 */ 322 INVALID_NUMBER, 323 /** 324 * Indicates the call is ended normally. 325 */ 326 CALL_ENDED_NORMALLY, 327 }; 328 329 /** 330 * @brief Indicates the information of SIM card. 331 */ 332 struct SIMCardInfo { 333 /** 334 * Indicates the SIM ICC id. 335 */ 336 int32_t simId = 0; 337 /** 338 * Indicated the country to which the SIM card belongs. 339 */ 340 int32_t country = 0; 341 /** 342 * Indicates wether the SIM card is active. 343 */ 344 int32_t state = 0; 345 /** 346 * Indicates the Network type. 347 */ 348 PhoneNetType phoneNetType = PhoneNetType::PHONE_TYPE_GSM; 349 }; 350 351 /** 352 * @brief Indicates the dialing call type. 353 */ 354 enum class DialType { 355 /** 356 * Indicates the dialing call type is normal cellular call. 357 */ 358 DIAL_CARRIER_TYPE = 0, 359 /** 360 * Indicates the dialing call type is voice mail. 361 */ 362 DIAL_VOICE_MAIL_TYPE, 363 /** 364 * Indicates the dialing call type is OTT. 365 */ 366 DIAL_OTT_TYPE, 367 }; 368 369 /** 370 * @brief Indicates the call state which will report to APP. 371 */ 372 enum class CallStateToApp { 373 /** 374 * Indicates an invalid state, which is used when the call state 375 * fails to be obtained. 376 */ 377 CALL_STATE_UNKNOWN = -1, 378 379 /** 380 * Indicates that there is no ongoing call. 381 */ 382 CALL_STATE_IDLE = 0, 383 384 /** 385 * Indicates that an incoming call is ringing or waiting. 386 */ 387 CALL_STATE_RINGING = 1, 388 389 /** 390 * Indicates that a least one call is in the dialing, active, or hold 391 * state, and there is no new incoming call ringing or waiting. 392 */ 393 CALL_STATE_OFFHOOK = 2, 394 395 CALL_STATE_ANSWERED = 3 396 }; 397 398 /** 399 * @brief Indicates the cause when the call is answered. 400 */ 401 enum class CallAnswerType { 402 /** 403 * Indicates the call answer is call missed. 404 */ 405 CALL_ANSWER_MISSED = 0, 406 /** 407 * Indicates the call answer is call active. 408 */ 409 CALL_ANSWER_ACTIVED, 410 /** 411 * Indicates the call answer is call rejected. 412 */ 413 CALL_ANSWER_REJECT, 414 }; 415 416 /** 417 * @brief Indicates the event ID of call ability. 418 */ 419 enum class CallAbilityEventId { 420 /** 421 * Indicates that there is no available carrier during dialing. 422 */ 423 EVENT_DIAL_NO_CARRIER = 1, 424 /** 425 * Indicates that FDN is invalid. 426 */ 427 EVENT_INVALID_FDN_NUMBER, 428 /** 429 * Indicates hold call fail. 430 */ 431 EVENT_HOLD_CALL_FAILED, 432 /** 433 * Indicates swap call fail. 434 */ 435 EVENT_SWAP_CALL_FAILED, 436 /** 437 * Indicates that the combine call failed. 438 */ 439 EVENT_COMBINE_CALL_FAILED, 440 /** 441 * Indicates that the split call failed. 442 */ 443 EVENT_SPLIT_CALL_FAILED, 444 /** 445 * Indicates that the OTT is not supported. 446 */ 447 EVENT_OTT_FUNCTION_UNSUPPORTED, 448 }; 449 450 /** 451 * @brief Indicates the event ID of call ability. 452 */ 453 enum class CallSessionEventId { 454 /** 455 * Indicates the camera event failure type. 456 */ 457 EVENT_CAMERA_FAILURE = 0, 458 /** 459 * Indicates the camera event ready type. 460 */ 461 EVENT_CAMERA_READY, 462 /** 463 * Indicates the display surface release type. 464 */ 465 EVENT_RELEASE_DISPLAY_SURFACE = 100, 466 /** 467 * Indicates the preview surface release type. 468 */ 469 EVENT_RELEASE_PREVIEW_SURFACE, 470 }; 471 472 /** 473 * @brief Indicates the type of device direction. 474 */ 475 enum DeviceDirection { 476 /** 477 * Indicates the device direction is 0 degree. 478 */ 479 DEVICE_DIRECTION_0 = 0, 480 /** 481 * Indicates the device direction is 90 degree. 482 */ 483 DEVICE_DIRECTION_90 = 90, 484 /** 485 * Indicates the device direction is 180 degree. 486 */ 487 DEVICE_DIRECTION_180 = 180, 488 /** 489 * Indicates the device direction is 270 degree. 490 */ 491 DEVICE_DIRECTION_270 = 270, 492 }; 493 494 /** 495 * @brief Indicates the what the Audio device type is used. 496 */ 497 enum class AudioDeviceType { 498 /** 499 * Indicates the device type is a earphone speaker. 500 */ 501 DEVICE_EARPIECE = 0, 502 /** 503 * Indicates the device type is the speaker system (i.e. a mono speaker or 504 * stereo speakers) built in a device. 505 */ 506 DEVICE_SPEAKER, 507 /** 508 * Indicates the device type is a headset, which is the combination of a 509 * headphones and microphone. 510 */ 511 DEVICE_WIRED_HEADSET, 512 /** 513 * Indicates the device type is a Bluetooth device typically used for 514 * telephony. 515 */ 516 DEVICE_BLUETOOTH_SCO, 517 /** 518 * Indicates the audio device is disabled. 519 */ 520 DEVICE_DISABLE, 521 /** 522 * Indicates the device type is an unknown or uninitialized. 523 */ 524 DEVICE_UNKNOWN, 525 /** 526 * Indicates the device type is a distributed car device. 527 */ 528 DEVICE_DISTRIBUTED_AUTOMOTIVE, 529 /** 530 * Indicates the device type is a distributed phone device. 531 */ 532 DEVICE_DISTRIBUTED_PHONE, 533 /** 534 * Indicates the device type is a distributed pad device. 535 */ 536 DEVICE_DISTRIBUTED_PAD, 537 }; 538 539 /** 540 * @brief Indicates the call event type. 541 */ 542 enum class CellularCallEventType { 543 EVENT_REQUEST_RESULT_TYPE = 0, 544 }; 545 546 /** 547 * @brief Indicates the call event id, one id corresponds to one request. 548 */ 549 enum class RequestResultEventId { 550 INVALID_REQUEST_RESULT_EVENT_ID = -1, 551 RESULT_DIAL_SEND_FAILED = 0, 552 RESULT_DIAL_NO_CARRIER, 553 RESULT_END_SEND_FAILED, 554 RESULT_REJECT_SEND_FAILED, 555 RESULT_ACCEPT_SEND_FAILED, 556 RESULT_HOLD_SEND_FAILED, 557 RESULT_ACTIVE_SEND_FAILED, 558 RESULT_SWAP_SEND_FAILED, 559 RESULT_COMBINE_SEND_FAILED, 560 RESULT_JOIN_SEND_FAILED, 561 RESULT_SPLIT_SEND_FAILED, 562 RESULT_SUPPLEMENT_SEND_FAILED, 563 RESULT_INVITE_TO_CONFERENCE_SUCCESS, 564 RESULT_INVITE_TO_CONFERENCE_FAILED, 565 RESULT_KICK_OUT_FROM_CONFERENCE_SUCCESS, 566 RESULT_KICK_OUT_FROM_CONFERENCE_FAILED, 567 568 RESULT_SEND_DTMF_SUCCESS, 569 RESULT_SEND_DTMF_FAILED, 570 571 RESULT_GET_CURRENT_CALLS_FAILED, 572 573 RESULT_SET_CALL_PREFERENCE_MODE_SUCCESS, 574 RESULT_SET_CALL_PREFERENCE_MODE_FAILED, 575 RESULT_GET_IMS_CALLS_DATA_FAILED, 576 577 RESULT_GET_CALL_WAITING_SUCCESS, 578 RESULT_GET_CALL_WAITING_FAILED, 579 RESULT_SET_CALL_WAITING_SUCCESS, 580 RESULT_SET_CALL_WAITING_FAILED, 581 RESULT_GET_CALL_RESTRICTION_SUCCESS, 582 RESULT_GET_CALL_RESTRICTION_FAILED, 583 RESULT_SET_CALL_RESTRICTION_SUCCESS, 584 RESULT_SET_CALL_RESTRICTION_FAILED, 585 RESULT_GET_CALL_TRANSFER_SUCCESS, 586 RESULT_GET_CALL_TRANSFER_FAILED, 587 RESULT_SET_CALL_TRANSFER_SUCCESS, 588 RESULT_SET_CALL_TRANSFER_FAILED, 589 RESULT_SEND_USSD_SUCCESS, 590 RESULT_SEND_USSD_FAILED, 591 592 RESULT_SET_MUTE_SUCCESS, 593 RESULT_SET_MUTE_FAILED, 594 595 RESULT_CTRL_CAMERA_SUCCESS, 596 RESULT_CTRL_CAMERA_FAILED, 597 RESULT_SET_PREVIEW_WINDOW_SUCCESS, 598 RESULT_SET_PREVIEW_WINDOW_FAILED, 599 RESULT_SET_DISPLAY_WINDOW_SUCCESS, 600 RESULT_SET_DISPLAY_WINDOW_FAILED, 601 RESULT_SET_CAMERA_ZOOM_SUCCESS, 602 RESULT_SET_CAMERA_ZOOM_FAILED, 603 RESULT_SET_PAUSE_IMAGE_SUCCESS, 604 RESULT_SET_PAUSE_IMAGE_FAILED, 605 RESULT_SET_DEVICE_DIRECTION_SUCCESS, 606 RESULT_SET_DEVICE_DIRECTION_FAILED, 607 }; 608 609 /** 610 * @brief Indicates the call result report id in callback, 611 * one id corresponds to one request. 612 */ 613 enum class CallResultReportId { 614 START_DTMF_REPORT_ID = 0, 615 STOP_DTMF_REPORT_ID, 616 SEND_USSD_REPORT_ID, 617 GET_IMS_CALL_DATA_REPORT_ID, 618 GET_CALL_WAITING_REPORT_ID, 619 SET_CALL_WAITING_REPORT_ID, 620 GET_CALL_RESTRICTION_REPORT_ID, 621 SET_CALL_RESTRICTION_REPORT_ID, 622 GET_CALL_TRANSFER_REPORT_ID, 623 SET_CALL_TRANSFER_REPORT_ID, 624 GET_CALL_CLIP_ID, 625 GET_CALL_CLIR_ID, 626 SET_CALL_CLIR_ID, 627 START_RTT_REPORT_ID, 628 STOP_RTT_REPORT_ID, 629 GET_IMS_CONFIG_REPORT_ID, 630 SET_IMS_CONFIG_REPORT_ID, 631 GET_IMS_FEATURE_VALUE_REPORT_ID, 632 SET_IMS_FEATURE_VALUE_REPORT_ID, 633 INVITE_TO_CONFERENCE_REPORT_ID, 634 UPDATE_MEDIA_MODE_REPORT_ID, 635 CLOSE_UNFINISHED_USSD_REPORT_ID, 636 SET_CALL_RESTRICTION_PWD_REPORT_ID, 637 }; 638 } // namespace Telephony 639 } // namespace OHOS 640 #endif // CALL_MANAGER_BASE_H