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
4f3ebf93
Commit
4f3ebf93
authored
Dec 27, 2015
by
Max Lv
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #497 from Mygod/master
Fix #496
parents
9feb5bd9
bf135107
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
27 deletions
+20
-27
src/main/scala/com/github/shadowsocks/BaseService.scala
src/main/scala/com/github/shadowsocks/BaseService.scala
+12
-11
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+0
-3
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
...in/scala/com/github/shadowsocks/ShadowsocksSettings.scala
+6
-8
src/main/scala/com/github/shadowsocks/database/DBHelper.scala
...main/scala/com/github/shadowsocks/database/DBHelper.scala
+2
-5
No files found.
src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
4f3ebf93
...
...
@@ -56,6 +56,7 @@ trait BaseService extends Service {
var
trafficMonitorThread
:
TrafficMonitorThread
=
null
final
val
callbacks
=
new
RemoteCallbackList
[
IShadowsocksServiceCallback
]
var
callbacksCount
:
Int
=
_
val
binder
=
new
IShadowsocksService
.
Stub
{
override
def
getMode
:
Int
=
{
...
...
@@ -67,19 +68,19 @@ trait BaseService extends Service {
}
override
def
unregisterCallback
(
cb
:
IShadowsocksServiceCallback
)
{
if
(
cb
!=
null
)
{
callbacks
.
unregister
(
cb
)
}
if
(
callbacks
.
getRegisteredCallbackCount
==
0
&&
timer
!=
null
)
{
if
(
cb
!=
null
&&
callbacks
.
unregister
(
cb
))
{
callbacksCount
-=
1
if
(
callbacksCount
==
0
&&
timer
!=
null
)
{
timer
.
cancel
()
timer
=
null
}
}
}
override
def
registerCallback
(
cb
:
IShadowsocksServiceCallback
)
{
if
(
cb
!=
null
)
{
callbacks
.
register
(
cb
)
if
(
callbacks
.
getRegisteredCallback
Count
!=
0
&&
timer
==
null
)
{
if
(
cb
!=
null
&&
callbacks
.
register
(
cb
)
)
{
callbacks
Count
+=
1
if
(
callbacksCount
!=
0
&&
timer
==
null
)
{
val
task
=
new
TimerTask
{
def
run
{
if
(
TrafficMonitor
.
updateRate
())
updateTrafficRate
()
...
...
@@ -160,7 +161,7 @@ trait BaseService extends Service {
def
updateTrafficRate
()
{
val
handler
=
new
Handler
(
getContext
.
getMainLooper
)
handler
.
post
(()
=>
{
if
(
callbacks
.
getRegisteredCallback
Count
>
0
)
{
if
(
callbacksCount
>
0
)
{
val
txRate
=
TrafficMonitor
.
getTxRate
val
rxRate
=
TrafficMonitor
.
getRxRate
val
txTotal
=
TrafficMonitor
.
getTxTotal
...
...
@@ -181,7 +182,7 @@ trait BaseService extends Service {
protected
def
changeState
(
s
:
Int
,
msg
:
String
)
{
val
handler
=
new
Handler
(
getContext
.
getMainLooper
)
handler
.
post
(()
=>
if
(
state
!=
s
)
{
if
(
callbacks
.
getRegisteredCallback
Count
>
0
)
{
if
(
callbacksCount
>
0
)
{
val
n
=
callbacks
.
beginBroadcast
()
for
(
i
<-
0
until
n
)
{
try
{
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
4f3ebf93
...
...
@@ -104,7 +104,6 @@ class Shadowsocks
var
progressDialog
:
ProgressDialog
=
_
var
progressTag
=
-
1
var
state
=
State
.
STOPPED
var
prepared
=
false
var
currentProfile
=
new
Profile
var
vpnEnabled
=
-
1
var
trafficCache
:
String
=
_
...
...
@@ -402,7 +401,6 @@ class Shadowsocks
protected
override
def
onPause
()
{
super
.
onPause
()
ShadowsocksApplication
.
profileManager
.
save
prepared
=
false
}
private
def
stateUpdate
()
{
...
...
@@ -517,7 +515,6 @@ class Shadowsocks
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
=
resultCode
match
{
case
Activity
.
RESULT_OK
=>
prepared
=
true
serviceStart
()
case
_
=>
cancelStart
()
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
View file @
4f3ebf93
...
...
@@ -166,18 +166,16 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
isProxyApps
.
setChecked
(
ShadowsocksApplication
.
settings
.
getBoolean
(
Key
.
isProxyApps
,
false
))
// update
}
override
def
on
Pause
{
super
.
on
Pause
()
override
def
on
Destroy
{
super
.
on
Destroy
()
ShadowsocksApplication
.
settings
.
unregisterOnSharedPreferenceChangeListener
(
this
)
}
def
onSharedPreferenceChanged
(
sharedPreferences
:
SharedPreferences
,
key
:
String
)
=
key
match
{
case
Key
.
isNAT
=>
activity
.
handler
.
post
(()
=>
{
case
Key
.
isNAT
=>
activity
.
handler
.
post
(()
=>
{
activity
.
deattachService
activity
.
attachService
})
setEnabled
(
enabled
)
case
_
=>
}
...
...
src/main/scala/com/github/shadowsocks/database/DBHelper.scala
View file @
4f3ebf93
...
...
@@ -105,17 +105,14 @@ class DBHelper(val context: Context)
" ipv6, individual FROM `tmp`;"
)
profileDao
.
executeRawNoArgs
(
"DROP TABLE `tmp`;"
)
profileDao
.
executeRawNoArgs
(
"COMMIT;"
)
return
}
if
(
oldVersion
<
13
)
{
}
else
if
(
oldVersion
<
13
)
{
profileDao
.
executeRawNoArgs
(
"ALTER TABLE `profile` ADD COLUMN tx LONG;"
)
profileDao
.
executeRawNoArgs
(
"ALTER TABLE `profile` ADD COLUMN rx LONG;"
)
profileDao
.
executeRawNoArgs
(
"ALTER TABLE `profile` ADD COLUMN date VARCHAR;"
)
}
if
(
oldVersion
<
15
)
{
profileDao
.
executeRawNoArgs
(
"ALTER TABLE `profile` ADD COLUMN userOrder LONG;"
)
if
(
oldVersion
>=
12
)
profileDao
.
executeRawNoArgs
(
"ALTER TABLE `profile` ADD COLUMN userOrder LONG;"
)
var
i
=
0
for
(
profile
<-
profileDao
.
queryForAll
.
asScala
)
{
if
(
oldVersion
<
14
)
profile
.
individual
=
updateProxiedApps
(
context
,
profile
.
individual
)
...
...
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