Add ril v2 support.

Change-Id: I14f4d5f3650f0d397c38a72e8bea2600c17b07de
diff --git a/mbtk/libmbtk_lib_v2/ril/mbtk_ril.h b/mbtk/libmbtk_lib_v2/ril/mbtk_ril.h
index 04b5623..b8b21b5 100755
--- a/mbtk/libmbtk_lib_v2/ril/mbtk_ril.h
+++ b/mbtk/libmbtk_lib_v2/ril/mbtk_ril.h
@@ -13,6 +13,10 @@
 #define RIL_SOCK_NAME "/tmp/mbtk_ril_sock"
 #define RIL_SOCK_MSG_LEN_MAX (1024 * 6)
 
+#define IND_REGISTER_MAX 20
+#define PACK_PROCESS_QUEUE_MAX 20
+
+
 // Tag(4) + Packet_Length(2)
 #define RIL_SOCK_PACK_EXTRA_LEN 6
 // RIL_SOCK_PACK_EXTRA_LEN + Index(2) + Type(2) + Id(2) + Error(2) + data_len(2)
@@ -31,7 +35,7 @@
 typedef enum
 {
     // Device Information
-    RIL_MSG_ID_DEV_BEGIN = 0,
+    RIL_MSG_ID_DEV_BEGIN = 0x0,
     // <string> IMEI
     RIL_MSG_ID_DEV_IMEI,
     // <string> SN
@@ -54,7 +58,7 @@
     RIL_MSG_ID_DEV_END,
 
     // Sim Information
-    RIL_MSG_ID_SIM_BEGIN = 1000,
+    RIL_MSG_ID_SIM_BEGIN = 0x100,
     // <uint8> 0:NOT_EXIST 1:READY ...
     RIL_MSG_ID_SIM_STATE,
     // <uint8> 0: SIM 1: USIM 2: TEST SIM 3: TEST USIM 4: UNKNOWN
@@ -75,7 +79,7 @@
     RIL_MSG_ID_SIM_END,
 
     // Network Information
-    RIL_MSG_ID_NET_BEGIN = 2000,
+    RIL_MSG_ID_NET_BEGIN = 0x200,
     // sel_mode(uint8)type(uint8)plmn(uint32)...sel_mode(uint8)type(uint8)plmn(uint32)
     RIL_MSG_ID_NET_AVAILABLE,
     // <uint8> 0: automatic 1: manual
@@ -90,8 +94,14 @@
     RIL_MSG_ID_NET_REG,
     // mbtk_cell_info_t[]
     RIL_MSG_ID_NET_CELL,
+
+    RIL_MSG_ID_NET_END,
+
+
+    // Network Information
+    RIL_MSG_ID_DATA_CALL_BEGIN = 0x300,
     // mbtk_apn_info_t
-    RIL_MSG_ID_NET_APN,
+    RIL_MSG_ID_DATA_CALL_APN,
     // REQ:
     // <call_type[1]><cid[1]><timeout[1]>
     //  call_type : mbtk_data_call_type_enum
@@ -102,13 +112,13 @@
     //  type : 0-IPV4   1-IPV6  2-IPV4V6
     //  ipv4 : mbtk_ipv4_info_t
     //  ipv6 : mbtk_ipv6_info_t
-    RIL_MSG_ID_NET_DATA_CALL,
+    RIL_MSG_ID_DATA_CALL_OPT,
 
-    RIL_MSG_ID_NET_END,
+    RIL_MSG_ID_DATA_CALL_END,
 
 
     // Call Information
-    RIL_MSG_ID_CALL_BEGIN = 3000,
+    RIL_MSG_ID_CALL_BEGIN = 0x400,
     RIL_MSG_ID_CALL_STATE,
 
     // Start call.
@@ -132,7 +142,7 @@
     RIL_MSG_ID_CALL_END,
 
     // SMS Information
-    RIL_MSG_ID_SMS_BEGIN = 4000,
+    RIL_MSG_ID_SMS_BEGIN = 0x500,
     RIL_MSG_ID_SMS_STATE,
     RIL_MSG_ID_SMS_CMGF,
     RIL_MSG_ID_SMS_CPMS,
@@ -150,33 +160,71 @@
     RIL_MSG_ID_SMS_END,
 
     // PhoneBook Information
-    RIL_MSG_ID_PB_BEGIN = 5000,
+    RIL_MSG_ID_PB_BEGIN = 0x600,
     RIL_MSG_ID_PB_STATE,
 
     RIL_MSG_ID_PB_END,
 
-    // IND Information
-    RIL_MSG_ID_IND_BEGIN = 10000,
+    // Ecall Information
+    RIL_MSG_ID_ECALL_BEGIN = 0x700,
+    // mbtk_ecall_msd_cfg_info_t
+    RIL_MSG_ID_ECALL_MSDCFG,
     // NULL
-    RIL_MSG_ID_IND_SER_READY,
-    // <uint8>  State
-    RIL_MSG_ID_IND_NET_STATE_CHANGE,
+    RIL_MSG_ID_ECALL_MSDGEN,
+    // uint8[]
+    RIL_MSG_ID_ECALL_MSD,
+    // NULL
+    RIL_MSG_ID_ECALL_PUSH,
+    // mbtk_ecall_only_info_t
+    RIL_MSG_ID_ECALL_ONLY,
+    // reg <uint8>
+    RIL_MSG_ID_ECALL_REG,
+    // mbtk_ecall_dial_type_enum
+    RIL_MSG_ID_ECALL_DIAL,
+    // mbtk_ecall_mode_type_enum
+    RIL_MSG_ID_ECALL_MODE,
+    // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t
+    RIL_MSG_ID_ECALL_CFG,
+    // uint8[]
+    RIL_MSG_ID_ECALL_SMS_NUM,
+    // uint8
+    RIL_MSG_ID_ECALL_MUTESPK,
+    // mbtk_ecall_gain_info_t
+    RIL_MSG_ID_ECALL_DSP_GAIN,
+
+    RIL_MSG_ID_ECALL_END,
+
+    // IND Information
+    RIL_MSG_ID_IND_BEGIN = 0x1000,
+    // mbtk_ril_ser_state_enum
+    RIL_MSG_ID_IND_SER_STATE_CHANGE,
+    // mbtk_ril_net_reg_state_info_t
+    RIL_MSG_ID_IND_NET_REG_STATE_CHANGE,
     // <uint8>  State
     RIL_MSG_ID_IND_CALL_STATE_CHANGE,
     // <uint8>  State
     RIL_MSG_ID_IND_SMS_STATE_CHANGE,
-    // <uint8>  State
+    // mbtk_ril_radio_state_info_t
     RIL_MSG_ID_IND_RADIO_STATE_CHANGE,
-    // <uint8>  State
+    // mbtk_ril_sim_state_info_t
     RIL_MSG_ID_IND_SIM_STATE_CHANGE,
-    // <uint8>  State
+    // mbtk_ril_pdp_state_info_t
     RIL_MSG_ID_IND_PDP_STATE_CHANGE,
-    // <uint8> State
+    // mbtk_ril_signal_state_info_t
     RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE,
+    // mbtk_ril_ecall_state_info_t
+    RIL_MSG_ID_IND_ECALL_STATE_CHANGE,
 
 
     RIL_MSG_ID_IND_END,
-    RIL_MSG_ID_UNKNOWN        // Unknown information.
+
+    // URC message
+    RIL_URC_MSG_BEGIN = 0x2000,
+    RIL_URC_MSG_GET_SIM_STATE,     //check sim status
+    RIL_URC_MSG_NET_STATE_LOG,      // Save Network state into file.
+    RIL_URC_MSG_END,
+
+    RIL_MSG_ID_UNKNOWN = 0xFFFF        // Unknown information.
 } ril_msg_id_enum;
 
 typedef struct {
diff --git a/mbtk/libmbtk_lib_v2/ril/mbtk_ril_api.c b/mbtk/libmbtk_lib_v2/ril/mbtk_ril_api.c
index 93efd84..b6b61ca 100755
--- a/mbtk/libmbtk_lib_v2/ril/mbtk_ril_api.c
+++ b/mbtk/libmbtk_lib_v2/ril/mbtk_ril_api.c
@@ -21,6 +21,7 @@
     int cli_fd;
     bool ril_ready;
     int exit_fd[2];
+    mbtk_ril_callback_func cb[IND_REGISTER_MAX];
     pthread_t read_thread_id;
     pthread_mutex_t send_mutex;
     list_node_t* msg_list;           // ril_msg_info_t
@@ -110,13 +111,24 @@
 
 static int ril_ind_process(ril_msg_pack_info_t* pack)
 {
+    LOGD("IND - %d", id2str(pack->msg_id));
+    if(pack->msg_id > RIL_MSG_ID_IND_BEGIN && pack->msg_id < RIL_MSG_ID_IND_END) {
+        if(ril_cli.cb[pack->msg_id - RIL_MSG_ID_IND_BEGIN - 1])
+            ril_cli.cb[pack->msg_id - RIL_MSG_ID_IND_BEGIN - 1](pack->data, pack->data_len);
+    }
+
     switch(pack->msg_id) {
-        case RIL_MSG_ID_IND_SER_READY: // rild service ready.
+        case RIL_MSG_ID_IND_SER_STATE_CHANGE: // rild service ready.
         {
-            ril_cli.ril_ready = TRUE;
+            if(pack->data && pack->data_len > 0) {
+                mbtk_ril_ser_state_enum state = (mbtk_ril_ser_state_enum)pack->data[0];
+                if(state == MBTK_RIL_SER_STATE_READY) {
+                    ril_cli.ril_ready = TRUE;
+                }
+            }
             return 0;
         }
-        case RIL_MSG_ID_IND_NET_STATE_CHANGE:
+        case RIL_MSG_ID_IND_NET_REG_STATE_CHANGE:
         {
             return 0;
         }
@@ -255,6 +267,10 @@
                 if(epoll_events[i].events & EPOLLHUP)   // Closed by server.
                 {
                     LOGD("Closed by server.");
+                    if(ril_cli.cb[RIL_MSG_ID_IND_SER_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1]) {
+                        mbtk_ril_ser_state_enum state = MBTK_RIL_SER_STATE_EXIT;
+                        ril_cli.cb[RIL_MSG_ID_IND_SER_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1](&state, 1);
+                    }
                     goto read_thread_exit;
                 }
                 else if(epoll_events[i].events & EPOLLIN)
@@ -1256,7 +1272,7 @@
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_APN, NULL, 0, apns, FALSE);
+    return ril_req_process(RIL_MSG_ID_DATA_CALL_APN, NULL, 0, apns, FALSE);
 }
 
 
@@ -1286,14 +1302,15 @@
         }
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_APN, apn, sizeof(mbtk_apn_info_t), NULL, FALSE);
+    return ril_req_process(RIL_MSG_ID_DATA_CALL_APN, apn, sizeof(mbtk_apn_info_t), NULL, FALSE);
 }
 
 /*
 * Start data call.
 */
 mbtk_ril_err_enum mbtk_data_call_start(mbtk_ril_cid_enum cid, bool auto_boot_call,
-            bool def_route, bool as_dns, int retry_interval, int timeout, mbtk_ip_info_t *rsp_info)
+            bool def_route, bool as_dns, int *retry_interval, int retry_interval_num,
+            int timeout, mbtk_ip_info_t *rsp_info)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1311,12 +1328,18 @@
     info.auto_boot_call = (uint8)auto_boot_call;
     info.def_route = (uint8)def_route;
     info.as_dns = (uint8)as_dns;
