Commit 028c5a64 authored by Max Lv's avatar Max Lv

fix #100

parent 4e39705a
...@@ -507,7 +507,7 @@ class Shadowsocks ...@@ -507,7 +507,7 @@ class Shadowsocks
val intent = new Intent(this, s) val intent = new Intent(this, s)
intent.setAction(Action.SERVICE) intent.setAction(Action.SERVICE)
bindService(intent, connection, Context.BIND_AUTO_CREATE) bindService(intent, connection, Context.BIND_AUTO_CREATE)
startService(new Intent(this, s)) if (!isVpnEnabled) startService(new Intent(this, s))
} }
} }
...@@ -518,9 +518,9 @@ class Shadowsocks ...@@ -518,9 +518,9 @@ class Shadowsocks
} catch { } catch {
case ignored: RemoteException => // Nothing case ignored: RemoteException => // Nothing
} }
unbindService(connection)
bgService = null bgService = null
} }
unbindService(connection)
} }
override def onRestoreInstanceState(inState: Bundle) { override def onRestoreInstanceState(inState: Bundle) {
......
...@@ -52,12 +52,12 @@ import org.apache.http.conn.util.InetAddressUtils ...@@ -52,12 +52,12 @@ import org.apache.http.conn.util.InetAddressUtils
import android.os.Message import android.os.Message
import scala.concurrent.ops._ import scala.concurrent.ops._
import org.apache.commons.net.util.SubnetUtils import org.apache.commons.net.util.SubnetUtils
import java.net.InetAddress
import com.github.shadowsocks.utils._ import com.github.shadowsocks.utils._
import scala.Some import scala.Some
import com.github.shadowsocks.aidl.{IShadowsocksService, Config} import com.github.shadowsocks.aidl.{IShadowsocksService, Config}
import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.ArrayBuffer
import java.io.File import java.io.File
import java.net.InetAddress
class ShadowsocksVpnService extends VpnService with BaseService { class ShadowsocksVpnService extends VpnService with BaseService {
...@@ -118,8 +118,13 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -118,8 +118,13 @@ class ShadowsocksVpnService extends VpnService with BaseService {
def startVpn() { def startVpn() {
val openIntent: Intent = new Intent(this, classOf[Shadowsocks])
openIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
val configIntent = PendingIntent.getActivity(this, 0, openIntent, 0)
val builder = new Builder() val builder = new Builder()
builder builder
.setConfigureIntent(configIntent)
.setSession(config.profileName) .setSession(config.profileName)
.setMtu(VPN_MTU) .setMtu(VPN_MTU)
.addAddress(PRIVATE_VLAN.format("1"), 24) .addAddress(PRIVATE_VLAN.format("1"), 24)
...@@ -265,10 +270,6 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -265,10 +270,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
Console.runCommand(ab.toArray) Console.runCommand(ab.toArray)
} }
override def onStartCommand(intent: Intent, flags: Int, startId: Int): Int = {
Service.START_STICKY
}
override def startRunner(c: Config) { override def startRunner(c: Config) {
config = c config = c
...@@ -383,7 +384,6 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -383,7 +384,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
override def stopBackgroundService() { override def stopBackgroundService() {
stopRunner() stopRunner()
stopSelf()
} }
override def getTag = TAG override def getTag = TAG
......
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