blob: f212ff7bbf4b141f5b3f60c708a3ede112e92f9d [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>
50using android::Parcel;
51/*Warren add for t800 ril servie 2021/12/23 end*/
52
53static int dtmf_volume = 0;
54void *dtmf_handle = NULL;
55
56extern "C" {
57 #include <dtmf.h>
58 #include "mixer_ctrl.h"
59}
60#undef LOG_TAG
61#define LOG_TAG "LYNQ_RIL_CC"
62
63static speech_status speechStatus = SPEECH_OFF;
64static int autoAnswerMode = 0;
65static int inCallRecordMode = 0;
66static call_status inCallstatus = CALL_OFF;
67//int callIndex = 0;
68const char g_card_name[] = "mtk_phonecall";
69/*for speech on*/
70const char g_mixer_name[] = "Speech_on";
71const char g_mixer_name_ecall[] = "Speech_on_ecall";
72const char g_mixer_reset_name[] = "Modem_reset_notify";
73const char g_mixer_name_bt[] = "Speech_on_bt";
74const char g_bt_has_ecnr_name[] = "BT_HAS_ECNR";
75const char g_bt_wbs_name[] = "BT_WBS";
76int g_audio_path = 0; // 0: normal, 1: bt
77int g_bt_has_ecnr_value = 0; // 0: ecnr, 1, no ecnr
78int g_bt_wbs_value = 0; // 0: 8000, 1, 16000
79/*for DL call volume*/
80const char g_mixer_name_volume[] = "DL Call";
81const char g_mixer_name_volume_bt[] = "DL BT";
82
83const char g_DL_mute_name[] = "Speech_DL_mute";
84const char g_UL_mute_name[] = "Speech_UL_mute";
85
86const char *RING_PATH = "/system/etc/tele/ring/ring.wav";
87static bool isRingStart = false;
88
89#if defined(TARGET_PLATFORM_MT2731)||defined(TARGET_PLATFORM_MT2735)
90#define MAX_VOLUME (7)
91#define MIN_VOLUME (1)
92#endif
93
94#ifdef TARGET_PLATFORM_MT2635
95#define MAX_VOLUME (17)
96#define MIN_VOLUME (-23)
97#endif
98
99#define BT_MAX_VOLUME (15)
100#define BT_MIN_VOLUME (0)
101#define DTMF_MAX_VOLUME (36)
102#define DTMF_MIN_VOLUME (0)
103
104int get_call_status(void)
105{
106 return inCallstatus;
107}
108
109void set_audio_path(int path)
110{
111 if ((path != 0) && (path != 1)) {
112 RLOGE("set_audio_path() illegal value %d, we support 0: normal, 1: bt", path);
113 return;
114 }
115
116 g_audio_path = path;
117}
118
119int get_audio_path(void)
120{
121 return g_audio_path;
122}
123
124void set_bt_has_ecnr(int ecnr)
125{
126 if ((ecnr != 0) && (ecnr != 1)) {
127 RLOGE("set_bt_has_ecnr() illegal value %d, we support 0: do ecnr, 1: no ecnr", ecnr);
128 return;
129 }
130
131 g_bt_has_ecnr_value = ecnr;
132}
133
134int get_bt_has_ecnr(void)
135{
136 return g_bt_has_ecnr_value;
137}
138
139void set_bt_wbs(int wbs)
140{
141 if ((wbs < 0) || (wbs > 15)) {
142 RLOGE("set_bt_wbs() illegal value %d, we support 0~15", wbs);
143 return;
144 }
145
146 g_bt_wbs_value = wbs;
147}
148
149int get_bt_wbs(void)
150{
151 return g_bt_wbs_value;
152}
153
154int mixer_init()
155{
156 RLOGD("set_card_name: %s", g_card_name);
157 int ret;
158
159 // only need to set card name once
160 ret = set_card_name(g_card_name);
161 RLOGD("mixer_init(%s) = %d", g_card_name, ret);
162 return ret;
163}
164int mixer_set(int value )
165{
166 int ret;
167
168 //set mixer ctl to om:1 or off:0
169 if(value){
170 ret = set_mixer_ctrl_value_int(isEcallAudioPath() ? g_mixer_name_ecall: g_mixer_name, value);
171 RLOGD("mixer_set(%s) = %d, ret: %d", (isEcallAudioPath() ? g_mixer_name_ecall: g_mixer_name), value, ret);
172 } else {
xja1c30b82022-01-25 16:13:48 +0800173 //setEcallAudioPathOn(false);
lh7b0674a2022-01-10 00:34:35 -0800174 ret = get_mixer_ctrl_value_int(g_mixer_name);
175 RLOGD("mixer_set(get_mixer_ctrl_value_int: %s) = %d", g_mixer_name, ret);
xja1c30b82022-01-25 16:13:48 +0800176 if(ret > 0) {
lh7b0674a2022-01-10 00:34:35 -0800177 ret = set_mixer_ctrl_value_int(g_mixer_name, value);
178 RLOGD("mixer_set(%s) = %d", g_mixer_name, ret);
179 } else {
180 ret = set_mixer_ctrl_value_int(g_mixer_name_ecall, value);
181 RLOGD("mixer_set(%s) = %d", g_mixer_name_ecall, ret);
182 }
183 }
184
185
186 return ret;
187}
188int mixer_reset_set(int value )
189{
190 int ret;
191
192 // set mixer to reset:1
193 ret = set_mixer_ctrl_value_int(g_mixer_reset_name, value);
194 RLOGD("mixer_reset_set(%s) = %d", g_mixer_reset_name, ret);
195 return ret;
196}
197int bt_mixer_set(int value)
198{
199 int ret;
200
201 //set mixer ctrl to on:1 or off:0
202 // bt speech
203 int bt_has_ecnr = get_bt_has_ecnr();
204 int bt_wbs = get_bt_wbs();
205 ret = set_mixer_ctrl_value_int(g_bt_has_ecnr_name, bt_has_ecnr);
206 ret = set_mixer_ctrl_value_int(g_bt_wbs_name, bt_wbs);
207 ret = set_mixer_ctrl_value_int(g_mixer_name_bt, value);
208
209 if (ret)
210 RLOGE("set_mixer_ctrl_value_int err: %d", ret);
211 return ret;
212}
213
214int mixer_check(int mix)
215{
216 int ret;
217
218 if (mix == 0) {
219 ret = get_mixer_ctrl_value_int(g_mixer_name);
220 } else if (mix == 1){
221 ret = get_mixer_ctrl_value_int(g_mixer_name_bt);
222 } else {
223 RLOGE("mixer_check wrong mix %d", mix);
xja1c30b82022-01-25 16:13:48 +0800224 ret = -1;
lh7b0674a2022-01-10 00:34:35 -0800225 }
226 RLOGD("The ctrl \"%s\" is set to %d ", g_mixer_name, ret);
227 return ret;
228}
229int mixer_set_volume(int value)
230{
231 int ret;
232 if (get_audio_path() == 0) {
233 ret = set_mixer_ctrl_volume_value(g_mixer_name_volume, value);
234 } else {
235 ret = set_mixer_ctrl_volume_value(g_mixer_name_volume_bt, value);
236 }
237 if (ret)
238 RLOGE("set_mixer_ctrl_volume_value_int err: %d", ret);
239 return ret;
240}
241long int mixer_get_volume()
242{
243 long int vol_value;
244 if (get_audio_path() == 0) {
245 vol_value = get_mixer_ctrl_volume_value(g_mixer_name_volume);
246 } else {
247 vol_value = get_mixer_ctrl_volume_value(g_mixer_name_volume_bt);
248 }
lhb07f4e12022-02-17 22:08:54 -0800249 RLOGD("The ctrl \"%s\" is set to %ld", g_mixer_name_volume, vol_value);
lh7b0674a2022-01-10 00:34:35 -0800250 return vol_value;
251}
252
253GstElement *pipeline_element;
254GstState gst_cur_state = GST_STATE_NULL;
255static int gst_status = 0;
256
257int GSM_Init(char* filepath)
258{
259 GstElement *pipeline, *source, *mux, *encoder, *sink;
260 RLOGD("[GSM]GSM Init Start!");
261 /* Initialisation */
262 gst_init (NULL, NULL);
263
264 pipeline = gst_pipeline_new ("3gppmux-test");
265 source = gst_element_factory_make ("pulsesrc", "file-source");
266 encoder = gst_element_factory_make ("faac", "encoder");
267 mux = gst_element_factory_make ("3gppmux", "muxer");
268 sink = gst_element_factory_make ("filesink", "output");
269
270 g_object_set(mux, "fragment-duration", 100, NULL);
271 g_object_set(sink, "location", filepath, NULL);
272
273 if (!pipeline || !source || !encoder || !mux || !sink) {
274 if(pipeline) {
275 gst_object_unref (GST_OBJECT (pipeline));
276 pipeline = NULL;
277 }
278 if(source) {
279 gst_object_unref (GST_OBJECT (source));
280 source = NULL;
281 }
282 if(encoder) {
283 gst_object_unref (GST_OBJECT (encoder));
284 encoder = NULL;
285 }
286 if(mux) {
287 gst_object_unref (GST_OBJECT (mux));
288 mux = NULL;
289 }
290 if(sink) {
291 gst_object_unref (GST_OBJECT (sink));
292 sink = NULL;
293 }
294 RLOGE ("[GSM]One element could not be created. Exiting");
295 return -1;
296 }
297
298 gst_bin_add_many (GST_BIN (pipeline), source, encoder, mux, sink, NULL);
299 gst_element_link_many (source, encoder, mux, sink, NULL);
300
301 pipeline_element = pipeline;
302 gst_status = 1; //initial done
303 RLOGD("[GSM]GSM Init Done!");
304 return 0;
305}
306
307int GSM_Start(void)
308{
309 RLOGD("[GSM]GSM Start start!");
310 if(gst_status == 2)
311 return 0;
312
313 if(gst_status == 1 || gst_status ==3) {
314 GstStateChangeReturn ret = gst_element_set_state (pipeline_element, GST_STATE_PLAYING);
315
316 RLOGD("[GSM]Running... return: %d", ret);
317 //g_main_loop_run (gst_loop);
318 gst_status = 2; //start done
319 } else {
320 return -1;
321 }
322 RLOGD("[GSM]GSM Start End!");
323 return 0;
324}
325
326int GSM_Stop()
327{
328 RLOGD("[GSM]GSM Stop Start!");
329 if (gst_status == 4)
330 return 0;
331
332 if(gst_status == 2 || gst_status == 3) {
333 /* Out of the main loop, clean up nicely */
334 gboolean isSend = gst_element_send_event (pipeline_element, gst_event_new_eos ());
335 GstStateChangeReturn ret = gst_element_set_state (pipeline_element, GST_STATE_NULL);
336 RLOGD("[GSM]Returned, stopping playback. ret: %d, isSend: %d", ret, isSend);
337 gst_status = 4;
338 } else {
339 return -1;
340 }
341 RLOGD("[GSM]GSM Stop End!");
342 return 0;
343}
344
345int GSM_Close()
346{
347 RLOGD("[GSM]Deleting pipeline");
348 gst_object_unref (GST_OBJECT (pipeline_element));
349 gst_deinit ();
350 gst_status = 0;
351 RLOGD("[GSM]GSM Close Done!");
352 return 0;
353}
354/*cmd:1, address,
355*2, clirMode,
356*3, if present, uusinfo.type
357*4, as above, uusinfo.Dcs
358*5, as above, uusinfo.userdatalength
359*6, as above, uusinfo.UserData
360*/
361//RIL_REQUEST_DIAL
362int dial(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
363{
364 android::Parcel p;
365 size_t pos = p.dataPosition();
366
367 if (argc < 3 || argv[1]==NULL) {
368 //add log msg
369 free(pRI);
370 return -1;
371 }
372 //address;
373 writeStringToParcel(p, (const char *)argv[1]);
374 //clirMode
375 if (argc >=2) {
376 p.writeInt32(atoi(argv[2]));
377
378 if (argc == 7 && argv[3] != NULL
379 && argv[4] != NULL && argv[5] != NULL
380 && argv[6] != NULL ) {
381 p.writeInt32(1); // UUS information is present
382 p.writeInt32(atoi(argv[3]));
383 p.writeInt32(atoi(argv[4]));
384 p.writeByteArray((size_t)atoi(argv[5]),(uint8_t*)argv[6]);
385 } else {
386 p.writeInt32(0); // UUS information is absent
387 }
388 }
389 p.setDataPosition(pos);
390 setEcallAudioPathOn(false);
391 pRI->pCI->dispatchFunction(p, pRI);
392 inCallstatus = CALL_ON;
393 return 0;
394}
395#if 0 //not need user setup
396//RIL_REQUEST_OEM_HOOK_STRINGS
397int invokeOemRilRequestStrings(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
398{
399 android::Parcel p;
400 size_t pos = p.dataPosition();
401 RLOGD("OEM_HOOK_STRINGS: p1->\"%s\",p2->\"%s\"",argv[1],argv[2]);
402 p.writeInt32(2);
403 writeStringToParcel(p, (const char *)argv[1]);
404 writeStringToParcel(p, "\"\"");//(const char *)argv[2]);
405 p.setDataPosition(pos);
406
407 pRI->pCI->dispatchFunction(p, pRI);
408 return 0;
409}
410#endif
411
412extern void ARspRequest (int request,RIL_SOCKET_ID socket_id);
413//RIL_REQUEST_SET_AUDIO_PATH
414/*cmd:1, speech mode,
415*2, bt_has_ecnr
416*3, bt_wbs
417*/
418int setAudioPath(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
419{
420 if (argc < 1) {
421 free(pRI);
422 RLOGE("set bt mode need bt_has_encr and bt_wbs");
423 return -1;
424 }
425
426 int temp_audio_path = atoi(argv[1]);
427 int bt_has_ecnr;
428 int bt_wbs;
429 int current_audio_path = get_audio_path();
430 RLOGD("setAudioPath enter");
431 if ((temp_audio_path != 0) && (temp_audio_path != 1)) {
432 RLOGE("audio path illegal %d, only support 0 and 1", temp_audio_path);
433 return -1;
434 }
435 set_audio_path(temp_audio_path);
436 RLOGD("set audio path to %d, current audio path is %d", temp_audio_path, current_audio_path);
437 if (temp_audio_path == 1) {
438 /* bt speech need BT_HAS_ECNR and BT_WBS */
439 bt_has_ecnr = atoi(argv[2]);
440 bt_wbs = atoi(argv[3]);
441 set_bt_has_ecnr(bt_has_ecnr);
442 set_bt_wbs(bt_wbs);
443 RLOGD("set bt_has_ecnr %d, bt_wbs %d", bt_has_ecnr, bt_wbs);
444 }
445 if ((current_audio_path != temp_audio_path)
446 && (get_call_status() == CALL_ON)) {
447 if (current_audio_path == 0) {
448 if (getSpeechStatus() == NORMAL_SPEECH_ON) {
449 RLOGD("normal speech off then bt speech on");
450 mixer_set(0);
451 setSpeechAndStatus(2);
452 }
453 } else {
454 if (getSpeechStatus() == BT_SPEECH_ON) {
455 RLOGD("bt speech off then normal speech on");
456 bt_mixer_set(0);
457 setSpeechAndStatus(1);
458 }
459 }
460 }
461 if (pRI != NULL) {
462 free(pRI);
463 }
464
465 RLOGD("setAudioPath done");
466 return 0;
467}
468
469
470//RIL_REQUEST_HANGUP
471int hangupConnection(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
472{
473 android::Parcel p;
474 size_t pos = p.dataPosition();
475
476 p.writeInt32(1);
477 p.writeInt32(atoi(argv[1]));
478 p.setDataPosition(pos);
479
480 pRI->pCI->dispatchFunction(p, pRI);
481 return 0;
482}
483
484//RIL_REQUEST_FORCE_RELEASE_CALL
485int forceReleaseCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
486{
487 android::Parcel p;
488 size_t pos = p.dataPosition();
489
490 p.writeInt32(1);
491 p.writeInt32(atoi(argv[1]));
492 p.setDataPosition(pos);
493
494 pRI->pCI->dispatchFunction(p, pRI);
495 return 0;
496}
497
498//RIL_REQUEST_SEPARATE_CONNECTION
499int separateConnection(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
500{
501 android::Parcel p;
502 size_t pos = p.dataPosition();
503
504 p.writeInt32(1);
505 p.writeInt32(atoi(argv[1]));
506 p.setDataPosition(pos);
507
508 pRI->pCI->dispatchFunction(p, pRI);
509 return 0;
510}
511//RIL_REQUEST_DTMF
512//RIL_REQUEST_DTMF_START
513int sendDtmf(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
514{
515 android::Parcel p;
516 int number;
517 size_t pos = p.dataPosition();
518 char * c_num = NULL;
519
520 c_num = argv[1];
521 if (c_num == NULL) {
522 free(pRI);
523 return -1;
524 }
525 number = int(c_num[0] - '0');
526 if(number == -6)
527 number = 10;
528 if(number == -13)
529 number = 11;
530 RLOGD("DTMF input number is %s-->%d",c_num,number);
531 if ( number < 0 || number > 15 ) {
532 RLOGE("DTMF input number error");
533 free(pRI);
534 return -1;
535 }
536
537 writeStringToParcel(p, (const char *)argv[1]);
538 p.setDataPosition(pos);
539
540 dtmf_stop(dtmf_handle);
541 gint time_ms = 500;
542 if (pRI->pCI->requestNumber == RIL_REQUEST_DTMF_START) {
543 time_ms = 0;
544 }
545 RLOGD("request: %d, time_ms = %d", pRI->pCI->requestNumber, time_ms);
546 dtmf_handle = dtmf_start(number, time_ms, dtmf_volume, NULL);
547 pRI->pCI->dispatchFunction(p, pRI);
548 if (dtmf_handle == NULL)
549 RLOGE("[DTMF] dtmf_start return NULL!");
550 return 0;
551}
552
553//RIL_REQUEST_UDUB
554int rejectCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
555{
556 android::Parcel p;
557
558 pRI->pCI->dispatchFunction(p, pRI);
559 return 0;
560}
561//RIL_REQUEST_ANSWER
562int acceptCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
563{
564 android::Parcel p;
565
566 pRI->pCI->dispatchFunction(p, pRI);
567 inCallstatus = CALL_ON;
568 return 0;
569}
570
571//RIL_REQUEST_HANGUP_ALL
572int hangupAll(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
573{
574 android::Parcel p;
575
576 pRI->pCI->dispatchFunction(p, pRI);
577 return 0;
578}
579
580//RIL_REQUEST_CONFERENCE
581int conference(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
582{
583 android::Parcel p;
584
585 pRI->pCI->dispatchFunction(p, pRI);
586 return 0;
587}
588//RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND
589int hangupWaitingOrBackground(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
590{
591 android::Parcel p;
592
593 pRI->pCI->dispatchFunction(p, pRI);
594 return 0;
595}
596//RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE
597int switchWaitingOrHoldingAndActive(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
598{
599 android::Parcel p;
600
601 pRI->pCI->dispatchFunction(p, pRI);
602 return 0;
603}
604//RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND
605int hangupForegroundResumeBackground(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
606{
607 android::Parcel p;
608
609 pRI->pCI->dispatchFunction(p, pRI);
610 return 0;
611}
612//RIL_REQUEST_EXPLICIT_CALL_TRANSFER
613int explicitCallTransfer(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
614{
615 android::Parcel p;
616
617 pRI->pCI->dispatchFunction(p, pRI);
618 return 0;
619}
620
621//RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER
622int addImsConferenceCallMember(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
623{
624 android::Parcel p;
625 size_t pos = p.dataPosition();
626
627 p.writeInt32(3);
628 writeStringToParcel(p, (const char *)argv[1]);//confCallId
629 writeStringToParcel(p, (const char *)argv[2]);//address
630 writeStringToParcel(p, (const char *)argv[3]);//CallIdToAdd
631
632 p.setDataPosition(pos);
633 pRI->pCI->dispatchFunction(p, pRI);
634 return 0;
635}
636//RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER
637int removeImsConferenceCallMember(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
638{
639 android::Parcel p;
640 size_t pos = p.dataPosition();
641
642 p.writeInt32(3);
643 writeStringToParcel(p, (const char *)argv[1]);//confCallId
644 writeStringToParcel(p, (const char *)argv[2]);//address
645 writeStringToParcel(p, (const char *)argv[3]);//CallIdToRemove
646
647 p.setDataPosition(pos);
648 pRI->pCI->dispatchFunction(p, pRI);
649 return 0;
650}
651//RIL_REQUEST_CONFERENCE_DIAL
652//argv[1]:DialMethod
653//argv[2]:ParticipantsNumber
654//argv[2+ParticipantsNumber]:addresss
655//argv[2+ParticipantsNumber+1]:clir
656int conferenceDial(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
657{
658 android::Parcel p;
659 size_t pos = p.dataPosition();
660 int ParticipantsNumber,i;
661
662 if( argc < 3 ) {
663 free(pRI);
664 RLOGE("Error: conference Dial parameter is error!");
665 return -1;
666 }
667
668 ParticipantsNumber = atoi(argv[2]);
669
670 if( argc < (ParticipantsNumber+3) ) {
671 free(pRI);
672 RLOGE("Error: Dial With SIP URI parameter is error! \
673 argc is %d, and need parameter %d",argc,(ParticipantsNumber+3));
674 return -1;
675 }
676
677 p.writeInt32((ParticipantsNumber+3));
678 writeStringToParcel(p, (const char *)argv[1]); //DialMethod
679 writeStringToParcel(p, (const char *)argv[2]); //ParticipantsNumber
680 for( i=0; i<ParticipantsNumber; i++ ){ //address
681 writeStringToParcel(p, (const char *)argv[3+i]);
682 }
683 writeStringToParcel(p, (const char *)argv[3+ParticipantsNumber]);//clir
684
685 p.setDataPosition(pos);
686 setEcallAudioPathOn(false);
687 pRI->pCI->dispatchFunction(p, pRI);
688 return 0;
689}
690//RIL_REQUEST_DIAL_WITH_SIP_URI
691int dialWithSipUri(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
692{
693 android::Parcel p;
694 size_t pos = p.dataPosition();
695
696 if (argc < 3 || argv[1]==NULL) {
697 free(pRI);
698 return -1;
699 }
700
701 writeStringToParcel(p, (const char *)argv[1]);//address
702 /* for compatibility of test script, still receive clirMode and UUS,
703 but don't send them to libvendor-ril */
704#if 0
705 p.writeInt32(atoi(argv[2]));//clirMode
706 p.writeInt32(0); // UUS information is absent
707#endif
708
709 p.setDataPosition(pos);
710 setEcallAudioPathOn(false);
711 pRI->pCI->dispatchFunction(p, pRI);
712 return 0;
713}
714//RIL_REQUEST_HOLD_CALL
715int holdCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
716{
717 android::Parcel p;
718 size_t pos = p.dataPosition();
719
720 if (argc < 2 || argv[1]==NULL) {
721 free(pRI);
722 return -1;
723 }
724
725 //callIDToHold
726 p.writeInt32(1);
727 p.writeInt32(atoi(argv[1]));
728
729 p.setDataPosition(pos);
730
731 pRI->pCI->dispatchFunction(p, pRI);
732 return 0;
733}
734//RIL_REQUEST_RESUME_CALL
735int resumeCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
736{
737 android::Parcel p;
738 size_t pos = p.dataPosition();
739
740 if (argc < 2 || argv[1]==NULL) {
741 free(pRI);
742 return -1;
743 }
744
745 //callIDToResume
746 p.writeInt32(1);
747 p.writeInt32(atoi(argv[1]));
748
749 p.setDataPosition(pos);
750
751 pRI->pCI->dispatchFunction(p, pRI);
752 return 0;
753}
754int getCurrentCalls(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
755{
756 android::Parcel p;
757
758 pRI->pCI->dispatchFunction(p, pRI);
759 return 0;
760}
761int autoAnswerCall(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
762{
763 if(argc < 2) {
764 RLOGW("[error],set auto answer call parameter error!");
765 free(pRI);
766 return 0;
767 }
768 //need add lock to pretect.
769 autoAnswerMode = atoi(argv[1]) ? 1 : 0;
770 RLOGD("SetAutoAnserMode is %s",autoAnswerMode ? "On" :"Off");
771 if(pRI) {
772 free(pRI);
773 }
774 return 0;
775}
776
777int inCallRecord(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
778{
779 int recordEnable = 0;
780 char* filepath = NULL;
781 if(inCallstatus == CALL_OFF || speechStatus == SPEECH_OFF) {
782 RLOGW("[warning],not in calling status. Can't do record!");
783 return 0;
784 }
785
786 if(argc < 3) {
787 free(pRI);
788 RLOGW("[error],inCallRecord parameter error!");
789 return 0;
790 }
791
792 recordEnable = atoi(argv[1]) ? 1 : 0;
793 RLOGD("InCall record %s!",recordEnable ? "enable" : "disable");
794 filepath = argv[2];
795 RLOGD("InCall record file path as \'%s\'",filepath);
796
797 if (recordEnable == 1) {//enable record
798 RLOGD("start GSM!");
799 if(-1 != GSM_Init(filepath) && -1 != GSM_Start()) {
800 inCallRecordMode = 1;
801 RLOGW("inCallRecord Start OK!");
802 }else{
803 inCallRecordMode = 0;
804 RLOGW("[error],inCallRecord Start fail!");
805 }
806 } else { //disable record
807 if (inCallRecordMode == 1) {
808 if(!(-1 != GSM_Stop() && -1 != GSM_Close()))
809 RLOGW("[error],inCallRecord fail!");
810
811 inCallRecordMode = 0;
812 }
813 }
814
815 if(pRI != NULL) {
816 free(pRI);
817 }
818 return 0;
819}
820
821int StopRecord()
822{
823 RLOGD("After Handup, stop record! Before Record is %s",inCallRecordMode ? "Enable" : "Disable");
824 if (inCallRecordMode == 1) {
825 if(!(-1 != GSM_Stop() && -1 != GSM_Close()))
826 RLOGW("[error],inCallRecord fail!");
827
828 inCallRecordMode = 0;
829 /*From GSM report stop_record to PulseAudio send record_off need 15ms. so after stop record delay 30ms*/
830 usleep(30*1000);
831 }
832 return 0;
833}
834
835int setSpeechVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
836{
837 int setValue = 0;
838 RLOGD("setSpeechVolume start!");
839
840 if(argc < 2) {
841 free(pRI);
842 RLOGW("Warning: no set volume value!");
843 return -1;
844 }
845
846 setValue = atoi(argv[1]);
847 RLOGD("set Speech Volume value is %d!",setValue);
848 if (get_audio_path() == 0) {
849 if(setValue < MIN_VOLUME || setValue > MAX_VOLUME) {
850 RLOGW("Warning: set volume value is over-range!");
851 return -1;
852 }
853 } else {
854 if(setValue < BT_MIN_VOLUME || setValue > BT_MAX_VOLUME) {
855 RLOGW("Warning: set bt volume value is over-range!");
856 return -1;
857 }
858 }
859 //paramter is from 1 to 7
860 mixer_set_volume(setValue);
861 free(pRI);
862 return 0;
863}
864int setDtmfVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
865{
866 int setValue = 0;
867 Parcel p;
868 RLOGD("setDtmfVolume start!");
869 printf("setDtmfVolume start!\n");
870 if(argc < 2) {
871 RLOGW("Warning: no set volume value!");
872 printf("Warning: no set volume value!\n");
873 free(pRI);
874 return -1;
875 }
876
877 setValue = atoi(argv[1]);
878 RLOGD("set dtmf Volume value is %d!",setValue);
879 printf("set dtmf Volume value is %d!\n",setValue);
880 if(setValue < DTMF_MIN_VOLUME || setValue > DTMF_MAX_VOLUME) {
881 RLOGW("Warning: set volume value is over-range!");
882 printf("set dtmf Volume value is %d!\n",setValue);
883 /*Warren add for t800 ril service 2021/12/23 start*/
884 android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_DTMF_VOLUME,0,2);
885 android::LYNQ_RIL_respSocket_sp(p,pRI);
886 /*Warren add for t800 ril service 2021/12/23 end*/
887 free(pRI);
888 return -1;
889 }
890 //paramter is from 0 to 36
891 dtmf_volume = setValue;
892 printf(">>>>set dtmf Volume<<<< success value is %d!\n",setValue);
893 /*Warren add for t800 ril service 2021/12/23 start*/
894 android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_DTMF_VOLUME,0,0);
895 printf(">>>>set dtmf Volume<<<< success value is %d!\n",setValue);
896 /*Warren add for t800 ril service 2021/12/23 end*/
897 android::LYNQ_RIL_respSocket_sp(p,pRI);
898 free(pRI);
899 return 0;
900}
901
902speech_status getSpeechStatus()
903{
904 return speechStatus;
905}
906
907void setSpeechAndStatus(int value)
908{
909 RLOGD("setSpeechAndStatus value: %d, speechStatus: %d", value, speechStatus);
910 if (value == 1) {
911 speechStatus = NORMAL_SPEECH_ON;
912 mixer_set(1);
913 } else if (value == 2) {
914 speechStatus = BT_SPEECH_ON;
915 bt_mixer_set(1);
916 } else if (value == 0) {
917 speechStatus == BT_SPEECH_ON ? bt_mixer_set(0) : mixer_set(0);
918 speechStatus = SPEECH_OFF;
919 } else {
920 RLOGE("set speech value is invaild!\n");
921 }
922}
923//RIL_REQUEST_EMERGENCY_DIAL
924/*cmd:1, address,
925*2, clirMode,
926*3, if present, uusinfo.type
927*4, as above, uusinfo.Dcs
928*5, as above, uusinfo.userdatalength
929*6, as above, uusinfo.UserData
930*/
931int emergencyDial(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
932{
933 android::Parcel p;
934 size_t pos = p.dataPosition();
935
936 if (argc < 3 || argv[1] == NULL)
937 {
938 //add log msg
939 free(pRI);
940 return -1;
941 }
942 //address;
943 writeStringToParcel(p, (const char *) argv[1]);
944 //clirMode
945 if (argc >= 2)
946 {
947 p.writeInt32(atoi(argv[2]));
948
949 if (argc == 7&& argv[3] != NULL
950 && argv[4] != NULL && argv[5] != NULL
951 && argv[6] != NULL)
952 {
953 p.writeInt32(1); // UUS information is present
954 p.writeInt32(atoi(argv[3]));
955 p.writeInt32(atoi(argv[4]));
956 p.writeByteArray((size_t) atoi(argv[5]), (uint8_t*) argv[6]);
957 } else
958 {
959 p.writeInt32(0); // UUS information is absent
960 }
961 }
962 p.setDataPosition(pos);
963 setEcallAudioPathOn(false);
964 pRI->pCI->dispatchFunction(p, pRI);
965 return 0;
966}
967//RIL_REQUEST_SET_ECC_SERVICE_CATEGORY
968int setEccServiceCategory(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
969{
970 android::Parcel p;
971 size_t pos = p.dataPosition();
972
973 //if ( getSpeechStatus() != 1)
974 // setSpeechAndStatus(1);
975
976 p.writeInt32(1);
977 p.writeInt32(atoi(argv[1]));
978 p.setDataPosition(pos);
979 pRI->pCI->dispatchFunction(p, pRI);
980 return 0;
981}
982//RIL_REQUEST_SET_ECC_LIST
983/* argv[1]: list number
984 argv[2+i]: ECC string
985 argv[3+i]: Categroy
986 argv[4+i]: Conditon
987*/
988int setEccList(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
989{
990 android::Parcel p;
991 size_t pos = p.dataPosition();
992 int num = 0;
993 //if ( getSpeechStatus() != 1)
994 // setSpeechAndStatus(1);
995 if(argc < 3) {
996 RLOGE("%s parameter error!",__func__);
997 free(pRI);
998 return -1;
999 }
1000 num = atoi(argv[1]);
1001 RLOGD("list number is %d, argc is %d",num, argc);
1002 if((num == 0) || ((argc-2) < num*3)) {
1003 RLOGE("%s parameter error!",__func__);
1004 free(pRI);
1005 return -1;
1006 }
1007
1008 p.writeInt32(num*3);
1009 for(int i = 0; i < num; i++){
1010 writeStringToParcel(p, (const char *)argv[2+i*3+0]); //ECC
1011 writeStringToParcel(p, (const char *)argv[2+i*3+1]); //Category
1012 writeStringToParcel(p, (const char *)argv[2+i*3+2]); //Condition
1013 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]);
1014 }
1015 p.setDataPosition(pos);
1016 pRI->pCI->dispatchFunction(p, pRI);
1017 return 0;
1018}
1019
1020//RIL_REQUEST_SET_ECC_NUM
1021int setEccNum(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1022{
1023 android::Parcel p;
1024 size_t pos = p.dataPosition();
1025 int num = 0;
1026
1027 if(argc < 2 || argc > 3) {
1028 RLOGE("%s parameter error!",__func__);
1029 free(pRI);
1030 return -1;
1031 }
1032
1033 num = (argc > 2)?2:1;
1034
1035 p.writeInt32(num);
1036 writeStringToParcel(p, (const char *)argv[1]); //ECC number with card
1037 RLOGD("Set ECC number with card: %s",argv[1]);
1038 if (num>1){
1039 writeStringToParcel(p, (const char *)argv[2]); //ECC number without card
1040 RLOGD("Set ECC number without card: %s",argv[2]);
1041 }
1042 p.setDataPosition(pos);
1043 pRI->pCI->dispatchFunction(p, pRI);
1044 return 0;
1045}
1046
1047//RIL_REQUEST_GET_ECC_NUM
1048int getEccNum(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1049{
1050 android::Parcel p;
1051 pRI->pCI->dispatchFunction(p, pRI);
1052 return 0;
1053}
1054
1055int handleECCNumResponse(const void *data, int datalen, RIL_SOCKET_ID socket_id){
1056 if (data == NULL || datalen <= 0){
1057 RLOGE("%s parameter error!",__func__);
1058 return -1;
1059 }
1060
1061 printf("[ECC NUM][Slot%d] %s\n", socket_id, (const char*)data);
1062 RLOGD("[ECC NUM][Slot%d] %s\n", socket_id, (const char*)data);
1063 return 0;
1064}
1065
1066
1067//RIL_REQUEST_LAST_CALL_FAIL_CAUSE
1068int getLastCallFailCause(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
1069 if(argc != 1)
1070 {
1071 RLOGD("the peremeters numbers isn't right , so return");
1072 free(pRI);
1073 return -1;
1074 }
1075 RLOGD("getLastCallFailCause %d: " , pRI->pCI->requestNumber);
1076 android::Parcel p;
1077
1078 pRI->pCI->dispatchFunction(p, pRI);
1079 return 0;
1080}
1081
1082//#ifdef C2K_SUPPORT
1083static bool is12Key(char c) {
1084 return (c >= '0' && c <= '9') || c == '*' || c == '#';
1085}
1086
1087//RIL_REQUEST_CDMA_BURST_DTMF
1088int sendBurstDtmf(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI){
1089 if(argc < 4) {
1090 RLOGE("%s parameter error!",__func__);
1091 free(pRI);
1092 return -1;
1093 }
1094 int number;
1095 char * c_num = NULL;
1096
1097 c_num = argv[1];
1098 if (c_num == NULL) {
1099 free(pRI);
1100 return -1;
1101 }
1102 number = int(c_num[0] - '0');
1103 if(number == -6)
1104 number = 10;
1105 if(number == -13)
1106 number = 11;
1107 RLOGD("DTMF input number is %s-->%d",c_num,number);
1108 if ( number < 0 || number > 15 ) {
1109 RLOGE("DTMF input number error");
1110 free(pRI);
1111 return -1;
1112 }
1113 dtmf_stop(dtmf_handle);
1114 dtmf_handle = dtmf_start(number, 500, dtmf_volume, NULL);
1115 android::Parcel p;
1116 size_t pos = p.dataPosition();
1117 p.writeInt32(3);
1118 writeStringToParcel(p, c_num);
1119 writeStringToParcel(p, argv[2]);
1120 writeStringToParcel(p, argv[3]);
1121 p.setDataPosition(pos);
1122 pRI->pCI->dispatchFunction(p, pRI);
1123 if (dtmf_handle == NULL)
1124 RLOGE("[DTMF] dtmf_start return NULL!");
1125 return 0;
1126}
1127
1128//RIL_REQUEST_CDMA_FLASH
1129int sendCDMAFeatureCode(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI){
1130 if(argc > 2)
1131 {
1132 RLOGD("the peremeters numbers isn't right , so return");
1133 free(pRI);
1134 return -1;
1135 }
1136 android::Parcel p;
1137 size_t pos = p.dataPosition();
1138 writeStringToParcel(p, ((argc == 1) ? "" : argv[1]));
1139 p.setDataPosition(pos);
1140 pRI->pCI->dispatchFunction(p, pRI);
1141 return 0;
1142}
1143//#endif /*C2K_SUPPORT*/
1144
1145static int mixer_set_mute(int path, int value)
1146{
1147 RLOGD("mixer_set_mute path: %d , value: %d", path, value);
1148 int ret;
1149 /* DL:0 UL:1 */
1150 if (path == 0) {
1151 ret = set_mixer_ctrl_value_int(g_DL_mute_name, value);
1152 } else {
1153 ret = set_mixer_ctrl_value_int(g_UL_mute_name, value);
1154 }
1155 if (ret) {
1156 RLOGE("set_mixer_ctrl_volume_value_int err: %d", ret);
1157 }
1158 return ret;
1159}
1160
1161static long int mixer_get_mute(int path)
1162{
1163 long int is_mute;
1164
1165 /* DL:0 UL:1 */
1166 if (path == 0) {
1167 is_mute = get_mixer_ctrl_value_int(g_DL_mute_name);
lhb07f4e12022-02-17 22:08:54 -08001168 RLOGD("The ctrl \"%s\" is set to %ld", g_DL_mute_name, is_mute);
lh7b0674a2022-01-10 00:34:35 -08001169 } else {
1170 is_mute = get_mixer_ctrl_value_int(g_UL_mute_name);
lhb07f4e12022-02-17 22:08:54 -08001171 RLOGD("The ctrl \"%s\" is set to %ld", g_UL_mute_name, is_mute);
lh7b0674a2022-01-10 00:34:35 -08001172 }
1173
1174 return is_mute;
1175}
1176
1177static int setCallMute(bool mute) {
1178 RLOGD("setCallMute: %d", mute);
1179 return mixer_set_mute(1, (mute ? 1: 0));
1180}
1181
1182int getCallMute() {
1183 long int cc_mute = mixer_get_mute(1);
lhb07f4e12022-02-17 22:08:54 -08001184 RLOGD("getCallMute: %ld", cc_mute);
lh7b0674a2022-01-10 00:34:35 -08001185 return cc_mute;
1186}
1187
1188void resetMute() {
1189 if (getCallMute() > 0) {
1190 setCallMute(false);
1191 }
1192}
1193
1194void callRing(RIL_SOCKET_ID soc_id)
1195{
1196 resetMute();
1197 if (autoAnswerMode) {
1198 RLOGD("Auto Answer MT Call!");
1199 android::requestAnswer(soc_id);
1200 }
1201 return;
1202}
1203
1204void autoAnswerForCdma(RIL_SOCKET_ID socket_id)
1205{
1206 resetMute();
1207 if (autoAnswerMode) {
1208 RLOGD("Auto Answer MT Call for cdma");
1209 ARspRequest(RIL_REQUEST_CDMA_FLASH, socket_id);
1210 }
1211 return;
1212}
1213
1214//void callStateChange(void)
1215void speechonoff(int callnum)
1216{
1217 static int callIndex = 0;
1218 RLOGD("callnum = %d, Call State Change then judge speech on/off!", callnum);
1219 callIndex = callnum;
1220 if( callIndex == 1 && speechStatus == SPEECH_OFF) { //speech on
1221 //RLOGD("DemoAPP Call shell command (pactl set-card-profile 0 phonecall)");
1222 //system("pactl set-card-profile 0 phonecall");
1223 //RLOGD("DemoAPP Call shell command end");
1224 if (get_audio_path() == 0) {
1225 mixer_set(1);
1226 speechStatus = NORMAL_SPEECH_ON;
1227 } else {
1228 bt_mixer_set(1);
1229 speechStatus = BT_SPEECH_ON;
1230 }
1231 inCallstatus = CALL_ON;
1232 RLOGD("[speech]: set on");
1233 sendCallMsg(true); //for Power Manager test
1234 } else if (callIndex == 0
1235 && (speechStatus == NORMAL_SPEECH_ON
1236 || speechStatus == BT_SPEECH_ON)) { //speech off
1237 StopRecord();
1238 sendCallMsg(false); // for Power Manager test.
1239 dtmf_stop(dtmf_handle);
lhb07f4e12022-02-17 22:08:54 -08001240 dtmf_handle = NULL;
lh7b0674a2022-01-10 00:34:35 -08001241 if (speechStatus == NORMAL_SPEECH_ON) {
1242 mixer_set(0);
1243 } else {
1244 bt_mixer_set(0);
1245 }
1246 //RLOGD("DemoAPP Call shell command (pactl set-card-profile 0 HiFi)");
1247 //system("pactl set-card-profile 0 HiFi");
1248 //RLOGD("DemoAPP Call(pactl set-card-profile 0 HiFi) command end");
1249 speechStatus = SPEECH_OFF;
1250 inCallstatus = CALL_OFF;
1251 resetMute();
1252 RLOGD("[speech]: set off");
1253 } else {
1254 RLOGD("callIndex is %d, speechStatus is %d.",callIndex, speechStatus);
1255 }
1256
1257 return;
1258}
1259
1260//RIL_REQUEST_SET_MUTE
1261int setMute(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1262{
1263 Parcel p;
1264 printf("WARREN TEST002!!!\n");
1265 if(argc<2)
1266 {
1267 if(pRI)
1268 {
1269 free(pRI);
1270 }
1271 return -1;
1272 }
1273 bool mute = (atoi(argv[1]) > 0) ? true: false;
1274 RLOGD("set mute %s", ((atoi(argv[1]) > 0) ? "on": "off"));
1275 int ret = setCallMute(mute);
1276 if(ret) {
1277 /*Warren add for t800 ril service 2021/12/23 start*/
1278 android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_GET_MUTE,0,2);
1279 /*Warren add for t800 ril service 2021/12/23 start*/
1280 printf("set mute fail, please try agian\n");
1281 } else {
1282 /*Warren add for t800 ril service 2021/12/23 start*/
1283 android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_GET_MUTE,0,0);
1284 /*Warren add for t800 ril service 2021/12/23 start*/
1285 }
1286 /*Warren add for t800 ril service 2021/12/23 start*/
1287 printf("set mute %s\n", ((atoi(argv[1]) > 0) ? "on": "off"));
1288 android::LYNQ_RIL_respSocket(p,(void *)pRI);
1289 /*Warren add for t800 ril service 2021/12/23 start*/
1290 if(pRI) {
1291 free(pRI);
1292 }
1293 return 0;
1294}
1295
1296//RIL_REQUEST_GET_MUTE
1297int getMute(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1298{
1299
1300 Parcel p;
1301 printf("WARREN TEST001!!!\n");
1302 int mute = getCallMute();
1303 //TBC -200 fail status
1304 if(mute == -200) {
1305 printf("get mute state fail, please check whether does call exsit.\n");
1306 /*Warren add for t800 ril service 2021/12/23 start*/
1307 android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_GET_MUTE,0,2);
1308 /*Warren add for t800 ril service 2021/12/23 end*/
1309 } else {
1310 /*Warren add for t800 ril service 2021/12/23 start*/
1311 android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_GET_MUTE,0,0);
1312 /*Warren add for t800 ril service 2021/12/23 end*/
1313 }
1314 printf("current mute state is%s",((mute == 1) ? "on\n" : "off\n"));
1315 p.writeInt32(mute);
1316 android::LYNQ_RIL_respSocket(p,(void *)pRI);
1317 if(pRI) {
1318 free(pRI);
1319 }
1320 return 0;
1321}
1322
1323//RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR
1324int handleUnsolSipCallProgressInd(const void *response, size_t responselen) {
1325 if (response == NULL && responselen != 0) {
1326 RLOGE("handleUnsolSipCallProgressInd: invalid response: NULL");
1327 return -1;
1328 }
1329 if (responselen % sizeof(char *) != 0) {
1330 RLOGE("handleUnsolSipCallProgressInd: invalid response length %d expected multiple of %d\n",
1331 (int)responselen, (int)sizeof(char *));
1332 return -1;
1333 }
1334
1335 int numStrings = responselen / sizeof(char *);
1336 RLOGD("handleUnsolSipCallProgressInd: numStrings: %d", numStrings);
1337 if(numStrings < 6) {
1338 RLOGE("handleUnsolSipCallProgressInd: invalid response numbers: NULL");
1339 return -1;
1340 }
1341 char **p_cur = (char **) response;
1342 //<call_id>,<dir>,<SIP_msg_type>,<method>,<response_code>,"<reason_text>"
1343 //if response == <id>, 1, 0, 4, 0, "call completed elsewhere" ,printf "SIP CANCEL:Call completed elsewhere"
1344 //if response == <id>, 1, 0, 4, 0, " declined" ,printf "SIP CANCEL:declined"
1345 std::string call_id(p_cur[0]);
1346 std::string dir(p_cur[1]);
1347 std::string sip_msg_type(p_cur[2]);
1348 std::string method(p_cur[3]);
1349 std::string resp_code(p_cur[4]);
1350 std::string reason_text(p_cur[5]);
1351 RLOGD("%s, call_id=%s, dir=%s, sip_msg_type=%s, method=%s, resp_code=%s, reason_text=%s",
1352 __FUNCTION__, call_id.c_str(),dir.c_str(),sip_msg_type.c_str(),method.c_str(),resp_code.c_str(), reason_text.c_str());
1353 printf("call_id=%s, dir=%s, sip_msg_type=%s, method=%s, resp_code=%s, reason_text=%s\n",
1354 call_id.c_str(),dir.c_str(),sip_msg_type.c_str(),method.c_str(),resp_code.c_str(), reason_text.c_str());
1355
1356 if ((std::stoi(dir) == 1) && (std::stoi(sip_msg_type) == 0)
1357 && (std::stoi(method) == 4) && (std::stoi(resp_code) == 0)) {
lhb07f4e12022-02-17 22:08:54 -08001358 std::string msg("SIP CANCEL:");
lh7b0674a2022-01-10 00:34:35 -08001359 msg.append(reason_text);
1360 printf("%s", msg.c_str());
1361 }
1362 return 0;
1363}
1364
1365//RIL_UNSOL_CALL_INFO_INDICATION
1366int handleUnsolCallInfoInd(const void *response, size_t responselen, RIL_SOCKET_ID socket_id) {
1367 int numStrings = 0;
1368
1369 if (response == NULL && responselen != 0) {
1370 RLOGE("[slot%d]handleUnsolCallInfoInd, invalid response: NULL", socket_id);
1371 return -1;
1372 }
1373 if (responselen % sizeof(char *) != 0) {
1374 RLOGE("[slot%d]handleUnsolCallInfoInd: invalid response length %d expected multiple of %d\n",socket_id,
1375 (int)responselen, (int)sizeof(char *));
1376 return -1;
1377 }
1378
1379 if (response == NULL) {
1380 RLOGE("[slot%d]handleUnsolCallInfoInd, length and invalid response : NULL", socket_id);
1381 } else {
1382 char **p_cur = (char **) response;
1383
1384 numStrings = responselen / sizeof(char *);
1385 RLOGD("[slot%d]handleUnsolCallInfoInd: numStrings: %d",socket_id, numStrings);
1386 if(numStrings < 9) {
lhb07f4e12022-02-17 22:08:54 -08001387 RLOGE("[slot%d]handleUnsolCallInfoInd, invalid numStrings < 9, no pau value : numStrings", socket_id);
lh7b0674a2022-01-10 00:34:35 -08001388 return -1;
1389 } else {
1390 RLOGD("[slot%d]handleUnsolCallInfoInd(): pau: %s", socket_id, p_cur[8]);
1391 printf("[slot%d]handleUnsolCallInfoInd(): pau: %s\n", socket_id, p_cur[8]);
1392 }
1393 }
1394 return 0;
1395}
1396
1397static void playtone(int start) {
1398 RLOGD("playtone(): start: %d, isRingStart %d", start, isRingStart);
1399 char cmd[256];
1400 sprintf(cmd, "aplay %s", RING_PATH);
1401 system(cmd);
1402 isRingStart = false;
1403}
1404
1405//RIL_UNSOL_RINGBACK_TONE
1406int handleRingbackTone(const void *response, size_t responselen, RIL_SOCKET_ID socket_id) {
1407
1408 int numInts = 0;
1409
1410 if (response == NULL && responselen != 0) {
1411 RLOGE("[slot%d]handleRingbackTone, invalid response: NULL", socket_id);
1412 return -1;
1413 }
1414 if (responselen % sizeof(int) != 0) {
1415 RLOGE("[slot%d]handleRingbackTone: invalid response length %d expected multiple of %d\n",socket_id,
1416 (int)responselen, (int)sizeof(char *));
1417 return -1;
1418 }
1419
1420 int *p_int = (int *) response;
1421
1422 numInts = responselen / sizeof(int);
1423 RLOGD("[slot%d]handleRingbackTone: numInts: %d",socket_id, numInts);
1424 if(numInts < 1) {
lhb07f4e12022-02-17 22:08:54 -08001425 RLOGE("[slot%d]handleRingbackTone, invalid numStrings < 1", socket_id);
lh7b0674a2022-01-10 00:34:35 -08001426 return -1;
1427 } else {
1428 int start = p_int[0];
1429 RLOGD("[slot%d]handleRingbackTone(): start: %d, isRingStart %d", socket_id, start, isRingStart);
1430 printf("[slot%d]handleRingbackTone(): start: %d, isRingStart %d\n", socket_id, start, isRingStart);
1431#if defined(TARGET_PLATFORM_MT2731)
1432 if(start && (!isRingStart)) {
1433 isRingStart = true;
1434 std::thread t(playtone, start);
1435 t.detach();
1436 } else if((!start) && isRingStart) {
1437 isRingStart = false;
1438 system("kill $(ps aux | grep '[a]play' | awk '{print $2}')");
1439 }
1440#endif
1441 }
1442 return 0;
1443}
1444
1445//RIL_REQUEST_DTMF_STOP
1446int stopDtmf(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
1447{
1448 android::Parcel p;
1449
1450 dtmf_stop(dtmf_handle);
xja1c30b82022-01-25 16:13:48 +08001451 dtmf_handle = NULL;
lh7b0674a2022-01-10 00:34:35 -08001452 pRI->pCI->dispatchFunction(p, pRI);
1453 return 0;
1454}