Future proof to allow spoofing all properties

- remove backwards compatibility cruft for all deprecated fields except FIRST_API_LEVEL (for now)
- iterate through all entries with . or * (see next) to allow modifying any matching DroidGuard-checked system property
- allow leading * wildcard to match multiple system properties in one json entry
- add logging levels using VERBOSE_LOGS as the last json entry, with values of 0, 1, 2, 3 or 100
- spoof sys.usb.state to mtp for DroidGuard by default to hide USB Debugging

Co-authored-by: arda99 <arda99@noreply.xdaforums.com>
This commit is contained in:
osm0sis
2023-12-21 01:41:37 -04:00
parent 18ecfd6e32
commit dc10cae2b6
2 changed files with 71 additions and 98 deletions
@@ -16,6 +16,8 @@ import java.util.HashMap;
import java.util.Map;
public final class EntryPoint {
private static Integer verboseLogs = 0;
private static final Map<String, String> map = new HashMap<>();
public static void init() {
@@ -66,9 +68,10 @@ public final class EntryPoint {
static void spoofDevice() {
for (String key : map.keySet()) {
// Verbose logging if VERBOSE_LOGS with level number is last entry
if (key.equals("VERBOSE_LOGS")) {
verboseLogs = Integer.parseInt(map.get("VERBOSE_LOGS"));
// Backwards compatibility for chiteroman's alternate API naming
if (key.equals("BUILD_ID")) {
setField("ID", map.get("BUILD_ID"));
} else if (key.equals("FIRST_API_LEVEL")) {
setField("DEVICE_INITIAL_SDK_INT", map.get("FIRST_API_LEVEL"));
} else {
@@ -100,7 +103,7 @@ public final class EntryPoint {
} else if (classContainsField(Build.VERSION.class, name)) {
field = Build.VERSION.class.getDeclaredField(name);
} else {
LOG(String.format("Couldn't determine '%s' class name", name));
if (verboseLogs > 1) LOG(String.format("Couldn't determine '%s' class name", name));
return;
}
} catch (NoSuchFieldException e) {
@@ -115,7 +118,7 @@ public final class EntryPoint {
return;
}
if (value.equals(oldValue)) {
LOG(String.format("[%s]: already '%s', skipping...", name, value));
if (verboseLogs > 2) LOG(String.format("[%s]: %s (unchanged)", name, value));
return;
}
Class<?> fieldType = field.getType();