fix receivers & service connection leak

This commit is contained in:
Kr328 committed 2020-04-24 00:49:03 +08:00
1 parent 821bb49914
commit 1d68516cdb
2 files changed
+9 -9

No files matched your search

@@ -19,7 +19,6 @@ import java.io.File
class LogViewerActivity : BaseActivity() {
private val pauseMutex = Mutex()
private var pollingThread: Thread? = null
private val connection = object : ServiceConnection {
override fun onServiceDisconnected(name: ComponentName?) {
finish()
@@ -48,12 +47,6 @@ class LogViewerActivity : BaseActivity() {
startFileMode(file.toFile())
}
override fun onDestroy() {
super.onDestroy()
pollingThread?.interrupt()
}
override fun onStop() {
super.onStop()
@@ -78,6 +71,7 @@ class LogViewerActivity : BaseActivity() {
mainList.itemAnimator?.removeDuration = 100
stop.setOnClickListener {
unbindService(connection)
stopService(LogcatService::class.intent)
finish()
}
@@ -87,8 +87,14 @@ class ClashRuntime(private val context: Context) {
}
}
} finally {
modules.reversed().forEach {
it.onStop()
runCatching {
modules.reversed().forEach {
it.onStop()
}
}
runCatching {
context.unregisterReceiver(receiver)
}
Clash.stop()