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