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
415a9f68
Commit
415a9f68
authored
Aug 24, 2014
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refine onTaskRemoved
parent
91a069bc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
45 deletions
+38
-45
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+2
-2
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+13
-21
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+23
-22
No files found.
src/main/AndroidManifest.xml
View file @
415a9f68
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.github.shadowsocks"
android:versionCode=
"6
8
"
android:versionName=
"2.2.
0
"
>
android:versionCode=
"6
9
"
android:versionName=
"2.2.
1
"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
415a9f68
...
...
@@ -220,12 +220,12 @@ class ShadowsocksNatService extends Service with BaseService {
}
def
notifyForegroundAlert
(
title
:
String
,
info
:
String
,
rate
:
Int
)
{
val
openIntent
:
Intent
=
new
Intent
(
this
,
classOf
[
Shadowsocks
])
openIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_
CLEAR_TOP
)
val
contentIntent
:
PendingIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
openIntent
,
0
)
val
closeIntent
:
Intent
=
new
Intent
(
Action
.
CLOSE
)
val
actionIntent
:
PendingIntent
=
PendingIntent
.
getBroadcast
(
this
,
0
,
closeIntent
,
0
)
val
builder
:
NotificationCompat.Builder
=
new
NotificationCompat
.
Builder
(
this
)
val
openIntent
=
new
Intent
(
this
,
classOf
[
Shadowsocks
])
openIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_
REORDER_TO_FRONT
)
val
contentIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
openIntent
,
0
)
val
closeIntent
=
new
Intent
(
Action
.
CLOSE
)
val
actionIntent
=
PendingIntent
.
getBroadcast
(
this
,
0
,
closeIntent
,
0
)
val
builder
=
new
NotificationCompat
.
Builder
(
this
)
val
icon
=
getResources
.
getDrawable
(
R
.
drawable
.
ic_stat_shadowsocks
)
if
(
rate
>=
0
)
{
...
...
@@ -309,14 +309,6 @@ class ShadowsocksNatService extends Service with BaseService {
}
}
override
def
onStartCommand
(
intent
:
Intent
,
flags
:
Int
,
startId
:
Int
)
:
Int
=
{
Service
.
START_STICKY
}
override
def
onTaskRemoved
(
intent
:
Intent
)
{
stopRunner
()
}
def
killProcesses
()
{
Console
.
runRootCommand
(
Utils
.
getIptables
+
" -t nat -F OUTPUT"
)
...
...
@@ -564,13 +556,6 @@ class ShadowsocksNatService extends Service with BaseService {
timer
=
null
}
// clean up context
stopForegroundCompat
(
1
)
if
(
receiver
!=
null
)
{
unregisterReceiver
(
receiver
)
receiver
=
null
}
// reset NAT
killProcesses
()
...
...
@@ -578,6 +563,13 @@ class ShadowsocksNatService extends Service with BaseService {
if
(
callbackCount
==
0
)
{
stopSelf
()
}
// clean up context
if
(
receiver
!=
null
)
{
unregisterReceiver
(
receiver
)
receiver
=
null
}
stopForegroundCompat
(
1
)
}
override
def
stopBackgroundService
()
{
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
415a9f68
...
...
@@ -118,8 +118,8 @@ class ShadowsocksVpnService extends VpnService with BaseService {
def
startVpn
()
{
val
openIntent
:
Intent
=
new
Intent
(
this
,
classOf
[
Shadowsocks
])
openIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_
CLEAR_TOP
)
val
openIntent
=
new
Intent
(
this
,
classOf
[
Shadowsocks
])
openIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_
REORDER_TO_FRONT
)
val
configIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
openIntent
,
0
)
val
builder
=
new
Builder
()
...
...
@@ -221,10 +221,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
}
def
notifyAlert
(
title
:
String
,
info
:
String
)
{
val
openIntent
:
Intent
=
new
Intent
(
this
,
classOf
[
Shadowsocks
])
val
openIntent
=
new
Intent
(
this
,
classOf
[
Shadowsocks
])
openIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
)
val
contentIntent
:
PendingIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
openIntent
,
0
)
val
builder
:
NotificationCompat.Builder
=
new
NotificationCompat
.
Builder
(
this
)
val
contentIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
openIntent
,
0
)
val
builder
=
new
NotificationCompat
.
Builder
(
this
)
builder
.
setSmallIcon
(
R
.
drawable
.
ic_stat_shadowsocks
)
.
setWhen
(
0
)
...
...
@@ -255,14 +255,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
.
asInstanceOf
[
NotificationManager
]
}
override
def
onStartCommand
(
intent
:
Intent
,
flags
:
Int
,
startId
:
Int
)
:
Int
=
{
Service
.
START_STICKY
}
override
def
onTaskRemoved
(
intent
:
Intent
)
{
stopRunner
()
}
override
def
onRevoke
()
{
stopRunner
()
}
...
...
@@ -363,12 +355,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
.
set
(
Fields
.
SESSION_CONTROL
,
"stop"
)
.
build
())
// clean up the context
if
(
receiver
!=
null
)
{
unregisterReceiver
(
receiver
)
receiver
=
null
}
// reset VPN
killProcesses
()
...
...
@@ -378,13 +364,28 @@ class ShadowsocksVpnService extends VpnService with BaseService {
conn
=
null
}
// reset notifications
notificationManager
.
cancel
(
1
)
// stop the service if no callback registered
if
(
callbackCount
==
0
)
{
stopSelf
()
}
// clean up the context
if
(
receiver
!=
null
)
{
unregisterReceiver
(
receiver
)
receiver
=
null
}
// reset notifications
notificationManager
.
cancel
(
1
)
}
override
def
onStartCommand
(
intent
:
Intent
,
flags
:
Int
,
startId
:
Int
)
:
Int
=
{
Service
.
START_STICKY
}
override
def
onTaskRemoved
(
intent
:
Intent
)
{
stopRunner
()
}
override
def
stopBackgroundService
()
{
...
...
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