Skip to content

Commit d7f28e3

Browse files
authored
Merge pull request #1 from vicajilau/feature/update-project
Sync Fork
2 parents 31c272e + 29c722b commit d7f28e3

File tree

6 files changed

+114
-34
lines changed

6 files changed

+114
-34
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Flutter Plugin CI
2+
3+
on:
4+
push:
5+
branches: [main, migrate/gradle]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build_android:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout source
14+
uses: actions/checkout@v4
15+
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v4
18+
with:
19+
distribution: temurin
20+
java-version: "17"
21+
22+
- name: Set up Flutter
23+
uses: subosito/flutter-action@v2
24+
with:
25+
flutter-version: "3.35.4"
26+
27+
- name: Cache Flutter dependencies
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/.pub-cache
31+
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
32+
restore-keys: ${{ runner.os }}-pub-
33+
34+
- name: Install dependencies
35+
run: flutter pub get
36+
37+
- name: Build example (Android)
38+
working-directory: example
39+
run: flutter build apk --debug
40+
41+
- name: List .so 16KB page-size compatibility
42+
shell: bash
43+
run: |
44+
APK="example/build/app/outputs/flutter-apk/app-debug.apk"
45+
unzip -o "$APK" -d output_apk >/dev/null
46+
47+
while IFS= read -r -d '' so; do
48+
aligns=$(readelf -Wl "$so" | awk '/Program Headers/{ph=1} ph && /LOAD/ {for (i=1;i<=NF;i++) if ($i=="Align") print $(i+1)}')
49+
ok=true
50+
for a in $aligns; do
51+
if [[ "$a" =~ ^0x ]]; then val=$((a)); else val=$a; fi
52+
if [ "$val" -lt 16384 ]; then
53+
ok=false
54+
break
55+
fi
56+
done
57+
if $ok; then
58+
echo "[OK] $so (16KB SAFE)"
59+
else
60+
echo "[FAIL] $so (NOT 16KB SAFE)"
61+
fi
62+
done < <(find output_apk -name "*.so" -print0)
63+
64+
build_ios:
65+
runs-on: macos-latest
66+
steps:
67+
- name: Checkout source
68+
uses: actions/checkout@v4
69+
70+
- name: Set up Flutter
71+
uses: subosito/flutter-action@v2
72+
with:
73+
flutter-version: "3.35.4"
74+
75+
- name: Cache Flutter dependencies
76+
uses: actions/cache@v3
77+
with:
78+
path: ~/.pub-cache
79+
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
80+
restore-keys: ${{ runner.os }}-pub-
81+
82+
- name: Install dependencies
83+
run: flutter pub get
84+
85+
- name: Build example (iOS)
86+
working-directory: example
87+
run: flutter build ios --no-codesign

CHANGELOG.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 1.2.0
2+
3+
* Added support for 16 KB page sizes
4+
* Upgraded compileSdk and Gradle version
5+
* Added background execution support
6+
* Added null-safety support in `ExternalStorageCheck.kt`
7+
* Acknowledgements: Thanks to @n0ks, @maeddin, @vicajilau, @anderscheow, and @bjlf12 for their PRs 🙏
8+
19
## 1.1.6
210

311
* fix: TARGET_OS_SIMULATOR is deprecated in swift
@@ -40,15 +48,15 @@
4048

4149
## 0.0.5
4250

43-
* Change library for check detect frida
51+
* Change library for check detect frida
4452

4553
## 0.0.4
4654

47-
* Config jniLibs by "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
55+
* Config jniLibs by "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
4856

4957
## 0.0.3
5058

51-
* Config ndk abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
59+
* Config ndk abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
5260

5361
## 0.0.2
5462

android/src/main/kotlin/com/w3conext/jailbreak_root_detection/JailbreakRootDetectionPlugin.kt

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.w3conext.jailbreak_root_detection
22

3-
import android.app.Activity
3+
import android.content.Context
44
import com.anish.trust_fall.emulator.EmulatorCheck
55
import com.anish.trust_fall.externalstorage.ExternalStorageCheck
66
import com.anish.trust_fall.rooted.RootedCheck
@@ -10,8 +10,6 @@ import com.w3conext.jailbreak_root_detection.devmode.DevMode
1010
import com.w3conext.jailbreak_root_detection.frida.AntiFridaChecker
1111
import com.w3conext.jailbreak_root_detection.magisk.MagiskChecker
1212
import io.flutter.embedding.engine.plugins.FlutterPlugin
13-
import io.flutter.embedding.engine.plugins.activity.ActivityAware
14-
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
1513
import io.flutter.plugin.common.MethodCall
1614
import io.flutter.plugin.common.MethodChannel
1715
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
@@ -22,17 +20,18 @@ import kotlinx.coroutines.Job
2220
import kotlinx.coroutines.launch
2321

