mirror of
https://github.com/revanced/jadb.git
synced 2024-11-19 10:39:23 +01:00
Refactor: Fixing warnings
This commit is contained in:
parent
88faded23d
commit
dbe57d0279
@ -26,7 +26,7 @@ class Transport {
|
||||
|
||||
public void verifyResponse() throws IOException, JadbException {
|
||||
String response = readString(4);
|
||||
if ("OKAY".equals(response) == false)
|
||||
if (!"OKAY".equals(response))
|
||||
{
|
||||
String error = readString();
|
||||
throw new JadbException("command failed: " + error);
|
||||
@ -37,12 +37,11 @@ class Transport {
|
||||
DataInput reader = new DataInputStream(inputStream);
|
||||
byte[] responseBuffer = new byte[length];
|
||||
reader.readFully(responseBuffer);
|
||||
String response = new String(responseBuffer, Charset.forName("utf-8"));
|
||||
return response;
|
||||
return new String(responseBuffer, Charset.forName("utf-8"));
|
||||
}
|
||||
|
||||
public String getCommandLength(String command) {
|
||||
return String.format("%04x", Integer.valueOf(command.length()));
|
||||
return String.format("%04x", command.length());
|
||||
}
|
||||
|
||||
public void send(String command) throws IOException {
|
||||
|
@ -1,14 +1,15 @@
|
||||
package se.vidstige.jadb.test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
import se.vidstige.jadb.JadbDevice;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import se.vidstige.jadb.JadbConnection;
|
||||
import se.vidstige.jadb.JadbException;
|
||||
import se.vidstige.jadb.JadbDevice;
|
||||
import se.vidstige.jadb.test.fakes.AdbServer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MockedTestCases {
|
||||
|
||||
private AdbServer server;
|
||||
@ -30,6 +31,6 @@ public class MockedTestCases {
|
||||
@Test
|
||||
public void testListDevices() throws Exception {
|
||||
List<JadbDevice> devices = connection.getDevices();
|
||||
Assert.assertEquals("X", devices.get(0).getSerial());
|
||||
Assert.assertEquals("X", devices.get(0).getSerial());
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,8 @@
|
||||
package se.vidstige.jadb.test.fakes;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
// >set ANDROID_ADB_SERVER_PORT=15037
|
||||
public class AdbServer implements Runnable {
|
||||
@ -15,7 +10,7 @@ public class AdbServer implements Runnable {
|
||||
private int port = 15037;
|
||||
private ServerSocket socket;
|
||||
private Thread thread;
|
||||
private Object lockObject = new Object();
|
||||
private final Object lockObject = new Object();
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
@ -59,7 +54,8 @@ public class AdbServer implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws IOException {
|
||||
public void stop() throws IOException, InterruptedException {
|
||||
socket.close();
|
||||
thread.join();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user