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