[feature]shutdown and get version api
Change-Id: Idad845f4ca37943778b750ec784e9e73bcd37888
diff --git a/src/lynq/lib/liblynq-sim/include/lynq_sim.h b/src/lynq/lib/liblynq-sim/include/lynq_sim.h
index 846a1ec..b0457df 100755
--- a/src/lynq/lib/liblynq-sim/include/lynq_sim.h
+++ b/src/lynq/lib/liblynq-sim/include/lynq_sim.h
@@ -1,9 +1,9 @@
/*=============================================================================
-# FileName: lynq_sim.cpp
+# FileName: lynq_sim.h
# Desc: about SIMAPI
-# Author: mobiletek
+# Author: lei
# Version: V1.0
-# LastChange: 2020-07-29
+# LastChange: 2022-03-31
# History:
# If you need to use any API under lynq_sim, you must first call the lynq_sim_init() function to initialize these functions.
=============================================================================*/
@@ -50,6 +50,22 @@
*/
int lynq_req_sim_io(int list[5], char *path, char *data, char *pin2, char *aidPtr, int sw[2], char *simResponse);
+/**
+ * @brief
+ * @param options type: [IN] [options] define whether you want to halt, power-off, or reboot the machine.May be NULL
+ * @param time type: [IN] [time] specifies when you want the shutdown to perform.May be NULL
+ * @param message type: [IN] [message] adds a message that announces the shutdown.May be NULL
+ * @return int
+ */
+int lynq_shutdown(char options[], char time[], char message[]);
+
+/**
+ * @brief get currnet version of mobiletek
+ * @param buf type: [out] My Param doc
+ * @return int
+ */
+int lynq_get_version(char buf[]);
+
#ifdef __cplusplus
diff --git a/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp b/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp
index 4a2eb1a..e7de7a7 100755
--- a/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp
+++ b/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp
@@ -74,6 +74,11 @@
char pin2_buf[32] = {0};
char aidPtr_buf[32] = {0};
+/**/
+char options_buf[32] = {0};
+char time_buf[32] = {0};
+char message_buf[32] = {0};
+
int lynq_sim_init(int utoken){
if(g_lynq_sim_init_flag == 1)
{
@@ -668,8 +673,6 @@
if(!judge(slot))
return ret;
int send_num = 0;
- char res_data[MAX_LEN] = {0};
- int len = 0;
client_t.request = LYNQ_REQUEST_SET_DEFAULT_SIM_ALL;
client_t.paramLen = 1;
client_t.uToken = Global_uToken;
@@ -688,8 +691,6 @@
if(!judge(num))
return ret;
int send_num = 0;
- char res_data[MAX_LEN] = {0};
- int len = 0;
client_t.request = RIL_REQUEST_SCREEN_STATE;
client_t.paramLen = 1;
client_t.uToken = Global_uToken;
@@ -722,7 +723,6 @@
*/
static int judge_illegal(int list[5], char *path, char *data, char *pin2, char *aidPtr, int sw[2], char *simResponse)
{
- printf("__LINE__:%d\n", __LINE__);
if(list == NULL)
{
return -1;
@@ -777,7 +777,6 @@
int send_num = 0;
int recv_num = 0;
char res_data[MAX_LEN] = {0};
- int len = 0;
client_t.request = RIL_REQUEST_SIM_IO;
client_t.paramLen = 9;
client_t.uToken = Global_uToken;
@@ -797,11 +796,8 @@
Parcel p;
p.setData((uint8_t *)res_data,sizeof(char)*recv_num); // p.setData((uint8_t *) buffer, buflen);
p.setDataPosition(0);
- int num = -1;
if(p.dataAvail() > 0)
- {
- char test[30] = {0};
- char *argv[5] = {0};
+ {
p.readInt32(&resp_type);
p.readInt32(&request);
p.readInt32(&slot_id);
@@ -817,6 +813,65 @@
}
return error1;
}
+
+/**
+ * @brief handle shutdown buf
+ * @param options type: [IN]My Param doc
+ * @param time type: [IN]My Param doc
+ * @param message type: [IN]My Param doc
+ */
+static void handle_shutdown_buf(char options[], char time[], char message[])
+{
+ if(NULL == options)
+ {
+ bzero(options_buf, 32);
+ memcpy(options_buf," ", 1);
+ }
+ else
+ {
+ memcpy(options_buf,options, strlen(options));
+ }
+ if(NULL == time)
+ {
+ bzero(time_buf, 32);
+ memcpy(time_buf," ", 1);
+ }
+ else
+ {
+ memcpy(time_buf, time, strlen(time));
+ }
+ if(NULL == message)
+ {
+ bzero(message_buf, 32);
+ memcpy(message_buf," ", 1);
+ }
+ else
+ {
+ memcpy(message_buf, message, strlen(message));
+ }
+}
+
+int lynq_shutdown(char options[], char time[], char message[])
+{
+ char cmd[128] = {0};
+ handle_shutdown_buf(options, time, message);
+ sprintf(cmd, "%s %s %s %s", "shutdown", options_buf, time_buf, message_buf);
+ system(cmd);
+ return 0;
+}
+
+int lynq_get_version(char buf[])
+{
+ FILE * fp;
+ char buffer[128];
+ sprintf(buffer, "%s", "uci get lynq_uci_ro.lynq_version.LYNQ_SW_VERSION");
+ fp = popen(buffer, "r");
+ fgets(buffer, sizeof(buffer), fp);
+ memcpy(buf, buffer, strlen(buffer));
+ buf[strlen(buffer)] = '\0';
+ pclose(fp);
+ return 0;
+}
#if FLAG_TESS
int lynq_query_operator(char buf[]){
int32_t token = -1;