[Bugfix][T106BUG-462]fix delete apn failed after powering on again

Only Configure: No
Affected branch: master
Affected module: data
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: Iacbd7c45c007fa6ff6ea5a7be4258369f12087b7
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 395cf95..fb7494a 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
@@ -603,6 +603,61 @@
     return RESULT_ERROR;
 }
 
+int apn_xml_handle_clean()
+{
+    int node_num = 0;
+    int default_handle = LYNQ_APN_CHANNEL_MAX + 1;
+    xmlNodePtr node = NULL;
+    xmlNodePtr modify_node = NULL;
+    xmlChar *temp_char;
+    char temp_buff[12];
+
+    if(NULL == apn_table_xml_pdoc)
+    {
+        LYERRLOG("open xml file error");
+        goto FAILED;
+    }
+    
+    node = xmlDocGetRootElement(apn_table_xml_pdoc);
+    if (NULL == node)
+    {
+        LYERRLOG("xmlDocGetRootElement() error");
+        goto FAILED;
+    }
+    modify_node = node->xmlChildrenNode;
+    if(modify_node != NULL)
+    {
+        modify_node = modify_node->next;
+    }
+    else
+    {
+        LYERRLOG("modify_node is null\n");
+        goto FAILED;
+    }
+    while (modify_node != NULL)
+    {
+        temp_char = xmlGetProp(modify_node, "handle");
+        if (temp_char == NULL) 
+        {
+            modify_node = modify_node->next;
+            continue;
+        }
+        bzero(temp_buff,12);
+        snprintf(temp_buff,sizeof(temp_buff),"%d",default_handle);
+        xmlSetProp(modify_node,BAD_CAST"handle",(xmlChar *)temp_buff);
+        modify_node = modify_node->next;
+    }
+    xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1);
+    return RESULT_OK;
+
+    FAILED:
+    // if (apn_table_xml_pdoc)
+    // {
+    //     xmlFreeDoc(apn_table_xml_pdoc);
+    // }
+    return RESULT_ERROR;
+}
+
 int apn_xml_add(qser_apn_add_s *apn,unsigned char *apn_num)
 {
     int node_num = 0;
@@ -1254,6 +1309,12 @@
         LYERRLOG("open xml file error");
         return RESULT_ERROR;
     }
+    ret = apn_xml_handle_clean();
+    if(ret != RESULT_OK)
+    {
+        LYERRLOG("clean handle error");
+        return RESULT_ERROR;
+    }
     g_lynq_qser_data_init_flag = 1;
     return RESULT_OK;
 }