Skip to content

Nugon SOS v1.6 - Versión Hardening

Latest

Choose a tag to compare

@jzsalinas jzsalinas released this 30 Jul 13:39

Android 14+ Security Hardening

I have implemented critical security fixes to prevent SecurityException crashes on Android 14+ (API 34) and higher, ensuring a stable experience during the first run and background startup.

Technical Fixes for Modern Android

1. Permission-Aware Service Startup

Android 14 introduced strict requirements for starting Foreground Services (FGS) from the background. We addressed this with:

  • Startup Guard: Removed the immediate service start in MainActivity#onCreate. The monitor now only attempts to start once permissions are confirmed or when the user saves their settings.
  • Strict Location Check: In [EmergencyService.java], the app now verifies that both ACCESS_FINE_LOCATION and ACCESS_BACKGROUND_LOCATION are granted before declaring the location service type.

2. SecurityException Prevention (Graceful Fallback)

If the service is triggered (e.g., via a boot sequence) but the user has not yet granted the "Always Allow" location permission:

  • Fallback Mode: The service starts as a standard foreground service without the location capability. This prevents the app from crashing.
  • Safety First: The app logs a warning indicating that the SOS alert will lack GPS coordinates until the required permission is granted, rather than failing catastrophically.

3. Race Condition Resolution

Fixed a race condition where the app would attempt to start the monitoring service while the permission dialog was still visible to the user, which is now a fatal error in the latest Android versions.

Verification Summary

Manual Reliability Check

  1. Fresh Install: Verified that the app no longer crashes upon the first launch.
  2. Permission Denial: Verified that the app stays running even if location permission is temporarily unavailable, avoiding the SecurityException.
  3. Android 14/15/16 Support: The startForeground logic now uses the exact bitwise flags required by the newest Android Target SDK (36).

Nugon SOS is now fully compatible with the latest Android security enforcements.