Improve dump

This commit is contained in:
Marvin W 2022-04-07 11:42:43 +02:00
parent bdda930c87
commit 8c46f2c48a
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
5 changed files with 21 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2020, microG Project Team * SPDX-FileCopyrightText: 2020 microG Project Team
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -31,10 +31,6 @@ afterEvaluate {
id = 'microg' id = 'microg'
name = 'microG Team' name = 'microG Team'
} }
developer {
id = 'mar-v-in'
name = 'Marvin W.'
}
} }
scm { scm {
url = 'https://github.com/microg/UnifiedNlp' url = 'https://github.com/microg/UnifiedNlp'

View File

@ -46,6 +46,7 @@ class LocationProvider(private val context: Context, private val lifecycle: Life
} }
} }
private var opPackageName: String? = null private var opPackageName: String? = null
private var opPackageNames: Set<String> = emptySet()
private var autoTime = Long.MAX_VALUE private var autoTime = Long.MAX_VALUE
private var autoUpdate = false private var autoUpdate = false
@ -73,12 +74,16 @@ class LocationProvider(private val context: Context, private val lifecycle: Life
namesField.isAccessible = true namesField.isAccessible = true
val names = namesField[source] as Array<String> val names = namesField[source] as Array<String>
if (names != null) { if (names != null) {
opPackageNames = setOfNotNull(*names)
for (name in names) { for (name in names) {
if (!EXCLUDED_PACKAGES.contains(name)) { if (!EXCLUDED_PACKAGES.contains(name)) {
opPackageName = name opPackageName = name
break break
} }
} }
if (opPackageName == null && names.isNotEmpty()) opPackageName = names[0]
} else {
opPackageNames = emptySet()
} }
} catch (ignored: Exception) { } catch (ignored: Exception) {
} }
@ -129,6 +134,10 @@ class LocationProvider(private val context: Context, private val lifecycle: Life
writer?.println("connected: ${client.isConnectedUnsafe}") writer?.println("connected: ${client.isConnectedUnsafe}")
writer?.println("active: $autoUpdate") writer?.println("active: $autoUpdate")
writer?.println("interval: $autoTime") writer?.println("interval: $autoTime")
writer?.println("${opPackageNames.size} sources:")
for (packageName in opPackageNames) {
writer?.println(" $packageName")
}
} }
suspend fun connect() { suspend fun connect() {

View File

@ -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") writer?.println(" ${javaClass.simpleName} $serviceIntent bound=$bound")
} }

View File

@ -265,6 +265,11 @@ class LocationBackendHelper(context: Context, private val locationFuser: Locatio
backend = null backend = null
} }
override fun dump(writer: PrintWriter?) {
super.dump(writer)
writer?.println(" last location: ${lastLocation?.let { Location(it) }}")
}
private inner class Callback : LocationCallback.Stub() { private inner class Callback : LocationCallback.Stub() {
override fun report(location: Location?) { override fun report(location: Location?) {
val lastLocation = lastLocation val lastLocation = lastLocation

View File

@ -313,12 +313,13 @@ class LocationServiceImpl(private val context: Context, private val lifecycle: L
} }
override fun reportLocation(location: Location) { override fun reportLocation(location: Location) {
this.lastLocation = location val newLocation = Location(location)
this.lastLocation = newLocation
val requestsToDelete = hashSetOf<LocationRequestInternal>() val requestsToDelete = hashSetOf<LocationRequestInternal>()
synchronized(requests) { synchronized(requests) {
for (request in requests) { for (request in requests) {
try { try {
request.report(context, location) request.report(context, newLocation)
if (request.updatesPending <= 0) requestsToDelete.add(request) if (request.updatesPending <= 0) requestsToDelete.add(request)
} catch (e: Exception) { } catch (e: Exception) {
Log.w(TAG, "Removing request due to error: ", e) 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?) { fun dump(writer: PrintWriter?) {
writer?.println("Last reported location: $lastLocation") writer?.println("last location: $lastLocation")
writer?.println("Current location interval: $interval") writer?.println("interval: $interval")
writer?.println("${requests.size} requests:") writer?.println("${requests.size} requests:")
for (request in requests) { for (request in requests) {
writer?.println(" ${request.id} package=${request.packageName} source=${request.source} interval=${request.interval} pending=${request.updatesPending}") writer?.println(" ${request.id} package=${request.packageName} source=${request.source} interval=${request.interval} pending=${request.updatesPending}")