Commit 8c2690c0 authored by Mygod's avatar Mygod

Fix #468

parent c6a7560b
......@@ -67,11 +67,13 @@ trait ServiceBoundContext extends Context {
} catch {
case ignored: RemoteException => // Nothing
}
callback = null
}
if (connection != null) {
unbindService(connection)
connection = null
}
bgService = null
}
}
}
......@@ -157,6 +157,13 @@ class Shadowsocks
// Services
var currentServiceName = classOf[ShadowsocksNatService].getName
private val callback = new IShadowsocksServiceCallback.Stub {
def stateChanged(state: Int, msg: String) = onStateChanged(state, msg)
def trafficUpdated(txRate: String, rxRate: String, txTotal: String, rxTotal: String) =
Shadowsocks.this.trafficUpdated(txRate, rxRate, txTotal, rxTotal)
}
def attachService: Unit = attachService(callback)
override def onServiceConnected() {
// Update the UI
......@@ -377,16 +384,7 @@ class Shadowsocks
})
// Bind to the service
handler.post(() => {
attachService(new IShadowsocksServiceCallback.Stub {
override def stateChanged(state: Int, msg: String) {
onStateChanged(state, msg)
}
override def trafficUpdated(txRate: String, rxRate: String, txTotal: String, rxTotal: String) {
Shadowsocks.this.trafficUpdated(txRate, rxRate, txTotal, rxTotal)
}
})
})
handler.post(() => attachService)
}
def reloadProfile() {
......
......@@ -67,7 +67,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
})
}
override def onResume = {
override def onResume {
super.onResume
isProxyApps.setChecked(ShadowsocksApplication.settings.getBoolean(Key.isProxyApps, false)) // update
}
......@@ -75,9 +75,8 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
def onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) = key match {
case Key.isNAT => if (ShadowsocksApplication.isRoot && activity != null) {
activity.handler.post(() => {
val intent = activity.getIntent
activity.finish()
startActivity(intent)
activity.deattachService
activity.attachService
})
}
case _ =>
......
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