mirror of
https://github.com/revanced/jadb.git
synced 2025-05-03 16:14:25 +02:00
Adding gat state on AndroidDevice
This commit is contained in:
parent
b1a9f1b24f
commit
a4a2e1a6af
@ -1,21 +1,32 @@
|
|||||||
package se.vidstige.jadb;
|
package se.vidstige.jadb;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class AndroidDevice {
|
public class AndroidDevice {
|
||||||
private final String serial;
|
private final String serial;
|
||||||
|
private Transport transport;
|
||||||
|
|
||||||
public AndroidDevice(String serial, String type) {
|
AndroidDevice(String serial, String type, Transport transport) {
|
||||||
this.serial = serial;
|
this.serial = serial;
|
||||||
|
this.transport = transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AndroidDevice(String serial) {
|
|
||||||
this(serial, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSerial()
|
public String getSerial()
|
||||||
{
|
{
|
||||||
return serial;
|
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
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
@ -46,5 +57,4 @@ public class AndroidDevice {
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class JadbConnection {
|
|||||||
for (String line : lines)
|
for (String line : lines)
|
||||||
{
|
{
|
||||||
String[] parts = line.split("\t");
|
String[] parts = line.split("\t");
|
||||||
devices.add(new AndroidDevice(parts[0], parts[1]));
|
devices.add(new AndroidDevice(parts[0], parts[1], transport));
|
||||||
}
|
}
|
||||||
return devices;
|
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();
|
JadbConnection jadb = new JadbConnection();
|
||||||
List<AndroidDevice> actual = jadb.getDevices();
|
List<AndroidDevice> actual = jadb.getDevices();
|
||||||
AndroidDevice[] expected = { new AndroidDevice("emulator-5554") };
|
Assert.assertEquals("emulator-5554", actual.get(0).getSerial());
|
||||||
Assert.assertArrayEquals(expected, actual.toArray());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user