blob: f900f1e6792cc2e2cf5f634abd2e3f2a75131493 [file] [log] [blame]
lhb07f4e12022-02-17 22:08:54 -08001//SPDX-License-Identifier: MediaTekProprietary
lh7b0674a2022-01-10 00:34:35 -08002/* Copyright Statement:
3 *
4 * This software/firmware and related documentation ("MediaTek Software") are
5 * protected under relevant copyright laws. The information contained herein
6 * is confidential and proprietary to MediaTek Inc. and/or its licensors.
7 * Without the prior written permission of MediaTek inc. and/or its licensors,
8 * any reproduction, modification, use or disclosure of MediaTek Software,
9 * and information contained herein, in whole or in part, shall be strictly prohibited.
10 */
11/* MediaTek Inc. (C) 2010. All rights reserved.
12 *
13 * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
14 * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
15 * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
16 * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
19 * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
20 * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
21 * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
22 * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
23 * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
24 * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
25 * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
26 * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
27 * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
28 * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
29 * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
30 * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
31 *
32 * The following software/firmware and/or related documentation ("MediaTek Software")
33 * have been modified by MediaTek Inc. All revisions are subject to any receiver's
34 * applicable license agreements with MediaTek Inc.
35 */
36#include "cc.h"
37#include <alloca.h>
38#include <stdlib.h>
39#include <stdio.h>
40#include <cutils/jstring.h>
41#include <stdbool.h>
42#include <glib.h>
43#include <string.h>
44#include <string>
45#include <thread>
46#include "eCall.h"
47/*Warren add for t800 ril servie 2021/12/23 start*/
48#include "lynq_interface.h"
49#include <binder/Parcel.h>
q.huang1c03f752023-12-14 14:11:58 +080050#include "call_rtp.h"
lh7b0674a2022-01-10 00:34:35 -080051using android::Parcel;
52/*Warren add for t800 ril servie 2021/12/23 end*/
53
54static int dtmf_volume = 0;
55void *dtmf_handle = NULL;
56
57extern "C" {
58 #include <dtmf.h>
59 #include "mixer_ctrl.h"
60}
61#undef LOG_TAG
62#define LOG_TAG "LYNQ_RIL_CC"
63
64static speech_status speechStatus = SPEECH_OFF;
65static int autoAnswerMode = 0;
66static int inCallRecordMode = 0;
67static call_status inCallstatus = CALL_OFF;
68//int callIndex = 0;
69const char g_card_name[] = "mtk_phonecall";
70/*for speech on*/
71const char g_mixer_name[] = "Speech_on";
72const char g_mixer_name_ecall[] = "Speech_on_ecall";
73const char g_mixer_reset_name[] = "Modem_reset_notify";
74const char g_mixer_name_bt[] = "Speech_on_bt";
75const char g_bt_has_ecnr_name[] = "BT_HAS_ECNR";
76const char g_bt_wbs_name[] = "BT_WBS";
77int g_audio_path = 0; // 0: normal, 1: bt
78int g_bt_has_ecnr_value = 0; // 0: ecnr, 1, no ecnr
79int g_bt_wbs_value = 0; // 0: 8000, 1, 16000
80/*for DL call volume*/
81const char g_mixer_name_volume[] = "DL Call";
82const char g_mixer_name_volume_bt[] = "DL BT";
83
84const char g_DL_mute_name[] = "Speech_DL_mute";
85const char g_UL_mute_name[] = "Speech_UL_mute";
86
87const char *RING_PATH = "/system/etc/tele/ring/ring.wav";
88static bool isRingStart = false;
89
90#if defined(TARGET_PLATFORM_MT2731)||defined(TARGET_PLATFORM_MT2735)
91#define MAX_VOLUME (7)
92#define MIN_VOLUME (1)
93#endif
94
95#ifdef TARGET_PLATFORM_MT2635
96#define MAX_VOLUME (17)
97#define MIN_VOLUME (-23)
98#endif
99
100#define BT_MAX_VOLUME (15)
101#define BT_MIN_VOLUME (0)
102#define DTMF_MAX_VOLUME (36)
103#define DTMF_MIN_VOLUME (0)
104
105int get_call_status(void)
106{
107 return inCallstatus;
108}
109
110void set_audio_path(int path)
111{
112 if ((path != 0) && (path != 1)) {
113 RLOGE("set_audio_path() illegal value %d, we support 0: normal, 1: bt", path);
114 return;
115 }
116
117 g_audio_path = path;
118}
119
120int get_audio_path(void)
121{
122 return g_audio_path;
123}
124
125void set_bt_has_ecnr(int ecnr)
126{
127 if ((ecnr != 0) && (ecnr != 1)) {
128 RLOGE("set_bt_has_ecnr() illegal value %d, we support 0: do ecnr, 1: no ecnr", ecnr);
129 return;
130 }
131
132 g_bt_has_ecnr_value = ecnr;
133}
134
135int get_bt_has_ecnr(void)
136{
137 return g_bt_has_ecnr_value;
138}
139
140void set_bt_wbs(int wbs)
141{
142 if ((wbs < 0) || (wbs > 15)) {
143 RLOGE("set_bt_wbs() illegal value %d, we support 0~15", wbs);
144 return;
145 }
146
147 g_bt_wbs_value = wbs;
148}
149
150int get_bt_wbs(void)
151{
152 return g_bt_wbs_value;
153}
154
155int mixer_init()
156{
157 RLOGD("set_card_name: %s", g_card_name);
158 int ret;
159
160 // only need to set card name once
161 ret = set_card_name(g_card_name);
162 RLOGD("mixer_init(%s) = %d", g_card_name, ret);
163 return ret;
164}
165int mixer_set(int value )
166{
167 int ret;
168
169 //set mixer ctl to om:1 or off:0
170 if(value){
q.huang1c03f752023-12-14 14:11:58 +0800171 //ret = set_mixer_ctrl_value_int(isEcallAudioPath() ? g_mixer_name_ecall: g_mixer_name, value);
172 if(isEcallAudioPath())
173 {
174 exe_set_voice_audio_mode(AUDIO_MODE_CODEC);
175 }
176 else
177 {
178 exe_set_voice_audio_mode(AUDIO_MODE_RTP);
179 }
180 // RLOGD("mixer_set(%s) = %d, ret: %d", (isEcallAudioPath() ? g_mixer_name_ecall: g_mixer_name), value, ret);
181 } else {
182 exe_set_voice_audio_mode(AUDIO_MODE_ALL_CLOSE);
183/*
lh7b0674a2022-01-10 00:34:35 -0800184 ret = get_mixer_ctrl_value_int(g_mixer_name);
185 RLOGD("mixer_set(get_mixer_ctrl_value_int: %s) = %d", g_mixer_name, ret);
xja1c30b82022-01-25 16:13:48 +0800186 if(ret > 0) {
lh7b0674a2022-01-10 00:34:35 -0800187 ret = set_mixer_ctrl_value_int(g_mixer_name, value);
188 RLOGD("mixer_set(%s) = %d", g_mixer_name, ret);
189 } else {
190 ret = set_mixer_ctrl_value_int(g_mixer_name_ecall, value);
191 RLOGD("mixer_set(%s) = %d", g_mixer_name_ecall, ret);
192 }
q.huang1c03f752023-12-14 14:11:58 +0800193*/
lh7b0674a2022-01-10 00:34:35 -0800194 }
195
196
197 return ret;
198}
199int mixer_reset_set(int value )
200{
201 int ret;
202
203 // set mixer to reset:1
204 ret = set_mixer_ctrl_value_int(g_mixer_reset_name, value);
205 RLOGD("mixer_reset_set(%s) = %d", g_mixer_reset_name, ret);
206 return ret;
207}
208int bt_mixer_set(int value)
209{
210 int ret;
211
212 //set mixer ctrl to on:1 or off:0
213 // bt speech
214 int bt_has_ecnr = get_bt_has_ecnr();
215 int bt_wbs = get_bt_wbs();
216 ret = set_mixer_ctrl_value_int(g_bt_has_ecnr_name, bt_has_ecnr);
217 ret = set_mixer_ctrl_value_int(g_bt_wbs_name, bt_wbs);
218 ret = set_mixer_ctrl_value_int(g_mixer_name_bt, value);
219
220 if (ret)
221 RLOGE("set_mixer_ctrl_value_int err: %d", ret);
222 return ret;
223}
224
225int mixer_check(int mix)
226{
227 int ret;
228
229 if (mix == 0) {
230 ret = get_mixer_ctrl_value_int(g_mixer_name);
231 } else if (mix == 1){
232 ret = get_mixer_ctrl_value_int(g_mixer_name_bt);
233 } else {
234 RLOGE("mixer_check wrong mix %d", mix);
xja1c30b82022-01-25 16:13:48 +0800235 ret = -1;
lh7b0674a2022-01-10 00:34:35 -0800236 }
237 RLOGD("The ctrl \"%s\" is set to %d ", g_mixer_name, ret);
238 return ret;
239}
240int mixer_set_volume(int value)
241{
242 int ret;
243 if (get_audio_path() == 0) {
244 ret = set_mixer_ctrl_volume_value(g_mixer_name_volume, value);
245 } else {
246 ret = set_mixer_ctrl_volume_value(g_mixer_name_volume_bt, value);
247 }
248 if (ret)
249 RLOGE("set_mixer_ctrl_volume_value_int err: %d", ret);
250 return ret;
251}
252long int mixer_get_volume()
253{
254 long int vol_value;
255 if (get_audio_path() == 0) {
256 vol_value = get_mixer_ctrl_volume_value(g_mixer_name_volume);
257 } else {
258 vol_value = get_mixer_ctrl_volume_value(g_mixer_name_volume_bt);
259 }
lhb07f4e12022-02-17 22:08:54 -0800260 RLOGD("The ctrl \"%s\" is set to %ld", g_mixer_name_volume, vol_value);
lh7b0674a2022-01-10 00:34:35 -0800261 return vol_value;
262}
263
264GstElement *pipeline_element;
265GstState gst_cur_state = GST_STATE_NULL;
266static int gst_status = 0;
267
268int GSM_Init(char* filepath)
269{
270 GstElement *pipeline, *source, *mux, *encoder, *sink;
271 RLOGD("[GSM]GSM Init Start!");
272 /* Initialisation */
273 gst_init (NULL, NULL);
274
275 pipeline = gst_pipeline_new ("3gppmux-test");
276 source = gst_element_factory_make ("pulsesrc", "file-source");
277 encoder = gst_element_factory_make ("faac", "encoder");
278 mux = gst_element_factory_make ("3gppmux", "muxer");
279 sink = gst_element_factory_make ("filesink", "output");
280
281 g_object_set(mux, "fragment-duration", 100, NULL);
282 g_object_set(sink, "location", filepath, NULL);
283
284 if (!pipeline || !source || !encoder || !mux || !sink) {
285 if(pipeline) {
286 gst_object_unref (GST_OBJECT (pipeline));
287 pipeline = NULL;
288 }
289 if(source) {
290 gst_object_unref (GST_OBJECT (source));
291 source = NULL;
292 }
293 if(encoder) {
294 gst_object_unref (GST_OBJECT (encoder));
295 encoder = NULL;
296 }
297 if(mux) {
298 gst_object_unref (GST_OBJECT (mux));
299 mux = NULL;
300 }
301 if(sink) {
302 gst_object_unref (GST_OBJECT (sink));
303 sink = NULL;
304 }
305 RLOGE ("[GSM]One element could not be created. Exiting");
306 return -1;
307 }
308
309 gst_bin_add_many (GST_BIN (pipeline), source, encoder, mux, sink, NULL);
310 gst_element_link_many (source, encoder, mux, sink, NULL);
311
312 pipeline_element = pipeline;
313 gst_status = 1; //initial done
314 RLOGD("[GSM]GSM Init Done!");
315 return 0;
316}
317
318int GSM_Start(void)
319{
320 RLOGD("[GSM]GSM Start start!");
321 if(gst_status == 2)
322 return 0;
323
324 if(gst_status == 1 || gst_status ==3) {
325 GstStateChangeReturn ret = gst_element_set_state (pipeline_element, GST_STATE_PLAYING);
326
327 RLOGD("[GSM]Running... return: %d", ret);
328 //g_main_loop_run (gst_loop);
329 gst_status = 2; //start done
330 } else {
331 return -1;
332 }
333 RLOGD("[GSM]GSM Start End!");
334 return 0;
335}
336
337int GSM_Stop()
338{
339 RLOGD("[GSM]GSM Stop Start!");
340 if (gst_status == 4)
341 return 0;
342
343 if(gst_status == 2 || gst_status == 3) {
344 /* Out of the main loop, clean up nicely */
345 gboolean isSend = gst_element_send_event (pipeline_element, gst_event_new_eos ());
346 GstStateChangeReturn ret = gst_element_set_state (pipeline_element, GST_STATE_NULL);
347 RLOGD("[GSM]Returned, stopping playback. ret: %d, isSend: %d", ret, isSend);
348 gst_status = 4;
349 } else {
350 return -1;
351 }
352 RLOGD("[GSM]GSM Stop End!");
353 return 0;
354}
355
356int GSM_Close()
357{
358 RLOGD("[GSM]Deleting pipeline");
359 gst_object_unref (GST_OBJECT (pipeline_element));
360 gst_deinit ();
361 gst_status = 0;
362 RLOGD("[GSM]GSM Close Done!");
363 return 0;
364}
365/*cmd:1, address,
366*2, clirMode,
367*3, if present, uusinfo.type
368*4, as above, uusinfo.Dcs
369*5, as above, uusinfo.userdatalength
370*6, as above, uusinfo.UserData
371*/
372//RIL_REQUEST_DIAL
373int dial(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
374{
375 android::Parcel p;
376 size_t pos = p.dataPosition();
377
378 if (argc < 3 || argv[1]==NULL) {
379 //add log msg
380 free(pRI);
381 return -1;
382 }
383 //address;
384 writeStringToParcel(p, (const char *)argv[1]);
385 //clirMode
386 if (argc >=2) {
387 p.writeInt32(atoi(argv[2]));
388
389 if (argc == 7 && argv[3] != NULL
390 && argv[4] != NULL && argv[5] != NULL
391 && argv[6] != NULL ) {
392 p.writeInt32(1); // UUS information is present
393 p.writeInt32(atoi(argv[3]));
394 p.writeInt32(atoi(argv[4]));
395 p.writeByteArray((size_t)atoi(argv[5]),(uint8_t*)argv[6]);
396 } else {
397 p.writeInt32(0); // UUS information is absent
398 }
399 }
400 p.setDataPosition(pos);
q.huang1c03f752023-12-14 14:11:58 +0800401// setEcallAudioPathOn(false);
lh7b0674a2022-01-10 00:34:35 -0800402 pRI->pCI->dispatchFunction(p, pRI);
403 inCallstatus = CALL_ON;
404 return 0;
405}
406#if 0 //not need user setup
407//RIL_REQUEST_OEM_HOOK_STRINGS
408int invokeOemRilRequestStrings(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
409{
410 android::Parcel p;
411 size_t pos = p.dataPosition();
412 RLOGD("OEM_HOOK_STRINGS: p1->\"%s\",p2->\"%s\"",argv[1],argv[2]);
413 p.writeInt32(2);
414 writeStringToParcel(p, (const char *)argv[1]);
415 writeStringToParcel(p, "\"\"");//(const char *)argv[2]);
416 p.setDataPosition(pos);
417
418 pRI->pCI->dispatchFunction(p, pRI);
419 return 0;
420}
421#endif
422
423extern void ARspRequest (int request,RIL_SOCKET_ID socket_id);
424//RIL_REQUEST_SET_AUDIO_PATH
425/*cmd:1, speech mode,
426*2, bt_has_ecnr
427*3, bt_wbs
428*/
429int setAudioPath(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
430{
431 if (argc < 1) {
432 free(pRI);
433 RLOGE("set bt mode need bt_has_encr and bt_wbs");
434 return -1;
435 }
436
437 int temp_audio_path = atoi(argv[1]);
438 int bt_has_ecnr;
439 int bt_wbs;
440 int current_audio_path = get_audio_path();
441 RLOGD("setAudioPath enter");
442 if ((temp_audio_path != 0) && (temp_audio_path != 1)) {
443 RLOGE("audio path illegal %d, only support 0 and 1", temp_audio_path);
444 return -1;
445 }
446 set_audio_path(temp_audio_path);
447 RLOGD("set audio path to %d, current audio path is %d", temp_audio_path, current_audio_path);
448 if (temp_audio_path == 1) {
449 /* bt speech need BT_HAS_ECNR and BT_WBS */
450 bt_has_ecnr = atoi(argv[2]);
451 bt_wbs = atoi(argv[3]);
452 set_bt_has_ecnr(bt_has_ecnr);
453 set_bt_wbs(bt_wbs);
454 RLOGD("set bt_has_ecnr %d, bt_wbs %d", bt_has_ecnr, bt_wbs);
455 }
456 if ((current_audio_path != temp_audio_path)
457 && (get_call_status() == CALL_ON)) {
458 if (current_audio_path == 0) {
459 if (getSpeechStatus() == NORMAL_SPEECH_ON) {
460 RLOGD("normal speech off then bt speech on");
461 mixer_set(0);
462 setSpeechAndStatus(2);
463 }
464 } else {
465 if (getSpeechStatus() == BT_SPEECH_ON) {
466 RLOGD("bt speech off then normal speech on");
467 bt_mixer_set(0);
468 setSpeechAndStatus(1);
469 }
470 }
471 }
472 if (pRI != NULL) {
473 free(pRI);
474 }
475
476 RLOGD("setAudioPath done");
477 return 0;
478}
479
480
481//RIL_REQUEST_HANGUP
482int hangupConnection(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
483{
484 android::Parcel p;
485 size_t pos = p.dataPosition();
486
487 p.writeInt32(1);
488 p.writeInt32(atoi(argv[1]));
489 p.setDataPosition(pos);
490
491 pRI->pCI->dispatchFunction(p, pRI);
492 return 0;
493}
494
495//RIL_REQUEST_FORCE_RELEASE_CALL
496int forceReleaseCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
497{
498 android::Parcel p;
499 size_t pos = p.dataPosition();
500
501 p.writeInt32(1);
502 p.writeInt32(atoi(argv[1]));
503 p.setDataPosition(pos);
504
505 pRI->pCI->dispatchFunction(p, pRI);
506 return 0;
507}
508
509//RIL_REQUEST_SEPARATE_CONNECTION
510int separateConnection(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
511{
512 android::Parcel p;
513 size_t pos = p.dataPosition();
514
515 p.writeInt32(1);
516 p.writeInt32(atoi(argv[1]));
517 p.setDataPosition(pos);
518
519 pRI->pCI->dispatchFunction(p, pRI);
520 return 0;
521}
522//RIL_REQUEST_DTMF
523//RIL_REQUEST_DTMF_START
524int sendDtmf(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
525{
526 android::Parcel p;
527 int number;
528 size_t pos = p.dataPosition();
529 char * c_num = NULL;
530
531 c_num = argv[1];
532 if (c_num == NULL) {
533 free(pRI);
534 return -1;
535 }
536 number = int(c_num[0] - '0');
537 if(number == -6)
538 number = 10;
539 if(number == -13)
540 number = 11;
541 RLOGD("DTMF input number is %s-->%d",c_num,number);
542 if ( number < 0 || number > 15 ) {
543 RLOGE("DTMF input number error");
544 free(pRI);
545 return -1;
546 }
547
548 writeStringToParcel(p, (const char *)argv[1]);
549 p.setDataPosition(pos);
550
551 dtmf_stop(dtmf_handle);
552 gint time_ms = 500;
553 if (pRI->pCI->requestNumber == RIL_REQUEST_DTMF_START) {
554 time_ms = 0;
555 }
556 RLOGD("request: %d, time_ms = %d", pRI->pCI->requestNumber, time_ms);
557 dtmf_handle = dtmf_start(number, time_ms, dtmf_volume, NULL);
558 pRI->pCI->dispatchFunction(p, pRI);
559 if (dtmf_handle == NULL)
560 RLOGE("[DTMF] dtmf_start return NULL!");
561 return 0;
562}
563
564//RIL_REQUEST_UDUB
565int rejectCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
566{
567 android::Parcel p;
568
569 pRI->pCI->dispatchFunction(p, pRI);
570 return 0;
571}
572//RIL_REQUEST_ANSWER
573int acceptCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
574{
575 android::Parcel p;
576
577 pRI->pCI->dispatchFunction(p, pRI);
578 inCallstatus = CALL_ON;
579 return 0;
580}
581
582//RIL_REQUEST_HANGUP_ALL
583int hangupAll(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
584{
585 android::Parcel p;
586
587 pRI->pCI->dispatchFunction(p, pRI);
588 return 0;
589}
590
591//RIL_REQUEST_CONFERENCE
592int conference(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
593{
594 android::Parcel p;
595
596 pRI->pCI->dispatchFunction(p, pRI);
597 return 0;
598}
599//RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND
600int hangupWaitingOrBackground(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
601{
602 android::Parcel p;
603
604 pRI->pCI->dispatchFunction(p, pRI);
605 return 0;
606}
607//RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE
608int switchWaitingOrHoldingAndActive(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
609{
610 android::Parcel p;
611
612 pRI->pCI->dispatchFunction(p, pRI);
613 return 0;
614}
615//RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND
616int hangupForegroundResumeBackground(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
617{
618 android::Parcel p;
619
620 pRI->pCI->dispatchFunction(p, pRI);
621 return 0;
622}
623//RIL_REQUEST_EXPLICIT_CALL_TRANSFER
624int explicitCallTransfer(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
625{
626 android::Parcel p;
627
628 pRI->pCI->dispatchFunction(p, pRI);
629 return 0;
630}
631
632//RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER
633int addImsConferenceCallMember(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
634{
635 android::Parcel p;
636 size_t pos = p.dataPosition();
637
638 p.writeInt32(3);
639 writeStringToParcel(p, (const char *)argv[1]);//confCallId
640 writeStringToParcel(p, (const char *)argv[2]);//address
641 writeStringToParcel(p, (const char *)argv[3]);//CallIdToAdd
642
643 p.setDataPosition(pos);
644 pRI->pCI->dispatchFunction(p, pRI);
645 return 0;
646}
647//RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER
648int removeImsConferenceCallMember(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
649{
650 android::Parcel p;
651 size_t pos = p.dataPosition();
652
653 p.writeInt32(3);
654 writeStringToParcel(p, (const char *)argv[1]);//confCallId
655 writeStringToParcel(p, (const char *)argv[2]);//address
656 writeStringToParcel(p, (const char *)argv[3]);//CallIdToRemove
657
658 p.setDataPosition(pos);
659 pRI->pCI->dispatchFunction(p, pRI);
660 return 0;
661}
662//RIL_REQUEST_CONFERENCE_DIAL
663//argv[1]:DialMethod
664//argv[2]:ParticipantsNumber
665//argv[2+ParticipantsNumber]:addresss
666//argv[2+ParticipantsNumber+1]:clir
667int conferenceDial(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
668{
669 android::Parcel p;
670 size_t pos = p.dataPosition();
671 int ParticipantsNumber,i;
672
673 if( argc < 3 ) {
674 free(pRI);
675 RLOGE("Error: conference Dial parameter is error!");
676 return -1;
677 }
678
679 ParticipantsNumber = atoi(argv[2]);
680
681 if( argc < (ParticipantsNumber+3) ) {
682 free(pRI);
683 RLOGE("Error: Dial With SIP URI parameter is error! \
684 argc is %d, and need parameter %d",argc,(ParticipantsNumber+3));
685 return -1;
686 }
687
688 p.writeInt32((ParticipantsNumber+3));
689 writeStringToParcel(p, (const char *)argv[1]); //DialMethod
690 writeStringToParcel(p, (const char *)argv[2]); //ParticipantsNumber
691 for( i=0; i<ParticipantsNumber; i++ ){ //address
692 writeStringToParcel(p, (const char *)argv[3+i]);
693 }
694 writeStringToParcel(p, (const char *)argv[3+ParticipantsNumber]);//clir
695
696 p.setDataPosition(pos);
697 setEcallAudioPathOn(false);
698 pRI->pCI->dispatchFunction(p, pRI);
699 return 0;
700}
701//RIL_REQUEST_DIAL_WITH_SIP_URI
702int dialWithSipUri(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
703{
704 android::Parcel p;
705 size_t pos = p.dataPosition();
706
707 if (argc < 3 || argv[1]==NULL) {
708 free(pRI);
709 return -1;
710 }
711
712 writeStringToParcel(p, (const char *)argv[1]);//address
713 /* for compatibility of test script, still receive clirMode and UUS,
714 but don't send them to libvendor-ril */
715#if 0
716 p.writeInt32(atoi(argv[2]));//clirMode
717 p.writeInt32(0); // UUS information is absent
718#endif
719
720 p.setDataPosition(pos);
q.huang1c03f752023-12-14 14:11:58 +0800721// setEcallAudioPathOn(false);
lh7b0674a2022-01-10 00:34:35 -0800722 pRI->pCI->dispatchFunction(p, pRI);
723 return 0;
724}
725//RIL_REQUEST_HOLD_CALL
726int holdCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
727{
728 android::Parcel p;
729 size_t pos = p.dataPosition();
730
731 if (argc < 2 || argv[1]==NULL) {
732 free(pRI);
733 return -1;
734 }
735
736 //callIDToHold
737 p.writeInt32(1);
738 p.writeInt32(atoi(argv[1]));
739
740 p.setDataPosition(pos);
741
742 pRI->pCI->dispatchFunction(p, pRI);
743 return 0;
744}
745//RIL_REQUEST_RESUME_CALL
746int resumeCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
747{
748 android::Parcel p;
749 size_t pos = p.dataPosition();
750
751 if (argc < 2 || argv[1]==NULL) {
752 free(pRI);
753 return -1;
754 }
755
756 //callIDToResume
757 p.writeInt32(1);
758 p.writeInt32(atoi(argv[1]));
759
760 p.setDataPosition(pos);
761
762 pRI->pCI->dispatchFunction(p, pRI);
763 return 0;
764}
765int getCurrentCalls(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
766{
767 android::Parcel p;
768
769 pRI->pCI->dispatchFunction(p, pRI);
770 return 0;
771}
772int autoAnswerCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
773{
774 if(argc < 2) {
775 RLOGW("[error],set auto answer call parameter error!");
776 free(pRI);
777 return 0;
778 }
779 //need add lock to pretect.
780 autoAnswerMode = atoi(argv[1]) ? 1 : 0;
781 RLOGD("SetAutoAnserMode is %s",autoAnswerMode ? "On" :"Off");
782 if(pRI) {
783 free(pRI);
784 }
785 return 0;
786}
787
788int inCallRecord(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
789{
q.huangec88da92022-03-29 04:17:32 -0400790 android::Parcel p;
lh7b0674a2022-01-10 00:34:35 -0800791 int recordEnable = 0;
792 char* filepath = NULL;
793 if(inCallstatus == CALL_OFF || speechStatus == SPEECH_OFF) {
794 RLOGW("[warning],not in calling status. Can't do record!");
q.huangec88da92022-03-29 04:17:32 -0400795 goto FAIL_RETURN;
lh7b0674a2022-01-10 00:34:35 -0800796 }
797
q.huangec88da92022-03-29 04:17:32 -0400798 if(argc < 3) {
lh7b0674a2022-01-10 00:34:35 -0800799 RLOGW("[error],inCallRecord parameter error!");
q.huangec88da92022-03-29 04:17:32 -0400800 goto FAIL_RETURN;
lh7b0674a2022-01-10 00:34:35 -0800801 }
802
803 recordEnable = atoi(argv[1]) ? 1 : 0;
804 RLOGD("InCall record %s!",recordEnable ? "enable" : "disable");
805 filepath = argv[2];
806 RLOGD("InCall record file path as \'%s\'",filepath);
807
808 if (recordEnable == 1) {//enable record
809 RLOGD("start GSM!");
810 if(-1 != GSM_Init(filepath) && -1 != GSM_Start()) {
811 inCallRecordMode = 1;
812 RLOGW("inCallRecord Start OK!");
813 }else{
814 inCallRecordMode = 0;
815 RLOGW("[error],inCallRecord Start fail!");
q.huangec88da92022-03-29 04:17:32 -0400816 goto FAIL_RETURN;
lh7b0674a2022-01-10 00:34:35 -0800817 }
818 } else { //disable record
819 if (inCallRecordMode == 1) {
lh7b0674a2022-01-10 00:34:35 -0800820 inCallRecordMode = 0;
q.huangec88da92022-03-29 04:17:32 -0400821 if(!(-1 != GSM_Stop() && -1 != GSM_Close()))
822 {
823 RLOGW("[error],inCallRecord fail!");
824 goto FAIL_RETURN;
825 }
lh7b0674a2022-01-10 00:34:35 -0800826 }
827 }
q.huangec88da92022-03-29 04:17:32 -0400828 if(pRI != NULL) {
q.huangadbad2f2022-09-15 16:28:02 +0800829 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_RECORD,0,0);
q.huangec88da92022-03-29 04:17:32 -0400830 android::LYNQ_RIL_respSocket_sp(p,pRI);
lh7b0674a2022-01-10 00:34:35 -0800831 free(pRI);
q.huangec88da92022-03-29 04:17:32 -0400832 }
lh7b0674a2022-01-10 00:34:35 -0800833 return 0;
q.huangec88da92022-03-29 04:17:32 -0400834FAIL_RETURN:
835 if(pRI != NULL) {
q.huangadbad2f2022-09-15 16:28:02 +0800836 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_RECORD,0,2);
q.huangec88da92022-03-29 04:17:32 -0400837 android::LYNQ_RIL_respSocket_sp(p,pRI);
838 free(pRI);
839 }
840 return -1;
lh7b0674a2022-01-10 00:34:35 -0800841}
842
843int StopRecord()
844{
845 RLOGD("After Handup, stop record! Before Record is %s",inCallRecordMode ? "Enable" : "Disable");
846 if (inCallRecordMode == 1) {
847 if(!(-1 != GSM_Stop() && -1 != GSM_Close()))
848 RLOGW("[error],inCallRecord fail!");
849
850 inCallRecordMode = 0;
851 /*From GSM report stop_record to PulseAudio send record_off need 15ms. so after stop record delay 30ms*/
852 usleep(30*1000);
853 }
854 return 0;
855}
856
857int setSpeechVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
858{
q.huangec88da92022-03-29 04:17:32 -0400859 android::Parcel p;
lh7b0674a2022-01-10 00:34:35 -0800860 int setValue = 0;
861 RLOGD("setSpeechVolume start!");
862
863 if(argc < 2) {
q.huangadbad2f2022-09-15 16:28:02 +0800864 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,2);
q.huangec88da92022-03-29 04:17:32 -0400865 android::LYNQ_RIL_respSocket_sp(p,pRI);
lh7b0674a2022-01-10 00:34:35 -0800866 free(pRI);
867 RLOGW("Warning: no set volume value!");
868 return -1;
869 }
870
871 setValue = atoi(argv[1]);
872 RLOGD("set Speech Volume value is %d!",setValue);
873 if (get_audio_path() == 0) {
874 if(setValue < MIN_VOLUME || setValue > MAX_VOLUME) {
875 RLOGW("Warning: set volume value is over-range!");
q.huangadbad2f2022-09-15 16:28:02 +0800876 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,2);
q.huangec88da92022-03-29 04:17:32 -0400877 android::LYNQ_RIL_respSocket_sp(p,pRI);
878 free(pRI);
lh7b0674a2022-01-10 00:34:35 -0800879 return -1;
880 }
881 } else {
882 if(setValue < BT_MIN_VOLUME || setValue > BT_MAX_VOLUME) {
883 RLOGW("Warning: set bt volume value is over-range!");
q.huangadbad2f2022-09-15 16:28:02 +0800884 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,2);
q.huangec88da92022-03-29 04:17:32 -0400885 android::LYNQ_RIL_respSocket_sp(p,pRI);
886 free(pRI);
lh7b0674a2022-01-10 00:34:35 -0800887 return -1;
888 }
889 }
890 //paramter is from 1 to 7
891 mixer_set_volume(setValue);
q.huangadbad2f2022-09-15 16:28:02 +0800892 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,0);
q.huangec88da92022-03-29 04:17:32 -0400893 printf(">>>>set speech Volume<<<< success value is %d!\n",setValue);
894 /*Warren add for t800 ril service 2021/12/23 end*/
895 android::LYNQ_RIL_respSocket_sp(p,pRI);
lh7b0674a2022-01-10 00:34:35 -0800896 free(pRI);
897 return 0;
898}
q.huangec88da92022-03-29 04:17:32 -0400899int getSpeechVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
900{
901 android::Parcel p;
902 printf("WARREN TEST001!!!\n");
903 int volumn = mixer_get_volume();
904 //TBC -200 fail status
905 if(volumn <0) {
906 printf("get speech volumn fail, please check whether does call exsit.\n");
907 /*Warren add for t800 ril service 2021/12/23 start*/
q.huangadbad2f2022-09-15 16:28:02 +0800908 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_SPEECH_VOLUME,0,2);
q.huangec88da92022-03-29 04:17:32 -0400909 /*Warren add for t800 ril service 2021/12/23 end*/
910 } else {
911 /*Warren add for t800 ril service 2021/12/23 start*/
q.huangadbad2f2022-09-15 16:28:02 +0800912 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_SPEECH_VOLUME,0,0);
q.huangec88da92022-03-29 04:17:32 -0400913 /*Warren add for t800 ril service 2021/12/23 end*/
914 }
915 printf("current Speech Volume is%d",volumn);
916 p.writeInt32(volumn);
917 android::LYNQ_RIL_respSocket(p,(void *)pRI);
918 if(pRI) {
919 free(pRI);
920 }
921 return 0;
922}
lh7b0674a2022-01-10 00:34:35 -0800923int setDtmfVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
924{
q.huangec88da92022-03-29 04:17:32 -0400925 android::Parcel p;
lh7b0674a2022-01-10 00:34:35 -0800926 int setValue = 0;
lh7b0674a2022-01-10 00:34:35 -0800927 RLOGD("setDtmfVolume start!");
928 printf("setDtmfVolume start!\n");
929 if(argc < 2) {
930 RLOGW("Warning: no set volume value!");
931 printf("Warning: no set volume value!\n");
q.huangadbad2f2022-09-15 16:28:02 +0800932 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_DTMF_VOLUME,0,2);
q.huangec88da92022-03-29 04:17:32 -0400933 android::LYNQ_RIL_respSocket_sp(p,pRI);
lh7b0674a2022-01-10 00:34:35 -0800934 free(pRI);
935 return -1;
936 }
937
938 setValue = atoi(argv[1]);
939 RLOGD("set dtmf Volume value is %d!",setValue);
940 printf("set dtmf Volume value is %d!\n",setValue);
941 if(setValue < DTMF_MIN_VOLUME || setValue > DTMF_MAX_VOLUME) {
942 RLOGW("Warning: set volume value is over-range!");
943 printf("set dtmf Volume value is %d!\n",setValue);
944 /*Warren add for t800 ril service 2021/12/23 start*/
q.huangadbad2f2022-09-15 16:28:02 +0800945 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_DTMF_VOLUME,0,2);
lh7b0674a2022-01-10 00:34:35 -0800946 android::LYNQ_RIL_respSocket_sp(p,pRI);
947 /*Warren add for t800 ril service 2021/12/23 end*/
948 free(pRI);
949 return -1;
950 }
951 //paramter is from 0 to 36
952 dtmf_volume = setValue;
953 printf(">>>>set dtmf Volume<<<< success value is %d!\n",setValue);
954 /*Warren add for t800 ril service 2021/12/23 start*/
q.huangadbad2f2022-09-15 16:28:02 +0800955 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_DTMF_VOLUME,0,0);
lh7b0674a2022-01-10 00:34:35 -0800956 printf(">>>>set dtmf Volume<<<< success value is %d!\n",setValue);
957 /*Warren add for t800 ril service 2021/12/23 end*/
958 android::LYNQ_RIL_respSocket_sp(p,pRI);
959 free(pRI);
960 return 0;
961}
962
963speech_status getSpeechStatus()
964{
965 return speechStatus;
966}
967
968void setSpeechAndStatus(int value)
969{
970 RLOGD("setSpeechAndStatus value: %d, speechStatus: %d", value, speechStatus);
971 if (value == 1) {
972 speechStatus = NORMAL_SPEECH_ON;
973 mixer_set(1);
974 } else if (value == 2) {
975 speechStatus = BT_SPEECH_ON;
976 bt_mixer_set(1);
977 } else if (value == 0) {
978 speechStatus == BT_SPEECH_ON ? bt_mixer_set(0) : mixer_set(0);
979 speechStatus = SPEECH_OFF;
980 } else {
981 RLOGE("set speech value is invaild!\n");
982 }
983}
984//RIL_REQUEST_EMERGENCY_DIAL
985/*cmd:1, address,
986*2, clirMode,
987*3, if present, uusinfo.type
988*4, as above, uusinfo.Dcs
989*5, as above, uusinfo.userdatalength
990*6, as above, uusinfo.UserData
991*/
992int emergencyDial(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
993{
994 android::Parcel p;
995 size_t pos = p.dataPosition();
996
997 if (argc < 3 || argv[1] == NULL)
998 {
999 //add log msg
1000 free(pRI);
1001 return -1;
1002 }
1003 //address;
1004 writeStringToParcel(p, (const char *) argv[1]);
1005 //clirMode
1006 if (argc >= 2)
1007 {
1008 p.writeInt32(atoi(argv[2]));
1009
1010 if (argc == 7&& argv[3] != NULL
1011 && argv[4] != NULL && argv[5] != NULL
1012 && argv[6] != NULL)
1013 {
1014 p.writeInt32(1); // UUS information is present
1015 p.writeInt32(atoi(argv[3]));
1016 p.writeInt32(atoi(argv[4]));
1017 p.writeByteArray((size_t) atoi(argv[5]), (uint8_t*) argv[6]);
1018 } else
1019 {
1020 p.writeInt32(0); // UUS information is absent
1021 }
1022 }
1023 p.setDataPosition(pos);
q.huang1c03f752023-12-14 14:11:58 +08001024//setEcallAudioPathOn(false);
lh7b0674a2022-01-10 00:34:35 -08001025 pRI->pCI->dispatchFunction(p, pRI);
1026 return 0;
1027}
1028//RIL_REQUEST_SET_ECC_SERVICE_CATEGORY
1029int setEccServiceCategory(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1030{
1031 android::Parcel p;
1032 size_t pos = p.dataPosition();
1033
1034 //if ( getSpeechStatus() != 1)
1035 // setSpeechAndStatus(1);
1036
1037 p.writeInt32(1);
1038 p.writeInt32(atoi(argv[1]));
1039 p.setDataPosition(pos);
1040 pRI->pCI->dispatchFunction(p, pRI);
1041 return 0;
1042}
1043//RIL_REQUEST_SET_ECC_LIST
1044/* argv[1]: list number
1045 argv[2+i]: ECC string
1046 argv[3+i]: Categroy
1047 argv[4+i]: Conditon
1048*/
1049int setEccList(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1050{
1051 android::Parcel p;
1052 size_t pos = p.dataPosition();
1053 int num = 0;
1054 //if ( getSpeechStatus() != 1)
1055 // setSpeechAndStatus(1);
1056 if(argc < 3) {
1057 RLOGE("%s parameter error!",__func__);
1058 free(pRI);
1059 return -1;
1060 }
1061 num = atoi(argv[1]);
1062 RLOGD("list number is %d, argc is %d",num, argc);
1063 if((num == 0) || ((argc-2) < num*3)) {
1064 RLOGE("%s parameter error!",__func__);
1065 free(pRI);
1066 return -1;
1067 }
1068
1069 p.writeInt32(num*3);
1070 for(int i = 0; i < num; i++){
1071 writeStringToParcel(p, (const char *)argv[2+i*3+0]); //ECC
1072 writeStringToParcel(p, (const char *)argv[2+i*3+1]); //Category
1073 writeStringToParcel(p, (const char *)argv[2+i*3+2]); //Condition
1074 RLOGD("list[%d],ECC is %s, Category is %s, Condition is %s!",i+1,argv[2+i*3+0],argv[2+i*3+1],argv[2+i*3+2]);
1075 }
1076 p.setDataPosition(pos);
1077 pRI->pCI->dispatchFunction(p, pRI);
1078 return 0;
1079}
1080
1081//RIL_REQUEST_SET_ECC_NUM
1082int setEccNum(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1083{
1084 android::Parcel p;
1085 size_t pos = p.dataPosition();
1086 int num = 0;
1087
1088 if(argc < 2 || argc > 3) {
1089 RLOGE("%s parameter error!",__func__);
1090 free(pRI);
1091 return -1;
1092 }
1093
1094 num = (argc > 2)?2:1;
1095
1096 p.writeInt32(num);
1097 writeStringToParcel(p, (const char *)argv[1]); //ECC number with card
1098 RLOGD("Set ECC number with card: %s",argv[1]);
1099 if (num>1){
1100 writeStringToParcel(p, (const char *)argv[2]); //ECC number without card
1101 RLOGD("Set ECC number without card: %s",argv[2]);
1102 }
1103 p.setDataPosition(pos);
1104 pRI->pCI->dispatchFunction(p, pRI);
1105 return 0;
1106}
1107
1108//RIL_REQUEST_GET_ECC_NUM
1109int getEccNum(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1110{
1111 android::Parcel p;
1112 pRI->pCI->dispatchFunction(p, pRI);
1113 return 0;
1114}
1115
1116int handleECCNumResponse(const void *data, int datalen, RIL_SOCKET_ID socket_id){
1117 if (data == NULL || datalen <= 0){
1118 RLOGE("%s parameter error!",__func__);
1119 return -1;
1120 }
1121
1122 printf("[ECC NUM][Slot%d] %s\n", socket_id, (const char*)data);
1123 RLOGD("[ECC NUM][Slot%d] %s\n", socket_id, (const char*)data);
1124 return 0;
1125}
1126
1127
1128//RIL_REQUEST_LAST_CALL_FAIL_CAUSE
1129int getLastCallFailCause(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
1130 if(argc != 1)
1131 {
1132 RLOGD("the peremeters numbers isn't right , so return");
1133 free(pRI);
1134 return -1;
1135 }
1136 RLOGD("getLastCallFailCause %d: " , pRI->pCI->requestNumber);
1137 android::Parcel p;
1138
1139 pRI->pCI->dispatchFunction(p, pRI);
1140 return 0;
1141}
1142
1143//#ifdef C2K_SUPPORT
1144static bool is12Key(char c) {
1145 return (c >= '0' && c <= '9') || c == '*' || c == '#';
1146}
1147
1148//RIL_REQUEST_CDMA_BURST_DTMF
1149int sendBurstDtmf(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI){
1150 if(argc < 4) {
1151 RLOGE("%s parameter error!",__func__);
1152 free(pRI);
1153 return -1;
1154 }
1155 int number;
1156 char * c_num = NULL;
1157
1158 c_num = argv[1];
1159 if (c_num == NULL) {
1160 free(pRI);
1161 return -1;
1162 }
1163 number = int(c_num[0] - '0');
1164 if(number == -6)
1165 number = 10;
1166 if(number == -13)
1167 number = 11;
1168 RLOGD("DTMF input number is %s-->%d",c_num,number);
1169 if ( number < 0 || number > 15 ) {
1170 RLOGE("DTMF input number error");
1171 free(pRI);
1172 return -1;
1173 }
1174 dtmf_stop(dtmf_handle);
1175 dtmf_handle = dtmf_start(number, 500, dtmf_volume, NULL);
1176 android::Parcel p;
1177 size_t pos = p.dataPosition();
1178 p.writeInt32(3);
1179 writeStringToParcel(p, c_num);
1180 writeStringToParcel(p, argv[2]);
1181 writeStringToParcel(p, argv[3]);
1182 p.setDataPosition(pos);
1183 pRI->pCI->dispatchFunction(p, pRI);
1184 if (dtmf_handle == NULL)
1185 RLOGE("[DTMF] dtmf_start return NULL!");
1186 return 0;
1187}
1188
1189//RIL_REQUEST_CDMA_FLASH
1190int sendCDMAFeatureCode(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI){
1191 if(argc > 2)
1192 {
1193 RLOGD("the peremeters numbers isn't right , so return");
1194 free(pRI);
1195 return -1;
1196 }
1197 android::Parcel p;
1198 size_t pos = p.dataPosition();
1199 writeStringToParcel(p, ((argc == 1) ? "" : argv[1]));
1200 p.setDataPosition(pos);
1201 pRI->pCI->dispatchFunction(p, pRI);
1202 return 0;
1203}
1204//#endif /*C2K_SUPPORT*/
1205
1206static int mixer_set_mute(int path, int value)
1207{
1208 RLOGD("mixer_set_mute path: %d , value: %d", path, value);
1209 int ret;
1210 /* DL:0 UL:1 */
1211 if (path == 0) {
1212 ret = set_mixer_ctrl_value_int(g_DL_mute_name, value);
1213 } else {
1214 ret = set_mixer_ctrl_value_int(g_UL_mute_name, value);
1215 }
1216 if (ret) {
1217 RLOGE("set_mixer_ctrl_volume_value_int err: %d", ret);
1218 }
1219 return ret;
1220}
1221
1222static long int mixer_get_mute(int path)
1223{
1224 long int is_mute;
1225
1226 /* DL:0 UL:1 */
1227 if (path == 0) {
1228 is_mute = get_mixer_ctrl_value_int(g_DL_mute_name);
lhb07f4e12022-02-17 22:08:54 -08001229 RLOGD("The ctrl \"%s\" is set to %ld", g_DL_mute_name, is_mute);
lh7b0674a2022-01-10 00:34:35 -08001230 } else {
1231 is_mute = get_mixer_ctrl_value_int(g_UL_mute_name);
lhb07f4e12022-02-17 22:08:54 -08001232 RLOGD("The ctrl \"%s\" is set to %ld", g_UL_mute_name, is_mute);
lh7b0674a2022-01-10 00:34:35 -08001233 }
1234
1235 return is_mute;
1236}
1237
1238static int setCallMute(bool mute) {
1239 RLOGD("setCallMute: %d", mute);
1240 return mixer_set_mute(1, (mute ? 1: 0));
1241}
1242
1243int getCallMute() {
1244 long int cc_mute = mixer_get_mute(1);
lhb07f4e12022-02-17 22:08:54 -08001245 RLOGD("getCallMute: %ld", cc_mute);
lh7b0674a2022-01-10 00:34:35 -08001246 return cc_mute;
1247}
1248
1249void resetMute() {
1250 if (getCallMute() > 0) {
1251 setCallMute(false);
1252 }
1253}
1254
1255void callRing(RIL_SOCKET_ID soc_id)
1256{
lh7b0674a2022-01-10 00:34:35 -08001257 if (autoAnswerMode) {
1258 RLOGD("Auto Answer MT Call!");
1259 android::requestAnswer(soc_id);
1260 }
1261 return;
1262}
1263
1264void autoAnswerForCdma(RIL_SOCKET_ID socket_id)
1265{
1266 resetMute();
1267 if (autoAnswerMode) {
1268 RLOGD("Auto Answer MT Call for cdma");
1269 ARspRequest(RIL_REQUEST_CDMA_FLASH, socket_id);
1270 }
1271 return;
1272}
1273
q.huang7f0bd112022-07-12 10:32:10 +08001274/*hqing add for Geely demand on 11/07/2022, after cs call, codec should sleep*/
1275void set_codec(int open)
1276{
q.huang618fbdc2022-08-22 20:27:20 +08001277 RLOGD("set_codec %d",open);
1278
1279 if(open==0)
1280 {
1281 system("echo out 201 0 >/sys/devices/platform/10005000.pinctrl/mt_gpio");
1282 system("echo out 181 0 >/sys/devices/platform/10005000.pinctrl/mt_gpio");
1283 }
1284 else
1285 {
1286 system("echo out 181 1 >/sys/devices/platform/10005000.pinctrl/mt_gpio");
1287 usleep(10);//just open need usleep 10us
1288 system("echo out 201 1 >/sys/devices/platform/10005000.pinctrl/mt_gpio");
1289 system("echo 0x00 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1290 system("echo 0x01 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1291 system("echo 0x02 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1292 system("echo 0x03 0x80 > /sys/kernel/debug/regmap/0-0018/registers");
1293 system("echo 0x04 0x04 > /sys/kernel/debug/regmap/0-0018/registers");
1294 system("echo 0x05 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1295 system("echo 0x06 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1296 system("echo 0x07 0xa0 > /sys/kernel/debug/regmap/0-0018/registers");
1297 system("echo 0x08 0x20 > /sys/kernel/debug/regmap/0-0018/registers");
1298 system("echo 0x09 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1299 system("echo 0x0a 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1300 system("echo 0x0b 0x32 > /sys/kernel/debug/regmap/0-0018/registers");
1301 system("echo 0x0c 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1302 system("echo 0x0d 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1303 system("echo 0x0f 0x10 > /sys/kernel/debug/regmap/0-0018/registers");
1304 system("echo 0x10 0x20 > /sys/kernel/debug/regmap/0-0018/registers");
1305 system("echo 0x11 0xf8 > /sys/kernel/debug/regmap/0-0018/registers");
1306 system("echo 0x12 0xff > /sys/kernel/debug/regmap/0-0018/registers");
1307 system("echo 0x13 0x04 > /sys/kernel/debug/regmap/0-0018/registers");
1308 system("echo 0x14 0x78 > /sys/kernel/debug/regmap/0-0018/registers");
1309 system("echo 0x15 0x78 > /sys/kernel/debug/regmap/0-0018/registers");
1310 system("echo 0x16 0x04 > /sys/kernel/debug/regmap/0-0018/registers");
1311 system("echo 0x17 0x78 > /sys/kernel/debug/regmap/0-0018/registers");
1312 system("echo 0x18 0x78 > /sys/kernel/debug/regmap/0-0018/registers");
1313 system("echo 0x19 0x80 > /sys/kernel/debug/regmap/0-0018/registers");
1314 system("echo 0x1a 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1315 system("echo 0x1b 0xfe > /sys/kernel/debug/regmap/0-0018/registers");
1316 system("echo 0x1c 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1317 system("echo 0x1d 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1318 system("echo 0x1e 0xfe > /sys/kernel/debug/regmap/0-0018/registers");
1319 system("echo 0x1f 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1320 system("echo 0x20 0x18 > /sys/kernel/debug/regmap/0-0018/registers");
1321 system("echo 0x21 0x18 > /sys/kernel/debug/regmap/0-0018/registers");
1322 system("echo 0x22 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1323 system("echo 0x23 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1324 system("echo 0x24 0xc0 > /sys/kernel/debug/regmap/0-0018/registers");
1325 system("echo 0x25 0xc0 > /sys/kernel/debug/regmap/0-0018/registers");
1326 system("echo 0x26 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1327 system("echo 0x27 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1328 system("echo 0x28 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1329 system("echo 0x29 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1330 system("echo 0x2a 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1331 system("echo 0x2b 0x02 > /sys/kernel/debug/regmap/0-0018/registers");
1332 system("echo 0x2c 0x02 > /sys/kernel/debug/regmap/0-0018/registers");
1333 system("echo 0x2d 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1334 system("echo 0x2e 0x02 > /sys/kernel/debug/regmap/0-0018/registers");
1335 system("echo 0x2f 0x85 > /sys/kernel/debug/regmap/0-0018/registers");
1336 system("echo 0x30 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1337 system("echo 0x31 0x80 > /sys/kernel/debug/regmap/0-0018/registers");
1338 system("echo 0x32 0x85 > /sys/kernel/debug/regmap/0-0018/registers");
yu.dongb686d812023-09-19 03:36:06 -07001339 system("echo 0x33 0x00 > /sys/kernel/debug/regmap/0-0018/registers"); //dongyu@2023.9.18 Disables CODEC lineout output by default
q.huang618fbdc2022-08-22 20:27:20 +08001340 system("echo 0x34 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1341 system("echo 0x35 0x80 > /sys/kernel/debug/regmap/0-0018/registers");
1342 system("echo 0x36 0x82 > /sys/kernel/debug/regmap/0-0018/registers");
1343 system("echo 0x37 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1344 system("echo 0x38 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1345 system("echo 0x39 0x82 > /sys/kernel/debug/regmap/0-0018/registers");
yu.dongb686d812023-09-19 03:36:06 -07001346 system("echo 0x3a 0x00 > /sys/kernel/debug/regmap/0-0018/registers"); //dongyu@2023.9.18 Disables CODEC lineout output by default
q.huang618fbdc2022-08-22 20:27:20 +08001347 system("echo 0x3b 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1348 system("echo 0x3c 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1349 system("echo 0x3d 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1350 system("echo 0x3e 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1351 system("echo 0x3f 0x80 > /sys/kernel/debug/regmap/0-0018/registers");
1352 system("echo 0x40 0xaf > /sys/kernel/debug/regmap/0-0018/registers");
yu.dongb686d812023-09-19 03:36:06 -07001353 system("echo 0x41 0x00 > /sys/kernel/debug/regmap/0-0018/registers"); //dongyu@2023.9.18 Disables CODEC lineout output by default
q.huang618fbdc2022-08-22 20:27:20 +08001354 system("echo 0x42 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1355 system("echo 0x43 0x80 > /sys/kernel/debug/regmap/0-0018/registers");
1356 system("echo 0x44 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1357 system("echo 0x45 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1358 system("echo 0x46 0x02 > /sys/kernel/debug/regmap/0-0018/registers");
1359 system("echo 0x47 0xaf > /sys/kernel/debug/regmap/0-0018/registers");
yu.dongb686d812023-09-19 03:36:06 -07001360 system("echo 0x48 0x00 > /sys/kernel/debug/regmap/0-0018/registers"); //dongyu@2023.9.18 Disables CODEC lineout output by default
q.huang618fbdc2022-08-22 20:27:20 +08001361 system("echo 0x49 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1362 system("echo 0x4a 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1363 system("echo 0x4b 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1364 system("echo 0x4c 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1365 system("echo 0x4d 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1366 system("echo 0x4e 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1367 system("echo 0x4f 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1368 system("echo 0x50 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1369 system("echo 0x51 0x02 > /sys/kernel/debug/regmap/0-0018/registers");
1370 system("echo 0x52 0xbf > /sys/kernel/debug/regmap/0-0018/registers");
1371 system("echo 0x53 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1372 system("echo 0x54 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1373 system("echo 0x55 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1374 system("echo 0x56 0x9b > /sys/kernel/debug/regmap/0-0018/registers");
1375 system("echo 0x57 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1376 system("echo 0x58 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1377 system("echo 0x59 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1378 system("echo 0x5a 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1379 system("echo 0x5b 0x02 > /sys/kernel/debug/regmap/0-0018/registers");
1380 system("echo 0x5c 0xbf > /sys/kernel/debug/regmap/0-0018/registers");
1381 system("echo 0x5d 0x08 > /sys/kernel/debug/regmap/0-0018/registers");
1382 system("echo 0x5e 0xde > /sys/kernel/debug/regmap/0-0018/registers");
1383 system("echo 0x5f 0x0c > /sys/kernel/debug/regmap/0-0018/registers");
1384 system("echo 0x60 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1385 system("echo 0x61 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1386 system("echo 0x62 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1387 system("echo 0x63 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1388 system("echo 0x64 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1389 system("echo 0x65 0x01 > /sys/kernel/debug/regmap/0-0018/registers");
1390 system("echo 0x66 0xa2 > /sys/kernel/debug/regmap/0-0018/registers");
1391 system("echo 0x67 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1392 system("echo 0x68 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1393 system("echo 0x69 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1394 system("echo 0x6a 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1395 system("echo 0x6b 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1396 system("echo 0x6c 0x40 > /sys/kernel/debug/regmap/0-0018/registers");
1397 system("echo 0x6d 0x00 > /sys/kernel/debug/regmap/0-0018/registers");
1398 }
q.huang7f0bd112022-07-12 10:32:10 +08001399}
1400
lh7b0674a2022-01-10 00:34:35 -08001401//void callStateChange(void)
1402void speechonoff(int callnum)
1403{
1404 static int callIndex = 0;
1405 RLOGD("callnum = %d, Call State Change then judge speech on/off!", callnum);
1406 callIndex = callnum;
q.huang1c03f752023-12-14 14:11:58 +08001407 lock_rtp_audio_mtx();
1408 if( callIndex > 0 && speechStatus == SPEECH_OFF) { //speech on
lh7b0674a2022-01-10 00:34:35 -08001409 //RLOGD("DemoAPP Call shell command (pactl set-card-profile 0 phonecall)");
1410 //system("pactl set-card-profile 0 phonecall");
1411 //RLOGD("DemoAPP Call shell command end");
q.huang7f0bd112022-07-12 10:32:10 +08001412 set_codec(1); //hqing add for Geely demand on 11/07/2022, init cs call, open codec
lh7b0674a2022-01-10 00:34:35 -08001413 if (get_audio_path() == 0) {
1414 mixer_set(1);
1415 speechStatus = NORMAL_SPEECH_ON;
1416 } else {
1417 bt_mixer_set(1);
1418 speechStatus = BT_SPEECH_ON;
1419 }
1420 inCallstatus = CALL_ON;
q.huang1c03f752023-12-14 14:11:58 +08001421 unlock_rtp_audio_mtx();
lh7b0674a2022-01-10 00:34:35 -08001422 RLOGD("[speech]: set on");
1423 sendCallMsg(true); //for Power Manager test
1424 } else if (callIndex == 0
1425 && (speechStatus == NORMAL_SPEECH_ON
1426 || speechStatus == BT_SPEECH_ON)) { //speech off
1427 StopRecord();
1428 sendCallMsg(false); // for Power Manager test.
1429 dtmf_stop(dtmf_handle);
lhb07f4e12022-02-17 22:08:54 -08001430 dtmf_handle = NULL;
lh7b0674a2022-01-10 00:34:35 -08001431 if (speechStatus == NORMAL_SPEECH_ON) {
1432 mixer_set(0);
1433 } else {
1434 bt_mixer_set(0);
1435 }
1436 //RLOGD("DemoAPP Call shell command (pactl set-card-profile 0 HiFi)");
1437 //system("pactl set-card-profile 0 HiFi");
1438 //RLOGD("DemoAPP Call(pactl set-card-profile 0 HiFi) command end");
1439 speechStatus = SPEECH_OFF;
1440 inCallstatus = CALL_OFF;
1441 resetMute();
q.huang1c03f752023-12-14 14:11:58 +08001442 unlock_rtp_audio_mtx();
q.huang7f0bd112022-07-12 10:32:10 +08001443 set_codec(0); //hqing add for Geely demand on 11/07/2022, after cs call, close codec for power Manager
lh7b0674a2022-01-10 00:34:35 -08001444 RLOGD("[speech]: set off");
1445 } else {
q.huang1c03f752023-12-14 14:11:58 +08001446 unlock_rtp_audio_mtx();
lh7b0674a2022-01-10 00:34:35 -08001447 RLOGD("callIndex is %d, speechStatus is %d.",callIndex, speechStatus);
1448 }
1449
1450 return;
1451}
1452
1453//RIL_REQUEST_SET_MUTE
1454int setMute(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1455{
q.huangec88da92022-03-29 04:17:32 -04001456 android::Parcel p;
lh7b0674a2022-01-10 00:34:35 -08001457 printf("WARREN TEST002!!!\n");
1458 if(argc<2)
1459 {
1460 if(pRI)
1461 {
1462 free(pRI);
1463 }
1464 return -1;
1465 }
1466 bool mute = (atoi(argv[1]) > 0) ? true: false;
1467 RLOGD("set mute %s", ((atoi(argv[1]) > 0) ? "on": "off"));
1468 int ret = setCallMute(mute);
1469 if(ret) {
1470 /*Warren add for t800 ril service 2021/12/23 start*/
q.huangadbad2f2022-09-15 16:28:02 +08001471 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,RIL_REQUEST_SET_MUTE,0,2);
lh7b0674a2022-01-10 00:34:35 -08001472 /*Warren add for t800 ril service 2021/12/23 start*/
1473 printf("set mute fail, please try agian\n");
1474 } else {
1475 /*Warren add for t800 ril service 2021/12/23 start*/
q.huangadbad2f2022-09-15 16:28:02 +08001476 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,RIL_REQUEST_SET_MUTE,0,0);
lh7b0674a2022-01-10 00:34:35 -08001477 /*Warren add for t800 ril service 2021/12/23 start*/
1478 }
1479 /*Warren add for t800 ril service 2021/12/23 start*/
1480 printf("set mute %s\n", ((atoi(argv[1]) > 0) ? "on": "off"));
1481 android::LYNQ_RIL_respSocket(p,(void *)pRI);
1482 /*Warren add for t800 ril service 2021/12/23 start*/
1483 if(pRI) {
1484 free(pRI);
1485 }
1486 return 0;
1487}
1488
1489//RIL_REQUEST_GET_MUTE
1490int getMute(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1491{
1492
q.huangec88da92022-03-29 04:17:32 -04001493 android::Parcel p;
lh7b0674a2022-01-10 00:34:35 -08001494 printf("WARREN TEST001!!!\n");
1495 int mute = getCallMute();
1496 //TBC -200 fail status
q.huangec88da92022-03-29 04:17:32 -04001497 if(mute < 0) {
lh7b0674a2022-01-10 00:34:35 -08001498 printf("get mute state fail, please check whether does call exsit.\n");
1499 /*Warren add for t800 ril service 2021/12/23 start*/
q.huangadbad2f2022-09-15 16:28:02 +08001500 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,RIL_REQUEST_GET_MUTE,0,2);
lh7b0674a2022-01-10 00:34:35 -08001501 /*Warren add for t800 ril service 2021/12/23 end*/
1502 } else {
1503 /*Warren add for t800 ril service 2021/12/23 start*/
q.huangadbad2f2022-09-15 16:28:02 +08001504 android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,RIL_REQUEST_GET_MUTE,0,0);
lh7b0674a2022-01-10 00:34:35 -08001505 /*Warren add for t800 ril service 2021/12/23 end*/
1506 }
1507 printf("current mute state is%s",((mute == 1) ? "on\n" : "off\n"));
1508 p.writeInt32(mute);
lh7b0674a2022-01-10 00:34:35 -08001509 if(pRI) {
q.huangec88da92022-03-29 04:17:32 -04001510 android::LYNQ_RIL_respSocket(p,(void *)pRI);
lh7b0674a2022-01-10 00:34:35 -08001511 free(pRI);
1512 }
1513 return 0;
1514}
1515
1516//RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR
1517int handleUnsolSipCallProgressInd(const void *response, size_t responselen) {
1518 if (response == NULL && responselen != 0) {
1519 RLOGE("handleUnsolSipCallProgressInd: invalid response: NULL");
1520 return -1;
1521 }
1522 if (responselen % sizeof(char *) != 0) {
1523 RLOGE("handleUnsolSipCallProgressInd: invalid response length %d expected multiple of %d\n",
1524 (int)responselen, (int)sizeof(char *));
1525 return -1;
1526 }
1527
1528 int numStrings = responselen / sizeof(char *);
1529 RLOGD("handleUnsolSipCallProgressInd: numStrings: %d", numStrings);
1530 if(numStrings < 6) {
1531 RLOGE("handleUnsolSipCallProgressInd: invalid response numbers: NULL");
1532 return -1;
1533 }
1534 char **p_cur = (char **) response;
1535 //<call_id>,<dir>,<SIP_msg_type>,<method>,<response_code>,"<reason_text>"
1536 //if response == <id>, 1, 0, 4, 0, "call completed elsewhere" ,printf "SIP CANCEL:Call completed elsewhere"
1537 //if response == <id>, 1, 0, 4, 0, " declined" ,printf "SIP CANCEL:declined"
1538 std::string call_id(p_cur[0]);
1539 std::string dir(p_cur[1]);
1540 std::string sip_msg_type(p_cur[2]);
1541 std::string method(p_cur[3]);
1542 std::string resp_code(p_cur[4]);
1543 std::string reason_text(p_cur[5]);
1544 RLOGD("%s, call_id=%s, dir=%s, sip_msg_type=%s, method=%s, resp_code=%s, reason_text=%s",
1545 __FUNCTION__, call_id.c_str(),dir.c_str(),sip_msg_type.c_str(),method.c_str(),resp_code.c_str(), reason_text.c_str());
1546 printf("call_id=%s, dir=%s, sip_msg_type=%s, method=%s, resp_code=%s, reason_text=%s\n",
1547 call_id.c_str(),dir.c_str(),sip_msg_type.c_str(),method.c_str(),resp_code.c_str(), reason_text.c_str());
1548
1549 if ((std::stoi(dir) == 1) && (std::stoi(sip_msg_type) == 0)
1550 && (std::stoi(method) == 4) && (std::stoi(resp_code) == 0)) {
lhb07f4e12022-02-17 22:08:54 -08001551 std::string msg("SIP CANCEL:");
lh7b0674a2022-01-10 00:34:35 -08001552 msg.append(reason_text);
1553 printf("%s", msg.c_str());
1554 }
1555 return 0;
1556}
1557
1558//RIL_UNSOL_CALL_INFO_INDICATION
1559int handleUnsolCallInfoInd(const void *response, size_t responselen, RIL_SOCKET_ID socket_id) {
1560 int numStrings = 0;
1561
1562 if (response == NULL && responselen != 0) {
1563 RLOGE("[slot%d]handleUnsolCallInfoInd, invalid response: NULL", socket_id);
1564 return -1;
1565 }
1566 if (responselen % sizeof(char *) != 0) {
1567 RLOGE("[slot%d]handleUnsolCallInfoInd: invalid response length %d expected multiple of %d\n",socket_id,
1568 (int)responselen, (int)sizeof(char *));
1569 return -1;
1570 }
1571
1572 if (response == NULL) {
1573 RLOGE("[slot%d]handleUnsolCallInfoInd, length and invalid response : NULL", socket_id);
1574 } else {
1575 char **p_cur = (char **) response;
1576
1577 numStrings = responselen / sizeof(char *);
1578 RLOGD("[slot%d]handleUnsolCallInfoInd: numStrings: %d",socket_id, numStrings);
1579 if(numStrings < 9) {
lhb07f4e12022-02-17 22:08:54 -08001580 RLOGE("[slot%d]handleUnsolCallInfoInd, invalid numStrings < 9, no pau value : numStrings", socket_id);
lh7b0674a2022-01-10 00:34:35 -08001581 return -1;
1582 } else {
1583 RLOGD("[slot%d]handleUnsolCallInfoInd(): pau: %s", socket_id, p_cur[8]);
1584 printf("[slot%d]handleUnsolCallInfoInd(): pau: %s\n", socket_id, p_cur[8]);
1585 }
1586 }
1587 return 0;
1588}
1589
1590static void playtone(int start) {
1591 RLOGD("playtone(): start: %d, isRingStart %d", start, isRingStart);
1592 char cmd[256];
1593 sprintf(cmd, "aplay %s", RING_PATH);
1594 system(cmd);
1595 isRingStart = false;
1596}
1597
1598//RIL_UNSOL_RINGBACK_TONE
1599int handleRingbackTone(const void *response, size_t responselen, RIL_SOCKET_ID socket_id) {
1600
1601 int numInts = 0;
1602
1603 if (response == NULL && responselen != 0) {
1604 RLOGE("[slot%d]handleRingbackTone, invalid response: NULL", socket_id);
1605 return -1;
1606 }
1607 if (responselen % sizeof(int) != 0) {
1608 RLOGE("[slot%d]handleRingbackTone: invalid response length %d expected multiple of %d\n",socket_id,
1609 (int)responselen, (int)sizeof(char *));
1610 return -1;
1611 }
1612
1613 int *p_int = (int *) response;
1614
1615 numInts = responselen / sizeof(int);
1616 RLOGD("[slot%d]handleRingbackTone: numInts: %d",socket_id, numInts);
1617 if(numInts < 1) {
lhb07f4e12022-02-17 22:08:54 -08001618 RLOGE("[slot%d]handleRingbackTone, invalid numStrings < 1", socket_id);
lh7b0674a2022-01-10 00:34:35 -08001619 return -1;
1620 } else {
1621 int start = p_int[0];
1622 RLOGD("[slot%d]handleRingbackTone(): start: %d, isRingStart %d", socket_id, start, isRingStart);
1623 printf("[slot%d]handleRingbackTone(): start: %d, isRingStart %d\n", socket_id, start, isRingStart);
1624#if defined(TARGET_PLATFORM_MT2731)
1625 if(start && (!isRingStart)) {
1626 isRingStart = true;
1627 std::thread t(playtone, start);
1628 t.detach();
1629 } else if((!start) && isRingStart) {
1630 isRingStart = false;
1631 system("kill $(ps aux | grep '[a]play' | awk '{print $2}')");
1632 }
1633#endif
1634 }
1635 return 0;
1636}
1637
1638//RIL_REQUEST_DTMF_STOP
1639int stopDtmf(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1640{
1641 android::Parcel p;
1642
1643 dtmf_stop(dtmf_handle);
xja1c30b82022-01-25 16:13:48 +08001644 dtmf_handle = NULL;
lh7b0674a2022-01-10 00:34:35 -08001645 pRI->pCI->dispatchFunction(p, pRI);
1646 return 0;
1647}