• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 "hril_types.h"
23 #include "hril_call_parcel.h"
24 #include "module_service_utils.h"
25 #include "supplement_request.h"
26 #include "telephony_log_wrapper.h"
27 
28 namespace OHOS {
29 namespace Telephony {
30 class CellularCallSupplement {
31 public:
32     /**
33      * Deal Clip
34      *
35      * 3GPP TS 22.030 V4.0.0 (2001-03)  6.5.6.2	Calling Line Identification Presentation (CLIP)
36      * The CLIP Supplementary Service is defined in GSM 02.81[12]
37      * 3GPP TS 22.030 V4.0.0 (2001-03) Annex B (normative):Codes for defined Supplementary Services
38      *
39      * @param slotId
40      * @param MMIData
41      */
42     void GetClip(int32_t slotId, const MMIData &mmiData);
43 
44     /**
45      * Deal Clir
46      *
47      * 3GPP TS 22.081 V4.0.0 (2001-03) 2 Calling Line Identification Restriction (CLIR)
48      * 3GPP TS 22.030 V4.0.0 (2001-03) Annex B (normative):Codes for defined Supplementary Services
49      *
50      * @param slotId
51      * @param MMIData
52      */
53     void GetClir(int32_t slotId, const MMIData &mmiData);
54 
55     /**
56      * Deal Call Transfer
57      *
58      * 3GPP TS 22.030 V4.0.0 (2001-03)
59      * 3GPP TS 22.030 V4.0.0 (2001-03) Annex B (normative):Codes for defined Supplementary Services
60      *
61      * @param slotId
62      * @param MMIData
63      */
64     void DealCallTransfer(int32_t slotId, const MMIData &mmiData);
65 
66     /**
67      * Set Call Transfer
68      *
69      * 27007-430_2001 7.11 Call forwarding number and conditions +CCFC
70      * 3GPP TS 22.082 [4]
71      * Control of the call forwarding supplementary service
72      *
73      * @param slotId
74      * @param CallTransferInfo
75      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
76      */
77     int32_t SetCallTransferInfo(int32_t slotId, const CallTransferInfo &cTInfo);
78 
79     /**
80      * Inquire Call Transfer
81      *
82      * 27007-430_2001 7.11 Call forwarding number and conditions +CCFC
83      * 3GPP TS 22.082 [4]
84      * Control of the call forwarding supplementary service
85      *
86      * @param slotId
87      * @param CallTransferType
88      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
89      */
90     int32_t GetCallTransferInfo(int32_t slotId, CallTransferType type);
91 
92     /**
93      * Deal Call Restriction
94      *
95      * 3GPP TS 22.088 [6] 1	Barring of outgoing calls
96      * 3GPP TS 22.088 [6] 2	Barring of incoming calls
97      *
98      * @param slotId
99      * @param MMIData
100      */
101     void DealCallRestriction(int32_t slotId, const MMIData &mmiData);
102 
103     /**
104      * Set Call Restriction
105      *
106      * 27007-430_2001 7.4	Facility lock +CLCK
107      * 3GPP TS 22.088 [6] 1	Barring of outgoing calls
108      * 3GPP TS 22.088 [6] 2	Barring of incoming calls
109      *
110      * Control of the call barring supplementary service
111      *
112      * @param slotId
113      * @param CallRestrictionInfo
114      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
115      */
116     int32_t SetCallRestriction(int32_t slotId, const CallRestrictionInfo &cRInfo);
117 
118     /**
119      * Inquire Call Restriction
120      *
121      * 27007-430_2001 7.4	Facility lock +CLCK
122      * 3GPP TS 22.088 [6] 1	Barring of outgoing calls
123      * 3GPP TS 22.088 [6] 2	Barring of incoming calls
124      *
125      * Control of the call barring supplementary service
126      *
127      * @param slotId
128      * @param CallRestrictionType
129      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
130      */
131     int32_t GetCallRestriction(int32_t slotId, CallRestrictionType facType);
132 
133     /**
134      * Deal Call Waiting
135      *
136      * 27007-430_2001 7.12	Call waiting +CCWA
137      * 3GPP TS 22.083 [5] 1	Call waiting (CW)
138      *
139      * @param slotId
140      * Deal Call Waiting
141      * @param MMIData
142      */
143     void DealCallWaiting(int32_t slotId, const MMIData &mmiData);
144 
145     /**
146      * Set Call Waiting
147      *
148      * 27007-430_2001 7.12	Call waiting +CCWA
149      * 3GPP TS 22.083 [5] 1	Call waiting (CW)
150      *
151      * Control of the Call Waiting supplementary service
152      *
153      * @param slotId
154      * @param activate
155      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
156      */
157     int32_t SetCallWaiting(int32_t slotId, bool activate);
158 
159     /**
160      * Inquire Call Waiting
161      *
162      * 27007-430_2001 7.12	Call waiting +CCWA
163      * 3GPP TS 22.083 [5] 1	Call waiting (CW)
164      *
165      * Control of the Call Waiting supplementary service
166      *
167      * @param slotId
168      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
169      */
170     int32_t GetCallWaiting(int32_t slotId);
171 
172     /**
173      * Send Ussd msg
174      *
175      * 22.090 Unstructured Supplementary Service Data (USSD); Stage 1
176      * 23.090 Unstructured Supplementary Service Data (USSD); Stage 2
177      * 24.090 Unstructured Supplementary Service Data (USSD); Stage 3
178      *
179      * Control of the Ussd supplementary service
180      *
181      * @param slotId
182      * @return Returns TELEPHONY_SUCCESS on success, others on failure.
183      */
184     int32_t SendUssd(int32_t slotId, const std::string &msg);
185 
186     /**
187      * Event Set Pin Puk
188      *
189      * @param PinPukResponse
190      */
191     void EventSetPinPuk(const PinPukResponse &pinPukResponse);
192 
193     /**
194      * SIM PIN unlock
195      *
196      * @param slotId
197      * @param mmiData
198      * @return Returns true on success.
199      */
200     void AlterPinPassword(int32_t slotId, const MMIData &mmiData);
201 
202     /**
203      * SIM PUK unlock
204      *
205      * @param slotId
206      * @param mmiData
207      * @return Returns true on success.
208      */
209     void UnlockPuk(int32_t slotId, const MMIData &mmiData);
210 
211     /**
212      * SIM PIN2 unlock
213      *
214      * @param slotId
215      * @param mmiData
216      * @return Returns true on success.
217      */
218     void AlterPin2Password(int32_t slotId, const MMIData &mmiData);
219 
220     /**
221      * SIM PUK2 unlock
222      *
223      * @param slotId
224      * @param mmiData
225      * @return Returns true on success.
226      */
227     void UnlockPuk2(int32_t slotId, const MMIData &mmiData);
228 
229     /**
230      * Event Deal clip Mmi
231      *
232      * 3GPP TS 27.007 V3.9.0 (2001-06) 7.6	Calling line identification presentation +CLIP
233      *
234      * @param GetClipResult
235      */
236     void EventGetClip(GetClipResult &getClipResult);
237 
238     /**
239      * Event Deal Clir Mmi
240      *
241      * 3GPP TS 27.007 V3.9.0 (2001-06) 7.7	Calling line identification restriction +CLIR
242      *
243      * @param GetClirResult
244      */
245     void EventGetClir(GetClirResult &result);
246 
247     /**
248      * Event set Clir Mmi
249      *
250      * 3GPP TS 27.007 V3.9.0 (2001-06) 7.7	Calling line identification restriction +CLIR
251      *
252      * @param HRilRadioResponseInfo
253      */
254     void EventSetClir(HRilRadioResponseInfo &info);
255 
256     /**
257      * GetCallRestriction result
258      *
259      * 3GPP TS 27.007 V3.9.0 (2001-06) 7.4	Facility lock +CLCK
260      *
261      * @param CallRestrictionResult
262      */
263     void EventGetCallRestriction(const CallRestrictionResult &result);
264 
265     /**
266      * SetCallRestriction result
267      *
268      * 3GPP TS 27.007 V3.9.0 (2001-06) 7.4	Facility lock +CLCK
269      *
270      * @param HRilRadioResponseInfo
271      */
272     void EventSetCallRestriction(HRilRadioResponseInfo &info);
273 
274     /**
275      * Call Waiting result
276      *
277      * 3GPP TS 27.007 V3.9.0 (2001-06) 7.12	Call waiting +CCWA
278      * status: 0	not active;  1	active
279      *
280      * @param CallWaitResult waitingInfo
281      */
282     void EventGetCallWaiting(CallWaitResult &waitingInfo);
283 
284     /**
285      * Event Set CallWaiting
286      *
287      * 3GPP TS 27.007 V3.9.0 (2001-06) 7.12	Call waiting +CCWA
288      *
289      * @param HRilRadioResponseInfo
290      */
291     void EventSetCallWaiting(HRilRadioResponseInfo &responseInfo);
292 
293     /**
294      * Event Inquire Call Transfer
295      *
296      * 3GPP TS 27.007 V3.9.0 (2001-06) 7.11	Call forwarding number and conditions +CCFC
297      *
298      * @param CallForwardQueryInfoList
299      */
300     void EventGetCallTransferInfo(CallForwardQueryInfoList &cFQueryList);
301 
302     /**
303      * Event Set Call Transfer
304      *
305      * 3GPP TS 27.007 V3.9.0 (2001-06) 7.11	Call forwarding number and conditions +CCFC
306      *
307      * @param HRilRadioResponseInfo
308      */
309     void EventSetCallTransferInfo(HRilRadioResponseInfo &responseInfo);
310 
311     /**
312      * Event Send Ussd
313      *
314      * 3GPP TS 3GPP TS 22.030 V16.0.0 (2020-07) 6.5	Supplementary Services Control
315      *
316      * @param HRilRadioResponseInfo
317      */
318     void EventSendUssd(HRilRadioResponseInfo &responseInfo);
319 
320     /**
321      * Event Ss Notify
322      *
323      * @param SsNoticeInfo
324      */
325     void EventSsNotify(SsNoticeInfo &ssNoticeInfo);
326 
327     /**
328      * Event Ussd Notify
329      *
330      * @param UssdNoticeInfo
331      */
332     void EventUssdNotify(UssdNoticeInfo &ussdNoticeInfo);
333 
334 private:
335     /**
336      * Obtain ServiceCode
337      *
338      * @param serviceInfoB
339      * @return ServiceClassType
340      */
341     int32_t ObtainServiceCode(const std::string &serviceInfoB);
342 
343     /**
344      * Obtain Cause
345      *
346      * 3GPP TS 22.030 V4.0.0 (2001-03) Annex B (normative): Codes for defined Supplementary Services
347      *
348      * @param basicString
349      * @return CallTransferType
350      */
351     int32_t ObtainCause(const std::string &serviceInfoC);
352 
353     /**
354      * Obtain Barring Installation
355      *
356      * 27007-430_2001 7.4	Facility lock +CLCK
357      * 3GPP TS 22.088 [6] 1	Barring of outgoing calls
358      * 3GPP TS 22.088 [6] 2	Barring of incoming calls
359      *
360      * @param serviceInfoC
361      * @return Barring type
362      */
363     std::string ObtainBarringInstallation(const std::string &serviceInfoC);
364 
365     /**
366      * Is Phone Gsm Type
367      *
368      * @param slotId
369      * @return bool
370      */
371     bool PhoneTypeGsmOrNot(int32_t slotId);
372 
373     /**
374      * Get Message
375      *
376      * @param MmiCodeInfo
377      * @param SsNoticeInfo
378      */
379     void GetMessage(MmiCodeInfo &mmiCodeInfo, const SsNoticeInfo &ssNoticeInfo);
380 
381 private:
382     void BuildCallForwardQueryInfo(const CallForwardQueryResult &queryResult);
383     void ReportMmiCodeMessage(int32_t result, const std::string successMsg, const std::string failedMsg);
384     bool IsVaildPinOrPuk(std::string newPinOrPuk, std::string newPinOrPukCheck);
385 
386 private:
387     SupplementRequest supplementRequest_;
388     ModuleServiceUtils moduleServiceUtils_;
389 };
390 } // namespace Telephony
391 } // namespace OHOS
392 #endif // CELLULAR_CALL_SUPPLEMENT_H
393