running adb root
OctavianIonel opened this issue · 0 comments
OctavianIonel commented
Hi @cgutman,
I would like to run a command "adb root" and not passing through adb shell (which works):
using adb shell: getprop ro.build.version.incremental
it is working:
String getpropCommand = "getprop ro.build.version.incremental";
AdbStream streamGetpropCommand = connection.open("shell:" + getpropCommand);
while (!streamGetpropCommand .isClosed()) {
try {
String result = new String(streamGetpropCommand.read(), StandardCharsets.US_ASCII);
// Print each thing we read from the shell stream
System.out.println("-->step1: getprop result: " + result);
if (!result.isEmpty()) {
streamGetpropCommand.close();
}
} catch (InterruptedException | IOException e) {
e.printStackTrace();
return;
}
}
and when using adb root
does not work:
String rootCommand = "adb root";
AdbStream streamRootCommand = connection.open(rootCommand);
while (!streamRootCommand.isClosed()) {
try {
String result = new String(streamRootCommand.read(), StandardCharsets.US_ASCII);
// Print each thing we read from the shell stream
System.out.println("--> step2: adb root result: " + result);
if (!result.isEmpty()) {
streamRootCommand.close();
}
} catch (InterruptedException | IOException e) {
e.printStackTrace();
return;
}
}