mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-02 12:16:55 +01:00
Avoid taking into account network location if we have gps location.
This commit is contained in:
parent
303a858423
commit
99f82d9691
@ -23,6 +23,7 @@ import android.location.LocationManager
|
||||
import androidx.annotation.RequiresPermission
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.location.LocationListenerCompat
|
||||
import im.vector.app.BuildConfig
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -39,9 +40,12 @@ class LocationTracker @Inject constructor(
|
||||
|
||||
private var callback: Callback? = null
|
||||
|
||||
private var hasGpsProviderLocation = false
|
||||
|
||||
@RequiresPermission(anyOf = [Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION])
|
||||
fun start(callback: Callback?) {
|
||||
Timber.d("## LocationTracker. start()")
|
||||
hasGpsProviderLocation = false
|
||||
this.callback = callback
|
||||
|
||||
if (locationManager == null) {
|
||||
@ -82,7 +86,16 @@ class LocationTracker @Inject constructor(
|
||||
}
|
||||
|
||||
override fun onLocationChanged(location: Location) {
|
||||
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
|
||||
Timber.d("## LocationTracker. onLocationChanged: $location")
|
||||
} else {
|
||||
Timber.d("## LocationTracker. onLocationChanged")
|
||||
}
|
||||
if (location.provider != LocationManager.GPS_PROVIDER && hasGpsProviderLocation) {
|
||||
// Ignore this update
|
||||
Timber.d("## LocationTracker. ignoring location from ${location.provider}, we have gps location")
|
||||
return
|
||||
}
|
||||
callback?.onLocationUpdate(location.toLocationData())
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user