blob: 20076fb2c201043199d6a2b7321302d390402a20 [file] [log] [blame]
#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;
}