2422
/** JailbreakRootDetectionPlugin */
25-
class JailbreakRootDetectionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
23+
class JailbreakRootDetectionPlugin : FlutterPlugin, MethodCallHandler {
2624

2725
/// The MethodChannel that will the communication between Flutter and native Android
2826
///
2927
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
3028
/// when the Flutter Engine is detached from the Activity
3129
private lateinit var channel: MethodChannel
3230

33-
private var activity: Activity? = null
31+
private lateinit var appContext: Context
3432

3533
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
34+
appContext = flutterPluginBinding.applicationContext
3635
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "jailbreak_root_detection")
3736
channel.setMethodCallHandler(this)
3837
}
@@ -43,11 +42,11 @@ class JailbreakRootDetectionPlugin : FlutterPlugin, MethodCallHandler, ActivityA
4342
"isJailBroken" -> processJailBroken(result)
4443
"isRealDevice" -> result.success(!EmulatorCheck.isEmulator)
4544
"isOnExternalStorage" -> result.success(
46-
ExternalStorageCheck.isOnExternalStorage(activity)
45+
ExternalStorageCheck.isOnExternalStorage(appContext)
4746
)
4847

49-
"isDevMode" -> result.success(DevMode.isDevMode(activity))
50-
"isDebugged" -> result.success(Debugger.isDebugged(activity))
48+
"isDevMode" -> result.success(DevMode.isDevMode(appContext))
49+
"isDebugged" -> result.success(Debugger.isDebugged(appContext))
5150
else -> result.notImplemented()
5251
}
5352
}
@@ -56,40 +55,26 @@ class JailbreakRootDetectionPlugin : FlutterPlugin, MethodCallHandler, ActivityA
5655
channel.setMethodCallHandler(null)
5756
}
5857

59-
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
60-
activity = binding.activity
61-
}
62-
63-
override fun onDetachedFromActivityForConfigChanges() {}
64-
65-
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
66-
activity = binding.activity
67-
}
68-
69-
override fun onDetachedFromActivity() {
70-
activity = null
71-
}
72-
7358
private fun processCheckIssues(result: Result) {
7459
val scope = CoroutineScope(Job() + Dispatchers.Default)
7560
scope.launch {
7661

77-
QLog.LOGGING_LEVEL = QLog.NONE;
62+
QLog.LOGGING_LEVEL = QLog.NONE
7863

7964
val issues = mutableListOf<String>()
80-
if (RootedCheck.isJailBroken(activity)) {
65+
if (RootedCheck.isJailBroken(appContext)) {
8166
issues.add("jailbreak")
8267
}
8368

8469
if (AntiFridaChecker.checkFrida()) {
8570
issues.add("fridaFound")
8671
}
8772

88-
if (Debugger.isDebugged(activity)) {
73+
if (Debugger.isDebugged(appContext)) {
8974
issues.add("debugged")
9075
}
9176

92-
if (DevMode.isDevMode(activity)) {
77+
if (DevMode.isDevMode(appContext)) {
9378
issues.add("devMode")
9479
}
9580

@@ -101,7 +86,7 @@ class JailbreakRootDetectionPlugin : FlutterPlugin, MethodCallHandler, ActivityA
10186
issues.add("notRealDevice")
10287
}
10388

104-
if (ExternalStorageCheck.isOnExternalStorage(activity)) {
89+
if (ExternalStorageCheck.isOnExternalStorage(appContext)) {
10590
issues.add("onExternalStorage")
10691
}
10792

@@ -115,7 +100,7 @@ class JailbreakRootDetectionPlugin : FlutterPlugin, MethodCallHandler, ActivityA
115100

116101
QLog.LOGGING_LEVEL = QLog.NONE;
117102

118-
val isRootBeer = RootedCheck.isJailBroken(activity)
103+
val isRootBeer = RootedCheck.isJailBroken(appContext)
119104
val isFrida = AntiFridaChecker.checkFrida()
120105
val isMagisk = MagiskChecker.isInstalled()
121106
val isRooted = isRootBeer || isFrida || isMagisk

example/android/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gradle-wrapper.jar
77
GeneratedPluginRegistrant.java
88

99
# Remember to never publicly share your keystore.
10-
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
10+
# See https://flutter.dev/to/reference-keystore
1111
key.properties
1212
**/*.keystore
1313
**/*.jks

example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
org.gradle.jvmargs=-Xmx1536M
1+
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
33
android.enableJetifier=true

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class _MyAppState extends State<MyApp> {
3535
children: [
3636
Text(_result),
3737
ElevatedButton(
38-
onPressed: () => _processCheckJailbreakRoot,
38+
onPressed: _processCheckJailbreakRoot,
3939
child: const Text('Check'),
4040
),
4141
],

0 commit comments

Comments
 (0)