From 9983b46271ecb251a1b074e3f0627302b8fb9368 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Thu, 13 Feb 2014 12:33:08 +0800 Subject: [PATCH] make service control functions asynchronous --- .../shadowsocks/aidl/IShadowsocksService.aidl | 8 +++++--- .../com/github/shadowsocks/Shadowsocks.scala | 17 +---------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/github/shadowsocks/aidl/IShadowsocksService.aidl b/src/main/java/com/github/shadowsocks/aidl/IShadowsocksService.aidl index c06de025..66b2f820 100644 --- a/src/main/java/com/github/shadowsocks/aidl/IShadowsocksService.aidl +++ b/src/main/java/com/github/shadowsocks/aidl/IShadowsocksService.aidl @@ -6,8 +6,10 @@ import com.github.shadowsocks.aidl.IShadowsocksServiceCallback; interface IShadowsocksService { int getMode(); int getState(); - void start(in Config config); - void stop(); + void registerCallback(IShadowsocksServiceCallback cb); void unregisterCallback(IShadowsocksServiceCallback cb); -} \ No newline at end of file + + oneway void start(in Config config); + oneway void stop(); +} diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala index 3d19c1b2..777783dc 100644 --- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala +++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala @@ -317,12 +317,6 @@ class Shadowsocks // Update the UI switchButton.setEnabled(true) if (State.isAvailable(bgService.getState)) { - if (status.getBoolean(Key.isRunning, false)) { - spawn { - crash_recovery() - handler.sendEmptyMessage(MSG_CRASH_RECOVER) - } - } Crouton.cancelAllCroutons() setPreferenceEnabled(enabled = true) } else { @@ -347,16 +341,7 @@ class Shadowsocks lazy val profileManager = new ProfileManager(settings, getApplication.asInstanceOf[ShadowsocksApplication].dbHelper) - private val handler: Handler = new Handler { - override def handleMessage(msg: Message) { - msg.what match { - case MSG_CRASH_RECOVER => - Crouton.makeText(Shadowsocks.this, R.string.crash_alert, Style.ALERT).show() - status.edit().putBoolean(Key.isRunning, false).commit() - } - super.handleMessage(msg) - } - } + val handler = new Handler() private def changeSwitch (checked: Boolean) { switchButton.setOnCheckedChangeListener(null)