Skip to content

Commit

Permalink
fix: Location services availability crash #WPB-11304 (#3564)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-zagorski authored and github-actions[bot] committed Oct 30, 2024
1 parent 403ae9b commit 2066a42
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
}

Expand Down

0 comments on commit 2066a42

Please sign in to comment.