[Feature][T8TSK-289] merge lynq-ril-service from old platform branch

Only Configure: No
Affected branch: LYNQ_PUBLIC
Affected module: ril
Is it affected on both ZXIC and MTK: only MTK
Self-test: No
Doc Update: No

Change-Id: I2f9e2a881259b07369c4049e22736bf0234f57cf
diff --git a/common_src/framework/lynq-ril-service/src/atci/atci_lynq_data_cmd.cpp b/common_src/framework/lynq-ril-service/src/atci/atci_lynq_data_cmd.cpp
index e0b8321..f261dbd 100755
--- a/common_src/framework/lynq-ril-service/src/atci/atci_lynq_data_cmd.cpp
+++ b/common_src/framework/lynq-ril-service/src/atci/atci_lynq_data_cmd.cpp
@@ -10,7 +10,8 @@
 #include <vendor-ril/telephony/ril.h>
 #include <string.h>
 #include <log/log.h>
-
+#include <vector>
+#include "Radio_capability_switch_util.h"
 #include "ATCI.h"
 #include "atci_util.h"
 #include "atci_at_util.h"
@@ -139,6 +140,51 @@
     return SYS_SUCC;
 }
 
+int check_sim_state(void)
+{
+    char buf[16];
+    //send request
+    char* argv[1] = { 0 };
+    argv[0] = "RIL_REQUEST_GET_SIM_STATUS";
+    android::lynqSendToRil(1,argv,1024);
+    //wait response from callback
+    if(lynq_wait_result_comeback(2000))
+    {
+        sprintf(buf,"%s","+CME ERROR: 14");//sim busy
+        if(atci_send_data(buf)!=0)
+        {
+            RLOGD("send data fail");
+            return SYS_FAIL;
+        }
+        RLOGD("[%d][%s] wait sim state timeout",LINE,FUNC);
+        return SYS_FAIL;
+    }
+    //judge result
+    if(g_lynq_sim_state != 1)
+    {
+        RLOGD("SIM card absent");
+        sprintf(buf,"%s","+CME ERROR: 10");
+        if(atci_send_data(buf)!=0)
+        {
+            RLOGD("send data fail");
+            return SYS_FAIL;
+        }
+        return SYS_FAIL;
+    }
+    if(checkDataRegistration(1024))
+    {
+        RLOGD("[%d][%s] data registion fail",LINE,FUNC);
+        sprintf(buf,"%s","+CME ERROR: 1");
+        if(atci_send_data(buf)!=0)
+        {
+            RLOGD("send data fail");
+            return SYS_FAIL;
+        }
+        return SYS_FAIL;
+    }
+    return SYS_SUCC;
+}
+
 int atci_data_enable_pdp_hdlr(char *cmd, int op_mode, int target, char *response)
 {
     int ret;
@@ -174,6 +220,10 @@
 
             if(state==1)
             {
+                if(check_sim_state())
+                {
+                    return SYS_FAIL;
+                }
                 req.request_id = RIL_REQUEST_SETUP_DATA_CALL;
             }
             else if(state == 0)
@@ -204,6 +254,31 @@
             ATCIResponseNoToken(0,buf,RIL_REQUEST_SETUP_DATA_CALL);
             break;
         }
+        case AT_READ_MODE:
+        {
+            for(int i = 0;i < LYNQ_APN_CHANNEL_MAX; i ++)
+            {
+                if(!apn_table[i].used)
+                {
+                    continue;
+                }
+                memset(buf,0,sizeof(buf));
+                sprintf(buf,"+LAPNACT: %s,%s,%d,%s,%s\n", apn_table[i].apn, apn_table[i].apntype ,apn_table[i].pdpstate, apn_table[i].ifaceName, apn_table[i].address);
+                if(atci_send_data(buf)!=0)
+                {
+                    RLOGD("send data fail");
+                    return SYS_FAIL;
+                }
+            }
+            if(apn_count == 0)
+            {
+                memset(buf,0,sizeof(buf));
+                ATCIResponseNoToken(0,buf,RIL_REQUEST_SETUP_DATA_CALL);
+                return SYS_SUCC;
+            }
+            atci_send_result(0);
+            break;
+        }
         default:
         {
             RLOGD("set mute error");
@@ -320,6 +395,10 @@
             atci_data_req_t req;
             if(state==1)
             {
+                if(check_sim_state())
+                {
+                    return SYS_FAIL;
+                }
                 req.request_id = RIL_REQUEST_SETUP_DATA_CALL;
             }
             else if(state == 0)
@@ -357,7 +436,7 @@
                     continue;
                 }
                 memset(buf,0,sizeof(buf));
