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