Fix NAT mode not working after task removed from recent
This commit is contained in:
@@ -42,7 +42,7 @@ package com.github.shadowsocks
|
||||
import java.util.{Timer, TimerTask}
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Context
|
||||
import android.content.{Intent, Context}
|
||||
import android.os.{Handler, RemoteCallbackList}
|
||||
import com.github.shadowsocks.aidl.{Config, IShadowsocksService, IShadowsocksServiceCallback}
|
||||
import com.github.shadowsocks.utils.{State, TrafficMonitor, TrafficMonitorThread}
|
||||
@@ -110,6 +110,7 @@ trait BaseService extends Service {
|
||||
def startRunner(config: Config) {
|
||||
this.config = config
|
||||
|
||||
startService(new Intent(getContext, getClass))
|
||||
TrafficMonitor.reset()
|
||||
trafficMonitorThread = new TrafficMonitorThread()
|
||||
trafficMonitorThread.start()
|
||||
@@ -124,6 +125,12 @@ trait BaseService extends Service {
|
||||
trafficMonitorThread.stopThread()
|
||||
trafficMonitorThread = null
|
||||
}
|
||||
|
||||
// change the state
|
||||
changeState(State.STOPPED)
|
||||
|
||||
// stop the service if nothing has bound to it
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
def updateTrafficTotal(tx: Long, rx: Long) {
|
||||
|
||||
@@ -54,8 +54,6 @@ trait ServiceBoundContext extends Context {
|
||||
|
||||
connection = new ShadowsocksServiceConnection()
|
||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||
|
||||
startService(new Intent(this, s))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -458,8 +458,6 @@ class ShadowsocksNatService extends BaseService {
|
||||
|
||||
override def stopRunner() {
|
||||
|
||||
super.stopRunner()
|
||||
|
||||
// channge the state
|
||||
changeState(State.STOPPING)
|
||||
|
||||
@@ -476,11 +474,7 @@ class ShadowsocksNatService extends BaseService {
|
||||
// reset NAT
|
||||
killProcesses()
|
||||
|
||||
// stop the service if nothing has bound to it
|
||||
stopSelf()
|
||||
|
||||
// change the state
|
||||
changeState(State.STOPPED)
|
||||
super.stopRunner()
|
||||
}
|
||||
|
||||
override def getTag = TAG
|
||||
|
||||
@@ -113,8 +113,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
override def stopRunner() {
|
||||
|
||||
super.stopRunner()
|
||||
|
||||
if (vpnThread != null) {
|
||||
vpnThread.stopThread()
|
||||
vpnThread = null
|
||||
@@ -136,17 +134,13 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
conn = null
|
||||
}
|
||||
|
||||
// stop the service if nothing has bound to it
|
||||
stopSelf()
|
||||
|
||||
// clean up recevier
|
||||
if (closeReceiver != null) {
|
||||
unregisterReceiver(closeReceiver)
|
||||
closeReceiver = null
|
||||
}
|
||||
|
||||
// channge the state
|
||||
changeState(State.STOPPED)
|
||||
super.stopRunner()
|
||||
}
|
||||
|
||||
def getVersionName: String = {
|
||||
|
||||
Reference in New Issue
Block a user