mirror of
https://github.com/revanced/jadb.git
synced 2025-02-10 17:26:46 +01: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 DataInput input;
|
||||
|
||||
public SyncTransport(OutputStream outputStream, InputStream inputStream) {
|
||||
output = new DataOutputStream(outputStream);
|
||||
input = new DataInputStream(inputStream);
|
||||
}
|
||||
|
||||
public SyncTransport(DataOutput outputStream, DataInput inputStream) {
|
||||
output = outputStream;
|
||||
input = inputStream;
|
||||
|
@ -8,10 +8,14 @@ class Transport implements Closeable {
|
||||
|
||||
private final OutputStream outputStream;
|
||||
private final InputStream inputStream;
|
||||
private final DataInputStream dataInput;
|
||||
private final DataOutputStream dataOutput;
|
||||
|
||||
private Transport(OutputStream outputStream, InputStream inputStream) {
|
||||
this.outputStream = outputStream;
|
||||
this.inputStream = inputStream;
|
||||
this.dataInput = new DataInputStream(inputStream);
|
||||
this.dataOutput = new DataOutputStream(outputStream);
|
||||
}
|
||||
|
||||
public Transport(Socket socket) throws IOException {
|
||||
@ -41,9 +45,8 @@ class Transport implements Closeable {
|
||||
}
|
||||
|
||||
public String readString(int length) throws IOException {
|
||||
DataInput reader = new DataInputStream(inputStream);
|
||||
byte[] responseBuffer = new byte[length];
|
||||
reader.readFully(responseBuffer);
|
||||
dataInput.readFully(responseBuffer);
|
||||
return new String(responseBuffer, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@ -61,12 +64,12 @@ class Transport implements Closeable {
|
||||
public SyncTransport startSync() throws IOException, JadbException {
|
||||
send("sync:");
|
||||
verifyResponse();
|
||||
return new SyncTransport(outputStream, inputStream);
|
||||
return new SyncTransport(dataOutput, dataInput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
inputStream.close();
|
||||
outputStream.close();
|
||||
dataInput.close();
|
||||
dataOutput.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user