AdbProtocolHandler: extract loop body to new method

This commit is contained in:
Jano Svitok 2018-07-04 12:37:55 +02:00
parent ebf5d6b223
commit bc2c76486a

View File

@ -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 {