Refactor: Renaming to verify response

This commit is contained in:
Samuel Carlsson 2013-07-25 21:29:13 +02:00
parent c667a0aa41
commit 87ee4c5d83

View File

@ -20,15 +20,7 @@ public class JadbConnection {
public void getHostVersion() throws IOException, JadbException {
send("host:version");
String response = readResponse();
if ("OKAY".equals(response) == false) throw new JadbException("command");
}
private String readResponse() throws IOException {
DataInput reader = new DataInputStream(_socket.getInputStream());
byte[] responseBuffer = new byte[4];
reader.readFully(responseBuffer);
return new String(responseBuffer, Charset.forName("utf-8"));
verifyResponse();
}
public void close() throws IOException
@ -36,6 +28,14 @@ public class JadbConnection {
_socket.close();
}
private void verifyResponse() throws IOException, JadbException {
DataInput reader = new DataInputStream(_socket.getInputStream());
byte[] responseBuffer = new byte[4];
reader.readFully(responseBuffer);
String response = new String(responseBuffer, Charset.forName("utf-8"));
if ("OKAY".equals(response) == false) throw new JadbException("command failed");
}
private String getCommandLength(String command) {
return String.format("%04x", Integer.valueOf(command.length()));
}