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 #include "at_call.h"
17
18 #include "hril_notification.h"
19 #include "securec.h"
20 #include "vendor_report.h"
21 #include "vendor_util.h"
22
23 #undef DEFAULT_TIMEOUT
24 #define DEFAULT_TIMEOUT 5000
25 #define DEFAULT_TIMEOUT_CLCK 50000
26
27 CallNotify g_callNotifyTab[] = {
28 {"^CCALLSTATE:", ReportCallStateUpdated},
29 {"+CUSD:", ReportCallUssdNotice},
30 {"+CIREPH:", ReportSrvccStatusUpdate},
31 {"^CSCHANNELINFO:", ReportCsChannelInfo},
32 {"^XLEMA:", ReportEmergencyNumberList},
33 };
34
35 static int32_t lastCcCause = HRIL_ERR_CALL_CAUSE;
36
OnCallReportErrorMessages(const ReqDataInfo * requestInfo,uint32_t err,ResponseInfo * pResponse)37 static void OnCallReportErrorMessages(const ReqDataInfo *requestInfo, uint32_t err, ResponseInfo *pResponse)
38 {
39 uint32_t errorNo = HRIL_ERR_SUCCESS;
40 ModemReportErrorInfo errInfo = GetReportErrorInfo(pResponse);
41 errorNo = (err != HRIL_ERR_SUCCESS) ? err : errInfo.errorNo;
42 TELEPHONY_LOGW("Report error! ret:%{public}d", errorNo);
43 FreeResponseInfo(pResponse);
44 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, errorNo, HRIL_RESPONSE, 0);
45 reportInfo.modemErrInfo = errInfo;
46 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
47 }
48
ParseDiffPart(int32_t isAllInfo,char ** pLine,HRilCallInfo * outCall)49 static int32_t ParseDiffPart(int32_t isAllInfo, char **pLine, HRilCallInfo *outCall)
50 {
51 if (outCall == NULL) {
52 return HRIL_ERR_NULL_POINT;
53 }
54 int32_t tmp = 0;
55 if (isAllInfo) {
56 if (NextInt(pLine, &outCall->voiceDomain) < 0) {
57 return HRIL_ERR_NULL_POINT;
58 }
59 if (NextInt(pLine, &outCall->callType) < 0) {
60 return HRIL_ERR_NULL_POINT;
61 }
62 NextInt(pLine, &tmp); // ignore
63 } else {
64 outCall->voiceDomain = INT_DEFAULT_VALUE;
65 outCall->callType = INT_DEFAULT_VALUE;
66 }
67 return 0;
68 }
69
CallCmdCLCC(const char * lineCmd,HRilCallInfo * outCall)70 static int32_t CallCmdCLCC(const char *lineCmd, HRilCallInfo *outCall)
71 {
72 char *pLine = (char *)lineCmd;
73 int32_t state;
74 int32_t mode;
75
76 if (pLine == NULL || outCall == NULL) {
77 TELEPHONY_LOGE("src or desc pointer is null.");
78 return HRIL_ERR_NULL_POINT;
79 }
80 int32_t isAllInfo = ReportStrWith(pLine, "^CLCC:");
81 if (SkipATPrefix(&pLine) < 0) {
82 return HRIL_ERR_NULL_POINT;
83 }
84 if (NextInt(&pLine, &outCall->index) < 0) {
85 return HRIL_ERR_NULL_POINT;
86 }
87 if (NextInt(&pLine, &outCall->dir) < 0) {
88 return HRIL_ERR_NULL_POINT;
89 }
90 if (NextInt(&pLine, &state) < 0) {
91 return HRIL_ERR_NULL_POINT;
92 }
93 outCall->state = (HRilCallState)state;
94 if (NextInt(&pLine, &mode) < 0) {
95 return HRIL_ERR_NULL_POINT;
96 }
97 outCall->mode = (HRilCallMode)mode;
98 if (NextInt(&pLine, &outCall->mpty) < 0) {
99 return HRIL_ERR_NULL_POINT;
100 }
101 if (ParseDiffPart(isAllInfo, &pLine, outCall)) {
102 return HRIL_ERR_NULL_POINT;
103 }
104 if (NextStr(&pLine, &outCall->number) < 0) {
105 return HRIL_ERR_NULL_POINT;
106 }
107 if (NextInt(&pLine, &outCall->type) < 0) {
108 return HRIL_ERR_NULL_POINT;
109 }
110
111 if (pLine != NULL) { // The data returned by some modules does not have this alpha data.
112 if (NextStr(&pLine, &outCall->alpha) < 0) {
113 return HRIL_ERR_NULL_POINT;
114 }
115 }
116 return HRIL_ERR_SUCCESS;
117 }
118
ReportCallStateUpdated(const char * str)119 void ReportCallStateUpdated(const char *str)
120 {
121 int32_t err = HRIL_ERR_SUCCESS;
122 char *pStr = (char *)str;
123 int callId = 0;
124 int voiceDomain = 0;
125 int state = 0;
126 ReqDataInfo requestInfo = {0};
127 ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
128
129 if (SkipATPrefix(&pStr) < 0) {
130 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
131 }
132 if (NextInt(&pStr, &callId) < 0) {
133 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
134 }
135 if (NextInt(&pStr, &state) < 0) {
136 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
137 }
138 if (NextInt(&pStr, &voiceDomain) < 0) {
139 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
140 }
141
142 struct ReportInfo reportInfo = CreateReportInfo(&requestInfo, err, HRIL_NOTIFICATION, HNOTI_CALL_STATE_UPDATED);
143 reportInfo.modemErrInfo = errInfo;
144 OnCallReport(GetSlotId(NULL), reportInfo, NULL, 0);
145 }
146
ReportSrvccStatusUpdate(const char * str)147 void ReportSrvccStatusUpdate(const char *str)
148 {
149 int32_t err = HRIL_ERR_SUCCESS;
150 char *pStr = (char *)str;
151 HRilCallSrvccStatus srvccStatus = {0};
152 ReqDataInfo requestInfo = {0};
153 ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
154
155 if (SkipATPrefix(&pStr) < 0) {
156 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
157 }
158 if (err == HRIL_ERR_SUCCESS && NextInt(&pStr, &srvccStatus.status) < 0) {
159 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
160 }
161
162 struct ReportInfo reportInfo =
163 CreateReportInfo(&requestInfo, err, HRIL_NOTIFICATION, HNOTI_CALL_SRVCC_STATUS_REPORT);
164 reportInfo.modemErrInfo = errInfo;
165 OnCallReport(GetSlotId(NULL), reportInfo, (const uint8_t *)&srvccStatus, sizeof(HRilCallSrvccStatus));
166 }
167
ReportCsChannelInfo(const char * str)168 void ReportCsChannelInfo(const char *str)
169 {
170 int32_t err = HRIL_ERR_SUCCESS;
171 char *pStr = (char *)str;
172 HRilCallCsChannelInfo csChannelInfo = {0};
173 ReqDataInfo requestInfo = {0};
174 ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
175 /* 0 network alerting; 1 local alerting */
176 int32_t ringbackVoiceFlag = 0;
177
178 if (SkipATPrefix(&pStr) < 0) {
179 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
180 }
181 if (err == HRIL_ERR_SUCCESS && NextInt(&pStr, &csChannelInfo.status) < 0) {
182 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
183 }
184 if (err == HRIL_ERR_SUCCESS && NextInt(&pStr, &csChannelInfo.voiceDomain) < 0) {
185 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
186 }
187
188 ringbackVoiceFlag = !csChannelInfo.status;
189 struct ReportInfo reportInfo =
190 CreateReportInfo(&requestInfo, err, HRIL_NOTIFICATION, HNOTI_CALL_RINGBACK_VOICE_REPORT);
191 reportInfo.modemErrInfo = errInfo;
192 OnCallReport(GetSlotId(NULL), reportInfo, (const uint8_t *)&ringbackVoiceFlag, sizeof(int32_t));
193 }
194
IsCallNoticeCmd(const char * str)195 int32_t IsCallNoticeCmd(const char *str)
196 {
197 int32_t tabSize = sizeof(g_callNotifyTab) / sizeof(CallNotify);
198 for (int32_t i = 0; i < tabSize; i++) {
199 if (ReportStrWith(str, g_callNotifyTab[i].cmd)) {
200 return 1;
201 }
202 }
203 return 0;
204 }
205
CallReportInfoProcess(const char * str)206 void CallReportInfoProcess(const char *str)
207 {
208 int32_t tabSize = sizeof(g_callNotifyTab) / sizeof(CallNotify);
209 for (int32_t i = 0; i < tabSize; i++) {
210 if (ReportStrWith(str, g_callNotifyTab[i].cmd)) {
211 g_callNotifyTab[i].function(str);
212 break;
213 }
214 }
215 }
216
ReportEmergencyNumberList(const char * str)217 void ReportEmergencyNumberList(const char *str)
218 {
219 int32_t err = HRIL_ERR_SUCCESS;
220 char *pStr = (char *)str;
221 HRilEmergencyInfo pEmergencyInfo = {0};
222 ReqDataInfo requestInfo = {0};
223 ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
224
225 if (SkipATPrefix(&pStr) < 0) {
226 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
227 }
228 if (NextInt(&pStr, &pEmergencyInfo.index) < 0) {
229 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
230 }
231 if (NextInt(&pStr, &pEmergencyInfo.total) < 0) {
232 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
233 }
234 if (NextStr(&pStr, &pEmergencyInfo.eccNum) < 0) {
235 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
236 }
237 if (NextInt(&pStr, &pEmergencyInfo.category) < 0) {
238 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
239 }
240 if (NextInt(&pStr, &pEmergencyInfo.simpresent) < 0) {
241 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
242 }
243 if (NextStr(&pStr, &pEmergencyInfo.mcc) < 0) {
244 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
245 }
246 if (NextInt(&pStr, &pEmergencyInfo.abnormalService) < 0) {
247 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
248 }
249
250 struct ReportInfo reportInfo =
251 CreateReportInfo(&requestInfo, err, HRIL_NOTIFICATION, HNOTI_CALL_EMERGENCY_NUMBER_REPORT);
252 reportInfo.modemErrInfo = errInfo;
253 OnCallReport(GetSlotId(NULL), reportInfo, (const uint8_t *)&pEmergencyInfo, sizeof(pEmergencyInfo));
254 }
255
ReportCallUssdNotice(const char * str)256 void ReportCallUssdNotice(const char *str)
257 {
258 int32_t err = HRIL_ERR_SUCCESS;
259 char *pStr = (char *)str;
260 HRilUssdNoticeInfo ussdNoticeInfo = {0};
261 ReqDataInfo requestInfo = {0};
262 ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
263
264 if (SkipATPrefix(&pStr) < 0) {
265 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
266 }
267 if (NextInt(&pStr, &ussdNoticeInfo.m) < 0) {
268 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
269 }
270 if (NextStr(&pStr, &ussdNoticeInfo.str) < 0) {
271 err = HRIL_ERR_INVALID_MODEM_PARAMETER;
272 }
273 struct ReportInfo reportInfo = CreateReportInfo(&requestInfo, err, HRIL_NOTIFICATION, HNOTI_CALL_USSD_REPORT);
274 reportInfo.modemErrInfo = errInfo;
275 OnCallReport(GetSlotId(NULL), reportInfo, (const uint8_t *)&ussdNoticeInfo, sizeof(HRilUssdNoticeInfo));
276 }
277
InitCallListCmdBuffer(const ResponseInfo * pResponse,int32_t * callNum,HRilCallInfo ** pCalls)278 static int32_t InitCallListCmdBuffer(const ResponseInfo *pResponse, int32_t *callNum, HRilCallInfo **pCalls)
279 {
280 int32_t ret;
281 int32_t callNumTmp = 0;
282 Line *pLine = NULL;
283 HRilCallInfo *pCallsTmp = NULL;
284
285 if (pResponse == NULL || pCalls == NULL || callNum == NULL) {
286 TELEPHONY_LOGE("params: %{public}p,%{public}p,%{public}p", pResponse, callNum, pCalls);
287 return HRIL_ERR_NULL_POINT;
288 }
289
290 *callNum = 0;
291 *pCalls = NULL;
292
293 for (pLine = pResponse->head; pLine != NULL; pLine = pLine->next) {
294 callNumTmp++;
295 }
296 if (!callNumTmp) {
297 callNumTmp++; // Malloc size cannot be 0.
298 }
299 pCallsTmp = (HRilCallInfo *)malloc(callNumTmp * sizeof(HRilCallInfo));
300 if (pCallsTmp == NULL) {
301 TELEPHONY_LOGE("ReqGetCallList malloc pCalls failure");
302 return HRIL_ERR_MEMORY_FULL;
303 }
304 ret = memset_s(pCallsTmp, callNumTmp * sizeof(HRilCallInfo), 0, callNumTmp * sizeof(HRilCallInfo));
305 if (ret != EOK) {
306 TELEPHONY_LOGE("memset_s is failed!");
307 free(pCallsTmp);
308 pCallsTmp = NULL;
309 return ret;
310 }
311
312 *pCalls = pCallsTmp;
313 *callNum = callNumTmp;
314
315 return HRIL_ERR_SUCCESS;
316 }
317
BuildCallInfoList(const ReqDataInfo * requestInfo,ResponseInfo * response)318 int32_t BuildCallInfoList(const ReqDataInfo *requestInfo, ResponseInfo *response)
319 {
320 int32_t ret = 0;
321 int32_t callNum = 0;
322 int32_t validCallNum = 0;
323 int32_t err = HRIL_ERR_SUCCESS;
324 Line *pLine = NULL;
325 ResponseInfo *pResponse = response;
326 HRilCallInfo *pCalls = NULL;
327
328 if (pResponse == NULL || requestInfo == NULL) {
329 TELEPHONY_LOGE("response or requestInfo is null.");
330 return HRIL_ERR_NULL_POINT;
331 }
332 if (pResponse->success == 0) {
333 TELEPHONY_LOGE("send cmd return ERROR");
334 err = HRIL_ERR_GENERIC_FAILURE;
335 }
336
337 ret = InitCallListCmdBuffer(pResponse, &callNum, &pCalls);
338 if (ret != HRIL_ERR_SUCCESS) {
339 TELEPHONY_LOGE("init command failed: %{public}d", ret);
340 return ret;
341 }
342
343 for (pLine = pResponse->head; pLine != NULL && validCallNum < callNum; pLine = pLine->next) {
344 ret = CallCmdCLCC(pLine->data, pCalls + validCallNum);
345 if (ret != 0) {
346 TELEPHONY_LOGE("Parse CLCC data is fail. ret:%{public}d", ret);
347 continue;
348 }
349 validCallNum++;
350 }
351
352 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
353 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)pCalls, sizeof(HRilCallInfo) * validCallNum);
354 FreeResponseInfo(pResponse);
355 free(pCalls);
356 return HRIL_ERR_SUCCESS;
357 }
358
ReqGetCallList(const ReqDataInfo * requestInfo)359 void ReqGetCallList(const ReqDataInfo *requestInfo)
360 {
361 int32_t ret;
362 ResponseInfo *pResponse = NULL;
363 int32_t err = HRIL_ERR_SUCCESS;
364 long timeOut = DEFAULT_TIMEOUT;
365
366 ret = SendCommandLock("AT+CLCC", "+CLCC:", timeOut, &pResponse);
367 if (ret || (pResponse != NULL && !pResponse->success)) {
368 err = ret ? ret : err;
369 TELEPHONY_LOGE("cmd send failed, err:%{public}d", err);
370 if (err < HRIL_ERR_SUCCESS) {
371 err = HRIL_ERR_GENERIC_FAILURE;
372 }
373 OnCallReportErrorMessages(requestInfo, err, pResponse);
374 return;
375 }
376 err = BuildCallInfoList(requestInfo, pResponse);
377 if (err != HRIL_ERR_SUCCESS) {
378 if (err < HRIL_ERR_SUCCESS) {
379 err = HRIL_ERR_GENERIC_FAILURE;
380 }
381 TELEPHONY_LOGE("Build Call Info List is failed.");
382 OnCallReportErrorMessages(requestInfo, err, pResponse);
383 }
384 }
385
ReqDial(const ReqDataInfo * requestInfo,const HRilDial * data,size_t dataLen)386 void ReqDial(const ReqDataInfo *requestInfo, const HRilDial *data, size_t dataLen)
387 {
388 HRilDial *pDial = NULL;
389 char cmd[MAX_CMD_LENGTH] = {0};
390 const char *clir = NULL;
391 int32_t ret;
392 int32_t err = HRIL_ERR_SUCCESS;
393 ResponseInfo *pResponse = NULL;
394
395 if (data == NULL) {
396 TELEPHONY_LOGE("data is null!!!");
397 return;
398 }
399
400 pDial = (HRilDial *)data;
401 switch (pDial->clir) {
402 case CALL_CLIR_INVOCATION:
403 clir = "I";
404 break; /* invocation */
405 case CALL_CLIR_SUPPRESSION:
406 clir = "i";
407 break; /* suppression */
408 case CALL_CLIR_SUBSCRIPTION_DEFAULT:
409 default:
410 clir = "";
411 break; /* subscription default */
412 }
413
414 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "ATD%s%s;", pDial->address, clir);
415 if (ret < 0) {
416 TELEPHONY_LOGE("GenerateCommand is failed!");
417 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
418 return;
419 }
420 ret = SendCommandLock(cmd, NULL, 0, &pResponse);
421 if (ret != 0) {
422 err = HRIL_ERR_CMD_SEND_FAILURE;
423 TELEPHONY_LOGE("ATD send failed");
424 } else {
425 if (!pResponse->success) {
426 TELEPHONY_LOGE("ReqDial return ERROR");
427 err = HRIL_ERR_CMD_NO_CARRIER;
428 }
429 }
430
431 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
432 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
433 FreeResponseInfo(pResponse);
434 }
435
ReqHangup(const ReqDataInfo * requestInfo,const uint32_t * data,size_t dataLen)436 void ReqHangup(const ReqDataInfo *requestInfo, const uint32_t *data, size_t dataLen)
437 {
438 const int32_t *pLine = NULL;
439 int32_t ret;
440 int32_t err = HRIL_ERR_SUCCESS;
441 char cmd[MAX_CMD_LENGTH] = {0};
442 ResponseInfo *pResponse = NULL;
443
444 if (data == NULL) {
445 TELEPHONY_LOGE("data is null!!!");
446 return;
447 }
448 pLine = (const int32_t *)data;
449 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CHLD=1%d", pLine[0]);
450 if (ret < 0) {
451 TELEPHONY_LOGE("GenerateCommand is failed!");
452 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
453 return;
454 }
455 ret = SendCommandLock(cmd, NULL, 0, &pResponse);
456 if (ret != HRIL_ERR_SUCCESS || !pResponse->success) {
457 TELEPHONY_LOGE("AT+CHLD send failed");
458 err = HRIL_ERR_GENERIC_FAILURE;
459 }
460
461 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
462 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
463 FreeResponseInfo(pResponse);
464 }
465
ReqReject(const ReqDataInfo * requestInfo)466 void ReqReject(const ReqDataInfo *requestInfo)
467 {
468 ResponseInfo *pResponse = NULL;
469 int32_t ret;
470 int32_t err = HRIL_ERR_SUCCESS;
471
472 ret = SendCommandLock("ATH", NULL, 0, &pResponse);
473 if (ret != HRIL_ERR_SUCCESS || !pResponse->success) {
474 TELEPHONY_LOGE("ATH send failed");
475 err = HRIL_ERR_GENERIC_FAILURE;
476 }
477
478 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
479 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
480 FreeResponseInfo(pResponse);
481 }
482
ReqAnswer(const ReqDataInfo * requestInfo)483 void ReqAnswer(const ReqDataInfo *requestInfo)
484 {
485 int32_t ret;
486 int32_t err = HRIL_ERR_SUCCESS;
487 ResponseInfo *pResponse = NULL;
488
489 ret = SendCommandLock("ATA", NULL, 0, &pResponse);
490 if (ret != HRIL_ERR_SUCCESS || !pResponse->success) {
491 err = HRIL_ERR_GENERIC_FAILURE;
492 }
493
494 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
495 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
496 FreeResponseInfo(pResponse);
497 }
498
499 // Calling line identification presentation
ReqGetClip(const ReqDataInfo * requestInfo)500 void ReqGetClip(const ReqDataInfo *requestInfo)
501 {
502 HRilGetClipResult result = {0};
503 int32_t err = HRIL_ERR_SUCCESS;
504 ResponseInfo *pResponse = NULL;
505
506 err = SendCommandLock("AT+CLIP?", "+CLIP", 0, &pResponse);
507 if (err == HRIL_ERR_SUCCESS) {
508 if (!pResponse->success) {
509 TELEPHONY_LOGE("CLIP return ERROR");
510 err = HRIL_ERR_GENERIC_FAILURE;
511 } else {
512 if (pResponse->head != NULL) {
513 char *line = pResponse->head->data;
514 SkipATPrefix(&line);
515 NextInt(&line, &result.action);
516 NextInt(&line, &result.clipStat);
517 } else {
518 TELEPHONY_LOGE("ERROR: ReqGetClip pResponse->head is null");
519 err = HRIL_ERR_GENERIC_FAILURE;
520 }
521 }
522 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
523 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&result, sizeof(result));
524 FreeResponseInfo(pResponse);
525 } else {
526 TELEPHONY_LOGE("ReqGetClip send failed");
527 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, HRIL_ERR_CMD_SEND_FAILURE, HRIL_RESPONSE, 0);
528 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&result, 0);
529 }
530 }
531
ReqSetClip(const ReqDataInfo * requestInfo,int32_t action)532 void ReqSetClip(const ReqDataInfo *requestInfo, int32_t action)
533 {
534 char cmd[MAX_CMD_LENGTH] = {0};
535 int32_t err = HRIL_ERR_SUCCESS;
536 ResponseInfo *pResponse = NULL;
537
538 int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CLIP=%d", action);
539 if (ret < 0) {
540 TELEPHONY_LOGE("GenerateCommand is failed!");
541 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
542 return;
543 }
544 err = SendCommandLock(cmd, NULL, 0, &pResponse);
545 if (err == HRIL_ERR_SUCCESS) {
546 if (!pResponse->success) {
547 TELEPHONY_LOGE("ReqSetClip return ERROR");
548 err = HRIL_ERR_GENERIC_FAILURE;
549 }
550
551 FreeResponseInfo(pResponse);
552 } else {
553 TELEPHONY_LOGE("ReqSetClip send failed");
554 err = HRIL_ERR_GENERIC_FAILURE;
555 }
556 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
557 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
558 }
559
ReqGetClir(const ReqDataInfo * requestInfo)560 void ReqGetClir(const ReqDataInfo *requestInfo)
561 {
562 HRilGetCallClirResult result = {0};
563 int32_t err = HRIL_ERR_SUCCESS;
564 ResponseInfo *pResponse = NULL;
565
566 err = SendCommandLock("AT+CLIR?", "+CLIR", 0, &pResponse);
567 if (err == HRIL_ERR_SUCCESS) {
568 if (!pResponse->success) {
569 TELEPHONY_LOGE("CLIR return ERROR");
570 err = HRIL_ERR_GENERIC_FAILURE;
571 } else {
572 if (pResponse->head != NULL) {
573 char *line = pResponse->head->data;
574 SkipATPrefix(&line);
575 NextInt(&line, &result.action);
576 NextInt(&line, &result.clirStat);
577 } else {
578 TELEPHONY_LOGE("ERROR: ReqGetClir pResponse->head is null");
579 err = HRIL_ERR_GENERIC_FAILURE;
580 }
581 }
582 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
583 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&result, sizeof(result));
584 FreeResponseInfo(pResponse);
585 } else {
586 TELEPHONY_LOGE("ReqGetClir send failed");
587 err = HRIL_ERR_CMD_SEND_FAILURE;
588 OnCallReportErrorMessages(requestInfo, err, pResponse);
589 }
590 }
591
ReqSetClir(const ReqDataInfo * requestInfo,int32_t action)592 void ReqSetClir(const ReqDataInfo *requestInfo, int32_t action)
593 {
594 char cmd[MAX_CMD_LENGTH] = {0};
595 int32_t err = HRIL_ERR_SUCCESS;
596 ResponseInfo *pResponse = NULL;
597
598 int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CLIR=%d", action);
599 if (ret < 0) {
600 TELEPHONY_LOGE("GenerateCommand is failed!");
601 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
602 return;
603 }
604 err = SendCommandLock(cmd, NULL, 0, &pResponse);
605 if (err != HRIL_ERR_SUCCESS || !pResponse->success) {
606 TELEPHONY_LOGE("ReqSetClir send failed");
607 err = HRIL_ERR_GENERIC_FAILURE;
608 }
609 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
610 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
611 FreeResponseInfo(pResponse);
612 }
613
ReqStartDtmf(const ReqDataInfo * requestInfo,CallDtmfInfo info)614 void ReqStartDtmf(const ReqDataInfo *requestInfo, CallDtmfInfo info)
615 {
616 char cmd[MAX_CMD_LENGTH] = {0};
617 int32_t err = HRIL_ERR_SUCCESS;
618 ResponseInfo *pResponse = NULL;
619
620 int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT^DTMF=%d,%c,1,0", info.callId, info.dtmfKey[0]);
621 if (ret < 0) {
622 TELEPHONY_LOGE("GenerateCommand is failed!");
623 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
624 return;
625 }
626 err = SendCommandLock(cmd, NULL, 0, &pResponse);
627 if (err != HRIL_ERR_SUCCESS || !pResponse->success) {
628 TELEPHONY_LOGE("ReqStartDtmf send failed");
629 err = HRIL_ERR_GENERIC_FAILURE;
630 }
631 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
632 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
633 FreeResponseInfo(pResponse);
634 }
635
ReqSendDtmf(const ReqDataInfo * requestInfo,CallDtmfInfo info)636 void ReqSendDtmf(const ReqDataInfo *requestInfo, CallDtmfInfo info)
637 {
638 char cmd[MAX_CMD_LENGTH] = {0};
639 int32_t err = HRIL_ERR_SUCCESS;
640 ResponseInfo *pResponse = NULL;
641 int32_t stringLength = 0;
642 int32_t ret;
643
644 if (info.dtmfKey == NULL) {
645 err = HRIL_ERR_NULL_POINT;
646 OnCallReportErrorMessages(requestInfo, err, NULL);
647 return;
648 }
649
650 for (stringLength = 0; stringLength < info.stringLength; stringLength++) {
651 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT^DTMF=%d,%c,%d,%d", info.callId, info.dtmfKey[stringLength],
652 info.onLength, info.offLength);
653 if (ret < 0) {
654 TELEPHONY_LOGE("GenerateCommand is failed!");
655 continue;
656 }
657 err = SendCommandLock(cmd, NULL, 0, &pResponse);
658 if (err != HRIL_ERR_SUCCESS || !pResponse->success) {
659 TELEPHONY_LOGE("ReqSendDtmf send failed");
660 err = HRIL_ERR_GENERIC_FAILURE;
661 break;
662 }
663 }
664 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
665 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
666 FreeResponseInfo(pResponse);
667 }
668
ReqStopDtmf(const ReqDataInfo * requestInfo,CallDtmfInfo info)669 void ReqStopDtmf(const ReqDataInfo *requestInfo, CallDtmfInfo info)
670 {
671 char cmd[MAX_CMD_LENGTH] = {0};
672 int32_t err = HRIL_ERR_SUCCESS;
673 ResponseInfo *pResponse = NULL;
674
675 int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT^DTMF=%d,%c,0,0", info.callId, info.dtmfKey[0]);
676 if (ret < 0) {
677 TELEPHONY_LOGE("GenerateCommand is failed!");
678 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
679 return;
680 }
681 err = SendCommandLock(cmd, NULL, 0, &pResponse);
682 if (err != HRIL_ERR_SUCCESS || !pResponse->success) {
683 TELEPHONY_LOGE("ReqStopDtmf send failed");
684 err = HRIL_ERR_GENERIC_FAILURE;
685 }
686 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
687 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
688 FreeResponseInfo(pResponse);
689 }
690
HoldCallAndUnHoldCallAtSend(const ReqDataInfo * requestInfo)691 static void HoldCallAndUnHoldCallAtSend(const ReqDataInfo *requestInfo)
692 {
693 int32_t ret;
694 int32_t err = HRIL_ERR_SUCCESS;
695 ResponseInfo *pResponse = NULL;
696
697 ret = SendCommandLock("AT+CHLD=2", NULL, 0, &pResponse);
698 if (ret != HRIL_ERR_SUCCESS || !pResponse->success) {
699 TELEPHONY_LOGE("ATA send failed");
700 err = HRIL_ERR_GENERIC_FAILURE;
701 }
702
703 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
704 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
705 FreeResponseInfo(pResponse);
706 }
707
ReqHoldCall(const ReqDataInfo * requestInfo)708 void ReqHoldCall(const ReqDataInfo *requestInfo)
709 {
710 HoldCallAndUnHoldCallAtSend(requestInfo);
711 }
712
ReqUnHoldCall(const ReqDataInfo * requestInfo)713 void ReqUnHoldCall(const ReqDataInfo *requestInfo)
714 {
715 HoldCallAndUnHoldCallAtSend(requestInfo);
716 }
717
ReqSwitchCall(const ReqDataInfo * requestInfo)718 void ReqSwitchCall(const ReqDataInfo *requestInfo)
719 {
720 HoldCallAndUnHoldCallAtSend(requestInfo);
721 }
722
ReqCombineConference(const ReqDataInfo * requestInfo,int32_t callType)723 void ReqCombineConference(const ReqDataInfo *requestInfo, int32_t callType)
724 {
725 char cmd[MAX_CMD_LENGTH] = {0};
726 int32_t ret = 0;
727 int32_t count = 3;
728 int32_t err = HRIL_ERR_SUCCESS;
729
730 /* call type
731 * 0: Voice call
732 * 1: Video call: send one-way video, two-way voice
733 * 2: Video call: one-way receiving video, two-way voice
734 * 3: Video call: two-way video, two-way voice
735 */
736 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CHLD=3");
737 if (ret < 0) {
738 TELEPHONY_LOGE("GenerateCommand is failed!");
739 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
740 return;
741 }
742 // "Adds a held call to the conversation"
743 if (callType >= 0 && callType <= count) {
744 long timeout = DEFAULT_TIMEOUT;
745 ret = SendCommandLock(cmd, NULL, timeout, NULL);
746 if (ret != HRIL_ERR_SUCCESS) {
747 TELEPHONY_LOGE("ATA send failed");
748 err = HRIL_ERR_CMD_SEND_FAILURE;
749 }
750 } else {
751 TELEPHONY_LOGE("onRequest HREQ_CALL_COMBINE_CONFERENCE args error!!! \n");
752 err = HRIL_ERR_INVALID_PARAMETER;
753 }
754 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
755 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
756 }
757
ReqSeparateConference(const ReqDataInfo * requestInfo,int32_t callIndex,int32_t callType)758 void ReqSeparateConference(const ReqDataInfo *requestInfo, int32_t callIndex, int32_t callType)
759 {
760 char cmd[MAX_CMD_LENGTH] = {0};
761 int32_t ret = 0;
762 int32_t count = 3;
763 int32_t err = HRIL_ERR_SUCCESS;
764 ResponseInfo *pResponse = NULL;
765
766 // Make sure that party is in a valid range.
767 // (Note: The Telephony middle layer imposes a range of 1 to 7.
768 // It's sufficient for us to just make sure it's single digit.)
769 if ((callIndex > 0) && (callType >= 0 && callType <= count)) {
770 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CHLD=2%d", callIndex);
771 if (ret < 0) {
772 TELEPHONY_LOGE("GenerateCommand is failed!");
773 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
774 return;
775 }
776 ret = SendCommandLock(cmd, NULL, 0, &pResponse);
777 if (ret != HRIL_ERR_SUCCESS) {
778 TELEPHONY_LOGE("ATA send failed");
779 err = HRIL_ERR_CMD_SEND_FAILURE;
780 } else {
781 if (!pResponse->success) {
782 TELEPHONY_LOGE("ATA send failed");
783 err = HRIL_ERR_GENERIC_FAILURE;
784 }
785 }
786 } else {
787 TELEPHONY_LOGE("onRequest req split args error!!!");
788 err = HRIL_ERR_INVALID_PARAMETER;
789 }
790 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
791 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
792 FreeResponseInfo(pResponse);
793 }
794
ReqCallSupplement(const ReqDataInfo * requestInfo,int32_t type)795 void ReqCallSupplement(const ReqDataInfo *requestInfo, int32_t type)
796 {
797 char cmd[MAX_CMD_LENGTH] = {0};
798 int32_t ret = 0;
799 int32_t err = HRIL_ERR_SUCCESS;
800 ResponseInfo *pResponse = NULL;
801
802 switch (type) {
803 case TYPE_HANG_UP_HOLD_WAIT: {
804 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CHLD=0");
805 if (ret < 0) {
806 TELEPHONY_LOGE("GenerateCommand is failed!");
807 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
808 return;
809 }
810 break;
811 }
812 case TYPE_HANG_UP_ACTIVE: {
813 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CHLD=1");
814 if (ret < 0) {
815 TELEPHONY_LOGE("GenerateCommand is failed!");
816 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
817 return;
818 }
819 break;
820 }
821 default: {
822 TELEPHONY_LOGW("ReqCallSupplement warring, type is invalid");
823 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, HRIL_ERR_INVALID_PARAMETER, HRIL_RESPONSE, 0);
824 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
825 FreeResponseInfo(pResponse);
826 return;
827 }
828 }
829
830 const long timeout = 3000;
831 ret = SendCommandLock(cmd, NULL, timeout, &pResponse);
832 if (ret != HRIL_ERR_SUCCESS) {
833 TELEPHONY_LOGE("ReqCallSupplement cmd send failed");
834 err = HRIL_ERR_CMD_SEND_FAILURE;
835 } else {
836 if (!pResponse->success) {
837 TELEPHONY_LOGE("cmd send return error");
838 err = HRIL_ERR_GENERIC_FAILURE;
839 }
840 }
841
842 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
843 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
844 FreeResponseInfo(pResponse);
845 }
846
ReqGetCallWaiting(const ReqDataInfo * requestInfo)847 void ReqGetCallWaiting(const ReqDataInfo *requestInfo)
848 {
849 int32_t err = HRIL_ERR_SUCCESS;
850 ResponseInfo *pResponse = NULL;
851 HRilCallWaitResult hrilCallWaitResult = {0};
852 char *line = NULL;
853 const long timeout = 80000;
854 err = SendCommandLock("AT+CCWA=1,2,1", "+CCWA:", timeout, &pResponse);
855 if (err != HRIL_ERR_SUCCESS) {
856 TELEPHONY_LOGE("ReqGetCallWaiting return, CCWA send failed");
857 err = HRIL_ERR_CMD_SEND_FAILURE;
858 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
859 OnCallReport(
860 GetSlotId(requestInfo), reportInfo, (const uint8_t *)&hrilCallWaitResult, sizeof(HRilCallWaitResult));
861 return;
862 }
863 if (!pResponse->success) {
864 TELEPHONY_LOGE("Get CCWA return ERROR");
865 err = HRIL_ERR_GENERIC_FAILURE;
866 } else {
867 if (pResponse->head != NULL) {
868 line = pResponse->head->data;
869 SkipATPrefix(&line);
870 NextInt(&line, &hrilCallWaitResult.status);
871 NextInt(&line, &hrilCallWaitResult.classCw);
872 } else {
873 TELEPHONY_LOGE("ERROR: ReqGetCallWaiting pResponse->head is null");
874 err = HRIL_ERR_GENERIC_FAILURE;
875 }
876 }
877 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
878 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&hrilCallWaitResult, sizeof(HRilCallWaitResult));
879 FreeResponseInfo(pResponse);
880 }
881
ReqSetCallWaiting(const ReqDataInfo * requestInfo,int32_t active)882 void ReqSetCallWaiting(const ReqDataInfo *requestInfo, int32_t active)
883 {
884 char cmd[MAX_CMD_LENGTH] = {0};
885 int32_t err = HRIL_ERR_SUCCESS;
886 ResponseInfo *pResponse = NULL;
887 const long timeout = 500;
888
889 int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CCWA=1,%d,1", active);
890 if (ret < 0) {
891 TELEPHONY_LOGE("GenerateCommand is failed!");
892 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
893 return;
894 }
895 err = SendCommandLock(cmd, NULL, timeout, &pResponse);
896 if (err != HRIL_ERR_SUCCESS) {
897 TELEPHONY_LOGE("ReqSetCallWaiting return, CCWA send failed");
898 err = HRIL_ERR_CMD_SEND_FAILURE;
899 } else {
900 if (!pResponse->success) {
901 err = HRIL_ERR_GENERIC_FAILURE;
902 }
903 }
904 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
905 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
906 FreeResponseInfo(pResponse);
907 }
908
ReqSetCallTransferInfo(const ReqDataInfo * requestInfo,HRilCFInfo info)909 void ReqSetCallTransferInfo(const ReqDataInfo *requestInfo, HRilCFInfo info)
910 {
911 int32_t numType;
912 const int32_t NUM_F = 145;
913 const int32_t NUM_S = 129;
914 int32_t err = HRIL_ERR_SUCCESS;
915 ResponseInfo *pResponse = NULL;
916 char cmd[MAX_CMD_LENGTH] = {0};
917
918 if (info.reason > CALL_FORWARD_REASON_ALL_CCF || info.mode > CALL_FORWARD_MODE_ERASURE) {
919 TELEPHONY_LOGE("ReqSetCallTransferInfo call forwarding parameter err!!");
920 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, HRIL_ERR_INVALID_PARAMETER, HRIL_RESPONSE, 0);
921 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
922 return;
923 }
924
925 if (info.number != NULL && info.number[0] == '+') {
926 numType = NUM_F;
927 } else {
928 numType = NUM_S;
929 }
930
931 int32_t ret = GenerateCommand(
932 cmd, MAX_CMD_LENGTH, "AT+CCFC=%d,%d,\"%s\",%d,%d", info.reason, info.mode, info.number, numType, info.classx);
933 if (ret < 0) {
934 TELEPHONY_LOGE("GenerateCommand is failed!");
935 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
936 return;
937 }
938 err = SendCommandLock(cmd, NULL, 0, &pResponse);
939 if (err != HRIL_ERR_SUCCESS) {
940 TELEPHONY_LOGE("CCFC send failed");
941 err = HRIL_ERR_CMD_SEND_FAILURE;
942 } else {
943 if (!pResponse->success) {
944 err = HRIL_ERR_GENERIC_FAILURE;
945 }
946 }
947 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
948 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
949 FreeResponseInfo(pResponse);
950 }
951
ReqGetCallTransferInfo(const ReqDataInfo * requestInfo,int32_t reason)952 void ReqGetCallTransferInfo(const ReqDataInfo *requestInfo, int32_t reason)
953 {
954 char cmd[MAX_CMD_LENGTH] = {0};
955 int32_t err = HRIL_ERR_SUCCESS;
956 ResponseInfo *pResponse = NULL;
957 HRilCFQueryInfo queryInfo = {0};
958 char *line = NULL;
959
960 if (reason > CALL_FORWARD_REASON_ALL_CCF) {
961 TELEPHONY_LOGE("ReqGetCallTransferInfo call forwarding parameter err!!");
962 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, HRIL_ERR_INVALID_PARAMETER, HRIL_RESPONSE, 0);
963 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
964 return;
965 }
966 int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CCFC=%d,2", reason);
967 if (ret < 0) {
968 TELEPHONY_LOGE("GenerateCommand is failed!");
969 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
970 return;
971 }
972 err = SendCommandLock(cmd, "+CCFC", 0, &pResponse);
973 if (err != HRIL_ERR_SUCCESS) {
974 TELEPHONY_LOGE("CCFC send failed");
975 err = HRIL_ERR_CMD_SEND_FAILURE;
976 } else if (pResponse != NULL) {
977 if (!pResponse->success) {
978 TELEPHONY_LOGE("CCFC send and return ERROR");
979 err = HRIL_ERR_GENERIC_FAILURE;
980 } else {
981 if (pResponse->head) {
982 line = pResponse->head->data;
983 SkipATPrefix(&line);
984 NextInt(&line, &queryInfo.status);
985 NextInt(&line, &queryInfo.classx);
986 NextStr(&line, &queryInfo.number);
987 NextInt(&line, &queryInfo.type);
988 } else {
989 TELEPHONY_LOGE("ERROR: ReqGetCallTransferInfo pResponse->head is null");
990 err = HRIL_ERR_GENERIC_FAILURE;
991 }
992 }
993 } else {
994 TELEPHONY_LOGE("ERROR: ReqGetCallTransferInfo pResponse is null");
995 err = HRIL_ERR_GENERIC_FAILURE;
996 }
997 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
998 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&queryInfo, sizeof(queryInfo));
999 FreeResponseInfo(pResponse);
1000 }
1001
ReqGetCallRestriction(const ReqDataInfo * requestInfo,const char * fac)1002 void ReqGetCallRestriction(const ReqDataInfo *requestInfo, const char *fac)
1003 {
1004 long long timeOut = DEFAULT_TIMEOUT_CLCK;
1005 int32_t err = HRIL_ERR_SUCCESS;
1006 ResponseInfo *pResponse = NULL;
1007 HRilCallRestrictionResult result = {0};
1008 char *line = NULL;
1009 char cmd[MAX_CMD_LENGTH] = {0};
1010
1011 int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CLCK=\"%s\",2", fac);
1012 if (ret < 0) {
1013 TELEPHONY_LOGE("GenerateCommand is failed!");
1014 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
1015 return;
1016 }
1017 err = SendCommandLock(cmd, "+CLCK:", timeOut, &pResponse);
1018 if (err != HRIL_ERR_SUCCESS) {
1019 TELEPHONY_LOGE("CLCK send failed err = %{public}d", err);
1020 err = HRIL_ERR_CMD_SEND_FAILURE;
1021 } else if (pResponse != NULL) {
1022 if (!pResponse->success) {
1023 TELEPHONY_LOGE("ERROR: ReqGetCallRestriction return ERROR");
1024 err = HRIL_ERR_GENERIC_FAILURE;
1025 } else {
1026 if (pResponse->head) {
1027 line = pResponse->head->data;
1028 SkipATPrefix(&line);
1029 NextInt(&line, &result.status);
1030 NextInt(&line, &result.classCw);
1031 } else {
1032 TELEPHONY_LOGE("ERROR: ReqGetCallRestriction pResponse->head is null");
1033 err = HRIL_ERR_GENERIC_FAILURE;
1034 }
1035 }
1036 } else {
1037 TELEPHONY_LOGE("ERROR: ReqGetCallRestriction pResponse is null");
1038 err = HRIL_ERR_GENERIC_FAILURE;
1039 }
1040 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1041 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&result, sizeof(HRilCallRestrictionResult));
1042 FreeResponseInfo(pResponse);
1043 }
1044
ReqSetCallRestriction(const ReqDataInfo * requestInfo,CallRestrictionInfo info)1045 void ReqSetCallRestriction(const ReqDataInfo *requestInfo, CallRestrictionInfo info)
1046 {
1047 long long timeOut = DEFAULT_TIMEOUT;
1048 char cmd[MAX_CMD_LENGTH] = {0};
1049 int32_t err = HRIL_ERR_SUCCESS;
1050 ResponseInfo *pResponse = NULL;
1051
1052 int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CLCK=\"%s\",%d,\"%s\"", info.fac, info.mode, info.password);
1053 if (ret < 0) {
1054 TELEPHONY_LOGE("GenerateCommand is failed!");
1055 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
1056 return;
1057 }
1058 err = SendCommandLock(cmd, NULL, timeOut, &pResponse);
1059 if (err != HRIL_ERR_SUCCESS) {
1060 TELEPHONY_LOGE("CLCK send failed");
1061 err = HRIL_ERR_CMD_SEND_FAILURE;
1062 } else {
1063 if (!pResponse->success) {
1064 err = HRIL_ERR_GENERIC_FAILURE;
1065 }
1066 }
1067 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1068 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
1069 FreeResponseInfo(pResponse);
1070 }
1071
ReqSetBarringPassword(const ReqDataInfo * requestInfo,HRilSetBarringInfo info)1072 void ReqSetBarringPassword(const ReqDataInfo *requestInfo, HRilSetBarringInfo info)
1073 {
1074 long long timeOut = DEFAULT_TIMEOUT;
1075 char cmd[MAX_CMD_LENGTH] = { 0 };
1076 ResponseInfo *pResponse = NULL;
1077
1078 int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CPWD=\"%s\",\"%s\",\"%s\"", info.fac,
1079 info.oldPassword, info.newPassword);
1080 if (ret < 0) {
1081 TELEPHONY_LOGE("GenerateCommand is failed!");
1082 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
1083 return;
1084 }
1085 int32_t err = SendCommandLock(cmd, NULL, timeOut, &pResponse);
1086 if (err != HRIL_ERR_SUCCESS) {
1087 TELEPHONY_LOGE("CPWD send failed");
1088 err = HRIL_ERR_CMD_SEND_FAILURE;
1089 } else if (pResponse != NULL) {
1090 if (!pResponse->success) {
1091 TELEPHONY_LOGE("ERROR: ReqSetBarringPassword return ERROR");
1092 err = HRIL_ERR_GENERIC_FAILURE;
1093 }
1094 } else {
1095 TELEPHONY_LOGE("ERROR: ReqSetBarringPassword pResponse is null");
1096 err = HRIL_ERR_GENERIC_FAILURE;
1097 }
1098 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1099 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
1100 FreeResponseInfo(pResponse);
1101 }
1102
ReqGetCallPreferenceMode(const ReqDataInfo * requestInfo)1103 void ReqGetCallPreferenceMode(const ReqDataInfo *requestInfo)
1104 {
1105 char *line = NULL;
1106 int32_t mode = VENDOR_FAIL;
1107 int32_t ret = VENDOR_FAIL;
1108 int32_t err = HRIL_ERR_SUCCESS;
1109 ResponseInfo *pResponse = NULL;
1110
1111 ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
1112 ret = SendCommandLock("AT+CEVDP?", "+CEVDP:", 0, &pResponse);
1113 if (ret || pResponse == NULL || !pResponse->success) {
1114 err = (ret != HRIL_ERR_SUCCESS) ? HRIL_ERR_CMD_SEND_FAILURE : err;
1115 TELEPHONY_LOGE("cmd send failed, err:%{public}d", err);
1116 OnCallReportErrorMessages(requestInfo, err, pResponse);
1117 return;
1118 }
1119 if (pResponse->head) {
1120 line = pResponse->head->data;
1121 err = SkipATPrefix(&line);
1122 if (err == 0) {
1123 err = NextInt(&line, &mode);
1124 TELEPHONY_LOGI("mode:%{public}d", mode);
1125 } else {
1126 TELEPHONY_LOGE("response error");
1127 }
1128 } else {
1129 TELEPHONY_LOGE("ERROR: pResponse->head is null");
1130 err = HRIL_ERR_GENERIC_FAILURE;
1131 }
1132 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1133 reportInfo.modemErrInfo = errInfo;
1134 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&mode, sizeof(mode));
1135 FreeResponseInfo(pResponse);
1136 }
1137
ReqSetCallPreferenceMode(const ReqDataInfo * requestInfo,int32_t mode)1138 void ReqSetCallPreferenceMode(const ReqDataInfo *requestInfo, int32_t mode)
1139 {
1140 int32_t ret = VENDOR_FAIL;
1141 int32_t err = HRIL_ERR_SUCCESS;
1142 int32_t value = HRIL_CALL_MODE_CS_1ST_PS_2ND;
1143 char cmd[MAX_CMD_LENGTH] = {0};
1144 ResponseInfo *pResponse = NULL;
1145
1146 ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
1147 value = mode;
1148 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CEVDP=%d", value);
1149 if (ret < 0) {
1150 TELEPHONY_LOGE("GenerateCommand is failed!");
1151 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
1152 return;
1153 }
1154 ret = SendCommandLock(cmd, NULL, 0, &pResponse);
1155 if (ret || (pResponse != NULL && !pResponse->success)) {
1156 errInfo = GetReportErrorInfo(pResponse);
1157 err = errInfo.errorNo;
1158 TELEPHONY_LOGE("cmd send failed, err:%{public}d", ret ? ret : err);
1159 }
1160 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1161 reportInfo.modemErrInfo = errInfo;
1162 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
1163 FreeResponseInfo(pResponse);
1164 }
1165
ReqSetUssd(const ReqDataInfo * requestInfo,const char * str)1166 void ReqSetUssd(const ReqDataInfo *requestInfo, const char *str)
1167 {
1168 int32_t ret;
1169 int32_t err = HRIL_ERR_SUCCESS;
1170 char cmd[MAX_CMD_LENGTH] = {0};
1171 ResponseInfo *pResponse = NULL;
1172 ModemReportErrorInfo errInfo = {};
1173
1174 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CUSD=1, \"% s\" , 15", str);
1175 if (ret < 0) {
1176 TELEPHONY_LOGE("GenerateCommand is failed!");
1177 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
1178 return;
1179 }
1180 ret = SendCommandLock(cmd, NULL, 0, &pResponse);
1181 if (ret || (pResponse != NULL && !pResponse->success)) {
1182 errInfo = GetReportErrorInfo(pResponse);
1183 err = errInfo.errorNo;
1184 TELEPHONY_LOGE("cmd send failed, err:%{public}d", ret ? ret : err);
1185 }
1186 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1187 reportInfo.modemErrInfo = errInfo;
1188 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
1189 FreeResponseInfo(pResponse);
1190 }
1191
ReqGetUssd(const ReqDataInfo * requestInfo)1192 void ReqGetUssd(const ReqDataInfo *requestInfo)
1193 {
1194 int32_t ret;
1195 char *line = NULL;
1196 int32_t cusd = 0;
1197 int32_t err = HRIL_ERR_SUCCESS;
1198 ResponseInfo *pResponse = NULL;
1199 ModemReportErrorInfo errInfo = {};
1200
1201 ret = SendCommandLock("AT+CUSD?", "+CUSD:", 0, &pResponse);
1202 if (ret || pResponse == NULL || !pResponse->success) {
1203 err = ret ? ret : err;
1204 TELEPHONY_LOGE("cmd send failed, err:%{public}d", err);
1205 OnCallReportErrorMessages(requestInfo, err, pResponse);
1206 return;
1207 }
1208 if (pResponse->head) {
1209 line = pResponse->head->data;
1210 err = SkipATPrefix(&line);
1211 if (err == 0) {
1212 err = NextInt(&line, &cusd);
1213 TELEPHONY_LOGI("+CUSD:%{public}d", cusd);
1214 } else {
1215 TELEPHONY_LOGE("response error");
1216 }
1217 } else {
1218 TELEPHONY_LOGE("ERROR: pResponse->head is null");
1219 err = HRIL_ERR_GENERIC_FAILURE;
1220 }
1221 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1222 reportInfo.modemErrInfo = errInfo;
1223 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&cusd, sizeof(cusd));
1224 FreeResponseInfo(pResponse);
1225 }
1226
ReqSetMute(const ReqDataInfo * requestInfo,int32_t mute)1227 void ReqSetMute(const ReqDataInfo *requestInfo, int32_t mute)
1228 {
1229 int32_t ret;
1230 int32_t err = HRIL_ERR_SUCCESS;
1231 char cmd[MAX_CMD_LENGTH] = {0};
1232 ResponseInfo *pResponse = NULL;
1233 ModemReportErrorInfo errInfo = {};
1234
1235 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CMUT=%d ", mute);
1236 if (ret < 0) {
1237 TELEPHONY_LOGE("GenerateCommand is failed!");
1238 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
1239 return;
1240 }
1241 ret = SendCommandLock(cmd, NULL, 0, &pResponse);
1242 if (ret || (pResponse != NULL && !pResponse->success)) {
1243 errInfo = GetReportErrorInfo(pResponse);
1244 err = errInfo.errorNo;
1245 TELEPHONY_LOGE("cmd send failed, err:%{public}d", ret ? ret : err);
1246 }
1247 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1248 reportInfo.modemErrInfo = errInfo;
1249 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
1250 FreeResponseInfo(pResponse);
1251 }
1252
ReqGetMute(const ReqDataInfo * requestInfo)1253 void ReqGetMute(const ReqDataInfo *requestInfo)
1254 {
1255 int32_t ret;
1256 char *line = NULL;
1257 int32_t mute = 0;
1258 int32_t err = HRIL_ERR_SUCCESS;
1259 ResponseInfo *pResponse = NULL;
1260 ModemReportErrorInfo errInfo = {};
1261
1262 ret = SendCommandLock("AT+CMUT?", "+CMUT:", 0, &pResponse);
1263 if (ret || pResponse == NULL || !pResponse->success) {
1264 err = ret ? ret : err;
1265 TELEPHONY_LOGE("cmd send failed, err:%{public}d", err);
1266 OnCallReportErrorMessages(requestInfo, err, pResponse);
1267 return;
1268 }
1269 if (pResponse->head) {
1270 line = pResponse->head->data;
1271 err = SkipATPrefix(&line);
1272 if (err == 0) {
1273 err = NextInt(&line, &mute);
1274 TELEPHONY_LOGI("+CMUT:%{public}d", mute);
1275 } else {
1276 TELEPHONY_LOGE("response error");
1277 }
1278 } else {
1279 TELEPHONY_LOGE("ERROR: pResponse->head is null");
1280 err = HRIL_ERR_GENERIC_FAILURE;
1281 }
1282 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1283 reportInfo.modemErrInfo = errInfo;
1284 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&mute, sizeof(mute));
1285 FreeResponseInfo(pResponse);
1286 }
1287
CallCmdXLEMA(const char * lineCmd,HRilEmergencyInfo * outCall)1288 static int32_t CallCmdXLEMA(const char *lineCmd, HRilEmergencyInfo *outCall)
1289 {
1290 char *pLine = (char *)lineCmd;
1291
1292 if (pLine == NULL || outCall == NULL) {
1293 TELEPHONY_LOGE("src or desc pointer is null.");
1294 return HRIL_ERR_NULL_POINT;
1295 }
1296
1297 if (SkipATPrefix(&pLine) < 0) {
1298 return HRIL_ERR_NULL_POINT;
1299 }
1300 if (NextInt(&pLine, &outCall->index) < 0) {
1301 return HRIL_ERR_NULL_POINT;
1302 }
1303 if (NextInt(&pLine, &outCall->total) < 0) {
1304 return HRIL_ERR_NULL_POINT;
1305 }
1306 if (NextStr(&pLine, &outCall->eccNum) < 0) {
1307 return HRIL_ERR_NULL_POINT;
1308 }
1309 if (NextInt(&pLine, &outCall->category) < 0) {
1310 return HRIL_ERR_NULL_POINT;
1311 }
1312 if (NextInt(&pLine, &outCall->simpresent) < 0) {
1313 return HRIL_ERR_NULL_POINT;
1314 }
1315 if (NextStr(&pLine, &outCall->mcc) < 0) {
1316 return HRIL_ERR_NULL_POINT;
1317 }
1318 if (NextInt(&pLine, &outCall->abnormalService) < 0) {
1319 return HRIL_ERR_NULL_POINT;
1320 }
1321 return HRIL_ERR_SUCCESS;
1322 }
1323
InitGetEmergencyCallList(const ResponseInfo * pResponse,int32_t * callNum,HRilEmergencyInfo ** pEmergencyCalls)1324 static int32_t InitGetEmergencyCallList(const ResponseInfo *pResponse, int32_t *callNum,
1325 HRilEmergencyInfo **pEmergencyCalls)
1326 {
1327 int32_t ret;
1328 int32_t callNumTmp = 0;
1329 Line *pLine = NULL;
1330 HRilEmergencyInfo *pEmergencyCallsTmp = NULL;
1331
1332 if (pResponse == NULL || pEmergencyCalls == NULL || callNum == NULL) {
1333 TELEPHONY_LOGE("params: %{public}p,%{public}p,%{public}p", pResponse, callNum, pEmergencyCalls);
1334 return HRIL_ERR_NULL_POINT;
1335 }
1336
1337 *callNum = 0;
1338 *pEmergencyCalls = NULL;
1339
1340 for (pLine = pResponse->head; pLine != NULL; pLine = pLine->next) {
1341 callNumTmp++;
1342 }
1343 if (!callNumTmp) {
1344 callNumTmp++; // Malloc size cannot be 0.
1345 }
1346 pEmergencyCallsTmp = (HRilEmergencyInfo *)malloc(callNumTmp * sizeof(HRilEmergencyInfo));
1347 if (pEmergencyCallsTmp == NULL) {
1348 TELEPHONY_LOGE("ReqGetCallList malloc pCalls failure");
1349 return HRIL_ERR_MEMORY_FULL;
1350 }
1351 ret = memset_s(
1352 pEmergencyCallsTmp, callNumTmp * sizeof(HRilEmergencyInfo), 0, callNumTmp * sizeof(HRilEmergencyInfo));
1353 if (ret != EOK) {
1354 TELEPHONY_LOGE("memset_s is failed!");
1355 free(pEmergencyCallsTmp);
1356 pEmergencyCallsTmp = NULL;
1357 return ret;
1358 }
1359
1360 *pEmergencyCalls = pEmergencyCallsTmp;
1361 *callNum = callNumTmp;
1362
1363 return HRIL_ERR_SUCCESS;
1364 }
1365
BuildGetEmergencyCallList(const ReqDataInfo * requestInfo,ResponseInfo * response)1366 int32_t BuildGetEmergencyCallList(const ReqDataInfo *requestInfo, ResponseInfo *response)
1367 {
1368 int32_t ret = 0;
1369 int32_t callNum = 0;
1370 int32_t validCallNum = 0;
1371 int32_t err = HRIL_ERR_SUCCESS;
1372 Line *pLine = NULL;
1373 ResponseInfo *pResponse = response;
1374 HRilEmergencyInfo *pEmergencyCalls = NULL;
1375
1376 if (pResponse == NULL || requestInfo == NULL) {
1377 TELEPHONY_LOGE("response or requestInfo is null.");
1378 return HRIL_ERR_NULL_POINT;
1379 }
1380 if (pResponse->success == 0) {
1381 TELEPHONY_LOGE("send cmd return ERROR");
1382 err = HRIL_ERR_GENERIC_FAILURE;
1383 }
1384
1385 ret = InitGetEmergencyCallList(pResponse, &callNum, &pEmergencyCalls);
1386 if (ret != HRIL_ERR_SUCCESS) {
1387 TELEPHONY_LOGE("init command failed: %{public}d", ret);
1388 return ret;
1389 }
1390
1391 for (pLine = pResponse->head; pLine != NULL && validCallNum < callNum; pLine = pLine->next) {
1392 ret = CallCmdXLEMA(pLine->data, pEmergencyCalls + validCallNum);
1393 if (ret != 0) {
1394 TELEPHONY_LOGE("Parse CLCC data is fail. ret:%{public}d", ret);
1395 continue;
1396 }
1397 validCallNum++;
1398 }
1399
1400 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1401 OnCallReport(
1402 GetSlotId(requestInfo), reportInfo, (const uint8_t *)pEmergencyCalls, sizeof(HRilEmergencyInfo) * validCallNum);
1403 FreeResponseInfo(pResponse);
1404 free(pEmergencyCalls);
1405 return HRIL_ERR_SUCCESS;
1406 }
1407
ReqGetEmergencyCallList(const ReqDataInfo * requestInfo)1408 void ReqGetEmergencyCallList(const ReqDataInfo *requestInfo)
1409 {
1410 int32_t ret;
1411 ResponseInfo *pResponse = NULL;
1412 int32_t err = HRIL_ERR_SUCCESS;
1413 long timeOut = DEFAULT_TIMEOUT;
1414
1415 ret = SendCommandLock("AT^XLEMA?", "^XLEMA:", timeOut, &pResponse);
1416 if (ret || (pResponse != NULL && !pResponse->success)) {
1417 err = (ret != HRIL_ERR_SUCCESS) ? HRIL_ERR_CMD_SEND_FAILURE : err;
1418 TELEPHONY_LOGE("cmd send failed, err:%{public}d", err);
1419 OnCallReportErrorMessages(requestInfo, err, pResponse);
1420 return;
1421 }
1422 err = BuildGetEmergencyCallList(requestInfo, pResponse);
1423 if (err != HRIL_ERR_SUCCESS) {
1424 TELEPHONY_LOGE("Build Call Info List is failed.");
1425 OnCallReportErrorMessages(requestInfo, err, pResponse);
1426 }
1427 }
1428
ReqSetEmergencyCallList(const ReqDataInfo * requestInfo,HRilEmergencyInfo * emergencyInfo,const int len)1429 void ReqSetEmergencyCallList(const ReqDataInfo *requestInfo, HRilEmergencyInfo *emergencyInfo, const int len)
1430 {
1431 TELEPHONY_LOGI("ReqSetEmergencyCallList start");
1432 int32_t ret = 0;
1433 int32_t err = HRIL_ERR_SUCCESS;
1434 char cmd[MAX_CMD_LENGTH] = {0};
1435 ResponseInfo *pResponse = NULL;
1436 ModemReportErrorInfo errInfo = {};
1437 for (int i = 0; i < len; i++) {
1438 ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT^NVM=%d,%d,\"%s\",%d,%d,%s,%d", emergencyInfo[i].index,
1439 emergencyInfo[i].total, emergencyInfo[i].eccNum, emergencyInfo[i].category, emergencyInfo[i].simpresent,
1440 emergencyInfo[i].mcc, emergencyInfo[i].abnormalService);
1441 if (ret < 0) {
1442 TELEPHONY_LOGE("GenerateCommand is failed!");
1443 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
1444 return;
1445 }
1446 ret = SendCommandLock(cmd, NULL, 0, &pResponse);
1447 if (ret || (pResponse != NULL && !pResponse->success)) {
1448 errInfo = GetReportErrorInfo(pResponse);
1449 err = errInfo.errorNo;
1450 TELEPHONY_LOGE("cmd send failed, err:%{public}d", ret ? ret : err);
1451 }
1452 }
1453 TELEPHONY_LOGI("ReqSetEmergencyCallList end");
1454 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1455 reportInfo.modemErrInfo = errInfo;
1456 OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
1457 FreeResponseInfo(pResponse);
1458 }
1459
ReqGetCallFailReason(const ReqDataInfo * requestInfo)1460 void ReqGetCallFailReason(const ReqDataInfo *requestInfo)
1461 {
1462 int32_t err = HRIL_ERR_SUCCESS;
1463 ResponseInfo *pResponse = NULL;
1464 ModemReportErrorInfo errInfo = {};
1465
1466 if (lastCcCause == HRIL_ERR_CALL_CAUSE) {
1467 TELEPHONY_LOGE("lastCcCause is none!");
1468 OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
1469 return;
1470 }
1471
1472 struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
1473 reportInfo.modemErrInfo = errInfo;
1474 OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&lastCcCause, sizeof(lastCcCause));
1475 FreeResponseInfo(pResponse);
1476 }
1477