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 CELLULAR_CALL_SUPPLEMENT_H 17 #define CELLULAR_CALL_SUPPLEMENT_H 18 19 #include <string> 20 21 #include "cellular_call_data_struct.h" 22 #include "tel_ril_call_parcel.h" 23 #include "tel_ril_types.h" 24 #include "ims_call_types.h" 25 #include "module_service_utils.h" 26 #include "supplement_request_cs.h" 27 #include "supplement_request_ims.h" 28 #include "telephony_log_wrapper.h" 29 30 namespace OHOS { 31 namespace Telephony { 32 class CellularCallSupplement { 33 public: 34 /** 35 * Handle Clip mmi code 36 * 37 * 3GPP TS 22.030 V4.0.0 (2001-03) 6.5.6.2 Calling Line Identification Presentation (CLIP) 38 * The CLIP Supplementary Service is defined in GSM 02.81[12] 39 * 3GPP TS 22.030 V4.0.0 (2001-03) Annex B (normative):Codes for defined Supplementary Services 40 * 41 * @param slotId 42 * @param MMIData 43 */ 44 void HandleClip(int32_t slotId, const MMIData &mmiData); 45 46 /** 47 * Handle Clir mmi code 48 * 49 * 3GPP TS 22.081 V4.0.0 (2001-03) 2 Calling Line Identification Restriction (CLIR) 50 * 3GPP TS 22.030 V4.0.0 (2001-03) Annex B (normative):Codes for defined Supplementary Services 51 * 52 * @param slotId 53 * @param MMIData 54 */ 55 void HandleClir(int32_t slotId, const MMIData &mmiData); 56 57 /** 58 * Handle Colr mmi code 59 * 60 * 3GPP TS 22.081 V4.0.0 (2001-03) 4 Connected Line Identification Restriction (COLR) 61 * 3GPP TS 22.030 V4.0.0 (2001-03) Annex B (normative):Codes for defined Supplementary Services 62 * 63 * @param slotId 64 * @param MMIData 65 */ 66 void HandleColr(int32_t slotId, const MMIData &mmiData); 67 68 /** 69 * Handle Colp mmi code 70 * 71 * 3GPP TS 22.081 V4.0.0 (2001-03) 3 Connected Line Identification Presentation (COLP) 72 * 3GPP TS 22.030 V4.0.0 (2001-03) Annex B (normative):Codes for defined Supplementary Services 73 * 74 * @param slotId 75 * @param MMIData 76 */ 77 void HandleColp(int32_t slotId, const MMIData &mmiData); 78 79 /** 80 * Handle Call Transfer mmi code 81 * 82 * 3GPP TS 22.030 V4.0.0 (2001-03) 83 * 3GPP TS 22.030 V4.0.0 (2001-03) Annex B (normative):Codes for defined Supplementary Services 84 * 85 * @param slotId 86 * @param MMIData 87 */ 88 void HandleCallTransfer(int32_t slotId, const MMIData &mmiData); 89 90 /** 91 * Set Call Transfer 92 * 93 * 27007-430_2001 7.11 Call forwarding number and conditions +CCFC 94 * 3GPP TS 22.082 [4] 95 * Control of the call forwarding supplementary service 96 * 97 * @param slotId 98 * @param CallTransferInfo 99 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 100 */ 101 int32_t SetCallTransferInfo(int32_t slotId, const CallTransferInfo &cTInfo); 102 103 /** 104 * Confirm whether IMS can set call transfer time. 105 * 106 * @param slotId[in], The slot id 107 * @param result[out], The result of can set or not 108 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 109 */ 110 int32_t CanSetCallTransferTime(int32_t slotId, bool &result); 111 112 /** 113 * Inquire Call Transfer 114 * 115 * 27007-430_2001 7.11 Call forwarding number and conditions +CCFC 116 * 3GPP TS 22.082 [4] 117 * Control of the call forwarding supplementary service 118 * 119 * @param slotId 120 * @param CallTransferType 121 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 122 */ 123 int32_t GetCallTransferInfo(int32_t slotId, CallTransferType type); 124 125 /** 126 * Handle Call Restriction mmi code 127 * 128 * 3GPP TS 22.088 [6] 1 Barring of outgoing calls 129 * 3GPP TS 22.088 [6] 2 Barring of incoming calls 130 * 131 * @param slotId 132 * @param MMIData 133 */ 134 void HandleCallRestriction(int32_t slotId, const MMIData &mmiData); 135 136 /** 137 * Set Call Restriction 138 * 139 * 27007-430_2001 7.4 Facility lock +CLCK 140 * 3GPP TS 22.088 [6] 1 Barring of outgoing calls 141 * 3GPP TS 22.088 [6] 2 Barring of incoming calls 142 * 143 * Control of the call barring supplementary service 144 * 145 * @param slotId 146 * @param CallRestrictionInfo 147 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 148 */ 149 int32_t SetCallRestriction(int32_t slotId, const CallRestrictionInfo &cRInfo); 150 151 /** 152 * Inquire Call Restriction 153 * 154 * 27007-430_2001 7.4 Facility lock +CLCK 155 * 3GPP TS 22.088 [6] 1 Barring of outgoing calls 156 * 3GPP TS 22.088 [6] 2 Barring of incoming calls 157 * 158 * Control of the call barring supplementary service 159 * 160 * @param slotId 161 * @param CallRestrictionType 162 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 163 */ 164 int32_t GetCallRestriction(int32_t slotId, CallRestrictionType facType); 165 166 /** 167 * Inquire Call Restriction Password 168 * 169 * 27007-430_2001 7.4 Facility lock +CLCK 170 * 3GPP TS 22.088 [6] 1 Barring of outgoing calls 171 * 3GPP TS 22.088 [6] 2 Barring of incoming calls 172 * 173 * Control of the call barring supplementary service 174 * 175 * @param slotId 176 * @param CallRestrictionType 177 * @param oldPassword[in] indicate the call restriction old password 178 * @param newPassword[in] indicate the call restriction new password 179 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 180 */ 181 int32_t SetBarringPassword( 182 int32_t slotId, CallRestrictionType facType, const char *oldPassword, const char *newPassword); 183 184 /** 185 * Handle Call Waiting mmi code 186 * 187 * 27007-430_2001 7.12 Call waiting +CCWA 188 * 3GPP TS 22.083 [5] 1 Call waiting (CW) 189 * 190 * @param slotId 191 * @param MMIData 192 */ 193 void HandleCallWaiting(int32_t slotId, const MMIData &mmiData); 194 195 /** 196 * Set Call Waiting 197 * 198 * 27007-430_2001 7.12 Call waiting +CCWA 199 * 3GPP TS 22.083 [5] 1 Call waiting (CW) 200 * 201 * Control of the Call Waiting supplementary service 202 * 203 * @param slotId 204 * @param activate 205 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 206 */ 207 int32_t SetCallWaiting(int32_t slotId, bool activate); 208 209 /** 210 * Inquire Call Waiting 211 * 212 * 27007-430_2001 7.12 Call waiting +CCWA 213 * 3GPP TS 22.083 [5] 1 Call waiting (CW) 214 * 215 * Control of the Call Waiting supplementary service 216 * 217 * @param slotId 218 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 219 */ 220 int32_t GetCallWaiting(int32_t slotId); 221 222 /** 223 * Send Ussd msg 224 * 225 * 22.090 Unstructured Supplementary Service Data (USSD); Stage 1 226 * 23.090 Unstructured Supplementary Service Data (USSD); Stage 2 227 * 24.090 Unstructured Supplementary Service Data (USSD); Stage 3 228 * 229 * Control of the Ussd supplementary service 230 * 231 * @param slotId 232 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 233 */ 234 int32_t SendUssd(int32_t slotId, const std::string &msg); 235 236 /** 237 * Event Set Pin Puk 238 * 239 * @param PinPukResponse 240 */ 241 void EventSetPinPuk(const PinPukResponse &pinPukResponse); 242 243 /** 244 * SIM PIN unlock 245 * 246 * @param slotId 247 * @param mmiData 248 * @return Returns true on success. 249 */ 250 void AlterPinPassword(int32_t slotId, const MMIData &mmiData); 251 252 /** 253 * SIM PUK unlock 254 * 255 * @param slotId 256 * @param mmiData 257 * @return Returns true on success. 258 */ 259 void UnlockPuk(int32_t slotId, const MMIData &mmiData); 260 261 /** 262 * SIM PIN2 unlock 263 * 264 * @param slotId 265 * @param mmiData 266 * @return Returns true on success. 267 */ 268 void AlterPin2Password(int32_t slotId, const MMIData &mmiData); 269 270 /** 271 * SIM PUK2 unlock 272 * 273 * @param slotId 274 * @param mmiData 275 * @return Returns true on success. 276 */ 277 void UnlockPuk2(int32_t slotId, const MMIData &mmiData); 278 279 /** 280 * Close Unfinished ussd 281 * 282 * Control of close Ussd supplementary service 283 * 284 * @param slotId 285 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 286 */ 287 int32_t CloseUnFinishedUssd(int32_t slotId); 288 289 /** 290 * Get clip result 291 * 292 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.6 Calling line identification presentation +CLIP 293 * 294 * @param GetClipResult 295 * @param message the remain message for user which come from network 296 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 297 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 298 */ 299 void EventGetClip(const GetClipResult &getClipResult, const std::string &message, int32_t flag); 300 301 /** 302 * Set clip result 303 * 304 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.6 Calling line identification presentation +CLIP 305 * 306 * @param result 307 * @param message the remain message for user which come from network 308 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 309 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 310 */ 311 void EventSetClip(int32_t result, const std::string &message, int32_t flag); 312 313 /** 314 * Get clir result 315 * 316 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.7 Calling line identification restriction +CLIR 317 * 318 * @param GetClirResult 319 * @param message the remain message for user which come from network 320 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 321 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 322 */ 323 void EventGetClir(const GetClirResult &result, const std::string &message, int32_t flag); 324 325 /** 326 * Set clir result 327 * 328 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.7 Calling line identification restriction +CLIR 329 * 330 * @param result 331 * @param message the remain message for user which come from network 332 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 333 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 334 */ 335 void EventSetClir(int32_t result, const std::string &message, int32_t flag); 336 337 /** 338 * Get colr result 339 * 340 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.31 Connected line identification restriction status +COLR 341 * 342 * @param GetColrResult 343 * @param message the remain message for user which come from network 344 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 345 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 346 */ 347 void EventGetColr(const GetColrResult &result, const std::string &message, int32_t flag); 348 349 /** 350 * Set colr result 351 * 352 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.31 Connected line identification restriction status +COLR 353 * 354 * @param result 355 * @param message the remain message for user which come from network 356 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 357 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 358 */ 359 void EventSetColr(int32_t result, const std::string &message, int32_t flag); 360 361 /** 362 * Get colp result 363 * 364 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.8 Connected line identification presentation +COLP 365 * 366 * @param GetColpResult 367 * @param message the remain message for user which come from network 368 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 369 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 370 */ 371 void EventGetColp(const GetColpResult &result, const std::string &message, int32_t flag); 372 373 /** 374 * Set colp result 375 * 376 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.8 Connected line identification presentation +COLP 377 * 378 * @param result 379 * @param message the remain message for user which come from network 380 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 381 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 382 */ 383 void EventSetColp(int32_t result, const std::string &message, int32_t flag); 384 385 /** 386 * Get call restriction result 387 * 388 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.4 Facility lock +CLCK 389 * 390 * @param CallRestrictionResult 391 * @param message the remain message for user which come from network 392 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 393 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 394 */ 395 void EventGetCallRestriction(const CallRestrictionResult &result, const std::string &message, int32_t flag); 396 397 /** 398 * Set call restriction result 399 * 400 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.4 Facility lock +CLCK 401 * 402 * @param result 403 * @param message the remain message for user which come from network 404 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 405 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 406 */ 407 void EventSetCallRestriction(int32_t result, const std::string &message, int32_t flag); 408 409 /** 410 * Set call restriction password result 411 * 412 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.4 Facility lock +CLCK 413 * 414 * @param result 415 * @param message the remain message for user which come from network 416 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 417 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 418 */ 419 void EventSetBarringPassword(int32_t result, const std::string &message, int32_t flag); 420 /** 421 * Get call waiting result 422 * 423 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.12 Call waiting +CCWA 424 * status: 0 not active; 1 active 425 * 426 * @param CallWaitResult waitingInfo 427 * @param message the remain message for user which come from network 428 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 429 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 430 */ 431 void EventGetCallWaiting(const CallWaitResult &waitingInfo, const std::string &message, int32_t flag); 432 433 /** 434 * Set call waiting result 435 * 436 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.12 Call waiting +CCWA 437 * 438 * @param result 439 * @param message the remain message for user which come from network 440 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 441 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 442 */ 443 void EventSetCallWaiting(int32_t result, const std::string &message, int32_t flag); 444 445 /** 446 * Get call transfer result 447 * 448 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.11 Call forwarding number and conditions +CCFC 449 * 450 * @param CallForwardQueryInfoList 451 * @param message the remain message for user which come from network 452 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 453 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 454 */ 455 void EventGetCallTransferInfo( 456 const CallForwardQueryInfoList &cFQueryList, const std::string &message, int32_t flag); 457 458 /** 459 * Set call transfer result 460 * 461 * 3GPP TS 27.007 V3.9.0 (2001-06) 7.11 Call forwarding number and conditions +CCFC 462 * 463 * @param result 464 * @param message the remain message for user which come from network 465 * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api 466 * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. 467 */ 468 void EventSetCallTransferInfo(int32_t result, const std::string &message, int32_t flag); 469 470 /** 471 * Send ussd result 472 * 473 * 3GPP TS 3GPP TS 22.030 V16.0.0 (2020-07) 6.5 Supplementary Services Control 474 * 475 * @param RadioResponseInfo 476 */ 477 void EventSendUssd(const RadioResponseInfo &responseInfo); 478 479 /** 480 * Ss notify 481 * 482 * @param SsNoticeInfo 483 */ 484 void EventSsNotify(SsNoticeInfo &ssNoticeInfo); 485 486 /** 487 * Ussd notify 488 * 489 * @param UssdNoticeInfo 490 */ 491 void EventUssdNotify(UssdNoticeInfo &ussdNoticeInfo); 492 493 /** 494 * Close Unfinished ussd result 495 * 496 * @param RadioResponseInfo 497 */ 498 void EventCloseUnFinishedUssd(const RadioResponseInfo &responseInfo); 499 500 private: 501 /** 502 * Obtain ServiceCode 503 * 504 * @param serviceInfoB 505 * @return ServiceClassType 506 */ 507 int32_t ObtainServiceCode(const std::string &serviceInfoB); 508 509 /** 510 * Obtain ServiceCode 511 * 512 * @param actionString 513 * @param phoneNumber 514 * @param callTransferAction 515 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 516 */ 517 int32_t ObtainCallTrasferAction( 518 const char *actionString, const std::string &phoneNumber, CallTransferSettingType &callTransferAction); 519 520 /** 521 * Obtain Cause 522 * 523 * 3GPP TS 22.030 V4.0.0 (2001-03) Annex B (normative): Codes for defined Supplementary Services 524 * 525 * @param basicString 526 * @return CallTransferType 527 */ 528 int32_t ObtainCause(const std::string &serviceInfoC); 529 530 /** 531 * Handle get call transfer action which come from mmi code 532 * 533 * @param slotId 534 * @param cause the call transfer type 535 */ 536 void HandleGetCallTransfer(int32_t slotId, int32_t cause); 537 538 /** 539 * Handle set call transfer action which come from mmi code 540 * 541 * @param slotId 542 * @param serviceCode the service class type 543 * @param cause the call transfer type 544 * @param phoneNumber the call transfer number 545 * @param callTransferAction 546 */ 547 void HandleSetCallTransfer(int32_t slotId, int32_t serviceCode, int32_t cause, const std::string &phoneNumber, 548 CallTransferSettingType callTransferAction); 549 550 int32_t CheckSetCallTransferInfo(const CallTransferInfo &cfInfo); 551 int32_t SetCallTransferInfoByIms( 552 int32_t slotId, const CallTransferInfo &cfInfo, const std::shared_ptr<SsRequestCommand> &command); 553 int32_t CheckCallRestrictionType(std::string &fac, const CallRestrictionType &facType); 554 int32_t SetCallRestrictionByIms(int32_t slotId, std::string &fac, int32_t mode, std::string &pw, 555 const std::shared_ptr<SsRequestCommand> &command); 556 557 /** 558 * Obtain Barring Installation 559 * 560 * 27007-430_2001 7.4 Facility lock +CLCK 561 * 3GPP TS 22.088 [6] 1 Barring of outgoing calls 562 * 3GPP TS 22.088 [6] 2 Barring of incoming calls 563 * 564 * @param serviceInfoC 565 * @return Barring type 566 */ 567 std::string ObtainBarringInstallation(const std::string &serviceInfoC); 568 569 /** 570 * Is Phone Gsm Type 571 * 572 * @param slotId 573 * @return bool 574 */ 575 bool PhoneTypeGsmOrNot(int32_t slotId); 576 577 /** 578 * Confirm if need use IMS handle first 579 * 580 * @param slotId 581 * @return bool 582 */ 583 bool NeedUseImsToHandle(int32_t slotId); 584 585 /** 586 * Get Message 587 * 588 * @param MmiCodeInfo 589 * @param SsNoticeInfo 590 */ 591 void GetMessage(MmiCodeInfo &mmiCodeInfo, const SsNoticeInfo &ssNoticeInfo); 592 593 private: 594 void BuildCallForwardQueryInfo(const CallForwardQueryResult &queryResult, const std::string &message, int32_t flag); 595 void ReportMmiCodeMessage(int32_t result, const std::string successMsg, const std::string failedMsg); 596 bool IsVaildPinOrPuk(std::string newPinOrPuk, std::string newPinOrPukCheck); 597 598 private: 599 SupplementRequestCs supplementRequestCs_; 600 SupplementRequestIms supplementRequestIms_; 601 ModuleServiceUtils moduleServiceUtils_; 602 }; 603 } // namespace Telephony 604 } // namespace OHOS 605 #endif // CELLULAR_CALL_SUPPLEMENT_H 606