mirror of
https://github.com/revanced/jadb.git
synced 2025-05-08 10:24:30 +02:00
vidstige/jadb#38 skeleton implemented. Need unit-tests
This commit is contained in:
parent
6ec1a4f9f9
commit
02f6f6d79d
@ -4,7 +4,11 @@ import se.vidstige.jadb.managers.Bash;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class JadbDevice {
|
||||
private final String serial;
|
||||
@ -70,6 +74,37 @@ public class JadbDevice {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getprop() throws IOException, JadbException {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(executeShell("getprop")));
|
||||
return parseProp(bufferedReader);
|
||||
}
|
||||
|
||||
//@VisibleForTesting
|
||||
Map<String, String> parseProp(BufferedReader bufferedReader) throws IOException {
|
||||
final Pattern pattern = Pattern.compile("^\\[(.*)\\]:.\\[(.*)\\]");
|
||||
|
||||
HashMap<String, String> result = new HashMap<>();
|
||||
|
||||
String line;
|
||||
Matcher matcher = pattern.matcher("");
|
||||
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
matcher.reset(line);
|
||||
|
||||
if(matcher.find()) {
|
||||
if(matcher.groupCount() < 2) {
|
||||
System.err.println("Property line: " + line +" does not match patter. Ignoring");
|
||||
continue;
|
||||
}
|
||||
String key = matcher.group(1);
|
||||
String value = matcher.group(2);
|
||||
result.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<RemoteFile> list(String remotePath) throws IOException, JadbException {
|
||||
Transport transport = getTransport();
|
||||
SyncTransport sync = transport.startSync();
|
||||
|
Loading…
x
Reference in New Issue
Block a user