-                sprintf(buf,"+ELAPNACT:%s,%s,%d,%s,%s\n", apn_table[i].apn, apn_table[i].apntype ,apn_table[i].pdpstate, apn_table[i].ifaceName, apn_table[i].address);
+                sprintf(buf,"+ELAPNACT: %s,%s,%d,%s,%s\n", apn_table[i].apn, apn_table[i].apntype ,apn_table[i].pdpstate, apn_table[i].ifaceName, apn_table[i].address);
                 if(atci_send_data(buf)!=0)
                 {
                     RLOGD("send data fail");
diff --git a/common_src/framework/lynq-ril-service/src/cc.cpp b/common_src/framework/lynq-ril-service/src/cc.cpp
index 953438c..fa06fda 100755
--- a/common_src/framework/lynq-ril-service/src/cc.cpp
+++ b/common_src/framework/lynq-ril-service/src/cc.cpp
@@ -49,6 +49,9 @@
 #include <binder/Parcel.h>
 #include "call_rtp.h"
 #include "liblynq-codec/lynq_codec.h"
+#ifdef LED_SUPPORT
+#include "led.h"
+#endif
 using android::Parcel;
 /*Warren add for t800 ril servie 2021/12/23 end*/
 
diff --git a/common_src/framework/lynq-ril-service/src/common.cpp b/common_src/framework/lynq-ril-service/src/common.cpp
index 2c2cdde..402aad1 100755
--- a/common_src/framework/lynq-ril-service/src/common.cpp
+++ b/common_src/framework/lynq-ril-service/src/common.cpp
@@ -95,6 +95,7 @@
 */
 extern int current_data_reg = -1;
 extern int modemStatus = 0;
+int g_lynq_sim_state = -1;
 
 /*Warren add for SZZT 2021/11/14 end*/
 
@@ -372,22 +373,26 @@
     pthread_mutex_unlock(&s_state_change_mutex);
 }
 
-void lynq_wait_result_comeback(int mtime)
+int lynq_wait_result_comeback(int mtime)
 {
     RLOGD("wait_call_state");
     int sec = 0;
-    int usec = 0;
+    int ms = 0;
     struct timeval now;
     struct timespec timeout;
     gettimeofday(&now,NULL);
     sec = mtime/1000;
-    usec = mtime%1000;
+    ms = mtime%1000;
     timeout.tv_sec = now.tv_sec+sec;
-    timeout.tv_nsec = now.tv_usec*1000+usec*1000000;
+    unsigned long long ns;
+    ns = now.tv_usec*1000ull + ms*1000000ull;
+    timeout.tv_sec += ns/1000000000;
+    timeout.tv_nsec = ns % 1000000000;
     pthread_mutex_lock(&s_state_change_mutex);
-    pthread_cond_timedwait(&s_state_change_cond,&s_state_change_mutex,&timeout);
+    int ret = pthread_cond_timedwait(&s_state_change_cond,&s_state_change_mutex,&timeout);
     pthread_mutex_unlock(&s_state_change_mutex);
     RLOGD("wait_call_state end");
+    return ret;
 }
 
 int get_default_sim_voice(){
@@ -566,6 +571,9 @@
     } else {
         RLOGD("[slot%d]updateCardStatusV6: sim card message is null", slot);
     }
+#ifdef LED_SUPPORT
+    mbtk_netled_state_update(GPIO_NETLED_REFLASH_NORMAL);  
+#endif
 }
 
 char* getAid(int slot)
@@ -592,6 +600,9 @@
         reg_voice_service_state[slot] = atoi(code);
         regCodeToServiceState(request, atoi(code), slot);
     }
+#ifdef LED_SUPPORT
+    mbtk_netled_state_update(GPIO_NETLED_REFLASH_NORMAL);  
+#endif
 }
 
 void update_reg_voice_radio_tech(int request, int code, int slot, int32_t token) {
@@ -611,6 +622,9 @@
         current_data_reg = status;       
         /*Warren change for SZZT 2021//11/14 end*/
     }
+#ifdef LED_SUPPORT
+    mbtk_netled_state_update(GPIO_NETLED_REFLASH_NORMAL);  
+#endif
 }
 
 void update_reg_data_radio_tech(int request, int code, int slot, int32_t token){
@@ -1040,6 +1054,18 @@
     }
     return false;	
 }
+
+bool ril_get_if_3gpp_data_reg_success()
+{
+    int slot_id=get_default_sim_data();
+
+    if(slot_id==0 || slot_id ==1)
+    {
+        return reg_data_service_state[slot_id] ==1;
+    }
+    return false;	
+}
+
 #endif
 /*hq add for key info output 2022/03/01 begin*/
 // void lynq_output_LINFO_all()
diff --git a/common_src/framework/lynq-ril-service/src/common.h b/common_src/framework/lynq-ril-service/src/common.h
index fba62ac..a7f2a6b 100755
--- a/common_src/framework/lynq-ril-service/src/common.h
+++ b/common_src/framework/lynq-ril-service/src/common.h
@@ -153,6 +153,7 @@
 */
 extern int current_data_reg;
 extern int modemStatus;
+extern int g_lynq_sim_state;
 /*Warren add for SZZT 2021/11/14 end*/
 
 // extern int lynq_output_LINFO_enable;
@@ -176,7 +177,7 @@
 void lynq_output_info(const char* format,...);
 
 void lynq_send_result_already(void);
-void lynq_wait_result_comeback(int mtime);
+int lynq_wait_result_comeback(int mtime);
 
 void updateCardStatusV6(RIL_CardStatus_v6 *card_status,int slot);
 char* getAid(int slot);
@@ -211,6 +212,7 @@
 /*for led add by hq 20221202*/
 bool ril_get_if_insert_simcard();
 bool ril_get_if_3gpp_reg_success();
+bool ril_get_if_3gpp_data_reg_success();
 #endif
 
 /*for urc broad cast optimission by hq 20221216*/
diff --git a/common_src/framework/lynq-ril-service/src/data/data_gdbus.cpp b/common_src/framework/lynq-ril-service/src/data/data_gdbus.cpp
index 3ea7719..0136939 100755
--- a/common_src/framework/lynq-ril-service/src/data/data_gdbus.cpp
+++ b/common_src/framework/lynq-ril-service/src/data/data_gdbus.cpp
@@ -147,6 +147,12 @@
                     writeStringToParcel(p,urc_response->ifname);
                     android::LYNQ_RIL_urcBroadcast(p,LYNQ_URC_DATA_CALL_STATUS_IND);
                     RLOGD("removed apn:%s,apntype:%s",apn_table[i].apn,apn_table[i].apntype);
+#ifdef LED_SUPPORT
+                    if(apn_count==0)
+                    {
+                        mbtk_netled_state_update(GPIO_NETLED_PPP_CLOSED);  
+                    }
+#endif
                     break;
                 }
             }
diff --git a/common_src/framework/lynq-ril-service/src/led/include/led.h b/common_src/framework/lynq-ril-service/src/led/include/led.h
new file mode 100755
index 0000000..d8d6508
--- /dev/null
+++ b/common_src/framework/lynq-ril-service/src/led/include/led.h
@@ -0,0 +1,44 @@
+/**

+ * @file led.h

+ * @author hq

+ * @brief 

+ * @version 1.0

+ * @date 2022-11-28

+ * 

+ * @copyright Copyright (c) 2022

+ * 

+ */

+#ifdef LED_SUPPORT 

+#ifndef LED_H

+#define LED_H 1

+

+#define wait_led_update_effective_timer_ms 20

+

+#ifdef __cplusplus

+extern "C" {

+#endif

+

+typedef enum

+{

+    GPIO_NETLED_REFLASH_NORMAL,

+    GPIO_NETLED_CS_CALLING,

+    GPIO_NETLED_CS_CALLEND,

+    GPIO_NETLED_PPP_CONNECT,

+    GPIO_NETLED_PPP_CLOSED,

+    GPIO_NETLED_AP_GOINGSLEEP,

+    GPIO_NETLED_AP_WAKEUP,

+    GPIO_NETLED_WWAN_CONNECT,

+    GPIO_NETLED_WWAN_CLOSED,

+} mbtk_netled_reflash_type;

+

+void mbtk_netled_state_update(mbtk_netled_reflash_type flag);

+

+void mbtk_netled_init();

+

+void mbtk_netled_deinit();

+

+#ifdef __cplusplus

+}

+#endif

+#endif

+#endif

diff --git a/common_src/framework/lynq-ril-service/src/led/led.cpp b/common_src/framework/lynq-ril-service/src/led/led.cpp
index 62e4b11..a252764 100755
--- a/common_src/framework/lynq-ril-service/src/led/led.cpp
+++ b/common_src/framework/lynq-ril-service/src/led/led.cpp
@@ -273,24 +273,25 @@
 

 mbtk_netled_reg_net_status  mbtk_get_reg_net_status(void)

 {

-    mbtk_netled_reg_net_status reg_net_status = NET_REG_FAIL;

-

     if(false  == ril_get_if_insert_simcard())

     {

         RLOGE("ril_get_if_insert_simcard false" );

-        reg_net_status = NET_REG_FAIL;

-        return reg_net_status;

+        return NET_REG_FAIL;

     }

    

     if(true == ril_get_if_3gpp_reg_success())

     {

         RLOGD("ril_get_if_3gpp_reg_success true");

-        reg_net_status = NET_REG_SUCCESS;

-        return reg_net_status;

+        return NET_REG_SUCCESS;

     }

 

-    return reg_net_status;

+    if(true == ril_get_if_3gpp_data_reg_success())

+    {

+        RLOGD("ril_get_if_3gpp_data_reg_success true");

+        return NET_REG_SUCCESS;

+    }	

 

+    return NET_REG_FAIL;

 }

 

 /*=============================================

@@ -504,7 +505,6 @@
 	}

 }

 

-

 /*=============================================

 FUNCTION

     mbtk_netled_reflash_handle

diff --git a/common_src/framework/lynq-ril-service/src/led/led_inner.h b/common_src/framework/lynq-ril-service/src/led/led_inner.h
new file mode 100755
index 0000000..5b0750d
--- /dev/null
+++ b/common_src/framework/lynq-ril-service/src/led/led_inner.h
@@ -0,0 +1,61 @@
+/**

+ * @file led_inner.h

+ * @author hq

+ * @brief 

+ * @version 1.0

+ * @date 2022-11-28

+ * 

+ * @copyright Copyright (c) 2022

+ * 

+ */

+#ifdef LED_SUPPORT 

+#ifndef LED_INNER_H

+#define LED_INNER_H 1

+

+#ifdef __cplusplus

+extern "C" {

+#endif

+

+/*************************************************************

+    Definitions:enum,struct,union,class

+*************************************************************/

+typedef struct {

+    bool gpio_netled_cs_flag;

+    bool gpio_netled_ppp_flag;

+    bool gpio_netled_wwan_flag;

+    bool gpio_netled_goingsleep_flag;

+}mbtk_netled_state_t;

+

+typedef enum

+{

+    GPIO_NETLED_OFF,

+    GPIO_NETLED_REG,

+    GPIO_NETLED_CONNECT,

+    GPIO_NETLED_LIGHT,

+    GPIO_CS_REG,

+    GPIO_NETLED_MAX

+}mbtk_netled_status_type;

+

+typedef enum

+{

+    NET_REG_SUCCESS,

+    NET_REG_FAIL,

+    NET_REG_MAX

+}mbtk_netled_reg_net_status;

+

+typedef enum

+{

+    MBTK_SOCKET_CONNECTED,

+    MBTK_SOCKET_DISCONNECT,

+    MBTK_SOCKET_CONN_MAX

+}mbtk_netled_socket_conn_status;

+

+/*************************************************************

+    Function Declaration

+*************************************************************/

+

+#ifdef __cplusplus

+}

+#endif

+#endif

+#endif

diff --git a/common_src/framework/lynq-ril-service/src/lynq_common.cpp b/common_src/framework/lynq-ril-service/src/lynq_common.cpp
index 418fe86..a5338bc 100755
--- a/common_src/framework/lynq-ril-service/src/lynq_common.cpp
+++ b/common_src/framework/lynq-ril-service/src/lynq_common.cpp
@@ -390,8 +390,11 @@
     char *argv_temp[3]={};
     argv_temp[0] = "RIL_REQUEST_DATA_REGISTRATION_STATE";
     android::lynqSendToRil(1,argv_temp,uToken);
-    ret = lynqATWaitWithTime(10);
-    printf("ret=%d\n,current_data_reg=%d\n",ret,current_data_reg);
+    if(lynqATWaitWithTime(2000))
+    {
+        RLOGD("function %s line %d time out", __FUNCTION__, __LINE__);
+        return -1;
+    }
     /*
     if(ret == ETIMEDOUT)
     {
@@ -405,11 +408,6 @@
     */
     if(current_data_reg!=0)
     {
-        int n = write(ttyGS3_fd,"+CME ERROR: 1\n",strlen("+CME ERROR: 1\n"));
-        if(n<0)
-        {
-            perror("lynq resp write:");
-        }
         return -1;
     }
     return 0;
