[feature] voice call audio interface

Change-Id: I3429a426c07f1cd082ffff2855dbda05cb22373f
diff --git a/framework/lynq-ril-service/src/cc.cpp b/framework/lynq-ril-service/src/cc.cpp
index f212ff7..09456b8 100755
--- a/framework/lynq-ril-service/src/cc.cpp
+++ b/framework/lynq-ril-service/src/cc.cpp
@@ -776,17 +776,17 @@
 
 int inCallRecord(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
 {
+     android::Parcel p;
     int recordEnable = 0;
     char* filepath = NULL;
     if(inCallstatus == CALL_OFF || speechStatus == SPEECH_OFF) {
         RLOGW("[warning],not in calling status. Can't do record!");
-        return 0;
+        goto FAIL_RETURN;
     }
 
-    if(argc < 3) {
-        free(pRI);
+    if(argc < 3) {   
         RLOGW("[error],inCallRecord parameter error!");
-        return 0;
+        goto FAIL_RETURN;
     }
 
     recordEnable = atoi(argv[1]) ? 1 : 0;
@@ -802,20 +802,31 @@
        }else{
             inCallRecordMode = 0;
             RLOGW("[error],inCallRecord Start fail!");
+            goto FAIL_RETURN;
       }
     } else { //disable record
         if (inCallRecordMode == 1) {
-            if(!(-1 != GSM_Stop() && -1 != GSM_Close()))
-                RLOGW("[error],inCallRecord fail!");
-
             inCallRecordMode = 0;
+            if(!(-1 != GSM_Stop() && -1 != GSM_Close()))
+            {
+                RLOGW("[error],inCallRecord fail!");
+                goto FAIL_RETURN;
+            }            
         }
     }
-
-   if(pRI != NULL) {
+    if(pRI != NULL) {
+       android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_RECORD,0,0);  
+       android::LYNQ_RIL_respSocket_sp(p,pRI);
        free(pRI);
-   }
+    }
     return 0;
+FAIL_RETURN:
+    if(pRI != NULL) {    
+        android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_RECORD,0,2);
+        android::LYNQ_RIL_respSocket_sp(p,pRI);
+        free(pRI);
+    }
+    return -1;       
 }
 
 int StopRecord()
@@ -834,10 +845,13 @@
 
 int setSpeechVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
 {
+    android::Parcel p;
     int setValue = 0;
     RLOGD("setSpeechVolume start!");
 
     if(argc < 2) {
+        android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,2);
+        android::LYNQ_RIL_respSocket_sp(p,pRI);
         free(pRI);
         RLOGW("Warning: no set volume value!");
         return -1;
@@ -848,28 +862,64 @@
     if (get_audio_path() == 0) {
         if(setValue < MIN_VOLUME || setValue > MAX_VOLUME) {
             RLOGW("Warning: set volume value is over-range!");
+            android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,2);
+            android::LYNQ_RIL_respSocket_sp(p,pRI);
+            free(pRI);
             return -1;
         }
     } else {
         if(setValue < BT_MIN_VOLUME || setValue > BT_MAX_VOLUME) {
             RLOGW("Warning: set bt volume value is over-range!");
+            android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,2);
+            android::LYNQ_RIL_respSocket_sp(p,pRI);
+            free(pRI);
             return -1;
         }
     }
     //paramter is from 1 to 7
     mixer_set_volume(setValue);
+    android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_SPEECH_VOLUME,0,0);
+    printf(">>>>set speech Volume<<<< success value is %d!\n",setValue);
+    /*Warren add for t800 ril service 2021/12/23 end*/
+    android::LYNQ_RIL_respSocket_sp(p,pRI);
     free(pRI);
     return 0;
 }
