I want to disable usb ports in my rooted android device, When I run below code it returns result is true but usb ports is still active, I want to disable usb ports When I click disable button and then When I click enable button, enable usb ports how can I do this?
disable.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String[] command = { "/system/bin/sh", "-c", "echo 0 > /sys/bus/usb/devices/usb1/power/level", };
try {
Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
}
}
});
You need to define in drivers, and after echo define name of the usb like below code.
String command = "echo 'usb1' > /sys/bus/usb/drivers/usb/unbind";