mirror of
https://github.com/revanced/jadb.git
synced 2025-02-11 17:46:47 +01:00
Refactor: Renaming to JadbDevice.
This commit is contained in:
parent
15f49dde6a
commit
e09b429b86
@ -36,7 +36,7 @@ public class JadbConnection {
|
|||||||
main.verifyResponse();
|
main.verifyResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AndroidDevice> getDevices() throws IOException, JadbException
|
public List<JadbDevice> getDevices() throws IOException, JadbException
|
||||||
{
|
{
|
||||||
Transport devices = createTransport();
|
Transport devices = createTransport();
|
||||||
|
|
||||||
@ -46,18 +46,18 @@ public class JadbConnection {
|
|||||||
return parseDevices(body);
|
return parseDevices(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AndroidDevice> parseDevices(String body) {
|
private List<JadbDevice> parseDevices(String body) {
|
||||||
String[] lines = body.split("\n");
|
String[] lines = body.split("\n");
|
||||||
ArrayList<AndroidDevice> devices = new ArrayList<AndroidDevice>(lines.length);
|
ArrayList<JadbDevice> devices = new ArrayList<JadbDevice>(lines.length);
|
||||||
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], main));
|
devices.add(new JadbDevice(parts[0], parts[1], main));
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AndroidDevice getAnyDevice() {
|
public JadbDevice getAnyDevice() {
|
||||||
return AndroidDevice.createAny(main);
|
return JadbDevice.createAny(main);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,19 @@ import java.io.*;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AndroidDevice {
|
public class JadbDevice {
|
||||||
private String serial;
|
private String serial;
|
||||||
private Transport transport;
|
private Transport transport;
|
||||||
private boolean selected = false;
|
private boolean selected = false;
|
||||||
|
|
||||||
AndroidDevice(String serial, String type, Transport transport) {
|
JadbDevice(String serial, String type, Transport transport) {
|
||||||
this.serial = serial;
|
this.serial = serial;
|
||||||
this.transport = transport;
|
this.transport = transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AndroidDevice createAny(Transport transport) { return new AndroidDevice(transport); }
|
static JadbDevice createAny(Transport transport) { return new JadbDevice(transport); }
|
||||||
|
|
||||||
private AndroidDevice(Transport transport)
|
private JadbDevice(Transport transport)
|
||||||
{
|
{
|
||||||
serial = null;
|
serial = null;
|
||||||
this.transport = transport;
|
this.transport = transport;
|
||||||
@ -129,7 +129,7 @@ public class AndroidDevice {
|
|||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
AndroidDevice other = (AndroidDevice) obj;
|
JadbDevice other = (JadbDevice) obj;
|
||||||
if (serial == null) {
|
if (serial == null) {
|
||||||
if (other.serial != null)
|
if (other.serial != null)
|
||||||
return false;
|
return false;
|
@ -4,7 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import se.vidstige.jadb.AndroidDevice;
|
import se.vidstige.jadb.JadbDevice;
|
||||||
import se.vidstige.jadb.JadbConnection;
|
import se.vidstige.jadb.JadbConnection;
|
||||||
import se.vidstige.jadb.JadbException;
|
import se.vidstige.jadb.JadbException;
|
||||||
|
|
||||||
@ -13,8 +13,8 @@ public class AndroidDeviceTestCases {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetState() throws Exception {
|
public void testGetState() throws Exception {
|
||||||
JadbConnection jadb = new JadbConnection();
|
JadbConnection jadb = new JadbConnection();
|
||||||
List<AndroidDevice> devices = jadb.getDevices();
|
List<JadbDevice> devices = jadb.getDevices();
|
||||||
AndroidDevice device = devices.get(0);
|
JadbDevice device = devices.get(0);
|
||||||
device.getState();
|
device.getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,8 +22,8 @@ public class AndroidDeviceTestCases {
|
|||||||
public void invalidShellCommand() throws Exception
|
public void invalidShellCommand() throws Exception
|
||||||
{
|
{
|
||||||
JadbConnection jadb = new JadbConnection("localhost", 5037);
|
JadbConnection jadb = new JadbConnection("localhost", 5037);
|
||||||
List<AndroidDevice> devices = jadb.getDevices();
|
List<JadbDevice> devices = jadb.getDevices();
|
||||||
AndroidDevice device = devices.get(0);
|
JadbDevice device = devices.get(0);
|
||||||
device.executeShell("cmd", "foo", "bar");
|
device.executeShell("cmd", "foo", "bar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,11 @@ package se.vidstige.jadb.test;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import se.vidstige.jadb.AndroidDevice;
|
import se.vidstige.jadb.JadbDevice;
|
||||||
import se.vidstige.jadb.JadbConnection;
|
import se.vidstige.jadb.JadbConnection;
|
||||||
import se.vidstige.jadb.RemoteFile;
|
import se.vidstige.jadb.RemoteFile;
|
||||||
import se.vidstige.jadb.test.fakes.AdbServer;
|
|
||||||
|
|
||||||
public class JadbTestCases {
|
public class JadbTestCases {
|
||||||
|
|
||||||
@ -23,7 +21,7 @@ public class JadbTestCases {
|
|||||||
{
|
{
|
||||||
//JadbConnection jadb = new JadbConnection("localhost", 15037);
|
//JadbConnection jadb = new JadbConnection("localhost", 15037);
|
||||||
JadbConnection jadb = new JadbConnection();
|
JadbConnection jadb = new JadbConnection();
|
||||||
List<AndroidDevice> actual = jadb.getDevices();
|
List<JadbDevice> actual = jadb.getDevices();
|
||||||
//Assert.assertEquals("emulator-5554", actual.get(0).getSerial());
|
//Assert.assertEquals("emulator-5554", actual.get(0).getSerial());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +29,7 @@ public class JadbTestCases {
|
|||||||
public void testListFiles() throws Exception
|
public void testListFiles() throws Exception
|
||||||
{
|
{
|
||||||
JadbConnection jadb = new JadbConnection();
|
JadbConnection jadb = new JadbConnection();
|
||||||
AndroidDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
List<RemoteFile> files = any.list("/");
|
List<RemoteFile> files = any.list("/");
|
||||||
for (RemoteFile f : files)
|
for (RemoteFile f : files)
|
||||||
{
|
{
|
||||||
@ -43,7 +41,7 @@ public class JadbTestCases {
|
|||||||
public void testPushFile() throws Exception
|
public void testPushFile() throws Exception
|
||||||
{
|
{
|
||||||
JadbConnection jadb = new JadbConnection();
|
JadbConnection jadb = new JadbConnection();
|
||||||
AndroidDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
any.push("README.md", "/sdcard/README.md");
|
any.push("README.md", "/sdcard/README.md");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user