Skip to content
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

Added arg jailbroken method to allow for disabling RootBeer logging #42

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean?>("setLogging") == true
rootBeer.setLogging(setLoggingValue)
result.success(rootBeer.isRooted)
} else if (call.method.equals("developerMode")) {
result.success(isDevMode())
Expand Down
14 changes: 9 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class _MyAppState extends State<MyApp> {
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;
Expand All @@ -52,10 +52,14 @@ class _MyAppState extends State<MyApp> {
appBar: AppBar(
title: const Text('Jailbroken plugin example app'),
),
body: Center(
child: Column( mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[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: <Widget>[
Text(
'Jailbroken: ${_jailbroken == null ? "Unknown" : _jailbroken! ? "YES" : "NO"}'),
Text(
'Developer mode: ${_developerMode == null ? "Unknown" : _developerMode! ? "YES" : "NO"}')
],
),
),
Expand Down
6 changes: 4 additions & 2 deletions lib/flutter_jailbreak_detection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ class FlutterJailbreakDetection {
static const MethodChannel _channel =
const MethodChannel('flutter_jailbreak_detection');

static Future<bool> get jailbroken async {
bool? jailbroken = await _channel.invokeMethod<bool>('jailbroken');
static Future<bool> jailbroken({bool setLogging = true}) async {
bool? jailbroken = await _channel.invokeMethod<bool>(
'jailbroken', <String, dynamic>{"setLogging": setLogging});

return jailbroken ?? true;
}

Expand Down