+int getSpeechVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+    android::Parcel p;
+    printf("WARREN TEST001!!!\n");
+    int volumn = mixer_get_volume();
+    //TBC -200 fail status
+    if(volumn <0) {
+        printf("get speech volumn fail, please check whether does call exsit.\n");
+        /*Warren add for t800 ril service 2021/12/23 start*/
+        android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_GET_SPEECH_VOLUME,0,2);
+        /*Warren add for t800 ril service 2021/12/23 end*/
+    } else {
+        /*Warren add for t800 ril service 2021/12/23 start*/
+        android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_GET_SPEECH_VOLUME,0,0);
+        /*Warren add for t800 ril service 2021/12/23 end*/
+    }
+    printf("current Speech Volume is%d",volumn);
+    p.writeInt32(volumn);
+    android::LYNQ_RIL_respSocket(p,(void *)pRI);
+    if(pRI) {
+        free(pRI);
+    }
+    return 0;
+}
 int setDtmfVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
 {
+    android::Parcel p;
     int setValue = 0;
-    Parcel p;
     RLOGD("setDtmfVolume start!");
     printf("setDtmfVolume start!\n");
     if(argc < 2) {
         RLOGW("Warning: no set volume value!");
         printf("Warning: no set volume value!\n");
+        android::lynqAssemblyParcelheader(p,socket_id,LYNQ_REQUEST_SET_DTMF_VOLUME,0,2);
+        android::LYNQ_RIL_respSocket_sp(p,pRI);
         free(pRI);
         return -1;
     }
@@ -1260,7 +1310,7 @@
 //RIL_REQUEST_SET_MUTE
 int setMute(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
 {
-    Parcel p;
+    android::Parcel p;
     printf("WARREN TEST002!!!\n");
     if(argc<2)
     {
@@ -1275,12 +1325,12 @@
     int ret = setCallMute(mute);
     if(ret) {
         /*Warren add for t800 ril service 2021/12/23 start*/
-        android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_GET_MUTE,0,2);
+        android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_SET_MUTE,0,2);
         /*Warren add for t800 ril service 2021/12/23 start*/
         printf("set mute fail, please try agian\n");
     } else {
         /*Warren add for t800 ril service 2021/12/23 start*/
-        android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_GET_MUTE,0,0);
+        android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_SET_MUTE,0,0);
         /*Warren add for t800 ril service 2021/12/23 start*/
     }
     /*Warren add for t800 ril service 2021/12/23 start*/
