Refine logging

This commit is contained in:
Mygod
2020-07-23 07:50:38 +08:00
parent ecd277cd81
commit 3fead73a12

View File

@@ -194,11 +194,10 @@ class RootServer @JvmOverloads constructor(private val warnLogger: (String) -> U
break break
} }
val result = input.readByte() val result = input.readByte()
Timber.i("Received callback #$index: $result")
val callback = mutex.synchronized { val callback = mutex.synchronized {
callbackLookup[index]!!.also { (callbackLookup[index] ?: error("Empty callback #$index")).also {
if (it.shouldRemove(result).also { shouldRemove -> if (it.shouldRemove(result)) {
Timber.i("$index($result) should remove $it: $shouldRemove")
}) {
callbackLookup.remove(index) callbackLookup.remove(index)
it.active = false it.active = false
} }
@@ -277,6 +276,7 @@ class RootServer @JvmOverloads constructor(private val warnLogger: (String) -> U
val callback = Callback.Ordinary(this, counter, classLoader, future as CompletableDeferred<Parcelable?>) val callback = Callback.Ordinary(this, counter, classLoader, future as CompletableDeferred<Parcelable?>)
mutex.withLock { mutex.withLock {
if (active) { if (active) {
Timber.i("Register callback #$counter $command")
callbackLookup[counter] = callback callbackLookup[counter] = callback
sendLocked(command) sendLocked(command)
} else future.cancel() } else future.cancel()
@@ -307,6 +307,7 @@ class RootServer @JvmOverloads constructor(private val warnLogger: (String) -> U
val callback = Callback.Channel(this@RootServer, counter, classLoader, this as SendChannel<Parcelable?>) val callback = Callback.Channel(this@RootServer, counter, classLoader, this as SendChannel<Parcelable?>)
mutex.withLock { mutex.withLock {
if (active) { if (active) {
Timber.i("Register callback #$counter $command")
callbackLookup[counter] = callback callbackLookup[counter] = callback
sendLocked(command) sendLocked(command)
} else callback.finish.cancel() } else callback.finish.cancel()