Drop location in tracker service (temp) 3'

This commit is contained in:
max-klaus 2021-01-13 09:32:16 +03:00
parent 055b4c0f5a
commit 4b51b5fdb7

View file

@ -54,34 +54,6 @@ class TelegramLocationProvider(private val app: TelegramApplication) : SensorEve
private var agpsDataLastTimeDownloaded: Long = 0 private var agpsDataLastTimeDownloaded: Long = 0
private val useMagneticFieldSensorCompass = false private val useMagneticFieldSensorCompass = false
// note, passive provider is from API_LEVEL 8 but it is a constant, we can check for it.
// constant should not be changed in future
// LocationManager.PASSIVE_PROVIDER
// put passive provider to first place
// find location
val firstTimeRunDefaultLocation: net.osmand.Location?
@SuppressLint("MissingPermission")
get() {
if (!AndroidUtils.isLocationPermissionAvailable(app)) {
return null
}
val service = app.getSystemService(Context.LOCATION_SERVICE) as LocationManager
val ps = service.getProviders(true) ?: return null
val providers = ArrayList(ps)
val passiveFirst = providers.indexOf("passive")
if (passiveFirst > -1) {
providers.add(0, providers.removeAt(passiveFirst))
}
for (provider in providers) {
val location = convertLocation(service.getLastKnownLocation(provider))
if (location != null) {
return location
}
}
return null
}
private val gpsListener = object : LocationListener { private val gpsListener = object : LocationListener {
override fun onLocationChanged(location: Location?) { override fun onLocationChanged(location: Location?) {
if (location != null) { if (location != null) {
@ -167,6 +139,7 @@ class TelegramLocationProvider(private val app: TelegramApplication) : SensorEve
} }
private fun redownloadAGPS() { private fun redownloadAGPS() {
/*
try { try {
val service = app.getSystemService(Context.LOCATION_SERVICE) as LocationManager val service = app.getSystemService(Context.LOCATION_SERVICE) as LocationManager
service.sendExtraCommand(LocationManager.GPS_PROVIDER, "delete_aiding_data", null) service.sendExtraCommand(LocationManager.GPS_PROVIDER, "delete_aiding_data", null)
@ -178,7 +151,7 @@ class TelegramLocationProvider(private val app: TelegramApplication) : SensorEve
agpsDataLastTimeDownloaded = 0L agpsDataLastTimeDownloaded = 0L
e.printStackTrace() e.printStackTrace()
} }
*/
} }
private fun getGpsStatusListener(service: LocationManager): GpsStatus.Listener { private fun getGpsStatusListener(service: LocationManager): GpsStatus.Listener {