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