Commit 3975f3f4 authored by Mygod's avatar Mygod

Disconnect as soon as binder died

parent be79e6f8
...@@ -196,8 +196,8 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, Drawe ...@@ -196,8 +196,8 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, Drawe
override fun onServiceConnected(service: IShadowsocksService) = changeState(service.state) override fun onServiceConnected(service: IShadowsocksService) = changeState(service.state)
override fun onServiceDisconnected() = changeState(BaseService.IDLE) override fun onServiceDisconnected() = changeState(BaseService.IDLE)
override fun binderDied() { override fun binderDied() {
super.binderDied()
app.handler.post { app.handler.post {
connection.disconnect()
Executable.killAll() Executable.killAll()
connection.connect() connection.connect()
} }
......
...@@ -48,7 +48,10 @@ class ShadowsocksConnection(private val instance: Interface) : ServiceConnection ...@@ -48,7 +48,10 @@ class ShadowsocksConnection(private val instance: Interface) : ServiceConnection
* Different from Android framework, this method will be called even when you call `detachService`. * Different from Android framework, this method will be called even when you call `detachService`.
*/ */
fun onServiceDisconnected() { } fun onServiceDisconnected() { }
override fun binderDied() { } override fun binderDied() {
connection.service = null
connection.disconnect()
}
} }
private var connectionActive = false private var connectionActive = false
...@@ -109,6 +112,7 @@ class ShadowsocksConnection(private val instance: Interface) : ServiceConnection ...@@ -109,6 +112,7 @@ class ShadowsocksConnection(private val instance: Interface) : ServiceConnection
connectionActive = false connectionActive = false
if (instance.listenForDeath) binder?.unlinkToDeath(instance, 0) if (instance.listenForDeath) binder?.unlinkToDeath(instance, 0)
binder = null binder = null
service?.stopListeningForBandwidth(instance.serviceCallback)
service = null service = null
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment