Merge "[Bugfix][T106BUG-512][POWER]cant create wakelcok repeatly"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq-qser-network-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq-qser-network-demo.cpp
index 3982cbc..ad38820 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq-qser-network-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq-qser-network-demo.cpp
@@ -25,6 +25,10 @@
 int (*qser_nw_get_oos_config_p)(nw_client_handle_type   h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info);

 int (*qser_nw_set_rf_mode_p) (nw_client_handle_type   h_nw,E_QSER_NW_RF_MODE_TYPE_T rf_mode);

 int (*qser_nw_get_rf_mode_p) (nw_client_handle_type   h_nw,E_QSER_NW_RF_MODE_TYPE_T* rf_mode);

+int (*qser_nw_set_ims_enable_p) (nw_client_handle_type h_nw,E_QSER_NW_IMS_MODE_TYPE_T ims_mode);

+int (*qser_nw_get_ims_reg_status_p) (nw_client_handle_type h_nw, QSER_NW_IMS_REG_STATUS_INFO_T *pt_info);

+

+

 

 int getFunc()

 {

@@ -48,10 +52,13 @@
     qser_nw_set_oos_config_p = (int (*)(nw_client_handle_type   h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info))dlsym(handle_network,"qser_nw_set_oos_config");

     qser_nw_set_rf_mode_p = (int (*)(nw_client_handle_type   h_nw, E_QSER_NW_RF_MODE_TYPE_T rf_mode))dlsym(handle_network,"qser_nw_set_rf_mode");

     qser_nw_get_rf_mode_p = (int (*)(nw_client_handle_type   h_nw, E_QSER_NW_RF_MODE_TYPE_T* rf_mode))dlsym(handle_network,"qser_nw_get_rf_mode");

+    qser_nw_set_ims_enable_p = (int (*)(nw_client_handle_type  h_nw, E_QSER_NW_IMS_MODE_TYPE_T ims_mode))dlsym(handle_network,"qser_nw_set_ims_enable");

+    qser_nw_get_ims_reg_status_p = (int (*)(nw_client_handle_type  h_nw, QSER_NW_IMS_REG_STATUS_INFO_T  *pt_info))dlsym(handle_network,"qser_nw_get_ims_reg_status");

         

     if(qser_nw_client_deinit_p==NULL || qser_nw_client_init_p==NULL || qser_nw_set_config_p ==NULL ||

        qser_nw_get_operator_name_p == NULL || qser_nw_get_reg_status_p ==NULL || qser_nw_add_rx_msg_handler_p==NULL ||

-       qser_nw_set_rf_mode_p == NULL || qser_nw_get_rf_mode_p == NULL || qser_nw_get_oos_config_p == NULL || qser_nw_set_oos_config_p == NULL)

+       qser_nw_set_rf_mode_p == NULL || qser_nw_get_rf_mode_p == NULL || qser_nw_get_oos_config_p == NULL || qser_nw_set_oos_config_p == NULL || 

+       qser_nw_set_ims_enable_p == NULL || qser_nw_get_ims_reg_status_p == NULL)

     {

         printf("get func pointer null");

         exit(EXIT_FAILURE);

@@ -91,9 +98,9 @@
     {7,     "qser_nw_get_oos_config"},

     {8,     "qser_nw_set_rf_mode"},

     {9,     "qser_nw_get_rf_mode"},

-    {10,     "qser_nw_client_deinit"},  

- 

-    

+    {10,     "qser_nw_set_ims_enable"},

+    {11,     "qser_nw_get_ims_reg_status"},

+    {12,     "qser_nw_client_deinit"},      

     {-1,    "quit"}

 };

 

@@ -298,7 +305,13 @@
                             ind->hdr_sig_info.io);

                 }

                 break;

-            }        

+            }

+        case NW_IND_IMS_REG_EVENT_IND_FLAG:

+            {

+                printf("Recv event indication : IMS REG EVENT\n");               

+                

+                break;

+            }

         default:

             break;

     }

@@ -439,7 +452,7 @@
                              

                  break;

              }                 

-             case 10://"qser_nw_client_deinit"

+             case 12://"qser_nw_client_deinit"

              {

                  ret = qser_nw_client_deinit_p(h_nw);

                  printf("qser_nw_client_deinit ret = %d\n", ret);

@@ -576,6 +589,28 @@
                  printf("qser_nw_set_rf_mode %d ret = %dn",rf_mode, ret);

                  break;

              }       

+             case 10://"qser_nw_set_ims_enable"

