mirror of
https://github.com/revanced/jadb.git
synced 2025-05-04 16:44:25 +02:00
get state by get-state command
This commit is contained in:
parent
e324cbe004
commit
76c9045b0c
@ -13,18 +13,17 @@ import java.util.regex.Pattern;
|
|||||||
public class JadbDevice {
|
public class JadbDevice {
|
||||||
public enum State {
|
public enum State {
|
||||||
Unknown,
|
Unknown,
|
||||||
Online,
|
Offline,
|
||||||
Offline
|
Device,
|
||||||
|
BootLoader
|
||||||
};
|
};
|
||||||
|
|
||||||
private final String serial;
|
private final String serial;
|
||||||
private final ITransportFactory transportFactory;
|
private final ITransportFactory transportFactory;
|
||||||
private State state = State.Unknown;
|
|
||||||
|
|
||||||
JadbDevice(String serial, String type, ITransportFactory tFactory) {
|
JadbDevice(String serial, String type, ITransportFactory tFactory) {
|
||||||
this.serial = serial;
|
this.serial = serial;
|
||||||
this.transportFactory = tFactory;
|
this.transportFactory = tFactory;
|
||||||
state = convertState(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static JadbDevice createAny(JadbConnection connection) {
|
static JadbDevice createAny(JadbConnection connection) {
|
||||||
@ -38,8 +37,9 @@ public class JadbDevice {
|
|||||||
|
|
||||||
private State convertState(String type) {
|
private State convertState(String type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "device": return State.Online;
|
case "device": return State.Device;
|
||||||
case "offline": return State.Offline;
|
case "offline": return State.Offline;
|
||||||
|
case "bootloader": return State.BootLoader;
|
||||||
default: return State.Unknown;
|
default: return State.Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,8 +60,17 @@ public class JadbDevice {
|
|||||||
return serial;
|
return serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
public State getState() {
|
public State getState() throws IOException, JadbException {
|
||||||
return state;
|
Transport transport = transportFactory.createTransport();
|
||||||
|
if (serial == null) {
|
||||||
|
transport.send("host:get-state");
|
||||||
|
transport.verifyResponse();
|
||||||
|
} else {
|
||||||
|
transport.send("host-serial:" + serial + ":get-state");
|
||||||
|
transport.verifyResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
return convertState(transport.readString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream executeShell(String command, String... args) throws IOException, JadbException {
|
public InputStream executeShell(String command, String... args) throws IOException, JadbException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user