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