[BugFix][audio][API-1405] sos occasional call probability no sound problem, optimize dialing process

    Only Configure: No
    Affected branch: GSW3.0-No-Connman
    Affected module:  audio,call
    Is it affected on both ZXIC and MTK: only MTK
    Self-test: Yes
    Doc Update:No

Change-Id: I189733eb307153e0b83fb7af4436e2a5ef11ae41
diff --git a/lib/liblynq-call/lynq_call.cpp b/lib/liblynq-call/lynq_call.cpp
index 1f2b28b..002257f 100755
--- a/lib/liblynq-call/lynq_call.cpp
+++ b/lib/liblynq-call/lynq_call.cpp
@@ -26,6 +26,11 @@
 #define CALL_ON  (1)

 #define USER_LOG_TAG "LYNQ_CALL"

 

+#define AP_SPEECH "/tmp/ap_speech"

+#define AUDIO_CTRL_SER "/tmp/audio_ctrl_service"

+#define LIBMODEM_AFE "/tmp/libmodem-afe-ctrl"

+#define TELE_DEMO_LOCK "/tmp/tel_demo_single_proc.lock"

+

 using ::android::Parcel;

 

 /**

@@ -906,6 +911,53 @@
 }

 

 

+int check_file_access(const char *fileName)

+{

+    if(0 == access(fileName,F_OK))

+    {

+        LYINFLOG("find file %s success",fileName);

+        return 0;

+    }

+    LYERRLOG("find file %s fail",fileName);

+    return 1;

+}

+int try_reset_audio_service()

+{

+    //check files:audio-ctrl-service,libmodem-afe-service,speech_daemon

+    int ap_speech = 0;

+    int audio_ctrl_ser = 0;

+    int md_afe = 0;

+    int tele_demo_lock = 0;

+    LYINFLOG("try_reset_audio_service start");

+    ap_speech = check_file_access(AP_SPEECH);

+    audio_ctrl_ser = check_file_access(AUDIO_CTRL_SER);

+    md_afe = check_file_access(LIBMODEM_AFE);

+    tele_demo_lock = check_file_access(TELE_DEMO_LOCK);

+    if((ap_speech + audio_ctrl_ser + md_afe) > 0)

+    {

+        system("systemctl stop audio-ctrl-service");

+        system("systemctl stop speech_daemon");

+        system("systemctl stop libmodem_afe_service");

+        usleep(200000);//200ms

+        system("rm /tmp/audio_ctrl_service -rf");

+        system("rm /tmp/ap_speech -rf");

+        system("rm /tmp/libmodem-afe-ctrl -rf");

+        usleep(100000);//100ms

+        system("systemctl start libmodem_afe_service");

+        usleep(200000);//200ms

+        system("systemctl start speech_daemon");

+        usleep(200000);//200ms

+        system("systemctl start audio-ctrl-service");

+        sleep(1);//1s

+        LYERRLOG("reset audio relation service");

+    }

+    if(tele_demo_lock)

+    {

+        LYERRLOG("%s lose,why?",TELE_DEMO_LOCK);

+    }

+    return 0;

+}

+

 int lynq_call(int* handle,char addr[])

 {

     if(g_module_init_flag != MODULE_RUNNING)

@@ -913,7 +965,7 @@
         LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

         return LYNQ_E_CONFLICT;

     }

-    

+    try_reset_audio_service();

     int lynq_call_id = -1;

 

     LYINFLOG("lynq_call begin addr %s",addr);