diff --git a/android/src/main/kotlin/appmire/be/flutterjailbreakdetection/FlutterJailbreakDetectionPlugin.kt b/android/src/main/kotlin/appmire/be/flutterjailbreakdetection/FlutterJailbreakDetectionPlugin.kt index d34917c..0f7ad1c 100644 --- a/android/src/main/kotlin/appmire/be/flutterjailbreakdetection/FlutterJailbreakDetectionPlugin.kt +++ b/android/src/main/kotlin/appmire/be/flutterjailbreakdetection/FlutterJailbreakDetectionPlugin.kt @@ -41,6 +41,8 @@ class FlutterJailbreakDetectionPlugin : FlutterPlugin, MethodCallHandler { override fun onMethodCall(call: MethodCall, result: Result): Unit { if (call.method.equals("jailbroken")) { val rootBeer = RootBeer(context) + val setLoggingValue = call.argument("setLogging") == true + rootBeer.setLogging(setLoggingValue) result.success(rootBeer.isRooted) } else if (call.method.equals("developerMode")) { result.success(isDevMode()) diff --git a/example/lib/main.dart b/example/lib/main.dart index a6e84e7..50b8bbe 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -27,7 +27,7 @@ class _MyAppState extends State { bool developerMode; // Platform messages may fail, so we use a try/catch PlatformException. try { - jailbroken = await FlutterJailbreakDetection.jailbroken; + jailbroken = await FlutterJailbreakDetection.jailbroken(); developerMode = await FlutterJailbreakDetection.developerMode; } on PlatformException { jailbroken = true; @@ -52,10 +52,14 @@ class _MyAppState extends State { appBar: AppBar( title: const Text('Jailbroken plugin example app'), ), - body: Center( - child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [Text('Jailbroken: ${_jailbroken == null ? "Unknown" : _jailbroken! ? "YES" : "NO"}'), - Text('Developer mode: ${_developerMode == null ? "Unknown" : _developerMode! ? "YES" : "NO"}') + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Jailbroken: ${_jailbroken == null ? "Unknown" : _jailbroken! ? "YES" : "NO"}'), + Text( + 'Developer mode: ${_developerMode == null ? "Unknown" : _developerMode! ? "YES" : "NO"}') ], ), ), diff --git a/lib/flutter_jailbreak_detection.dart b/lib/flutter_jailbreak_detection.dart index 6adaace..226adc7 100644 --- a/lib/flutter_jailbreak_detection.dart +++ b/lib/flutter_jailbreak_detection.dart @@ -6,8 +6,10 @@ class FlutterJailbreakDetection { static const MethodChannel _channel = const MethodChannel('flutter_jailbreak_detection'); - static Future get jailbroken async { - bool? jailbroken = await _channel.invokeMethod('jailbroken'); + static Future jailbroken({bool setLogging = true}) async { + bool? jailbroken = await _channel.invokeMethod( + 'jailbroken', {"setLogging": setLogging}); + return jailbroken ?? true; }