ll | 630be41 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 2 | #include <stdio.h>
|
| 3 | #include <sys/types.h>
|
| 4 | #include <sys/socket.h>
|
| 5 | #include <arpa/inet.h>
|
| 6 | #include <fcntl.h>
|
| 7 | #include <string.h>
|
| 8 | #include <stdlib.h>
|
| 9 | #include <unistd.h>
|
| 10 | #include <binder/Parcel.h>
|
| 11 | #include <log/log.h>
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 12 | #include <cutils/jstring.h>
|
| 13 | #include <pthread.h>
|
| 14 | #include "liblog/lynq_deflog.h"
|
lh | 2afc773 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 15 | #include <sys/time.h>
|
lh | 21502f5 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 16 | #include <string.h>
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 17 | #include <vendor-ril/telephony/ril.h>
|
| 18 | #include <vendor-ril/telephony/mtk_ril_sp.h>
|
| 19 | #include <vendor-ril/telephony/mtk_ril_ivt.h>
|
| 20 | #include "lynq_call.h"
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 21 | #include "lynq_module_common.h"
|
| 22 | #include "lynq_module_socket.h"
|
| 23 | #include "lynq_call_common.h"
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 24 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 25 | #define CALL_OFF (0)
|
| 26 | #define CALL_ON (1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 27 | #define USER_LOG_TAG "LYNQ_CALL"
|
| 28 |
|
lh | 3b6f7ea | 2023-11-08 01:16:42 -0800 | [diff] [blame] | 29 | #define AP_SPEECH "/tmp/ap_speech"
|
| 30 | #define AUDIO_CTRL_SER "/tmp/audio_ctrl_service"
|
| 31 | #define LIBMODEM_AFE "/tmp/libmodem-afe-ctrl"
|
| 32 | #define TELE_DEMO_LOCK "/tmp/tel_demo_single_proc.lock"
|
| 33 |
|
q.huang | 305fadc | 2024-01-02 18:40:40 +0800 | [diff] [blame^] | 34 | #define MAX_RING_INCOMING_INTERVAL 10
|
| 35 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 36 | using ::android::Parcel;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 37 |
|
| 38 | /**
|
| 39 | * @brief mark call initialization state
|
| 40 | * 0: deinit state
|
| 41 | * 1: init state
|
| 42 | */
|
| 43 | int g_module_init_flag = 0;
|
| 44 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 45 | typedef enum {
|
| 46 | LYNQ_CALL_ACTIVE = 0,
|
| 47 | LYNQ_CALL_HOLDING = 1,
|
| 48 | LYNQ_CALL_DIALING = 2, /* MO call only */
|
| 49 | LYNQ_CALL_ALERTING = 3, /* MO call only */
|
| 50 | LYNQ_CALL_INCOMING = 4, /* MT call only */
|
lh | e45b700 | 2022-04-26 00:45:44 -0700 | [diff] [blame] | 51 | LYNQ_CALL_WAITING = 5, /* MT call only */
|
| 52 | /*warren add for T800 platform 2022/04/26 start*/
|
| 53 | LYNQ_CALL_END = 6, /*CALL END*/
|
| 54 | /*warren add for T800 platform 2022/04/26 end*/
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 55 | }lynq_call_state_t;
|
| 56 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 57 | typedef struct
|
| 58 | {
|
| 59 | int used;
|
| 60 | int call_id;
|
| 61 | int call_state;
|
| 62 | int toa;
|
| 63 | int direction;/*0: MO call,1:MT call*/
|
| 64 | char addr[LYNQ_PHONE_NUMBER_MAX];
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 65 | }lynq_call_list_e_t;
|
| 66 | typedef struct
|
| 67 | {
|
| 68 | int call_id;
|
| 69 | int call_state;
|
| 70 | int toa;
|
| 71 | int direction;/*0: MO call,1:MT call*/
|
| 72 | char addr[LYNQ_PHONE_NUMBER_MAX];
|
| 73 | }lynq_call_list_t;
|
| 74 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 75 | static lynq_call_list_e_t s_call_lists[LYNQ_CALL_MAX]={};
|
| 76 | static bool s_call_list_loop = 0;
|
| 77 | static pthread_t s_call_list_loop_tid = -1;
|
| 78 | static pthread_mutex_t s_notice_get_call_list_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 79 | static pthread_cond_t s_notice_get_call_list_cond = PTHREAD_COND_INITIALIZER;
|
| 80 |
|
| 81 | static int s_module_isDial = 0;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 82 | static pthread_mutex_t call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 83 | static pthread_cond_t call_state_change_cond = PTHREAD_COND_INITIALIZER;
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 84 | static int s_CallId = 0;
|
| 85 | static pthread_mutex_t s_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 86 | static pthread_cond_t s_call_state_change_cond = PTHREAD_COND_INITIALIZER;
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 87 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 88 | static int s_module_call_state =CALL_OFF;
|
| 89 | static int s_call_auto_answer = 0;
|
q.huang | 305fadc | 2024-01-02 18:40:40 +0800 | [diff] [blame^] | 90 | static time_t s_rev_ring_time=0;
|
| 91 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 92 |
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 93 | typedef enum{
|
| 94 | LYNQ_E_VOLUMN_SET_DTMF,
|
| 95 | LYNQ_E_VOLUMN_SET_SPEECH
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 96 | }LYNQ_E_VOLUMN_SET;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 97 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 98 | #if 0
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 99 | int JumpHeader(Parcel &p,int *resp_type,int* token,int *request,int *slot_id,int *error)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 100 | {
|
| 101 | if(p.dataAvail() > 0)
|
| 102 | {
|
| 103 | p.readInt32(resp_type);
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 104 | p.readInt32(token);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 105 | p.readInt32(request);
|
| 106 | p.readInt32(slot_id);
|
| 107 | p.readInt32(error);
|
| 108 | return 0;
|
| 109 | }
|
| 110 | else
|
| 111 | {
|
| 112 | return -1;
|
| 113 | }
|
| 114 | }
|
| 115 | int send_request(int sockfd,lynq_client_t *client_tmp)
|
| 116 | {
|
| 117 | int ret=0;
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 118 | ret = sendto(sockfd, client_tmp, client_size, 0, (struct sockaddr *)&addr_serv, len_addr_serv);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 119 | if(ret==-1)
|
| 120 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 121 | LYERRLOG("sendto error");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 122 | return -1;
|
| 123 | }
|
| 124 | return 0;
|
| 125 | }
|
| 126 |
|
| 127 | int get_response(int sockfd,Parcel &p)
|
| 128 | {
|
| 129 | int len = 0;
|
| 130 | char recvline[LYNQ_REC_BUF];
|
| 131 | bzero(recvline,LYNQ_REC_BUF);
|
| 132 | /* receive data from server */
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 133 | len = recvfrom(sockfd,recvline,LYNQ_REC_BUF, 0, (struct sockaddr *)&addr_serv,(socklen_t*)&len_addr_serv);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 134 | if(len == -1)
|
| 135 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 136 | LYERRLOG("recvfrom error");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 137 | return -1;
|
| 138 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 139 | if (recvline != NULL) {
|
| 140 | p.setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen);
|
| 141 | p.setDataPosition(0);
|
| 142 | }
|
| 143 | return 0;
|
| 144 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 145 | #endif
|
| 146 | static char *strdupReadString(Parcel* &p) {
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 147 | size_t stringlen;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 148 | const char16_t *s16;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 149 | s16 = p->readString16Inplace(&stringlen);
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 150 | return strndup16to8(s16, stringlen);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 151 | }
|
| 152 |
|
| 153 | int lynq_get_current_call_list(lynq_call_list_t call_list[LYNQ_CALL_MAX])
|
| 154 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 155 | Parcel* p=NULL;
|
| 156 | int ret=lynq_send_common_request(p,8,RIL_REQUEST_GET_CURRENT_CALLS,0,"");
|
| 157 | if(ret!=0)
|
| 158 | {
|
| 159 | return ret;
|
| 160 | }
|
| 161 |
|
| 162 | int call_num = 0;
|
| 163 | int temp = 0;
|
| 164 | char *remote_phoneNum;
|
| 165 | char *remote_name;
|
| 166 | char uusData[128];
|
| 167 |
|
| 168 | p->readInt32(&call_num);
|
| 169 |
|
| 170 | if(call_num<=0)
|
| 171 | {
|
| 172 | s_module_call_state = CALL_OFF;
|
| 173 | LYINFLOG("lynq_call_state:%d",s_module_call_state);
|
| 174 | delete p;
|
| 175 | return RESULT_OK;
|
| 176 | }
|
| 177 | s_module_call_state = CALL_ON;
|
| 178 | LYINFLOG("lynq_call_state:%d, call num is %d ",s_module_call_state,call_num);
|
| 179 | for(int i = 0;i < call_num;i++)
|
| 180 | {
|
| 181 | p->readInt32(&temp);
|
| 182 | call_list[i].call_state = temp;
|
| 183 | p->readInt32(&call_list[i].call_id);
|
| 184 | p->readInt32(&call_list[i].toa);
|
| 185 | p->readInt32(&temp);
|
| 186 | p->readInt32(&temp);
|
| 187 | call_list[i].direction = temp;
|
| 188 | p->readInt32(&temp);
|
| 189 | p->readInt32(&temp);
|
| 190 | p->readInt32(&temp);
|
| 191 | remote_phoneNum = strdupReadString(p);
|
| 192 | memcpy(call_list[i].addr,remote_phoneNum,strlen(remote_phoneNum));
|
| 193 | if(remote_phoneNum !=NULL)
|
| 194 | {
|
| 195 | free(remote_phoneNum);
|
| 196 | }
|
| 197 | LYINFLOG("call_id=%d,call_state=%d,direction=%d,addr=%s,toa=%d",call_list[i].call_id,call_list[i].call_state,
|
| 198 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 199 | p->readInt32(&temp);
|
| 200 | remote_name = strdupReadString(p);
|
| 201 | if(remote_name !=NULL)
|
| 202 | {
|
| 203 | free(remote_name);
|
| 204 | }
|
| 205 | p->readInt32(&temp);
|
| 206 | p->readInt32(&temp);
|
| 207 | if(temp==0)
|
| 208 | {
|
| 209 | continue;
|
| 210 | }
|
| 211 | p->readInt32(&temp); /* UUS Information is present */
|
| 212 | p->readInt32(&temp);
|
| 213 | p->readInt32(&temp);
|
| 214 | if(temp<=128)
|
| 215 | {
|
| 216 | p->read(uusData,temp);
|
| 217 | }
|
| 218 | else
|
| 219 | {
|
| 220 | LYERRLOG("%s len %d is too great",__func__,temp);
|
| 221 | delete p;
|
| 222 | return LYNQ_E_MALLOC_ERROR;
|
| 223 | }
|
| 224 | }
|
| 225 |
|
| 226 | delete p;
|
| 227 | return RESULT_OK;
|
| 228 |
|
| 229 | #if 0
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 230 | Parcel p;
|
| 231 | lynq_client_t client;
|
| 232 | int resp_type = -1;
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 233 | int token;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 234 | int request = -1;
|
| 235 | int slot_id = -1;
|
| 236 | int error = -1;
|
| 237 | int call_num = 0;
|
| 238 | int temp = 0;
|
| 239 | char *remote_phoneNum = NULL;
|
| 240 | char *remote_name= NULL;
|
| 241 | char *uusData = NULL;
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 242 | client.uToken = Global_uToken_call;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 243 | client.request = 9;//RIL_REQUEST_GET_CURRENT_CALLS
|
| 244 | client.paramLen = 0;
|
| 245 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 246 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 247 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 248 | {
|
| 249 | LYERRLOG("send request fail");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 250 | return -1;
|
| 251 | }
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 252 | get_response(lynq_call_client_sockfd,p);
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 253 | JumpHeader(p,&resp_type,&token,&request,&slot_id,&error);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 254 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 255 | if(error == 0)
|
| 256 | {
|
| 257 | p.readInt32(&call_num);
|
| 258 | global_call_count = call_num;
|
| 259 | if(call_num<=0)
|
| 260 | {
|
| 261 | lynq_call_state = CALL_OFF;
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 262 | LYINFLOG("lynq_call_state:%d",lynq_call_state);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 263 | return 0;
|
| 264 | }
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 265 | lynq_call_state = CALL_ON;
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 266 | LYINFLOG("lynq_call_state:%d, call num is %d ",lynq_call_state,call_num);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 267 | for(int i = 0;i < call_num;i++)
|
| 268 | {
|
| 269 | p.readInt32(&temp);
|
| 270 | call_list[i].call_state = temp;
|
| 271 | p.readInt32(&call_list[i].call_id);
|
| 272 | p.readInt32(&call_list[i].toa);
|
| 273 | p.readInt32(&temp);
|
| 274 | p.readInt32(&temp);
|
| 275 | call_list[i].direction = temp;
|
| 276 | p.readInt32(&temp);
|
| 277 | p.readInt32(&temp);
|
| 278 | p.readInt32(&temp);
|
| 279 | remote_phoneNum = strdupReadString(p);
|
| 280 | memcpy(call_list[i].addr,remote_phoneNum,strlen(remote_phoneNum));
|
| 281 | LYINFLOG("call_id=%d,call_state=%d,direction=%d,addr=%s,toa=%d",call_list[i].call_id,call_list[i].call_state,
|
| 282 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 283 | p.readInt32(&temp);
|
| 284 | remote_name = strdupReadString(p);
|
| 285 | p.readInt32(&temp);
|
| 286 | p.readInt32(&temp);
|
| 287 | if(temp==0)
|
| 288 | {
|
| 289 | continue;
|
| 290 | }
|
| 291 | p.readInt32(&temp); /* UUS Information is present */
|
| 292 | p.readInt32(&temp);
|
| 293 | p.readInt32(&temp);
|
| 294 | p.read(uusData,temp);
|
| 295 | }
|
| 296 | }
|
| 297 | return 0;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 298 | #endif
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 299 | }
|
| 300 |
|
| 301 | void cleanCallList(int lynq_call_id)
|
| 302 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 303 | LYINFLOG("cleanCall local idx is %d, id is %d",lynq_call_id,s_call_lists[lynq_call_id].call_id);
|
| 304 | s_call_lists[lynq_call_id].call_id = 0;
|
| 305 | s_call_lists[lynq_call_id].call_state = (int)LYNQ_CALL_END;
|
| 306 | s_call_lists[lynq_call_id].toa = 0;
|
| 307 | s_call_lists[lynq_call_id].direction = 0;
|
| 308 | s_call_lists[lynq_call_id].used = 0;
|
| 309 | memset(s_call_lists[lynq_call_id].addr,0,sizeof(s_call_lists[lynq_call_id].addr));
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 310 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 311 |
|
| 312 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 313 | int getUnusedElement()
|
| 314 | {
|
| 315 | for(int i=0;i < LYNQ_CALL_MAX; i++)
|
| 316 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 317 | if(s_call_lists[i].used!=1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 318 | {
|
| 319 | return i;
|
| 320 | }
|
| 321 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 322 | return INVALID_ID;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 323 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 324 | int addAddr(char addr[], int call_id)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 325 | {
|
| 326 | int ret = 0;
|
| 327 | ret = getUnusedElement();
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 328 | memcpy(s_call_lists[ret].addr,addr,strlen(addr)+1);
|
| 329 | s_call_lists[ret].call_id=call_id;
|
| 330 | s_call_lists[ret].used = 1;
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 331 | LYINFLOG("add local idx is %d addr is %s",ret,addr);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 332 | return ret;
|
| 333 | }
|
| 334 | void updateCallList(lynq_call_list_e_t *callList, int call_id,int call_state,int toa,int direction)
|
| 335 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 336 | LYINFLOG("Update original local id is %d, new local id is %d",callList->call_id,call_id);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 337 | callList->call_id = call_id;
|
| 338 | callList->call_state = call_state;
|
| 339 | callList->toa = toa;
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 340 | callList->direction = direction;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 341 | return;
|
| 342 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 343 |
|
| 344 | void wait_call_state()
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 345 | {
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 346 | LYINFLOG("call state changed");
|
| 347 | pthread_mutex_lock(&s_call_state_change_mutex);
|
| 348 | pthread_cond_wait(&s_call_state_change_cond,&s_call_state_change_mutex);
|
| 349 | pthread_mutex_unlock(&s_call_state_change_mutex);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 350 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 351 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 352 | int checkHasCall(char addr[])
|
| 353 | {
|
| 354 | for(int i = 0;i<LYNQ_CALL_MAX;i++)
|
| 355 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 356 | if(strcmp(s_call_lists[i].addr,addr)==0)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 357 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 358 | LYINFLOG("checkHasCall addr is %s idx is %d id is %d",addr,i,s_call_lists[i].call_id);
|
| 359 | return true;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 360 | }
|
| 361 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 362 | LYINFLOG("checkHasCall addr is %s , no idx is found",addr);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 363 | return false;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 364 | }
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 365 | int find_call_id_with_addr(char *addr)
|
| 366 | {
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 367 | for(int id = 0; id < LYNQ_CALL_MAX; id++)
|
| 368 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 369 | if(s_call_lists[id].used && (strcmp(s_call_lists[id].addr,addr) == 0))
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 370 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 371 | LYINFLOG("find addr %s in local list, local idx is %d id is %d",addr,id,s_call_lists[id].call_id);
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 372 | return id;
|
| 373 | }
|
| 374 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 375 | LYINFLOG("find addr %s in local list , not found",addr);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 376 | return INVALID_ID;
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 377 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 378 | int find_call_id_with_call_id(int call_id)
|
| 379 | {
|
| 380 | for(int id = 0; id < LYNQ_CALL_MAX; id++)
|
| 381 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 382 | if(s_call_lists[id].used && (s_call_lists[id].call_id == call_id))
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 383 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 384 | LYINFLOG("find id %d in local list, local idx is %d, addr is %s",call_id,id,s_call_lists[id].addr);
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 385 | return id;
|
| 386 | }
|
| 387 | }
|
| 388 | LYINFLOG("find id %d in local list , not found",call_id);
|
| 389 | return INVALID_ID;
|
| 390 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 391 | void sendSignalToWaitCallStateChange()
|
| 392 | {
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 393 | LYINFLOG("send Signal To Wait Call State Change");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 394 | pthread_mutex_lock(&call_state_change_mutex);
|
| 395 | pthread_cond_signal(&call_state_change_cond);
|
| 396 | pthread_mutex_unlock(&call_state_change_mutex);
|
| 397 | }
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 398 | void send_call_state_change(int callid)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 399 | {
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 400 | LYINFLOG("send call state change");
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 401 | s_CallId = callid;
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 402 | pthread_mutex_lock(&s_call_state_change_mutex);
|
| 403 | pthread_cond_signal(&s_call_state_change_cond);
|
| 404 | pthread_mutex_unlock(&s_call_state_change_mutex);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 405 | }
|
| 406 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 407 | void cleanup_call_list_mutex(void *arg)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 408 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 409 | pthread_mutex_unlock(&s_notice_get_call_list_mutex);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 410 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 411 |
|
| 412 | void update_end_state(int lynq_call_id)
|
| 413 | {
|
| 414 | LYINFLOG("update_end_state local idx is %d, id is %d",lynq_call_id,s_call_lists[lynq_call_id].call_id);
|
| 415 | s_call_lists[lynq_call_id].call_state = (int)LYNQ_CALL_END;
|
| 416 | }
|
| 417 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 418 | void *triggerGetCallList(void *parg)
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 419 | {
|
| 420 | int ret=0;
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 421 | bool call_end;
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 422 | lynq_call_list_t call_list[LYNQ_CALL_MAX];
|
q.huang | 8b33ed5 | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 423 | int update=0;
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 424 | int cnt;
|
| 425 | int i,n;
|
q.huang | e97cfcf | 2022-08-29 20:04:31 +0800 | [diff] [blame] | 426 | #ifdef ECALL_SUPPORT
|
| 427 | int handupIncomingMT=0;
|
| 428 | #endif
|
q.huang | 305fadc | 2024-01-02 18:40:40 +0800 | [diff] [blame^] | 429 | unsigned long interval;
|
| 430 | time_t now;
|
| 431 |
|
| 432 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 433 | pthread_mutex_lock(&s_notice_get_call_list_mutex);
|
| 434 | pthread_cleanup_push(cleanup_call_list_mutex, NULL); // thread cleanup handler
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 435 | int tmp_call_id;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 436 | while(s_call_list_loop)
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 437 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 438 | update=0;
|
| 439 | pthread_cond_wait(&s_notice_get_call_list_cond, &s_notice_get_call_list_mutex);
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 440 | LYINFLOG("triggerGetCallList event %p!!!", pthread_self());
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 441 | memset(call_list,0,sizeof(call_list));
|
| 442 | ret = lynq_get_current_call_list(call_list);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 443 | if(ret != RESULT_OK)
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 444 | {
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 445 | LYERRLOG("get current call list failure!!!");
|
ll | bc03533 | 2022-04-11 05:49:51 +0000 | [diff] [blame] | 446 | continue;
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 447 | }
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 448 | LYINFLOG("++++++++++++++triggerGetCallList++++++++++++++");
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 449 | LYINFLOG("clear local index begin");
|
| 450 | cnt=0;
|
| 451 | for(i = 0;i < LYNQ_CALL_MAX;i++)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 452 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 453 | if(s_call_lists[i].used ==0)
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 454 | {
|
| 455 | continue;
|
| 456 | }
|
| 457 | cnt++;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 458 | LYINFLOG("local idx is %d id is %d addr is %s state is %d direction is %d",i,s_call_lists[i].call_id,s_call_lists[i].addr,s_call_lists[i].call_state,s_call_lists[i].direction);
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 459 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 460 | if(s_call_lists[i].call_id > 0)
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 461 | {
|
| 462 | call_end = 0;
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 463 | for(n = 0; n < LYNQ_CALL_MAX; n++)
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 464 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 465 | if(call_list[n].call_id == s_call_lists[i].call_id)
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 466 | {
|
| 467 | call_end = 1;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 468 | LYINFLOG("find lynq call local idx %d, service idx %d id is %d!!!",i,n,s_call_lists[i].call_id);
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 469 | break;
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 470 | }
|
| 471 | }
|
| 472 | if(call_end == 0)
|
| 473 | {
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 474 | LYINFLOG("MT/MO hungup,then clean call info local idx is %d id is %d",i, s_call_lists[i].call_id);
|
| 475 | //update_end_state(i);//lei modify for:update end state for this call
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 476 | tmp_call_id = s_call_lists[i].call_id;
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 477 | cleanCallList(i);
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 478 | //Release the end handle
|
| 479 | send_call_state_change(tmp_call_id);//means mt/mo call is end
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 480 | //cleanCallList(i);
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 481 | }
|
| 482 | } //fix bug API-54
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 483 | else
|
| 484 | {
|
| 485 | LYINFLOG("local id is 0");
|
| 486 | }
|
| 487 | }
|
| 488 | LYINFLOG("clear local index end, local used cnt is %d", cnt);
|
| 489 |
|
| 490 | LYINFLOG("add or update local index begin ");
|
| 491 | for (i = 0;i < LYNQ_CALL_MAX;i++)
|
| 492 | {
|
| 493 | if(call_list[i].call_id==0)
|
| 494 | {
|
| 495 | break;
|
| 496 | }
|
| 497 |
|
| 498 | LYINFLOG("servie idx %d begin: call_id=%d, call_state=%d, direction=%d, addr=%s, toa=%d",i,call_list[i].call_id, call_list[i].call_state,
|
| 499 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 500 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 501 | if(call_list[i].direction == 1)//MT call
|
| 502 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 503 | LYINFLOG("This is a MT CALL");
|
lh | 0fd3b01 | 2022-05-13 03:02:19 -0700 | [diff] [blame] | 504 | /*MT CALL state code
|
| 505 | **LYNQ_CALL_INCOMING = 4,
|
| 506 | **LYNQ_CALL_WAITING = 5,
|
| 507 | */
|
q.huang | e97cfcf | 2022-08-29 20:04:31 +0800 | [diff] [blame] | 508 | #ifdef ECALL_SUPPORT
|
lh | 0fd3b01 | 2022-05-13 03:02:19 -0700 | [diff] [blame] | 509 | if((call_list[i].call_state ==4) || (call_list[i].call_state ==5))
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 510 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 511 | handupIncomingMT=Is_handup_IncomingMT(call_list[i].call_id);
|
q.huang | e97cfcf | 2022-08-29 20:04:31 +0800 | [diff] [blame] | 512 | LYINFLOG("handupIncomingMT is %d",handupIncomingMT);
|
| 513 | if(handupIncomingMT)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 514 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 515 | lynq_call_hungup(&(call_list[i].call_id));
|
| 516 | continue;
|
q.huang | e97cfcf | 2022-08-29 20:04:31 +0800 | [diff] [blame] | 517 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 518 | }
|
q.huang | e97cfcf | 2022-08-29 20:04:31 +0800 | [diff] [blame] | 519 | #endif
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 520 | /*you call me, and i call you,One party failed to dial*/
|
| 521 | n = find_call_id_with_addr(call_list[i].addr);
|
| 522 | if(n ==INVALID_ID)
|
| 523 | {
|
q.huang | 305fadc | 2024-01-02 18:40:40 +0800 | [diff] [blame^] | 524 | if(s_call_auto_answer==false && call_list[i].call_state==LYNQ_CALL_INCOMING)
|
| 525 | {
|
| 526 | time(&now);
|
| 527 | interval = difftime(now,s_rev_ring_time);
|
| 528 | if(interval>MAX_RING_INCOMING_INTERVAL)
|
| 529 | {
|
| 530 | LYINFLOG("recv incoming, %d second no ril ring",interval);
|
| 531 | continue;
|
| 532 | }
|
| 533 | }
|
| 534 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 535 | n = addAddr(call_list[i].addr,call_list[i].call_id);
|
| 536 | updateCallList(&s_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 537 | send_call_state_change(call_list[i].call_id);
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 538 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 539 | else if(s_call_lists[n].call_state == call_list[i].call_state)
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 540 | {
|
| 541 | LYINFLOG("state not changed, state is %d ",call_list[i].call_state);
|
| 542 | if(call_list[i].call_state ==4 || call_list[i].call_state ==5)
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 543 | {
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 544 | /*if call state not change,Maybe this call was ignored, so we need to continue to inform the user of
|
| 545 | **an incoming call until the status changes.
|
| 546 | **fix bug API-54
|
| 547 | */
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 548 | LYINFLOG("resend incoming call signal");
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 549 | send_call_state_change(call_list[i].call_id);
|
lh | d1e457c | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 550 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 551 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 552 | else
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 553 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 554 | LYINFLOG("state changed from %d to %d",s_call_lists[n].call_state,call_list[i].call_state);
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 555 |
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 556 | updateCallList(&s_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);//update mt call
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 557 | send_call_state_change(call_list[i].call_id);
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 558 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 559 | }
|
| 560 | else
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 561 | {
|
| 562 | LYINFLOG("This is a MO CALL");
|
| 563 | call_end = 0;
|
| 564 | for(n = 0 ; n < LYNQ_CALL_MAX; n++)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 565 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 566 | if(s_call_lists[n].used && ((strcmp(call_list[i].addr,s_call_lists[n].addr)==0)||(call_list[i].call_id==s_call_lists[n].call_id)))
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 567 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 568 | if(s_call_lists[n].call_id==0)
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 569 | {
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 570 | LYINFLOG("add a call id");
|
| 571 | update=1;//for send sigal
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 572 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 573 | LYINFLOG("local idx %d updated, original call id is %d origial addr is %s original state is %d",n,s_call_lists[n].call_id,s_call_lists[n].addr,s_call_lists[n].call_state);
|
| 574 | updateCallList(&s_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 575 | call_end = 1;
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 576 | send_call_state_change(call_list[i].call_id);//means mo call is success
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 577 | break;
|
| 578 | }
|
| 579 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 580 | if(call_end == 0)//1.there is no space to use 2.can't find addr in buffer 3.call_id not equal eg:when call is error return 8004/handle <= 0 will into this
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 581 | {
|
| 582 | LYINFLOG("need to hangup id %d", call_list[i].call_id);
|
| 583 | #ifdef ECALL_SUPPORT
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 584 | if(IsECallDialing())
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 585 | {
|
| 586 | LYINFLOG("ecall is dialing, for the timebeing, don't huangup");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 587 | continue;
|
| 588 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 589 | #endif
|
| 590 | LYINFLOG("hang up service call id %d",call_list[i].call_id);
|
| 591 | lynq_call_hungup(&(call_list[i].call_id));
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 592 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 593 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 594 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 595 | LYDBGLOG("servie idx %d end",i);
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 596 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 597 | LYINFLOG("add or update local index end ");
|
| 598 | if(s_module_isDial==1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 599 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 600 | LYINFLOG("now is dialing");
|
| 601 | if(update==1)
|
| 602 | {
|
| 603 | LYINFLOG("find added call");
|
| 604 | sendSignalToWaitCallStateChange();
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 605 | s_module_isDial = 0;
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 606 | }
|
| 607 | else
|
| 608 | {
|
| 609 | LYINFLOG("not find added call");
|
| 610 | }
|
| 611 | }
|
| 612 | else
|
| 613 | {
|
| 614 | LYINFLOG("now is not dialing");
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 615 | }
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 616 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 617 | pthread_cleanup_pop(0);
|
| 618 | pthread_mutex_unlock(&s_notice_get_call_list_mutex);
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 619 | return NULL;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 620 | }
|
| 621 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 622 | void lynqNoticeGetModuleCallList()
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 623 | {
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 624 | LYINFLOG("RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED send start");
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 625 | pthread_mutex_lock(&s_notice_get_call_list_mutex);
|
| 626 | pthread_cond_signal(&s_notice_get_call_list_cond);
|
| 627 | pthread_mutex_unlock(&s_notice_get_call_list_mutex);
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 628 | LYINFLOG("RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED send end");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 629 | }
|
| 630 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 631 | #if 0
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 632 | /*Warren add for T800 platform 2021/11/19 start*/
|
| 633 | int lynq_socket_client_start()
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 634 | {
|
| 635 | #if 0
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 636 | struct sockaddr_in lynq_socket_server_addr;
|
| 637 | /* init lynq_socket_server_addr */
|
| 638 | bzero(&lynq_socket_server_addr, sizeof(lynq_socket_server_addr));
|
| 639 | lynq_socket_server_addr.sin_family = AF_INET;
|
| 640 | lynq_socket_server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
|
| 641 | lynq_socket_server_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 642 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 643 | /*
|
| 644 | if(inet_pton(AF_INET,"127.0.0.1", &lynq_socket_server_addr.sin_addr) <= 0)
|
| 645 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 646 | LYDBGLOG("[%s] is not a valid IPaddress", argv[1]);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 647 | exit(1);
|
| 648 | }
|
| 649 | */
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 650 | lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| 651 | if(connect(lynq_call_client_sockfd, (struct sockaddr *)&lynq_socket_server_addr, sizeof(lynq_socket_server_addr)) == -1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 652 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 653 | LYERRLOG("connect error");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 654 | return -1;
|
| 655 | }
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 656 | #endif
|
| 657 | lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| 658 | if (-1 == lynq_call_client_sockfd)
|
| 659 | {
|
| 660 | return lynq_call_client_sockfd;
|
| 661 | }
|
ll | 630be41 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 662 | struct timeval timeOut;
|
| 663 | timeOut.tv_sec = 60;
|
| 664 | timeOut.tv_usec = 0;
|
| 665 | if (setsockopt(lynq_call_client_sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeOut, sizeof(timeOut)) < 0)
|
| 666 | {
|
| 667 | RLOGD("time out setting failed\n");
|
| 668 | return -1;
|
| 669 | }
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 670 | /* 设置address */
|
| 671 | memset(&addr_serv, 0, sizeof(addr_serv));
|
| 672 | addr_serv.sin_family = AF_INET;
|
| 673 | addr_serv.sin_addr.s_addr = inet_addr(DSET_IP_ADDRESS);
|
| 674 | addr_serv.sin_port = htons(LYNQ_SERVICE_PORT);
|
| 675 | len_addr_serv = sizeof(addr_serv);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 676 | return 0;
|
| 677 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 678 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 679 | int lynq_socket_urc_start()
|
| 680 | {
|
| 681 | int socket_fd=0;
|
| 682 | int rt=0;
|
| 683 | int len=0;
|
| 684 | int on=1;
|
| 685 | struct sockaddr_in urc_local_addr;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 686 | pthread_attr_t attr;
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 687 | socket_fd = socket(AF_INET,SOCK_DGRAM,0);
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 688 | if(socket_fd < 0)
|
| 689 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 690 | LYERRLOG("creaet socket for udp fail");
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 691 | return -1;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 692 | }
|
| 693 | urc_local_addr.sin_family = AF_INET;
|
| 694 | urc_local_addr.sin_port = htons(LYNQ_URC_SERVICE_PORT);
|
| 695 | urc_local_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
| 696 | /* Set socket to allow reuse of address and port, SO_REUSEADDR value is 2*/
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 697 | rt = setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
|
| 698 | if(rt<0)
|
| 699 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 700 | LYERRLOG("SO_REUSEADDR fail");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 701 | return -1;
|
| 702 | }
|
| 703 | rt = bind(socket_fd ,(struct sockaddr*)&urc_local_addr, sizeof(urc_local_addr));
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 704 | if (rt == -1)
|
| 705 | {
|
lh | 21502f5 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 706 | LYERRLOG("bind failed");
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 707 | return -1;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 708 | }
|
| 709 | pthread_attr_init(&attr);
|
| 710 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 711 | rt = pthread_create(&lynq_call_urc_tid,&attr,thread_urc_recv,(void *)socket_fd);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 712 | if(rt < 0)
|
| 713 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 714 | LYERRLOG("urc loop failure!!!");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 715 | return -1;
|
| 716 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 717 | LYDBGLOG("urc loop success!!!");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 718 | return 0;
|
| 719 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 720 | #endif
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 721 |
|
| 722 | void lynq_call_state_change_test(int soc_id)
|
| 723 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 724 | LYDBGLOG("call state change,sim:%d",soc_id);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 725 | }
|
q.huang | cb7b729 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 726 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 727 | int lynq_start_call_list_loop()
|
| 728 | {
|
| 729 | #if 0
|
| 730 | int ret = 0;
|
| 731 | pthread_attr_t attr;
|
| 732 | pthread_attr_init(&attr);
|
| 733 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
q.huang | cb7b729 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 734 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 735 | s_notice_get_call_list_mutex = new pthread_mutex_t;
|
| 736 | pthread_mutex_init(s_notice_get_call_list_mutex, NULL);
|
| 737 | s_notice_get_call_list_cond = new pthread_cond_t;
|
| 738 | LYINFLOG("liulei s_notice_get_call_list_mutex\n");
|
| 739 | pthread_cond_init(s_notice_get_call_list_cond, NULL);
|
| 740 | LYINFLOG("liulei s_notice_get_call_list_cond\n");
|
| 741 | #endif
|
q.huang | cb7b729 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 742 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 743 | s_call_list_loop = 1;
|
| 744 | int ret = pthread_create(&s_call_list_loop_tid,/*&attr*/NULL,triggerGetCallList,NULL);
|
| 745 | if(ret < 0)
|
q.huang | cb7b729 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 746 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 747 | LYERRLOG("lynq_update_call_list_loop fail!!!");
|
ll | a8c25a8 | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 748 | return -1;
|
| 749 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 750 | LYINFLOG("lynq_update_call_list_loop success!!!");
|
q.huang | cb7b729 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 751 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 752 | memset(s_call_lists,0,sizeof(s_call_lists));
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 753 | return 0;
|
| 754 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 755 |
|
| 756 | int lynq_stop_call_list_loop()
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 757 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 758 | int ret;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 759 | pthread_mutex_lock(&s_notice_get_call_list_mutex);
|
| 760 | s_call_list_loop = 0;
|
| 761 | ret = pthread_cancel(s_call_list_loop_tid);
|
| 762 | LYINFLOG("pthread cancel w_c_list ret = %d",ret);
|
| 763 | pthread_mutex_unlock(&s_notice_get_call_list_mutex);
|
| 764 | ret = pthread_join(s_call_list_loop_tid,NULL);
|
| 765 | LYINFLOG("pthread join w_c_list ret = %d",ret);
|
| 766 | s_call_list_loop_tid=-1;
|
| 767 | #if 0
|
| 768 | pthread_mutex_destroy(s_notice_get_call_list_mutex);
|
| 769 | pthread_cond_destroy(s_notice_get_call_list_cond);
|
| 770 | delete s_notice_get_call_list_mutex;
|
| 771 | //s_notice_get_call_list_mutex = NULL;
|
| 772 | delete s_notice_get_call_list_cond;
|
| 773 | //s_notice_get_call_list_cond = NULL;
|
| 774 | #endif
|
| 775 |
|
| 776 | return 0;
|
rita | 98e2e9c | 2022-04-07 06:08:13 -0400 | [diff] [blame] | 777 | }
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 778 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 779 | int lynq_init_call(int utoken){
|
q.huang | f6a9ddc | 2023-12-08 20:23:56 +0800 | [diff] [blame] | 780 |
|
| 781 | LYLOGSET(LOG_INFO);
|
| 782 | LYLOGEINIT(USER_LOG_TAG);
|
| 783 | LYERRLOG("%s start, parameter is %d", __func__,utoken);
|
| 784 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 785 | if(g_module_init_flag != MODULE_CLOSED)
|
| 786 | {
|
| 787 | LYERRLOG("module state is %d",g_module_init_flag);
|
| 788 | return LYNQ_E_CONFLICT;
|
| 789 | }
|
| 790 | if(utoken <0){
|
| 791 | LYERRLOG("utoken is less than 0",utoken);
|
| 792 | return LYNQ_E_PARAMETER_ANONALY;
|
| 793 | }
|
| 794 | g_module_init_flag = MODULE_SWITCHING;
|
q.huang | f6a9ddc | 2023-12-08 20:23:56 +0800 | [diff] [blame] | 795 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 796 |
|
| 797 | g_module_Global_uToken = utoken;
|
| 798 |
|
q.huang | 036b6cf | 2023-01-10 14:29:20 +0800 | [diff] [blame] | 799 | int ret = lynq_start_all_urc_socket_thread();
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 800 | if(ret != RESULT_OK)
|
| 801 | {
|
| 802 | LYERRLOG("init socket urc fail!!!");
|
| 803 | g_module_init_flag = MODULE_CLOSED;
|
| 804 | return LYNQ_E_INNER_ERROR;
|
| 805 | }
|
| 806 |
|
q.huang | 036b6cf | 2023-01-10 14:29:20 +0800 | [diff] [blame] | 807 | ret = lynq_start_all_rc_socket_thread();
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 808 | if(ret !=RESULT_OK)
|
| 809 | {
|
| 810 | LYERRLOG("init socket client fail!!!");
|
q.huang | 036b6cf | 2023-01-10 14:29:20 +0800 | [diff] [blame] | 811 | lynq_close_all_urc_socket_thread();
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 812 | g_module_init_flag = MODULE_CLOSED;
|
| 813 | return LYNQ_E_INNER_ERROR;
|
| 814 | }
|
| 815 |
|
| 816 |
|
| 817 | int result = lynq_start_call_list_loop();
|
| 818 | if(ret != RESULT_OK)
|
| 819 | {
|
| 820 | LYERRLOG("lynq_start_call_list_loop fail!!!");
|
q.huang | 036b6cf | 2023-01-10 14:29:20 +0800 | [diff] [blame] | 821 | lynq_close_all_urc_socket_thread();
|
| 822 | lynq_close_all_rc_socket_thread();
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 823 | g_module_init_flag = MODULE_CLOSED;
|
| 824 | return LYNQ_E_INNER_ERROR;
|
| 825 | }
|
| 826 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 827 | g_module_init_flag = MODULE_RUNNING;
|
q.huang | f6a9ddc | 2023-12-08 20:23:56 +0800 | [diff] [blame] | 828 |
|
| 829 | LYERRLOG("%s end suc", __func__);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 830 | return 0;
|
| 831 | }
|
| 832 |
|
| 833 | int lynq_deinit_call(void){
|
q.huang | f6a9ddc | 2023-12-08 20:23:56 +0800 | [diff] [blame] | 834 | LYERRLOG("%s start", __func__);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 835 |
|
| 836 | if (g_module_init_flag != MODULE_RUNNING)
|
| 837 | {
|
| 838 | LYERRLOG("module state is %d",g_module_init_flag);
|
| 839 | return LYNQ_E_CONFLICT;
|
| 840 | }
|
| 841 | lynq_call_hungup_all();
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 842 | g_module_init_flag = MODULE_SWITCHING;
|
q.huang | 036b6cf | 2023-01-10 14:29:20 +0800 | [diff] [blame] | 843 | lynq_close_all_urc_socket_thread();
|
| 844 | lynq_close_all_rc_socket_thread();
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 845 | lynq_stop_call_list_loop();
|
| 846 | g_module_init_flag = MODULE_CLOSED;
|
q.huang | f6a9ddc | 2023-12-08 20:23:56 +0800 | [diff] [blame] | 847 |
|
| 848 | LYERRLOG("%s end suc", __func__);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 849 | return 0;
|
| 850 | }
|
| 851 |
|
| 852 | #if 0
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 853 | int lynq_set_common_request(int request_id, int argc, const char* format,...)
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 854 | {
|
| 855 | Parcel p;
|
| 856 | lynq_client_t client;
|
| 857 | int resp_type = -1;
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 858 | int token;
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 859 | int request = -1;
|
| 860 | int slot_id = -1;
|
| 861 | int error = -1;
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 862 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 863 | Parcel* p=NULL;
|
| 864 | int ret=lynq_send_common_request(request_id,5,p,argc,format,...);
|
| 865 | if(ret==RESULT_OK)
|
| 866 | {
|
| 867 | delete p;
|
| 868 | }
|
| 869 | return ret;
|
| 870 |
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 871 | client.uToken = Global_uToken_call;
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 872 | client.request = request_id;
|
| 873 | client.paramLen = argc;
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 874 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 875 | if(argc!=0)
|
| 876 | {
|
| 877 | va_list args;
|
| 878 | va_start(args, format);
|
| 879 | vsnprintf(client.param, LYNQ_REQUEST_PARAM_BUF, format, args);
|
| 880 | va_end(args);
|
| 881 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 882 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 883 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 884 | {
|
| 885 | LYERRLOG("send request fail");
|
| 886 | return -1;
|
| 887 | }
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 888 | if(get_response(lynq_call_client_sockfd,p)==0)
|
| 889 | {
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 890 | JumpHeader(p,&resp_type,&token,&request,&slot_id,&error);
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 891 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 892 | }
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 893 | return error;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 894 |
|
| 895 |
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 896 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 897 | #endif
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 898 |
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 899 | int lynq_get_common_request(int request_id, int* status)
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 900 | {
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 901 | if(status==NULL)
|
| 902 | {
|
| 903 | LYERRLOG("status is null");
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 904 | return LYNQ_E_PARAMETER_ANONALY;
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 905 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 906 |
|
| 907 | Parcel* p=NULL;
|
| 908 | int ret=lynq_send_common_request(p,g_wait_time,request_id,0,"");
|
| 909 | if(ret==RESULT_OK)
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 910 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 911 | p->readInt32(status);
|
| 912 | delete p;
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 913 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 914 | return ret;
|
| 915 | }
|
| 916 |
|
| 917 | int waitCallstateChange(int mtime)
|
| 918 | {
|
| 919 | LYINFLOG("wait Call state Change");
|
| 920 | int ret = 0;
|
| 921 | int sec = 0;
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 922 | int ms = 0;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 923 | struct timeval now;
|
| 924 | struct timespec timeout;
|
| 925 | gettimeofday(&now,NULL);
|
| 926 | sec = mtime/1000;
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 927 | ms = mtime%1000;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 928 | timeout.tv_sec = now.tv_sec+sec;
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 929 | unsigned long long ns;
|
| 930 | ns = now.tv_usec*1000ull + ms*1000000ull;
|
| 931 | timeout.tv_sec += ns/1000000000;
|
| 932 | timeout.tv_nsec = ns % 1000000000;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 933 | pthread_mutex_lock(&call_state_change_mutex);
|
| 934 | ret = pthread_cond_timedwait(&call_state_change_cond,&call_state_change_mutex,&timeout);
|
| 935 | pthread_mutex_unlock(&call_state_change_mutex);
|
| 936 | return ret;
|
| 937 | }
|
| 938 |
|
| 939 | int IsNormalCallDailing()
|
| 940 | {
|
| 941 | return s_module_isDial;
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 942 | }
|
| 943 |
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 944 |
|
lh | 3b6f7ea | 2023-11-08 01:16:42 -0800 | [diff] [blame] | 945 | int check_file_access(const char *fileName)
|
| 946 | {
|
| 947 | if(0 == access(fileName,F_OK))
|
| 948 | {
|
| 949 | LYINFLOG("find file %s success",fileName);
|
| 950 | return 0;
|
| 951 | }
|
| 952 | LYERRLOG("find file %s fail",fileName);
|
| 953 | return 1;
|
| 954 | }
|
| 955 | int try_reset_audio_service()
|
| 956 | {
|
| 957 | //check files:audio-ctrl-service,libmodem-afe-service,speech_daemon
|
| 958 | int ap_speech = 0;
|
| 959 | int audio_ctrl_ser = 0;
|
| 960 | int md_afe = 0;
|
| 961 | int tele_demo_lock = 0;
|
| 962 | LYINFLOG("try_reset_audio_service start");
|
| 963 | ap_speech = check_file_access(AP_SPEECH);
|
| 964 | audio_ctrl_ser = check_file_access(AUDIO_CTRL_SER);
|
| 965 | md_afe = check_file_access(LIBMODEM_AFE);
|
| 966 | tele_demo_lock = check_file_access(TELE_DEMO_LOCK);
|
| 967 | if((ap_speech + audio_ctrl_ser + md_afe) > 0)
|
| 968 | {
|
| 969 | system("systemctl stop audio-ctrl-service");
|
| 970 | system("systemctl stop speech_daemon");
|
| 971 | system("systemctl stop libmodem_afe_service");
|
| 972 | usleep(200000);//200ms
|
| 973 | system("rm /tmp/audio_ctrl_service -rf");
|
| 974 | system("rm /tmp/ap_speech -rf");
|
| 975 | system("rm /tmp/libmodem-afe-ctrl -rf");
|
| 976 | usleep(100000);//100ms
|
| 977 | system("systemctl start libmodem_afe_service");
|
| 978 | usleep(200000);//200ms
|
| 979 | system("systemctl start speech_daemon");
|
| 980 | usleep(200000);//200ms
|
| 981 | system("systemctl start audio-ctrl-service");
|
| 982 | sleep(1);//1s
|
| 983 | LYERRLOG("reset audio relation service");
|
| 984 | }
|
| 985 | if(tele_demo_lock)
|
| 986 | {
|
| 987 | LYERRLOG("%s lose,why?",TELE_DEMO_LOCK);
|
| 988 | }
|
| 989 | return 0;
|
| 990 | }
|
| 991 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 992 | int lynq_call(int* handle,char addr[])
|
| 993 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 994 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 995 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 996 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 997 | return LYNQ_E_CONFLICT;
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 998 | }
|
lh | 3b6f7ea | 2023-11-08 01:16:42 -0800 | [diff] [blame] | 999 | try_reset_audio_service();
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1000 | int lynq_call_id = -1;
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1001 |
|
| 1002 | LYINFLOG("lynq_call begin addr %s",addr);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1003 | if(addr==NULL)
|
| 1004 | {
|
| 1005 | LYERRLOG("Phone num is null!!!");
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1006 | return LYNQ_E_PARAMETER_ANONALY;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1007 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1008 |
|
| 1009 | if(find_call_id_with_addr(addr)!=INVALID_ID)
|
| 1010 | {
|
| 1011 | LYERRLOG("addr %s exists",addr);
|
| 1012 | return LYNQ_E_CONFLICT;
|
| 1013 | }
|
| 1014 |
|
| 1015 | #ifdef ECALL_SUPPORT
|
| 1016 | if(lynq_ecall_is_running())
|
| 1017 | {
|
| 1018 | LYERRLOG("lynq_fast_ecall ecall is running");
|
| 1019 | return LYNQ_E_ECALL_BEING_RUNNING;
|
| 1020 | }
|
| 1021 | #endif
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1022 | Parcel* p=NULL;
|
| 1023 | lynq_call_id = addAddr(addr,0);
|
| 1024 | int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_DIAL,2,"%s %d",addr, 0);
|
| 1025 | if(ret!=0)
|
| 1026 | {
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1027 | cleanCallList(lynq_call_id);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1028 | return ret;
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1029 | }
|
| 1030 | delete p;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1031 | s_module_isDial = 1;
|
| 1032 | if(waitCallstateChange(6000)==ETIMEDOUT)//6000ms
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1033 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1034 | //if timeout,this call need destroy.
|
| 1035 | s_module_isDial = 0;
|
| 1036 | LYERRLOG("lynq_call timeout:wait Call state fail!!! clear local idx %d",lynq_call_id);
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1037 | cleanCallList(lynq_call_id);
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 1038 | send_call_state_change(lynq_call_id);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1039 | return LYNQ_E_TIME_OUT;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1040 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1041 | s_module_isDial = 0;
|
| 1042 | *handle = s_call_lists[lynq_call_id].call_id;
|
| 1043 | if(*handle > 0)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1044 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1045 | LYINFLOG("lynq_call dial addr %s suc, id is %d",addr,*handle);
|
| 1046 | return RESULT_OK;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1047 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1048 | else
|
| 1049 | {
|
| 1050 | LYERRLOG("lynq_call dial addr %s fail, invalid id",addr);
|
ll | e3b9a23 | 2023-01-14 13:21:20 +0800 | [diff] [blame] | 1051 | cleanCallList(lynq_call_id);
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 1052 | send_call_state_change(lynq_call_id);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1053 | return LYNQ_E_INVALID_ID_ANONALY;
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1054 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1055 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1056 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1057 | int lynq_call_answer()
|
| 1058 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1059 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1060 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1061 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1062 | return LYNQ_E_CONFLICT;
|
| 1063 | }
|
| 1064 |
|
| 1065 | Parcel* p=NULL;
|
| 1066 | int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ANSWER,0,"");
|
| 1067 | if(ret==RESULT_OK)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1068 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1069 | delete p;
|
| 1070 | }
|
| 1071 | return ret;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1072 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1073 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1074 | int lynq_call_hungup(int* handle)
|
| 1075 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1076 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1077 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1078 | return LYNQ_E_CONFLICT;
|
| 1079 | }
|
| 1080 |
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1081 | if(handle==NULL||!((*handle>=0)&&(*handle<10)))
|
| 1082 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1083 | LYERRLOG("%s illegal input!!!!",__func__);
|
| 1084 | return LYNQ_E_PARAMETER_ANONALY;
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1085 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1086 |
|
| 1087 | int call_id = *handle;
|
| 1088 | Parcel* p=NULL;
|
| 1089 | int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_HANGUP,1,"%d",call_id);
|
| 1090 | if(ret!=0)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1091 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1092 | return ret;
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 1093 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1094 | delete p;
|
| 1095 |
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 1096 | int lynq_call_id=find_call_id_with_call_id(call_id);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1097 | if(lynq_call_id!=INVALID_ID)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1098 | {
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 1099 | //lei modify for API-857
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1100 | cleanCallList(lynq_call_id);
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 1101 | send_call_state_change(call_id);
|
| 1102 | }
|
| 1103 | return RESULT_OK;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1104 | }
|
| 1105 | int lynq_call_hungup_all()
|
| 1106 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1107 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1108 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1109 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1110 | return LYNQ_E_CONFLICT;
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1111 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1112 |
|
| 1113 | Parcel* p=NULL;
|
| 1114 | int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_UDUB,0,"");
|
| 1115 | if(ret==RESULT_OK)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1116 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1117 | delete p;
|
| 1118 | }
|
| 1119 | return ret;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1120 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1121 |
|
| 1122 | int lynq_wait_call_state_change(int *handle)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1123 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1124 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1125 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1126 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1127 | return LYNQ_E_CONFLICT;
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1128 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1129 | wait_call_state();
|
| 1130 | *handle = s_CallId;
|
| 1131 | LYINFLOG("lynq mo/mt call id:%d",s_CallId);
|
| 1132 | return RESULT_OK;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1133 | }
|
| 1134 |
|
| 1135 | int lynq_set_auto_answercall(const int mode)
|
| 1136 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1137 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1138 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1139 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1140 | return LYNQ_E_CONFLICT;
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1141 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1142 | s_call_auto_answer = mode;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1143 | LYINFLOG("auto answer call mode =%d",mode);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1144 | return RESULT_OK;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1145 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1146 |
|
| 1147 | int lynq_find_already_end()
|
| 1148 | {
|
| 1149 | for(int i=0;i < LYNQ_CALL_MAX; i++)
|
| 1150 | {
|
| 1151 | if(s_call_lists[i].call_state == 6)
|
| 1152 | {
|
| 1153 | return 0;
|
| 1154 | }
|
| 1155 | }
|
| 1156 | return INVALID_ID;
|
| 1157 | }
|
| 1158 |
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1159 | int lynq_get_current_call_state(int *handle, int *call_state,int *toa,int *direction,char addr[])
|
| 1160 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1161 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1162 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1163 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1164 | return LYNQ_E_CONFLICT;
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1165 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1166 | int lynq_call_id = 0;
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1167 | LYINFLOG("lynq_get_current_call_state begin ");
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1168 | if(handle==NULL)
|
| 1169 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1170 | LYERRLOG("handle is NULL");
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1171 | return LYNQ_E_PARAMETER_ANONALY;
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1172 | }
|
you.chen | 79d8f93 | 2023-12-26 17:03:44 +0800 | [diff] [blame] | 1173 | if((*handle) <= 0)
|
| 1174 | {
|
| 1175 | LYINFLOG("lynq_get_current_call_state input error %d\n ", *handle);
|
| 1176 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1177 | }
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1178 | LYINFLOG("lynq_get_current_call_state %d\n ", *handle);
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1179 | lynq_call_id = find_call_id_with_call_id(*handle);
|
| 1180 | if(lynq_call_id==INVALID_ID)
|
| 1181 | {
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1182 | //find end state
|
| 1183 | if((*handle) >= 0)
|
| 1184 | {
|
| 1185 | *call_state = (int)LYNQ_CALL_END;
|
| 1186 | return RESULT_OK;
|
| 1187 | }
|
| 1188 | else
|
| 1189 | {
|
| 1190 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1191 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1192 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1193 | *call_state = s_call_lists[lynq_call_id].call_state;
|
| 1194 | *toa = s_call_lists[lynq_call_id].toa;
|
| 1195 | *direction = s_call_lists[lynq_call_id].direction;
|
| 1196 | memcpy(addr,s_call_lists[lynq_call_id].addr,strlen(s_call_lists[lynq_call_id].addr)+1);
|
ll | b392107 | 2023-01-10 14:47:46 +0800 | [diff] [blame] | 1197 | return RESULT_OK;
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1198 | }
|
| 1199 |
|
q.huang | e97cfcf | 2022-08-29 20:04:31 +0800 | [diff] [blame] | 1200 | int lynq_get_current_call_number()
|
| 1201 | {
|
| 1202 | int cnt=0;
|
| 1203 | int i;
|
| 1204 | for(i = 0;i < LYNQ_CALL_MAX;i++)
|
| 1205 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1206 | if(s_call_lists[i].used !=0)
|
q.huang | e97cfcf | 2022-08-29 20:04:31 +0800 | [diff] [blame] | 1207 | {
|
| 1208 | cnt++;
|
| 1209 | }
|
| 1210 | }
|
| 1211 |
|
| 1212 | return cnt;
|
| 1213 | }
|
| 1214 |
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1215 | /*audio begin*/
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1216 | static int judge_mic(const int enable){
|
ll | f512fa3 | 2022-02-14 08:58:16 +0000 | [diff] [blame] | 1217 | switch(enable){
|
| 1218 | case 0:
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1219 | return true;
|
ll | f512fa3 | 2022-02-14 08:58:16 +0000 | [diff] [blame] | 1220 | case 1:
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1221 | return true;
|
ll | f512fa3 | 2022-02-14 08:58:16 +0000 | [diff] [blame] | 1222 | default:
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1223 | return false;
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1224 | }
|
| 1225 | }
|
| 1226 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1227 | int lynq_set_mute_mic(const int enable)
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1228 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1229 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1230 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1231 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1232 | return LYNQ_E_CONFLICT;
|
| 1233 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1234 | if(!judge_mic(enable)){
|
| 1235 | return LYNQ_E_PARAMETER_ANONALY;
|
| 1236 | }
|
| 1237 | // return lynq_set_common_request(53,1,"%d",enable); //RIL_REQUEST_SET_MUTE
|
| 1238 |
|
| 1239 | Parcel* p=NULL;
|
| 1240 | int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SET_MUTE,1,"%d",enable);
|
| 1241 | if(ret==RESULT_OK)
|
| 1242 | {
|
| 1243 | delete p;
|
| 1244 | }
|
| 1245 | return ret;
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1246 | }
|
| 1247 | int lynq_get_mute_mic(int *status)
|
| 1248 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1249 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1250 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1251 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1252 | return LYNQ_E_CONFLICT;
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1253 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1254 | return lynq_get_common_request(RIL_REQUEST_GET_MUTE,status);//54
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1255 | }
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1256 |
|
| 1257 | /**
|
| 1258 | * @brief Check whether DTMF is valid
|
| 1259 | *
|
| 1260 | * @param callnum dtmf eg:0-9 * #
|
| 1261 | * @return int
|
| 1262 | */
|
| 1263 | static int judge_dtmf(const char callnum)
|
| 1264 | {
|
| 1265 | if(callnum == '#')
|
| 1266 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1267 | return true;
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1268 | }
|
| 1269 | if(callnum == '*')
|
| 1270 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1271 | return true;
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1272 | }
|
| 1273 | if(callnum >= '0'&& callnum <= '9')
|
| 1274 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1275 | return true;
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1276 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1277 | return false;
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1278 | }
|
| 1279 |
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1280 | int lynq_switch_waiting_or_holding_and_active(void)
|
| 1281 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1282 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1283 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1284 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1285 | return LYNQ_E_CONFLICT;
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1286 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1287 |
|
| 1288 | Parcel* p=NULL;
|
| 1289 | int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE,0,"");
|
| 1290 | if(ret==RESULT_OK)
|
| 1291 | {
|
| 1292 | delete p;
|
| 1293 | }
|
| 1294 | return ret;
|
| 1295 |
|
| 1296 | #if 0
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1297 | Parcel p;
|
| 1298 | lynq_client_t client;
|
| 1299 | int resp_type = -1;
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 1300 | int token;
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1301 | int request = -1;
|
| 1302 | int slot_id = -1;
|
| 1303 | int error = -1;
|
| 1304 | client.uToken = Global_uToken_call;
|
| 1305 | client.request = RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE;
|
| 1306 | client.paramLen = 0;
|
| 1307 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1308 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
ll | 630be41 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1309 | pthread_mutex_lock(&g_lynq_call_sendto_mutex);
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1310 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1311 | {
|
| 1312 | LYERRLOG("send request fail");
|
| 1313 | return -1;
|
| 1314 | }
|
| 1315 | get_response(lynq_call_client_sockfd,p);
|
ll | 630be41 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1316 | pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 1317 | JumpHeader(p,&resp_type,&token,&request,&slot_id,&error);
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1318 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1319 | return error;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1320 | #endif
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1321 | }
|
| 1322 |
|
| 1323 | int lynq_hangup_waiting_or_background(void)
|
| 1324 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1325 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1326 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1327 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1328 | return LYNQ_E_CONFLICT;
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1329 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1330 |
|
| 1331 | Parcel* p=NULL;
|
| 1332 | int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND,0,"");
|
| 1333 | if(ret==RESULT_OK)
|
| 1334 | {
|
| 1335 | delete p;
|
| 1336 | }
|
| 1337 | return ret;
|
| 1338 | #if 0
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1339 | Parcel p;
|
| 1340 | lynq_client_t client;
|
| 1341 | int resp_type = -1;
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 1342 | int token;
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1343 | int request = -1;
|
| 1344 | int slot_id = -1;
|
| 1345 | int error = -1;
|
| 1346 | client.uToken = Global_uToken_call;
|
| 1347 | client.request = RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND;
|
| 1348 | client.paramLen = 0;
|
| 1349 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1350 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
ll | 630be41 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1351 | pthread_mutex_lock(&g_lynq_call_sendto_mutex);
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1352 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1353 | {
|
| 1354 | LYERRLOG("send request fail");
|
| 1355 | return -1;
|
| 1356 | }
|
| 1357 | get_response(lynq_call_client_sockfd,p);
|
ll | 630be41 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1358 | pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 1359 | JumpHeader(p,&resp_type,&token,&request,&slot_id,&error);
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1360 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1361 | return error;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1362 | #endif
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1363 | }
|
| 1364 |
|
| 1365 | int lynq_hangup_foreground_resume_background(void)
|
| 1366 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1367 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1368 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1369 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1370 | return LYNQ_E_CONFLICT;
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1371 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1372 |
|
| 1373 | Parcel* p=NULL;
|
| 1374 | int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND,0,"");
|
| 1375 | if(ret==RESULT_OK)
|
| 1376 | {
|
| 1377 | delete p;
|
| 1378 | }
|
| 1379 | return ret;
|
| 1380 | #if 0
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1381 | Parcel p;
|
| 1382 | lynq_client_t client;
|
| 1383 | int resp_type = -1;
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 1384 | int token;
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1385 | int request = -1;
|
| 1386 | int slot_id = -1;
|
| 1387 | int error = -1;
|
| 1388 | client.uToken = Global_uToken_call;
|
| 1389 | client.request = RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND;
|
| 1390 | client.paramLen = 0;
|
| 1391 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1392 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
ll | 630be41 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1393 | pthread_mutex_lock(&g_lynq_call_sendto_mutex);
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1394 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1395 | {
|
| 1396 | LYERRLOG("send request fail");
|
| 1397 | return -1;
|
| 1398 | }
|
| 1399 | get_response(lynq_call_client_sockfd,p);
|
ll | 630be41 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1400 | pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
|
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 1401 | JumpHeader(p,&resp_type,&token,&request,&slot_id,&error);
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1402 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1403 | return error;
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1404 | #endif
|
ll | 209e611 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1405 | }
|
| 1406 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1407 | int lynq_set_DTMF(const char callnum)
|
| 1408 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1409 | if(g_module_init_flag != MODULE_RUNNING)
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1410 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1411 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1412 | return LYNQ_E_CONFLICT;
|
ll | 27dbe75 | 2022-08-10 00:33:52 -0700 | [diff] [blame] | 1413 | }
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1414 | if(!judge_dtmf(callnum))
|
| 1415 | {
|
| 1416 | return LYNQ_E_CONFLICT;
|
| 1417 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1418 | if(s_module_call_state!=CALL_ON)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1419 | {
|
| 1420 | LYERRLOG("LYNQ_E_CONFLICT");
|
| 1421 | return LYNQ_E_CONFLICT;
|
| 1422 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1423 |
|
| 1424 | // return lynq_set_common_request(24,1,"%c",callnum); //RIL_REQUEST_DTMF
|
| 1425 |
|
| 1426 | Parcel* p=NULL;
|
| 1427 | int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_DTMF,1,"%c",callnum);
|
| 1428 | if(ret==RESULT_OK)
|
| 1429 | {
|
| 1430 | delete p;
|
| 1431 | }
|
| 1432 | return ret;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1433 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1434 | static int judge_volume(LYNQ_E_VOLUMN_SET set,const int volume){
|
| 1435 | if(set==LYNQ_E_VOLUMN_SET_DTMF){
|
| 1436 | if(volume < 0 ||volume >36){
|
| 1437 | return 0;
|
| 1438 | }
|
| 1439 | }
|
| 1440 | else if (set==LYNQ_E_VOLUMN_SET_SPEECH)
|
| 1441 | {
|
| 1442 | if(volume < 1 ||volume >7){
|
| 1443 | return 0;
|
| 1444 | }
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1445 | }
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 1446 | return 1;
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1447 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1448 | int lynq_set_DTMF_volume(const int volume)
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1449 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1450 | if(g_module_init_flag != MODULE_RUNNING)
|
| 1451 | {
|
| 1452 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1453 | return LYNQ_E_CONFLICT;
|
| 1454 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1455 | if(!judge_volume(LYNQ_E_VOLUMN_SET_DTMF,volume)){
|
| 1456 | return LYNQ_E_PARAMETER_ANONALY;
|
| 1457 | }
|
| 1458 | // return lynq_set_common_request(8003,1,"%d",volume);//LYNQ_REQUEST_SET_DTMF_VOLUME
|
| 1459 | Parcel* p=NULL;
|
| 1460 | int ret=lynq_send_common_request(p,g_wait_time,LYNQ_REQUEST_SET_DTMF_VOLUME,1,"%d",volume);
|
| 1461 | if(ret==RESULT_OK)
|
| 1462 | {
|
| 1463 | delete p;
|
| 1464 | }
|
| 1465 | return ret;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1466 | }
|
q.huang | b212fde | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1467 | int lynq_set_speech_volume(const int volume)//mixer_set_volume
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1468 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1469 | if(g_module_init_flag != MODULE_RUNNING)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1470 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1471 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1472 | return LYNQ_E_CONFLICT;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1473 | }
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1474 | if(!judge_volume(LYNQ_E_VOLUMN_SET_SPEECH,volume))
|
| 1475 | {
|
| 1476 | return LYNQ_E_PARAMETER_ANONALY;
|
| 1477 | }
|
| 1478 | // return lynq_set_common_request(8009,1,"%d",volume); //LYNQ_REQUEST_SET_SPEECH_VOLUME
|
| 1479 | Parcel* p=NULL;
|
| 1480 | int ret=lynq_send_common_request(p,g_wait_time,LYNQ_REQUEST_SET_SPEECH_VOLUME,1,"%d",volume);
|
| 1481 | if(ret==RESULT_OK)
|
| 1482 | {
|
| 1483 | delete p;
|
| 1484 | }
|
| 1485 | return ret;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1486 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1487 | int lynq_get_speech_volume(int* volumn)//mixer_get_volume
|
| 1488 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1489 | return lynq_get_common_request(LYNQ_REQUEST_GET_SPEECH_VOLUME,volumn);//8010
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1490 | }
|
q.huang | b212fde | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1491 | int lynq_incall_record_start(const char* file_path)
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1492 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1493 | // return lynq_set_common_request(8011,2,"%s %s","1",file_path); //LYNQ_REQUEST_RECORD
|
| 1494 | Parcel* p=NULL;
|
| 1495 | int ret=lynq_send_common_request(p,g_wait_time,LYNQ_REQUEST_RECORD,2,"%s %s","1",file_path);
|
| 1496 | if(ret==RESULT_OK)
|
| 1497 | {
|
| 1498 | delete p;
|
| 1499 | }
|
| 1500 | return ret;
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1501 | }
|
| 1502 | int lynq_incall_record_stop()
|
| 1503 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1504 | if(g_module_init_flag != MODULE_RUNNING)
|
| 1505 | {
|
| 1506 | LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
|
| 1507 | return LYNQ_E_CONFLICT;
|
| 1508 | }
|
q.huang | b212fde | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1509 | const char* unused_file="just_ocuupy_paramter_postion";
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1510 | // return lynq_set_common_request(8011,2,"%s %s","0",unused_file); //LYNQ_REQUEST_RECORD
|
| 1511 | Parcel* p=NULL;
|
| 1512 | int ret=lynq_send_common_request(p,g_wait_time,LYNQ_REQUEST_RECORD,2,"%s %s","0",unused_file);
|
| 1513 | if(ret==RESULT_OK)
|
| 1514 | {
|
| 1515 | delete p;
|
| 1516 | }
|
| 1517 | return ret;
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1518 | }
|
| 1519 | /*audio end*/
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1520 |
|
q.huang | 036b6cf | 2023-01-10 14:29:20 +0800 | [diff] [blame] | 1521 |
|
| 1522 |
|
| 1523 | bool is_support_urc(int urc_id)
|
| 1524 | {
|
| 1525 | switch(urc_id)
|
| 1526 | {
|
| 1527 | case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
|
| 1528 | case RIL_UNSOL_CALL_RING:
|
| 1529 | case RIL_UNSOL_RINGBACK_TONE:
|
| 1530 | case RIL_UNSOL_CALL_INFO_INDICATION:
|
| 1531 | #ifdef ECALL_SUPPORT
|
| 1532 | case RIL_UNSOL_ECALL_INDICATIONS://9502
|
| 1533 | #endif
|
| 1534 | return true;
|
| 1535 | default:
|
| 1536 | return false;
|
| 1537 | }
|
| 1538 | }
|
| 1539 |
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1540 | void urc_msg_process(Parcel *p)
|
| 1541 | {
|
| 1542 | int resp_type;
|
| 1543 | int urcid;
|
| 1544 | int slot_id;
|
q.huang | 036b6cf | 2023-01-10 14:29:20 +0800 | [diff] [blame] | 1545 |
|
| 1546 | int size=p->dataSize();
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1547 | p->readInt32(&resp_type);
|
| 1548 | p->readInt32(&urcid);
|
| 1549 | p->readInt32(&slot_id);
|
q.huang | 036b6cf | 2023-01-10 14:29:20 +0800 | [diff] [blame] | 1550 | LYINFLOG("%s urc id = %d, slot_id = %d, size is %d, msg is %s",__func__, urcid,slot_id,size,requestToString(urcid));
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1551 | switch (urcid)
|
| 1552 | {
|
| 1553 | case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED://1001
|
| 1554 | {
|
| 1555 | LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
| 1556 | lynqNoticeGetModuleCallList();
|
| 1557 | break;
|
| 1558 | }
|
| 1559 | case RIL_UNSOL_CALL_RING: //1018
|
| 1560 | {
|
q.huang | 305fadc | 2024-01-02 18:40:40 +0800 | [diff] [blame^] | 1561 | time(&s_rev_ring_time);
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1562 | if(s_call_auto_answer==1)
|
| 1563 | {
|
| 1564 | lynq_call_answer();
|
| 1565 | }
|
| 1566 | break;
|
| 1567 | }
|
| 1568 | case RIL_UNSOL_RINGBACK_TONE: //1029
|
| 1569 | case RIL_UNSOL_CALL_INFO_INDICATION://3049
|
| 1570 | {
|
| 1571 | LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
| 1572 | break;
|
| 1573 | }
|
q.huang | 714145d | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1574 | #ifdef ECALL_SUPPORT
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1575 | case RIL_UNSOL_ECALL_INDICATIONS://9502
|
q.huang | e97cfcf | 2022-08-29 20:04:31 +0800 | [diff] [blame] | 1576 | {
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1577 | urc_ecall_msg_process(p);
|
q.huang | e97cfcf | 2022-08-29 20:04:31 +0800 | [diff] [blame] | 1578 | }
|
q.huang | e97cfcf | 2022-08-29 20:04:31 +0800 | [diff] [blame] | 1579 | #endif
|
q.huang | 5292166 | 2022-10-20 15:25:45 +0800 | [diff] [blame] | 1580 | default:
|
| 1581 | break;
|
q.huang | cb7b729 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1582 | }
|
q.huang | 5ca6c07 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1583 | }
|
q.huang | 5ca6c07 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1584 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1585 | #if 0
|
| 1586 | int main(int argc,char **argv)
|
| 1587 | {
|
| 1588 | int n = 0;
|
| 1589 | n = lynq_init_call(lynq_call_state_change_test,2222);
|
| 1590 | if(n<0)
|
| 1591 | {
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1592 | LYDBGLOG("lynq init call fail!!!");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1593 | return -1;
|
| 1594 | }
|
q.huang | 70b7649 | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1595 | LYDBGLOG("lynq call init success!!!");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1596 | char phoneNum[LYNQ_PHONE_NUMBER_MAX];
|
| 1597 | sprintf(phoneNum,"18180053406 0",strlen("18180053406 0")+1);
|
| 1598 | lynq_call(phoneNum);
|
| 1599 | while(1)
|
| 1600 | {
|
| 1601 | sleep(1);
|
| 1602 | }
|
| 1603 | return 0;
|
| 1604 | }
|
| 1605 | #endif
|
| 1606 | /*Warren add for T800 platform 2021/11/19 end*/
|