mirror of
https://github.com/revanced/jadb.git
synced 2025-02-11 17:46:47 +01:00
Adding get host version method.
This commit is contained in:
parent
9eb33de413
commit
b36ede6770
40
src/se/vidstige/jadb/JadbConnection.java
Normal file
40
src/se/vidstige/jadb/JadbConnection.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package se.vidstige.jadb;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.nio.CharBuffer;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
public class JadbConnection {
|
||||||
|
|
||||||
|
private Socket _socket;
|
||||||
|
private static final int DEFAULTPORT = 5037;
|
||||||
|
|
||||||
|
public JadbConnection() throws UnknownHostException, IOException
|
||||||
|
{
|
||||||
|
_socket = new Socket("localhost", DEFAULTPORT);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getHostVersion() throws IOException {
|
||||||
|
OutputStreamWriter writer = new OutputStreamWriter(_socket.getOutputStream());
|
||||||
|
DataInput reader = new DataInputStream(_socket.getInputStream());
|
||||||
|
writer.write("000Chost:version");
|
||||||
|
writer.flush();
|
||||||
|
byte[] response = new byte[4];
|
||||||
|
reader.readFully(response);
|
||||||
|
System.out.println(new String(response, Charset.forName("utf-8")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() throws IOException
|
||||||
|
{
|
||||||
|
_socket.close();
|
||||||
|
}
|
||||||
|
}
|
14
test/se/vidstige/jadb/test/JadbTestCases.java
Normal file
14
test/se/vidstige/jadb/test/JadbTestCases.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package se.vidstige.jadb.test;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import se.vidstige.jadb.JadbConnection;
|
||||||
|
|
||||||
|
public class JadbTestCases {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception {
|
||||||
|
JadbConnection jadb = new JadbConnection();
|
||||||
|
jadb.getHostVersion();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user