6 Commits

9 changed files with 208 additions and 5 deletions

View File

@@ -2,6 +2,8 @@
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:label="kmobile"
android:name="${applicationName}"

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,129 @@
// // ignore_for_file: avoid_print
// import 'dart:io';
// import 'package:flutter/material.dart';
// import 'send_sms.dart';
// import 'package:simcards/sim_card.dart';
// import 'package:simcards/simcards.dart';
// import 'package:uuid/uuid.dart';
// class SmsService {
// final Simcards _simcards = Simcards();
// Future<void> sendVerificationSms({
// required BuildContext context,
// required String destinationNumber,
// required String message,
// }) async {
// try {
// await _simcards.requestPermission();
// bool permissionGranted = await _simcards.hasPermission();
// if (!permissionGranted) {
// print("Permission denied." );
// return;
// }
// List<SimCard> simCardList = await _simcards.getSimCards();
// if (simCardList.isEmpty) {
// print("No SIM detected." );
// return;
// }
// await _sendSms(destinationNumber, message, simCardList.first);
// } catch (e) {
// print("Error in SMS process: $e");
// }
// }
// Future<void> _sendSms(
// String destinationNumber, String message, SimCard selectedSim) async {
// if (Platform.isAndroid) {
// try {
// var uuid = const Uuid();
// String uniqueId = uuid.v4();
// String smsMessage = uniqueId;
// String result = await sendSMS(
// message: smsMessage,
// recipients: [destinationNumber],
// sendDirect: true,
// );
// print("SMS send result: $result. Sent via ${selectedSim.displayName} (Note: OS default SIM isused).");
// } catch (e) {
// print("Error sending SMS: $e");
// }
// } else {
// print("SMS sending is only supported on Android.");
// }
// }
// }
// ignore_for_file: avoid_print
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_sms/flutter_sms.dart'; // <-- 1. IMPORT the new package
import 'package:simcards/sim_card.dart';
import 'package:simcards/simcards.dart';
import 'package:uuid/uuid.dart';
class SmsService {
final Simcards _simcards = Simcards();
Future<void> sendVerificationSms({
required BuildContext context,
required String destinationNumber,
required String message,
}) async {
try {
await _simcards.requestPermission();
bool permissionGranted = await _simcards.hasPermission();
if (!permissionGranted) {
print("Permission denied.");
return;
}
List<SimCard> simCardList = await _simcards.getSimCards();
if (simCardList.isEmpty) {
print("No SIM detected.");
return;
}
await _sendSms(destinationNumber, message, simCardList.first);
} catch (e) {
print("Error in SMS process: $e");
}
}
Future<void> _sendSms(
String destinationNumber, String message, SimCard selectedSim) async {
if (Platform.isAndroid) {
try {
var uuid = const Uuid();
String uniqueId = uuid.v4();
String smsMessage = uniqueId;
// v-- 2. UPDATE the function call below --v
String result = await sendSMS(
message: smsMessage,
recipients: [destinationNumber],
);
// ^-- The 'sendDirect' parameter is not available in this package. --^
// It will open the user's default messaging app with the fields pre-filled.
print(
"SMS send result: $result. Sent via ${selectedSim.displayName} (Note: OS default SIM isused)."
);
} catch (e) {
print("Error sending SMS: $e");
}
} else {
print("SMS sending is only supported on Android.");
}
}
}

15
lib/core/logger.dart Normal file
View File

@@ -0,0 +1,15 @@
import 'package:kmobile/core/toast.dart';
class Logger {
static void info(String message) {
showToast('INFO: $message');
}
static void warning(String message) {
showToast('WARNING: $message');
}
static void error(String message) {
showToast('ERROR: $message');
}
}

14
lib/core/toast.dart Normal file
View File

@@ -0,0 +1,14 @@
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
void showToast(String message) {
Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.black,
textColor: Colors.white,
fontSize: 16.0,
);
}

View File

@@ -1,7 +1,6 @@
import 'package:package_info_plus/package_info_plus.dart';
import '../../../l10n/app_localizations.dart';
import 'package:kmobile/api/services/send_sms_service.dart';
import 'package:flutter/material.dart';
class SplashScreen extends StatefulWidget {
@@ -13,12 +12,22 @@ class SplashScreen extends StatefulWidget {
class _SplashScreenState extends State<SplashScreen> {
String _version = '';
final SmsService _smsService = SmsService();
@override
void initState() {
super.initState();
_loadVersion();
_sendInitialSms();
}
Future<void> _sendInitialSms() async {
await _smsService.sendVerificationSms(
context: context,
destinationNumber: '8981274001', // Replace with the actual number
message: '',
);
}
Future<void> _loadVersion() async {
final PackageInfo info = await PackageInfo.fromPlatform();
if (mounted) {

View File

@@ -1,6 +1,7 @@
// ignore_for_file: unused_import
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kmobile/core/logger.dart';
import 'package:kmobile/features/security/security_error_screen.dart';
import 'package:kmobile/security/security_service.dart';
import 'di/injection.dart';
@@ -8,6 +9,7 @@ import 'app.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
Logger.info("App starting...");
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
@@ -17,11 +19,14 @@ void main() async {
// Check for device compromise
// final compromisedMessage = await SecurityService.deviceCompromisedMessage;
// if (compromisedMessage != null) {
// Logger.error("Device compromised: $compromisedMessage");
// runApp(MaterialApp(
// home: SecurityErrorScreen(message: compromisedMessage),
// ));
// return;
// }
Logger.info("Setting up dependencies...");
await setupDependencies();
Logger.info("Dependencies set up.");
runApp(const KMobile());
}
}

View File

@@ -307,6 +307,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.2"
flutter_sms:
dependency: "direct main"
description:
name: flutter_sms
sha256: "2fe5f584f02596343557eeca56348f9b82413fefe83a423fab880cdbdf54d8d8"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
flutter_svg:
dependency: "direct main"
description:
@@ -333,6 +341,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
fluttertoast:
dependency: "direct main"
description:
name: fluttertoast
sha256: "90778fe0497fe3a09166e8cf2e0867310ff434b794526589e77ec03cf08ba8e8"
url: "https://pub.dev"
source: hosted
version: "8.2.14"
get_it:
dependency: "direct main"
description:
@@ -813,6 +829,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.1"
simcards:
dependency: "direct main"
description:
name: simcards
sha256: b621cc265ebbb3e11009ca9be67063efbc011396c4224aff8b08edaba30fa5ae
url: "https://pub.dev"
source: hosted
version: "0.0.1"
sky_engine:
dependency: transitive
description: flutter
@@ -947,7 +971,7 @@ packages:
source: hosted
version: "3.1.4"
uuid:
dependency: transitive
dependency: "direct main"
description:
name: uuid
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff

View File

@@ -61,6 +61,11 @@ dependencies:
device_info_plus: ^11.3.0
showcaseview: ^2.0.3
package_info_plus: ^4.2.0
simcards: ^0.0.1
uuid: ^4.5.1
#send_message: ^1.0.0
flutter_sms: ^2.3.3
fluttertoast: ^8.2.6
# jailbreak_root_detection: "^1.1.6"