From 0a3d16326450398fd1f7fca3705617404939a32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit?= <40565628+tryigit@users.noreply.github.com> Date: Wed, 13 Dec 2023 18:17:29 +0300 Subject: [PATCH] Add missing support for Boolean and Long fields (#4) e.g. IS_TREBLE_ENABLED, IS_DEBUGGABLE and TIME Reference: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/Build.java --- .../playintegrityfix/EntryPoint.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java b/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java index d60bb3d..8470021 100644 --- a/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java +++ b/app/src/main/java/es/chiteroman/playintegrityfix/EntryPoint.java @@ -91,6 +91,7 @@ public final class EntryPoint { Field field = null; String oldValue = null; + Object newValue = null; try { if (classContainsField(Build.class, name)) { @@ -116,12 +117,21 @@ public final class EntryPoint { LOG(String.format("[%s]: already '%s', skipping...", name, value)); return; } + Class fieldType = field.getType(); + if (fieldType == String.class) { + newValue = value; + } else if (fieldType == int.class) { + newValue = Integer.parseInt(value); + } else if (fieldType == long.class) { + newValue = Long.parseLong(value); + } else if (fieldType == boolean.class) { + newValue = Boolean.parseBoolean(value); + } else { + LOG(String.format("Couldn't convert '%s' to '%s' type", value, fieldType)); + return; + } try { - if (field.getType().equals(Integer.TYPE)) { - field.set(null, Integer.parseInt(value)); - } else { - field.set(null, value); - } + field.set(null, newValue); } catch (IllegalAccessException e) { LOG(String.format("Couldn't modify '%s' field value: " + e, name)); return;