@@ -1297,11 +1347,11 @@
 int getMute(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
 {
 
-    Parcel p;
+    android::Parcel p;
     printf("WARREN TEST001!!!\n");
     int mute = getCallMute();
     //TBC -200 fail status
-    if(mute == -200) {
+    if(mute < 0) {
         printf("get mute state fail, please check whether does call exsit.\n");
         /*Warren add for t800 ril service 2021/12/23 start*/
         android::lynqAssemblyParcelheader(p,socket_id,RIL_REQUEST_GET_MUTE,0,2);
@@ -1313,8 +1363,8 @@
     }
     printf("current mute state is%s",((mute == 1) ? "on\n" : "off\n"));
     p.writeInt32(mute);
-    android::LYNQ_RIL_respSocket(p,(void *)pRI);
     if(pRI) {
+        android::LYNQ_RIL_respSocket(p,(void *)pRI);
         free(pRI);
     }
     return 0;
diff --git a/framework/lynq-ril-service/src/cc.h b/framework/lynq-ril-service/src/cc.h
index d4c01bb..a1176ae 100755
--- a/framework/lynq-ril-service/src/cc.h
+++ b/framework/lynq-ril-service/src/cc.h
@@ -90,6 +90,7 @@
 void set_bt_wbs(int wbs);
 int get_bt_wbs(void);
 int setSpeechVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int getSpeechVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
 int setDtmfVolume(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
 //void callStateChange(void);
 void speechonoff(int callnum);
diff --git a/framework/lynq-ril-service/src/commands.h b/framework/lynq-ril-service/src/commands.h
index 133fd06..e051db0 100755
--- a/framework/lynq-ril-service/src/commands.h
+++ b/framework/lynq-ril-service/src/commands.h
@@ -74,7 +74,7 @@
     {"RIL_REQUEST_LAST_CALL_FAIL_CAUSE",getLastCallFailCause, "get last call fail cause", RIL_REQUEST_LAST_CALL_FAIL_CAUSE},
     {"RIL_REQUEST_GET_CURRENT_CALLS",getCurrentCalls,"get Current Calls",RIL_REQUEST_GET_CURRENT_CALLS},
     {"RIL_REQUEST_AUTO_ANSWER",autoAnswerCall,"auto answer call",-1},
-    {"RIL_REQUEST_RECORD",inCallRecord,"InCall record",-1},
+    {"RIL_REQUEST_RECORD",inCallRecord,"InCall record",LYNQ_REQUEST_RECORD},
 
     #ifdef C2K_SUPPORT
     {"RIL_REQUEST_CDMA_BURST_DTMF",sendBurstDtmf,"cdma burst dtmf",RIL_REQUEST_CDMA_BURST_DTMF},
@@ -85,7 +85,8 @@
     {"RIL_REQUEST_SET_SPEECH_ON",setSpeechOn,"set Speech On",-1},
     {"RIL_REQUEST_SET_SPEECH_OFF",setSpeechOff,"set Speech Off",-1},
     #endif
-    {"RIL_REQUEST_SET_SPEECH_VOLUME",setSpeechVolume,"set Speech Volume",-1},
+    {"RIL_REQUEST_GET_SPEECH_VOLUME",getSpeechVolume,"get Speech Volume",LYNQ_REQUEST_GET_SPEECH_VOLUME},
+    {"RIL_REQUEST_SET_SPEECH_VOLUME",setSpeechVolume,"set Speech Volume",LYNQ_REQUEST_SET_SPEECH_VOLUME},
     /*Warren change for t800 ril service 2021/12/24 start*/
     {"RIL_REQUEST_SET_DTMF_VOLUME",setDtmfVolume,"set dtmf Volume",LYNQ_REQUEST_SET_DTMF_VOLUME},
     /*Warren change for t800 ril service 2021/12/24 start*/
diff --git a/framework/lynq-ril-service/src/lynq_interface.h b/framework/lynq-ril-service/src/lynq_interface.h
index 2a26b51..3d250cb 100755
--- a/framework/lynq-ril-service/src/lynq_interface.h
+++ b/framework/lynq-ril-service/src/lynq_interface.h
@@ -13,6 +13,11 @@
 #define LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY (LYNQ_REQUEST_VENDOR_BASE + 6)
 #define LYNQ_REQUEST_LIST_SMS_FROM_MEMORY (LYNQ_REQUEST_VENDOR_BASE + 7)
 #define LYNQ_REQUEST_SET_DEFAULT_SIM_ALL (LYNQ_REQUEST_VENDOR_BASE + 8)
+
+#define LYNQ_REQUEST_SET_SPEECH_VOLUME (LYNQ_REQUEST_VENDOR_BASE +9)
+#define LYNQ_REQUEST_GET_SPEECH_VOLUME (LYNQ_REQUEST_VENDOR_BASE +10)
+#define LYNQ_REQUEST_RECORD  (LYNQ_REQUEST_VENDOR_BASE +11)
+
 typedef struct{
     int request;
     int waitTime;
diff --git a/framework/lynq-ril-service/src/ril.cpp b/framework/lynq-ril-service/src/ril.cpp
index 3dd15d3..64d758f 100755
--- a/framework/lynq-ril-service/src/ril.cpp
+++ b/framework/lynq-ril-service/src/ril.cpp
@@ -4945,6 +4945,9 @@
         /*LYNQ CMD*/
         case LYNQ_AUTO_ANSWER_CALL: return "LYNQ_AUTO_ANSWER_CALL";
         case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
+        case LYNQ_REQUEST_SET_SPEECH_VOLUME: return "RIL_REQUEST_SET_SPEECH_VOLUME";
+        case LYNQ_REQUEST_GET_SPEECH_VOLUME: return "RIL_REQUEST_GET_SPEECH_VOLUME";
+        case LYNQ_REQUEST_RECORD: return "RIL_REQUEST_RECORD";       
         case LYNQ_REQUEST_WRITE_SMS_TO_MEMORY: return "LYNQ_REQUEST_WRITE_SMS_TO_MEMORY";
         case LYNQ_REQUEST_READ_SMS_FROM_MEMORY: return "LYNQ_REQUEST_READ_SMS_FROM_MEMORY";
         case LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY: return "LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY";
@@ -5206,6 +5209,9 @@
         case RIL_REQUEST_QUERY_SIM_RETRY_COUNT: return "RIL_REQUEST_QUERY_SIM_RETRY_COUNT";
         case RIL_REQUEST_QUERY_EID: return "RIL_REQUEST_QUERY_EID";
         case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
+        case LYNQ_REQUEST_SET_SPEECH_VOLUME: return "RIL_REQUEST_SET_SPEECH_VOLUME";
+        case LYNQ_REQUEST_GET_SPEECH_VOLUME: return "RIL_REQUEST_GET_SPEECH_VOLUME";
+        case LYNQ_REQUEST_RECORD: return "RIL_REQUEST_RECORD";
         /*warren add for t800 ril service 2022/1/22 start*/
         case LYNQ_REQUEST_WRITE_SMS_TO_MEMORY: return "LYNQ_REQUEST_WRITE_SMS_TO_MEMORY";
         case LYNQ_REQUEST_READ_SMS_FROM_MEMORY: return "LYNQ_REQUEST_READ_SMS_FROM_MEMORY";