fix #100
This commit is contained in:
@@ -507,7 +507,7 @@ class Shadowsocks
|
||||
val intent = new Intent(this, s)
|
||||
intent.setAction(Action.SERVICE)
|
||||
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
|
||||
} catch {
|
||||
case ignored: RemoteException => // Nothing
|
||||
}
|
||||
unbindService(connection)
|
||||
bgService = null
|
||||
}
|
||||
unbindService(connection)
|
||||
}
|
||||
|
||||
override def onRestoreInstanceState(inState: Bundle) {
|
||||
|
||||
@@ -52,12 +52,12 @@ import org.apache.http.conn.util.InetAddressUtils
|
||||
import android.os.Message
|
||||
import scala.concurrent.ops._
|
||||
import org.apache.commons.net.util.SubnetUtils
|
||||
import java.net.InetAddress
|
||||
import com.github.shadowsocks.utils._
|
||||
import scala.Some
|
||||
import com.github.shadowsocks.aidl.{IShadowsocksService, Config}
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
import java.io.File
|
||||
import java.net.InetAddress
|
||||
|
||||
class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
@@ -118,8 +118,13 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
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()
|
||||
builder
|
||||
.setConfigureIntent(configIntent)
|
||||
.setSession(config.profileName)
|
||||
.setMtu(VPN_MTU)
|
||||
.addAddress(PRIVATE_VLAN.format("1"), 24)
|
||||
@@ -265,10 +270,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
Console.runCommand(ab.toArray)
|
||||
}
|
||||
|
||||
override def onStartCommand(intent: Intent, flags: Int, startId: Int): Int = {
|
||||
Service.START_STICKY
|
||||
}
|
||||
|
||||
override def startRunner(c: Config) {
|
||||
|
||||
config = c
|
||||
@@ -383,7 +384,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
override def stopBackgroundService() {
|
||||
stopRunner()
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
override def getTag = TAG
|
||||
|
||||
Reference in New Issue
Block a user