-    info.retry_interval = (uint16)retry_interval;
+    int i = 0;
+    while(i < retry_interval_num && i < RIL_DATA_CALL_RETRY_MAX) {
+        info.retry_interval[i] = (uint16)retry_interval[i];
+        i++;
+    }
     if(timeout > 0) {
         info.timeout = (uint16)timeout;
+    } else {
+        info.timeout = (uint16)10;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_DATA_CALL, &info, sizeof(mbtk_data_call_info_t), rsp_info, FALSE);
+    return ril_req_process(RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), rsp_info, FALSE);
 }
 
 /*
@@ -1340,7 +1363,7 @@
     if(timeout > 0) {
         info.timeout = (uint16)timeout;
     }
-    return ril_req_process(RIL_MSG_ID_NET_DATA_CALL, &info, sizeof(mbtk_data_call_info_t), NULL, FALSE);
+    return ril_req_process(RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), NULL, FALSE);
 }
 
 /*
@@ -1368,7 +1391,7 @@
     info.type = MBTK_DATA_CALL_STATE;
     info.cid = cid;
 
-    return ril_req_process(RIL_MSG_ID_NET_DATA_CALL, &info, sizeof(mbtk_data_call_info_t), ip, FALSE);
+    return ril_req_process(RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), ip, FALSE);
 }
 
 /*
@@ -2108,6 +2131,344 @@
     return ril_req_process(RIL_MSG_ID_CALL_DTMF, dtmf_character, sizeof(mbtk_call_dtmf_info_t), NULL, FALSE);
 }
 
+/*
+* Set msd item.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_msd_item_set(const mbtk_ecall_msd_cfg_info_t *msd_cfg)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(msd_cfg == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_MSDCFG, msd_cfg, sizeof(mbtk_ecall_msd_cfg_info_t), NULL, FALSE);
+}
+
+/*
+* Generate msd after msd item set.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_msd_gen()
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_MSDGEN, NULL, 0, NULL, FALSE);
+}
+
+/*
+* Set ecall msd.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_msd_set(const void* msd)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(str_empty(msd))
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_MSD, msd, strlen(msd), NULL, FALSE);
+}
+
+/*
+* Get ecall msd.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_msd_get(void* msd)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(msd == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_MSD, NULL, 0, msd, FALSE);
+}
+
+
+/*
+* Set ecall msd item.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_push()
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_PUSH, NULL, 0, NULL, FALSE);
+}
+
+/*
+* Set ecall only configs.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_only_set(const mbtk_ecall_only_info_t* info)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(info == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_ONLY, info, sizeof(mbtk_ecall_only_info_t), NULL, FALSE);
+}
+
+/*
+* Get ecall only configs.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_only_get(mbtk_ecall_only_info_t* info)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(info == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_ONLY, NULL, 0, info, FALSE);
+}
+
+/*
+* Set ecall network reg.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_reg_set(int reg)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(reg != 0 && reg != 1)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+    return ril_req_process(RIL_MSG_ID_ECALL_REG, &reg, 1, NULL, FALSE);
+}
+
+/*
+* Start ecall dial start.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_dial_start(mbtk_ecall_dial_type_enum type)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_DIAL, &type, 1, NULL, FALSE);
+}
+
+/*
+* Get ecall dial state.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_dial_state_get(mbtk_ecall_dial_type_enum* type)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(type == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+    memset(type, 0, sizeof(mbtk_ecall_dial_type_enum));
+
+    return ril_req_process(RIL_MSG_ID_ECALL_DIAL, NULL, 0, type, FALSE);
+}
+
+/*
+* Set ecall mode.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_mode_set(mbtk_ecall_mode_type_enum mode)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_MODE, &mode, 1, NULL, FALSE);
+}
+
+/*
+* Get ecall mode.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_mode_get(mbtk_ecall_mode_type_enum *mode)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(mode == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+    memset(mode, 0, sizeof(mbtk_ecall_mode_type_enum));
+
+    return ril_req_process(RIL_MSG_ID_ECALL_MODE, NULL, 0, mode, FALSE);
+}
+
+/*
+* Set ecall configs.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_cfg_set(const mbtk_ecall_cfg_info_t *cfg)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(cfg == NULL || cfg->type >= MBTK_ECALL_CFG_ITEM_MAX)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_CFG, cfg, sizeof(mbtk_ecall_cfg_info_t), NULL, FALSE);
+}
+
+/*
+* Get ecall configs.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_cfg_get(mbtk_ecall_cfg_info_t* cfg)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(cfg == NULL || cfg->type >= MBTK_ECALL_CFG_ITEM_MAX)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+    mbtk_ecall_cfg_item_enum type = cfg->type;
+
+    return ril_req_process(RIL_MSG_ID_ECALL_CFG, &type, 1, cfg, FALSE);
+}
+
+/*
+* Set ecall sms number.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_sms_number_set(const void *number)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(str_empty(number))
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_SMS_NUM, number, strlen(number), NULL, FALSE);
+}
+
+/*
+* Get ecall sms number.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_sms_number_get(void *number)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(number == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_SMS_NUM, NULL, 0, number, FALSE);
+}
+
+/*
+* Set ecall mute speaker.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_mute_spk_set(int mute)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(mute != 0 && mute != 1)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_MUTESPK, &mute, 1, NULL, FALSE);
+}
+
+/*
+* Set ecall dsp gain.
+*
+*/
+mbtk_ril_err_enum mbtk_ecall_dsp_gain_set(const mbtk_ecall_gain_info_t *gain_info)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(gain_info == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    return ril_req_process(RIL_MSG_ID_ECALL_DSP_GAIN, gain_info, sizeof(mbtk_ecall_gain_info_t), NULL, FALSE);
+}
 
 #if 0
 /*
@@ -2156,151 +2517,163 @@
 
 #endif
 
-#if 0
 /*
-* Set pdp state change callback function.
+* Set ril server state change callback function.
 */
