Log SecurityException in LocationProvider instead of swallowing silently
A revoked location permission was previously caught and sent as null with zero logging, making it indistinguishable from "no fix yet" and impossible to diagnose. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4950feb751
commit
cd51c1a843
1 changed files with 6 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ import android.content.Context
|
|||
import android.content.pm.PackageManager
|
||||
import android.location.Location
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.google.android.gms.location.FusedLocationProviderClient
|
||||
import com.google.android.gms.location.LocationCallback
|
||||
|
|
@ -21,6 +22,10 @@ import kotlinx.coroutines.flow.callbackFlow
|
|||
*/
|
||||
class LocationProvider(private val context: Context) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "LocationProvider"
|
||||
}
|
||||
|
||||
private val fusedLocationClient: FusedLocationProviderClient =
|
||||
LocationServices.getFusedLocationProviderClient(context)
|
||||
|
||||
|
|
@ -61,6 +66,7 @@ class LocationProvider(private val context: Context) {
|
|||
location?.let { trySend(it) }
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
Log.w(TAG, "Location permission revoked at runtime", e)
|
||||
trySend(null)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue