mirror of
https://github.com/revanced/jadb.git
synced 2025-05-02 23:54:33 +02:00
Adding gat state on AndroidDevice
This commit is contained in:
parent
b1a9f1b24f
commit
a4a2e1a6af
@ -1,21 +1,32 @@
|
||||
package se.vidstige.jadb;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class AndroidDevice {
|
||||
private final String serial;
|
||||
private Transport transport;
|
||||
|
||||
public AndroidDevice(String serial, String type) {
|
||||
AndroidDevice(String serial, String type, Transport transport) {
|
||||
this.serial = serial;
|
||||
this.transport = transport;
|
||||
}
|
||||
|
||||
public AndroidDevice(String serial) {
|
||||
this(serial, null);
|
||||
}
|
||||
|
||||
public String getSerial()
|
||||
{
|
||||
return serial;
|
||||
}
|
||||
|
||||
public String getStatus() throws IOException, JadbException {
|
||||
transport.send(getPrefix() + "get-state");
|
||||
transport.verifyResponse();
|
||||
return transport.readString();
|
||||
}
|
||||
|
||||
private String getPrefix() {
|
||||
//return "host-serial:" + serial + ":";
|
||||
return "host-local:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@ -46,5 +57,4 @@ public class AndroidDevice {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class JadbConnection {
|
||||
for (String line : lines)
|
||||
{
|
||||
String[] parts = line.split("\t");
|
||||
devices.add(new AndroidDevice(parts[0], parts[1]));
|
||||
devices.add(new AndroidDevice(parts[0], parts[1], transport));
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
|
19
test/se/vidstige/jadb/test/AndroidDeviceTestCases.java
Normal file
19
test/se/vidstige/jadb/test/AndroidDeviceTestCases.java
Normal file
@ -0,0 +1,19 @@
|
||||
package se.vidstige.jadb.test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import se.vidstige.jadb.AndroidDevice;
|
||||
import se.vidstige.jadb.JadbConnection;
|
||||
|
||||
public class AndroidDeviceTestCases {
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
JadbConnection jadb = new JadbConnection();
|
||||
List<AndroidDevice> devices = jadb.getDevices();
|
||||
AndroidDevice device = devices.get(0);
|
||||
device.getStatus();
|
||||
}
|
||||
}
|
@ -21,7 +21,6 @@ public class JadbTestCases {
|
||||
{
|
||||
JadbConnection jadb = new JadbConnection();
|
||||
List<AndroidDevice> actual = jadb.getDevices();
|
||||
AndroidDevice[] expected = { new AndroidDevice("emulator-5554") };
|
||||
Assert.assertArrayEquals(expected, actual.toArray());
|
||||
Assert.assertEquals("emulator-5554", actual.get(0).getSerial());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user