-
Couldn't load subscription status.
- Fork 10
speedup jailbreak monkey (-700ms) #3289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
f949be6
210b334
f2f3b72
313b8b4
a38322f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| diff --git a/android/src/main/java/com/gantix/JailMonkey/JailMonkeyModule.java b/android/src/main/java/com/gantix/JailMonkey/JailMonkeyModule.java | ||
| index 018d7051a57a2250c738e018ba8e1518d1b9525a..e89a135c10edc50174315c5cf0a3c9871fe65e6a 100644 | ||
| --- a/android/src/main/java/com/gantix/JailMonkey/JailMonkeyModule.java | ||
| +++ b/android/src/main/java/com/gantix/JailMonkey/JailMonkeyModule.java | ||
| @@ -74,11 +74,7 @@ public class JailMonkeyModule extends ReactContextBaseJavaModule { | ||
| final Map<String, Object> constants = new HashMap<>(); | ||
|
|
||
| constants.put("isJailBroken", rootedCheck.isJailBroken()); | ||
| - constants.put("rootedDetectionMethods", rootedCheck.getResultByDetectionMethod()); | ||
| - constants.put("hookDetected", hookDetected(context)); | ||
| - constants.put("canMockLocation", isMockLocationOn(context)); | ||
| - constants.put("isOnExternalStorage", isOnExternalStorage(context)); | ||
| - constants.put("AdbEnabled", AdbEnabled(context)); | ||
| return constants; | ||
| } | ||
| } | ||
| + | ||
| diff --git a/android/src/main/java/com/gantix/JailMonkey/Rooted/RootedCheck.java b/android/src/main/java/com/gantix/JailMonkey/Rooted/RootedCheck.java | ||
| index bf75f27fd11293205bf6d58de4f8069ea0a155fe..d63ac51b87e456bd13e252c7ca691c07e28704a5 100644 | ||
| --- a/android/src/main/java/com/gantix/JailMonkey/Rooted/RootedCheck.java | ||
| +++ b/android/src/main/java/com/gantix/JailMonkey/Rooted/RootedCheck.java | ||
| @@ -4,25 +4,44 @@ import android.content.Context; | ||
| import com.scottyab.rootbeer.RootBeer; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| +import java.util.concurrent.CountDownLatch; | ||
| + | ||
| +import androidx.tracing.Trace; | ||
|
|
||
| public class RootedCheck { | ||
| private static boolean checkWithJailMonkeyMethod() { | ||
| - CheckApiVersion check; | ||
| - | ||
| - if (android.os.Build.VERSION.SDK_INT >= 23) { | ||
| - check = new GreaterThan23(); | ||
| - } else { | ||
| - check = new LessThan23(); | ||
| + Trace.beginSection("[JailMonkey] checkWithJailMonkeyMethod"); | ||
|
||
| + try { | ||
| + CheckApiVersion check; | ||
| + | ||
| + if (android.os.Build.VERSION.SDK_INT >= 23) { | ||
| + check = new GreaterThan23(); | ||
| + } else { | ||
| + check = new LessThan23(); | ||
| + } | ||
| + return check.checkRooted(); | ||
| + } finally { | ||
| + Trace.endSection(); | ||
| } | ||
| - return check.checkRooted(); | ||
| } | ||
|
|
||
| - private final boolean jailMonkeyResult; | ||
| - private final RootBeerResults rootBeerResults; | ||
| + private static boolean jailMonkeyResult; | ||
| + private static RootBeerResults rootBeerResults; | ||
| + private static CountDownLatch latch = new CountDownLatch(1); | ||
| + public static void precompute(Context context) { | ||
| + new Thread(() -> { | ||
| + jailMonkeyResult = checkWithJailMonkeyMethod(); | ||
| + rootBeerResults = new RootBeerResults(context); | ||
| + latch.countDown(); | ||
| + }).start(); | ||
| + } | ||
|
|
||
| public RootedCheck(Context context) { | ||
| - jailMonkeyResult = checkWithJailMonkeyMethod(); | ||
| - rootBeerResults = new RootBeerResults(context); | ||
| + try { | ||
| + latch.await(); | ||
| + } catch (InterruptedException e) { | ||
| + throw new RuntimeException(e); | ||
| + } | ||
| } | ||
|
|
||
| public boolean isJailBroken() { | ||
| @@ -87,3 +106,4 @@ public class RootedCheck { | ||
| } | ||
| } | ||
| } | ||
| + | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you also drop a quick comment in packages/core-mobile/docs/patches.md about this patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done