25-2/24/1

This commit is contained in:
Hamza-Ayed
2025-02-24 23:38:42 +03:00
parent 218e174c87
commit 3162b1bec6
56 changed files with 1318 additions and 527 deletions

View File

@@ -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:

View File

@@ -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() // يغلق جميع الأنشطة ويفتح نافذة جديدة
}
}

View File

@@ -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 // نفترض أن الجهاز موثوق
}
}

View 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>

View File

@@ -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>

View File

@@ -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