blob: 20076fb2c201043199d6a2b7321302d390402a20 [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>
hong.liucd370792025-05-28 06:29:19 -070013#include "gsw_usb_interface.h"
b.liu68a94c92025-05-24 12:53:41 +080014
15#define TMP_USB_RESTART "/sbin/tmp_usb_init"
16#define USB_OPEN 3300
17#define USB_CLOSE 3329
18
hong.liud2417072025-06-27 07:10:37 -070019int32_t gsw_usb_permanent_switch(EN_GSW_USB_SWITCH_TYPE type)
b.liu68a94c92025-05-24 12:53:41 +080020{
21 int ret;
22 char cmd[256];
23 if(type != EN_GSW_USB_SWITCH_OPEN && type != EN_GSW_USB_SWITCH_CLOSE)
hong.liucd370792025-05-28 06:29:19 -070024 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +080025 sprintf(cmd, "setprop persist.mbtk.usb_pid %d && %s %d &", type?USB_OPEN:USB_CLOSE, TMP_USB_RESTART, type?USB_OPEN:USB_CLOSE);
26 ret = system(cmd);
27 return ret;
28}
29
hong.liud2417072025-06-27 07:10:37 -070030int32_t gsw_usb_temporary_switch(EN_GSW_USB_SWITCH_TYPE type)
b.liu68a94c92025-05-24 12:53:41 +080031{
32 int ret;
33 char cmd[256];
34 if(type != EN_GSW_USB_SWITCH_OPEN && type != EN_GSW_USB_SWITCH_CLOSE)
hong.liucd370792025-05-28 06:29:19 -070035 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +080036 sprintf(cmd, "%s %d &", TMP_USB_RESTART, type?USB_OPEN:USB_CLOSE);
37 ret = system(cmd);
38 return ret;
39}