25-2/24/1
This commit is contained in:
@@ -61,8 +61,8 @@ android {
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||
minSdk = 23
|
||||
targetSdk = flutter.targetSdkVersion
|
||||
versionCode = 118
|
||||
versionName = '2.0.118'
|
||||
versionCode = 121
|
||||
versionName = '2.0.121'
|
||||
multiDexEnabled =true
|
||||
|
||||
// manifestPlaceholders can be specified here if needed
|
||||
@@ -98,6 +98,7 @@ dependencies {
|
||||
// implementation platform('com.google.firebase:firebase-bom:32.1.1')
|
||||
implementation "com.stripe:stripe-android:20.52.2"
|
||||
implementation 'com.stripe:paymentsheet:20.52.2'
|
||||
implementation 'com.scottyab:rootbeer-lib:0.1.0'
|
||||
|
||||
|
||||
// If push provisioning is needed, make sure you have the correct version:
|
||||
|
||||
@@ -1,8 +1,76 @@
|
||||
package com.mobileapp.store.ride
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import io.flutter.embedding.android.FlutterFragmentActivity
|
||||
import java.util.*
|
||||
|
||||
class MainActivity: FlutterFragmentActivity() {
|
||||
}
|
||||
class MainActivity : FlutterFragmentActivity() {
|
||||
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) {
|
||||
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 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.mobileapp.store.ride
|
||||
|
||||
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,4 +4,10 @@
|
||||
<!-- <string name="default_notification_channel_id">default_channel</string> -->
|
||||
<string name="default_notification_channel_id">high_importance_channel</string>
|
||||
<string name="api_key">AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0</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>
|
||||
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
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