diff --git a/src/se/vidstige/jadb/AndroidDevice.java b/src/se/vidstige/jadb/AndroidDevice.java index 0d531ea..56d64d8 100644 --- a/src/se/vidstige/jadb/AndroidDevice.java +++ b/src/se/vidstige/jadb/AndroidDevice.java @@ -1,6 +1,8 @@ package se.vidstige.jadb; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; public class AndroidDevice { private String serial; @@ -64,15 +66,17 @@ public class AndroidDevice { send("shell:" + shellLine.toString()); } - public void list(String remotePath) throws IOException, JadbException { + public List list(String remotePath) throws IOException, JadbException { selectTransport(); SyncTransport sync = transport.startSync(); sync.send("LIST", remotePath); + List result = new ArrayList(); for (RemoteFile dent = sync.readDirectoryEntry(); dent != RemoteFile.DONE; dent = sync.readDirectoryEntry()) { - System.out.println(dent.getName()); + result.add(dent); } + return result; } public void push(String localPath, String remotePath) throws IOException, JadbException { diff --git a/src/se/vidstige/jadb/RemoteFile.java b/src/se/vidstige/jadb/RemoteFile.java index 056cdcd..fe08e05 100644 --- a/src/se/vidstige/jadb/RemoteFile.java +++ b/src/se/vidstige/jadb/RemoteFile.java @@ -3,16 +3,35 @@ package se.vidstige.jadb; /** * Created by vidstige on 2014-03-19. */ -class RemoteFile { - public static final RemoteFile DONE = new RemoteFile("DONE", null); - private String name; +public class RemoteFile { + public static final RemoteFile DONE = new RemoteFile("DONE", null, 0, 0, 0); - public RemoteFile(String id, String name) { + private final String name; + private final int mode; + private final int size; + private final long lastModified; + + public RemoteFile(String id, String name, int mode, int size, long lastModified) { this.name = name; + this.mode = mode; + this.size = size; + this.lastModified = lastModified; } public String getName() { return name; } + + public int getSize() { + return size; + } + + public long getLastModified() { + return lastModified; + } + + public boolean isDirectory() { + return (mode & (1 << 14)) == (1 << 14); + } } diff --git a/src/se/vidstige/jadb/SyncTransport.java b/src/se/vidstige/jadb/SyncTransport.java index 0f54deb..34639e7 100644 --- a/src/se/vidstige/jadb/SyncTransport.java +++ b/src/se/vidstige/jadb/SyncTransport.java @@ -42,6 +42,6 @@ class SyncTransport { String name = readString(nameLenght); if ("DENT".equals(id) == false) return RemoteFile.DONE; - return new RemoteFile(id, name); + return new RemoteFile(id, name, mode, size, time); } } diff --git a/test/se/vidstige/jadb/test/JadbTestCases.java b/test/se/vidstige/jadb/test/JadbTestCases.java index 56aeced..bc9a8bf 100644 --- a/test/se/vidstige/jadb/test/JadbTestCases.java +++ b/test/se/vidstige/jadb/test/JadbTestCases.java @@ -7,6 +7,7 @@ import org.junit.Test; import se.vidstige.jadb.AndroidDevice; import se.vidstige.jadb.JadbConnection; +import se.vidstige.jadb.RemoteFile; import se.vidstige.jadb.test.fakes.AdbServer; public class JadbTestCases { @@ -31,6 +32,10 @@ public class JadbTestCases { { JadbConnection jadb = new JadbConnection(); AndroidDevice any = jadb.getAnyDevice(); - any.list("/"); + List files = any.list("/"); + for (RemoteFile f : files) + { + System.out.println(f.getName()); + } } }