Small fixes

- replace if with switch
- remove unnecessary toString()
This commit is contained in:
Jano Svitok 2019-02-19 15:32:32 +01:00
parent a6dcb3ec38
commit 3c4b0c6997
2 changed files with 14 additions and 8 deletions

View File

@ -186,7 +186,7 @@ public class JadbDevice {
public void push(InputStream source, long lastModified, int mode, RemoteFile remote) throws IOException, JadbException {
try (Transport transport = getTransport()) {
SyncTransport sync = transport.startSync();
sync.send("SEND", remote.getPath() + "," + Integer.toString(mode));
sync.send("SEND", remote.getPath() + "," + mode);
sync.sendStream(source);

View File

@ -178,13 +178,19 @@ class AdbProtocolHandler implements Runnable {
try {
String id = readString(input, 4);
int length = readInt(input);
if ("SEND".equals(id)) {
syncSend(output, input, length);
} else if ("RECV".equals(id)) {
syncRecv(output, input, length);
} else if ("LIST".equals(id)) {
syncList(output, input, length);
} else throw new JadbException("Unknown sync id " + id);
switch (id) {
case "SEND":
syncSend(output, input, length);
break;
case "RECV":
syncRecv(output, input, length);
break;
case "LIST":
syncList(output, input, length);
break;
default:
throw new JadbException("Unknown sync id " + id);
}
} catch (JadbException e) { // sync response with a different type of fail message
SyncTransport sync = getSyncTransport(output, input);
sync.send("FAIL", e.getMessage());