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