Improve dump
This commit is contained in:
parent
bdda930c87
commit
8c46f2c48a
5 changed files with 21 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-FileCopyrightText: 2020 microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
@ -31,10 +31,6 @@ afterEvaluate {
|
|||
id = 'microg'
|
||||
name = 'microG Team'
|
||||
}
|
||||
developer {
|
||||
id = 'mar-v-in'
|
||||
name = 'Marvin W.'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url = 'https://github.com/microg/UnifiedNlp'
|
||||
|
|
|
@ -46,6 +46,7 @@ class LocationProvider(private val context: Context, private val lifecycle: Life
|
|||
}
|
||||
}
|
||||
private var opPackageName: String? = null
|
||||
private var opPackageNames: Set<String> = emptySet()
|
||||
private var autoTime = Long.MAX_VALUE
|
||||
private var autoUpdate = false
|
||||
|
||||
|
@ -73,12 +74,16 @@ class LocationProvider(private val context: Context, private val lifecycle: Life
|
|||
namesField.isAccessible = true
|
||||
val names = namesField[source] as Array<String>
|
||||
if (names != null) {
|
||||
opPackageNames = setOfNotNull(*names)
|
||||
for (name in names) {
|
||||
if (!EXCLUDED_PACKAGES.contains(name)) {
|
||||
opPackageName = name
|
||||
break
|
||||
}
|
||||
}
|
||||
if (opPackageName == null && names.isNotEmpty()) opPackageName = names[0]
|
||||
} else {
|
||||
opPackageNames = emptySet()
|
||||
}
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
|
@ -129,6 +134,10 @@ class LocationProvider(private val context: Context, private val lifecycle: Life
|
|||
writer?.println("connected: ${client.isConnectedUnsafe}")
|
||||
writer?.println("active: $autoUpdate")
|
||||
writer?.println("interval: $autoTime")
|
||||
writer?.println("${opPackageNames.size} sources:")
|
||||
for (packageName in opPackageNames) {
|
||||
writer?.println(" $packageName")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun connect() {
|
||||
|
|
|
@ -92,7 +92,7 @@ abstract class AbstractBackendHelper(private val TAG: String, private val contex
|
|||
}
|
||||
}
|
||||
|
||||
fun dump(writer: PrintWriter?) {
|
||||
open fun dump(writer: PrintWriter?) {
|
||||
writer?.println(" ${javaClass.simpleName} $serviceIntent bound=$bound")
|
||||
}
|
||||
|
||||
|
|
|
@ -265,6 +265,11 @@ class LocationBackendHelper(context: Context, private val locationFuser: Locatio
|
|||
backend = null
|
||||
}
|
||||
|
||||
override fun dump(writer: PrintWriter?) {
|
||||
super.dump(writer)
|
||||
writer?.println(" last location: ${lastLocation?.let { Location(it) }}")
|
||||
}
|
||||
|
||||
private inner class Callback : LocationCallback.Stub() {
|
||||
override fun report(location: Location?) {
|
||||
val lastLocation = lastLocation
|
||||
|
|
|
@ -313,12 +313,13 @@ class LocationServiceImpl(private val context: Context, private val lifecycle: L
|
|||
}
|
||||
|
||||
override fun reportLocation(location: Location) {
|
||||
this.lastLocation = location
|
||||
val newLocation = Location(location)
|
||||
this.lastLocation = newLocation
|
||||
val requestsToDelete = hashSetOf<LocationRequestInternal>()
|
||||
synchronized(requests) {
|
||||
for (request in requests) {
|
||||
try {
|
||||
request.report(context, location)
|
||||
request.report(context, newLocation)
|
||||
if (request.updatesPending <= 0) requestsToDelete.add(request)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Removing request due to error: ", e)
|
||||
|
@ -331,8 +332,8 @@ class LocationServiceImpl(private val context: Context, private val lifecycle: L
|
|||
}
|
||||
|
||||
fun dump(writer: PrintWriter?) {
|
||||
writer?.println("Last reported location: $lastLocation")
|
||||
writer?.println("Current location interval: $interval")
|
||||
writer?.println("last location: $lastLocation")
|
||||
writer?.println("interval: $interval")
|
||||
writer?.println("${requests.size} requests:")
|
||||
for (request in requests) {
|
||||
writer?.println(" ${request.id} package=${request.packageName} source=${request.source} interval=${request.interval} pending=${request.updatesPending}")
|
||||
|
|
Loading…
Add table
Reference in a new issue