diff --git a/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/location/LocationPickerHelper.kt b/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/location/LocationPickerHelper.kt index 880191b1281..cbd5edcab77 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/location/LocationPickerHelper.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/location/LocationPickerHelper.kt @@ -27,6 +27,7 @@ import android.os.CancellationSignal import androidx.annotation.VisibleForTesting import androidx.core.location.LocationManagerCompat import com.wire.android.AppJsonStyledLogger +import com.wire.android.appLogger import com.wire.android.di.ApplicationScope import com.wire.android.ui.home.appLock.CurrentTimestampProvider import com.wire.kalium.logger.KaliumLogLevel @@ -115,9 +116,18 @@ class LocationPickerHelper @Inject constructor( timeoutJob.start() } + @Suppress("TooGenericExceptionCaught") internal fun isLocationServicesEnabled(): Boolean { - val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager - return LocationManagerCompat.isLocationEnabled(locationManager) + return try { + val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager + LocationManagerCompat.isLocationEnabled(locationManager) + } catch (e: Exception) { + appLogger.i( + message = "Checking for location services availability failed", + throwable = e + ) + false + } } }