Browse Source

Improve dump

master
Marvin W 4 months ago
parent
commit
8c46f2c48a
No known key found for this signature in database
GPG Key ID: 72E9235DB996F2A
  1. 6
      gradle/publish.gradle
  2. 9
      location-v2/src/main/java/org/microg/nlp/location/v2/LocationProvider.kt
  3. 2
      service/src/main/kotlin/org/microg/nlp/service/AbstractBackendHelper.kt
  4. 5
      service/src/main/kotlin/org/microg/nlp/service/LocationFuser.kt
  5. 9
      service/src/main/kotlin/org/microg/nlp/service/LocationService.kt

6
gradle/publish.gradle

@ -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'

9
location-v2/src/main/java/org/microg/nlp/location/v2/LocationProvider.kt

@ -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() {

2
service/src/main/kotlin/org/microg/nlp/service/AbstractBackendHelper.kt

@ -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")
}

5
service/src/main/kotlin/org/microg/nlp/service/LocationFuser.kt

@ -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

9
service/src/main/kotlin/org/microg/nlp/service/LocationService.kt

@ -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…
Cancel
Save