Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
a21a4d24
Commit
a21a4d24
authored
Feb 24, 2014
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stop the service in time
parent
4bbbc6b7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
4 deletions
+44
-4
project/Build.scala
project/Build.scala
+2
-2
src/main/scala/com/github/shadowsocks/BaseService.scala
src/main/scala/com/github/shadowsocks/BaseService.scala
+13
-2
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+5
-0
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+10
-0
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+14
-0
No files found.
project/Build.scala
View file @
a21a4d24
...
...
@@ -5,8 +5,8 @@ import sbtandroid._
import
sbtandroid.AndroidPlugin._
object
App
{
val
version
=
"2.1.
0
"
val
versionCode
=
6
1
val
version
=
"2.1.
1
"
val
versionCode
=
6
2
}
object
General
{
...
...
src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
a21a4d24
...
...
@@ -50,6 +50,7 @@ import android.content.Context
trait
BaseService
{
var
state
=
State
.
INIT
var
callbackCount
=
0
final
val
callbacks
=
new
RemoteCallbackList
[
IShadowsocksServiceCallback
]
...
...
@@ -63,11 +64,20 @@ trait BaseService {
}
override
def
unregisterCallback
(
cb
:
IShadowsocksServiceCallback
)
{
if
(
cb
!=
null
)
callbacks
.
unregister
(
cb
)
if
(
cb
!=
null
)
{
callbacks
.
unregister
(
cb
)
callbackCount
-=
1
}
if
(
callbackCount
==
0
&&
state
!=
State
.
CONNECTING
&&
state
!=
State
.
CONNECTED
)
{
stopBackgroundService
()
}
}
override
def
registerCallback
(
cb
:
IShadowsocksServiceCallback
)
{
if
(
cb
!=
null
)
callbacks
.
register
(
cb
)
if
(
cb
!=
null
)
{
callbacks
.
register
(
cb
)
callbackCount
+=
1
}
}
override
def
stop
()
{
...
...
@@ -79,6 +89,7 @@ trait BaseService {
}
}
def
stopBackgroundService
()
def
startRunner
(
config
:
Config
)
def
stopRunner
()
def
getServiceMode
:
Int
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
a21a4d24
...
...
@@ -326,6 +326,11 @@ class Shadowsocks
override
def
onServiceDisconnected
(
name
:
ComponentName
)
{
switchButton
.
setEnabled
(
false
)
try
{
bgService
.
unregisterCallback
(
callback
)
}
catch
{
case
ignored
:
RemoteException
=>
// Nothing
}
bgService
=
null
}
}
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
a21a4d24
...
...
@@ -526,6 +526,16 @@ class ShadowsocksNatService extends Service with BaseService {
// reset NAT
killProcesses
()
// stop the service if no callback registered
if
(
callbackCount
==
0
)
{
stopSelf
()
}
}
override
def
stopBackgroundService
()
{
stopRunner
()
stopSelf
()
}
override
def
getTag
=
TAG
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
a21a4d24
...
...
@@ -252,6 +252,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
}
override
def
onRevoke
()
{
stopRunner
()
}
def
killProcesses
()
{
val
sb
=
new
StringBuilder
...
...
@@ -373,6 +377,16 @@ class ShadowsocksVpnService extends VpnService with BaseService {
// reset notifications
notificationManager
.
cancel
(
1
)
// stop the service if no callback registered
if
(
callbackCount
==
0
)
{
stopSelf
()
}
}
override
def
stopBackgroundService
()
{
stopRunner
()
stopSelf
()
}
override
def
getTag
=
TAG
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment