mirror of
https://github.com/revanced/jadb.git
synced 2025-05-09 10:54:29 +02:00
Allow any character except square brackets in property values
PropertyManager failed to get all properties from certain devices because it allowed only [a-zA-Z0-9_.-] characters in values but they can contain other characters too. For example in Nexus 9 ro.product.model is "Nexus 9" (has space). This commit changes allowed characters in property value to contain anything except square brackets.
This commit is contained in:
parent
0cb9550b50
commit
206b9c4352
@ -27,7 +27,7 @@ public class PropertyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> parseProp(BufferedReader bufferedReader) throws IOException {
|
private Map<String, String> parseProp(BufferedReader bufferedReader) throws IOException {
|
||||||
final Pattern pattern = Pattern.compile("^\\[([a-zA-Z0-9_.-]*)\\]:.\\[([a-zA-Z0-9_.-]*)\\]");
|
final Pattern pattern = Pattern.compile("^\\[([a-zA-Z0-9_.-]*)\\]:.\\[([^\\[\\]]*)\\]");
|
||||||
|
|
||||||
HashMap<String, String> result = new HashMap<>();
|
HashMap<String, String> result = new HashMap<>();
|
||||||
|
|
||||||
|
@ -55,6 +55,38 @@ public class PropertyManagerTest {
|
|||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPropsValueHasSpecialCharacters() throws Exception {
|
||||||
|
/* Some example properties from Nexus 9:
|
||||||
|
[ro.product.model]: [Nexus 9]
|
||||||
|
[ro.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
|
||||||
|
[ro.retaildemo.video_path]: [/data/preloads/demo/retail_demo.mp4]
|
||||||
|
[ro.url.legal]: [http://www.google.com/intl/%s/mobile/android/basic/phone-legal.html]
|
||||||
|
[ro.vendor.build.date]: [Tue Nov 1 18:21:23 UTC 2016]
|
||||||
|
*/
|
||||||
|
//Arrange
|
||||||
|
Map<String, String> expected = new HashMap<>();
|
||||||
|
expected.put("ro.product.model", "Nexus 9");
|
||||||
|
expected.put("ro.product.cpu.abilist", "arm64-v8a,armeabi-v7a,armeabi");
|
||||||
|
expected.put("ro.retaildemo.video_path", "/data/preloads/demo/retail_demo.mp4");
|
||||||
|
expected.put("ro.url.legal", "http://www.google.com/intl/%s/mobile/android/basic/phone-legal.html");
|
||||||
|
expected.put("ro.vendor.build.date", "Tue Nov 1 18:21:23 UTC 2016");
|
||||||
|
|
||||||
|
String response = "[ro.product.model]: [Nexus 9]\n" +
|
||||||
|
"[ro.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]\n" +
|
||||||
|
"[ro.retaildemo.video_path]: [/data/preloads/demo/retail_demo.mp4]\n" +
|
||||||
|
"[ro.url.legal]: [http://www.google.com/intl/%s/mobile/android/basic/phone-legal.html]\n" +
|
||||||
|
"[ro.vendor.build.date]: [Tue Nov 1 18:21:23 UTC 2016]";
|
||||||
|
|
||||||
|
server.expectShell(DEVICE_SERIAL, "getprop").returns(response);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
Map<String, String> actual = new PropertyManager(device).getprop();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPropsMalformedIgnoredString() throws Exception {
|
public void testGetPropsMalformedIgnoredString() throws Exception {
|
||||||
//Arrange
|
//Arrange
|
||||||
|
Loading…
x
Reference in New Issue
Block a user