[feature] add e-call interface 2
Change-Id: I0c234ef6c247d423bb463c3e1e7687eac63aebeb
diff --git a/lib/liblynq-call/lynq_call.cpp b/lib/liblynq-call/lynq_call.cpp
index bca0ea6..15d9841 100755
--- a/lib/liblynq-call/lynq_call.cpp
+++ b/lib/liblynq-call/lynq_call.cpp
@@ -8,12 +8,17 @@
#include <unistd.h>
#include <binder/Parcel.h>
#include <log/log.h>
-#include "lynq_call.h"
#include <cutils/jstring.h>
#include <pthread.h>
#include "liblog/lynq_deflog.h"
#include <sys/time.h>
#include <string.h>
+#include <vendor-ril/telephony/ril.h>
+#include <vendor-ril/telephony/mtk_ril_sp.h>
+#include <vendor-ril/telephony/mtk_ril_ivt.h>
+#include "lynq_call.h"
+
+
#define LYNQ_SERVICE_PORT 8088
#define DSET_IP_ADDRESS "127.0.0.1"
#define LYNQ_URC_SERVICE_PORT 8086
@@ -114,6 +119,17 @@
bool call_list_loop = 1;
int isDial = 0;
int lynqIncomingCallId = 0;
+/*E-CALL begin*/
+typedef enum{
+ LYNQ_ECALL_TYPE_TEST = 0, /* Test eCall */
+ LYNQ_ECALL_TYPE_RECONFIG = 1, /* Reconfiguration eCall */
+ LYNQ_ECALL_MANUAL_EMERGENCY = 2, /*Manual Emergency eCall */
+ LYNQ_ECALL_TYPE_AUTO_EMERGENCY = 3, /* Automatic Emergency eCall */\
+}LYNQ_ECall_Type;
+
+char e_call_addr[LYNQ_ECALL_VAR_MAX][LYNQ_PHONE_NUMBER_MAX]={"","112","112"};
+/*E-CALL end*/
+
/**
* @brief mark call initialization state
* 0: deinit state
@@ -683,8 +699,8 @@
return 0;
}
}
-#ifdef ECALL_SUPPORT
-int lynq_fast_ecall(int* handle, int ecall_cat, int ecall_variant, char *addr, unsigned char *msd_data)
+
+int lynq_set_common_request(int request_id, int argc, const char* format,...)
{
Parcel p;
lynq_client_t client;
@@ -692,80 +708,33 @@
int request = -1;
int slot_id = -1;
int error = -1;
- int lynq_call_id = -1;
-
- if(addr==NULL)
- {
- LYERRLOG("Phone num is null!!!");
- return -1;
- }
- client.uToken = Global_uToken_call;
- client.request = 9010;
- client.paramLen = 5;
- bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
- sprintf(client.param,"%d %d %s %s", ecall_cat, ecall_variant, addr, msd_data);
- LYDBGLOG("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
-
- if(send_request(lynq_call_client_sockfd, &client)==-1)
- {
- LYERRLOG("send request fail");
- return -1;
- }
-
- get_response(lynq_call_client_sockfd, p);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYDBGLOG("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
-
- lynq_call_id = updateAddr(addr);
- if(error==0)
- {
- isDial = 1;
- if(waitCallstateChange(3000)==ETIMEDOUT)//3000ms
- {
- error = LYNQ_E_TIME_OUT;
- LYERRLOG("timeout:wait Call state fail!!!");
- lynq_call_lists[lynq_call_id].hasTimeout = 1;
- return error;
- }
-
- *handle = lynq_call_id;
- }
-
- return error;
-}
-
-int lynq_set_psap(int enable)
-{
- Parcel p;
- lynq_client_t client;
- int resp_type = -1;
- int request = -1;
- int slot_id = -1;
- int error = -1;
-
client.uToken = Global_uToken_call;
- client.request = 9005;
- client.paramLen = 2;
+ client.request = request_id;
+ client.paramLen = argc;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
- sprintf(client.param, "%d", enable);
- LYDBGLOG("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
-
+ if(argc!=0)
+ {
+ va_list args;
+ va_start(args, format);
+ vsnprintf(client.param, LYNQ_REQUEST_PARAM_BUF, format, args);
+ va_end(args);
+ }
+ LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s\n",client.uToken,client.request,client.paramLen,client.param);
if(send_request(lynq_call_client_sockfd,&client)==-1)
{
LYERRLOG("send request fail");
return -1;
}
-
- get_response(lynq_call_client_sockfd,p);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYDBGLOG("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
-
+ if(get_response(lynq_call_client_sockfd,p)==0)
+ {
+ JumpHeader(p,&resp_type,&request,&slot_id,&error);
+ LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
+ }
return error;
}
-
-int lynq_psap_pull_msd()
+int lynq_get_common_request(int request_id, int* status)
{
Parcel p;
lynq_client_t client;
@@ -773,182 +742,30 @@
int request = -1;
int slot_id = -1;
int error = -1;
- int lynq_call_id = -1;
-
-
+ if(status==NULL)
+ {
+ LYERRLOG("status is null");
+ return -1;
+ }
client.uToken = Global_uToken_call;
- client.request = 9008;
- client.paramLen = 1;
+ client.request = request_id;
+ client.paramLen = 0;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
- LYDBGLOG("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
-
+ LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s\n",client.uToken,client.request,client.paramLen,client.param);
if(send_request(lynq_call_client_sockfd,&client)==-1)
{
LYERRLOG("send request fail");
return -1;
}
-
- get_response(lynq_call_client_sockfd,p);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYDBGLOG("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
-
- return error;
-}
-int lynq_make_ecall(int* handle, int type)
-{
- Parcel p;
- lynq_client_t client;
- int resp_type = -1;
- int request = -1;
- int slot_id = -1;
- int error = -1;
- int lynq_call_id = -1;
-
-
- client.uToken = Global_uToken_call;
- client.request = 9006;
- client.paramLen = 2;
- bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
- sprintf(client.param, "%d", type);
- LYDBGLOG("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
-
- if(send_request(lynq_call_client_sockfd,&client)==-1)
+ if(get_response(lynq_call_client_sockfd,p)==0)
{
- LYERRLOG("send request fail");
- return -1;
+ JumpHeader(p,&resp_type,&request,&slot_id,&error);
+ p.readInt32(status);
+ LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
}
-
- get_response(lynq_call_client_sockfd,p);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYDBGLOG("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
-
return error;
}
-
-int lynq_set_msd(int call_id, char *msd_data)
-{
- Parcel p;
- lynq_client_t client;
- int resp_type = -1;
- int request = -1;
- int slot_id = -1;
- int error = -1;
- int lynq_call_id = -1;
-
-
- client.uToken = Global_uToken_call;
- client.request = 9004;
- client.paramLen = 3;
- bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
- sprintf(client.param, "%d %s", call_id, msd_data);
- LYDBGLOG("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
-
- if(send_request(lynq_call_client_sockfd,&client)==-1)
- {
- LYERRLOG("send request fail");
- return -1;
- }
-
- get_response(lynq_call_client_sockfd,p);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYDBGLOG("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
-
- return error;
-}
-
-int lynq_set_ivs(int enable)
-{
- Parcel p;
- lynq_client_t client;
- int resp_type = -1;
- int request = -1;
- int slot_id = -1;
- int error = -1;
- int lynq_call_id = -1;
-
-
- client.uToken = Global_uToken_call;
- client.request = 9004;
- client.paramLen = 2;
- bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
- sprintf(client.param, "%d", enable);
- LYDBGLOG("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
-
- if(send_request(lynq_call_client_sockfd,&client)==-1)
- {
- LYERRLOG("send request fail");
- return -1;
- }
-
- get_response(lynq_call_client_sockfd,p);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYDBGLOG("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
-
- return error;
-}
-
-int lynq_reset_ivs()
-{
- Parcel p;
- lynq_client_t client;
- int resp_type = -1;
- int request = -1;
- int slot_id = -1;
- int error = -1;
- int lynq_call_id = -1;
-
-
- client.uToken = Global_uToken_call;
- client.request = 9012;
- client.paramLen = 1;
- bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
- LYDBGLOG("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
-
- if(send_request(lynq_call_client_sockfd,&client)==-1)
- {
- LYERRLOG("send request fail");
- return -1;
- }
-
- get_response(lynq_call_client_sockfd,p);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYDBGLOG("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
-
- return error;
-}
-
-int lynq_ivs_push_msd()
-{
- Parcel p;
- lynq_client_t client;
- int resp_type = -1;
- int request = -1;
- int slot_id = -1;
- int error = -1;
- int lynq_call_id = -1;
-
-
- client.uToken = Global_uToken_call;
- client.request = 9007;
- client.paramLen = 1;
- bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
- // sprintf(client.param, "%d", enable);
- LYDBGLOG("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
-
- if(send_request(lynq_call_client_sockfd,&client)==-1)
- {
- LYERRLOG("send request fail");
- return -1;
- }
-
- get_response(lynq_call_client_sockfd,p);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYDBGLOG("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
-
- return error;
-}
-#endif
int lynq_call(int* handle,char addr[])
{
Parcel p;
@@ -1106,73 +923,6 @@
}
/*audio begin*/
-int lynq_set_common_request(int request_id, int argc, const char* format,...)
-{
- Parcel p;
- lynq_client_t client;
- int resp_type = -1;
- int request = -1;
- int slot_id = -1;
- int error = -1;
- //if(!lynq_call_state)
- //{
- // LYERRLOG("LYNQ_E_CONFLICT");
- // return LYNQ_E_CONFLICT;
- //}
- client.uToken = Global_uToken_call;
- client.request = request_id;
- client.paramLen = argc;
- bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
- va_list args;
- va_start(args, format);
- vsnprintf(client.param, LYNQ_REQUEST_PARAM_BUF, format, args);
- va_end(args);
- LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s\n",client.uToken,client.request,client.paramLen,client.param);
- if(send_request(lynq_call_client_sockfd,&client)==-1)
- {
- LYERRLOG("send request fail");
- return -1;
- }
- if(get_response(lynq_call_client_sockfd,p)==0)
- {
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
- }
- return error;
-}
-
-int lynq_get_common_request(int request_id, int* status)
-{
- Parcel p;
- lynq_client_t client;
- int resp_type = -1;
- int request = -1;
- int slot_id = -1;
- int error = -1;
- if(status==NULL)
- {
- LYERRLOG("status is null");
- return -1;
- }
- client.uToken = Global_uToken_call;
- client.request = request_id;
- client.paramLen = 0;
- bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
- LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s\n",client.uToken,client.request,client.paramLen,client.param);
- if(send_request(lynq_call_client_sockfd,&client)==-1)
- {
- LYERRLOG("send request fail");
- return -1;
- }
- if(get_response(lynq_call_client_sockfd,p)==0)
- {
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- p.readInt32(status);
- LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
- }
- return error;
-}
-
static int judge_mic(const int enable){
switch(enable){
case 0:
@@ -1275,6 +1025,166 @@
return lynq_set_common_request(8011,2,"%s %s","0",unused_file); //LYNQ_REQUEST_RECORD
}
/*audio end*/
+
+#ifdef ECALL_SUPPORT
+LYNQ_ECall_Variant lynq_get_lynq_ecall_variant_from_lynq_type(LYNQ_ECall_Type type)
+{
+ switch(type)
+ {
+ case LYNQ_ECALL_TYPE_TEST:
+ return LYNQ_ECALL_TEST;
+ case LYNQ_ECALL_TYPE_RECONFIG:
+ return LYNQ_ECALL_RECONFIG;
+ default:
+ return LYNQ_ECALL_EMERGENCY;
+ }
+}
+
+RIL_ECall_Variant lynq_get_ril_ecall_variant_from_lynq_variant(LYNQ_ECall_Variant type)
+{
+ switch(type)
+ {
+ case LYNQ_ECALL_TEST:
+ return ECALL_TEST;
+ case LYNQ_ECALL_RECONFIG:
+ return ECALL_RECONFIG;
+ default:
+ return ECALL_EMERGENCY;
+ }
+}
+
+RIL_ECall_Category lynq_get_ril_ecall_cat_from_lynq_cat(LYNQ_ECall_Category cat)
+{
+ switch(cat)
+ {
+ case LYNQ_EMER_CAT_MANUAL_ECALL:
+ return EMER_CAT_MANUAL_ECALL;
+ default:
+ return EMER_CAT_AUTO_ECALL;
+ }
+}
+
+
+int lynq_set_test_num(LYNQ_ECall_Set_Type type, const char *test_num, int test_num_length)
+{
+ int error;
+
+ if(test_num==NULL || test_num_length > LYNQ_PHONE_NUMBER_MAX )
+ {
+ LYERRLOG("test_num is null or test_num_length %d s greater than %d\n ",test_num_length,LYNQ_PHONE_NUMBER_MAX);
+ return -1;
+ }
+
+ error=lynq_set_common_request(RIL_REQUEST_ECALL_SET_TEST_NUM,2,"%d %s",type,test_num);
+
+ if(error==0)
+ {
+ snprintf(e_call_addr[LYNQ_ECALL_TEST],LYNQ_PHONE_NUMBER_MAX,"%s",test_num);
+ }
+
+ return error;
+}
+
+
+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 char *msd_data, int msd_length)
+{
+ int error = -1;
+ int lynq_call_id = -1;
+ RIL_ECall_Variant ril_ecall_variant = lynq_get_ril_ecall_variant_from_lynq_variant (lynq_ecall_variant);
+ LYNQ_ECall_Category ril_ecall_cat = lynq_get_ril_ecall_cat_from_lynq_cat(lynq_ecall_cat);
+
+ error=lynq_set_common_request(RIL_REQUEST_ECALL_FAST_MAKE_ECALL,4,"%d %d %s %s",ril_ecall_cat, ril_ecall_variant, "null", msd_data);
+
+ if(error==0)
+ {
+ lynq_call_id = updateAddr(e_call_addr[lynq_ecall_variant]);
+ isDial = 1;
+ if(waitCallstateChange(10000)==ETIMEDOUT)//10000ms
+ {
+ error = LYNQ_E_TIME_OUT;
+ LYERRLOG("timeout:wait Call state fail!!!");
+ lynq_call_lists[lynq_call_id].hasTimeout = 1;
+ return error;
+ }
+
+ *handle = lynq_call_id;
+ }
+
+ return error;
+}
+
+int lynq_set_psap(int enable)
+{
+ return lynq_set_common_request(RIL_REQUEST_ECALL_SET_PSAP,1,"%d",enable);
+}
+
+int lynq_psap_pull_msd()
+{
+ return lynq_set_common_request(RIL_REQUEST_ECALL_PSAP_PULL_MSD,0,"");
+}
+
+int lynq_make_ecall(int* handle, LYNQ_ECall_Type type)
+{
+ LYNQ_ECall_Variant lynq_ecall_variant;
+ int error = -1;
+ int lynq_call_id = -1;
+
+ if(handle==NULL)
+ {
+ LYERRLOG("handle is NULL, parameter error \n ");
+ return -1;
+ }
+
+ error=lynq_set_common_request(RIL_REQUEST_ECALL_MAKE_ECALL,1,"%d",type);
+
+ if(error==0)
+ {
+ lynq_ecall_variant=lynq_get_lynq_ecall_variant_from_lynq_type(type);
+
+ lynq_call_id = updateAddr(e_call_addr[lynq_ecall_variant]);
+ isDial = 1;
+ if(waitCallstateChange(10000)==ETIMEDOUT)//10000ms
+ {
+ error = LYNQ_E_TIME_OUT;
+ LYERRLOG("timeout:wait Call state fail!!!");
+ lynq_call_lists[lynq_call_id].hasTimeout = 1;
+ return error;
+ }
+
+ *handle = lynq_call_id;
+ }
+
+ return error;
+}
+
+
+int lynq_set_msd(int* handle, const char *msd_data, int msd_length)
+{
+ if(handle==NULL || ((*handle) >= LYNQ_CALL_MAX))
+ {
+ LYERRLOG("handle is NULL or *handle %d is greater or equeal to %d, parameter error\n",*handle,LYNQ_CALL_MAX);
+ return -1;
+ }
+
+ return lynq_set_common_request(RIL_REQUEST_ECALL_SET_MSD,2,"%d %s",lynq_call_lists[(*handle)].call_id,msd_data);
+}
+
+int lynq_set_ivs(int enable)
+{
+ return lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
+}
+
+int lynq_reset_ivs()
+{
+ return lynq_set_common_request(RIL_REQUEST_ECALL_RESET_IVS,0,"");
+}
+
+int lynq_ivs_push_msd()
+{
+ return lynq_set_common_request(RIL_REQUEST_ECALL_IVS_PUSH_MSD,0,"");
+}
+#endif
+
#if 0
int main(int argc,char **argv)
{