Skip to content
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
30 changes: 19 additions & 11 deletions .idea/libraries/Dart_SDK.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 63 additions & 30 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package space.wisnuwiry.root_detector

import android.content.Context
import androidx.annotation.NonNull
import android.os.Build
import com.scottyab.rootbeer.RootBeer

import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import java.lang.IllegalArgumentException
import android.os.Build

/** RootDetectorPlugin */
class RootDetectorPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
Expand All @@ -24,15 +21,15 @@ class RootDetectorPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
private lateinit var context: Context
private lateinit var rootBeer: RootBeer

override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel =
MethodChannel(flutterPluginBinding.binaryMessenger, "space.wisnuwiry/root_detector")
channel.setMethodCallHandler(this)
context = flutterPluginBinding.applicationContext
rootBeer = RootBeer(context)
}

override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
override fun onMethodCall(call: MethodCall, result: Result) {
val ignoreSimulator = call.arguments == true

if (call.method == "checkIsRooted") {
Expand All @@ -46,7 +43,7 @@ class RootDetectorPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {


// Get check root status in normal devices
private fun checkIsRooted(@NonNull result: Result, ignoreSimulator: Boolean) {
private fun checkIsRooted(result: Result, ignoreSimulator: Boolean) {
try {
val isRoot = rootBeer.isRooted
if (isRoot && ignoreSimulator && isEmulator()) {
Expand All @@ -55,7 +52,7 @@ class RootDetectorPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
result.success(isRoot)
}
} catch (e: IllegalArgumentException) {
result.error(e.message, e.message, e.stackTrace)
result.error(e.message.toString(), e.message, e.stackTrace)
}
}

Expand All @@ -64,7 +61,7 @@ class RootDetectorPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
// - All OnePlus Devices
// - Moto E
// - OPPO R9m (ColorOS 3.0,Android 5.1,Android security patch January 5, 2018 )
private fun checkIsRootedWithBusyBox(@NonNull result: Result, ignoreSimulator: Boolean) {
private fun checkIsRootedWithBusyBox(result: Result, ignoreSimulator: Boolean) {
try {
val isRoot = rootBeer.isRootedWithBusyBoxCheck
if (isRoot && ignoreSimulator && isEmulator()) {
Expand All @@ -73,11 +70,11 @@ class RootDetectorPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
result.success(isRoot)
}
} catch (e: IllegalArgumentException) {
result.error(e.message, e.message, e.stackTrace)
result.error(e.message.toString(), e.message, e.stackTrace)
}
}

override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
}

Expand Down
49 changes: 21 additions & 28 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.1"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,28 +21,21 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -56,7 +49,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -73,21 +66,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.2"
root_detector:
dependency: "direct main"
description:
Expand All @@ -106,7 +106,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
Expand All @@ -127,35 +127,28 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.12"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.2"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.0.0"
Loading