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