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
bdac32bd
Commit
bdac32bd
authored
May 29, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inter-process persistent preferences
parent
8f9ebabd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
14 deletions
+28
-14
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
+3
-2
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+2
-6
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
...ain/scala/com/github/shadowsocks/ShadowsocksService.scala
+3
-6
src/main/scala/com/github/shadowsocks/Utils.scala
src/main/scala/com/github/shadowsocks/Utils.scala
+20
-0
No files found.
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
View file @
bdac32bd
...
...
@@ -174,11 +174,12 @@ class ShadowVpnService extends VpnService {
return
}
settings
.
edit
().
putBoolean
(
"isRunning"
,
true
).
commit
()
settings
.
edit
().
putBoolean
(
Key
.
isRunning
,
true
).
commit
()
changeState
(
State
.
CONNECTING
)
config
=
Extra
.
get
(
intent
)
Extra
.
save
(
settings
,
config
)
new
Thread
(
new
Runnable
{
def
run
()
{
...
...
@@ -376,7 +377,7 @@ class ShadowVpnService extends VpnService {
def
destroy
()
{
changeState
(
State
.
STOPPED
)
settings
.
edit
.
putBoolean
(
"isRunning"
,
false
).
commit
settings
.
edit
.
putBoolean
(
Key
.
isRunning
,
false
).
commit
EasyTracker
.
getTracker
.
sendEvent
(
TAG
,
"stop"
,
getVersionName
,
0L
)
if
(
receiver
!=
null
)
{
unregisterReceiver
(
receiver
)
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
bdac32bd
...
...
@@ -211,18 +211,16 @@ class Shadowsocks
private
val
handler
:
Handler
=
new
Handler
{
override
def
handleMessage
(
msg
:
Message
)
{
val
ed
:
SharedPreferences.Editor
=
settings
.
edit
msg
.
what
match
{
case
MSG_CRASH_RECOVER
=>
Crouton
.
makeText
(
Shadowsocks
.
this
,
R
.
string
.
crash_alert
,
Style
.
ALERT
).
show
()
ed
.
putBoolean
(
"isRunning"
,
false
)
settings
.
edit
().
putBoolean
(
Key
.
isRunning
,
false
).
apply
(
)
case
MSG_INITIAL_FINISH
=>
if
(
progressDialog
!=
null
)
{
progressDialog
.
dismiss
()
progressDialog
=
null
}
}
ed
.
commit
super
.
handleMessage
(
msg
)
}
}
...
...
@@ -380,9 +378,7 @@ class Shadowsocks
}
}
if
(!
settings
.
getBoolean
(
versionName
,
false
))
{
val
edit
:
SharedPreferences.Editor
=
settings
.
edit
edit
.
putBoolean
(
versionName
,
true
)
edit
.
commit
settings
.
edit
.
putBoolean
(
versionName
,
true
).
apply
()
reset
()
}
handler
.
sendEmptyMessage
(
MSG_INITIAL_FINISH
)
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
View file @
bdac32bd
...
...
@@ -127,18 +127,16 @@ class ShadowsocksService extends Service {
val
handler
:
Handler
=
new
Handler
{
override
def
handleMessage
(
msg
:
Message
)
{
val
ed
:
SharedPreferences.Editor
=
settings
.
edit
msg
.
what
match
{
case
MSG_CONNECT_SUCCESS
=>
changeState
(
State
.
CONNECTED
)
ed
.
putBoolean
(
"isRunning"
,
true
)
settings
.
edit
().
putBoolean
(
Key
.
isRunning
,
true
).
apply
(
)
case
MSG_CONNECT_FAIL
=>
changeState
(
State
.
STOPPED
)
case
MSG_STOP_SELF
=>
stopSelf
()
case
_
=>
}
ed
.
commit
super
.
handleMessage
(
msg
)
}
}
...
...
@@ -215,6 +213,7 @@ class ShadowsocksService extends Service {
changeState
(
State
.
CONNECTING
)
config
=
Extra
.
get
(
intent
)
Extra
.
save
(
settings
,
config
)
new
Thread
(
new
Runnable
{
def
run
()
{
...
...
@@ -395,9 +394,7 @@ class ShadowsocksService extends Service {
killProcesses
()
}
}.
start
()
val
ed
:
SharedPreferences.Editor
=
settings
.
edit
ed
.
putBoolean
(
"isRunning"
,
false
)
ed
.
commit
settings
.
edit
.
putBoolean
(
Key
.
isRunning
,
false
).
apply
()
if
(
receiver
!=
null
)
{
unregisterReceiver
(
receiver
)
receiver
=
null
...
...
src/main/scala/com/github/shadowsocks/Utils.scala
View file @
bdac32bd
...
...
@@ -53,6 +53,8 @@ import android.graphics.{Canvas, Bitmap}
import
android.app.ActivityManager
object
Key
{
val
isRunning
=
"isRunning"
val
isGlobalProxy
=
"isGlobalProxy"
val
isGFWList
=
"isGFWList"
val
isBypassApps
=
"isBypassApps"
...
...
@@ -96,6 +98,24 @@ object Extra {
val
STATE
=
"state"
val
MESSAGE
=
"message"
def
save
(
settings
:
SharedPreferences
,
config
:
Config
)
{
val
edit
=
settings
.
edit
()
edit
.
putBoolean
(
Key
.
isGlobalProxy
,
config
.
isGlobalProxy
)
edit
.
putBoolean
(
Key
.
isGFWList
,
config
.
isGFWList
)
edit
.
putBoolean
(
Key
.
isBypassApps
,
config
.
isBypassApps
)
edit
.
putBoolean
(
Key
.
isDNSProxy
,
config
.
isDNSProxy
)
edit
.
putBoolean
(
Key
.
isHTTPProxy
,
config
.
isHTTPProxy
)
edit
.
putString
(
Key
.
proxy
,
config
.
proxy
)
edit
.
putString
(
Key
.
sitekey
,
config
.
sitekey
)
edit
.
putString
(
Key
.
encMethod
,
config
.
encMethod
)
edit
.
putString
(
Key
.
remotePort
,
config
.
remotePort
.
toString
)
edit
.
putString
(
Key
.
localPort
,
config
.
localPort
.
toString
)
edit
.
apply
()
}
def
get
(
intent
:
Intent
)
:
Config
=
{
val
isGlobalProxy
=
intent
.
getBooleanExtra
(
Key
.
isGlobalProxy
,
false
)
val
isGFWList
=
intent
.
getBooleanExtra
(
Key
.
isGFWList
,
false
)
...
...
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