Commit 9983b462 authored by Max Lv's avatar Max Lv

make service control functions asynchronous

parent 29686ee8
......@@ -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);
oneway void start(in Config config);
oneway void stop();
}
......@@ -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)
......
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