lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1 | #include <stdio.h>
|
| 2 | #include <sys/types.h>
|
| 3 | #include <sys/socket.h>
|
| 4 | #include <arpa/inet.h>
|
| 5 | #include <fcntl.h>
|
| 6 | #include <string.h>
|
| 7 | #include <stdlib.h>
|
| 8 | #include <unistd.h>
|
| 9 | #include <binder/Parcel.h>
|
| 10 | #include <log/log.h>
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 11 | #include <cutils/jstring.h>
|
| 12 | #include <pthread.h>
|
| 13 | #include "liblog/lynq_deflog.h"
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 14 | #include <sys/time.h>
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 15 | #include <string.h>
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 16 | #include <vendor-ril/telephony/ril.h>
|
| 17 | #include <vendor-ril/telephony/mtk_ril_sp.h>
|
| 18 | #include <vendor-ril/telephony/mtk_ril_ivt.h>
|
| 19 | #include "lynq_call.h"
|
| 20 |
|
| 21 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 22 | #define LYNQ_SERVICE_PORT 8088
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 23 | #define DSET_IP_ADDRESS "127.0.0.1"
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 24 | #define LYNQ_URC_SERVICE_PORT 8086
|
| 25 | #define LYNQ_REC_BUF 8192
|
| 26 | #define LYNQ_REQUEST_PARAM_BUF 8192
|
| 27 | #define LYQN_SEDN_BUF 1024*8+sizeof(int)*3
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 28 | #define INVALID_ID (-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 29 | #define USER_LOG_TAG "LYNQ_CALL"
|
| 30 |
|
| 31 | using ::android::Parcel;
|
| 32 | typedef enum {
|
| 33 | LYNQ_CALL_ACTIVE = 0,
|
| 34 | LYNQ_CALL_HOLDING = 1,
|
| 35 | LYNQ_CALL_DIALING = 2, /* MO call only */
|
| 36 | LYNQ_CALL_ALERTING = 3, /* MO call only */
|
| 37 | LYNQ_CALL_INCOMING = 4, /* MT call only */
|
lh | 8657e74 | 2022-04-26 00:45:44 -0700 | [diff] [blame] | 38 | LYNQ_CALL_WAITING = 5, /* MT call only */
|
| 39 | /*warren add for T800 platform 2022/04/26 start*/
|
| 40 | LYNQ_CALL_END = 6, /*CALL END*/
|
| 41 | /*warren add for T800 platform 2022/04/26 end*/
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 42 | }lynq_call_state_t;
|
| 43 |
|
| 44 | typedef struct{
|
| 45 | int uToken;
|
| 46 | int request;
|
| 47 | int paramLen;
|
| 48 | char param[LYNQ_REQUEST_PARAM_BUF];
|
| 49 | }lynq_client_t;
|
| 50 | typedef struct
|
| 51 | {
|
| 52 | int used;
|
| 53 | int call_id;
|
| 54 | int call_state;
|
| 55 | int toa;
|
| 56 | int direction;/*0: MO call,1:MT call*/
|
| 57 | char addr[LYNQ_PHONE_NUMBER_MAX];
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 58 | }lynq_call_list_e_t;
|
| 59 | typedef struct
|
| 60 | {
|
| 61 | int call_id;
|
| 62 | int call_state;
|
| 63 | int toa;
|
| 64 | int direction;/*0: MO call,1:MT call*/
|
| 65 | char addr[LYNQ_PHONE_NUMBER_MAX];
|
| 66 | }lynq_call_list_t;
|
| 67 |
|
| 68 | lynq_call_list_e_t lynq_call_lists[LYNQ_CALL_MAX]={};
|
| 69 | static pthread_mutex_t call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 70 | static pthread_cond_t call_state_change_cond = PTHREAD_COND_INITIALIZER;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 71 | static pthread_mutex_t s_urc_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 72 | static pthread_cond_t s_urc_call_state_change_cond = PTHREAD_COND_INITIALIZER;
|
| 73 | static pthread_mutex_t s_incoming_call_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 74 | static pthread_cond_t s_incoming_call_cond = PTHREAD_COND_INITIALIZER;
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 75 | pthread_t lynq_call_urc_tid = -1;
|
| 76 | pthread_t lynq_call_list_loop_tid = -1;
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 77 |
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 78 | /*lei add*/
|
| 79 | /* socket文件描述符 */
|
| 80 | int len_addr_serv;
|
| 81 | struct sockaddr_in addr_serv;
|
| 82 | lynq_client_t client_t;
|
| 83 | int client_size = 0;
|
| 84 | /*lei add*/
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 85 |
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 86 | int s_call_urc_event_complete = 1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 87 |
|
| 88 | enum{
|
| 89 | CALL_OFF=0,
|
| 90 | CALL_ON=1
|
| 91 | }call_state;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 92 | typedef enum{
|
| 93 | LYNQ_E_CARDSTATE_ERROR=8000,
|
| 94 | /* The voice service state is out of service*/
|
| 95 | LYNQ_E_STATE_OUT_OF_SERVICE=8001,
|
| 96 | /* The voice service state is EMERGENCY_ONLY*/
|
| 97 | LYNQ_E_STATE_EMERGENCY_ONLY=8002,
|
| 98 | /* The radio power is power off*/
|
| 99 | LYNQ_E_STATE_POWER_OFF=8003,
|
| 100 | LYNQ_E_TIME_OUT=8004,
|
| 101 | /*create or open sms DB fail */
|
| 102 | LYNQ_E_SMS_DB_FAIL=8005,
|
| 103 | /*Failed to execute sql statement*/
|
| 104 | LYNQ_E_SMS_SQL_FAIL = 8006,
|
| 105 | LYNQ_E_SMS_NOT_FIND = 8007,
|
| 106 | /* The logic conflict*/
|
| 107 | LYNQ_E_CONFLICT=9000,
|
| 108 | /*Null anomaly*/
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 109 | LYNQ_E_NULL_ANONALY=9001,
|
| 110 | /*Invalid id anomaly*/
|
| 111 | LYNQ_E_INVALID_ID_ANONALY=9002,
|
| 112 | #ifdef ECALL_SUPPORT
|
| 113 | LYNQ_E_ECALL_BEING_RUNNING =9003,
|
| 114 | LYNQ_E_ECALL_MSD_LENGTH_ERROR =9004,
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 115 | LYNQ_E_ECALL_DAILING_NO_ANSWER =9005,
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 116 | #endif
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 117 | }LYNQ_E;
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 118 | typedef enum{
|
| 119 | LYNQ_E_VOLUMN_SET_DTMF,
|
| 120 | LYNQ_E_VOLUMN_SET_SPEECH
|
| 121 | }LYNQ_E_VOLUMN_SET;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 122 |
|
| 123 | int lynq_call_state =CALL_OFF;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 124 | int lynq_call_client_sockfd = 0;
|
| 125 | int Global_uToken_call = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 126 | int global_call_count =0;
|
| 127 | int global_call_auto_answer = 0;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 128 | bool urc_call_recive_status = 1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 129 | bool call_list_loop = 1;
|
| 130 | int isDial = 0;
|
| 131 | int lynqIncomingCallId = 0;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 132 |
|
| 133 | #ifdef ECALL_SUPPORT
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 134 | int lynq_set_common_request(int request_id, int argc, const char* format,...);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 135 | int g_ecallId = INVALID_ID;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 136 | typedef enum{
|
| 137 | LYNQ_ECALL_TYPE_TEST = 0, /* Test eCall */
|
| 138 | LYNQ_ECALL_TYPE_RECONFIG = 1, /* Reconfiguration eCall */
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 139 | LYNQ_ECALL_MANUAL_EMERGENCY = 2, /*Manual Emergency eCall */
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 140 | LYNQ_ECALL_TYPE_AUTO_EMERGENCY = 3, /* Automatic Emergency eCall */
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 141 | }LYNQ_ECall_Type;
|
| 142 |
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 143 | typedef enum{
|
| 144 | LYNQ_ECALL_DAILING_STATE_NONE =0,
|
| 145 | LYNQ_ECALL_DAILING_STATE_STARTED = 1,
|
| 146 | LYNQ_ECALL_DAILING_STATE_ANSWERED = 2,
|
| 147 | }LYNQ_ECall_Dailing_State;
|
| 148 |
|
| 149 | LYNQ_ECall_Dailing_State is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 150 | char e_call_addr[LYNQ_ECALL_VAR_MAX][LYNQ_PHONE_NUMBER_MAX]={"test_ecall","emergency_ecall","reconf_ecall"};
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 151 |
|
| 152 | static pthread_mutex_t s_incoming_e_call_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 153 | static pthread_cond_t s_incoming_e_call_cond = PTHREAD_COND_INITIALIZER;
|
| 154 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 155 | LYNQ_ECall_Indication g_lynqIncomingEcallIndication;
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 156 | int g_lynqIncomingEcallId;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 157 |
|
| 158 | void sendSignalIncomingECallEvent()
|
| 159 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 160 | LYINFLOG("send incoming ecall event signal");;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 161 | pthread_mutex_lock(&s_incoming_e_call_mutex);
|
| 162 | pthread_cond_signal(&s_incoming_e_call_cond);
|
| 163 | pthread_mutex_unlock(&s_incoming_e_call_mutex);
|
| 164 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 165 |
|
| 166 | int lynq_is_msd_suc(LYNQ_ECall_Indication lynqIncomingEcallIndication)
|
| 167 | {
|
| 168 | if(LYNQ_ECALL_LLACK_RECEIVED == lynqIncomingEcallIndication ||
|
| 169 | LYNQ_ECALL_ALACK_POSITIVE_RECEIVED == lynqIncomingEcallIndication ||
|
| 170 | LYNQ_ECALL_ALACK_CLEARDOWN_RECEIVED == lynqIncomingEcallIndication ||
|
| 171 | LYNQ_ECALL_T5_TIMER_OUT == lynqIncomingEcallIndication ||
|
| 172 | LYNQ_ECALL_T6_TIMER_OUT == lynqIncomingEcallIndication ||
|
| 173 | LYNQ_ECALL_T7_TIMER_OUT == lynqIncomingEcallIndication)
|
| 174 | {
|
| 175 | return 1;
|
| 176 | }
|
| 177 |
|
| 178 | return 0;
|
| 179 | }
|
| 180 |
|
| 181 | int lynq_ecall_is_running()
|
| 182 | {
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 183 | return (is_ecall_dial!=LYNQ_ECALL_DAILING_STATE_NONE) || (g_ecallId !=INVALID_ID);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 184 | }
|
| 185 |
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 186 | #endif
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 187 |
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 188 | /**
|
| 189 | * @brief mark call initialization state
|
| 190 | * 0: deinit state
|
| 191 | * 1: init state
|
| 192 | */
|
| 193 | int g_lynq_call_init_flag = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 194 |
|
| 195 | int JumpHeader(Parcel &p,int *resp_type,int *request,int *slot_id,int *error)
|
| 196 | {
|
| 197 | if(p.dataAvail() > 0)
|
| 198 | {
|
| 199 | p.readInt32(resp_type);
|
| 200 | p.readInt32(request);
|
| 201 | p.readInt32(slot_id);
|
| 202 | p.readInt32(error);
|
| 203 | return 0;
|
| 204 | }
|
| 205 | else
|
| 206 | {
|
| 207 | return -1;
|
| 208 | }
|
| 209 | }
|
| 210 | int send_request(int sockfd,lynq_client_t *client_tmp)
|
| 211 | {
|
| 212 | int ret=0;
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 213 | ret = sendto(sockfd, client_tmp, client_size, 0, (struct sockaddr *)&addr_serv, len_addr_serv);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 214 | if(ret==-1)
|
| 215 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 216 | LYERRLOG("sendto error");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 217 | return -1;
|
| 218 | }
|
| 219 | return 0;
|
| 220 | }
|
| 221 |
|
| 222 | int get_response(int sockfd,Parcel &p)
|
| 223 | {
|
| 224 | int len = 0;
|
| 225 | char recvline[LYNQ_REC_BUF];
|
| 226 | bzero(recvline,LYNQ_REC_BUF);
|
| 227 | /* receive data from server */
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 228 | len = recvfrom(sockfd,recvline,LYNQ_REC_BUF, 0, (struct sockaddr *)&addr_serv,(socklen_t*)&len_addr_serv);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 229 | if(len == -1)
|
| 230 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 231 | LYERRLOG("recvfrom error");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 232 | return -1;
|
| 233 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 234 | if (recvline != NULL) {
|
| 235 | p.setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen);
|
| 236 | p.setDataPosition(0);
|
| 237 | }
|
| 238 | return 0;
|
| 239 | }
|
| 240 | static char *strdupReadString(Parcel &p) {
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 241 | size_t stringlen;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 242 | const char16_t *s16;
|
| 243 | s16 = p.readString16Inplace(&stringlen);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 244 | return strndup16to8(s16, stringlen);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 245 | }
|
| 246 |
|
| 247 | int lynq_get_current_call_list(lynq_call_list_t call_list[LYNQ_CALL_MAX])
|
| 248 | {
|
| 249 | Parcel p;
|
| 250 | lynq_client_t client;
|
| 251 | int resp_type = -1;
|
| 252 | int request = -1;
|
| 253 | int slot_id = -1;
|
| 254 | int error = -1;
|
| 255 | int call_num = 0;
|
| 256 | int temp = 0;
|
| 257 | char *remote_phoneNum = NULL;
|
| 258 | char *remote_name= NULL;
|
| 259 | char *uusData = NULL;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 260 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 261 | client.request = 9;//RIL_REQUEST_GET_CURRENT_CALLS
|
| 262 | client.paramLen = 0;
|
| 263 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 264 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 265 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 266 | {
|
| 267 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 268 | return -1;
|
| 269 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 270 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 271 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 272 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 273 | if(error == 0)
|
| 274 | {
|
| 275 | p.readInt32(&call_num);
|
| 276 | global_call_count = call_num;
|
| 277 | if(call_num<=0)
|
| 278 | {
|
| 279 | lynq_call_state = CALL_OFF;
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 280 | LYINFLOG("lynq_call_state:%d",lynq_call_state);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 281 | return 0;
|
| 282 | }
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 283 | lynq_call_state = CALL_ON;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 284 | LYINFLOG("lynq_call_state:%d, call num is %d ",lynq_call_state,call_num);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 285 | for(int i = 0;i < call_num;i++)
|
| 286 | {
|
| 287 | p.readInt32(&temp);
|
| 288 | call_list[i].call_state = temp;
|
| 289 | p.readInt32(&call_list[i].call_id);
|
| 290 | p.readInt32(&call_list[i].toa);
|
| 291 | p.readInt32(&temp);
|
| 292 | p.readInt32(&temp);
|
| 293 | call_list[i].direction = temp;
|
| 294 | p.readInt32(&temp);
|
| 295 | p.readInt32(&temp);
|
| 296 | p.readInt32(&temp);
|
| 297 | remote_phoneNum = strdupReadString(p);
|
| 298 | memcpy(call_list[i].addr,remote_phoneNum,strlen(remote_phoneNum));
|
| 299 | LYINFLOG("call_id=%d,call_state=%d,direction=%d,addr=%s,toa=%d",call_list[i].call_id,call_list[i].call_state,
|
| 300 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 301 | p.readInt32(&temp);
|
| 302 | remote_name = strdupReadString(p);
|
| 303 | p.readInt32(&temp);
|
| 304 | p.readInt32(&temp);
|
| 305 | if(temp==0)
|
| 306 | {
|
| 307 | continue;
|
| 308 | }
|
| 309 | p.readInt32(&temp); /* UUS Information is present */
|
| 310 | p.readInt32(&temp);
|
| 311 | p.readInt32(&temp);
|
| 312 | p.read(uusData,temp);
|
| 313 | }
|
| 314 | }
|
| 315 | return 0;
|
| 316 | }
|
| 317 |
|
| 318 | void cleanCallList(int lynq_call_id)
|
| 319 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 320 | LYINFLOG("cleanCall local idx is %d, id is %d",lynq_call_id,lynq_call_lists[lynq_call_id].call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 321 | lynq_call_lists[lynq_call_id].call_id = 0;
|
lh | 8657e74 | 2022-04-26 00:45:44 -0700 | [diff] [blame] | 322 | lynq_call_lists[lynq_call_id].call_state = (int)LYNQ_CALL_END;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 323 | lynq_call_lists[lynq_call_id].toa = 0;
|
| 324 | lynq_call_lists[lynq_call_id].direction = 0;
|
| 325 | lynq_call_lists[lynq_call_id].used = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 326 | memset(lynq_call_lists[lynq_call_id].addr,0,sizeof(lynq_call_lists[lynq_call_id].addr));
|
| 327 | }
|
| 328 | int getUnusedElement()
|
| 329 | {
|
| 330 | for(int i=0;i < LYNQ_CALL_MAX; i++)
|
| 331 | {
|
| 332 | if(lynq_call_lists[i].used!=1)
|
| 333 | {
|
| 334 | return i;
|
| 335 | }
|
| 336 | }
|
| 337 | return -1;
|
| 338 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 339 | int addAddr(char addr[])
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 340 | {
|
| 341 | int ret = 0;
|
| 342 | ret = getUnusedElement();
|
| 343 | memcpy(lynq_call_lists[ret].addr,addr,strlen(addr)+1);
|
| 344 | lynq_call_lists[ret].used = 1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 345 | LYINFLOG("add local idx is %d addr is %s",ret,addr);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 346 | return ret;
|
| 347 | }
|
| 348 | void updateCallList(lynq_call_list_e_t *callList, int call_id,int call_state,int toa,int direction)
|
| 349 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 350 | LYINFLOG("Update original local id is %d, new local id is %d",callList->call_id,call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 351 | callList->call_id = call_id;
|
| 352 | callList->call_state = call_state;
|
| 353 | callList->toa = toa;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 354 | callList->direction = direction;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 355 | return;
|
| 356 | }
|
| 357 | int waitCallstateChange(int mtime)
|
| 358 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 359 | LYINFLOG("wait Call state Change");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 360 | int ret = 0;
|
| 361 | int sec = 0;
|
| 362 | int usec = 0;
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 363 | struct timeval now;
|
| 364 | struct timespec timeout;
|
| 365 | gettimeofday(&now,NULL);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 366 | sec = mtime/1000;
|
| 367 | usec = mtime%1000;
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 368 | timeout.tv_sec = now.tv_sec+sec;
|
| 369 | timeout.tv_nsec = now.tv_usec*1000+usec*1000000;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 370 | pthread_mutex_lock(&call_state_change_mutex);
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 371 | ret = pthread_cond_timedwait(&call_state_change_cond,&call_state_change_mutex,&timeout);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 372 | pthread_mutex_unlock(&call_state_change_mutex);
|
| 373 | return ret;
|
| 374 | }
|
| 375 | int waitIncomingCall()
|
| 376 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 377 | LYINFLOG("wait incming call");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 378 | int ret = 0;
|
| 379 | pthread_mutex_lock(&s_incoming_call_mutex);
|
| 380 | ret = pthread_cond_wait(&s_incoming_call_cond,&s_incoming_call_mutex);
|
| 381 | pthread_mutex_unlock(&s_incoming_call_mutex);
|
| 382 | return ret;
|
| 383 | }
|
| 384 | int checkHasCall(char addr[])
|
| 385 | {
|
| 386 | for(int i = 0;i<LYNQ_CALL_MAX;i++)
|
| 387 | {
|
| 388 | if(strcmp(lynq_call_lists[i].addr,addr)==0)
|
| 389 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 390 | LYINFLOG("checkHasCall addr is %s idx is %d id is %d",addr,i,lynq_call_lists[i].call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 391 | return 1;
|
| 392 | }
|
| 393 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 394 | LYINFLOG("checkHasCall addr is %s , no idx is found",addr);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 395 | return 0;
|
| 396 | }
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 397 | int find_call_id_with_addr(char *addr)
|
| 398 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 399 | for(int id = 0; id < LYNQ_CALL_MAX; id++)
|
| 400 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 401 | if(lynq_call_lists[id].used && (strcmp(lynq_call_lists[id].addr,addr) == 0))
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 402 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 403 | LYINFLOG("find addr %s in local list, local idx is %d id is %d",addr,id,lynq_call_lists[id].call_id);
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 404 | return id;
|
| 405 | }
|
| 406 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 407 | LYINFLOG("find addr %s in local list , not found",addr);
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 408 | return -1;
|
| 409 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 410 | int find_call_id_with_call_id(int call_id)
|
| 411 | {
|
| 412 | for(int id = 0; id < LYNQ_CALL_MAX; id++)
|
| 413 | {
|
| 414 | if(lynq_call_lists[id].used && (lynq_call_lists[id].call_id == call_id))
|
| 415 | {
|
| 416 | LYINFLOG("find id %d in local list, local idx is %d, addr is %s",call_id,id,lynq_call_lists[id].addr);
|
| 417 | return id;
|
| 418 | }
|
| 419 | }
|
| 420 | LYINFLOG("find id %d in local list , not found",call_id);
|
| 421 | return INVALID_ID;
|
| 422 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 423 | void sendSignalToWaitCallStateChange()
|
| 424 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 425 | LYINFLOG("send Signal To Wait Call State Change");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 426 | pthread_mutex_lock(&call_state_change_mutex);
|
| 427 | pthread_cond_signal(&call_state_change_cond);
|
| 428 | pthread_mutex_unlock(&call_state_change_mutex);
|
| 429 | }
|
| 430 | void sendSignalIncomingCall()
|
| 431 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 432 | LYINFLOG("send incoming call signal");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 433 | pthread_mutex_lock(&s_incoming_call_mutex);
|
| 434 | pthread_cond_signal(&s_incoming_call_cond);
|
| 435 | pthread_mutex_unlock(&s_incoming_call_mutex);
|
| 436 | }
|
| 437 |
|
| 438 | void addCallListToLynqCallList(lynq_call_list_e_t *callList, int call_id,int call_state,int toa,int direction,char addr[LYNQ_PHONE_NUMBER_MAX])
|
| 439 | {
|
| 440 | callList->call_id = call_id;
|
| 441 | callList->call_state = call_state;
|
| 442 | callList->toa = toa;
|
| 443 | callList->direction = direction;
|
| 444 | memcpy(callList->addr,addr,strlen(addr)+1);
|
| 445 | callList->used = 1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 446 | return;
|
| 447 | }
|
| 448 |
|
| 449 | void *triggerGetCallList(void *parg)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 450 | {
|
| 451 | int ret=0;
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 452 | bool call_end;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 453 | lynq_call_list_t call_list[LYNQ_CALL_MAX];
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 454 | int update=0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 455 | int cnt;
|
| 456 | int i,n;
|
| 457 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 458 | while(call_list_loop)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 459 | {
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 460 | update=0;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 461 | pthread_mutex_lock(&s_urc_call_state_change_mutex);
|
| 462 | pthread_cond_wait(&s_urc_call_state_change_cond, &s_urc_call_state_change_mutex);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 463 | LYDBGLOG("triggerGetCallList event!!!");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 464 | memset(call_list,0,sizeof(call_list));
|
| 465 | ret = lynq_get_current_call_list(call_list);
|
| 466 | if(ret != 0)
|
| 467 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 468 | LYDBGLOG("get current call list failure!!!");
|
ll | 2210140 | 2022-04-11 05:49:51 +0000 | [diff] [blame] | 469 | continue;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 470 | }
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 471 | LYINFLOG("++++++++++++++triggerGetCallList++++++++++++++");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 472 | LYINFLOG("clear local index begin");
|
| 473 | cnt=0;
|
| 474 | for(i = 0;i < LYNQ_CALL_MAX;i++)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 475 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 476 | if(lynq_call_lists[i].used ==0)
|
| 477 | {
|
| 478 | continue;
|
| 479 | }
|
| 480 | cnt++;
|
| 481 | LYINFLOG("local idx is %d id is %d addr is %s state is %d direction is %d",i,lynq_call_lists[i].call_id,lynq_call_lists[i].addr,lynq_call_lists[i].call_state,lynq_call_lists[i].direction);
|
| 482 |
|
| 483 | if(lynq_call_lists[i].call_id > 0)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 484 | {
|
| 485 | call_end = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 486 | for(n = 0; n < LYNQ_CALL_MAX; n++)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 487 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 488 | if(call_list[n].call_id == lynq_call_lists[i].call_id)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 489 | {
|
| 490 | call_end = 1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 491 | LYINFLOG("find lynq call local idx %d, service idx %d id is %d!!!",i,n,lynq_call_lists[i].call_id);
|
| 492 | break;
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 493 | }
|
| 494 | }
|
| 495 | if(call_end == 0)
|
| 496 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 497 | LYINFLOG("MT hungup,then clean call info local idx is %d id is %d",i, lynq_call_lists[i].call_id);
|
| 498 | cleanCallList(i);
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 499 | }
|
| 500 | } //fix bug API-54
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 501 | else
|
| 502 | {
|
| 503 | LYINFLOG("local id is 0");
|
| 504 | }
|
| 505 | }
|
| 506 | LYINFLOG("clear local index end, local used cnt is %d", cnt);
|
| 507 |
|
| 508 | LYINFLOG("add or update local index begin ");
|
| 509 | for (i = 0;i < LYNQ_CALL_MAX;i++)
|
| 510 | {
|
| 511 | if(call_list[i].call_id==0)
|
| 512 | {
|
| 513 | break;
|
| 514 | }
|
| 515 |
|
| 516 | 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,
|
| 517 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 518 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 519 | if(call_list[i].direction == 1)//MT call
|
| 520 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 521 | LYINFLOG("This is a MT CALL");
|
lh | 4256e1b | 2022-05-13 03:02:19 -0700 | [diff] [blame] | 522 | /*MT CALL state code
|
| 523 | **LYNQ_CALL_INCOMING = 4,
|
| 524 | **LYNQ_CALL_WAITING = 5,
|
| 525 | */
|
| 526 | if((call_list[i].call_state ==4) || (call_list[i].call_state ==5))
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 527 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 528 | #ifdef ECALL_SUPPORT
|
| 529 | if(lynq_ecall_is_running())
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 530 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 531 | lynq_call_hungup(&(call_list[i].call_id));
|
| 532 | continue;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 533 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 534 | #endif
|
| 535 | }
|
| 536 | /*you call me, and i call you,One party failed to dial*/
|
| 537 | n = find_call_id_with_addr(call_list[i].addr);
|
| 538 | if(n ==INVALID_ID)
|
| 539 | {
|
| 540 | n = addAddr(call_list[i].addr);
|
| 541 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
| 542 | lynqIncomingCallId = call_list[i].call_id;
|
| 543 | sendSignalIncomingCall();
|
| 544 | }
|
| 545 | else if(lynq_call_lists[n].call_state == call_list[i].call_state)
|
| 546 | {
|
| 547 | LYINFLOG("state not changed, state is %d ",call_list[i].call_state);
|
| 548 | if(call_list[i].call_state ==4 || call_list[i].call_state ==5)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 549 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 550 | /*if call state not change,Maybe this call was ignored, so we need to continue to inform the user of
|
| 551 | **an incoming call until the status changes.
|
| 552 | **fix bug API-54
|
| 553 | */
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 554 | LYINFLOG("resend incoming call signal");
|
| 555 | sendSignalIncomingCall();
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 556 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 557 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 558 | else
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 559 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 560 | LYINFLOG("state changed from %d to %d",lynq_call_lists[n].call_state,call_list[i].call_state);
|
| 561 |
|
| 562 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
| 563 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 564 | }
|
| 565 | else
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 566 | {
|
| 567 | LYINFLOG("This is a MO CALL");
|
| 568 | call_end = 0;
|
| 569 | for(n = 0 ; n < LYNQ_CALL_MAX; n++)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 570 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 571 | if(lynq_call_lists[n].used && ((strcmp(call_list[i].addr,lynq_call_lists[n].addr)==0)||(call_list[i].call_id==lynq_call_lists[n].call_id)))
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 572 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 573 | if(lynq_call_lists[n].call_id==0)
|
| 574 | {
|
| 575 | LYINFLOG("add a call id");
|
| 576 | update=1;
|
| 577 | }
|
| 578 | LYINFLOG("local idx %d updated, original call id is %d origial addr is %s original state is %d",n,lynq_call_lists[n].call_id,lynq_call_lists[n].addr,lynq_call_lists[n].call_state);
|
| 579 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
| 580 | call_end = 1;
|
| 581 | break;
|
| 582 | }
|
| 583 | }
|
| 584 |
|
| 585 | if(call_end == 0)
|
| 586 | {
|
| 587 | LYINFLOG("need to hangup id %d", call_list[i].call_id);
|
| 588 | #ifdef ECALL_SUPPORT
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 589 | if(is_ecall_dial != LYNQ_ECALL_DAILING_STATE_NONE)
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 590 | {
|
| 591 | LYINFLOG("ecall is dialing, for the timebeing, don't huangup");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 592 | continue;
|
| 593 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 594 | #endif
|
| 595 | LYINFLOG("hang up service call id %d",call_list[i].call_id);
|
| 596 | lynq_call_hungup(&(call_list[i].call_id));
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 597 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 598 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 599 | LYDBGLOG("servie idx %d end",i);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 600 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 601 | LYINFLOG("add or update local index end ");
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 602 | s_call_urc_event_complete = 1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 603 | if(isDial==1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 604 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 605 | LYINFLOG("now is dialing");
|
| 606 | if(update==1)
|
| 607 | {
|
| 608 | LYINFLOG("find added call");
|
| 609 | sendSignalToWaitCallStateChange();
|
| 610 | isDial = 0;
|
| 611 | }
|
| 612 | else
|
| 613 | {
|
| 614 | LYINFLOG("not find added call");
|
| 615 | }
|
| 616 | }
|
| 617 | else
|
| 618 | {
|
| 619 | LYINFLOG("now is not dialing");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 620 | }
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 621 | pthread_mutex_unlock(&s_urc_call_state_change_mutex);
|
| 622 | }
|
| 623 | return NULL;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 624 | }
|
| 625 |
|
| 626 | void lynqRespWatingEvent()
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 627 | {
|
| 628 | if(s_call_urc_event_complete==1)
|
| 629 | {
|
| 630 | pthread_mutex_lock(&s_urc_call_state_change_mutex);
|
| 631 | pthread_cond_signal(&s_urc_call_state_change_cond);
|
| 632 | s_call_urc_event_complete = 0;
|
| 633 | pthread_mutex_unlock(&s_urc_call_state_change_mutex);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 634 | }
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 635 | return;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 636 | }
|
| 637 |
|
| 638 | /*Warren add for T800 platform 2021/11/19 start*/
|
| 639 | int lynq_socket_client_start()
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 640 | {
|
| 641 | #if 0
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 642 | struct sockaddr_in lynq_socket_server_addr;
|
| 643 | /* init lynq_socket_server_addr */
|
| 644 | bzero(&lynq_socket_server_addr, sizeof(lynq_socket_server_addr));
|
| 645 | lynq_socket_server_addr.sin_family = AF_INET;
|
| 646 | lynq_socket_server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
|
| 647 | lynq_socket_server_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 648 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 649 | /*
|
| 650 | if(inet_pton(AF_INET,"127.0.0.1", &lynq_socket_server_addr.sin_addr) <= 0)
|
| 651 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 652 | LYDBGLOG("[%s] is not a valid IPaddress", argv[1]);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 653 | exit(1);
|
| 654 | }
|
| 655 | */
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 656 | lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| 657 | if(connect(lynq_call_client_sockfd, (struct sockaddr *)&lynq_socket_server_addr, sizeof(lynq_socket_server_addr)) == -1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 658 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 659 | LYERRLOG("connect error");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 660 | return -1;
|
| 661 | }
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 662 | #endif
|
| 663 | lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| 664 | if (-1 == lynq_call_client_sockfd)
|
| 665 | {
|
| 666 | return lynq_call_client_sockfd;
|
| 667 | }
|
| 668 | /* 设置address */
|
| 669 | memset(&addr_serv, 0, sizeof(addr_serv));
|
| 670 | addr_serv.sin_family = AF_INET;
|
| 671 | addr_serv.sin_addr.s_addr = inet_addr(DSET_IP_ADDRESS);
|
| 672 | addr_serv.sin_port = htons(LYNQ_SERVICE_PORT);
|
| 673 | len_addr_serv = sizeof(addr_serv);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 674 | return 0;
|
| 675 | }
|
| 676 | int lynq_update_call_list_loop()
|
| 677 | {
|
| 678 | int ret = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 679 | pthread_attr_t attr;
|
| 680 | pthread_attr_init(&attr);
|
| 681 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 682 | ret = pthread_create(&lynq_call_list_loop_tid,&attr,triggerGetCallList,NULL);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 683 | if(ret < 0)
|
| 684 | {
|
| 685 | LYERRLOG("lynq_update_call_list_loop fail!!!");
|
| 686 | return -1;
|
| 687 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 688 | LYDBGLOG("lynq_update_call_list_loop success!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 689 | return 0;
|
| 690 |
|
| 691 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 692 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 693 | void *thread_urc_recv(void *parg)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 694 | {
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 695 | int socket_fd = (int64_t)parg;
|
| 696 | int len=0;
|
| 697 | socklen_t addr_len=0;
|
| 698 | uint8_t *dataLength = NULL;
|
| 699 | char urc_data[LYNQ_REC_BUF];
|
| 700 | int slot_id = -1;
|
| 701 | int resp_type = -1;
|
| 702 | int urcid = -1;
|
| 703 | Parcel *p = NULL;
|
| 704 | struct sockaddr_in dest_addr;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 705 | #ifdef ECALL_SUPPORT
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 706 | int ecall_ind;
|
| 707 | int ecallId;
|
| 708 | int unused_callid;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 709 | #endif
|
| 710 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 711 | LYINFLOG("thread_urc_recv in running....");
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 712 | while(urc_call_recive_status)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 713 | {
|
| 714 | bzero(urc_data,LYNQ_REC_BUF);
|
| 715 | //get data msg
|
| 716 | len = recvfrom(socket_fd,urc_data,LYNQ_REC_BUF,0,(struct sockaddr *)&dest_addr,&addr_len);
|
| 717 | if(len <= 0)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 718 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 719 | LYERRLOG("thread_urc_recv step2 fail");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 720 | break;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 721 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 722 | LYDBGLOG("=====>urc data len<=====:%d",len);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 723 | p = new Parcel();
|
| 724 | if(p==NULL)
|
| 725 | {
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 726 | LYERRLOG("new parcel failure!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 727 | break;
|
| 728 | }
|
| 729 | p->setData((uint8_t *)urc_data,len); // p.setData((uint8_t *) buffer, buflen);
|
| 730 | p->setDataPosition(0);
|
| 731 | if(p->dataAvail() > 0)
|
| 732 | {
|
| 733 | p->readInt32(&resp_type);
|
| 734 | p->readInt32(&urcid);
|
| 735 | p->readInt32(&slot_id);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 736 | //LYDBGLOG("*******Warren test*******:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 737 | switch (urcid)
|
| 738 | {
|
| 739 | case 1001://RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED
|
| 740 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 741 | LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 742 | lynqRespWatingEvent();
|
| 743 | break;
|
| 744 | }
|
| 745 | case 1018://RIL_UNSOL_CALL_RING
|
| 746 | {
|
| 747 | if(global_call_auto_answer==1)
|
| 748 | {
|
| 749 | lynq_call_answer();
|
| 750 | }
|
| 751 | break;
|
| 752 | }
|
| 753 | case 1029://RIL_UNSOL_RINGBACK_TONE
|
| 754 | case 3049://RIL_UNSOL_CALL_INFO_INDICATION
|
| 755 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 756 | LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 757 | break;
|
| 758 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 759 | #ifdef ECALL_SUPPORT
|
| 760 | case RIL_UNSOL_ECALL_INDICATIONS:
|
| 761 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 762 | p->readInt32(&ecall_ind);
|
| 763 | g_lynqIncomingEcallIndication = ecall_ind;
|
| 764 | p->readInt32(&ecallId);
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 765 | g_lynqIncomingEcallId = ecallId;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 766 | LYINFLOG("**************:RIL_UNSOL_ECALL_INDICATIONS ,Id %d, ind %d, ecall dialing is %d, normal dialing is %d, local ecall id is %d",ecallId,ecall_ind,is_ecall_dial,isDial,g_ecallId);
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 767 | switch (g_lynqIncomingEcallIndication)
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 768 | {
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 769 | case LYNQ_ECALL_ACTIVE:
|
| 770 | if(is_ecall_dial)
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 771 | {
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 772 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_ANSWERED;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 773 | }
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 774 | break;
|
| 775 | case LYNQ_ECALL_LLACK_RECEIVED:
|
| 776 | case LYNQ_ECALL_ALACK_POSITIVE_RECEIVED:
|
| 777 | case LYNQ_ECALL_ALACK_CLEARDOWN_RECEIVED:
|
| 778 | case LYNQ_ECALL_T5_TIMER_OUT:
|
| 779 | case LYNQ_ECALL_T6_TIMER_OUT:
|
| 780 | case LYNQ_ECALL_T7_TIMER_OUT:
|
| 781 | if(is_ecall_dial)
|
| 782 | {
|
| 783 | LYINFLOG("ecall is dialing, recv suc indication");
|
| 784 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
| 785 | if(ecallId >0 && find_call_id_with_call_id(ecallId)==INVALID_ID)
|
| 786 | {
|
| 787 | LYINFLOG("add ecall in loacl list");
|
| 788 | g_ecallId = ecallId;
|
| 789 | unused_callid=addAddr("ecall");
|
| 790 | lynq_call_lists[unused_callid].call_id=g_ecallId;
|
| 791 | }
|
| 792 | sendSignalToWaitCallStateChange();
|
| 793 | }
|
| 794 | else if(ecallId >0 && (find_call_id_with_call_id(ecallId)==INVALID_ID))
|
| 795 | {
|
| 796 | LYERRLOG("ecall is not in dialing and first recv suc indication, hangup");
|
| 797 | lynq_call_hungup(&ecallId);
|
| 798 | }
|
| 799 | else
|
| 800 | {
|
| 801 | LYERRLOG("ecall is not in dialing and not first recv suc indication");
|
| 802 | }
|
| 803 | break;
|
| 804 | case LYNQ_ECALL_PSAP_CALLBACK_START:
|
| 805 | if(lynq_ecall_is_running()==0)
|
| 806 | {
|
| 807 | LYINFLOG("ecall is not running, recv psap call back msd start, set ecall in dialing");
|
| 808 | if(find_call_id_with_call_id(ecallId)!=INVALID_ID)
|
| 809 | {
|
| 810 | g_ecallId = ecallId;
|
| 811 | if(isDial)
|
| 812 | {
|
| 813 | LYINFLOG("stop normal dial");
|
| 814 | sendSignalToWaitCallStateChange();
|
| 815 | }
|
| 816 | else
|
| 817 | {
|
| 818 | LYINFLOG("no normal dial");
|
| 819 | }
|
| 820 | }
|
| 821 | else
|
| 822 | {
|
| 823 | LYERRLOG("can't find ecall id in local list");
|
| 824 | }
|
| 825 | }
|
| 826 | else
|
| 827 | {
|
| 828 | LYERRLOG("ecall is running, recv psap call back msd start");
|
| 829 | }
|
| 830 | break;
|
| 831 | case LYNQ_ECALL_ABNORMAL_HANGUP:
|
| 832 | if(is_ecall_dial == LYNQ_ECALL_DAILING_STATE_NONE)
|
| 833 | {
|
| 834 | LYERRLOG("ecall is not in dialing , recv abnormal hangup");
|
| 835 | g_ecallId = INVALID_ID;
|
| 836 | }
|
| 837 | else if (is_ecall_dial == LYNQ_ECALL_DAILING_STATE_STARTED)
|
| 838 | {
|
| 839 | LYERRLOG("ecall is in dialing state, recv no answer, recv abnormal hangup, dont' redial");
|
| 840 | g_ecallId = INVALID_ID;
|
| 841 | sendSignalToWaitCallStateChange();
|
| 842 | }
|
| 843 | else {
|
| 844 | LYINFLOG("ecall is in dialing and recv answer, recv abnormal hangup");
|
| 845 | }
|
| 846 | break;
|
| 847 | case LYNQ_ECALL_DISCONNECTED:
|
| 848 | case LYNQ_ECALL_REDIAL_TIMER_OUT:
|
| 849 | case LYNQ_ECALL_T2_TIMER_OUT :
|
| 850 | case LYNQ_ECALL_IMS_DISCONNECTED:
|
| 851 | g_ecallId = INVALID_ID;
|
| 852 | if(is_ecall_dial != LYNQ_ECALL_DAILING_STATE_NONE)
|
| 853 | {
|
| 854 | LYERRLOG("ecall is in dialing, recv like disconnect indication");
|
| 855 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
| 856 | sendSignalToWaitCallStateChange();
|
| 857 | }
|
| 858 | else
|
| 859 | {
|
| 860 | LYINFLOG("ecall is not in dialing, recv like disconnect indication");
|
| 861 | }
|
| 862 | break;
|
| 863 | default:
|
| 864 | LYINFLOG("not special indication");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 865 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 866 | sendSignalIncomingECallEvent();
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 867 | LYINFLOG("**************:RIL_UNSOL_ECALL_INDICATIONS, local ecall id is %d", g_ecallId);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 868 | break;
|
| 869 | }
|
| 870 | #endif
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 871 | default:
|
| 872 | break;
|
| 873 | }
|
| 874 | }
|
| 875 | delete p;
|
| 876 | p = NULL;
|
| 877 | }
|
| 878 | close(socket_fd);
|
| 879 | }
|
| 880 | int lynq_socket_urc_start()
|
| 881 | {
|
| 882 | int socket_fd=0;
|
| 883 | int rt=0;
|
| 884 | int len=0;
|
| 885 | int on=1;
|
| 886 | struct sockaddr_in urc_local_addr;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 887 | pthread_attr_t attr;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 888 | socket_fd = socket(AF_INET,SOCK_DGRAM,0);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 889 | if(socket_fd < 0)
|
| 890 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 891 | LYERRLOG("creaet socket for udp fail");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 892 | return -1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 893 | }
|
| 894 | urc_local_addr.sin_family = AF_INET;
|
| 895 | urc_local_addr.sin_port = htons(LYNQ_URC_SERVICE_PORT);
|
| 896 | urc_local_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
| 897 | /* Set socket to allow reuse of address and port, SO_REUSEADDR value is 2*/
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 898 | rt = setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
|
| 899 | if(rt<0)
|
| 900 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 901 | LYERRLOG("SO_REUSEADDR fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 902 | return -1;
|
| 903 | }
|
| 904 | rt = bind(socket_fd ,(struct sockaddr*)&urc_local_addr, sizeof(urc_local_addr));
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 905 | if (rt == -1)
|
| 906 | {
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 907 | LYERRLOG("bind failed");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 908 | return -1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 909 | }
|
| 910 | pthread_attr_init(&attr);
|
| 911 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 912 | rt = pthread_create(&lynq_call_urc_tid,&attr,thread_urc_recv,(void *)socket_fd);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 913 | if(rt < 0)
|
| 914 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 915 | LYERRLOG("urc loop failure!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 916 | return -1;
|
| 917 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 918 | LYDBGLOG("urc loop success!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 919 | return 0;
|
| 920 | }
|
| 921 | int getSelfElement(char addr[])
|
| 922 | {
|
| 923 | for(int i=0;i < LYNQ_CALL_MAX; i++)
|
| 924 | {
|
| 925 | if(lynq_call_lists[i].used==1)
|
| 926 | {
|
| 927 | if(strcmp(lynq_call_lists[i].addr,addr)==0)
|
| 928 | {
|
| 929 | return i;
|
| 930 | }
|
| 931 |
|
| 932 | }
|
| 933 | }
|
| 934 | return -1;
|
| 935 | }
|
| 936 |
|
| 937 | void lynq_call_state_change_test(int soc_id)
|
| 938 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 939 | LYDBGLOG("call state change,sim:%d",soc_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 940 | }
|
| 941 | int lynq_init_call(int uToken)
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 942 | {
|
| 943 | if(g_lynq_call_init_flag == 1){
|
| 944 | LYDBGLOG("lynq init call failed!!!");
|
| 945 | return -1;
|
| 946 | }
|
| 947 | g_lynq_call_init_flag = 1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 948 | int result = 0;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 949 | Global_uToken_call = uToken;
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 950 | urc_call_recive_status = 1;
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 951 | client_size = sizeof(client_t);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 952 | LYLOGSET(LOG_INFO);
|
| 953 | LYLOGEINIT(USER_LOG_TAG);
|
| 954 | result = lynq_socket_client_start();
|
| 955 | if(result!=0)
|
| 956 | {
|
| 957 | return -1;
|
| 958 | }
|
| 959 | result = lynq_socket_urc_start();
|
| 960 | if(result!=0)
|
| 961 | {
|
| 962 | return -1;
|
| 963 | }
|
| 964 | result = lynq_update_call_list_loop();
|
| 965 | if(result!=0)
|
| 966 | {
|
| 967 | return -1;
|
| 968 | }
|
| 969 | memset(lynq_call_lists,0,sizeof(lynq_call_lists));
|
| 970 | LYDBGLOG("lynq init call success!!!");
|
| 971 | return 0;
|
| 972 | }
|
| 973 | int lynq_deinit_call()
|
| 974 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 975 | int ret;
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 976 | if(g_lynq_call_init_flag == 0)
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 977 | {
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 978 | LYDBGLOG("lynq_deinit_call failed!!!");
|
| 979 | return -1;
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 980 | }
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 981 | else
|
| 982 | {
|
| 983 | g_lynq_call_init_flag = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 984 | lynq_call_hungup_all();
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 985 | if(lynq_call_client_sockfd>0)
|
| 986 | {
|
| 987 | close(lynq_call_client_sockfd);
|
| 988 | }
|
| 989 | urc_call_recive_status = 0;
|
| 990 | call_list_loop = 0;
|
| 991 | if(lynq_call_urc_tid == -1 || lynq_call_list_loop_tid == -1)
|
| 992 | {
|
| 993 | return -1;
|
| 994 | }
|
| 995 | ret = pthread_cancel(lynq_call_urc_tid);
|
| 996 | LYDBGLOG("pthread cancel ret = %d",ret);
|
| 997 | ret = pthread_cancel(lynq_call_list_loop_tid);
|
| 998 | LYDBGLOG("pthread cancel ret = %d",ret);
|
| 999 | ret = pthread_join(lynq_call_urc_tid,NULL);
|
| 1000 | LYDBGLOG("pthread join ret = %d",ret);
|
| 1001 | ret = pthread_join(lynq_call_list_loop_tid,NULL);
|
| 1002 | LYDBGLOG("pthread join ret = %d",ret);
|
| 1003 | return 0;
|
| 1004 | }
|
rita | 47debb9 | 2022-04-07 06:08:13 -0400 | [diff] [blame] | 1005 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1006 |
|
| 1007 | int lynq_set_common_request(int request_id, int argc, const char* format,...)
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1008 | {
|
| 1009 | Parcel p;
|
| 1010 | lynq_client_t client;
|
| 1011 | int resp_type = -1;
|
| 1012 | int request = -1;
|
| 1013 | int slot_id = -1;
|
| 1014 | int error = -1;
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1015 |
|
| 1016 | client.uToken = Global_uToken_call;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1017 | client.request = request_id;
|
| 1018 | client.paramLen = argc;
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1019 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1020 | if(argc!=0)
|
| 1021 | {
|
| 1022 | va_list args;
|
| 1023 | va_start(args, format);
|
| 1024 | vsnprintf(client.param, LYNQ_REQUEST_PARAM_BUF, format, args);
|
| 1025 | va_end(args);
|
| 1026 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1027 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1028 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1029 | {
|
| 1030 | LYERRLOG("send request fail");
|
| 1031 | return -1;
|
| 1032 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1033 | if(get_response(lynq_call_client_sockfd,p)==0)
|
| 1034 | {
|
| 1035 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1036 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1037 | }
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1038 | return error;
|
| 1039 | }
|
| 1040 |
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1041 | int lynq_get_common_request(int request_id, int* status)
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1042 | {
|
| 1043 | Parcel p;
|
| 1044 | lynq_client_t client;
|
| 1045 | int resp_type = -1;
|
| 1046 | int request = -1;
|
| 1047 | int slot_id = -1;
|
| 1048 | int error = -1;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1049 | if(status==NULL)
|
| 1050 | {
|
| 1051 | LYERRLOG("status is null");
|
| 1052 | return -1;
|
| 1053 | }
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1054 | client.uToken = Global_uToken_call;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1055 | client.request = request_id;
|
| 1056 | client.paramLen = 0;
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1057 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1058 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1059 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1060 | {
|
| 1061 | LYERRLOG("send request fail");
|
| 1062 | return -1;
|
| 1063 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1064 | if(get_response(lynq_call_client_sockfd,p)==0)
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1065 | {
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1066 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1067 | p.readInt32(status);
|
| 1068 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1069 | }
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1070 | return error;
|
| 1071 | }
|
| 1072 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1073 | int lynq_call(int* handle,char addr[])
|
| 1074 | {
|
| 1075 | Parcel p;
|
| 1076 | lynq_client_t client;
|
| 1077 | int resp_type = -1;
|
| 1078 | int request = -1;
|
| 1079 | int slot_id = -1;
|
| 1080 | int error = -1;
|
| 1081 | int lynq_call_id = -1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1082 |
|
| 1083 | LYINFLOG("lynq_call begin addr %s",addr);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1084 | if(addr==NULL)
|
| 1085 | {
|
| 1086 | LYERRLOG("Phone num is null!!!");
|
| 1087 | return -1;
|
| 1088 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1089 |
|
| 1090 | if(find_call_id_with_addr(addr)!=INVALID_ID)
|
| 1091 | {
|
| 1092 | LYERRLOG("addr %s exists",addr);
|
| 1093 | return LYNQ_E_CONFLICT;
|
| 1094 | }
|
| 1095 |
|
| 1096 | #ifdef ECALL_SUPPORT
|
| 1097 | if(lynq_ecall_is_running())
|
| 1098 | {
|
| 1099 | LYERRLOG("lynq_fast_ecall ecall is running");
|
| 1100 | return LYNQ_E_ECALL_BEING_RUNNING;
|
| 1101 | }
|
| 1102 | #endif
|
| 1103 |
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1104 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1105 | client.request = 10;//RIL_REQUEST_DIAL
|
| 1106 | client.paramLen = 2;
|
| 1107 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1108 | memcpy(client.param,addr,strlen(addr)+1);
|
| 1109 | strcat(client.param," 0");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1110 | lynq_call_id = addAddr(addr);
|
| 1111 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1112 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1113 | {
|
| 1114 | LYERRLOG("send request fail");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1115 | cleanCallList(lynq_call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1116 | return -1;
|
| 1117 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1118 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1119 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1120 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1121 | if(error==0)
|
| 1122 | {
|
| 1123 | isDial = 1;
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1124 | if(waitCallstateChange(6000)==ETIMEDOUT)//6000ms
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1125 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 1126 | //if timeout,this call need destroy.
|
| 1127 | isDial = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1128 | error = LYNQ_E_TIME_OUT;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1129 | LYERRLOG("lynq_call timeout:wait Call state fail!!! clear local idx %d",lynq_call_id);
|
| 1130 | cleanCallList(lynq_call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1131 | return error;
|
| 1132 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1133 | isDial = 0;
|
| 1134 | *handle = lynq_call_lists[lynq_call_id].call_id;
|
| 1135 | if(*handle > 0)
|
| 1136 | {
|
| 1137 | LYINFLOG("lynq_call dial addr %s suc, id is %d",addr,*handle);
|
| 1138 | return 0;
|
| 1139 | }
|
| 1140 | else
|
| 1141 | {
|
| 1142 | LYERRLOG("lynq_call dial addr %s fail, invalid id",addr);
|
| 1143 | cleanCallList(lynq_call_id);
|
| 1144 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1145 | }
|
| 1146 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1147 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1148 | LYERRLOG("lynq_call dial addr %s fail, service error %d",addr, error);
|
| 1149 | cleanCallList(lynq_call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1150 | return error;
|
| 1151 | }
|
| 1152 | int lynq_call_answer()
|
| 1153 | {
|
| 1154 | Parcel p;
|
| 1155 | lynq_client_t client;
|
| 1156 | int resp_type = -1;
|
| 1157 | int request = -1;
|
| 1158 | int slot_id = -1;
|
| 1159 | int error = -1;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1160 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1161 | client.request = 40;//RIL_REQUEST_DIAL
|
| 1162 | client.paramLen = 0;
|
| 1163 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1164 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1165 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1166 | {
|
| 1167 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1168 | return -1;
|
| 1169 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1170 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1171 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1172 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1173 | return error;
|
| 1174 | }
|
| 1175 | int lynq_call_hungup(int* handle)
|
| 1176 | {
|
| 1177 | Parcel p;
|
| 1178 | lynq_client_t client;
|
| 1179 | int resp_type = -1;
|
| 1180 | int request = -1;
|
| 1181 | int slot_id = -1;
|
| 1182 | int error = -1;
|
| 1183 | int call_id = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1184 | int lynq_call_id;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1185 | if(handle==NULL||!((*handle>=0)&&(*handle<10)))
|
| 1186 | {
|
| 1187 | LYERRLOG("[%s] illegal input!!!!",__FUNCTION__);
|
| 1188 | return LYNQ_E_CONFLICT;
|
| 1189 | }
|
| 1190 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1191 | client.request = 12;//RIL_REQUEST_HUNGUP
|
| 1192 | client.paramLen = 1;
|
| 1193 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1194 | call_id = *handle;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1195 | sprintf(client.param,"%d",call_id);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1196 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1197 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1198 | {
|
| 1199 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1200 | return -1;
|
| 1201 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1202 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1203 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1204 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1205 | if(error==0)
|
| 1206 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1207 | lynq_call_id=find_call_id_with_call_id(call_id);
|
| 1208 | if(lynq_call_id!=INVALID_ID)
|
| 1209 | {
|
| 1210 | cleanCallList(lynq_call_id);
|
| 1211 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1212 | }
|
| 1213 | return error;
|
| 1214 | }
|
| 1215 | int lynq_call_hungup_all()
|
| 1216 | {
|
| 1217 | Parcel p;
|
| 1218 | lynq_client_t client;
|
| 1219 | int resp_type = -1;
|
| 1220 | int request = -1;
|
| 1221 | int slot_id = -1;
|
| 1222 | int error = -1;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1223 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1224 | client.request = 17;//RIL_REQUEST_UDUB
|
| 1225 | client.paramLen = 0;
|
| 1226 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1227 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1228 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1229 | {
|
| 1230 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1231 | return -1;
|
| 1232 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1233 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1234 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1235 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1236 | return error;
|
| 1237 | }
|
| 1238 | int lynq_wait_incoming_call(int *handle)
|
| 1239 | {
|
| 1240 | waitIncomingCall();
|
| 1241 | *handle = lynqIncomingCallId;
|
| 1242 | LYINFLOG("lynq incoming call id:%d",lynqIncomingCallId);
|
| 1243 | return 0;
|
| 1244 | }
|
| 1245 |
|
| 1246 | int lynq_set_auto_answercall(const int mode)
|
| 1247 | {
|
| 1248 | global_call_auto_answer = mode;
|
| 1249 | LYINFLOG("auto answer call mode =%d",mode);
|
| 1250 | return 0;
|
| 1251 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1252 | int lynq_get_current_call_state(int *handle, int *call_state,int *toa,int *direction,char addr[])
|
| 1253 | {
|
| 1254 | int lynq_call_id = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1255 | LYINFLOG("lynq_get_current_call_state begin ");
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1256 | if(handle==NULL)
|
| 1257 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1258 | LYERRLOG("handle is NULL");
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1259 | return LYNQ_E_NULL_ANONALY;
|
| 1260 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1261 | lynq_call_id = find_call_id_with_call_id(*handle);
|
| 1262 | if(lynq_call_id==INVALID_ID)
|
| 1263 | {
|
| 1264 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1265 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1266 | *call_state = lynq_call_lists[lynq_call_id].call_state;
|
| 1267 | *toa = lynq_call_lists[lynq_call_id].toa;
|
| 1268 | *direction = lynq_call_lists[lynq_call_id].direction;
|
| 1269 | memcpy(addr,lynq_call_lists[lynq_call_id].addr,strlen(lynq_call_lists[lynq_call_id].addr)+1);
|
| 1270 | return 0;
|
| 1271 | }
|
| 1272 |
|
| 1273 | /*audio begin*/
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1274 | static int judge_mic(const int enable){
|
ll | c603006 | 2022-02-14 08:58:16 +0000 | [diff] [blame] | 1275 | switch(enable){
|
| 1276 | case 0:
|
| 1277 | return 1;
|
| 1278 | case 1:
|
| 1279 | return 1;
|
| 1280 | default:
|
| 1281 | return 0;
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1282 | }
|
| 1283 | }
|
| 1284 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1285 | int lynq_set_mute_mic(const int enable)
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1286 | {
|
| 1287 | if(!judge_mic(enable)){
|
| 1288 | return LYNQ_E_CONFLICT;
|
| 1289 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1290 | return lynq_set_common_request(53,1,"%d",enable); //RIL_REQUEST_SET_MUTE
|
| 1291 | }
|
| 1292 | int lynq_get_mute_mic(int *status)
|
| 1293 | {
|
| 1294 | return lynq_get_common_request(54,status);//RIL_REQUEST_GET_MUTE
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1295 | }
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1296 |
|
| 1297 | /**
|
| 1298 | * @brief Check whether DTMF is valid
|
| 1299 | *
|
| 1300 | * @param callnum dtmf eg:0-9 * #
|
| 1301 | * @return int
|
| 1302 | */
|
| 1303 | static int judge_dtmf(const char callnum)
|
| 1304 | {
|
| 1305 | if(callnum == '#')
|
| 1306 | {
|
| 1307 | return 1;
|
| 1308 | }
|
| 1309 | if(callnum == '*')
|
| 1310 | {
|
| 1311 | return 1;
|
| 1312 | }
|
| 1313 | if(callnum >= '0'&& callnum <= '9')
|
| 1314 | {
|
| 1315 | return 1;
|
| 1316 | }
|
| 1317 | return 0;
|
| 1318 | }
|
| 1319 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1320 | int lynq_set_DTMF(const char callnum)
|
| 1321 | {
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1322 | if(!judge_dtmf(callnum))
|
| 1323 | {
|
| 1324 | return LYNQ_E_CONFLICT;
|
| 1325 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1326 | if(!lynq_call_state)
|
| 1327 | {
|
| 1328 | LYERRLOG("LYNQ_E_CONFLICT");
|
| 1329 | return LYNQ_E_CONFLICT;
|
| 1330 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1331 | return lynq_set_common_request(24,1,"%c",callnum); //RIL_REQUEST_DTMF
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1332 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1333 | static int judge_volume(LYNQ_E_VOLUMN_SET set,const int volume){
|
| 1334 | if(set==LYNQ_E_VOLUMN_SET_DTMF){
|
| 1335 | if(volume < 0 ||volume >36){
|
| 1336 | return 0;
|
| 1337 | }
|
| 1338 | }
|
| 1339 | else if (set==LYNQ_E_VOLUMN_SET_SPEECH)
|
| 1340 | {
|
| 1341 | if(volume < 1 ||volume >7){
|
| 1342 | return 0;
|
| 1343 | }
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1344 | }
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 1345 | return 1;
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1346 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1347 | int lynq_set_DTMF_volume(const int volume)
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1348 | {
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1349 | if(!judge_volume(LYNQ_E_VOLUMN_SET_DTMF,volume)){
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1350 | return LYNQ_E_CONFLICT;
|
| 1351 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1352 | return lynq_set_common_request(8003,1,"%d",volume);//LYNQ_REQUEST_SET_DTMF_VOLUME
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1353 | }
|
q.huang | 9ee6d5b | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1354 | int lynq_set_speech_volume(const int volume)//mixer_set_volume
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1355 | {
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1356 | if(!judge_volume(LYNQ_E_VOLUMN_SET_SPEECH,volume))
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1357 | {
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1358 | return LYNQ_E_CONFLICT;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1359 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1360 | return lynq_set_common_request(8009,1,"%d",volume); //LYNQ_REQUEST_SET_SPEECH_VOLUME
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1361 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1362 | int lynq_get_speech_volume(int* volumn)//mixer_get_volume
|
| 1363 | {
|
| 1364 | return lynq_get_common_request(8010,volumn);//LYNQ_REQUEST_GET_SPEECH_VOLUME
|
| 1365 | }
|
q.huang | 9ee6d5b | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1366 | int lynq_incall_record_start(const char* file_path)
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1367 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1368 | return lynq_set_common_request(8011,2,"%s %s","1",file_path); //LYNQ_REQUEST_RECORD
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1369 | }
|
| 1370 | int lynq_incall_record_stop()
|
| 1371 | {
|
q.huang | 9ee6d5b | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1372 | const char* unused_file="just_ocuupy_paramter_postion";
|
| 1373 | return lynq_set_common_request(8011,2,"%s %s","0",unused_file); //LYNQ_REQUEST_RECORD
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1374 | }
|
| 1375 | /*audio end*/
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1376 |
|
| 1377 | #ifdef ECALL_SUPPORT
|
| 1378 | LYNQ_ECall_Variant lynq_get_lynq_ecall_variant_from_lynq_type(LYNQ_ECall_Type type)
|
| 1379 | {
|
| 1380 | switch(type)
|
| 1381 | {
|
| 1382 | case LYNQ_ECALL_TYPE_TEST:
|
| 1383 | return LYNQ_ECALL_TEST;
|
| 1384 | case LYNQ_ECALL_TYPE_RECONFIG:
|
| 1385 | return LYNQ_ECALL_RECONFIG;
|
| 1386 | default:
|
| 1387 | return LYNQ_ECALL_EMERGENCY;
|
| 1388 | }
|
| 1389 | }
|
| 1390 |
|
| 1391 | RIL_ECall_Variant lynq_get_ril_ecall_variant_from_lynq_variant(LYNQ_ECall_Variant type)
|
| 1392 | {
|
| 1393 | switch(type)
|
| 1394 | {
|
| 1395 | case LYNQ_ECALL_TEST:
|
| 1396 | return ECALL_TEST;
|
| 1397 | case LYNQ_ECALL_RECONFIG:
|
| 1398 | return ECALL_RECONFIG;
|
| 1399 | default:
|
| 1400 | return ECALL_EMERGENCY;
|
| 1401 | }
|
| 1402 | }
|
| 1403 |
|
| 1404 | RIL_ECall_Category lynq_get_ril_ecall_cat_from_lynq_cat(LYNQ_ECall_Category cat)
|
| 1405 | {
|
| 1406 | switch(cat)
|
| 1407 | {
|
| 1408 | case LYNQ_EMER_CAT_MANUAL_ECALL:
|
| 1409 | return EMER_CAT_MANUAL_ECALL;
|
| 1410 | default:
|
| 1411 | return EMER_CAT_AUTO_ECALL;
|
| 1412 | }
|
| 1413 | }
|
| 1414 |
|
| 1415 |
|
| 1416 | int lynq_set_test_num(LYNQ_ECall_Set_Type type, const char *test_num, int test_num_length)
|
| 1417 | {
|
| 1418 | int error;
|
| 1419 |
|
| 1420 | if(test_num==NULL || test_num_length > LYNQ_PHONE_NUMBER_MAX )
|
| 1421 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1422 | LYERRLOG("test_num is null or test_num_length %d s greater than %d ",test_num_length,LYNQ_PHONE_NUMBER_MAX);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1423 | return -1;
|
| 1424 | }
|
| 1425 |
|
| 1426 | error=lynq_set_common_request(RIL_REQUEST_ECALL_SET_TEST_NUM,2,"%d %s",type,test_num);
|
| 1427 |
|
| 1428 | if(error==0)
|
| 1429 | {
|
| 1430 | snprintf(e_call_addr[LYNQ_ECALL_TEST],LYNQ_PHONE_NUMBER_MAX,"%s",test_num);
|
| 1431 | }
|
| 1432 |
|
| 1433 | return error;
|
| 1434 | }
|
| 1435 |
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1436 | int lynq_fast_ecall(int* handle, LYNQ_ECall_Category lynq_ecall_cat, LYNQ_ECall_Variant lynq_ecall_variant, const char *addr, int addr_length, const unsigned char *msd_data,int msd_length)
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1437 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1438 | int error;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1439 | RIL_ECall_Variant ril_ecall_variant = lynq_get_ril_ecall_variant_from_lynq_variant (lynq_ecall_variant);
|
q.huang | 9a9b876 | 2022-04-19 05:20:12 -0400 | [diff] [blame] | 1440 | RIL_ECall_Category ril_ecall_cat = lynq_get_ril_ecall_cat_from_lynq_cat(lynq_ecall_cat);
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1441 | char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};
|
| 1442 | unsigned int i;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1443 | if(lynq_ecall_is_running())
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1444 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1445 | LYERRLOG("lynq_fast_ecall ecall is running");
|
| 1446 | return LYNQ_E_ECALL_BEING_RUNNING;
|
| 1447 | }
|
| 1448 |
|
| 1449 | if(msd_length > MSD_MAX_LENGTH || msd_length <=0)
|
| 1450 | {
|
| 1451 | LYERRLOG("lynq_fast_ecall msd_length %d is greater than %d or <= 0, parameter error",msd_length,MSD_MAX_LENGTH);
|
| 1452 | return LYNQ_E_ECALL_MSD_LENGTH_ERROR;
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1453 | }
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1454 |
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1455 | for(i =0; i<msd_length;i++)
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1456 | {
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1457 | sprintf(&(lynq_msd_data[i<<1]),"%02x",msd_data[i]);
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1458 | }
|
| 1459 |
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1460 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1461 | LYINFLOG("lynq_fast_ecall addr is %s",e_call_addr[lynq_ecall_variant]);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1462 |
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1463 | error=lynq_set_common_request(RIL_REQUEST_ECALL_FAST_MAKE_ECALL,4,"%d %d %s %s",ril_ecall_cat, ril_ecall_variant, "null", lynq_msd_data);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1464 |
|
| 1465 | if(error==0)
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1466 | {
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 1467 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_STARTED;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1468 | if(waitCallstateChange(180000)==ETIMEDOUT)//180000ms
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1469 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1470 | LYERRLOG("lynq_fast_ecall timeout:wait Call state time out!!!");
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 1471 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1472 | lynqRespWatingEvent();
|
| 1473 | return LYNQ_E_TIME_OUT;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1474 | }
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 1475 | if(is_ecall_dial == LYNQ_ECALL_DAILING_STATE_STARTED)
|
| 1476 | {
|
| 1477 | /*just dail, no recv answer*/
|
| 1478 | LYERRLOG("lynq_fast_ecall, no answer!");
|
| 1479 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
| 1480 | lynqRespWatingEvent();
|
| 1481 | return LYNQ_E_ECALL_DAILING_NO_ANSWER;
|
| 1482 | }
|
| 1483 |
|
| 1484 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1485 | lynqRespWatingEvent();
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1486 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1487 | if(g_ecallId != INVALID_ID)
|
| 1488 | {
|
| 1489 | *handle=g_ecallId;
|
| 1490 | LYINFLOG("lynq_fast_ecall id is %d",g_ecallId);
|
| 1491 | return 0;
|
| 1492 | }
|
| 1493 | else
|
| 1494 | {
|
| 1495 | LYERRLOG("lynq_fast_ecall service return fail");
|
| 1496 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1497 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1498 | }
|
| 1499 |
|
| 1500 | return error;
|
| 1501 | }
|
| 1502 |
|
| 1503 | int lynq_set_psap(int enable)
|
| 1504 | {
|
| 1505 | return lynq_set_common_request(RIL_REQUEST_ECALL_SET_PSAP,1,"%d",enable);
|
| 1506 | }
|
| 1507 |
|
| 1508 | int lynq_psap_pull_msd()
|
| 1509 | {
|
| 1510 | return lynq_set_common_request(RIL_REQUEST_ECALL_PSAP_PULL_MSD,0,"");
|
| 1511 | }
|
| 1512 |
|
| 1513 | int lynq_make_ecall(int* handle, LYNQ_ECall_Type type)
|
| 1514 | {
|
| 1515 | LYNQ_ECall_Variant lynq_ecall_variant;
|
| 1516 | int error = -1;
|
| 1517 | int lynq_call_id = -1;
|
| 1518 |
|
| 1519 | if(handle==NULL)
|
| 1520 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1521 | LYERRLOG("handle is NULL, parameter error ");
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1522 | return -1;
|
| 1523 | }
|
| 1524 |
|
| 1525 | error=lynq_set_common_request(RIL_REQUEST_ECALL_MAKE_ECALL,1,"%d",type);
|
| 1526 |
|
| 1527 | if(error==0)
|
| 1528 | {
|
| 1529 | lynq_ecall_variant=lynq_get_lynq_ecall_variant_from_lynq_type(type);
|
| 1530 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1531 | lynq_call_id = addAddr(e_call_addr[lynq_ecall_variant]);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1532 | isDial = 1;
|
| 1533 | if(waitCallstateChange(10000)==ETIMEDOUT)//10000ms
|
| 1534 | {
|
| 1535 | error = LYNQ_E_TIME_OUT;
|
| 1536 | LYERRLOG("timeout:wait Call state fail!!!");
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1537 | return error;
|
| 1538 | }
|
| 1539 |
|
| 1540 | *handle = lynq_call_id;
|
| 1541 | }
|
| 1542 |
|
| 1543 | return error;
|
| 1544 | }
|
| 1545 |
|
| 1546 |
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1547 | int lynq_set_msd(int* handle, const unsigned char *msd_data, int msd_length)
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1548 | {
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1549 | char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};
|
| 1550 | unsigned int i;
|
| 1551 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1552 | if(handle==NULL || ((*handle) >= LYNQ_CALL_MAX) || msd_length > MSD_MAX_LENGTH || msd_length == 0 || msd_data ==NULL)
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1553 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1554 | LYERRLOG("lynq_set_msd handle is NULL or *handle %d is greater or equeal to %d or msd_length %d is greater than %d or msd_data %s is NULL, parameter error",*handle,LYNQ_CALL_MAX,msd_length,MSD_MAX_LENGTH, msd_data);
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1555 | return -1;
|
| 1556 | }
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1557 |
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1558 | for(i=0; i<msd_length;i++)
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1559 | {
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1560 | sprintf(&(lynq_msd_data[i<<1]),"%02x",msd_data[i]);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1561 | }
|
| 1562 |
|
| 1563 | LYINFLOG("lynq_set_msd ");
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1564 |
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1565 | return lynq_set_common_request(RIL_REQUEST_ECALL_SET_MSD,2,"%d %s",lynq_call_lists[(*handle)].call_id,lynq_msd_data);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1566 | }
|
| 1567 |
|
| 1568 | int lynq_set_ivs(int enable)
|
| 1569 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1570 | if(enable<0)
|
| 1571 | {
|
| 1572 | lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
|
| 1573 | return 0;
|
| 1574 | }
|
| 1575 |
|
| 1576 | return lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1577 | }
|
| 1578 |
|
| 1579 | int lynq_reset_ivs()
|
| 1580 | {
|
| 1581 | return lynq_set_common_request(RIL_REQUEST_ECALL_RESET_IVS,0,"");
|
| 1582 | }
|
| 1583 |
|
| 1584 | int lynq_ivs_push_msd()
|
| 1585 | {
|
| 1586 | return lynq_set_common_request(RIL_REQUEST_ECALL_IVS_PUSH_MSD,0,"");
|
| 1587 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1588 |
|
| 1589 | int wait_ecall_event()
|
| 1590 | {
|
| 1591 | int ret = 0;
|
| 1592 | pthread_mutex_lock(&s_incoming_e_call_mutex);
|
| 1593 | ret = pthread_cond_wait(&s_incoming_e_call_cond,&s_incoming_e_call_mutex);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1594 | pthread_mutex_unlock(&s_incoming_e_call_mutex);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1595 | return ret;
|
| 1596 | }
|
| 1597 |
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 1598 | int lynq_wait_ecall_indication(int* eCall_Id, LYNQ_ECall_Indication *eCall_Indication)
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1599 | {
|
| 1600 | wait_ecall_event();
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame^] | 1601 | *eCall_Id = g_lynqIncomingEcallId;
|
| 1602 | *eCall_Indication = g_lynqIncomingEcallIndication;
|
| 1603 | LYINFLOG("lynq_wait_ecall_indication call id %d, Ind id: %d", *eCall_Id, *eCall_Indication);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1604 | return 0;
|
| 1605 | }
|
| 1606 |
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1607 | #endif
|
| 1608 |
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1609 | /*Audio Path setting begin*/
|
| 1610 | /*set*/
|
| 1611 | int lynq_set_voice_audio_mode(const LYNQ_Audio_Mode audio_mode)
|
| 1612 | {
|
| 1613 | return 0;
|
| 1614 | }
|
q.huang | 65033cb | 2022-06-06 20:23:15 +0800 | [diff] [blame] | 1615 | int lynq_set_rtp_ip(const LYNQ_Rtp_Mode rtp_mode, const char* ip, const int ip_length)
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1616 | {
|
| 1617 | return 0;
|
| 1618 | }
|
q.huang | 65033cb | 2022-06-06 20:23:15 +0800 | [diff] [blame] | 1619 | int lynq_set_rtp_port(const LYNQ_Rtp_Mode rtp_mode, const int port)
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1620 | {
|
| 1621 | return 0;
|
| 1622 | }
|
| 1623 | int lynq_set_rtp_param(const int clock_rate,const int channels,const int latency) //only for client mode
|
| 1624 | {
|
| 1625 | return 0;
|
| 1626 | }
|
| 1627 | /*get*/
|
| 1628 | LYNQ_Audio_Mode lynq_get_voice_audio_mode()
|
| 1629 | {
|
| 1630 | return AUDIO_MODE_CODEC;
|
| 1631 | }
|
| 1632 | int lynq_get_rtp_ip(const LYNQ_Rtp_Mode rtp_mode, char* ip, const int ip_length)
|
| 1633 | {
|
| 1634 | if(ip==NULL)
|
| 1635 | {
|
| 1636 | return 1;
|
| 1637 | }
|
| 1638 | return 0;
|
| 1639 | }
|
| 1640 | int lynq_get_rtp_port(const LYNQ_Rtp_Mode rtp_mode, int* port)
|
| 1641 | {
|
| 1642 | if(port==NULL)
|
| 1643 | {
|
| 1644 | return 1;
|
| 1645 | }
|
| 1646 | return 0;
|
| 1647 | }
|
| 1648 | int lynq_get_rtp_param(int* clock_rate, int* channels, int* latency)//only for client mode
|
| 1649 | {
|
| 1650 | if(clock_rate == NULL || channels ==NULL || latency ==NULL)
|
| 1651 | {
|
| 1652 | return 1;
|
| 1653 | }
|
| 1654 |
|
| 1655 | return 0;
|
| 1656 | }
|
| 1657 | /*Audio Path setting end*/
|
| 1658 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1659 | #if 0
|
| 1660 | int main(int argc,char **argv)
|
| 1661 | {
|
| 1662 | int n = 0;
|
| 1663 | n = lynq_init_call(lynq_call_state_change_test,2222);
|
| 1664 | if(n<0)
|
| 1665 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1666 | LYDBGLOG("lynq init call fail!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1667 | return -1;
|
| 1668 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1669 | LYDBGLOG("lynq call init success!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1670 | char phoneNum[LYNQ_PHONE_NUMBER_MAX];
|
| 1671 | sprintf(phoneNum,"18180053406 0",strlen("18180053406 0")+1);
|
| 1672 | lynq_call(phoneNum);
|
| 1673 | while(1)
|
| 1674 | {
|
| 1675 | sleep(1);
|
| 1676 | }
|
| 1677 | return 0;
|
| 1678 | }
|
| 1679 | #endif
|
| 1680 | /*Warren add for T800 platform 2021/11/19 end*/
|