mirror of
https://github.com/revanced/jadb.git
synced 2025-04-29 22:24:33 +02:00
Move creation of Data{Input|Output}Stream to Transport
This commit is contained in:
parent
9d7f4f7846
commit
5e1f1ec522
@ -11,11 +11,6 @@ public class SyncTransport {
|
|||||||
private final DataOutput output;
|
private final DataOutput output;
|
||||||
private final DataInput input;
|
private final DataInput input;
|
||||||
|
|
||||||
public SyncTransport(OutputStream outputStream, InputStream inputStream) {
|
|
||||||
output = new DataOutputStream(outputStream);
|
|
||||||
input = new DataInputStream(inputStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SyncTransport(DataOutput outputStream, DataInput inputStream) {
|
public SyncTransport(DataOutput outputStream, DataInput inputStream) {
|
||||||
output = outputStream;
|
output = outputStream;
|
||||||
input = inputStream;
|
input = inputStream;
|
||||||
|
@ -8,10 +8,14 @@ class Transport implements Closeable {
|
|||||||
|
|
||||||
private final OutputStream outputStream;
|
private final OutputStream outputStream;
|
||||||
private final InputStream inputStream;
|
private final InputStream inputStream;
|
||||||
|
private final DataInputStream dataInput;
|
||||||
|
private final DataOutputStream dataOutput;
|
||||||
|
|
||||||
private Transport(OutputStream outputStream, InputStream inputStream) {
|
private Transport(OutputStream outputStream, InputStream inputStream) {
|
||||||
this.outputStream = outputStream;
|
this.outputStream = outputStream;
|
||||||
this.inputStream = inputStream;
|
this.inputStream = inputStream;
|
||||||
|
this.dataInput = new DataInputStream(inputStream);
|
||||||
|
this.dataOutput = new DataOutputStream(outputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Transport(Socket socket) throws IOException {
|
public Transport(Socket socket) throws IOException {
|
||||||
@ -41,9 +45,8 @@ class Transport implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String readString(int length) throws IOException {
|
public String readString(int length) throws IOException {
|
||||||
DataInput reader = new DataInputStream(inputStream);
|
|
||||||
byte[] responseBuffer = new byte[length];
|
byte[] responseBuffer = new byte[length];
|
||||||
reader.readFully(responseBuffer);
|
dataInput.readFully(responseBuffer);
|
||||||
return new String(responseBuffer, StandardCharsets.UTF_8);
|
return new String(responseBuffer, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,12 +64,12 @@ class Transport implements Closeable {
|
|||||||
public SyncTransport startSync() throws IOException, JadbException {
|
public SyncTransport startSync() throws IOException, JadbException {
|
||||||
send("sync:");
|
send("sync:");
|
||||||
verifyResponse();
|
verifyResponse();
|
||||||
return new SyncTransport(outputStream, inputStream);
|
return new SyncTransport(dataOutput, dataInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
inputStream.close();
|
dataInput.close();
|
||||||
outputStream.close();
|
dataOutput.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user