mirror of
https://github.com/revanced/jadb.git
synced 2025-02-11 17:46:47 +01:00
Verifying result code
This commit is contained in:
parent
008492e140
commit
c667a0aa41
@ -18,13 +18,17 @@ public class JadbConnection {
|
||||
_socket = new Socket("localhost", DEFAULTPORT);
|
||||
}
|
||||
|
||||
public void getHostVersion() throws IOException {
|
||||
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[] response = new byte[4];
|
||||
reader.readFully(response);
|
||||
System.out.println(new String(response, Charset.forName("utf-8")));
|
||||
byte[] responseBuffer = new byte[4];
|
||||
reader.readFully(responseBuffer);
|
||||
return new String(responseBuffer, Charset.forName("utf-8"));
|
||||
}
|
||||
|
||||
public void close() throws IOException
|
||||
|
11
src/se/vidstige/jadb/JadbException.java
Normal file
11
src/se/vidstige/jadb/JadbException.java
Normal file
@ -0,0 +1,11 @@
|
||||
package se.vidstige.jadb;
|
||||
|
||||
public class JadbException extends Exception {
|
||||
|
||||
public JadbException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -3879283786835654165L;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user