+             {

+                 E_QSER_NW_IMS_MODE_TYPE_T  ims_mode;

+                 printf("please input you want set ims mode (0: off;  1: volte enable \n");

+                 scanf("%d", &ims_mode);

+                 ret = qser_nw_set_ims_enable_p(h_nw, ims_mode);

+                 printf("qser_nw_set_ims_enable %d ret = %dn",ims_mode, ret);

+                 break;

+             }       

+             case 11://"qser_nw_get_ims_reg_status"

+             {

+                 QSER_NW_IMS_REG_STATUS_INFO_T         t_info;

+                 memset(&t_info, 0, sizeof(QSER_NW_IMS_REG_STATUS_INFO_T));

+                 ret = qser_nw_get_ims_reg_status_p(h_nw, &t_info);

+                 printf("qser_nw_get_ims_reg_status ret = %d, detail info:\n", ret);

+                 if(ret == 0)

+                 {

+                     printf("ims_registration: registration_state=%d\n",                          

+                         t_info.registration_state);

+                 }                

+                 break;

+             }                 

              default:

              {

                  show_group_help(&t_nw_test);

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq_qser_network.h b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq_qser_network.h
index bf7781a..56e2ce0 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq_qser_network.h
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq_qser_network.h
@@ -35,6 +35,12 @@
     E_QSER_NW_ROAM_STATE_TYPE_T   roaming_pref;       /**<   Roaming preference.*/
 }QSER_NW_CONFIG_INFO_T;
 
+typedef enum 
+{
+    E_QSER_NW_IMS_MODE_OFF    = 0,     /**<  close ims. */
+    E_QSER_NW_IMS_MODE_VOLTE_ENABLE    = 1,  /**<  support volte. */
+}E_QSER_NW_IMS_MODE_TYPE_T;
+
 /** Configures the OOS (out of service)  settings that define the MCM network interface. */
 #define QSER_NW_OOS_CFG_TYPE_FAST_SCAN          0x00    /**<  fast net scan */
 #define QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN     0x01    /**<  full band scan */
@@ -65,12 +71,13 @@
   } u;
 }QSER_NW_OOS_CONFIG_INFO_T;
 
-
-
 //defined for QSER_NW_EventRegister
 #define     NW_IND_VOICE_REG_EVENT_IND_FLAG               (1 << 0)    /**< msg format : QSER_NW_VOICE_REG_EVENT_IND_T */
 #define     NW_IND_DATA_REG_EVENT_IND_FLAG                (1 << 1)    /**< msg format : QSER_NW_DATA_REG_EVENT_IND_T */ 
 #define     NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG         (1 << 2)    /**< msg format : QSER_NW_SINGNAL_EVENT_IND_T */ 
+//#define     NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG   (1 << 3)    /**< msg format : QL_MCM_NW_CELL_ACCESS_STATE_EVENT_IND_T */ 
+//#define     NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG        (1 << 4)    /**< msg format : QL_MCM_NW_NITZ_TIME_EVENT_IND_T */ 
+#define     NW_IND_IMS_REG_EVENT_IND_FLAG                 (1 << 5)    /**< msg format : NULL */ 
 
 typedef struct 
 {
@@ -209,6 +216,16 @@
     QSER_NW_3GPP2_REG_INFO_T      data_registration_details_3gpp2;        /**<   Data registration details for 3GPP2. */
 }QSER_NW_REG_STATUS_INFO_T;
 
