lh | b07f4e1 | 2022-02-17 22:08:54 -0800 | [diff] [blame] | 1 | //SPDX-License-Identifier: MediaTekProprietary |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 2 | /* 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> |
| 50 | using android::Parcel; |
| 51 | /*Warren add for t800 ril servie 2021/12/23 end*/ |
| 52 | |
| 53 | static int dtmf_volume = 0; |
| 54 | void *dtmf_handle = NULL; |
| 55 | |
| 56 | extern "C" { |
| 57 | #include <dtmf.h> |
| 58 | #include "mixer_ctrl.h" |
| 59 | } |
| 60 | #undef LOG_TAG |
| 61 | #define LOG_TAG "LYNQ_RIL_CC" |
| 62 | |
| 63 | static speech_status speechStatus = SPEECH_OFF; |
| 64 | static int autoAnswerMode = 0; |
| 65 | static int inCallRecordMode = 0; |
| 66 | static call_status inCallstatus = CALL_OFF; |
| 67 | //int callIndex = 0; |
| 68 | const char g_card_name[] = "mtk_phonecall"; |
| 69 | /*for speech on*/ |
| 70 | const char g_mixer_name[] = "Speech_on"; |
| 71 | const char g_mixer_name_ecall[] = "Speech_on_ecall"; |
| 72 | const char g_mixer_reset_name[] = "Modem_reset_notify"; |
| 73 | const char g_mixer_name_bt[] = "Speech_on_bt"; |
| 74 | const char g_bt_has_ecnr_name[] = "BT_HAS_ECNR"; |
| 75 | const char g_bt_wbs_name[] = "BT_WBS"; |
| 76 | int g_audio_path = 0; // 0: normal, 1: bt |
| 77 | int g_bt_has_ecnr_value = 0; // 0: ecnr, 1, no ecnr |
| 78 | int g_bt_wbs_value = 0; // 0: 8000, 1, 16000 |
| 79 | /*for DL call volume*/ |
| 80 | const char g_mixer_name_volume[] = "DL Call"; |
| 81 | const char g_mixer_name_volume_bt[] = "DL BT"; |
| 82 | |
| 83 | const char g_DL_mute_name[] = "Speech_DL_mute"; |
| 84 | const char g_UL_mute_name[] = "Speech_UL_mute"; |
| 85 | |
| 86 | const char *RING_PATH = "/system/etc/tele/ring/ring.wav"; |
| 87 | static 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 | |
| 104 | int get_call_status(void) |
| 105 | { |
| 106 | return inCallstatus; |
| 107 | } |
| 108 | |
| 109 | void 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 | |
| 119 | int get_audio_path(void) |
| 120 | { |
| 121 | return g_audio_path; |
| 122 | } |
| 123 | |
| 124 | void 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 | |
| 134 | int get_bt_has_ecnr(void) |
| 135 | { |
| 136 | return g_bt_has_ecnr_value; |
| 137 | } |
| 138 | |
| 139 | void 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 | |
| 149 | int get_bt_wbs(void) |
| 150 | { |
| 151 | return g_bt_wbs_value; |
| 152 | } |
| 153 | |
| 154 | int 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 | } |
| 164 | int 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 { |
xj | a1c30b8 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 173 | //setEcallAudioPathOn(false); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 174 | ret = get_mixer_ctrl_value_int(g_mixer_name); |
| 175 | RLOGD("mixer_set(get_mixer_ctrl_value_int: %s) = %d", g_mixer_name, ret); |
xj | a1c30b8 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 176 | if(ret > 0) { |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 177 | 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 | } |
| 188 | int 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 | } |
| 197 | int 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 | |
| 214 | int 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); |
xj | a1c30b8 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 224 | ret = -1; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 225 | } |
| 226 | RLOGD("The ctrl \"%s\" is set to %d ", g_mixer_name, ret); |
| 227 | return ret; |
| 228 | } |
| 229 | int 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 | } |
| 241 | long 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 | } |
lh | b07f4e1 | 2022-02-17 22:08:54 -0800 | [diff] [blame] | 249 | RLOGD("The ctrl \"%s\" is set to %ld", g_mixer_name_volume, vol_value); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 250 | return vol_value; |
| 251 | } |
| 252 | |
| 253 | GstElement *pipeline_element; |
| 254 | GstState gst_cur_state = GST_STATE_NULL; |
| 255 | static int gst_status = 0; |
| 256 | |
| 257 | int 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 | |
| 307 | int 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 | |
| 326 | int 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 | |
| 345 | int 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 |
| 362 | int 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 |
| 397 | int 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 | |
| 412 | extern 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 | */ |
| 418 | int 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 |
| 471 | int 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 |
| 485 | int 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 |
| 499 | int 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 |
| 513 | int 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 |
| 554 | int 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 |
| 562 | int 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 |
| 572 | int 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 |
| 581 | int 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 |
| 589 | int 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 |
| 597 | int 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 |
| 605 | int 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 |
| 613 | int 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 |
| 622 | int 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 |
| 637 | int 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 |
| 656 | int 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 |
| 691 | int 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 |
| 715 | int 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 |
| 735 | int 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 | } |
| 754 | int 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 | } |
| 761 | int 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 | |
| 777 | int inCallRecord(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 778 | { |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 779 | android::Parcel p; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 780 | int recordEnable = 0; |
| 781 | char* filepath = NULL; |
| 782 | if(inCallstatus == CALL_OFF || speechStatus == SPEECH_OFF) { |
| 783 | RLOGW("[warning],not in calling status. Can't do record!"); |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 784 | goto FAIL_RETURN; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 785 | } |
| 786 | |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 787 | if(argc < 3) { |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 788 | RLOGW("[error],inCallRecord parameter error!"); |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 789 | goto FAIL_RETURN; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 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!"); |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 805 | goto FAIL_RETURN; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 806 | } |
| 807 | } else { //disable record |
| 808 | if (inCallRecordMode == 1) { |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 809 | inCallRecordMode = 0; |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 810 | if(!(-1 != GSM_Stop() && -1 != GSM_Close())) |
| 811 | { |
| 812 | RLOGW("[error],inCallRecord fail!"); |
| 813 | goto FAIL_RETURN; |
| 814 | } |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 815 | } |
| 816 | } |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 817 | if(pRI != NULL) { |
| 818 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_RECORD,0,0); |
| 819 | android::LYNQ_RIL_respSocket_sp(p,pRI); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 820 | free(pRI); |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 821 | } |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 822 | return 0; |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 823 | FAIL_RETURN: |
| 824 | if(pRI != NULL) { |
| 825 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_RECORD,0,2); |
| 826 | android::LYNQ_RIL_respSocket_sp(p,pRI); |
| 827 | free(pRI); |
| 828 | } |
| 829 | return -1; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | int StopRecord() |
| 833 | { |
| 834 | RLOGD("After Handup, stop record! Before Record is %s",inCallRecordMode ? "Enable" : "Disable"); |
| 835 | if (inCallRecordMode == 1) { |
| 836 | if(!(-1 != GSM_Stop() && -1 != GSM_Close())) |
| 837 | RLOGW("[error],inCallRecord fail!"); |
| 838 | |
| 839 | inCallRecordMode = 0; |
| 840 | /*From GSM report stop_record to PulseAudio send record_off need 15ms. so after stop record delay 30ms*/ |
| 841 | usleep(30*1000); |
| 842 | } |
| 843 | return 0; |
| 844 | } |
| 845 | |
| 846 | int setSpeechVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 847 | { |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 848 | android::Parcel p; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 849 | int setValue = 0; |
| 850 | RLOGD("setSpeechVolume start!"); |
| 851 | |
| 852 | if(argc < 2) { |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 853 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,2); |
| 854 | android::LYNQ_RIL_respSocket_sp(p,pRI); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 855 | free(pRI); |
| 856 | RLOGW("Warning: no set volume value!"); |
| 857 | return -1; |
| 858 | } |
| 859 | |
| 860 | setValue = atoi(argv[1]); |
| 861 | RLOGD("set Speech Volume value is %d!",setValue); |
| 862 | if (get_audio_path() == 0) { |
| 863 | if(setValue < MIN_VOLUME || setValue > MAX_VOLUME) { |
| 864 | RLOGW("Warning: set volume value is over-range!"); |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 865 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,2); |
| 866 | android::LYNQ_RIL_respSocket_sp(p,pRI); |
| 867 | free(pRI); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 868 | return -1; |
| 869 | } |
| 870 | } else { |
| 871 | if(setValue < BT_MIN_VOLUME || setValue > BT_MAX_VOLUME) { |
| 872 | RLOGW("Warning: set bt volume value is over-range!"); |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 873 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,2); |
| 874 | android::LYNQ_RIL_respSocket_sp(p,pRI); |
| 875 | free(pRI); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 876 | return -1; |
| 877 | } |
| 878 | } |
| 879 | //paramter is from 1 to 7 |
| 880 | mixer_set_volume(setValue); |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 881 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,0); |
| 882 | printf(">>>>set speech Volume<<<< success value is %d!\n",setValue); |
| 883 | /*Warren add for t800 ril service 2021/12/23 end*/ |
| 884 | android::LYNQ_RIL_respSocket_sp(p,pRI); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 885 | free(pRI); |
| 886 | return 0; |
| 887 | } |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 888 | int getSpeechVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 889 | { |
| 890 | android::Parcel p; |
| 891 | printf("WARREN TEST001!!!\n"); |
| 892 | int volumn = mixer_get_volume(); |
| 893 | //TBC -200 fail status |
| 894 | if(volumn <0) { |
| 895 | printf("get speech volumn fail, please check whether does call exsit.\n"); |
| 896 | /*Warren add for t800 ril service 2021/12/23 start*/ |
| 897 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_GET_SPEECH_VOLUME,0,2); |
| 898 | /*Warren add for t800 ril service 2021/12/23 end*/ |
| 899 | } else { |
| 900 | /*Warren add for t800 ril service 2021/12/23 start*/ |
| 901 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_GET_SPEECH_VOLUME,0,0); |
| 902 | /*Warren add for t800 ril service 2021/12/23 end*/ |
| 903 | } |
| 904 | printf("current Speech Volume is%d",volumn); |
| 905 | p.writeInt32(volumn); |
| 906 | android::LYNQ_RIL_respSocket(p,(void *)pRI); |
| 907 | if(pRI) { |
| 908 | free(pRI); |
| 909 | } |
| 910 | return 0; |
| 911 | } |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 912 | int setDtmfVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 913 | { |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 914 | android::Parcel p; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 915 | int setValue = 0; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 916 | RLOGD("setDtmfVolume start!"); |
| 917 | printf("setDtmfVolume start!\n"); |
| 918 | if(argc < 2) { |
| 919 | RLOGW("Warning: no set volume value!"); |
| 920 | printf("Warning: no set volume value!\n"); |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 921 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_DTMF_VOLUME,0,2); |
| 922 | android::LYNQ_RIL_respSocket_sp(p,pRI); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 923 | free(pRI); |
| 924 | return -1; |
| 925 | } |
| 926 | |
| 927 | setValue = atoi(argv[1]); |
| 928 | RLOGD("set dtmf Volume value is %d!",setValue); |
| 929 | printf("set dtmf Volume value is %d!\n",setValue); |
| 930 | if(setValue < DTMF_MIN_VOLUME || setValue > DTMF_MAX_VOLUME) { |
| 931 | RLOGW("Warning: set volume value is over-range!"); |
| 932 | printf("set dtmf Volume value is %d!\n",setValue); |
| 933 | /*Warren add for t800 ril service 2021/12/23 start*/ |
| 934 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_DTMF_VOLUME,0,2); |
| 935 | android::LYNQ_RIL_respSocket_sp(p,pRI); |
| 936 | /*Warren add for t800 ril service 2021/12/23 end*/ |
| 937 | free(pRI); |
| 938 | return -1; |
| 939 | } |
| 940 | //paramter is from 0 to 36 |
| 941 | dtmf_volume = setValue; |
| 942 | printf(">>>>set dtmf Volume<<<< success value is %d!\n",setValue); |
| 943 | /*Warren add for t800 ril service 2021/12/23 start*/ |
| 944 | android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_DTMF_VOLUME,0,0); |
| 945 | printf(">>>>set dtmf Volume<<<< success value is %d!\n",setValue); |
| 946 | /*Warren add for t800 ril service 2021/12/23 end*/ |
| 947 | android::LYNQ_RIL_respSocket_sp(p,pRI); |
| 948 | free(pRI); |
| 949 | return 0; |
| 950 | } |
| 951 | |
| 952 | speech_status getSpeechStatus() |
| 953 | { |
| 954 | return speechStatus; |
| 955 | } |
| 956 | |
| 957 | void setSpeechAndStatus(int value) |
| 958 | { |
| 959 | RLOGD("setSpeechAndStatus value: %d, speechStatus: %d", value, speechStatus); |
| 960 | if (value == 1) { |
| 961 | speechStatus = NORMAL_SPEECH_ON; |
| 962 | mixer_set(1); |
| 963 | } else if (value == 2) { |
| 964 | speechStatus = BT_SPEECH_ON; |
| 965 | bt_mixer_set(1); |
| 966 | } else if (value == 0) { |
| 967 | speechStatus == BT_SPEECH_ON ? bt_mixer_set(0) : mixer_set(0); |
| 968 | speechStatus = SPEECH_OFF; |
| 969 | } else { |
| 970 | RLOGE("set speech value is invaild!\n"); |
| 971 | } |
| 972 | } |
| 973 | //RIL_REQUEST_EMERGENCY_DIAL |
| 974 | /*cmd:1, address, |
| 975 | *2, clirMode, |
| 976 | *3, if present, uusinfo.type |
| 977 | *4, as above, uusinfo.Dcs |
| 978 | *5, as above, uusinfo.userdatalength |
| 979 | *6, as above, uusinfo.UserData |
| 980 | */ |
| 981 | int emergencyDial(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 982 | { |
| 983 | android::Parcel p; |
| 984 | size_t pos = p.dataPosition(); |
| 985 | |
| 986 | if (argc < 3 || argv[1] == NULL) |
| 987 | { |
| 988 | //add log msg |
| 989 | free(pRI); |
| 990 | return -1; |
| 991 | } |
| 992 | //address; |
| 993 | writeStringToParcel(p, (const char *) argv[1]); |
| 994 | //clirMode |
| 995 | if (argc >= 2) |
| 996 | { |
| 997 | p.writeInt32(atoi(argv[2])); |
| 998 | |
| 999 | if (argc == 7&& argv[3] != NULL |
| 1000 | && argv[4] != NULL && argv[5] != NULL |
| 1001 | && argv[6] != NULL) |
| 1002 | { |
| 1003 | p.writeInt32(1); // UUS information is present |
| 1004 | p.writeInt32(atoi(argv[3])); |
| 1005 | p.writeInt32(atoi(argv[4])); |
| 1006 | p.writeByteArray((size_t) atoi(argv[5]), (uint8_t*) argv[6]); |
| 1007 | } else |
| 1008 | { |
| 1009 | p.writeInt32(0); // UUS information is absent |
| 1010 | } |
| 1011 | } |
| 1012 | p.setDataPosition(pos); |
| 1013 | setEcallAudioPathOn(false); |
| 1014 | pRI->pCI->dispatchFunction(p, pRI); |
| 1015 | return 0; |
| 1016 | } |
| 1017 | //RIL_REQUEST_SET_ECC_SERVICE_CATEGORY |
| 1018 | int setEccServiceCategory(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 1019 | { |
| 1020 | android::Parcel p; |
| 1021 | size_t pos = p.dataPosition(); |
| 1022 | |
| 1023 | //if ( getSpeechStatus() != 1) |
| 1024 | // setSpeechAndStatus(1); |
| 1025 | |
| 1026 | p.writeInt32(1); |
| 1027 | p.writeInt32(atoi(argv[1])); |
| 1028 | p.setDataPosition(pos); |
| 1029 | pRI->pCI->dispatchFunction(p, pRI); |
| 1030 | return 0; |
| 1031 | } |
| 1032 | //RIL_REQUEST_SET_ECC_LIST |
| 1033 | /* argv[1]: list number |
| 1034 | argv[2+i]: ECC string |
| 1035 | argv[3+i]: Categroy |
| 1036 | argv[4+i]: Conditon |
| 1037 | */ |
| 1038 | int setEccList(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 1039 | { |
| 1040 | android::Parcel p; |
| 1041 | size_t pos = p.dataPosition(); |
| 1042 | int num = 0; |
| 1043 | //if ( getSpeechStatus() != 1) |
| 1044 | // setSpeechAndStatus(1); |
| 1045 | if(argc < 3) { |
| 1046 | RLOGE("%s parameter error!",__func__); |
| 1047 | free(pRI); |
| 1048 | return -1; |
| 1049 | } |
| 1050 | num = atoi(argv[1]); |
| 1051 | RLOGD("list number is %d, argc is %d",num, argc); |
| 1052 | if((num == 0) || ((argc-2) < num*3)) { |
| 1053 | RLOGE("%s parameter error!",__func__); |
| 1054 | free(pRI); |
| 1055 | return -1; |
| 1056 | } |
| 1057 | |
| 1058 | p.writeInt32(num*3); |
| 1059 | for(int i = 0; i < num; i++){ |
| 1060 | writeStringToParcel(p, (const char *)argv[2+i*3+0]); //ECC |
| 1061 | writeStringToParcel(p, (const char *)argv[2+i*3+1]); //Category |
| 1062 | writeStringToParcel(p, (const char *)argv[2+i*3+2]); //Condition |
| 1063 | 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]); |
| 1064 | } |
| 1065 | p.setDataPosition(pos); |
| 1066 | pRI->pCI->dispatchFunction(p, pRI); |
| 1067 | return 0; |
| 1068 | } |
| 1069 | |
| 1070 | //RIL_REQUEST_SET_ECC_NUM |
| 1071 | int setEccNum(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 1072 | { |
| 1073 | android::Parcel p; |
| 1074 | size_t pos = p.dataPosition(); |
| 1075 | int num = 0; |
| 1076 | |
| 1077 | if(argc < 2 || argc > 3) { |
| 1078 | RLOGE("%s parameter error!",__func__); |
| 1079 | free(pRI); |
| 1080 | return -1; |
| 1081 | } |
| 1082 | |
| 1083 | num = (argc > 2)?2:1; |
| 1084 | |
| 1085 | p.writeInt32(num); |
| 1086 | writeStringToParcel(p, (const char *)argv[1]); //ECC number with card |
| 1087 | RLOGD("Set ECC number with card: %s",argv[1]); |
| 1088 | if (num>1){ |
| 1089 | writeStringToParcel(p, (const char *)argv[2]); //ECC number without card |
| 1090 | RLOGD("Set ECC number without card: %s",argv[2]); |
| 1091 | } |
| 1092 | p.setDataPosition(pos); |
| 1093 | pRI->pCI->dispatchFunction(p, pRI); |
| 1094 | return 0; |
| 1095 | } |
| 1096 | |
| 1097 | //RIL_REQUEST_GET_ECC_NUM |
| 1098 | int getEccNum(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 1099 | { |
| 1100 | android::Parcel p; |
| 1101 | pRI->pCI->dispatchFunction(p, pRI); |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
| 1105 | int handleECCNumResponse(const void *data, int datalen, RIL_SOCKET_ID socket_id){ |
| 1106 | if (data == NULL || datalen <= 0){ |
| 1107 | RLOGE("%s parameter error!",__func__); |
| 1108 | return -1; |
| 1109 | } |
| 1110 | |
| 1111 | printf("[ECC NUM][Slot%d] %s\n", socket_id, (const char*)data); |
| 1112 | RLOGD("[ECC NUM][Slot%d] %s\n", socket_id, (const char*)data); |
| 1113 | return 0; |
| 1114 | } |
| 1115 | |
| 1116 | |
| 1117 | //RIL_REQUEST_LAST_CALL_FAIL_CAUSE |
| 1118 | int getLastCallFailCause(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 1119 | if(argc != 1) |
| 1120 | { |
| 1121 | RLOGD("the peremeters numbers isn't right , so return"); |
| 1122 | free(pRI); |
| 1123 | return -1; |
| 1124 | } |
| 1125 | RLOGD("getLastCallFailCause %d: " , pRI->pCI->requestNumber); |
| 1126 | android::Parcel p; |
| 1127 | |
| 1128 | pRI->pCI->dispatchFunction(p, pRI); |
| 1129 | return 0; |
| 1130 | } |
| 1131 | |
| 1132 | //#ifdef C2K_SUPPORT |
| 1133 | static bool is12Key(char c) { |
| 1134 | return (c >= '0' && c <= '9') || c == '*' || c == '#'; |
| 1135 | } |
| 1136 | |
| 1137 | //RIL_REQUEST_CDMA_BURST_DTMF |
| 1138 | int sendBurstDtmf(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI){ |
| 1139 | if(argc < 4) { |
| 1140 | RLOGE("%s parameter error!",__func__); |
| 1141 | free(pRI); |
| 1142 | return -1; |
| 1143 | } |
| 1144 | int number; |
| 1145 | char * c_num = NULL; |
| 1146 | |
| 1147 | c_num = argv[1]; |
| 1148 | if (c_num == NULL) { |
| 1149 | free(pRI); |
| 1150 | return -1; |
| 1151 | } |
| 1152 | number = int(c_num[0] - '0'); |
| 1153 | if(number == -6) |
| 1154 | number = 10; |
| 1155 | if(number == -13) |
| 1156 | number = 11; |
| 1157 | RLOGD("DTMF input number is %s-->%d",c_num,number); |
| 1158 | if ( number < 0 || number > 15 ) { |
| 1159 | RLOGE("DTMF input number error"); |
| 1160 | free(pRI); |
| 1161 | return -1; |
| 1162 | } |
| 1163 | dtmf_stop(dtmf_handle); |
| 1164 | dtmf_handle = dtmf_start(number, 500, dtmf_volume, NULL); |
| 1165 | android::Parcel p; |
| 1166 | size_t pos = p.dataPosition(); |
| 1167 | p.writeInt32(3); |
| 1168 | writeStringToParcel(p, c_num); |
| 1169 | writeStringToParcel(p, argv[2]); |
| 1170 | writeStringToParcel(p, argv[3]); |
| 1171 | p.setDataPosition(pos); |
| 1172 | pRI->pCI->dispatchFunction(p, pRI); |
| 1173 | if (dtmf_handle == NULL) |
| 1174 | RLOGE("[DTMF] dtmf_start return NULL!"); |
| 1175 | return 0; |
| 1176 | } |
| 1177 | |
| 1178 | //RIL_REQUEST_CDMA_FLASH |
| 1179 | int sendCDMAFeatureCode(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI){ |
| 1180 | if(argc > 2) |
| 1181 | { |
| 1182 | RLOGD("the peremeters numbers isn't right , so return"); |
| 1183 | free(pRI); |
| 1184 | return -1; |
| 1185 | } |
| 1186 | android::Parcel p; |
| 1187 | size_t pos = p.dataPosition(); |
| 1188 | writeStringToParcel(p, ((argc == 1) ? "" : argv[1])); |
| 1189 | p.setDataPosition(pos); |
| 1190 | pRI->pCI->dispatchFunction(p, pRI); |
| 1191 | return 0; |
| 1192 | } |
| 1193 | //#endif /*C2K_SUPPORT*/ |
| 1194 | |
| 1195 | static int mixer_set_mute(int path, int value) |
| 1196 | { |
| 1197 | RLOGD("mixer_set_mute path: %d , value: %d", path, value); |
| 1198 | int ret; |
| 1199 | /* DL:0 UL:1 */ |
| 1200 | if (path == 0) { |
| 1201 | ret = set_mixer_ctrl_value_int(g_DL_mute_name, value); |
| 1202 | } else { |
| 1203 | ret = set_mixer_ctrl_value_int(g_UL_mute_name, value); |
| 1204 | } |
| 1205 | if (ret) { |
| 1206 | RLOGE("set_mixer_ctrl_volume_value_int err: %d", ret); |
| 1207 | } |
| 1208 | return ret; |
| 1209 | } |
| 1210 | |
| 1211 | static long int mixer_get_mute(int path) |
| 1212 | { |
| 1213 | long int is_mute; |
| 1214 | |
| 1215 | /* DL:0 UL:1 */ |
| 1216 | if (path == 0) { |
| 1217 | is_mute = get_mixer_ctrl_value_int(g_DL_mute_name); |
lh | b07f4e1 | 2022-02-17 22:08:54 -0800 | [diff] [blame] | 1218 | RLOGD("The ctrl \"%s\" is set to %ld", g_DL_mute_name, is_mute); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1219 | } else { |
| 1220 | is_mute = get_mixer_ctrl_value_int(g_UL_mute_name); |
lh | b07f4e1 | 2022-02-17 22:08:54 -0800 | [diff] [blame] | 1221 | RLOGD("The ctrl \"%s\" is set to %ld", g_UL_mute_name, is_mute); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1222 | } |
| 1223 | |
| 1224 | return is_mute; |
| 1225 | } |
| 1226 | |
| 1227 | static int setCallMute(bool mute) { |
| 1228 | RLOGD("setCallMute: %d", mute); |
| 1229 | return mixer_set_mute(1, (mute ? 1: 0)); |
| 1230 | } |
| 1231 | |
| 1232 | int getCallMute() { |
| 1233 | long int cc_mute = mixer_get_mute(1); |
lh | b07f4e1 | 2022-02-17 22:08:54 -0800 | [diff] [blame] | 1234 | RLOGD("getCallMute: %ld", cc_mute); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1235 | return cc_mute; |
| 1236 | } |
| 1237 | |
| 1238 | void resetMute() { |
| 1239 | if (getCallMute() > 0) { |
| 1240 | setCallMute(false); |
| 1241 | } |
| 1242 | } |
| 1243 | |
| 1244 | void callRing(RIL_SOCKET_ID soc_id) |
| 1245 | { |
| 1246 | resetMute(); |
| 1247 | if (autoAnswerMode) { |
| 1248 | RLOGD("Auto Answer MT Call!"); |
| 1249 | android::requestAnswer(soc_id); |
| 1250 | } |
| 1251 | return; |
| 1252 | } |
| 1253 | |
| 1254 | void autoAnswerForCdma(RIL_SOCKET_ID socket_id) |
| 1255 | { |
| 1256 | resetMute(); |
| 1257 | if (autoAnswerMode) { |
| 1258 | RLOGD("Auto Answer MT Call for cdma"); |
| 1259 | ARspRequest(RIL_REQUEST_CDMA_FLASH, socket_id); |
| 1260 | } |
| 1261 | return; |
| 1262 | } |
| 1263 | |
| 1264 | //void callStateChange(void) |
| 1265 | void speechonoff(int callnum) |
| 1266 | { |
| 1267 | static int callIndex = 0; |
| 1268 | RLOGD("callnum = %d, Call State Change then judge speech on/off!", callnum); |
| 1269 | callIndex = callnum; |
| 1270 | if( callIndex == 1 && speechStatus == SPEECH_OFF) { //speech on |
| 1271 | //RLOGD("DemoAPP Call shell command (pactl set-card-profile 0 phonecall)"); |
| 1272 | //system("pactl set-card-profile 0 phonecall"); |
| 1273 | //RLOGD("DemoAPP Call shell command end"); |
| 1274 | if (get_audio_path() == 0) { |
| 1275 | mixer_set(1); |
| 1276 | speechStatus = NORMAL_SPEECH_ON; |
| 1277 | } else { |
| 1278 | bt_mixer_set(1); |
| 1279 | speechStatus = BT_SPEECH_ON; |
| 1280 | } |
| 1281 | inCallstatus = CALL_ON; |
| 1282 | RLOGD("[speech]: set on"); |
| 1283 | sendCallMsg(true); //for Power Manager test |
| 1284 | } else if (callIndex == 0 |
| 1285 | && (speechStatus == NORMAL_SPEECH_ON |
| 1286 | || speechStatus == BT_SPEECH_ON)) { //speech off |
| 1287 | StopRecord(); |
| 1288 | sendCallMsg(false); // for Power Manager test. |
| 1289 | dtmf_stop(dtmf_handle); |
lh | b07f4e1 | 2022-02-17 22:08:54 -0800 | [diff] [blame] | 1290 | dtmf_handle = NULL; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1291 | if (speechStatus == NORMAL_SPEECH_ON) { |
| 1292 | mixer_set(0); |
| 1293 | } else { |
| 1294 | bt_mixer_set(0); |
| 1295 | } |
| 1296 | //RLOGD("DemoAPP Call shell command (pactl set-card-profile 0 HiFi)"); |
| 1297 | //system("pactl set-card-profile 0 HiFi"); |
| 1298 | //RLOGD("DemoAPP Call(pactl set-card-profile 0 HiFi) command end"); |
| 1299 | speechStatus = SPEECH_OFF; |
| 1300 | inCallstatus = CALL_OFF; |
| 1301 | resetMute(); |
| 1302 | RLOGD("[speech]: set off"); |
| 1303 | } else { |
| 1304 | RLOGD("callIndex is %d, speechStatus is %d.",callIndex, speechStatus); |
| 1305 | } |
| 1306 | |
| 1307 | return; |
| 1308 | } |
| 1309 | |
| 1310 | //RIL_REQUEST_SET_MUTE |
| 1311 | int setMute(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 1312 | { |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 1313 | android::Parcel p; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1314 | printf("WARREN TEST002!!!\n"); |
| 1315 | if(argc<2) |
| 1316 | { |
| 1317 | if(pRI) |
| 1318 | { |
| 1319 | free(pRI); |
| 1320 | } |
| 1321 | return -1; |
| 1322 | } |
| 1323 | bool mute = (atoi(argv[1]) > 0) ? true: false; |
| 1324 | RLOGD("set mute %s", ((atoi(argv[1]) > 0) ? "on": "off")); |
| 1325 | int ret = setCallMute(mute); |
| 1326 | if(ret) { |
| 1327 | /*Warren add for t800 ril service 2021/12/23 start*/ |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 1328 | android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_SET_MUTE,0,2); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1329 | /*Warren add for t800 ril service 2021/12/23 start*/ |
| 1330 | printf("set mute fail, please try agian\n"); |
| 1331 | } else { |
| 1332 | /*Warren add for t800 ril service 2021/12/23 start*/ |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 1333 | android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_SET_MUTE,0,0); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1334 | /*Warren add for t800 ril service 2021/12/23 start*/ |
| 1335 | } |
| 1336 | /*Warren add for t800 ril service 2021/12/23 start*/ |
| 1337 | printf("set mute %s\n", ((atoi(argv[1]) > 0) ? "on": "off")); |
| 1338 | android::LYNQ_RIL_respSocket(p,(void *)pRI); |
| 1339 | /*Warren add for t800 ril service 2021/12/23 start*/ |
| 1340 | if(pRI) { |
| 1341 | free(pRI); |
| 1342 | } |
| 1343 | return 0; |
| 1344 | } |
| 1345 | |
| 1346 | //RIL_REQUEST_GET_MUTE |
| 1347 | int getMute(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 1348 | { |
| 1349 | |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 1350 | android::Parcel p; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1351 | printf("WARREN TEST001!!!\n"); |
| 1352 | int mute = getCallMute(); |
| 1353 | //TBC -200 fail status |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 1354 | if(mute < 0) { |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1355 | printf("get mute state fail, please check whether does call exsit.\n"); |
| 1356 | /*Warren add for t800 ril service 2021/12/23 start*/ |
| 1357 | android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_GET_MUTE,0,2); |
| 1358 | /*Warren add for t800 ril service 2021/12/23 end*/ |
| 1359 | } else { |
| 1360 | /*Warren add for t800 ril service 2021/12/23 start*/ |
| 1361 | android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_GET_MUTE,0,0); |
| 1362 | /*Warren add for t800 ril service 2021/12/23 end*/ |
| 1363 | } |
| 1364 | printf("current mute state is%s",((mute == 1) ? "on\n" : "off\n")); |
| 1365 | p.writeInt32(mute); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1366 | if(pRI) { |
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame^] | 1367 | android::LYNQ_RIL_respSocket(p,(void *)pRI); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1368 | free(pRI); |
| 1369 | } |
| 1370 | return 0; |
| 1371 | } |
| 1372 | |
| 1373 | //RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR |
| 1374 | int handleUnsolSipCallProgressInd(const void *response, size_t responselen) { |
| 1375 | if (response == NULL && responselen != 0) { |
| 1376 | RLOGE("handleUnsolSipCallProgressInd: invalid response: NULL"); |
| 1377 | return -1; |
| 1378 | } |
| 1379 | if (responselen % sizeof(char *) != 0) { |
| 1380 | RLOGE("handleUnsolSipCallProgressInd: invalid response length %d expected multiple of %d\n", |
| 1381 | (int)responselen, (int)sizeof(char *)); |
| 1382 | return -1; |
| 1383 | } |
| 1384 | |
| 1385 | int numStrings = responselen / sizeof(char *); |
| 1386 | RLOGD("handleUnsolSipCallProgressInd: numStrings: %d", numStrings); |
| 1387 | if(numStrings < 6) { |
| 1388 | RLOGE("handleUnsolSipCallProgressInd: invalid response numbers: NULL"); |
| 1389 | return -1; |
| 1390 | } |
| 1391 | char **p_cur = (char **) response; |
| 1392 | //<call_id>,<dir>,<SIP_msg_type>,<method>,<response_code>,"<reason_text>" |
| 1393 | //if response == <id>, 1, 0, 4, 0, "call completed elsewhere" ,printf "SIP CANCEL:Call completed elsewhere" |
| 1394 | //if response == <id>, 1, 0, 4, 0, " declined" ,printf "SIP CANCEL:declined" |
| 1395 | std::string call_id(p_cur[0]); |
| 1396 | std::string dir(p_cur[1]); |
| 1397 | std::string sip_msg_type(p_cur[2]); |
| 1398 | std::string method(p_cur[3]); |
| 1399 | std::string resp_code(p_cur[4]); |
| 1400 | std::string reason_text(p_cur[5]); |
| 1401 | RLOGD("%s, call_id=%s, dir=%s, sip_msg_type=%s, method=%s, resp_code=%s, reason_text=%s", |
| 1402 | __FUNCTION__, call_id.c_str(),dir.c_str(),sip_msg_type.c_str(),method.c_str(),resp_code.c_str(), reason_text.c_str()); |
| 1403 | printf("call_id=%s, dir=%s, sip_msg_type=%s, method=%s, resp_code=%s, reason_text=%s\n", |
| 1404 | call_id.c_str(),dir.c_str(),sip_msg_type.c_str(),method.c_str(),resp_code.c_str(), reason_text.c_str()); |
| 1405 | |
| 1406 | if ((std::stoi(dir) == 1) && (std::stoi(sip_msg_type) == 0) |
| 1407 | && (std::stoi(method) == 4) && (std::stoi(resp_code) == 0)) { |
lh | b07f4e1 | 2022-02-17 22:08:54 -0800 | [diff] [blame] | 1408 | std::string msg("SIP CANCEL:"); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1409 | msg.append(reason_text); |
| 1410 | printf("%s", msg.c_str()); |
| 1411 | } |
| 1412 | return 0; |
| 1413 | } |
| 1414 | |
| 1415 | //RIL_UNSOL_CALL_INFO_INDICATION |
| 1416 | int handleUnsolCallInfoInd(const void *response, size_t responselen, RIL_SOCKET_ID socket_id) { |
| 1417 | int numStrings = 0; |
| 1418 | |
| 1419 | if (response == NULL && responselen != 0) { |
| 1420 | RLOGE("[slot%d]handleUnsolCallInfoInd, invalid response: NULL", socket_id); |
| 1421 | return -1; |
| 1422 | } |
| 1423 | if (responselen % sizeof(char *) != 0) { |
| 1424 | RLOGE("[slot%d]handleUnsolCallInfoInd: invalid response length %d expected multiple of %d\n",socket_id, |
| 1425 | (int)responselen, (int)sizeof(char *)); |
| 1426 | return -1; |
| 1427 | } |
| 1428 | |
| 1429 | if (response == NULL) { |
| 1430 | RLOGE("[slot%d]handleUnsolCallInfoInd, length and invalid response : NULL", socket_id); |
| 1431 | } else { |
| 1432 | char **p_cur = (char **) response; |
| 1433 | |
| 1434 | numStrings = responselen / sizeof(char *); |
| 1435 | RLOGD("[slot%d]handleUnsolCallInfoInd: numStrings: %d",socket_id, numStrings); |
| 1436 | if(numStrings < 9) { |
lh | b07f4e1 | 2022-02-17 22:08:54 -0800 | [diff] [blame] | 1437 | RLOGE("[slot%d]handleUnsolCallInfoInd, invalid numStrings < 9, no pau value : numStrings", socket_id); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1438 | return -1; |
| 1439 | } else { |
| 1440 | RLOGD("[slot%d]handleUnsolCallInfoInd(): pau: %s", socket_id, p_cur[8]); |
| 1441 | printf("[slot%d]handleUnsolCallInfoInd(): pau: %s\n", socket_id, p_cur[8]); |
| 1442 | } |
| 1443 | } |
| 1444 | return 0; |
| 1445 | } |
| 1446 | |
| 1447 | static void playtone(int start) { |
| 1448 | RLOGD("playtone(): start: %d, isRingStart %d", start, isRingStart); |
| 1449 | char cmd[256]; |
| 1450 | sprintf(cmd, "aplay %s", RING_PATH); |
| 1451 | system(cmd); |
| 1452 | isRingStart = false; |
| 1453 | } |
| 1454 | |
| 1455 | //RIL_UNSOL_RINGBACK_TONE |
| 1456 | int handleRingbackTone(const void *response, size_t responselen, RIL_SOCKET_ID socket_id) { |
| 1457 | |
| 1458 | int numInts = 0; |
| 1459 | |
| 1460 | if (response == NULL && responselen != 0) { |
| 1461 | RLOGE("[slot%d]handleRingbackTone, invalid response: NULL", socket_id); |
| 1462 | return -1; |
| 1463 | } |
| 1464 | if (responselen % sizeof(int) != 0) { |
| 1465 | RLOGE("[slot%d]handleRingbackTone: invalid response length %d expected multiple of %d\n",socket_id, |
| 1466 | (int)responselen, (int)sizeof(char *)); |
| 1467 | return -1; |
| 1468 | } |
| 1469 | |
| 1470 | int *p_int = (int *) response; |
| 1471 | |
| 1472 | numInts = responselen / sizeof(int); |
| 1473 | RLOGD("[slot%d]handleRingbackTone: numInts: %d",socket_id, numInts); |
| 1474 | if(numInts < 1) { |
lh | b07f4e1 | 2022-02-17 22:08:54 -0800 | [diff] [blame] | 1475 | RLOGE("[slot%d]handleRingbackTone, invalid numStrings < 1", socket_id); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1476 | return -1; |
| 1477 | } else { |
| 1478 | int start = p_int[0]; |
| 1479 | RLOGD("[slot%d]handleRingbackTone(): start: %d, isRingStart %d", socket_id, start, isRingStart); |
| 1480 | printf("[slot%d]handleRingbackTone(): start: %d, isRingStart %d\n", socket_id, start, isRingStart); |
| 1481 | #if defined(TARGET_PLATFORM_MT2731) |
| 1482 | if(start && (!isRingStart)) { |
| 1483 | isRingStart = true; |
| 1484 | std::thread t(playtone, start); |
| 1485 | t.detach(); |
| 1486 | } else if((!start) && isRingStart) { |
| 1487 | isRingStart = false; |
| 1488 | system("kill $(ps aux | grep '[a]play' | awk '{print $2}')"); |
| 1489 | } |
| 1490 | #endif |
| 1491 | } |
| 1492 | return 0; |
| 1493 | } |
| 1494 | |
| 1495 | //RIL_REQUEST_DTMF_STOP |
| 1496 | int stopDtmf(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 1497 | { |
| 1498 | android::Parcel p; |
| 1499 | |
| 1500 | dtmf_stop(dtmf_handle); |
xj | a1c30b8 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 1501 | dtmf_handle = NULL; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1502 | pRI->pCI->dispatchFunction(p, pRI); |
| 1503 | return 0; |
| 1504 | } |