diff --git a/lib/core/service/security_service.dart b/lib/core/service/security_service.dart index bacd46e8..407dac52 100644 --- a/lib/core/service/security_service.dart +++ b/lib/core/service/security_service.dart @@ -44,6 +44,8 @@ abstract class SecurityService { void setOnCriticalThreatCallback(OnCriticalThreatDetected callback); } +SecurityService service = SecurityServiceImpl(); + /// Implementation of SecurityService using Talsec (freeRASP) class SecurityServiceImpl implements SecurityService { Logger logger = Logger( diff --git a/lib/locator.dart b/lib/locator.dart index 39aba533..1be76422 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -156,5 +156,5 @@ void setupLocator() { locator.registerFactory(() => InterventionMedicationViewModel()); locator.registerFactory(() => ERSignInViewModel()); locator.registerFactory(() => PharmacyInterventionViewModel()); - locator.registerFactory(() => SecurityServiceImpl()); + locator.registerFactory(() => SecurityServiceImpl()); } diff --git a/lib/main.dart b/lib/main.dart index 20577199..dd83125d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -32,11 +32,11 @@ void main() async { await clearPrefsOnFirstLaunch(); tz.initializeTimeZones(); - if (!kReleaseMode) { - await locator.get().initialize(); + if (kReleaseMode) { + await service.initialize(); // Set up critical threat callback to navigate to unsafe device page - locator.get().setOnCriticalThreatCallback(() { + service.setOnCriticalThreatCallback(() { final navigationService = locator.get(); final context = navigationService.navigatorKey.currentContext; if (context != null) { diff --git a/lib/screens/splash/splash_screen.dart b/lib/screens/splash/splash_screen.dart index 72a6a214..3fb746e2 100644 --- a/lib/screens/splash/splash_screen.dart +++ b/lib/screens/splash/splash_screen.dart @@ -31,7 +31,7 @@ class _SplashScreenState extends State { void initState() { super.initState(); AppGlobal.CONTEX = context; - if (!kReleaseMode) { + if (kReleaseMode) { checkDeviceSafety(); } Timer(Duration(seconds: 2, milliseconds: 500), () async { diff --git a/lib/unsafe_device.dart b/lib/unsafe_device.dart index 72606390..92a9b131 100644 --- a/lib/unsafe_device.dart +++ b/lib/unsafe_device.dart @@ -65,7 +65,7 @@ class _UnsafeDeviceState extends State { textAlign: TextAlign.center, ), SizedBox(height: 24), - if (locator.get().detectedThreats.isNotEmpty) ...[ + if (service.detectedThreats.isNotEmpty) ...[ Text( 'Detected Issues:', style: TextStyle( @@ -83,16 +83,15 @@ class _UnsafeDeviceState extends State { border: Border.all(color: Colors.red.withOpacity(0.3)), ), child: Column( - children: locator - .get() - .detectedThreats + children: service.detectedThreats .where((t) => t.severity == ThreatSeverity.critical) .take(5) // Show max 5 threats .map((threat) => Padding( padding: EdgeInsets.symmetric(vertical: 4), child: Row( children: [ - Icon(Icons.error_outline, size: 16, color: Colors.red), + Icon(Icons.error_outline, + size: 16, color: Colors.red), SizedBox(width: 8), Expanded( child: Text(