• 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_HANDLER_H
17 #define CELLULAR_CALL_HANDLER_H
18 
19 #include <memory>
20 
21 #include "cellular_call_data_struct.h"
22 #include "telephony_log_wrapper.h"
23 #include "cs_control.h"
24 #include "ims_control.h"
25 #include "cellular_call_register.h"
26 
27 namespace OHOS {
28 namespace Telephony {
29 class CellularCallHandler : public AppExecFwk::EventHandler {
30 public:
31     /**
32      * CellularCallHandler constructor
33      *
34      * @param runner
35      * @param server
36      */
37     explicit CellularCallHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner);
38 
39     /**
40      * ~CellularCallHandler destructor
41      */
42     ~CellularCallHandler() = default;
43 
44     /**
45      * ProcessEvent.
46      *
47      * @param CellularCallRadioResponseEvent, Process Radio Response Event .
48      */
49     void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
50 
51     /**
52      * Set Slot Id
53      *
54      * @param id
55      */
56     void SetSlotId(int32_t id);
57 
58     /**
59      * Get Slot Id
60      * @return id
61      */
62     int32_t GetSlotId();
63 
64     /**
65      * DialResponse
66      *
67      * @param code process
68      */
69     void DialResponse(const AppExecFwk::InnerEvent::Pointer &event);
70 
71     /**
72      * CommonResultResponse
73      *
74      * @param code process
75      */
76     void CommonResultResponse(const AppExecFwk::InnerEvent::Pointer &event);
77 
78     /**
79      * SendDtmfResponse
80      *
81      * @param code process
82      */
83     void SendDtmfResponse(const AppExecFwk::InnerEvent::Pointer &event);
84 
85     /**
86      * StartDtmfResponse
87      *
88      * @param code process
89      */
90     void StartDtmfResponse(const AppExecFwk::InnerEvent::Pointer &event);
91 
92     /**
93      * StopDtmfResponse
94      *
95      * @param code process
96      */
97     void StopDtmfResponse(const AppExecFwk::InnerEvent::Pointer &event);
98 
99     /**
100      * GetCsCallsDataResponse
101      *
102      * @param code process
103      */
104     void GetCsCallsDataResponse(const AppExecFwk::InnerEvent::Pointer &event);
105 
106     /**
107      * GetImsCallsDataResponse
108      *
109      * @param code process
110      */
111     void GetImsCallsDataResponse(const AppExecFwk::InnerEvent::Pointer &event);
112 
113     /**
114      * CallStatusInfoResponse
115      *
116      * @param code process
117      */
118     void CallStatusInfoResponse(const AppExecFwk::InnerEvent::Pointer &event);
119 
120     /**
121      * CallImsServiceStatusResponse
122      *
123      * @param code process
124      */
125     void CallImsServiceStatusResponse(const AppExecFwk::InnerEvent::Pointer &event);
126 
127     /**
128      * SetDomainPreferenceModeResponse
129      *
130      * @param code process
131      */
132     void SetDomainPreferenceModeResponse(const AppExecFwk::InnerEvent::Pointer &event);
133 
134     /**
135      * GetDomainPreferenceModeResponse
136      *
137      * @param code process
138      */
139     void GetDomainPreferenceModeResponse(const AppExecFwk::InnerEvent::Pointer &event);
140 
141     /**
142      * SetLteImsSwitchStatusResponse
143      *
144      * @param code process
145      */
146     void SetLteImsSwitchStatusResponse(const AppExecFwk::InnerEvent::Pointer &event);
147 
148     /**
149      * GetLteImsSwitchStatusResponse
150      *
151      * @param code process
152      */
153     void GetLteImsSwitchStatusResponse(const AppExecFwk::InnerEvent::Pointer &event);
154 
155     /**
156      * UssdNotifyResponse
157      *
158      * @param code process
159      */
160     void UssdNotifyResponse(const AppExecFwk::InnerEvent::Pointer &event);
161 
162     /**
163      * CallRingBackVoiceResponse
164      *
165      * @param code process
166      */
167     void CallRingBackVoiceResponse(const AppExecFwk::InnerEvent::Pointer &event);
168 
169     /**
170      * SetMuteResponse
171      *
172      * @param code process
173      */
174     void SetMuteResponse(const AppExecFwk::InnerEvent::Pointer &event);
175 
176     /**
177      * GetMuteResponse
178      *
179      * @param code process
180      */
181     void GetMuteResponse(const AppExecFwk::InnerEvent::Pointer &event);
182 
183     /**
184      * GetEmergencyCallListResponse
185      *
186      * @param code process
187      */
188     void GetEmergencyCallListResponse(const AppExecFwk::InnerEvent::Pointer &event);
189 
190     /**
191      * GetCallFailReasonResponse
192      *
193      * @param code process
194      */
195     void GetCallFailReasonResponse(const AppExecFwk::InnerEvent::Pointer &event);
196 
197     /**
198      * Set CallType
199      *
200      * @param callType
201      */
202     void SetCallType(CallType callType);
203 
204     /**
205      * Update Srvcc State Report
206      *
207      * @param AppExecFwk::InnerEvent::Pointer
208      */
209     void UpdateSrvccStateReport(const AppExecFwk::InnerEvent::Pointer &event);
210 
211     /**
212      * SrvccState Completed
213      */
214     void SrvccStateCompleted();
215 
216 public:
217     const uint32_t REGISTER_HANDLER_ID = 1002;
218     const uint32_t REGISTER_IMS_CALLBACK_ID = 1003;
219     int32_t srvccState_ = SrvccState::SRVCC_NONE;
220 
221 private:
222     /**
223      * Prevent violent requests
224      * @return bool
225      */
226     bool IsCanRequestCallsData();
227 
228     /**
229      * Current Time Millis
230      * @return int64_t Time Millis
231      */
232     int64_t CurrentTimeMillis();
233 
234     /**
235      * GetCsCallData
236      */
237     void GetCsCallData(const AppExecFwk::InnerEvent::Pointer &event);
238 
239     /**
240      * GetImsCallData
241      */
242     void GetImsCallData(const AppExecFwk::InnerEvent::Pointer &event);
243 
244     /**
245      * DealCsCallsDataRequest
246      */
247     void GetCsCallsDataRequest(const AppExecFwk::InnerEvent::Pointer &event);
248 
249     /**
250      * GetImsCallsDataRequest.
251      *
252      * @param code process
253      */
254     void GetImsCallsDataRequest(const AppExecFwk::InnerEvent::Pointer &event);
255 
256     /**
257      * Register Handler
258      */
259     void RegisterHandler(const AppExecFwk::InnerEvent::Pointer &event);
260 
261     /**
262      * Register Ims Callback
263      */
264     void RegisterImsCallback(const AppExecFwk::InnerEvent::Pointer &event);
265 
266     /**
267      * GetMMIResponse
268      *
269      * @param AppExecFwk::InnerEvent::Pointer
270      */
271     void GetMMIResponse(const AppExecFwk::InnerEvent::Pointer &event);
272 
273     /**
274      * GetCallWaitingResponse
275      *
276      * @param AppExecFwk::InnerEvent::Pointer
277      */
278     void GetCallWaitingResponse(const AppExecFwk::InnerEvent::Pointer &event);
279 
280     /**
281      * SetCallWaitingResponse
282      *
283      * @param AppExecFwk::InnerEvent::Pointer
284      */
285     void SetCallWaitingResponse(const AppExecFwk::InnerEvent::Pointer &event);
286 
287     /**
288      * GetClirResponse
289      *
290      * @param AppExecFwk::InnerEvent::Pointer
291      */
292     void GetClirResponse(const AppExecFwk::InnerEvent::Pointer &event);
293 
294     /**
295      * SetClirResponse
296      *
297      * @param AppExecFwk::InnerEvent::Pointer
298      */
299     void SetClirResponse(const AppExecFwk::InnerEvent::Pointer &event);
300 
301     /**
302      * GetClipResponse
303      *
304      * @param AppExecFwk::InnerEvent::Pointer
305      */
306     void GetClipResponse(const AppExecFwk::InnerEvent::Pointer &event);
307 
308     /**
309      * GetCallTransferResponse
310      *
311      * @param AppExecFwk::InnerEvent::Pointer
312      */
313     void GetCallTransferResponse(const AppExecFwk::InnerEvent::Pointer &event);
314 
315     /**
316      * SetCallTransferInfoResponse
317      *
318      * @param AppExecFwk::InnerEvent::Pointer
319      */
320     void SetCallTransferInfoResponse(const AppExecFwk::InnerEvent::Pointer &event);
321 
322     /**
323      * GetCallRestrictionResponse
324      *
325      * @param AppExecFwk::InnerEvent::Pointer
326      */
327     void GetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer &event);
328 
329     /**
330      * SetCallRestrictionResponse
331      *
332      * @param AppExecFwk::InnerEvent::Pointer
333      */
334     void SetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer &event);
335 
336     /**
337      * SendUssdResponse
338      *
339      * @param AppExecFwk::InnerEvent::Pointer
340      */
341     void SendUssdResponse(const AppExecFwk::InnerEvent::Pointer &event);
342 
343     /**
344      * InitBasicFuncMap
345      */
346     void InitBasicFuncMap();
347 
348     /**
349      * InitConfigFuncMap
350      */
351     void InitConfigFuncMap();
352 
353     /**
354      * InitSupplementFuncMap
355      */
356     void InitSupplementFuncMap();
357 
358     /**
359      * InitActiveReportFuncMap
360      */
361     void InitActiveReportFuncMap();
362 
363     /**
364      * ReportCsCallsData
365      *
366      * @param CallInfoList
367      */
368     void ReportCsCallsData(const CallInfoList &callInfoList);
369 
370     /**
371      * ReportImsCallsData
372      *
373      * @param CallInfoList
374      */
375     void ReportImsCallsData(const CallInfoList &imsCallInfoList);
376 
377 private:
378     int32_t slotId_ = DEFAULT_SIM_SLOT_ID;
379     int64_t lastTime_ = 0L;
380     const int64_t FAST_DELAY_TIME = 250;
381     int64_t lastCallsDataFlag_ = 0L;
382     const uint32_t GET_CS_CALL_DATA_ID = 10001;
383     const uint32_t GET_IMS_CALL_DATA_ID = 10002;
384     int64_t delayTime_ = 100;
385     using RequestFuncType = void (CellularCallHandler::*)(const AppExecFwk::InnerEvent::Pointer &event);
386     std::map<uint32_t, RequestFuncType> requestFuncMap_;
387     CallType callType_ = CallType::TYPE_ERR_CALL;
388     std::shared_ptr<CellularCallRegister> registerInstance_ = DelayedSingleton<CellularCallRegister>::GetInstance();
389 };
390 } // namespace Telephony
391 } // namespace OHOS
392 
393 #endif
394