b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame^] | 1 | #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 | |
| 15 | #include "gsw_usb.h" |
| 16 | |
| 17 | #define TMP_USB_RESTART "/sbin/tmp_usb_init" |
| 18 | #define USB_OPEN 3300 |
| 19 | #define USB_CLOSE 3329 |
| 20 | |
| 21 | int32_t gsw_usb_permanent_switch(EN_GSW_USB_SWITCH_TYPE type) |
| 22 | { |
| 23 | int ret; |
| 24 | char cmd[256]; |
| 25 | if(type != EN_GSW_USB_SWITCH_OPEN && type != EN_GSW_USB_SWITCH_CLOSE) |
| 26 | return GSW_HAL_FAIL; |
| 27 | 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 | |
| 32 | int32_t gsw_usb_tempporary_switch(EN_GSW_USB_SWITCH_TYPE type) |
| 33 | { |
| 34 | int ret; |
| 35 | char cmd[256]; |
| 36 | if(type != EN_GSW_USB_SWITCH_OPEN && type != EN_GSW_USB_SWITCH_CLOSE) |
| 37 | return GSW_HAL_FAIL; |
| 38 | sprintf(cmd, "%s %d &", TMP_USB_RESTART, type?USB_OPEN:USB_CLOSE); |
| 39 | ret = system(cmd); |
| 40 | return ret; |
| 41 | } |