+typedef enum 
+{
+    E_QSER_NW_IMS_SERVICE_NONE     = 0x0000,  /**<  Not registered */
+    E_QSER_NW_IMS_SERVICE_REGISTERED     = 0x0001,  /**<  Registered*/
+}E_QSER_NW_IMS_SERVICE_TYPE_T;
+
+typedef struct 
+{   
+    E_QSER_NW_IMS_SERVICE_TYPE_T      registration_state; /**<   Registration state.*/
+}QSER_NW_IMS_REG_STATUS_INFO_T;
 
 typedef struct 
 {
@@ -305,6 +322,7 @@
  *  NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG : QSER_NW_SINGNAL_EVENT_IND_T
  *  NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG : QSER_NW_CELL_ACCESS_STATE_EVENT_IND_T
  *  NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG : QSER_NW_NITZ_TIME_EVENT_IND_T 
+ *  NW_IND_IMS_REG_EVENT_IND_FLAG : NULL 
  * */
 typedef void (*QSER_NW_RxMsgHandlerFunc_t)(
     nw_client_handle_type h_nw, 
@@ -383,6 +401,12 @@
     QSER_NW_CONFIG_INFO_T     *pt_info 
 );
 
+int qser_nw_set_ims_enable
+(
+    nw_client_handle_type h_nw,
+    E_QSER_NW_IMS_MODE_TYPE_T ims_mode
+);
+
 int qser_nw_set_oos_config
 (
     nw_client_handle_type       h_nw,
@@ -413,6 +437,12 @@
     QSER_NW_REG_STATUS_INFO_T         *pt_info 
 );
 
+int qser_nw_get_ims_reg_status
+(
+    nw_client_handle_type h_nw,
+    QSER_NW_IMS_REG_STATUS_INFO_T *pt_info
+);
+
 int qser_nw_get_signal_strength
 (
     nw_client_handle_type               h_nw,
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/include/lynq_qser_network.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/include/lynq_qser_network.h
index 81aa0c2..dcfb9b7 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/include/lynq_qser_network.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/include/lynq_qser_network.h
@@ -35,6 +35,12 @@
     E_QSER_NW_ROAM_STATE_TYPE_T   roaming_pref;       /**<   Roaming preference.*/
 }QSER_NW_CONFIG_INFO_T;
 
+typedef enum 
+{
+    E_QSER_NW_IMS_MODE_OFF    = 0,     /**<  close ims. */
+    E_QSER_NW_IMS_MODE_VOLTE_ENABLE    = 1,  /**<  support volte. */
+}E_QSER_NW_IMS_MODE_TYPE_T;
+
 /** Configures the OOS (out of service)  settings that define the MCM network interface. */
 #define QSER_NW_OOS_CFG_TYPE_FAST_SCAN          0x00    /**<  fast net scan */
 #define QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN     0x01    /**<  full band scan */
@@ -69,6 +75,9 @@
 #define     NW_IND_VOICE_REG_EVENT_IND_FLAG               (1 << 0)    /**< msg format : QSER_NW_VOICE_REG_EVENT_IND_T */
 #define     NW_IND_DATA_REG_EVENT_IND_FLAG                (1 << 1)    /**< msg format : QSER_NW_DATA_REG_EVENT_IND_T */ 
 #define     NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG         (1 << 2)    /**< msg format : QSER_NW_SINGNAL_EVENT_IND_T */ 
+//#define     NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG   (1 << 3)    /**< msg format : QL_MCM_NW_CELL_ACCESS_STATE_EVENT_IND_T */ 
+//#define     NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG        (1 << 4)    /**< msg format : QL_MCM_NW_NITZ_TIME_EVENT_IND_T */ 
+#define     NW_IND_IMS_REG_EVENT_IND_FLAG                 (1 << 5)    /**< msg format : NULL */ 
 
 typedef struct 
 {
@@ -207,6 +216,16 @@
     QSER_NW_3GPP2_REG_INFO_T      data_registration_details_3gpp2;        /**<   Data registration details for 3GPP2. */
 }QSER_NW_REG_STATUS_INFO_T;
 
+typedef enum 
+{
+    E_QSER_NW_IMS_SERVICE_NONE     = 0x0000,  /**<  Not registered */
+    E_QSER_NW_IMS_SERVICE_REGISTERED     = 0x0001,  /**<  Registered*/
+}E_QSER_NW_IMS_SERVICE_TYPE_T;
+
+typedef struct 
+{   
+    E_QSER_NW_IMS_SERVICE_TYPE_T      registration_state; /**<   Registration state.*/
+}QSER_NW_IMS_REG_STATUS_INFO_T;
 
 typedef struct 
 {
@@ -303,6 +322,7 @@
  *  NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG : QSER_NW_SINGNAL_EVENT_IND_T
  *  NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG : QSER_NW_CELL_ACCESS_STATE_EVENT_IND_T
  *  NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG : QSER_NW_NITZ_TIME_EVENT_IND_T 
+ *  NW_IND_IMS_REG_EVENT_IND_FLAG : NULL 
  * */
 typedef void (*QSER_NW_RxMsgHandlerFunc_t)(
     nw_client_handle_type h_nw, 
@@ -371,7 +391,6 @@
     E_QSER_NW_RF_MODE_FLIGHT = 4,    /**<  Flight Mode, CFUN 4. */
 }E_QSER_NW_RF_MODE_TYPE_T;
 
-
 int qser_nw_client_init(nw_client_handle_type  *ph_nw);
 
 int qser_nw_client_deinit(nw_client_handle_type  h_nw);
@@ -382,6 +401,12 @@
     QSER_NW_CONFIG_INFO_T     *pt_info 
 );
 
+int qser_nw_set_ims_enable
+(
+    nw_client_handle_type h_nw,
+    E_QSER_NW_IMS_MODE_TYPE_T ims_mode
+);
+
 int qser_nw_set_oos_config
 (
     nw_client_handle_type       h_nw,
@@ -412,6 +437,12 @@
     QSER_NW_REG_STATUS_INFO_T         *pt_info 
 );
 
+int qser_nw_get_ims_reg_status
+(
+    nw_client_handle_type h_nw,
+    QSER_NW_IMS_REG_STATUS_INFO_T *pt_info
+);
+
 int qser_nw_get_signal_strength
 (
     nw_client_handle_type               h_nw,
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
index d75c23b..86f3ed6 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
@@ -116,6 +116,13 @@
     }  
 }
 
