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