From 1bb3a6bf5d32eb91afc0a48ac36524f44cb15662 Mon Sep 17 00:00:00 2001 From: chentao Date: Thu, 25 Feb 2016 00:00:33 +0800 Subject: [PATCH] Add ShadowsocksDeathRecipient --- .../ShadowsocksDeathRecipient.scala | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/scala/com/github/shadowsocks/ShadowsocksDeathRecipient.scala diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksDeathRecipient.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksDeathRecipient.scala new file mode 100644 index 00000000..44b4e177 --- /dev/null +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksDeathRecipient.scala @@ -0,0 +1,28 @@ +package com.github.shadowsocks + +import android.os.IBinder +import android.util.Log +import com.github.shadowsocks.utils.ProcessUtils._ + +/** + * @author chentaov5@gmail.com + */ +class ShadowsocksDeathRecipient(val mContext: ServiceBoundContext) + extends IBinder.DeathRecipient { + + val TAG = "ShadowsocksDeathRecipient" + + override def binderDied(): Unit = { + Log.d(TAG, "[ShadowsocksDeathRecipient] binder died.") + + mContext match { + case ss: Shadowsocks => + inShadowsocks { + ss.unregisterCallback + ss.bindToService() + } + case _ => + } + } + +}