+void urc_msg_process_ims_reg()
+{
+    if(s_handlerPtr!=NULL)
+    {
+        s_handlerPtr(g_ph_hw,NW_IND_IMS_REG_EVENT_IND_FLAG,NULL,0,s_contextPtr);
+    }
+}
 
 void urc_msg_process_signal_strength()
 {
@@ -182,6 +189,11 @@
                 urc_msg_process_signal_strength();
                 break;
             }
+            case 1037://RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:
+            {   
+                urc_msg_process_ims_reg();
+                break;
+            }
         }        
     }
     return NULL;
@@ -226,6 +238,9 @@
         LYINFLOG("pthread join waiting urc thread ret = %d",ret);
         s_new_network_tid =-1;
     }
+	
+    s_handlerPtr=NULL;
+    s_contextPtr=NULL;
 
     ret=lynq_network_deinit();
     
@@ -271,6 +286,24 @@
     return RESULT_OK;
 }
 
+int qser_nw_set_ims_enable(nw_client_handle_type h_nw,E_QSER_NW_IMS_MODE_TYPE_T ims_mode)
+{ 
+    if(h_nw != g_ph_hw || h_nw == INVALID_CLIENT_HANDLE)
+    {
+        LYERRLOG("h_nw not right %d %d",h_nw,g_ph_hw);
+        return RESULT_ERROR;
+    }          
+    
+    int ret = lynq_set_ims(ims_mode);
+    if (ret != RESULT_OK)
+    {
+        LYERRLOG("lynq_set_ims failed ret is %d",ret);
+        return RESULT_ERROR;
+    }
+    return RESULT_OK;
+}
+
+
 int qser_nw_set_oos_config(    nw_client_handle_type       h_nw,QSER_NW_OOS_CONFIG_INFO_T     *pt_info
 )
 {
@@ -632,6 +665,43 @@
     return RESULT_OK;
 }
 
+int qser_nw_get_ims_reg_status(nw_client_handle_type h_nw, QSER_NW_IMS_REG_STATUS_INFO_T *pt_info)
+{
+    if(NULL == pt_info)
+    {
+        LYERRLOG("invalid client parameters incoming");
+        return RESULT_ERROR;
+    }
+
+    if(h_nw != g_ph_hw || h_nw == INVALID_CLIENT_HANDLE)
+    {
+        LYERRLOG("h_nw not right %d %d",h_nw,g_ph_hw);
+        return RESULT_ERROR;
+    }    
+    
+    int ret = 0;   
+    int regState = 0;
+    int imsRegState = 0;
+    char CID[128]={0};
+    char LAC[128]={0};
+    int netType = 0;
+    int radioTechFam = 0;
+    int netreject = 0;
+        
+
+    ret = lynq_query_registration_state("IMS",&regState,&imsRegState,LAC,CID,&netType,&radioTechFam,&netreject);
+    if(ret!=0)
+    {
+        LYERRLOG("get ims regstate fail ret is %d", ret);         
+    }
+    else {    
+        pt_info->registration_state = imsRegState;        
+    }    
+       
+    return ret;
+}
+
+
 int qser_nw_setlowpowermode(nw_client_handle_type h_nw,uint32_t low_power_mode_on)
 {
     if(h_nw == 0)
@@ -708,6 +778,7 @@
             LYDBGLOG("%s pthread_create error!!!",__func__);
             s_handlerPtr=NULL;
             s_contextPtr=NULL;
+            s_new_network_tid=-1;
             return RESULT_ERROR;
         }
     }