Merge pull request #208 from tryigit/patch-2

Update EntryPoint.java
This commit is contained in:
Marcos 2024-01-15 17:29:25 +01:00 committed by GitHub
commit 931fd3db07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,13 @@ public final class EntryPoint {
static { static {
try { try {
spoofProvider();
} catch (Throwable t) {
LOG("spoofProvider exception: " + t);
}
}
private static void spoofProvider() throws Exception {
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(null); keyStore.load(null);
@ -33,21 +40,15 @@ public final class EntryPoint {
Security.insertProviderAt(customProvider, 1); Security.insertProviderAt(customProvider, 1);
LOG("Spoof KeyStoreSpi and Provider done!"); LOG("Spoof KeyStoreSpi and Provider done!");
} catch (Throwable t) {
LOG("spoofProvider exception: " + t);
}
} }
public static void init(String json) { public static void init(String json) {
try { try {
jsonObject = new JSONObject(json); jsonObject = new JSONObject(json);
spoofDevice();
} catch (JSONException e) { } catch (JSONException e) {
LOG("Couldn't parse JSON from Zygisk"); LOG("Couldn't parse JSON from Zygisk");
} }
spoofDevice();
} }
static void LOG(String msg) { static void LOG(String msg) {
@ -69,6 +70,26 @@ public final class EntryPoint {
if (value instanceof String str) if (str.isEmpty() || str.isBlank()) return; if (value instanceof String str) if (str.isEmpty() || str.isBlank()) return;
Field field = getField(name);
if (field == null) return;
field.setAccessible(true);
try {
Object oldValue = field.get(null);
if (!value.equals(oldValue)) {
field.set(null, value);
LOG("Set [" + name + "] field value to [" + value + "]");
}
} catch (IllegalAccessException e) {
LOG("Couldn't modify field: " + e);
}
field.setAccessible(false);
}
private static Field getField(String name) {
Field field = null; Field field = null;
try { try {
@ -81,22 +102,6 @@ public final class EntryPoint {
} }
} }
if (field == null) return; return field;
field.setAccessible(true);
try {
Object oldValue = field.get(null);
if (!value.equals(oldValue)) {
field.set(null, value);
LOG("Set [" + name + "] field value to [" + value + "]");
}
} catch (IllegalAccessException e) {
LOG("Couldn't modify field: " + e);
}
field.setAccessible(false);
} }
} }