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