Skip to content

Commit 41420f2

Browse files
authored
chore(release): 1.0.2
2 parents 6e318bc + 72a4800 commit 41420f2

37 files changed

+826
-544
lines changed

.fvmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"flutter": "stable"
3+
}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ migrate_working_dir/
2727
**/doc/api/
2828
.dart_tool/
2929
build/
30+
31+
# FVM Version Cache
32+
.fvm/
33+
34+
# Android
35+
.cxx

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ and ios. Please refer to readme to participate in native development
6363
Please use the latest Flutter Version. Use the provided example project to test
6464
or bug report any existing or new features.
6565

66+
Use Pigeon to update interfaces between flutter and native libraries:
67+
`dart run pigeon --input lib/src/pigeon.dart`
68+
6669
## Submitting changes
6770

6871
Before submitting your changes as a pull request, please make sure to format

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ android {
3333
namespace = "com.example.flutter_security_toolkit"
3434
}
3535

36-
compileSdk = 34
36+
compileSdk = 35
3737

3838
compileOptions {
3939
sourceCompatibility = JavaVersion.VERSION_1_8

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

android/src/main/kotlin/com/example/flutter_security_toolkit/FlutterSecurityToolkitPlugin.kt

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// Autogenerated from Pigeon (v26.0.1), do not edit directly.
2+
// See also: https://pub.dev/packages/pigeon
3+
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")
4+
5+
6+
import android.util.Log
7+
import io.flutter.plugin.common.BasicMessageChannel
8+
import io.flutter.plugin.common.BinaryMessenger
9+
import io.flutter.plugin.common.EventChannel
10+
import io.flutter.plugin.common.MessageCodec
11+
import io.flutter.plugin.common.StandardMethodCodec
12+
import io.flutter.plugin.common.StandardMessageCodec
13+
import java.io.ByteArrayOutputStream
14+
import java.nio.ByteBuffer
15+
private object ThreatCenterApiPigeonUtils {
16+
17+
fun wrapResult(result: Any?): List<Any?> {
18+
return listOf(result)
19+
}
20+
21+
fun wrapError(exception: Throwable): List<Any?> {
22+
return if (exception is FlutterError) {
23+
listOf(
24+
exception.code,
25+
exception.message,
26+
exception.details
27+
)
28+
} else {
29+
listOf(
30+
exception.javaClass.simpleName,
31+
exception.toString(),
32+
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)
33+
)
34+
}
35+
}
36+
}
37+
38+
/**
39+
* Error class for passing custom error details to Flutter via a thrown PlatformException.
40+
* @property code The error code.
41+
* @property message The error message.
42+
* @property details The error details. Must be a datatype supported by the api codec.
43+
*/
44+
class FlutterError (
45+
val code: String,
46+
override val message: String? = null,
47+
val details: Any? = null
48+
) : Throwable()
49+
private open class ThreatCenterApiPigeonCodec : StandardMessageCodec() {
50+
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
51+
return super.readValueOfType(type, buffer)
52+
}
53+
override fun writeValue(stream: ByteArrayOutputStream, value: Any?) {
54+
super.writeValue(stream, value)
55+
}
56+
}
57+
58+
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
59+
interface ThreatCenterApi {
60+
fun areRootPrivilegesDetected(): Boolean
61+
fun areHooksDetected(): Boolean
62+
fun isSimulatorDetected(): Boolean
63+
64+
companion object {
65+
/** The codec used by ThreatCenterApi. */
66+
val codec: MessageCodec<Any?> by lazy {
67+
ThreatCenterApiPigeonCodec()
68+
}
69+
/** Sets up an instance of `ThreatCenterApi` to handle messages through the `binaryMessenger`. */
70+
@JvmOverloads
71+
fun setUp(binaryMessenger: BinaryMessenger, api: ThreatCenterApi?, messageChannelSuffix: String = "") {
72+
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
73+
run {
74+
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_security_toolkit.ThreatCenterApi.areRootPrivilegesDetected$separatedMessageChannelSuffix", codec)
75+
if (api != null) {
76+
channel.setMessageHandler { _, reply ->
77+
val wrapped: List<Any?> = try {
78+
listOf(api.areRootPrivilegesDetected())
79+
} catch (exception: Throwable) {
80+
ThreatCenterApiPigeonUtils.wrapError(exception)
81+
}
82+
reply.reply(wrapped)
83+
}
84+
} else {
85+
channel.setMessageHandler(null)
86+
}
87+
}
88+
run {
89+
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_security_toolkit.ThreatCenterApi.areHooksDetected$separatedMessageChannelSuffix", codec)
90+
if (api != null) {
91+
channel.setMessageHandler { _, reply ->
92+
val wrapped: List<Any?> = try {
93+
listOf(api.areHooksDetected())
94+
} catch (exception: Throwable) {
95+
ThreatCenterApiPigeonUtils.wrapError(exception)
96+
}
97+
reply.reply(wrapped)
98+
}
99+
} else {
100+
channel.setMessageHandler(null)
101+
}
102+
}
103+
run {
104+
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_security_toolkit.ThreatCenterApi.isSimulatorDetected$separatedMessageChannelSuffix", codec)
105+
if (api != null) {
106+
channel.setMessageHandler { _, reply ->
107+
val wrapped: List<Any?> = try {
108+
listOf(api.isSimulatorDetected())
109+
} catch (exception: Throwable) {
110+
ThreatCenterApiPigeonUtils.wrapError(exception)
111+
}
112+
reply.reply(wrapped)
113+
}
114+
} else {
115+
channel.setMessageHandler(null)
116+
}
117+
}
118+
}
119+
}
120+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
package com.exxeta.security_toolkit
3+
4+
import ThreatCenterApi
5+
import com.exxeta.securitytoolkit.ThreatDetectionCenter
6+
import io.flutter.embedding.engine.plugins.FlutterPlugin
7+
8+
class ThreatCenterApiImpl : FlutterPlugin, ThreatCenterApi {
9+
private lateinit var threatDetectionCenter: ThreatDetectionCenter
10+
11+
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
12+
threatDetectionCenter = ThreatDetectionCenter(binding.applicationContext)
13+
ThreatCenterApi.setUp(binding.binaryMessenger, this)
14+
}
15+
16+
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
17+
ThreatCenterApi.setUp(binding.binaryMessenger, null)
18+
}
19+
20+
// MARK: - ThreatCenterApi
21+
22+
override fun areRootPrivilegesDetected(): Boolean {
23+
return threatDetectionCenter.areRootPrivilegesDetected
24+
}
25+
26+
override fun areHooksDetected(): Boolean {
27+
return threatDetectionCenter.areHooksDetected
28+
}
29+
30+
override fun isSimulatorDetected(): Boolean {
31+
return threatDetectionCenter.isSimulatorDetected
32+
}
33+
}

example/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*.swp
66
.DS_Store
77
.atom/
8+
.build/
89
.buildlog/
910
.history
1011
.svn/
12+
.swiftpm/
1113
migrate_working_dir/
1214

1315
# IntelliJ related

example/android/app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ android {
3333
targetCompatibility = JavaVersion.VERSION_1_8
3434
}
3535

36+
kotlinOptions {
37+
jvmTarget = JavaVersion.VERSION_1_8
38+
}
39+
3640
defaultConfig {
3741
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
3842
applicationId = "com.example.flutter_security_toolkit_example"

0 commit comments

Comments
 (0)