@@ -887,21 +885,24 @@
     return 0;
 }
 
-int lynqATWaitWithTime(int time)
+int lynqATWaitWithTime(int mtime)
 {
-    int ret = 0;
-    struct timespec start_tm;
-    //struct timespec end_tm;
-    //int timeout_ms = 2500;
-    clock_gettime(CLOCK_MONOTONIC, &start_tm);
-    //struct timeval now;
-    struct timespec outTime;
-    //gettimeofday(&now, NULL);//now.tv_sec(s),now.tv_usec(Micro s)
-    outTime.tv_sec = start_tm.tv_sec + time;
+    RLOGD("wait_call_state");
+    int sec = 0;
+    int usec = 0;
+    struct timeval now;
+    struct timespec outtime;
+    gettimeofday(&now,NULL);
+    sec = mtime/1000;
+    outtime.tv_sec = now.tv_sec+sec;
+    unsigned long long ns;
+    ns = now.tv_usec*1000ull + (mtime%1000)*1000000ull;
+    outtime.tv_sec += ns/1000000000;
+    outtime.tv_nsec = ns%1000000000;
     pthread_mutex_lock(&lynq_at_mutex);
-    //ret = pthread_cond_timedwait(&lynq_at_cond,&lynq_at_mutex,&outTime);
-    pthread_cond_wait(&lynq_at_cond,&lynq_at_mutex);
+    int ret = pthread_cond_timedwait(&lynq_at_cond,&lynq_at_mutex,&outtime);
     pthread_mutex_unlock(&lynq_at_mutex);
+    RLOGD("wait_call_state end");
     return ret;
 }
 void lynqAtRespWatingEvent()
diff --git a/common_src/framework/lynq-ril-service/src/lynq_common.h b/common_src/framework/lynq-ril-service/src/lynq_common.h
index ec1e9e2..16b6403 100755
--- a/common_src/framework/lynq-ril-service/src/lynq_common.h
+++ b/common_src/framework/lynq-ril-service/src/lynq_common.h
@@ -122,4 +122,5 @@
 int lynq_modify_apn_info(int argc,char*argv[],char *rilReq, int uToken);
 void sendSignalApnChange();
 int waitApnResult();
+int checkDataRegistration(int uToken);
 #endif
diff --git a/common_src/framework/lynq-ril-service/src/makefile b/common_src/framework/lynq-ril-service/src/makefile
index 2a07df1..db6b04e 100755
--- a/common_src/framework/lynq-ril-service/src/makefile
+++ b/common_src/framework/lynq-ril-service/src/makefile
@@ -25,6 +25,10 @@
     LOCAL_CFLAGS += -DMODE_DSSS
 endif
 
