blob: 1b912bdbaa214ef24c97543c2b9ac95b32ef298f [file] [log] [blame]
b.liu68a94c92025-05-24 12:53:41 +08001#include <stdio.h>
2#include <stdlib.h>
3#include <fcntl.h>
4#include <sys/types.h>
5#include <sys/stat.h>
6#include <string.h>
7#include <errno.h>
8#include <termios.h>
9#include <unistd.h>
10#include <stdint.h>
11#include <sys/ioctl.h>
12#include <dlfcn.h>
13
14
hong.liucd370792025-05-28 06:29:19 -070015#include "gsw_usb_interface.h"
b.liu68a94c92025-05-24 12:53:41 +080016
17#define TMP_USB_RESTART "/sbin/tmp_usb_init"
18#define USB_OPEN 3300
19#define USB_CLOSE 3329
20
hong.liucd370792025-05-28 06:29:19 -070021int gsw_usb_permanent_switch(EN_GSW_USB_SWITCH_TYPE type)
b.liu68a94c92025-05-24 12:53:41 +080022{
23 int ret;
24 char cmd[256];
25 if(type != EN_GSW_USB_SWITCH_OPEN && type != EN_GSW_USB_SWITCH_CLOSE)
hong.liucd370792025-05-28 06:29:19 -070026 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +080027 sprintf(cmd, "setprop persist.mbtk.usb_pid %d && %s %d &", type?USB_OPEN:USB_CLOSE, TMP_USB_RESTART, type?USB_OPEN:USB_CLOSE);
28 ret = system(cmd);
29 return ret;
30}
31
hong.liucd370792025-05-28 06:29:19 -070032int gsw_usb_tempporary_switch(EN_GSW_USB_SWITCH_TYPE type)
b.liu68a94c92025-05-24 12:53:41 +080033{
34 int ret;
35 char cmd[256];
36 if(type != EN_GSW_USB_SWITCH_OPEN && type != EN_GSW_USB_SWITCH_CLOSE)
hong.liucd370792025-05-28 06:29:19 -070037 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +080038 sprintf(cmd, "%s %d &", TMP_USB_RESTART, type?USB_OPEN:USB_CLOSE);
39 ret = system(cmd);
40 return ret;
41}