[Bugfix][T106BUG-448][AUTOSUSPEND]uevent_open_socket fail when restart init

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

Change-Id: I8dc15a2107df3c2dde5a2358dcda70603a641a6a
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
index 5a88ef7..204660a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
@@ -6,7 +6,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <pthread.h>
-#include<unistd.h>
+#include <unistd.h>
 #include <cutils/uevent.h>
 
 #include <lynq_autosuspend.h>
@@ -28,6 +28,7 @@
 #define FILE_LOCK_TABLE "/tmp/.lock_table"
 #define UEVENT_MSG_LEN 128
 
+int device_fd;
 
 struct dtr_uevent {
     const char *action;
@@ -273,7 +274,6 @@
 
 void *check_dtr(void * arg)
 {
-    int device_fd;
     qser_lpm_edge_t lpm_edge;
     char msg[UEVENT_MSG_LEN+2];
     struct dtr_uevent dtr_uevent;
@@ -292,8 +292,16 @@
         msg[n] = '\0';
         msg[n+1] = '\0';
         parse_event(msg, &dtr_uevent);
-        if((!strcmp(dtr_uevent.subsystem, "xp2xp")) && (!strcmp(dtr_uevent.action, "online")))
+        if((!strcmp(dtr_uevent.subsystem, "xp2xp")))
         {
+            if(!strcmp(dtr_uevent.action, "online"))
+            {
+                lpm_edge =E_QL_LPM_FALLING;
+            }
+            else
+            {
+                lpm_edge =E_QL_LPM_RISING;
+            }
             g_lpm_handler(lpm_edge);
         }
     }
@@ -321,6 +329,7 @@
 {
     int ret;
     ret = pthread_cancel(thid);
+    close(device_fd);
     if(!ret)
     {
         LYERRLOG("pthread cancel success, lpm deinit success\n");