Commit 8c2690c0 authored by Mygod's avatar Mygod

Fix #468

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