25-2/24/1
This commit is contained in:
@@ -55,8 +55,8 @@ android {
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||
minSdk = 23
|
||||
targetSdk = flutter.targetSdkVersion
|
||||
versionCode = 135
|
||||
versionName = '2.0.135'
|
||||
versionCode = 136
|
||||
versionName = '2.0.136'
|
||||
multiDexEnabled =true
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ flutter {
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
implementation 'com.scottyab:rootbeer-lib:0.1.0'
|
||||
implementation 'com.stripe:paymentsheet:20.52.2'
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
|
||||
|
||||
|
||||
@@ -1,21 +1,95 @@
|
||||
package com.sefer_driver
|
||||
|
||||
import android.content.Intent
|
||||
// import android.content.Intent
|
||||
// import io.flutter.embedding.android.FlutterFragmentActivity
|
||||
// import io.flutter.embedding.engine.FlutterEngine
|
||||
|
||||
// class MainActivity : FlutterFragmentActivity() {
|
||||
// override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
// try {
|
||||
// super.configureFlutterEngine(MyApplication.flutterEngine)
|
||||
// } catch (e: UninitializedPropertyAccessException) {
|
||||
// super.configureFlutterEngine(flutterEngine)
|
||||
// }
|
||||
// }
|
||||
|
||||
// private fun bringAppToForeground() {
|
||||
// val intent = Intent(this, MainActivity::class.java)
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||
// startActivity(intent)
|
||||
// }
|
||||
// }
|
||||
import android.app.AlertDialog
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import io.flutter.embedding.android.FlutterFragmentActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import java.util.*
|
||||
|
||||
class MainActivity : FlutterFragmentActivity() {
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
try {
|
||||
super.configureFlutterEngine(MyApplication.flutterEngine)
|
||||
} catch (e: UninitializedPropertyAccessException) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
Log.d("DEBUG", "onCreate executed - Checking root status...")
|
||||
|
||||
// بدء فحص الأمان
|
||||
performSecurityChecks()
|
||||
}
|
||||
|
||||
private fun performSecurityChecks() {
|
||||
val rootDetection = RootDetection
|
||||
|
||||
val isRooted = rootDetection.isRooted()
|
||||
val isDevMode = rootDetection.isDevMode(this)
|
||||
val isTampered = rootDetection.isTampered(this)
|
||||
val isRealDevice = rootDetection.isRealDevice()
|
||||
val isOnExternalStorage = rootDetection.isOnExternalStorage()
|
||||
val isNotTrust = rootDetection.isNotTrust()
|
||||
val checkForIssues = rootDetection.checkForIssues()
|
||||
|
||||
// Log.d("DEBUG", "Security Check Results:")
|
||||
// Log.d("DEBUG", "isRooted: $isRooted")
|
||||
// Log.d("DEBUG", "isDevMode: $isDevMode")
|
||||
// Log.d("DEBUG", "isTampered: $isTampered")
|
||||
// Log.d("DEBUG", "isRealDevice: $isRealDevice")
|
||||
// Log.d("DEBUG", "isOnExternalStorage: $isOnExternalStorage")
|
||||
// Log.d("DEBUG", "isNotTrust: $isNotTrust")
|
||||
// Log.d("DEBUG", "checkForIssues: $checkForIssues")
|
||||
|
||||
if (isRooted || isTampered || !isRealDevice || isOnExternalStorage || isNotTrust) {
|
||||
// Log.e("DEBUG", "Security issue detected! Showing dialog.")
|
||||
showSecurityWarningDialog()
|
||||
} else {
|
||||
// Log.d(
|
||||
// "DEBUG",
|
||||
// getString(R.string.device_secure)
|
||||
// ) // Using dynamic string based on the device language
|
||||
}
|
||||
}
|
||||
|
||||
private fun bringAppToForeground() {
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||
startActivity(intent)
|
||||
private fun showSecurityWarningDialog() {
|
||||
val builder = AlertDialog.Builder(this)
|
||||
builder.setTitle(getString(R.string.security_warning_title)) // Title based on language
|
||||
builder.setMessage(
|
||||
getString(R.string.security_warning_message)
|
||||
) // Message based on language
|
||||
|
||||
builder.setPositiveButton(getString(R.string.exit_button)) { _, _ ->
|
||||
Log.e("DEBUG", "User clicked exit. Closing app.")
|
||||
clearAppDataAndExit()
|
||||
}
|
||||
|
||||
builder.setCancelable(false)
|
||||
val alertDialog = builder.create()
|
||||
alertDialog.show()
|
||||
}
|
||||
|
||||
private fun clearAppDataAndExit() {
|
||||
// حذف جميع البيانات هنا، مثل ملفات التخزين وبيانات التطبيق
|
||||
// يمكنك استخدام SharedPreferences أو قاعدة بيانات
|
||||
Log.d("DEBUG", "Clearing app data...")
|
||||
|
||||
// يمكنك استخدام كود لحذف جميع البيانات (SharedPreferences, DB, ملفات)
|
||||
// ثم إغلاق التطبيق:
|
||||
finishAffinity() // يغلق جميع الأنشطة ويفتح نافذة جديدة
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.sefer_driver
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.provider.Settings
|
||||
import com.scottyab.rootbeer.RootBeer
|
||||
import java.io.File
|
||||
|
||||
object RootDetection {
|
||||
|
||||
fun isRooted(): Boolean {
|
||||
val paths =
|
||||
arrayOf(
|
||||
"/system/app/Superuser.apk",
|
||||
"/system/xbin/su",
|
||||
"/system/bin/su",
|
||||
"/system/bin/magisk",
|
||||
"/system/xbin/magisk",
|
||||
"/sbin/magisk"
|
||||
)
|
||||
for (path in paths) {
|
||||
if (File(path).exists()) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun isDevMode(context: Context): Boolean {
|
||||
return Settings.Global.getInt(
|
||||
context.contentResolver,
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
|
||||
0
|
||||
) == 1
|
||||
}
|
||||
|
||||
fun isTampered(context: Context): Boolean {
|
||||
val rootBeer = RootBeer(context)
|
||||
return rootBeer.isRooted
|
||||
}
|
||||
|
||||
fun checkForIssues(): Boolean {
|
||||
// يمكنك إضافة المزيد من الفحوصات حسب حاجتك
|
||||
return false // نفترض أنه لا توجد مشاكل للأجهزة غير المتجذرة
|
||||
}
|
||||
|
||||
fun isRealDevice(): Boolean {
|
||||
return !Build.FINGERPRINT.contains("generic") && !Build.MODEL.contains("google_sdk")
|
||||
}
|
||||
|
||||
fun isOnExternalStorage(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
|
||||
Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED
|
||||
}
|
||||
|
||||
fun isNotTrust(): Boolean {
|
||||
// مثال تحقق من الثقة (قد تحتاج لتطوير هذا حسب متطلباتك)
|
||||
return false // نفترض أن الجهاز موثوق
|
||||
}
|
||||
}
|
||||
6
android/app/src/main/res/values-ar/strings.xml
Normal file
6
android/app/src/main/res/values-ar/strings.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<string name="security_warning_title">تحذير أمني</string>
|
||||
<string name="security_warning_message">تم اكتشاف مشكلة أمنية أو تعديل على هذا الجهاز. لا يمكن تشغيل التطبيق على هذا الجهاز.</string>
|
||||
<string name="exit_button">إغلاق التطبيق</string>
|
||||
<string name="device_secure">الجهاز آمن. الاستمرار بشكل طبيعي.</string>
|
||||
</resources>
|
||||
@@ -4,6 +4,11 @@
|
||||
<string name="api_key">AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0</string>
|
||||
<string name="channel_name">FCM Notifications</string>
|
||||
<string name="channel_description">Notifications from Firebase Cloud Messaging</string>
|
||||
<string name="security_warning_title">Security Warning</string>
|
||||
<string name="security_warning_message">A security issue or modification has been detected on
|
||||
this device. The app cannot run on this device.</string>
|
||||
<string name="exit_button">Exit App</string>
|
||||
<string name="device_secure">Device is secure. Proceeding normally.</string>
|
||||
|
||||
|
||||
</resources>
|
||||
@@ -1,8 +1,8 @@
|
||||
# org.gradle.jvmargs=-Xmx1536M
|
||||
org.gradle.jvmargs=-Xmx4096M
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
org.gradle.jvmargs=-Xmx4096m
|
||||
android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonTransitiveRClass=false
|
||||
android.nonFinalResIds=false
|
||||
android.nonTransitiveRClass=true
|
||||
android.nonFinalResIds=true
|
||||
dart.obfuscation=true
|
||||
android.enableR8.fullMode=true
|
||||
Reference in New Issue
Block a user