mirror of
https://github.com/revanced/jadb.git
synced 2025-05-16 14:07:06 +02:00
AdbProtocolHandler: extract loop body to new method
This commit is contained in:
parent
ebf5d6b223
commit
bc2c76486a
@ -40,7 +40,12 @@ class AdbProtocolHandler implements Runnable {
|
||||
DataInput input = new DataInputStream(socket.getInputStream());
|
||||
DataOutputStream output = new DataOutputStream(socket.getOutputStream());
|
||||
|
||||
while (true) {
|
||||
while (processCommand(input, output)) {
|
||||
// nothing to do here
|
||||
}
|
||||
}
|
||||
|
||||
private boolean processCommand(DataInput input, DataOutputStream output) throws IOException {
|
||||
byte[] buffer = new byte[4];
|
||||
input.readFully(buffer);
|
||||
String encodedLength = new String(buffer, StandardCharsets.UTF_8);
|
||||
@ -85,7 +90,7 @@ class AdbProtocolHandler implements Runnable {
|
||||
output.writeBytes("OKAY");
|
||||
shell(shellCommand, output, input);
|
||||
output.close();
|
||||
return;
|
||||
return false;
|
||||
} else if ("host:get-state".equals(command)) {
|
||||
// TODO: Check so that exactly one device is selected.
|
||||
AdbDeviceResponder device = responder.getDevices().get(0);
|
||||
@ -119,7 +124,7 @@ class AdbProtocolHandler implements Runnable {
|
||||
send(output, e.getMessage());
|
||||
}
|
||||
output.flush();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void shell(String command, DataOutputStream stdout, DataInput stdin) throws IOException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user