Commit d4b55350 authored by Mygod's avatar Mygod

Ignore DeadObjectException when stopListening

parent 24f99801
...@@ -25,6 +25,7 @@ import android.content.ComponentName ...@@ -25,6 +25,7 @@ import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.ServiceConnection import android.content.ServiceConnection
import android.os.DeadObjectException
import android.os.IBinder import android.os.IBinder
import android.os.RemoteException import android.os.RemoteException
import com.github.shadowsocks.aidl.IShadowsocksService import com.github.shadowsocks.aidl.IShadowsocksService
...@@ -68,8 +69,9 @@ class ShadowsocksConnection(private val instance: Interface) : ServiceConnection ...@@ -68,8 +69,9 @@ class ShadowsocksConnection(private val instance: Interface) : ServiceConnection
set(value) { set(value) {
val service = service val service = service
if (listeningForBandwidth != value && service != null && instance.serviceCallback != null) if (listeningForBandwidth != value && service != null && instance.serviceCallback != null)
if (value) service.startListeningForBandwidth(instance.serviceCallback) if (value) service.startListeningForBandwidth(instance.serviceCallback) else try {
else service.stopListeningForBandwidth(instance.serviceCallback) service.stopListeningForBandwidth(instance.serviceCallback)
} catch (_: DeadObjectException) { }
field = value field = value
} }
var service: IShadowsocksService? = null var service: IShadowsocksService? = 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