• 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 #include "cellular_call_connection_cs.h"
17 
18 #include "cellular_call_hisysevent.h"
19 #include "cellular_call_service.h"
20 #include "radio_event.h"
21 
22 namespace OHOS {
23 namespace Telephony {
DialRequest(int32_t slotId,const DialRequestStruct & dialRequest)24 int32_t CellularCallConnectionCS::DialRequest(int32_t slotId, const DialRequestStruct &dialRequest)
25 {
26     TELEPHONY_LOGI("CellularCallConnectionCS::DialRequest start.");
27     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
28         TELEPHONY_LOGE("DialRequest return, error type: GetInstance() is nullptr.");
29         CellularCallHiSysEvent::WriteDialCallFaultEvent(
30             slotId, INVALID_PARAMETER, INVALID_PARAMETER, CALL_ERR_RESOURCE_UNAVAILABLE, "cellular service is nullptr");
31         return CALL_ERR_RESOURCE_UNAVAILABLE;
32     }
33     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
34     if (handle == nullptr) {
35         TELEPHONY_LOGE("DialRequest return, error type: handle is nullptr.");
36         CellularCallHiSysEvent::WriteDialCallFaultEvent(slotId, INVALID_PARAMETER, INVALID_PARAMETER,
37             CALL_ERR_RESOURCE_UNAVAILABLE, "cellular service handle is nullptr");
38         return CALL_ERR_RESOURCE_UNAVAILABLE;
39     }
40     CoreManagerInner::GetInstance().Dial(
41         slotId, RadioEvent::RADIO_DIAL, dialRequest.phoneNum, dialRequest.clirMode, handle);
42     return TELEPHONY_SUCCESS;
43 }
44 
HangUpRequest(int32_t slotId)45 int32_t CellularCallConnectionCS::HangUpRequest(int32_t slotId)
46 {
47     TELEPHONY_LOGI("CellularCallConnectionCS::HangUpRequest start.");
48     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
49         TELEPHONY_LOGE("HangUpRequest return, error type: GetInstance() is nullptr.");
50         CellularCallHiSysEvent::WriteHangUpFaultEvent(
51             slotId, INVALID_PARAMETER, CALL_ERR_RESOURCE_UNAVAILABLE, "cellular service is nullptr");
52         return CALL_ERR_RESOURCE_UNAVAILABLE;
53     }
54     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
55     if (handle == nullptr) {
56         TELEPHONY_LOGE("HangUpRequest return, error type: handle is nullptr.");
57         CellularCallHiSysEvent::WriteHangUpFaultEvent(
58             slotId, INVALID_PARAMETER, CALL_ERR_RESOURCE_UNAVAILABLE, "cellular service handle is nullptr");
59         return CALL_ERR_RESOURCE_UNAVAILABLE;
60     }
61     int32_t index = GetIndex();
62     CoreManagerInner::GetInstance().Hangup(slotId, RadioEvent::RADIO_HANGUP_CONNECT, index, handle);
63     return TELEPHONY_SUCCESS;
64 }
65 
AnswerRequest(int32_t slotId)66 int32_t CellularCallConnectionCS::AnswerRequest(int32_t slotId)
67 {
68     TELEPHONY_LOGI("CellularCallConnectionCS::AnswerRequest start.");
69     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
70         TELEPHONY_LOGE("AnswerRequest return, error type: GetInstance() is nullptr.");
71         CellularCallHiSysEvent::WriteAnswerCallFaultEvent(
72             slotId, INVALID_PARAMETER, INVALID_PARAMETER, CALL_ERR_RESOURCE_UNAVAILABLE, "cellular service is nullptr");
73         return CALL_ERR_RESOURCE_UNAVAILABLE;
74     }
75     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
76     if (handle == nullptr) {
77         TELEPHONY_LOGE("AnswerRequest return, error type: handle is nullptr.");
78         CellularCallHiSysEvent::WriteAnswerCallFaultEvent(slotId, INVALID_PARAMETER, INVALID_PARAMETER,
79             CALL_ERR_RESOURCE_UNAVAILABLE, "cellular service handle is nullptr");
80         return CALL_ERR_RESOURCE_UNAVAILABLE;
81     }
82     CoreManagerInner::GetInstance().Answer(slotId, RadioEvent::RADIO_ACCEPT_CALL, handle);
83     return TELEPHONY_SUCCESS;
84 }
85 
RejectRequest(int32_t slotId)86 int32_t CellularCallConnectionCS::RejectRequest(int32_t slotId)
87 {
88     TELEPHONY_LOGI("CellularCallConnectionCS::RejectRequest start.");
89     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
90         TELEPHONY_LOGE("RejectRequest return, error type: GetInstance() is nullptr.");
91         CellularCallHiSysEvent::WriteHangUpFaultEvent(
92             slotId, INVALID_PARAMETER, CALL_ERR_RESOURCE_UNAVAILABLE, "cellular service is nullptr");
93         return CALL_ERR_RESOURCE_UNAVAILABLE;
94     }
95     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
96     if (handle == nullptr) {
97         TELEPHONY_LOGE("RejectRequest return, error type: handle is nullptr.");
98         CellularCallHiSysEvent::WriteHangUpFaultEvent(
99             slotId, INVALID_PARAMETER, CALL_ERR_RESOURCE_UNAVAILABLE, "cellular service handle is nullptr");
100         return CALL_ERR_RESOURCE_UNAVAILABLE;
101     }
102     CoreManagerInner::GetInstance().Reject(slotId, RadioEvent::RADIO_REJECT_CALL, handle);
103     return TELEPHONY_SUCCESS;
104 }
105 
HoldRequest(int32_t slotId)106 int32_t CellularCallConnectionCS::HoldRequest(int32_t slotId)
107 {
108     TELEPHONY_LOGI("CellularCallConnectionCS::HoldRequest start.");
109     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
110         TELEPHONY_LOGE("HoldRequest return, error type: GetInstance() is nullptr.");
111         return CALL_ERR_RESOURCE_UNAVAILABLE;
112     }
113     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
114     if (handle == nullptr) {
115         TELEPHONY_LOGE("HoldRequest return, error type: handle is nullptr.");
116         return CALL_ERR_RESOURCE_UNAVAILABLE;
117     }
118     CoreManagerInner::GetInstance().HoldCall(slotId, RadioEvent::RADIO_HOLD_CALL, handle);
119     return TELEPHONY_SUCCESS;
120 }
121 
UnHoldCallRequest(int32_t slotId)122 int32_t CellularCallConnectionCS::UnHoldCallRequest(int32_t slotId)
123 {
124     TELEPHONY_LOGI("CellularCallConnectionCS::UnHoldCallRequest start.");
125     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
126         TELEPHONY_LOGE("UnHoldCallRequest return, error type: GetInstance() is nullptr.");
127         return CALL_ERR_RESOURCE_UNAVAILABLE;
128     }
129     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
130     if (handle == nullptr) {
131         TELEPHONY_LOGE("UnHoldCallRequest return, error type: handle is nullptr.");
132         return CALL_ERR_RESOURCE_UNAVAILABLE;
133     }
134     CoreManagerInner::GetInstance().UnHoldCall(slotId, RadioEvent::RADIO_ACTIVE_CALL, handle);
135     return TELEPHONY_SUCCESS;
136 }
137 
SwitchCallRequest(int32_t slotId)138 int32_t CellularCallConnectionCS::SwitchCallRequest(int32_t slotId)
139 {
140     TELEPHONY_LOGI("CellularCallConnectionCS::SwitchCallRequest start.");
141     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
142         TELEPHONY_LOGE("SwitchCallRequest return, error type: GetInstance() is nullptr.");
143         return CALL_ERR_RESOURCE_UNAVAILABLE;
144     }
145     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
146     if (handle == nullptr) {
147         TELEPHONY_LOGE("SwitchCallRequest return, error type: handle is nullptr.");
148         return CALL_ERR_RESOURCE_UNAVAILABLE;
149     }
150     CoreManagerInner::GetInstance().SwitchCall(slotId, RadioEvent::RADIO_SWAP_CALL, handle);
151     return TELEPHONY_SUCCESS;
152 }
153 
CombineConferenceRequest(int32_t slotId,int32_t voiceCall)154 int32_t CellularCallConnectionCS::CombineConferenceRequest(int32_t slotId, int32_t voiceCall)
155 {
156     TELEPHONY_LOGI("CellularCallConnectionCS::CombineConferenceRequest start.");
157     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
158         TELEPHONY_LOGE("CombineConferenceRequest return, error type: GetInstance() is nullptr.");
159         return CALL_ERR_RESOURCE_UNAVAILABLE;
160     }
161     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
162     if (handle == nullptr) {
163         TELEPHONY_LOGE("CombineConferenceRequest return, error type: handle is nullptr.");
164         return CALL_ERR_RESOURCE_UNAVAILABLE;
165     }
166     CoreManagerInner::GetInstance().CombineConference(slotId, RadioEvent::RADIO_JOIN_CALL, voiceCall, handle);
167     return TELEPHONY_SUCCESS;
168 }
169 
SeparateConferenceRequest(int32_t slotId,int32_t index,int32_t voiceCall)170 int32_t CellularCallConnectionCS::SeparateConferenceRequest(int32_t slotId, int32_t index, int32_t voiceCall)
171 {
172     TELEPHONY_LOGI("CellularCallConnectionCS::SeparateConferenceRequest start.");
173     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
174         TELEPHONY_LOGE("SeparateConferenceRequest return, error type: GetInstance() is nullptr.");
175         return CALL_ERR_RESOURCE_UNAVAILABLE;
176     }
177     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
178     if (handle == nullptr) {
179         TELEPHONY_LOGE("SeparateConferenceRequest return, error type: handle is nullptr.");
180         return CALL_ERR_RESOURCE_UNAVAILABLE;
181     }
182     CoreManagerInner::GetInstance().SeparateConference(slotId, RadioEvent::RADIO_SPLIT_CALL, index, voiceCall, handle);
183     return TELEPHONY_SUCCESS;
184 }
185 
CallSupplementRequest(int32_t slotId,CallSupplementType type)186 int32_t CellularCallConnectionCS::CallSupplementRequest(int32_t slotId, CallSupplementType type)
187 {
188     TELEPHONY_LOGI("CellularCallConnectionCS::CallSupplementRequest start.");
189     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
190         TELEPHONY_LOGE("CallSupplementRequest return, error type: GetInstance() is nullptr.");
191         return CALL_ERR_RESOURCE_UNAVAILABLE;
192     }
193     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
194     if (handle == nullptr) {
195         TELEPHONY_LOGE("CallSupplementRequest return, error type: handle is nullptr.");
196         return CALL_ERR_RESOURCE_UNAVAILABLE;
197     }
198     CoreManagerInner::GetInstance().CallSupplement(slotId, RadioEvent::RADIO_CALL_SUPPLEMENT, type, handle);
199     return TELEPHONY_SUCCESS;
200 }
201 
SendCDMAThreeWayDialRequest(int32_t slotId)202 int32_t CellularCallConnectionCS::SendCDMAThreeWayDialRequest(int32_t slotId)
203 {
204     TELEPHONY_LOGI("CellularCallConnectionCS::SendCDMAThreeWayDialRequest start.");
205     return TELEPHONY_SUCCESS;
206 }
207 
SendDtmfRequest(int32_t slotId,char cDtmfCode,int32_t index) const208 int32_t CellularCallConnectionCS::SendDtmfRequest(int32_t slotId, char cDtmfCode, int32_t index) const
209 {
210     TELEPHONY_LOGI("CellularCallConnectionCS::SendDtmfRequest start.");
211     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
212         TELEPHONY_LOGE("SendDtmfRequest return, error type: GetInstance() is nullptr.");
213         return CALL_ERR_RESOURCE_UNAVAILABLE;
214     }
215     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
216     if (handle == nullptr) {
217         TELEPHONY_LOGE("SendDtmfRequest return, error type: handle is nullptr.");
218         return CALL_ERR_RESOURCE_UNAVAILABLE;
219     }
220     CoreManagerInner::GetInstance().SendDTMF(slotId, RadioEvent::RADIO_SEND_DTMF, cDtmfCode, index, handle);
221     return TELEPHONY_SUCCESS;
222 }
223 
StartDtmfRequest(int32_t slotId,char cDtmfCode,int32_t index) const224 int32_t CellularCallConnectionCS::StartDtmfRequest(int32_t slotId, char cDtmfCode, int32_t index) const
225 {
226     TELEPHONY_LOGI("CellularCallConnectionCS::StartDtmfRequest start.");
227     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
228         TELEPHONY_LOGE("StartDtmfRequest return, error type: GetInstance() is nullptr.");
229         return CALL_ERR_RESOURCE_UNAVAILABLE;
230     }
231     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
232     if (handle == nullptr) {
233         TELEPHONY_LOGE("StartDtmfRequest return, error type: handle is nullptr.");
234         return CALL_ERR_RESOURCE_UNAVAILABLE;
235     }
236     CoreManagerInner::GetInstance().StartDTMF(slotId, RadioEvent::RADIO_START_DTMF, cDtmfCode, index, handle);
237     return TELEPHONY_SUCCESS;
238 }
239 
StopDtmfRequest(int32_t slotId,int32_t index) const240 int32_t CellularCallConnectionCS::StopDtmfRequest(int32_t slotId, int32_t index) const
241 {
242     TELEPHONY_LOGI("CellularCallConnectionCS::StopDtmfRequest start.");
243     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
244         TELEPHONY_LOGE("StopDtmfRequest return, error type: GetInstance() is nullptr.");
245         return CALL_ERR_RESOURCE_UNAVAILABLE;
246     }
247     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
248     if (handle == nullptr) {
249         TELEPHONY_LOGE("StopDtmfRequest return, error type: handle is nullptr.");
250         return CALL_ERR_RESOURCE_UNAVAILABLE;
251     }
252     CoreManagerInner::GetInstance().StopDTMF(slotId, RadioEvent::RADIO_STOP_DTMF, index, handle);
253     return TELEPHONY_SUCCESS;
254 }
255 
GetCsCallsDataRequest(int32_t slotId,int64_t lastCallsDataFlag)256 int32_t CellularCallConnectionCS::GetCsCallsDataRequest(int32_t slotId, int64_t lastCallsDataFlag)
257 {
258     TELEPHONY_LOGI("CellularCallConnectionCS::GetCsCallsDataRequest start.");
259     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
260         TELEPHONY_LOGE("GetCsCallsDataRequest return, error type: GetInstance() is nullptr.");
261         return CALL_ERR_RESOURCE_UNAVAILABLE;
262     }
263     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
264     if (handle == nullptr) {
265         TELEPHONY_LOGE("GetCsCallsDataRequest return, error type: handle is nullptr.");
266         return CALL_ERR_RESOURCE_UNAVAILABLE;
267     }
268 
269     // Implementation
270     // Optional. Recommended when +CHLD command is implemented.
271     CoreManagerInner::GetInstance().GetCallList(slotId, RadioEvent::RADIO_CURRENT_CALLS, handle);
272     return TELEPHONY_SUCCESS;
273 }
274 
GetCallFailReasonRequest(int32_t slotId) const275 int32_t CellularCallConnectionCS::GetCallFailReasonRequest(int32_t slotId) const
276 {
277     TELEPHONY_LOGI("CellularCallConnectionCS::GetCallFailReasonRequest start.");
278     if (DelayedSingleton<CellularCallService>::GetInstance() == nullptr) {
279         TELEPHONY_LOGE("GetCallFailReasonRequest return, error type: GetInstance() is nullptr.");
280         return CALL_ERR_RESOURCE_UNAVAILABLE;
281     }
282     auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
283     if (handle == nullptr) {
284         TELEPHONY_LOGE("GetCallFailReasonRequest return, error type: handle is nullptr.");
285         return CALL_ERR_RESOURCE_UNAVAILABLE;
286     }
287     CoreManagerInner::GetInstance().GetCallFailReason(slotId, RadioEvent::RADIO_GET_CALL_FAIL_REASON, handle);
288     return TELEPHONY_SUCCESS;
289 }
290 
RegisterHandler()291 void CellularCallConnectionCS::RegisterHandler()
292 {
293     DelayedSingleton<CellularCallService>::GetInstance()->RegisterHandler();
294 }
295 } // namespace Telephony
296 } // namespace OHOS
297