Revert commented location (activity) for tracker

This commit is contained in:
max-klaus 2021-01-14 17:09:54 +03:00
parent 588057fb82
commit 2714a9403b
2 changed files with 10 additions and 10 deletions

View file

@ -87,13 +87,12 @@ class TelegramLocationProvider(private val app: TelegramApplication) : SensorEve
@SuppressLint("MissingPermission")
fun resumeAllUpdates() {
/*
val service = app.getSystemService(Context.LOCATION_SERVICE) as LocationManager
if (app.isInternetConnectionAvailable) {
if (System.currentTimeMillis() - agpsDataLastTimeDownloaded > AGPS_TO_REDOWNLOAD) {
//force an updated check for internet connectivity here before destroying A-GPS-data
if (app.isInternetConnectionAvailable(true)) {
redownloadAGPS()
//redownloadAGPS()
}
}
}
@ -135,12 +134,11 @@ class TelegramLocationProvider(private val app: TelegramApplication) : SensorEve
}
}
*/
registerOrUnregisterCompassListener(true)
}
private fun redownloadAGPS() {
/*
try {
val service = app.getSystemService(Context.LOCATION_SERVICE) as LocationManager
service.sendExtraCommand(LocationManager.GPS_PROVIDER, "delete_aiding_data", null)
@ -152,7 +150,6 @@ class TelegramLocationProvider(private val app: TelegramApplication) : SensorEve
agpsDataLastTimeDownloaded = 0L
e.printStackTrace()
}
*/
}
private fun getGpsStatusListener(service: LocationManager): GpsStatus.Listener {
@ -219,7 +216,6 @@ class TelegramLocationProvider(private val app: TelegramApplication) : SensorEve
@Synchronized
fun registerOrUnregisterCompassListener(register: Boolean) {
/*
if (sensorRegistered && !register) {
Log.d(PlatformUtil.TAG, "Disable sensor") //$NON-NLS-1$
(app.getSystemService(Context.SENSOR_SERVICE) as SensorManager).unregisterListener(this)
@ -260,7 +256,6 @@ class TelegramLocationProvider(private val app: TelegramApplication) : SensorEve
}
sensorRegistered = true
}
*/
}
override fun onAccuracyChanged(sensor: Sensor, accuracy: Int) {}
@ -394,14 +389,12 @@ class TelegramLocationProvider(private val app: TelegramApplication) : SensorEve
}
private fun stopLocationRequests() {
/*
val service = app.getSystemService(Context.LOCATION_SERVICE) as LocationManager
service.removeGpsStatusListener(gpsStatusListener)
service.removeUpdates(gpsListener)
while (!networkListeners.isEmpty()) {
service.removeUpdates(networkListeners.poll())
}
*/
}
fun pauseAllUpdates() {

View file

@ -505,7 +505,6 @@ class TelegramSettings(private val app: TelegramApplication) {
val currentTimeMillis = System.currentTimeMillis()
val currentTime = currentTimeMillis / 1000
statusChangeTime = currentTimeMillis
val gpsEnabled = false
/*
val lm = app.getSystemService(Context.LOCATION_SERVICE) as LocationManager
val gpsEnabled = try {
@ -521,6 +520,14 @@ class TelegramSettings(private val app: TelegramApplication) {
false
}
*/
val gpsEnabled = try {
val loc = app.locationProvider.lastKnownLocation
val gpsActive = loc != null && ((currentTimeMillis - loc.time) / 1000) < GPS_UPDATE_EXPIRED_TIME
val lastSentLocationExpired = ((currentTimeMillis - app.shareLocationHelper.lastLocationUpdateTime) / 1000) > GPS_UPDATE_EXPIRED_TIME
(gpsActive || !lastSentLocationExpired)
} catch (ex: Exception) {
false
}
var initializing = false
var sendChatsErrors = false