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
0f12a7b0
Commit
0f12a7b0
authored
Jun 07, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refine speed stat
parent
a89d0806
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
src/main/res/values/strings.xml
src/main/res/values/strings.xml
+1
-1
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
...ain/scala/com/github/shadowsocks/ShadowsocksService.scala
+12
-4
No files found.
src/main/res/values/strings.xml
View file @
0f12a7b0
...
...
@@ -44,7 +44,7 @@
<!-- notification category -->
<string
name=
"forward_success"
>
Shadowsocks started.
</string>
<string
name=
"service_running"
>
Running in the background.
</string>
<string
name=
"service_status"
formatted=
"false"
>
Upload: %d KB/s
,
Download: %d KB/s
</string>
<string
name=
"service_status"
formatted=
"false"
>
Upload: %d KB/s
\t|\t
Download: %d KB/s
</string>
<string
name=
"forward_fail"
>
Shadowsocks failed to start.
</string>
<string
name=
"service_stopped"
>
Shadowsocks stopped.
</string>
<string
name=
"forward_stop"
>
Shadowsocks stopped.
</string>
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
View file @
0f12a7b0
...
...
@@ -120,8 +120,10 @@ class ShadowsocksService extends Service {
private
var
state
=
State
.
INIT
private
var
last
=
new
TrafficStat
(
TrafficStats
.
getTotalTxBytes
,
TrafficStats
.
getTotalRxBytes
,
java
.
lang
.
System
.
currentTimeMillis
())
private
var
lastTxRate
=
0
private
var
lastRxRate
=
0
private
val
timer
=
new
Timer
(
true
)
private
val
TIMER_INTERVAL
=
5
private
val
TIMER_INTERVAL
=
1
private
def
changeState
(
s
:
Int
)
{
if
(
state
!=
s
)
{
...
...
@@ -412,13 +414,19 @@ class ShadowsocksService extends Service {
def
run
()
{
val
now
=
new
TrafficStat
(
TrafficStats
.
getTotalTxBytes
,
TrafficStats
.
getTotalRxBytes
,
java
.
lang
.
System
.
currentTimeMillis
())
val
txRate
=
(
now
.
tx
-
last
.
tx
)
/
1024
/
TIMER_INTERVAL
val
rxRate
=
(
now
.
rx
-
last
.
rx
)
/
1024
/
TIMER_INTERVAL
val
txRate
=
(
(
now
.
tx
-
last
.
tx
)
/
1024
/
TIMER_INTERVAL
).
toInt
val
rxRate
=
(
(
now
.
rx
-
last
.
rx
)
/
1024
/
TIMER_INTERVAL
).
toInt
last
=
now
if
(
lastTxRate
==
txRate
&&
lastRxRate
==
rxRate
)
{
return
}
else
{
lastTxRate
=
txRate
lastRxRate
=
rxRate
}
if
(
state
==
State
.
CONNECTED
)
{
Log
.
d
(
TAG
,
getString
(
R
.
string
.
service_status
).
format
(
txRate
,
rxRate
))
notifyForegroundAlert
(
getString
(
R
.
string
.
forward_success
),
getString
(
R
.
string
.
service_status
).
format
(
txRate
,
rxRate
),
txRate
.
toInt
+
rxRate
.
toInt
)
getString
(
R
.
string
.
service_status
).
format
(
txRate
,
rxRate
),
txRate
+
rxRate
)
}
}
}
...
...
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