diff --git a/android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/MobileActsScreen.kt b/android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/MobileActsScreen.kt index 2f2d3d9..03e0ff8 100644 --- a/android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/MobileActsScreen.kt +++ b/android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/MobileActsScreen.kt @@ -426,13 +426,15 @@ private fun hasActLocation(context: Context): Boolean = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED private suspend fun currentActSignatureGeo(context: Context): ActSignatureGeo = suspendCancellableCoroutine { continuation -> - if (!hasActLocation(context)) { + val fineGranted = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED + val coarseGranted = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED + if (!fineGranted && !coarseGranted) { continuation.resumeWithException(SecurityException("Ubicación no autorizada")) return@suspendCancellableCoroutine } val source = CancellationTokenSource() - LocationServices.getFusedLocationProviderClient(context) - .getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY, source.token) + val client = LocationServices.getFusedLocationProviderClient(context) + client.getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY, source.token) .addOnSuccessListener { location -> if (!continuation.isActive) return@addOnSuccessListener if (location == null) continuation.resumeWithException(IllegalStateException("Ubicación no disponible"))