mirror of
https://github.com/revanced/jadb.git
synced 2025-02-11 09:36:48 +01:00
Adding callback for file pushed.
This commit is contained in:
parent
0e94c45791
commit
89403cb126
@ -1,9 +1,13 @@
|
||||
package se.vidstige.jadb.server;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
/**
|
||||
* Created by vidstige on 20/03/14.
|
||||
*/
|
||||
public interface AdbDeviceResponder {
|
||||
String getSerial();
|
||||
String getType();
|
||||
|
||||
void filePushed(String path, int mode, ByteArrayOutputStream buffer);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import java.nio.charset.Charset;
|
||||
public class AdbProtocolHandler implements Runnable {
|
||||
private final Socket socket;
|
||||
private final AdbResponder responder;
|
||||
private AdbDeviceResponder selected;
|
||||
|
||||
public AdbProtocolHandler(Socket socket, AdbResponder responder) {
|
||||
this.socket = socket;
|
||||
@ -61,6 +62,7 @@ public class AdbProtocolHandler implements Runnable {
|
||||
else if ("host:transport-any".equals(command))
|
||||
{
|
||||
// TODO: Check so that exactly one device is selected.
|
||||
selected = responder.getDevices().get(0);
|
||||
output.writeBytes("OKAY");
|
||||
}
|
||||
else if ("host:devices".equals(command)) {
|
||||
@ -76,7 +78,7 @@ public class AdbProtocolHandler implements Runnable {
|
||||
else if (command.startsWith("host:transport:"))
|
||||
{
|
||||
String serial = command.substring("host:transport:".length());
|
||||
findDevice(serial);
|
||||
selected = findDevice(serial);
|
||||
output.writeBytes("OKAY");
|
||||
}
|
||||
else if ("sync:".equals(command)) {
|
||||
@ -114,10 +116,20 @@ public class AdbProtocolHandler implements Runnable {
|
||||
if ("SEND".equals(id))
|
||||
{
|
||||
String remotePath = readString(input, length);
|
||||
int idx = remotePath.lastIndexOf(',');
|
||||
String path = remotePath;
|
||||
int mode = 0666;
|
||||
if (idx > 0)
|
||||
{
|
||||
path = remotePath.substring(0, idx);
|
||||
mode = Integer.parseInt(remotePath.substring(idx + 1));
|
||||
}
|
||||
SyncTransport transport = new SyncTransport(output, input);
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
transport.readChunksTo(buffer);
|
||||
transport.sendStatus("OKAY", 0); // 0 = ignored
|
||||
|
||||
selected.filePushed(path, mode, buffer);
|
||||
}
|
||||
else throw new JadbException("Unknown sync id " + id);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import se.vidstige.jadb.server.AdbDeviceResponder;
|
||||
import se.vidstige.jadb.server.AdbResponder;
|
||||
import se.vidstige.jadb.server.AdbServer;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -64,5 +65,10 @@ public class FakeAdbServer implements AdbResponder {
|
||||
public String getType() {
|
||||
return "device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filePushed(String path, int mode, ByteArrayOutputStream buffer) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user