[Feature][T108][system][task-view-1692]Merged gsw hal code

Only Configure: No
Affected branch: GSW_V1453
Affected module: libgsw
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no

Change-Id: I7fb669b6afc6e2f92a1e86ec8543498eb73120b4
diff --git a/mbtk/libgsw_lib/gsw_usb_interface.c b/mbtk/libgsw_lib/gsw_usb_interface.c
new file mode 100755
index 0000000..20076fb
--- /dev/null
+++ b/mbtk/libgsw_lib/gsw_usb_interface.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+#include <termios.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+#include "gsw_usb_interface.h"
+
+#define TMP_USB_RESTART "/sbin/tmp_usb_init"
+#define USB_OPEN 3300
+#define USB_CLOSE 3329
+
+int32_t gsw_usb_permanent_switch(EN_GSW_USB_SWITCH_TYPE type)
+{
+    int ret;
+    char cmd[256];
+    if(type != EN_GSW_USB_SWITCH_OPEN && type != EN_GSW_USB_SWITCH_CLOSE)
+        return GSW_HAL_NORMAL_FAIL;
+    sprintf(cmd, "setprop persist.mbtk.usb_pid %d && %s %d &", type?USB_OPEN:USB_CLOSE, TMP_USB_RESTART, type?USB_OPEN:USB_CLOSE);
+    ret = system(cmd);
+    return ret;
+}
+
+int32_t gsw_usb_temporary_switch(EN_GSW_USB_SWITCH_TYPE type)
+{
+    int ret;
+    char cmd[256];
+    if(type != EN_GSW_USB_SWITCH_OPEN && type != EN_GSW_USB_SWITCH_CLOSE)
+        return GSW_HAL_NORMAL_FAIL;
+    sprintf(cmd, "%s %d &", TMP_USB_RESTART, type?USB_OPEN:USB_CLOSE);
+    ret = system(cmd);
+    return ret;
+}
\ No newline at end of file