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 CORE_SERVICE_CLIENT_H 17 #define CORE_SERVICE_CLIENT_H 18 19 #include <atomic> 20 #include <cstdint> 21 #include <iremote_object.h> 22 #include <singleton.h> 23 #include <string_ex.h> 24 25 #include "i_core_service.h" 26 27 namespace OHOS { 28 namespace Telephony { 29 class CoreServiceClient : public DelayedRefSingleton<CoreServiceClient> { 30 DECLARE_DELAYED_REF_SINGLETON(CoreServiceClient); 31 32 public: 33 sptr<ICoreService> GetProxy(); 34 void OnRemoteDied(const wptr<IRemoteObject> &remote); 35 36 /** 37 * @brief Obtain the list of signal strength information of the registered network 38 * 39 * @param slotId[in], sim slot id 40 * @param signalslist[out], list of signal strength information of the registered network 41 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 42 */ 43 int32_t GetSignalInfoList(int32_t slotId, std::vector<sptr<SignalInformation>> &signals); 44 45 /** 46 * @brief Checks whether the device supports 5G New Radio (NR). 47 * 48 * @param slotId[in], sim slot id 49 * @return returns true if the device supports 5G NR; returns false otherwise. 50 */ 51 bool IsNrSupported(int32_t slotId); 52 53 /** 54 * @brief Obtain radio access technology (RAT) of the PS domain 55 * 56 * @param slotId[in], sim slot id 57 * @param psRadioTech[out], RAT of the PS domain on the registered network 58 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 59 */ 60 int32_t GetPsRadioTech(int32_t slotId, int32_t &psRadioTech); 61 62 /** 63 * @brief Obtain radio access technology (RAT) of the CS domain 64 * 65 * @param slotId[in], sim slot id 66 * @param csRadioTech[out], RAT of the CS domain on the registered network 67 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 68 */ 69 int32_t GetCsRadioTech(int32_t slotId, int32_t &csRadioTech); 70 71 /** 72 * @brief Obtain the selection mode of NR 73 * 74 * @param slotId[in], sim slot id 75 * @param mode[in], the selection mode of NR 76 * @param callback[out], Indicates the result of setting NR mode 77 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 78 */ 79 int32_t SetNrOptionMode(int32_t slotId, int32_t mode, const sptr<INetworkSearchCallback> &callback); 80 81 /** 82 * @brief Obtain the selection mode of NR 83 * 84 * @param slotId[in], sim slot id 85 * @param callback[out], the callback of NR mode 86 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 87 */ 88 int32_t GetNrOptionMode(int32_t slotId, const sptr<INetworkSearchCallback> &callback); 89 90 /** 91 * @brief Obtain the unique ID 92 * 93 * @param slotId[in], sim slot id 94 * @param deviceId[out], the unique ID of a device 95 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 96 */ 97 int32_t GetUniqueDeviceId(int32_t slotId, std::u16string &deviceId); 98 99 /** 100 * @brief Obtain the mobile equipment identifier 101 * 102 * @param slotId[in], sim slot id 103 * @param meid[out], the mobile equipment identifier of the SIM card 104 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 105 */ 106 int32_t GetMeid(int32_t slotId, std::u16string &meid); 107 108 /** 109 * @brief Obtain the operator numeric 110 * 111 * @param slotId[in], sim slot id 112 * @return std::u16string operator numeric of PLMN of the SIM card. 113 */ 114 std::u16string GetOperatorNumeric(int32_t slotId); 115 116 /** 117 * @brief Obtain the resident network numeric 118 * 119 * @param slotId[in], sim slot id 120 * @return std::string resident network numeric of PLMN of the SIM card. 121 */ 122 std::string GetResidentNetworkNumeric(int32_t slotId); 123 124 /** 125 * @brief Obtain the operator name 126 * 127 * @param slotId[in], sim slot id 128 * @param operatorName[out], the operator name of the SIM card 129 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 130 */ 131 int32_t GetOperatorName(int32_t slotId, std::u16string &operatorName); 132 133 /** 134 * @brief Obtain the network state 135 * 136 * @param slotId[in], sim slot id 137 * @param networkState[out], the callback of network registration state 138 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 139 */ 140 int32_t GetNetworkState(int32_t slotId, sptr<NetworkState> &networkState); 141 142 /** 143 * @brief Set the radio state 144 * 145 * @param slotId[in], sim slot id 146 * @param isOn[in], turn on or turn off the radio service 147 * @param callback[out], the callback of radio state 148 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 149 */ 150 int32_t SetRadioState(int32_t slotId, bool isOn, const sptr<INetworkSearchCallback> &callback); 151 152 /** 153 * @brief Obtain the radio state 154 * 155 * @param slotId[in], sim slot id 156 * @param callback[out], the callback of radio state 157 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 158 */ 159 int32_t GetRadioState(int32_t slotId, const sptr<INetworkSearchCallback> &callback); 160 161 /** 162 * @brief Obtain the International Mobile Equipment Identification 163 * 164 * @param slotId[in], sim slot id 165 * @param imei[out], the International Mobile Equipment Identification Number of the SIM card 166 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 167 */ 168 int32_t GetImei(int32_t slotId, std::u16string &imei); 169 170 /** 171 * @brief Obtains the software version number of a specified card slot of the device 172 * 173 * @param slotId[in], sim slot id 174 * @param imeiSv[out], the International Mobile Equipment Identification Number of the SIM card 175 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 176 */ 177 int32_t GetImeiSv(int32_t slotId, std::u16string &imeiSv); 178 179 /** 180 * @brief Checks whether a SIM card is inserted in a specified slot. 181 * 182 * @param slotId[in], sim slot id 183 * @param hasSimCard[out], returns true if a SIM card is inserted; return false otherwise 184 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 185 */ 186 int32_t HasSimCard(int32_t slotId, bool &hasSimCard); 187 188 /** 189 * @brief Obtain the state of the SIM card 190 * 191 * @param slotId[in], sim slot id 192 * @param simState[out], the state of the SIM card 193 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 194 */ 195 int32_t GetSimState(int32_t slotId, SimState &simState); 196 197 /** 198 * @brief Obtain the value of dsds mode 199 * 200 * @param dsdsMode[out], the value of dsds mode 201 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 202 */ 203 int32_t GetDsdsMode(int32_t &dsdsMode); 204 205 /** 206 * @brief Obtain the operator numeric of PLMN 207 * 208 * @param slotId[in], sim slot id 209 * @param operatorNumeric[out], the operator numeric of PLMN of the SIM card 210 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 211 */ 212 int32_t GetSimOperatorNumeric(int32_t slotId, std::u16string &operatorNumeric); 213 214 /** 215 * @brief Obtain the ISO country code 216 * 217 * @param slotId[in], sim slot id 218 * @param countryCode[out], the ISO country code of the SIM card 219 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 220 */ 221 int32_t GetISOCountryCodeForSim(int32_t slotId, std::u16string &countryCode); 222 223 /** 224 * @brief Obtain the service provider name 225 * 226 * @param slotId[in], sim slot id 227 * @param spn[out], the service provider name of the SIM card 228 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 229 */ 230 int32_t GetSimSpn(int32_t slotId, std::u16string &spn); 231 232 /** 233 * @brief Obtain the integrated circuit card identity 234 * 235 * @param slotId[in], sim slot id 236 * @param iccId[out], the integrated circuit card identity of the SIM card 237 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 238 */ 239 int32_t GetSimIccId(int32_t slotId, std::u16string &iccId); 240 241 /** 242 * @brief Obtain the international mobile subscriber identity 243 * 244 * @param slotId[in], sim slot id 245 * @param imsi[out], the international mobile subscriber identity of the SIM card 246 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 247 */ 248 int32_t GetIMSI(int32_t slotId, std::u16string &imsi); 249 250 /** 251 * @brief Check whther the SIM card in a specified slot is China Telecom SIM. 252 * 253 * @param slotId[in], sim slot id 254 * @param isCTSimCard[out], returns true if a SIM card is inserted; return false otherwise 255 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 256 */ 257 int32_t IsCTSimCard(int32_t slotId, bool &isCTSimCard); 258 259 /** 260 * @brief Checks whether the SIM card in a specified slot is activated 261 * 262 * @param slotId[in], sim slot id 263 * @return returns true if the SIM card activated; returns false otherwise. 264 */ 265 bool IsSimActive(int32_t slotId); 266 267 /** 268 * @brief Obtain the sim slot id of the simId 269 * 270 * @param simId[in], sim card id 271 * @return return the sim slot id of the simId. 272 */ 273 int32_t GetSlotId(int32_t simId); 274 275 /** 276 * @brief Obtain the sim card id 277 * 278 * @param slotId[in], sim slot id 279 * @return return the sim card id of the SIM card. 280 */ 281 int32_t GetSimId(int32_t slotId); 282 283 /** 284 * @brief Obtain the callback of network search information 285 * 286 * @param slotId[in], sim slot id 287 * @param callback[out], the callback of network search information 288 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 289 */ 290 int32_t GetNetworkSearchInformation(int32_t slotId, const sptr<INetworkSearchCallback> &callback); 291 292 /** 293 * @brief Obtain the callback of network selection mode 294 * 295 * @param slotId[in], sim slot id 296 * @param callback[out], the callback of network selection mode 297 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 298 */ 299 int32_t GetNetworkSelectionMode(int32_t slotId, const sptr<INetworkSearchCallback> &callback); 300 301 /** 302 * @brief Obtain the locale from the default sim 303 * 304 * @return std::u16string locale from default sim. 305 */ 306 std::u16string GetLocaleFromDefaultSim(); 307 308 /** 309 * @brief Obtain the group identifier level 1 310 * 311 * @param slotId[in], sim slot id 312 * @param gid1[out], the group identifier level 1 of the SIM card 313 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 314 */ 315 int32_t GetSimGid1(int32_t slotId, std::u16string &gid1); 316 317 /** 318 * @brief Obtain the group identifier level 2 319 * 320 * @param slotId[in], sim slot id 321 * @return std::u16string the group identifier level 2 of the SIM card. 322 */ 323 std::u16string GetSimGid2(int32_t slotId); 324 325 /** 326 * @brief Obtain the enhanced operator name string 327 * 328 * @param slotId[in], sim slot id 329 * @param plmn[in], public land mobile network 330 * @param lac[in], location area code 331 * @param longNameRequired[in], required long name or not 332 * @return std::u16string the enhanced operator name string of the SIM card. 333 */ 334 std::u16string GetSimEons(int32_t slotId, const std::string &plmn, int32_t lac, bool longNameRequired); 335 336 /** 337 * @brief Set the network search mode 338 * 339 * @param slotId[in], sim slot id 340 * @param selectMode[in], the network search mode of the SIM card 341 * @param networkInformation[in], the network information 342 * @param resumeSelection[in], whether to continue selecting the network selection mode 343 * @param callback[in], the callback of set network selection mode 344 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 345 */ 346 int32_t SetNetworkSelectionMode(int32_t slotId, int32_t selectMode, 347 const sptr<NetworkInformation> &networkInformation, bool resumeSelection, 348 const sptr<INetworkSearchCallback> &callback); 349 350 /** 351 * @brief Obtain the ISO-defined country code 352 * 353 * @param slotId[in], sim slot id 354 * @param countryCode[out], the ISO-defined country code of the country where the registered network is deployed 355 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 356 */ 357 int32_t GetIsoCountryCodeForNetwork(int32_t slotId, std::u16string &countryCode); 358 359 /** 360 * @brief Obtain the sim account information 361 * 362 * @param slotId[in], sim slot id 363 * @param info[out], account information of SIM card 364 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 365 */ 366 int32_t GetSimAccountInfo(int32_t slotId, IccAccountInfo &info); 367 368 /** 369 * @brief Set default voice slotId 370 * 371 * @param slotId[in], sim slot id 372 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 373 */ 374 int32_t SetDefaultVoiceSlotId(int32_t slotId); 375 376 /** 377 * @brief Obtain default voice slotId 378 * 379 * @return int32_t default voice slotId. 380 */ 381 int32_t GetDefaultVoiceSlotId(); 382 383 /** 384 * @brief Obtain default voice simId 385 * 386 * @param simId[out], default voice simId 387 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 388 */ 389 int32_t GetDefaultVoiceSimId(int32_t &simId); 390 391 /** 392 * @brief Set the SIM card show number 393 * 394 * @param slotId[in], sim slot id 395 * @param number[in], the SIM card show number 396 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 397 */ 398 int32_t SetShowNumber(int32_t slotId, const std::u16string &number); 399 400 /** 401 * @brief Obtain the SIM card show number 402 * 403 * @param slotId[in], sim slot id 404 * @param showNumber[out], the SIM card show number 405 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 406 */ 407 int32_t GetShowNumber(int32_t slotId, std::u16string &showNumber); 408 409 /** 410 * @brief Set the SIM card show name 411 * 412 * @param slotId[in], sim slot id 413 * @param name[in], the SIM card show name 414 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 415 */ 416 int32_t SetShowName(int32_t slotId, const std::u16string &name); 417 418 /** 419 * @brief Obtain the SIM card show name 420 * 421 * @param slotId[in], sim slot id 422 * @param showName[out], the SIM card show name 423 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 424 */ 425 int32_t GetShowName(int32_t slotId, std::u16string &showName); 426 427 /** 428 * @brief Obtain the list of active SIM card account information 429 * 430 * @param iccAccountInfoList[out], the list of active SIM card account information 431 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 432 */ 433 int32_t GetActiveSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList); 434 435 /** 436 * @brief Obtain the operator configs 437 * 438 * @param slotId[in], sim slot id 439 * @param poc[out], the operator configs of SIM card 440 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 441 */ 442 int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc); 443 444 /** 445 * @brief Unlock Pin 446 * 447 * @param slotId[in], sim slot id 448 * @param pin[in], the password of the SIM card 449 * @param response[out], the response of unlock pin 450 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 451 */ 452 int32_t UnlockPin(int32_t slotId, const std::u16string &pin, LockStatusResponse &response); 453 454 /** 455 * @brief Unlock Puk 456 * 457 * @param slotId[in], sim slot id 458 * @param newPin[in], newPin to reset the SIM card password 459 * @param puk[in], the unlock password of the SIM card password 460 * @param response[out], the response of unlock puk 461 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 462 */ 463 int32_t UnlockPuk( 464 int32_t slotId, const std::u16string &newPin, const std::u16string &puk, LockStatusResponse &response); 465 466 /** 467 * @brief Alter Pin 468 * 469 * @param slotId[in], sim slot id 470 * @param newPin[in], newPin to change the SIM card password 471 * @param oldPin[in], old password 472 * @param response[out], the response of alter pin 473 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 474 */ 475 int32_t AlterPin( 476 int32_t slotId, const std::u16string &newPin, const std::u16string &oldPin, LockStatusResponse &response); 477 478 /** 479 * @brief Unlock Pin2 480 * 481 * @param slotId[in], sim slot id 482 * @param pin2[in], the password of the SIM card 483 * @param response[out], the response of unlock pin2 484 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 485 */ 486 int32_t UnlockPin2(int32_t slotId, const std::u16string &pin2, LockStatusResponse &response); 487 488 /** 489 * @brief Unlock Puk2 490 * 491 * @param slotId[in], sim slot id 492 * @param newPin2[in], newPin2 to reset the SIM card password 493 * @param puk2[in], the unlock password of the SIM card password 494 * @param response[out], the response of unlock puk2 495 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 496 */ 497 int32_t UnlockPuk2( 498 int32_t slotId, const std::u16string &newPin2, const std::u16string &puk2, LockStatusResponse &response); 499 500 /** 501 * @brief Alter Pin2 502 * 503 * @param slotId[in], sim slot id 504 * @param newPin2[in], newPin2 to change the SIM card password 505 * @param oldPin2[in], old password 506 * @param response[out], the response of alter pin2 507 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 508 */ 509 int32_t AlterPin2( 510 int32_t slotId, const std::u16string &newPin2, const std::u16string &oldPin2, LockStatusResponse &response); 511 512 /** 513 * @brief Set the SIM card lock state 514 * 515 * @param slotId[in], sim slot id 516 * @param options[in], lock information 517 * @param response[out], the response of set lock state 518 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 519 */ 520 int32_t SetLockState(int32_t slotId, const LockInfo &options, LockStatusResponse &response); 521 522 /** 523 * @brief Obtain the SIM card lock state 524 * 525 * @param slotId[in], sim slot id 526 * @param lockType[in], lock type 527 * @param lockState[out], the response of get lock state 528 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 529 */ 530 int32_t GetLockState(int32_t slotId, LockType lockType, LockState &lockState); 531 532 /** 533 * @brief Refresh the SIM card State 534 * 535 * @param slotId[in], sim slot id 536 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 537 */ 538 int32_t RefreshSimState(int32_t slotId); 539 540 /** 541 * @brief Set the active sim enable or not 542 * 543 * @param slotId[in], sim slot id 544 * @param enable[in], set active sim enable or not 545 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 546 */ 547 int32_t SetActiveSim(const int32_t slotId, int32_t enable); 548 549 /** 550 * @brief Set the active sim enable or not used in satellite 551 * 552 * @param slotId[in], sim slot id 553 * @param enable[in], set active sim enable or not 554 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 555 */ 556 int32_t SetActiveSimSatellite(const int32_t slotId, int32_t enable); 557 558 /** 559 * @brief Obtain the preferred network 560 * 561 * @param slotId[in], sim slot id 562 * @param callback[out], the callback of get preferred network 563 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 564 */ 565 int32_t GetPreferredNetwork(int32_t slotId, const sptr<INetworkSearchCallback> &callback); 566 567 /** 568 * @brief Set the preferred network 569 * 570 * @param slotId[in], sim slot id 571 * @param networkMode[in], the preferred network mode 572 * @param callback[out], the callback of set preferred network 573 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 574 */ 575 int32_t SetPreferredNetwork(int32_t slotId, int32_t networkMode, const sptr<INetworkSearchCallback> &callback); 576 577 /** 578 * @brief Obtain the telephone number of the SIM card 579 * 580 * @param slotId[in], sim slot id 581 * @param telephoneNumber[out], telephone number of the SIM card 582 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 583 */ 584 int32_t GetSimTelephoneNumber(int32_t slotId, std::u16string &telephoneNumber); 585 586 /** 587 * @brief Get network capability 588 * 589 * @param slotId[in], sim slot id 590 * @param networkCapabilityType[in], network capability type 591 * @param networkCapabilityState[out], network capability state 592 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 593 */ 594 int32_t GetNetworkCapability(int32_t slotId, int32_t networkCapabilityType, int32_t &networkCapabilityState); 595 596 /** 597 * @brief Set network capability 598 * 599 * @param slotId[in], sim slot id 600 * @param networkCapabilityType[in], network capability type 601 * @param networkCapabilityState[in], network capability state 602 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 603 */ 604 int32_t SetNetworkCapability(int32_t slotId, int32_t networkCapabilityType, int32_t networkCapabilityState); 605 606 /** 607 * @brief Obtain the voiceMail identifier 608 * 609 * @param slotId[in], sim slot id 610 * @param voiceMailIdentifier[out], voiceMail identifier of the SIM card 611 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 612 */ 613 int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier); 614 615 /** 616 * @brief Obtain the voiceMail number 617 * 618 * @param slotId[in], sim slot id 619 * @param voiceMailNumber[out], voiceMail number of the SIM card 620 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 621 */ 622 int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber); 623 624 /** 625 * @brief Obtain the voiceMail count 626 * 627 * @param slotId[in], sim slot id 628 * @param voiceMailCount[out], voiceMail count of the SIM card 629 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 630 */ 631 int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount); 632 633 /** 634 * @brief Set the voiceMail count 635 * 636 * @param slotId[in], sim slot id 637 * @param voiceMailCount[in], voiceMail count of the SIM card 638 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 639 */ 640 int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount); 641 642 /** 643 * @brief Set the voice call forwarding 644 * 645 * @param slotId[in], sim slot id 646 * @param enable[in], enable voice call forwarding or not 647 * @param number[in], voice call forwarding number 648 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 649 */ 650 int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number); 651 652 /** 653 * @brief Query icc dialling numbers 654 * 655 * @param slotId[in], sim slot id 656 * @param type[in], icc dialling numbers type 657 * @param result[out], vector of icc dialling numbers 658 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 659 */ 660 int32_t QueryIccDiallingNumbers(int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result); 661 662 /** 663 * @brief Add icc dialling numbers 664 * 665 * @param slotId[in], sim slot id 666 * @param type[in], icc dialling number type 667 * @param diallingNumber[in], dialing number information 668 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 669 */ 670 int32_t AddIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber); 671 672 /** 673 * @brief Delete icc dialling numbers 674 * 675 * @param slotId[in], sim slot id 676 * @param type[in], icc dialling number type 677 * @param diallingNumber[in], dialing number information 678 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 679 */ 680 int32_t DelIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber); 681 682 /** 683 * @brief Update icc dialling numbers 684 * 685 * @param slotId[in], sim slot id 686 * @param type[in], icc dialling number type 687 * @param diallingNumber[in], dialing number information 688 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 689 */ 690 int32_t UpdateIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber); 691 692 /** 693 * @brief Set the VoiceMail information 694 * 695 * @param slotId[in], sim slot id 696 * @param mailName[in], VoiceMail name 697 * @param mailNumber[in], VoiceMail number 698 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 699 */ 700 int32_t SetVoiceMailInfo(int32_t slotId, const std::u16string &mailName, const std::u16string &mailNumber); 701 702 /** 703 * @brief Obtain the IMS register status info 704 * 705 * @param slotId[in], sim slot id 706 * @param imsSrvType[in], ims service type 707 * @param info[out], ims register status info 708 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 709 */ 710 int32_t GetImsRegStatus(int32_t slotId, ImsServiceType imsSrvType, ImsRegInfo &info); 711 712 /** 713 * @brief Obtain the maximum number of SIM card slots 714 * 715 * @return int32_t the maximum number of SIM card slots. 716 */ 717 int32_t GetMaxSimCount(); 718 719 /** 720 * @brief Obtain the operator key 721 * 722 * @param slotId[in], sim slot id 723 * @param opkey[out], operator key of the SIM card 724 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 725 */ 726 int32_t GetOpKey(int32_t slotId, std::u16string &opkey); 727 728 /** 729 * @brief Obtain the operator nv identity 730 * 731 * @param slotId[in], sim slot id 732 * @param opkeyExt[out], operator nv identity of the SIM card 733 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 734 */ 735 int32_t GetOpKeyExt(int32_t slotId, std::u16string &opkeyExt); 736 737 /** 738 * @brief Obtain the operator name 739 * 740 * @param slotId[in], sim slot id 741 * @param opname[out], operator name of the SIM card 742 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 743 */ 744 int32_t GetOpName(int32_t slotId, std::u16string &opname); 745 746 /** 747 * @brief Obtain the card type 748 * 749 * @param slotId[in], sim slot id 750 * @param cardType[out], card type of the SIM card 751 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 752 */ 753 int32_t GetCardType(int32_t slotId, CardType &cardType); 754 755 /** 756 * @brief Send envelope command to SIM card 757 * 758 * @param slotId[in], sim slot id 759 * @param cmd[in], envelope command to SIM card 760 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 761 */ 762 int32_t SendEnvelopeCmd(int32_t slotId, const std::string &cmd); 763 764 /** 765 * @brief Send terminal response command to SIM card 766 * 767 * @param slotId[in], sim slot id 768 * @param cmd[in], terminal response command to SIM card 769 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 770 */ 771 int32_t SendTerminalResponseCmd(int32_t slotId, const std::string &cmd); 772 773 /** 774 * @brief Send call setup request result 775 * 776 * @param slotId[in], sim slot id 777 * @param accept[in], whether accept the call setup request 778 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 779 */ 780 int32_t SendCallSetupRequestResult(int32_t slotId, bool accept); 781 782 /** 783 * @brief Unlock sim lock 784 * 785 * @param slotId[in], sim slot id 786 * @param lockInfo[in], customized lock type information 787 * @param response[out], the response of unlock sim lock 788 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 789 */ 790 int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response); 791 792 /** 793 * @brief Check whether your the caller has been granted the operator permissions 794 * 795 * @param slotId[in], sim slot id 796 * @param hasOperatorPrivileges[out], whether your the caller has been granted the operator permissions 797 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 798 */ 799 int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges); 800 801 /** 802 * @brief Performs SIM card authentication 803 * 804 * @param slotId[in], sim slot id 805 * @param aid[in], app id 806 * @param authData[in], authentication data 807 * @param response[out], the response of sim card authentication 808 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 809 */ 810 int32_t SimAuthentication( 811 int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response); 812 813 /** 814 * @brief Obtain the primary slotId 815 * 816 * @param slotId[out], primary slot id 817 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 818 */ 819 int32_t GetPrimarySlotId(int32_t &slotId); 820 821 /** 822 * @brief Set the primary slotId 823 * 824 * @param slotId[in], primary slot id 825 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 826 */ 827 int32_t SetPrimarySlotId(int32_t slotId); 828 829 /** 830 * @brief Obtain the cell information list 831 * 832 * @param slotId[in], primary slot id 833 * @param cellInfo[out], the current cell information of the SIM card 834 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 835 */ 836 int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo); 837 838 /** 839 * @brief Obtain the neighboring cell information list 840 * 841 * @param slotId[in], primary slot id 842 * @param cellInfo[out], the neighboring cell information of the SIM card 843 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 844 */ 845 int32_t GetNeighboringCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo); 846 847 /** 848 * @brief Requests for a cell location update 849 * 850 * @param slotId[in], primary slot id 851 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 852 */ 853 int32_t SendUpdateCellLocationRequest(int32_t slotId); 854 855 /** 856 * @brief Register IMS registry information callback 857 * 858 * @param slotId[in], sim slot id 859 * @param imsSrvType[in], ims service type 860 * @param callback[out], the callback of ims register status info 861 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 862 */ 863 int32_t RegisterImsRegInfoCallback( 864 int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback); 865 866 /** 867 * @brief Unregister IMS registry information callback 868 * 869 * @param slotId[in], sim slot id 870 * @param imsSrvType[in], ims service type 871 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 872 */ 873 int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType); 874 875 /** 876 * @brief Obtain the base band version 877 * 878 * @param slotId[in], sim slot id 879 * @param version[out], the the baseband version of the SIM card 880 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 881 */ 882 int32_t GetBasebandVersion(int32_t slotId, std::string &version); 883 884 /** 885 * @brief Obtain the NR ssb id information 886 * 887 * @param slotId[in], sim slot id 888 * @param nrSsbInfomation[out], the nr ssb information of the SIM card 889 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 890 */ 891 int32_t GetNrSsbIdInfo(int32_t slotId, const std::shared_ptr<NrSsbInformation> &nrSsbInformation); 892 893 /** 894 * @brief Reset all network settings of telephony 895 * 896 * @param slotId[in], sim slot id 897 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 898 */ 899 int32_t FactoryReset(int32_t slotId); 900 901 /** 902 * @brief Check whether insert apn in table. 903 * 904 * @param value[in], apn value 905 * @return return true if need insert, otherwise return false 906 */ 907 bool IsAllowedInsertApn(std::string &value); 908 909 /** 910 * @brief get cust opkey for sim card 911 * 912 * @param slotId[in], sim slot id 913 * @param opkey[out], cust opkey for sim card 914 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 915 */ 916 int32_t GetTargetOpkey(int32_t slotId, std::u16string &opkey); 917 918 /** 919 * @brief get opkey param version 920 * 921 * @param versionInfo[out], opkey param version info 922 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 923 */ 924 int32_t GetOpkeyVersion(std::string &versionInfo); 925 926 /** 927 * @brief get opname param version 928 * 929 * @param versionInfo[out], opname param version info 930 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 931 */ 932 int32_t GetOpnameVersion(std::string &versionInfo); 933 934 /** 935 * @brief Get data from sim io 936 * 937 * @param slotId[in], sim slot id 938 * @param command[in], command id 939 * @param fileId[in], file id 940 * @param dataStr[in], data to be sended 941 * @param path[in], file path 942 * @param response[out], the response of sim io command 943 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 944 */ 945 int32_t GetSimIO(int32_t slotId, int32_t command, int32_t fileId, 946 const std::string &dataStr, const std::string &path, SimAuthenticationResponse &response); 947 948 #ifdef CORE_SERVICE_SUPPORT_ESIM 949 /** 950 * @brief Provide sending upgrade or card binding data to the ESIM channel. 951 * 952 * @param slotId[in], sim slot id 953 * @param aid[in], apud sender 954 * @param apduData[in], apud data 955 * @param responseResult[out], return the result of execute one apdu 956 * @return int32_t TELEPHONY_SUCCESS on success, others on failure. 957 */ 958 int32_t SendApduData( 959 int32_t slotId, const std::u16string &aid, const EsimApduData &apduData, ResponseEsimResult &responseResult); 960 #endif 961 962 private: 963 void RemoveDeathRecipient(const wptr<IRemoteObject> &remote, bool isRemoteDied); 964 class CoreServiceDeathRecipient : public IRemoteObject::DeathRecipient { 965 public: CoreServiceDeathRecipient(CoreServiceClient & client)966 explicit CoreServiceDeathRecipient(CoreServiceClient &client) : client_(client), isValid_(true) {} 967 ~CoreServiceDeathRecipient() override = default; OnRemoteDied(const wptr<IRemoteObject> & remote)968 __attribute__((no_sanitize("cfi"))) void OnRemoteDied(const wptr<IRemoteObject> &remote) override 969 { 970 if (isValid_.load()) { 971 client_.OnRemoteDied(remote); 972 } 973 } 974 SetValid(bool isValid)975 void SetValid(bool isValid) 976 { 977 isValid_.store(isValid); 978 } 979 980 private: 981 CoreServiceClient &client_; 982 std::atomic_bool isValid_; 983 }; 984 985 private: 986 std::mutex mutexProxy_; 987 sptr<ICoreService> proxy_ { nullptr }; 988 sptr<IRemoteObject::DeathRecipient> deathRecipient_ { nullptr }; 989 }; 990 } // namespace Telephony 991 } // namespace OHOS 992 #endif // CORE_SERVICE_CLIENT_H 993