'Disable Usb Ports in rooted Android device
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();
}
}
});
Solution 1:[1]
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";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | R?dvan |