Commit faa1e5de authored by Mygod's avatar Mygod
parents 873560be d2a10272
...@@ -254,7 +254,7 @@ SHADOWSOCKS_SOURCES := local.c cache.c udprelay.c encrypt.c utils.c netutils.c j ...@@ -254,7 +254,7 @@ SHADOWSOCKS_SOURCES := local.c cache.c udprelay.c encrypt.c utils.c netutils.c j
LOCAL_MODULE := ss-local LOCAL_MODULE := ss-local
LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/src/, $(SHADOWSOCKS_SOURCES)) LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/src/, $(SHADOWSOCKS_SOURCES))
LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DUDPRELAY_LOCAL \ LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DMODULE_LOCAL \
-DUSE_CRYPTO_OPENSSL -DANDROID -DHAVE_CONFIG_H \ -DUSE_CRYPTO_OPENSSL -DANDROID -DHAVE_CONFIG_H \
-I$(LOCAL_PATH)/libev \ -I$(LOCAL_PATH)/libev \
-I$(LOCAL_PATH)/libancillary \ -I$(LOCAL_PATH)/libancillary \
...@@ -281,7 +281,7 @@ SHADOWSOCKS_SOURCES := tunnel.c cache.c udprelay.c encrypt.c utils.c netutils.c ...@@ -281,7 +281,7 @@ SHADOWSOCKS_SOURCES := tunnel.c cache.c udprelay.c encrypt.c utils.c netutils.c
LOCAL_MODULE := ss-tunnel LOCAL_MODULE := ss-tunnel
LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/src/, $(SHADOWSOCKS_SOURCES)) LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/src/, $(SHADOWSOCKS_SOURCES))
LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DUDPRELAY_LOCAL -DUDPRELAY_TUNNEL \ LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DMODULE_TUNNEL \
-DUSE_CRYPTO_OPENSSL -DANDROID -DHAVE_CONFIG_H -DSSTUNNEL_JNI \ -DUSE_CRYPTO_OPENSSL -DANDROID -DHAVE_CONFIG_H -DSSTUNNEL_JNI \
-I$(LOCAL_PATH)/libev \ -I$(LOCAL_PATH)/libev \
-I$(LOCAL_PATH)/libancillary \ -I$(LOCAL_PATH)/libancillary \
......
Subproject commit c5155e4a59c1965203b2f894c4f3c06358fa3a65 Subproject commit eeac81e8faa225b381223559811e1e477a195d2c
...@@ -9,7 +9,8 @@ import com.github.shadowsocks.utils.Action ...@@ -9,7 +9,8 @@ import com.github.shadowsocks.utils.Action
* @author Mygod * @author Mygod
*/ */
trait ServiceBoundContext extends Context { trait ServiceBoundContext extends Context {
val connection = new ServiceConnection {
class ShadowsocksServiceConnection extends ServiceConnection {
override def onServiceConnected(name: ComponentName, service: IBinder) { override def onServiceConnected(name: ComponentName, service: IBinder) {
bgService = IShadowsocksService.Stub.asInterface(service) bgService = IShadowsocksService.Stub.asInterface(service)
if (callback != null) try { if (callback != null) try {
...@@ -37,6 +38,7 @@ trait ServiceBoundContext extends Context { ...@@ -37,6 +38,7 @@ trait ServiceBoundContext extends Context {
def onServiceDisconnected() = () def onServiceDisconnected() = ()
private var callback: IShadowsocksServiceCallback.Stub = _ private var callback: IShadowsocksServiceCallback.Stub = _
private var connection: ShadowsocksServiceConnection = _
// Variables // Variables
var bgService: IShadowsocksService = _ var bgService: IShadowsocksService = _
...@@ -46,9 +48,13 @@ trait ServiceBoundContext extends Context { ...@@ -46,9 +48,13 @@ trait ServiceBoundContext extends Context {
if (bgService == null) { if (bgService == null) {
val s = val s =
if (ShadowsocksApplication.isVpnEnabled) classOf[ShadowsocksVpnService] else classOf[ShadowsocksNatService] if (ShadowsocksApplication.isVpnEnabled) classOf[ShadowsocksVpnService] else classOf[ShadowsocksNatService]
val intent = new Intent(this, s) val intent = new Intent(this, s)
intent.setAction(Action.SERVICE) intent.setAction(Action.SERVICE)
connection = new ShadowsocksServiceConnection()
bindService(intent, connection, Context.BIND_AUTO_CREATE) bindService(intent, connection, Context.BIND_AUTO_CREATE)
startService(new Intent(this, s)) startService(new Intent(this, s))
} }
} }
...@@ -62,8 +68,10 @@ trait ServiceBoundContext extends Context { ...@@ -62,8 +68,10 @@ trait ServiceBoundContext extends Context {
case ignored: RemoteException => // Nothing case ignored: RemoteException => // Nothing
} }
} }
unbindService(connection) if (connection != null) {
bgService = null unbindService(connection)
connection = null
}
} }
} }
} }
...@@ -73,10 +73,13 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan ...@@ -73,10 +73,13 @@ 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.handler.post(() => { case Key.isNAT => if (ShadowsocksApplication.isRoot && activity != null) {
activity.deattachService() activity.handler.post(() => {
activity.attachService() val intent = activity.getIntent
}) activity.finish()
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