-int mbtk_pdp_state_change_cb_reg(mbtk_info_handle_t* handle, mbtk_info_callback_func cb)
+int mbtk_ril_ser_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
-    if(handle == NULL)
+    if(!ril_cli.ril_ready)
     {
-        LOGE("ARG error.");
-        return -1;
+        return MBTK_RIL_ERR_NOT_INIT;
     }
-    if(info_item_process(handle, MBTK_INFO_ID_IND_PDP_STATE_CHANGE, NULL, 0, NULL) < 0)
+
+    int ret = ril_req_process(RIL_MSG_ID_IND_SER_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        return handle->info_err;
+        ril_cli.cb[RIL_MSG_ID_IND_SER_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
-    else
-    {
-        handle->pdp_state_cb = cb;
-        return 0;
-    }
+    return ret;
 }
 
 /*
-* Set network state change callback function.
+* Set net reg state change callback function.
 */
-int mbtk_net_state_change_cb_reg(mbtk_info_handle_t* handle, mbtk_info_callback_func cb)
+int mbtk_net_reg_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
-    if(handle == NULL)
+    if(!ril_cli.ril_ready)
     {
-        LOGE("ARG error.");
-        return -1;
+        return MBTK_RIL_ERR_NOT_INIT;
     }
-    if(info_item_process(handle, MBTK_INFO_ID_IND_NET_STATE_CHANGE, NULL, 0, NULL) < 0)
+
+    int ret = ril_req_process(RIL_MSG_ID_IND_NET_REG_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        return handle->info_err;
+        ril_cli.cb[RIL_MSG_ID_IND_NET_REG_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
-    else
-    {
-        handle->net_state_cb = cb;
-        return 0;
-    }
+    return ret;
 }
 
 /*
 * Set call state change callback function.
 */
-int mbtk_call_state_change_cb_reg(mbtk_info_handle_t* handle, mbtk_info_callback_func cb)
+int mbtk_call_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
-    if(handle == NULL)
+    if(!ril_cli.ril_ready)
     {
-        LOGE("ARG error.");
-        return -1;
+        return MBTK_RIL_ERR_NOT_INIT;
     }
-    if(info_item_process(handle, MBTK_INFO_ID_IND_CALL_STATE_CHANGE, NULL, 0, NULL) < 0)
+
+    int ret = ril_req_process(RIL_MSG_ID_IND_CALL_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        return handle->info_err;
+        ril_cli.cb[RIL_MSG_ID_IND_CALL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
-    else
-    {
-        handle->call_state_cb = cb;
-        return 0;
-    }
+    return ret;
 }
 
 /*
 * Set sms state change callback function.
 */
-int mbtk_sms_state_change_cb_reg(mbtk_info_handle_t* handle, mbtk_info_callback_func cb)
+int mbtk_sms_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
-    if(handle == NULL)
+    if(!ril_cli.ril_ready)
     {
-        LOGE("ARG error.");
-        return -1;
+        return MBTK_RIL_ERR_NOT_INIT;
     }
-    if(info_item_process(handle, MBTK_INFO_ID_IND_SMS_STATE_CHANGE, NULL, 0, NULL) < 0)
+
+    int ret = ril_req_process(RIL_MSG_ID_IND_SMS_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        return handle->info_err;
+        ril_cli.cb[RIL_MSG_ID_IND_SMS_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
-    else
-    {
-        handle->sms_state_cb = cb;
-        return 0;
-    }
+    return ret;
 }
 
 /*
 * Set radio state change callback function.
 */
-int mbtk_radio_state_change_cb_reg(mbtk_info_handle_t* handle, mbtk_info_callback_func cb)
+int mbtk_radio_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
-    if(handle == NULL)
+    if(!ril_cli.ril_ready)
     {
-        LOGE("ARG error.");
-        return -1;
+        return MBTK_RIL_ERR_NOT_INIT;
     }
-    if(info_item_process(handle, MBTK_INFO_ID_IND_RADIO_STATE_CHANGE, NULL, 0, NULL) < 0)
+
+    int ret = ril_req_process(RIL_MSG_ID_IND_RADIO_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        return handle->info_err;
+        ril_cli.cb[RIL_MSG_ID_IND_RADIO_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
-    else
-    {
-        handle->radio_state_cb = cb;
-        return 0;
-    }
+    return ret;
 }
 
 /*
 * Set sim state change callback function.
 */
-int mbtk_sim_state_change_cb_reg(mbtk_info_handle_t* handle, mbtk_info_callback_func cb)
+int mbtk_sim_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
-    if(handle == NULL)
+    if(!ril_cli.ril_ready)
     {
-        LOGE("ARG error.");
-        return -1;
+        return MBTK_RIL_ERR_NOT_INIT;
     }
-    if(info_item_process(handle, MBTK_INFO_ID_IND_SIM_STATE_CHANGE, NULL, 0, NULL) < 0)
+
+    int ret = ril_req_process(RIL_MSG_ID_IND_SIM_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        return handle->info_err;
+        ril_cli.cb[RIL_MSG_ID_IND_SIM_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
-    else
+    return ret;
+}
+
+/*
+* Set pdp state change callback function.
+*/
+int mbtk_pdp_state_change_cb_reg(mbtk_ril_callback_func cb)
+{
+    if(!ril_cli.ril_ready)
     {
-        handle->sim_state_cb = cb;
-        return 0;
+        return MBTK_RIL_ERR_NOT_INIT;
     }
+
+    int ret = ril_req_process(RIL_MSG_ID_IND_PDP_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(MBTK_RIL_ERR_SUCCESS == ret)
+    {
+        ril_cli.cb[RIL_MSG_ID_IND_PDP_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
+    }
+    return ret;
 }
 
 /*
 * Set signal state change callback function.
 */
-int mbtk_signal_state_change_cb_reg(mbtk_info_handle_t* handle, mbtk_info_callback_func cb)
+int mbtk_signal_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
-    if(handle == NULL)
+    if(!ril_cli.ril_ready)
     {
-        LOGE("ARG error.");
-        return -1;
+        return MBTK_RIL_ERR_NOT_INIT;
     }
-    if(info_item_process(handle, MBTK_INFO_ID_IND_SIGNAL_STATE_CHANGE, NULL, 0, NULL) < 0)
+
+    int ret = ril_req_process(RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        return handle->info_err;
+        ril_cli.cb[RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
-    else
-    {
-        handle->signal_state_cb = cb;
-        return 0;
-    }
+    return ret;
 }
-#endif
+
+int mbtk_ecall_state_change_cb_reg(mbtk_ril_callback_func cb)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    int ret = ril_req_process(RIL_MSG_ID_IND_ECALL_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(MBTK_RIL_ERR_SUCCESS == ret)
+    {
+        ril_cli.cb[RIL_MSG_ID_IND_ECALL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
+    }
+    return ret;
+}
+
+
diff --git a/mbtk/libmbtk_lib_v2/ril/ril_utils.c b/mbtk/libmbtk_lib_v2/ril/ril_utils.c
index f71b2dd..371275d 100755
--- a/mbtk/libmbtk_lib_v2/ril/ril_utils.c
+++ b/mbtk/libmbtk_lib_v2/ril/ril_utils.c
@@ -258,12 +258,12 @@
         case RIL_MSG_ID_NET_REG:
             return "NET_REG";
         // <string> cmnet/ctnet/3gnet/...
-        case RIL_MSG_ID_NET_APN:
+        case RIL_MSG_ID_DATA_CALL_APN:
             return "APN";
         // Lock net/cell/frequency
         case RIL_MSG_ID_NET_CELL:
             return "NET_CELL";
-        case RIL_MSG_ID_NET_DATA_CALL:
+        case RIL_MSG_ID_DATA_CALL_OPT:
             return "DATA_CALL";
         // Call Information
         case RIL_MSG_ID_CALL_STATE:
@@ -279,8 +279,8 @@
         case RIL_MSG_ID_IND_SER_READY:
             return "IND_SER_READY";
         // <uint8>  State
-        case RIL_MSG_ID_IND_NET_STATE_CHANGE:
-            return "IND_NET_STATE";
+        case RIL_MSG_ID_IND_NET_REG_STATE_CHANGE:
+            return "IND_NET_REG_STATE";
         // <uint8>  State
         case RIL_MSG_ID_IND_CALL_STATE_CHANGE:
             return "IND_CALL_STATE";