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