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