• 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 "call_status_callback.h"
17 
18 #include "call_manager_errors.h"
19 #include "telephony_log_wrapper.h"
20 
21 #include "call_ability_report_proxy.h"
22 #include "report_call_info_handler.h"
23 #include "audio_control_manager.h"
24 
25 namespace OHOS {
26 namespace Telephony {
CallStatusCallback()27 CallStatusCallback::CallStatusCallback() {}
28 
~CallStatusCallback()29 CallStatusCallback::~CallStatusCallback() {}
30 
UpdateCallReportInfo(const CallReportInfo & info)31 int32_t CallStatusCallback::UpdateCallReportInfo(const CallReportInfo &info)
32 {
33     CallDetailInfo detailInfo;
34     detailInfo.callType = info.callType;
35     detailInfo.accountId = info.accountId;
36     detailInfo.index = info.index;
37     detailInfo.state = info.state;
38     detailInfo.callMode = info.callMode;
39     detailInfo.voiceDomain = info.voiceDomain;
40     (void)memcpy_s(detailInfo.phoneNum, kMaxNumberLen, info.accountNum, kMaxNumberLen);
41     (void)memset_s(detailInfo.bundleName, kMaxBundleNameLen, 0, kMaxBundleNameLen);
42     int32_t ret = DelayedSingleton<ReportCallInfoHandlerService>::GetInstance()->UpdateCallReportInfo(detailInfo);
43     if (ret != TELEPHONY_SUCCESS) {
44         TELEPHONY_LOGE("UpdateCallReportInfo failed! errCode:%{public}d", ret);
45     } else {
46         TELEPHONY_LOGI("UpdateCallReportInfo success! state:%{public}d", info.state);
47     }
48     return ret;
49 }
50 
UpdateCallsReportInfo(const CallsReportInfo & info)51 int32_t CallStatusCallback::UpdateCallsReportInfo(const CallsReportInfo &info)
52 {
53     CallDetailsInfo detailsInfo;
54     CallDetailInfo detailInfo;
55     CallsReportInfo callsInfo = info;
56     std::vector<CallReportInfo>::iterator it = callsInfo.callVec.begin();
57     for (; it != callsInfo.callVec.end(); ++it) {
58         detailInfo.callType = (*it).callType;
59         detailInfo.accountId = (*it).accountId;
60         detailInfo.index = (*it).index;
61         detailInfo.state = (*it).state;
62         detailInfo.callMode = (*it).callMode;
63         detailInfo.voiceDomain = (*it).voiceDomain;
64         (void)memcpy_s(detailInfo.phoneNum, kMaxNumberLen, (*it).accountNum, kMaxNumberLen);
65         (void)memset_s(detailInfo.bundleName, kMaxBundleNameLen, 0, kMaxBundleNameLen);
66         detailsInfo.callVec.push_back(detailInfo);
67     }
68     detailsInfo.slotId = callsInfo.slotId;
69     (void)memset_s(detailsInfo.bundleName, kMaxBundleNameLen, 0, kMaxBundleNameLen);
70     int32_t ret = DelayedSingleton<ReportCallInfoHandlerService>::GetInstance()->UpdateCallsReportInfo(detailsInfo);
71     if (ret != TELEPHONY_SUCCESS) {
72         TELEPHONY_LOGE("UpdateCallsReportInfo failed! errCode:%{public}d", ret);
73     } else {
74         TELEPHONY_LOGI("UpdateCallsReportInfo success!");
75     }
76     return ret;
77 }
78 
UpdateDisconnectedCause(const DisconnectedDetails & cause)79 int32_t CallStatusCallback::UpdateDisconnectedCause(const DisconnectedDetails &cause)
80 {
81     int32_t ret = DelayedSingleton<ReportCallInfoHandlerService>::GetInstance()->UpdateDisconnectedCause(cause);
82     if (ret != TELEPHONY_SUCCESS) {
83         TELEPHONY_LOGE("UpdateDisconnectedCause failed! errCode:%{public}d", ret);
84     } else {
85         TELEPHONY_LOGI("UpdateDisconnectedCause success!");
86     }
87     return ret;
88 }
89 
UpdateEventResultInfo(const CellularCallEventInfo & info)90 int32_t CallStatusCallback::UpdateEventResultInfo(const CellularCallEventInfo &info)
91 {
92     int32_t ret = DelayedSingleton<ReportCallInfoHandlerService>::GetInstance()->UpdateEventResultInfo(info);
93     if (ret != TELEPHONY_SUCCESS) {
94         TELEPHONY_LOGE("UpdateEventResultInfo failed! errCode:%{public}d", ret);
95     } else {
96         TELEPHONY_LOGI("UpdateEventResultInfo success!");
97     }
98     return ret;
99 }
100 
UpdateRBTPlayInfo(const RBTPlayInfo info)101 int32_t CallStatusCallback::UpdateRBTPlayInfo(const RBTPlayInfo info)
102 {
103     TELEPHONY_LOGI("UpdateRBTPlayInfo info = %{public}d", info);
104     bool isLocalRingbackNeeded = false;
105     if (info == RBTPlayInfo::LOCAL_ALERTING) {
106         isLocalRingbackNeeded = true;
107     }
108     DelayedSingleton<AudioControlManager>::GetInstance()->SetLocalRingbackNeeded(isLocalRingbackNeeded);
109     return TELEPHONY_SUCCESS;
110 }
111 
StartDtmfResult(const int32_t result)112 int32_t CallStatusCallback::StartDtmfResult(const int32_t result)
113 {
114     CallResultReportId reportId = CallResultReportId::START_DTMF_REPORT_ID;
115     AppExecFwk::PacMap resultInfo;
116     resultInfo.PutIntValue("result", result);
117     TELEPHONY_LOGI("StartDtmfResult result = %{public}d", result);
118     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
119 }
120 
StopDtmfResult(const int32_t result)121 int32_t CallStatusCallback::StopDtmfResult(const int32_t result)
122 {
123     CallResultReportId reportId = CallResultReportId::STOP_DTMF_REPORT_ID;
124     AppExecFwk::PacMap resultInfo;
125     resultInfo.PutIntValue("result", result);
126     TELEPHONY_LOGI("StopDtmfResult result = %{public}d", result);
127     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
128 }
129 
SendUssdResult(const int32_t result)130 int32_t CallStatusCallback::SendUssdResult(const int32_t result)
131 {
132     CallResultReportId reportId = CallResultReportId::SEND_USSD_REPORT_ID;
133     AppExecFwk::PacMap resultInfo;
134     resultInfo.PutIntValue("result", result);
135     TELEPHONY_LOGI("SendUssdResult result = %{public}d", result);
136     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
137 }
138 
GetImsCallDataResult(const int32_t result)139 int32_t CallStatusCallback::GetImsCallDataResult(const int32_t result)
140 {
141     CallResultReportId reportId = CallResultReportId::GET_IMS_CALL_DATA_REPORT_ID;
142     AppExecFwk::PacMap resultInfo;
143     resultInfo.PutIntValue("result", result);
144     TELEPHONY_LOGI("GetImsCallDataResult result = %{public}d", result);
145     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
146 }
147 
UpdateGetWaitingResult(const CallWaitResponse & response)148 int32_t CallStatusCallback::UpdateGetWaitingResult(const CallWaitResponse &response)
149 {
150     TELEPHONY_LOGI("GetWaitingResult  status = %{public}d, classCw = %{public}d, result = %{public}d",
151         response.status, response.classCw, response.result);
152     CallResultReportId reportId = CallResultReportId::GET_CALL_WAITING_REPORT_ID;
153     AppExecFwk::PacMap resultInfo;
154     resultInfo.PutIntValue("result", response.result);
155     resultInfo.PutIntValue("status", response.status);
156     resultInfo.PutIntValue("classCw", response.classCw);
157     DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
158     return TELEPHONY_SUCCESS;
159 }
160 
UpdateSetWaitingResult(const int32_t result)161 int32_t CallStatusCallback::UpdateSetWaitingResult(const int32_t result)
162 {
163     TELEPHONY_LOGI("SetWaitingResult  result = %{public}d", result);
164     CallResultReportId reportId = CallResultReportId::SET_CALL_WAITING_REPORT_ID;
165     AppExecFwk::PacMap resultInfo;
166     resultInfo.PutIntValue("result", result);
167     DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
168     return TELEPHONY_SUCCESS;
169 }
170 
UpdateGetRestrictionResult(const CallRestrictionResponse & result)171 int32_t CallStatusCallback::UpdateGetRestrictionResult(const CallRestrictionResponse &result)
172 {
173     TELEPHONY_LOGI("GetRestrictionResult  status = %{public}d, classCw = %{public}d, result = %{public}d",
174         result.status, result.classCw, result.result);
175     CallResultReportId reportId = CallResultReportId::GET_CALL_RESTRICTION_REPORT_ID;
176     AppExecFwk::PacMap resultInfo;
177     resultInfo.PutIntValue("result", result.result);
178     resultInfo.PutIntValue("status", result.status);
179     resultInfo.PutIntValue("classCw", result.classCw);
180     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
181 }
182 
UpdateSetRestrictionResult(const int32_t result)183 int32_t CallStatusCallback::UpdateSetRestrictionResult(const int32_t result)
184 {
185     TELEPHONY_LOGI("SetRestrictionResult  result = %{public}d", result);
186     CallResultReportId reportId = CallResultReportId::SET_CALL_RESTRICTION_REPORT_ID;
187     AppExecFwk::PacMap resultInfo;
188     resultInfo.PutIntValue("result", result);
189     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
190 }
191 
UpdateGetTransferResult(const CallTransferResponse & response)192 int32_t CallStatusCallback::UpdateGetTransferResult(const CallTransferResponse &response)
193 {
194     CallResultReportId reportId = CallResultReportId::GET_CALL_TRANSFER_REPORT_ID;
195     AppExecFwk::PacMap resultInfo;
196     resultInfo.PutIntValue("result", response.result);
197     resultInfo.PutIntValue("status", response.status);
198     resultInfo.PutIntValue("classx", response.classx);
199     resultInfo.PutStringValue("number", response.number);
200     resultInfo.PutIntValue("type", response.type);
201     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
202 }
203 
UpdateSetTransferResult(const int32_t result)204 int32_t CallStatusCallback::UpdateSetTransferResult(const int32_t result)
205 {
206     TELEPHONY_LOGI("SetTransferResult  result = %{public}d", result);
207     CallResultReportId reportId = CallResultReportId::SET_CALL_TRANSFER_REPORT_ID;
208     AppExecFwk::PacMap resultInfo;
209     resultInfo.PutIntValue("result", result);
210     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
211 }
212 
UpdateGetCallClipResult(const ClipResponse & clipResponse)213 int32_t CallStatusCallback::UpdateGetCallClipResult(const ClipResponse &clipResponse)
214 {
215     TELEPHONY_LOGI("GetCallClipResult  action = %{public}d, clipStat = %{public}d, result = %{public}d",
216         clipResponse.action, clipResponse.clipStat, clipResponse.result);
217     CallResultReportId reportId = CallResultReportId::GET_CALL_CLIP_ID;
218     AppExecFwk::PacMap resultInfo;
219     resultInfo.PutIntValue("result", clipResponse.result);
220     resultInfo.PutIntValue("action", clipResponse.action);
221     resultInfo.PutIntValue("clipStat", clipResponse.clipStat);
222     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
223 }
224 
UpdateGetCallClirResult(const ClirResponse & clirResponse)225 int32_t CallStatusCallback::UpdateGetCallClirResult(const ClirResponse &clirResponse)
226 {
227     TELEPHONY_LOGI("GetCallClirResult  action = %{public}d, clirStat = %{public}d, result = %{public}d",
228         clirResponse.action, clirResponse.clirStat, clirResponse.result);
229     CallResultReportId reportId = CallResultReportId::GET_CALL_CLIR_ID;
230     AppExecFwk::PacMap resultInfo;
231     resultInfo.PutIntValue("result", clirResponse.result);
232     resultInfo.PutIntValue("action", clirResponse.action);
233     resultInfo.PutIntValue("clirStat", clirResponse.clirStat);
234     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
235 }
236 
UpdateSetCallClirResult(const int32_t result)237 int32_t CallStatusCallback::UpdateSetCallClirResult(const int32_t result)
238 {
239     TELEPHONY_LOGI("GetCallClirResult  result = %{public}d", result);
240     CallResultReportId reportId = CallResultReportId::SET_CALL_CLIR_ID;
241     AppExecFwk::PacMap resultInfo;
242     resultInfo.PutIntValue("result", result);
243     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
244 }
245 
GetVoLteStatusResult(const LteImsSwitchResponse & switchResponse)246 int32_t CallStatusCallback::GetVoLteStatusResult(const LteImsSwitchResponse &switchResponse)
247 {
248     TELEPHONY_LOGI("GetVoLteStatusResult result = %{public}d, active = %{public}d", switchResponse.result,
249         switchResponse.active);
250     CallResultReportId reportId = CallResultReportId::GET_CALL_VOTLE_REPORT_ID;
251     AppExecFwk::PacMap resultInfo;
252     resultInfo.PutIntValue("result", switchResponse.result);
253     resultInfo.PutIntValue("active", switchResponse.active);
254     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
255 }
256 
SetVoLteStatusResult(const LteImsSwitchResponse & switchResponse)257 int32_t CallStatusCallback::SetVoLteStatusResult(const LteImsSwitchResponse &switchResponse)
258 {
259     TELEPHONY_LOGI("SetVoLteStatusResult result = %{public}d", switchResponse.result);
260     CallResultReportId reportId = CallResultReportId::SET_CALL_VOTLE_REPORT_ID;
261     AppExecFwk::PacMap resultInfo;
262     resultInfo.PutIntValue("result", switchResponse.result);
263     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
264 }
265 
StartRttResult(const int32_t result)266 int32_t CallStatusCallback::StartRttResult(const int32_t result)
267 {
268     TELEPHONY_LOGI("StartRttResult result = %{public}d", result);
269     CallResultReportId reportId = CallResultReportId::START_RTT_REPORT_ID;
270     AppExecFwk::PacMap resultInfo;
271     resultInfo.PutIntValue("result", result);
272     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
273 }
274 
StopRttResult(const int32_t result)275 int32_t CallStatusCallback::StopRttResult(const int32_t result)
276 {
277     TELEPHONY_LOGI("StopRttResult result = %{public}d", result);
278     CallResultReportId reportId = CallResultReportId::STOP_RTT_REPORT_ID;
279     AppExecFwk::PacMap resultInfo;
280     resultInfo.PutIntValue("result", result);
281     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
282 }
283 
GetImsConfigResult(const GetImsConfigResponse & response)284 int32_t CallStatusCallback::GetImsConfigResult(const GetImsConfigResponse &response)
285 {
286     CallResultReportId reportId = CallResultReportId::GET_IMS_CONFIG_REPORT_ID;
287     AppExecFwk::PacMap resultInfo;
288     resultInfo.PutIntValue("result", response.result);
289     resultInfo.PutIntValue("value", response.value);
290     TELEPHONY_LOGI("result = %{public}d value = %{public}d", response.result, response.value);
291     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
292 }
293 
SetImsConfigResult(const int32_t result)294 int32_t CallStatusCallback::SetImsConfigResult(const int32_t result)
295 {
296     CallResultReportId reportId = CallResultReportId::SET_IMS_CONFIG_REPORT_ID;
297     AppExecFwk::PacMap resultInfo;
298     resultInfo.PutIntValue("result", result);
299     TELEPHONY_LOGI("result = %{public}d", result);
300     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
301 }
302 
GetImsFeatureValueResult(const GetImsFeatureValueResponse & response)303 int32_t CallStatusCallback::GetImsFeatureValueResult(const GetImsFeatureValueResponse &response)
304 {
305     CallResultReportId reportId = CallResultReportId::GET_IMS_FEATURE_VALUE_REPORT_ID;
306     AppExecFwk::PacMap resultInfo;
307     resultInfo.PutIntValue("result", response.result);
308     resultInfo.PutIntValue("value", response.value);
309     TELEPHONY_LOGI("result = %{public}d value = %{public}d", response.result, response.value);
310     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
311 }
312 
SetImsFeatureValueResult(const int32_t result)313 int32_t CallStatusCallback::SetImsFeatureValueResult(const int32_t result)
314 {
315     CallResultReportId reportId = CallResultReportId::SET_IMS_FEATURE_VALUE_REPORT_ID;
316     AppExecFwk::PacMap resultInfo;
317     resultInfo.PutIntValue("result", result);
318     TELEPHONY_LOGI("result = %{public}d", result);
319     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
320 }
321 
GetLteEnhanceModeResult(const GetLteEnhanceModeResponse & response)322 int32_t CallStatusCallback::GetLteEnhanceModeResult(const GetLteEnhanceModeResponse &response)
323 {
324     CallResultReportId reportId = CallResultReportId::GET_LTE_ENHANCE_MODE_REPORT_ID;
325     AppExecFwk::PacMap resultInfo;
326     resultInfo.PutIntValue("result", response.result);
327     resultInfo.PutIntValue("value", response.value);
328     TELEPHONY_LOGI("result = %{public}d value = %{public}d", response.result, response.value);
329     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
330 }
331 
SetLteEnhanceModeResult(const int32_t result)332 int32_t CallStatusCallback::SetLteEnhanceModeResult(const int32_t result)
333 {
334     CallResultReportId reportId = CallResultReportId::SET_LTE_ENHANCE_MODE_REPORT_ID;
335     AppExecFwk::PacMap resultInfo;
336     resultInfo.PutIntValue("result", result);
337     TELEPHONY_LOGI("SetLteEnhanceModeResult result = %{public}d", result);
338     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
339 }
340 
ReceiveUpdateCallMediaModeResponse(const CallMediaModeResponse & response)341 int32_t CallStatusCallback::ReceiveUpdateCallMediaModeResponse(const CallMediaModeResponse &response)
342 {
343     CallResultReportId reportId = CallResultReportId::UPDATE_MEDIA_MODE_REPORT_ID;
344     AppExecFwk::PacMap resultInfo;
345     resultInfo.PutIntValue("result", response.result);
346     TELEPHONY_LOGI("UpdateImsCallMode result = %{public}d", response.result);
347     (void)DelayedSingleton<ReportCallInfoHandlerService>::GetInstance()->UpdateMediaModeResponse(response);
348     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
349 }
350 
InviteToConferenceResult(const int32_t result)351 int32_t CallStatusCallback::InviteToConferenceResult(const int32_t result)
352 {
353     CallResultReportId reportId = CallResultReportId::INVITE_TO_CONFERENCE_REPORT_ID;
354     AppExecFwk::PacMap resultInfo;
355     resultInfo.PutIntValue("result", result);
356     TELEPHONY_LOGI("InviteToConferenceResult result = %{public}d", result);
357     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->ReportAsyncResults(reportId, resultInfo);
358 }
359 } // namespace Telephony
360 } // namespace OHOS
361