diff --git a/android/build/reports/problems/problems-report.html b/android/build/reports/problems/problems-report.html
index 30f5fa8..8733504 100644
--- a/android/build/reports/problems/problems-report.html
+++ b/android/build/reports/problems/problems-report.html
@@ -650,7 +650,7 @@ code + .copy-button {
diff --git a/lib/features/security/security_error_screen.dart b/lib/features/security/security_error_screen.dart
new file mode 100644
index 0000000..01698a1
--- /dev/null
+++ b/lib/features/security/security_error_screen.dart
@@ -0,0 +1,35 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:lottie/lottie.dart';
+
+class SecurityErrorScreen extends StatelessWidget {
+ final String message;
+
+ const SecurityErrorScreen({Key? key, required this.message}) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ body: Padding(
+ padding: const EdgeInsets.all(20.0),
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Lottie.asset('assets/animations/error.json', height: 200),
+ const SizedBox(height: 20),
+ Text(
+ message,
+ textAlign: TextAlign.center,
+ style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
+ ),
+ const SizedBox(height: 40),
+ ElevatedButton(
+ onPressed: () => SystemChannels.platform.invokeMethod('SystemNavigator.pop'),
+ child: const Text('Okay'),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/main.dart b/lib/main.dart
index 0d372f3..d79c64f 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
+import 'package:kmobile/features/security/security_error_screen.dart';
+import 'package:kmobile/security/security_service.dart';
import 'di/injection.dart';
import 'app.dart';
@@ -12,6 +14,15 @@ void main() async {
DeviceOrientation.portraitDown,
]);
+ // Check for device compromise
+ final compromisedMessage = await SecurityService.deviceCompromisedMessage;
+ if (compromisedMessage != null) {
+ runApp(MaterialApp(
+ home: SecurityErrorScreen(message: compromisedMessage),
+ ));
+ return;
+ }
+
// Initialize dependencies
await setupDependencies();
runApp(const KMobile());
diff --git a/lib/security/security_service.dart b/lib/security/security_service.dart
new file mode 100644
index 0000000..cdcf2b3
--- /dev/null
+++ b/lib/security/security_service.dart
@@ -0,0 +1,31 @@
+import 'dart:io';
+
+import 'package:jailbreak_root_detection/jailbreak_root_detection.dart';
+
+class SecurityService {
+ static Future get deviceCompromisedMessage async {
+ final isNotTrust = await JailbreakRootDetection.instance.isNotTrust;
+ if (isNotTrust) {
+ return 'Your device is rooted or jailbroken. For security reasons, you cannot access our services on a compromised device.';
+ }
+
+ final isRealDevice = await JailbreakRootDetection.instance.isRealDevice;
+ if (!isRealDevice) {
+ return 'Emulators are not allowed to access our services. Please use a real device.';
+ }
+
+ if (Platform.isAndroid) {
+ try {
+ final isOnExternalStorage =
+ await JailbreakRootDetection.instance.isOnExternalStorage;
+ if (isOnExternalStorage) {
+ return 'The application cannot be run from external storage.';
+ }
+ } catch (e) {
+ // Ignore
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/pubspec.lock b/pubspec.lock
index 4c68879..e7542f1 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -357,6 +357,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.20.2"
+ jailbreak_root_detection:
+ dependency: "direct main"
+ description:
+ name: jailbreak_root_detection
+ sha256: c611229940a09785bd686364e92a40b07724926d2496c931527805101eb3da86
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.6"
js:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 4979312..1cb7371 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -36,6 +36,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.6
+ jailbreak_root_detection: ^1.1.6
equatable: ^2.0.7
dio: ^5.8.0+1
flutter_secure_storage: ^9.2.4