Add DS support.

Change-Id: Ib8bc4e171dd5ca526f8e151ff3d467097582a8cb
diff --git a/mbtk/mbtk_rild_v2/src/ril_call.c b/mbtk/mbtk_rild_v2/src/ril_call.c
old mode 100644
new mode 100755
index ca80871..fe9d374
--- a/mbtk/mbtk_rild_v2/src/ril_call.c
+++ b/mbtk/mbtk_rild_v2/src/ril_call.c
@@ -17,21 +17,22 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(mbtk_sim_type_enum sim_id, ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port);
 
 /*
 ATDXXXXXXX;
 OK
 
 */
-static int req_call_start(ATPortType_enum port, char *phont_number, int *cme_err)
+static int req_call_start(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *phont_number, int *cme_err)
 {
     ATResponse *response = NULL;
 //    int tmp_int;
 //    char *tmp_str = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "ATD%s;", phont_number);
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -48,10 +49,10 @@
 OK
 
 */
-static int req_answer_call(ATPortType_enum port, int *cme_err)
+static int req_answer_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command(port, "AT+CHLD=2", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "AT+CHLD=2", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -67,10 +68,10 @@
 OK
 
 */
-static int req_hangup_call(ATPortType_enum port, int *cme_err)
+static int req_hangup_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command(port, "ATH", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "ATH", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -86,12 +87,12 @@
 OK
 
 */
-static int req_hangup_a_call(ATPortType_enum port, int phone_id, int *cme_err)
+static int req_hangup_a_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int phone_id, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+CHLD=1%d", phone_id);
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -107,10 +108,10 @@
 OK
 
 */
-static int req_hangup_waiting_or_background_call(ATPortType_enum port, int *cme_err)
+static int req_hangup_waiting_or_background_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command(port, "AT+CHLD=0", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "AT+CHLD=0", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -126,10 +127,10 @@
 OK
 
 */
-static int req_hangup_foreground_resume_background_call(ATPortType_enum port, int *cme_err)
+static int req_hangup_foreground_resume_background_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command(port, "AT+CHLD=1", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "AT+CHLD=1", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -145,13 +146,13 @@
 OK
 
 */
-static int req_waitin_call(ATPortType_enum port, mbtk_call_info_t *reg, int *cme_err)
+static int req_waitin_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_call_info_t *reg, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
     char *tmp_str = NULL;
 
-    int err = at_send_command_multiline(port, "AT+CLCC", "+CLCC:", &response);
+    int err = at_send_command_multiline(portType_2_portId(sim_id, port), "AT+CLCC", "+CLCC:", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -224,11 +225,11 @@
 
 OK
 */
-static int req_mute_get(ATPortType_enum port, int *state, int *cme_err)
+static int req_mute_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
-    int err = at_send_command_singleline(port, "AT+CMUT?", "+CMUT:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CMUT?", "+CMUT:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -258,13 +259,13 @@
 OK
 
 */
-static int req_mute_set(ATPortType_enum port, int state, int *cme_err)
+static int req_mute_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, int state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+CMUT=%d", state);
     LOG("Set the mute command is = %s.\n", cmd);
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -280,13 +281,13 @@
 OK
 
 */
-static int req_dtmf_set(ATPortType_enum port, mbtk_call_dtmf_info_t *state, int *cme_err)
+static int req_dtmf_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_call_dtmf_info_t *state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+VTS=%c,%d", state->character, state->duration);
     LOG("Set the DTMF command is = %s.\n", cmd);
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -297,11 +298,11 @@
     return err;
 }
 
-static int req_centric_get(ATPortType_enum port, int *state, int *cme_err)
+static int req_centric_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int = 0;
-    int err = at_send_command_singleline(port, "AT+CEUS?", "+CEUS:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CEUS?", "+CEUS:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -331,13 +332,13 @@
 OK
 
 */
-static int req_centric_set(ATPortType_enum port, int state, int *cme_err)
+static int req_centric_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, int state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+CEUS=%d", state);
     LOG("Set the centric command is = %s.\n", cmd);
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -367,7 +368,7 @@
             else     // Set
             {
                 char *pn = (char*)(pack->data);
-                if(req_call_start(cli_info->port, pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_call_start(cli_info->sim_id, cli_info->port, pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -378,7 +379,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -387,7 +388,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-               if(req_answer_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+               if(req_answer_call(cli_info->sim_id, cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -398,7 +399,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -412,7 +413,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_call(cli_info->sim_id, cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -423,7 +424,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -443,7 +444,7 @@
             else
             {
                 uint8 phone_id = *(pack->data);
-                if(req_hangup_a_call(cli_info->port, phone_id, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_a_call(cli_info->sim_id, cli_info->port, phone_id, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -454,7 +455,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -463,7 +464,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_waiting_or_background_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_waiting_or_background_call(cli_info->sim_id, cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -474,7 +475,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else
@@ -488,7 +489,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_foreground_resume_background_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_foreground_resume_background_call(cli_info->sim_id, cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -499,7 +500,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else
@@ -515,7 +516,7 @@
             {
                 mbtk_call_info_t reg;
                 memset(&reg, 0, sizeof(mbtk_call_info_t));
-                if(req_waitin_call(cli_info->port, &reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_waitin_call(cli_info->sim_id, cli_info->port, &reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -526,7 +527,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &reg, sizeof(mbtk_call_info_t));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &reg, sizeof(mbtk_call_info_t));
                 }
             }
             else     // Set
@@ -541,7 +542,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_mute_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_mute_get(cli_info->sim_id, cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -552,7 +553,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set mute state.
@@ -565,7 +566,7 @@
                     break;
                 }
 
-                if(req_mute_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_mute_set(cli_info->sim_id, cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -576,7 +577,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -591,7 +592,7 @@
             else     // Set
             {
                 mbtk_call_dtmf_info_t *reg = (mbtk_call_dtmf_info_t *)pack->data;
-                if(req_dtmf_set(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_dtmf_set(cli_info->sim_id, cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -602,7 +603,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -612,7 +613,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_centric_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_centric_get(cli_info->sim_id, cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -623,7 +624,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(int));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(int));
                 }
             }
             else     // Set mute state.
@@ -636,7 +637,7 @@
                     break;
                 }
 
-                if(req_centric_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_centric_set(cli_info->sim_id, cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -647,7 +648,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;