+ifeq ($(strip $(MTK_LED_SUPPORT)), yes)
+    LOCAL_CFLAGS += -DLED_SUPPORT
+endif
+
 $(warning ################# TARGET_PLATFORM: $(TARGET_PLATFORM))
 ifeq ($(strip $(TARGET_PLATFORM)), mt2731)
 $(warning ################# TARGET_PLATFORM_MT2731)
@@ -40,6 +44,10 @@
 LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2735
 LOCAL_CFLAGS += -DBASELIB_DIR_LIB64 -DTELEMATIC_5G_SUPPORT
 endif
+ifeq ($(strip $(MOBILETEK_RIL_CFG)), GSW)
+    LOCAL_CFLAGS += -DGSW_RIL_CFG
+
+endif
 
 LOCAL_PATH   = .
 
@@ -68,6 +76,7 @@
   -I$(LOCAL_PATH)/factory \
   -I$(LOCAL_PATH)/fota \
   -I$(LOCAL_PATH)/temp \
+  -I$(LOCAL_PATH)/led/include \
   -I$(LOCAL_PATH)/rtp \
   -I$(ROOT)$(includedir)/logger \
   -I$(ROOT)$(includedir)/liblog \
@@ -128,7 +137,7 @@
 endif
 
 
-SOURCES = $(wildcard util/*.cpp *.cpp ecall/*.cpp ecall/gost/*.cpp ecall/gost/utils/*.cpp ecall/gost/sslp/*.cpp ecall/gost/sslp/auth/*.cpp ecall/gost/sslp/firmware/*.cpp ecall/gost/sslp/commands/*.cpp ecall/gost/sslp/ecall/*.cpp ecall/gost/sslp/teledata/*.cpp data/*.cpp  em/rfdesense/*.cpp em/networkinfo/*.cpp em/*.cpp sms/*.cpp sms/gsm/*.cpp sms/cdma/*.cpp atci/*.cpp stateManager/*.cpp sms/lynqSmsManager/*.cpp  rndis/*.cpp factory/*.cpp  temp/*.cpp fota/*.cpp  rtp/*.cpp)
+SOURCES = $(wildcard util/*.cpp *.cpp ecall/*.cpp ecall/gost/*.cpp ecall/gost/utils/*.cpp ecall/gost/sslp/*.cpp ecall/gost/sslp/auth/*.cpp ecall/gost/sslp/firmware/*.cpp ecall/gost/sslp/commands/*.cpp ecall/gost/sslp/ecall/*.cpp ecall/gost/sslp/teledata/*.cpp data/*.cpp  em/rfdesense/*.cpp em/networkinfo/*.cpp em/*.cpp sms/*.cpp sms/gsm/*.cpp sms/cdma/*.cpp atci/*.cpp stateManager/*.cpp sms/lynqSmsManager/*.cpp  rndis/*.cpp factory/*.cpp  temp/*.cpp led/*.cpp fota/*.cpp  rtp/*.cpp)
 
 EXECUTABLE = lynq-ril-service
 
diff --git a/common_src/framework/lynq-ril-service/src/ril.cpp b/common_src/framework/lynq-ril-service/src/ril.cpp
index ecabb01..ef41d33 100755
--- a/common_src/framework/lynq-ril-service/src/ril.cpp
+++ b/common_src/framework/lynq-ril-service/src/ril.cpp
@@ -4177,6 +4177,11 @@
     }
 }
 
+static void lynq_get_sim_state(RIL_CardStatus_v6 *card_status)
+{
+    g_lynq_sim_state = card_status->card_state;
+}
+
 extern "C" void
 RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
     RequestInfo *pRI;
@@ -4361,7 +4366,9 @@
                    if (responselen == sizeof (RIL_CardStatus_v6)) {
                        RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
                        updateCardStatusV6(p_cur, socket_id);
+                       lynq_get_sim_state(p_cur);
                    }
+                   lynq_send_result_already();
                    break;
                }
                case RIL_REQUEST_VOICE_RADIO_TECH:
@@ -5753,6 +5760,9 @@
 
 static void initCoditions()
 {
+#ifdef LED_SUPPORT
+    mbtk_netled_init();
+#endif
     mixer_init();
     lynq_init_rtp();
 
@@ -6276,6 +6286,9 @@
      }
      RLOGD("close socket fd");
      close(server_socket_fd);
+#ifdef LED_SUPPORT
+     mbtk_netled_deinit();
+#endif
      return ;
 }
 int LYNQ_RIL_respSocket(Parcel &p,RIL_Token t)
diff --git a/common_src/framework/lynq-ril-service/src/stateManager/stateManager.cpp b/common_src/framework/lynq-ril-service/src/stateManager/stateManager.cpp
index 9e16b5e..d4f3ce3 100755
--- a/common_src/framework/lynq-ril-service/src/stateManager/stateManager.cpp
+++ b/common_src/framework/lynq-ril-service/src/stateManager/stateManager.cpp
@@ -47,6 +47,9 @@
 #include "util/utils.h"
 #include <cutils/jstring.h>
 #include <liblog/lynq_deflog.h>
+#ifdef LED_SUPPORT
+#include "led.h"
+#endif
 #undef LOG_TAG
 #define LOG_TAG "DEMO_MANAGER"
 
@@ -96,7 +99,13 @@
     size_t pos = p.dataPosition();
 
     p.writeInt32(1);
-    p.writeInt32(atoi(argv[1]));
+
+    int screen_state= atoi(argv[1]);
+    p.writeInt32(screen_state);
+#ifdef LED_SUPPORT
+    mbtk_netled_state_update(screen_state==0 ? GPIO_NETLED_AP_GOINGSLEEP : GPIO_NETLED_AP_WAKEUP);	
+    usleep(wait_led_update_effective_timer_ms*1000);
+#endif
 
     p.setDataPosition(pos);
     pRI->pCI->dispatchFunction(p, pRI);