1 /* 2 * Copyright (C) 2021-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 CALL_MANAGER_CLIENT_H 17 #define CALL_MANAGER_CLIENT_H 18 19 #include "singleton.h" 20 #include "pac_map.h" 21 22 #include "call_manager_callback.h" 23 #include "i_call_status_callback.h" 24 25 namespace OHOS { 26 namespace Telephony { 27 class CallManagerClient : public std::enable_shared_from_this<CallManagerClient> { 28 DECLARE_DELAYED_SINGLETON(CallManagerClient) 29 30 public: 31 void Init(int32_t systemAbilityId); 32 void UnInit(); 33 34 /** 35 * @brief Register callback 36 * 37 * @param callback[in], callback function pointer 38 * @return Returns 0 on success, others on failure. 39 */ 40 int32_t RegisterCallBack(std::unique_ptr<CallManagerCallback> callback); 41 42 /** 43 * @brief unregister callback 44 * 45 * @return Returns 0 on success, others on failure. 46 */ 47 int32_t UnRegisterCallBack(); 48 49 /** 50 * @brief the application subscribe the OnCallDetailsChange event 51 * 52 * @return Returns 0 on success, others on failure. 53 */ 54 int32_t ObserverOnCallDetailsChange(); 55 56 /** 57 * @brief the application subscribe the OnMeeTimeDetailsChange event 58 * 59 * @return Returns 0 on success, others on failure. 60 */ 61 int32_t ObserverOnMeeTimeDetailsChange(); 62 63 /** 64 * @brief Dial a phone call 65 * 66 * @param number[in], dial param. 67 * @param extras[in], extras date. 68 * @return Returns callId when the value is greater than zero, others on failure. 69 */ 70 int32_t DialCall(std::u16string number, AppExecFwk::PacMap &extras); 71 72 /** 73 * @brief Make a phone call 74 * 75 * @param number[in], call param. 76 * @return Returns 0 on success, others on failure. 77 */ 78 int32_t MakeCall(std::string number); 79 80 /** 81 * @brief Answer a phone call 82 * 83 * @param callId[in], call id 84 * @param videoState[in], 0: audio, 1: video 85 * @return Returns 0 on success, others on failure. 86 */ 87 int32_t AnswerCall(int32_t callId, int32_t videoState); 88 89 /** 90 * @brief Reject a phone call 91 * 92 * @param callId[in], call id 93 * @param rejectWithMessage[in], Whether to enter the reason for rejection,true:yes false:no 94 * @param textMessage[in], The reason you reject the call 95 * @return Returns 0 on success, others on failure. 96 */ 97 int32_t RejectCall(int32_t callId, bool isSendSms, std::u16string content); 98 99 /** 100 * @brief Hang up the phone 101 * 102 * @param callId[in], call id 103 * @return Returns 0 on success, others on failure. 104 */ 105 int32_t HangUpCall(int32_t callId); 106 107 /** 108 * @brief Obtain the call status of the device 109 * 110 * @return Returns call state. 111 */ 112 int32_t GetCallState(); 113 114 /** 115 * @brief Park a phone call 116 * 117 * @param callId[in], call id 118 * @return Returns 0 on success, others on failure. 119 */ 120 int32_t HoldCall(int32_t callId); 121 122 /** 123 * @brief Activate a phone call 124 * 125 * @param callId[in], call id 126 * @return Returns 0 on success, others on failure. 127 */ 128 int32_t UnHoldCall(int32_t callId); 129 130 /** 131 * @brief Switch the phone call between hold and unhold 132 * 133 * @param callId[in], call id 134 * @return Returns 0 on success, others on failure. 135 */ 136 int32_t SwitchCall(int32_t callId); 137 138 /** 139 * @brief Merge calls to form a conference 140 * 141 * @param callId[in], call id 142 * @return Returns 0 on success, others on failure. 143 */ 144 int32_t CombineConference(int32_t callId); 145 146 /** 147 * @brief Separates a specified call from a conference call 148 * 149 * @param callId[in], call id 150 * @return Returns 0 on success, others on failure. 151 */ 152 int32_t SeparateConference(int32_t callId); 153 154 /** 155 * @brief Hangup a specified call from a conference call 156 * 157 * @param callId[in], call id 158 * @return Returns 0 on success, others on failure. 159 */ 160 int32_t KickOutFromConference(int32_t callId); 161 162 /** 163 * @brief Obtain the ID of the primary call in a conference 164 * 165 * @param callId[in], Id of a call in a conference 166 * @return Returns main call id, -1 on not call id. 167 */ 168 int32_t GetMainCallId(int32_t &callId, int32_t &mainCallId); 169 170 /** 171 * @brief Obtain the list of neutron call ids 172 * 173 * @param callId[in], Id of a call in a conference 174 * @param callIdList[out], the list of neutron call ids 175 * @return Returns 0 on success, others on failure. 176 */ 177 int32_t GetSubCallIdList(int32_t callId, std::vector<std::u16string> &callIdList); 178 179 /** 180 * @brief Obtain the callId list of all calls in a conference 181 * 182 * @param callId[in], Id of a call in a conference 183 * @param callIdList[out], the callId list of all calls in a conference 184 * @return Returns 0 on success, others on failure. 185 */ 186 int32_t GetCallIdListForConference(int32_t callId, std::vector<std::u16string> &callIdList); 187 188 /** 189 * @brief Gets whether the call waiting service of the current account is enabled 190 * 191 * @param slotId[in], The slot id 192 * @return Returns 0 on success, others on failure. 193 */ 194 int32_t GetCallWaiting(int32_t slotId); 195 196 /** 197 * @brief Set the call waiting function for the current account 198 * 199 * @param slotId[in], The slot id 200 * @param activate[in], Activation of switch 201 * @return Returns 0 on success, others on failure. 202 */ 203 int32_t SetCallWaiting(int32_t slotId, bool activate); 204 205 /** 206 * @brief Gets the call restriction information of the specified account 207 * 208 * @param slotId[in], The slot id 209 * @param type[in], Call Restriction type 210 * @return Returns 0 on success, others on failure. 211 */ 212 int32_t GetCallRestriction(int32_t slotId, CallRestrictionType type); 213 214 /** 215 * @brief Set the call restriction function for the current account 216 * 217 * @param slotId[in], The slot id 218 * @param info[in], Call restriction information 219 * @return Returns 0 on success, others on failure. 220 */ 221 int32_t SetCallRestriction(int32_t slotId, CallRestrictionInfo &info); 222 223 /** 224 * @brief Set the call restriction password function for the current account 225 * 226 * @param slotId[in], The slot id 227 * @param fac[in], Call restriction type 228 * @param oldPassword[in], Old password of call restriction type 229 * @param newPassword[in], New password of call restriction type 230 * @return Returns 0 on success, others on failure. 231 */ 232 int32_t SetCallRestrictionPassword( 233 int32_t slotId, CallRestrictionType fac, const char *oldPassword, const char *newPassword); 234 235 /** 236 * @brief Gets the call transfer information of the current account 237 * 238 * @param slotId[in], The slot id 239 * @param type[in], Call Transfer Type 240 * @return Returns 0 on success, others on failure. 241 */ 242 int32_t GetCallTransferInfo(int32_t slotId, CallTransferType type); 243 244 /** 245 * @brief Set the call transfer function for the current account 246 * 247 * @param slotId[in], The slot id 248 * @param info[in], Call Transfer Information 249 * @return Returns 0 on success, others on failure. 250 */ 251 int32_t SetCallTransferInfo(int32_t slotId, CallTransferInfo &info); 252 253 /** 254 * @brief confirm whether IMS can set call transfer time. 255 * 256 * @param slotId[in], The slot id 257 * @param result[out], The result of can set or not 258 * @return Returns true on can set, others on can not set. 259 */ 260 int32_t CanSetCallTransferTime(int32_t slotId, bool &result); 261 262 /** 263 * @brief Setting the Call Type 264 * 265 * @param slotId[in], The slot id 266 * @param mode[in], Preference Mode 267 * @return Returns 0 on success, others on failure. 268 */ 269 int32_t SetCallPreferenceMode(int32_t slotId, int32_t mode); 270 271 /** 272 * @brief Enable and send DTMF 273 * 274 * @param callId[in], call id 275 * @param str[in], Characters sent 276 * @return Returns 0 on success, others on failure. 277 */ 278 int32_t StartDtmf(int32_t callId, char str); 279 280 /** 281 * @brief Stop the DTMF 282 * 283 * @param callId[in], call id 284 * @return Returns 0 on success, others on failure. 285 */ 286 int32_t StopDtmf(int32_t callId); 287 288 int32_t PostDialProceed(int32_t callId, bool proceed); 289 /** 290 * @brief Whether the ringing 291 * 292 * @param enabled[out], true on ringing, false on there is no ringing 293 * @return Returns interface processing results. 294 */ 295 int32_t IsRinging(bool &enabled); 296 297 /** 298 * @brief Is there Call 299 * 300 * @return Returns true on has call, others on there is no call. 301 */ 302 bool HasCall(); 303 304 /** 305 * @brief Can I initiate a call 306 * 307 * @param enabled[out], whether allow new calls 308 * @return Returns interface processing results. 309 */ 310 int32_t IsNewCallAllowed(bool &enabled); 311 312 /** 313 * @brief Is there an emergency call 314 * 315 * @param enabled[out], true on emergency call, false on no emergency call 316 * @return Returns interface processing results. 317 */ 318 int32_t IsInEmergencyCall(bool &enabled); 319 320 /** 321 * @brief Is it an emergency call 322 * 323 * @param number[in], Phone number to be formatted 324 * @param slotId[in], The slot id 325 * @param enabled[out] result of is it an emergency call 326 * @return Returns 0 on success, others on failure. 327 */ 328 int32_t IsEmergencyPhoneNumber(std::u16string &number, int32_t slotId, bool &enabled); 329 330 /** 331 * @brief Formatting a phone number 332 * 333 * @param number[in], Phone number to be formatted 334 * @param countryCode[in], Country code of the phone number 335 * @param formatNumber[out] Formatting a phone number 336 * @return Returns 0 on success, others on failure. 337 */ 338 int32_t FormatPhoneNumber(std::u16string &number, std::u16string &countryCode, std::u16string &formatNumber); 339 340 /** 341 * @brief Formatting a phone number 342 * 343 * @param number[in]. Phone number to be formatted 344 * @param countryCode[in], Country code of the phone number 345 * @param formatNumber[out] Formatting a phone number 346 * @return Returns 0 on success, others on failure. 347 */ 348 int32_t FormatPhoneNumberToE164( 349 std::u16string &number, std::u16string &countryCode, std::u16string &formatNumber); 350 351 /** 352 * @brief Mute the Microphone 353 * 354 * @param isMute[in], mute state 355 * @return Returns 0 on success, others on failure. 356 */ 357 int32_t SetMuted(bool isMute); 358 359 /** 360 * @brief Call mute 361 * 362 * @return Returns 0 on success, others on failure. 363 */ 364 int32_t MuteRinger(); 365 366 /** 367 * @brief Setting the Audio Channel 368 * 369 * @param audioDevice[in], contain audioDeviceType and address 370 * @return Returns 0 on success, others on failure. 371 */ 372 int32_t SetAudioDevice(const AudioDevice &audioDevice); 373 374 /** 375 * @brief Open or close camera 376 * 377 * @param callId[in], The call id 378 * @param cameraId[in], The camera id 379 * @return Returns 0 on success, others on failure. 380 */ 381 int32_t ControlCamera(int32_t callId, std::u16string cameraId); 382 383 /** 384 * @brief Set the location and size of the preview window for videos captured by the local camera. 385 * 386 * @param callId[in], The call id 387 * @param surfaceId[in], Window information 388 * @return Returns 0 on success, others on failure. 389 */ 390 int32_t SetPreviewWindow(int32_t callId, std::string &surfaceId); 391 392 /** 393 * @brief Sets the location and size of the remote video window. 394 * 395 * @param callId[in], The call id 396 * @param surfaceId[in], Window information 397 * @return Returns 0 on success, others on failure. 398 */ 399 int32_t SetDisplayWindow(int32_t callId, std::string &surfaceId); 400 401 /** 402 * @brief Sets the local camera zoom scale 403 * 404 * @param zoomRatio[in], Camera scale 405 * @return Returns 0 on success, others on failure. 406 */ 407 int32_t SetCameraZoom(float zoomRatio); 408 409 /** 410 * @brief APP sets the screen of the remote video freeze immediately. 411 * If the APP does not call this interface when making a video call, 412 * the last frame before the remote video freeze is displayed by default 413 * 414 * @param callId[in], The call id 415 * @param path[in], Local Picture address 416 * @return Returns 0 on success, others on failure. 417 */ 418 int32_t SetPausePicture(int32_t callId, std::u16string path); 419 420 /** 421 * @brief Set the rotation Angle of the local device. The default value is 0 422 * 423 * @param rotation[in], Rotation Angle 424 * @return Returns 0 on success, others on failure. 425 */ 426 int32_t SetDeviceDirection(int32_t callId, int32_t rotation); 427 428 /** 429 * @brief Obtain the IMS service configuration 430 * 431 * @param slotId[in], The slot id 432 * @param item[in] 433 * @return Returns 0 on success, others on failure. 434 */ 435 int32_t GetImsConfig(int32_t slotId, ImsConfigItem item); 436 437 /** 438 * @brief Example Set the IMS service configuration 439 * 440 * @param slotId[in], The slot id 441 * @param item[in] 442 * @return Returns 0 on success, others on failure. 443 */ 444 int32_t SetImsConfig(int32_t slotId, ImsConfigItem item, std::u16string &value); 445 446 /** 447 * @brief Gets the value of the IMS function item of the specified network type 448 * 449 * @param slotId[in], The slot id 450 * @param info[in], FeatureType 451 * @return Returns 0 on success, others on failure. 452 */ 453 int32_t GetImsFeatureValue(int32_t slotId, FeatureType type); 454 455 /** 456 * @brief Set the value of the IMS function item of the specified network type 457 * 458 * @param slotId[in], The slot id 459 * @param info[in], FeatureType 460 * @param value[in] 461 * @return Returns 0 on success, others on failure. 462 */ 463 int32_t SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value); 464 465 /** 466 * @brief Setting the Call Mode 467 * 468 * @param callId[in], The call id 469 * @param mode[in], Calling patterns 470 * @return Returns 0 on success, others on failure. 471 */ 472 int32_t UpdateImsCallMode(int32_t callId, ImsCallMode mode); 473 474 /** 475 * @brief Start VoLte 476 * 477 * @param slotId[in], The slot id 478 * @return Returns 0 on success, others on failure. 479 */ 480 int32_t EnableImsSwitch(int32_t slotId); 481 482 /** 483 * @brief Stop VoLte 484 * 485 * @param slotId[in], The slot id 486 * @return Returns 0 on success, others on failure. 487 */ 488 int32_t DisableImsSwitch(int32_t slotId); 489 490 /** 491 * @brief Whether to enable VoLte 492 * 493 * @param slotId[in], The slot id 494 * @param enabled[out], The result of enable or not 495 * @return Returns 0 on success, others on failure. 496 */ 497 int32_t IsImsSwitchEnabled(int32_t slotId, bool &enabled); 498 499 /** 500 * @brief Set VoNR Switch Status 501 * 502 * @param state[in] Indicates the VoNR state, 0: off, 1: on 503 * @param slotId[in] the slot id 504 * @return Returns 0 on success, others on failure. 505 */ 506 int32_t SetVoNRState(int32_t slotId, int32_t state); 507 508 /** 509 * @brief Get VoNR Switch Status 510 * 511 * @param slotId[in] the slot id 512 * @param state[out] Indicates the VoNR state, 0: off, 1: on 513 * @return Returns 0 on success, others on failure. 514 */ 515 int32_t GetVoNRState(int32_t slotId, int32_t &state); 516 517 /** 518 * @brief Enable and send RTT information 519 * 520 * @param callId[in], The call id 521 * @param msg[in], RTT information 522 * @return Returns 0 on success, others on failure. 523 */ 524 int32_t StartRtt(int32_t callId, std::u16string &msg); 525 526 /** 527 * @brief Close the RTT 528 * 529 * @param callId[in], The call id 530 * @return Returns 0 on success, others on failure. 531 */ 532 int32_t StopRtt(int32_t callId); 533 534 /** 535 * @brief Bring someone into a meeting 536 * 537 * @param callId[in], The call id 538 * @param numberList[in], List of calls to join the conference 539 * @return Returns 0 on success, others on failure. 540 */ 541 int32_t JoinConference(int32_t callId, std::vector<std::u16string> &numberList); 542 543 /** 544 * @brief report ott call details info 545 * 546 * @param ottVec[in], ott call status detail info list 547 * @return Returns 0 on success, others on failure. 548 */ 549 int32_t ReportOttCallDetailsInfo(std::vector<OttCallDetailsInfo> &ottVec); 550 551 /** 552 * @brief report ott call event info 553 * 554 * @param eventInfo[in], ott call event detail info 555 * @return Returns 0 on success, others on failure. 556 */ 557 int32_t ReportOttCallEventInfo(OttCallEventInfo &eventInfo); 558 559 /** 560 * @brief Close Unfinished ussd function for the current account 561 * 562 * @param slotId[in], The slot id 563 * @return Returns 0 on success, others on failure. 564 */ 565 int32_t CloseUnFinishedUssd(int32_t slotId); 566 567 /** 568 * @brief Handle special code from dialer. 569 * 570 * @param specialCode[in], special code 571 * @return Returns 0 on success, others on failure. 572 */ 573 int32_t InputDialerSpecialCode(const std::string &specialCode); 574 575 /** 576 * @brief Remove missed incoming call notification. 577 * 578 * @return Returns 0 on success, others on failure. 579 */ 580 int32_t RemoveMissedIncomingCallNotification(); 581 582 /** 583 * @brief Set VoIP Call state 584 * 585 * @param state[in] Indicates the VoIP Call state 586 * @return Returns 0 on success, others on failure. 587 */ 588 int32_t SetVoIPCallState(int32_t state); 589 590 /** 591 * @brief Get VoIP Call Switch Status 592 * 593 * @param state[out] Indicates the VoIP Call state 594 * @return Returns 0 on success, others on failure. 595 */ 596 int32_t GetVoIPCallState(int32_t &state); 597 598 /** 599 * @brief Set VoIP Call info 600 * 601 * @param callId[in] Indicates the VoIP Call id 602 * @param state[in] Indicates the VoIP Call state 603 * @param phoneNumber[in] Indicates the VoIP Call phone number 604 * @return Returns 0 on success, others on failure. 605 */ 606 int32_t SetVoIPCallInfo(int32_t callId, int32_t state, std::string phoneNumber); 607 608 /** 609 * @brief Get VoIP Call info 610 * 611 * @param callId[out] Indicates the VoIP Call id 612 * @param state[out] Indicates the VoIP Call state 613 * @param phoneNumber[out] Indicates the VoIP Call phone number 614 * @return Returns 0 on success, others on failure. 615 */ 616 int32_t GetVoIPCallInfo(int32_t &callId, int32_t &state, std::string &phoneNumber); 617 618 /** 619 * @brief Checks whether a device supports voice calls 620 * 621 * @return true on support voice calls, false on not support. 622 */ 623 bool HasVoiceCapability(); 624 625 /** 626 * @brief report audio device info 627 * 628 * @return Returns 0 on success, others on failure. 629 */ 630 int32_t ReportAudioDeviceInfo(); 631 632 /** 633 * @brief cancel upgrade to video call 634 * 635 * @param callId[in], The call id 636 * @return Returns 0 on success, others on failure. 637 */ 638 int32_t CancelCallUpgrade(int32_t callId); 639 640 /** 641 * @brief request camera capabilities 642 * 643 * @param callId[in], The call id 644 * @return Returns 0 on success, others on failure. 645 */ 646 int32_t RequestCameraCapabilities(int32_t callId); 647 648 /** 649 * @brief notify voip register callstatus callback 650 * 651 * @return Returns 0 on success, others on failure. 652 */ 653 int32_t RegisterVoipCallManagerCallback(); 654 655 /** 656 * @brief notify voip unregister callstatus callback 657 * 658 * @return Returns 0 on success, others on failure. 659 */ 660 int32_t UnRegisterVoipCallManagerCallback(); 661 662 /** 663 * @brief send call ui event 664 * 665 * @return Returns 0 on success, others on failure. 666 */ 667 int32_t SendCallUiEvent(int32_t callId, std::string &eventName); 668 669 /** 670 * @brief notify bluetoothcall register callstatus callback 671 * 672 * @return Returns sptr<ICallStatusCallback>. 673 */ 674 sptr<ICallStatusCallback> RegisterBluetoothCallManagerCallbackPtr(std::string &macAddress); 675 676 /** 677 * @brief send ussd response to modem 678 * 679 * @return Returns 0 on success, others on failure. 680 */ 681 int32_t SendUssdResponse(int32_t slotId, std::string &content); 682 }; 683 } // namespace Telephony 684 } // namespace OHOS 685 686 #endif 687