Merge "[Feature][ZXW-77]add auto recover lynq_qser_data_apn.xml"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
index e1234e5..0d1d63d 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
@@ -24,6 +24,7 @@
 static pthread_cond_t s_qser_data_cb_cond = PTHREAD_COND_INITIALIZER;
 
 #define data_xml_path "/mnt/userdata/lynq_qser_data_apn.xml"
+#define COPY_XML_RETRY_TIMES 3
 
 static qser_data_call_evt_cb_t s_data_call_cb = NULL;
 const int apndb_offset = 683;
@@ -601,6 +602,22 @@
     }
     return;
 }
+int check_xml_file(const char *file)
+{
+    /* Check for existence */
+    if((access(file, F_OK)) == -1)   
+    {   
+        LYERRLOG("no such xml file.\n");
+        system("cp /data/lynq_qser_data_apn.xml /mnt/userdata/");
+    }
+
+    if((access(file, F_OK)) == -1)   
+    {   
+        LYERRLOG("error copy xml file.\n");
+        return -1;
+    }
+    return RESULT_OK;
+}
 
 int qser_data_call_init(qser_data_call_evt_cb_t evt_cb)
 {   
@@ -611,6 +628,14 @@
         LYERRLOG("init incoming paramters error");
         return RESULT_ERROR;
     }
+
+    ret = check_xml_file(data_xml_path);
+    if (ret != RESULT_OK)
+    {
+        LYERRLOG("check xml file error");
+        return RESULT_ERROR;
+    }
+
     s_data_call_cb = evt_cb;
     qser_cb_pthread_create();
     ret = lynq_init_data(utoken);