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
07b9cfa7
Commit
07b9cfa7
authored
Nov 18, 2015
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refine the traffic stat
parent
e667a77b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+5
-1
src/main/scala/com/github/shadowsocks/utils/TrafficMonitor.scala
...n/scala/com/github/shadowsocks/utils/TrafficMonitor.scala
+2
-2
No files found.
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
07b9cfa7
...
@@ -471,7 +471,11 @@ class Shadowsocks
...
@@ -471,7 +471,11 @@ class Shadowsocks
// initialize timer
// initialize timer
val
task
=
new
TimerTask
{
val
task
=
new
TimerTask
{
def
run
()
{
def
run
()
{
TrafficMonitor
.
update
()
if
(
state
==
State
.
CONNECTED
)
{
TrafficMonitor
.
update
()
}
else
{
TrafficMonitor
.
reset
()
}
val
pm
=
getSystemService
(
Context
.
POWER_SERVICE
).
asInstanceOf
[
PowerManager
]
val
pm
=
getSystemService
(
Context
.
POWER_SERVICE
).
asInstanceOf
[
PowerManager
]
if
(
pm
.
isScreenOn
)
{
if
(
pm
.
isScreenOn
)
{
val
trafficStat
=
getString
(
R
.
string
.
stat_summary
).
formatLocal
(
Locale
.
ENGLISH
,
val
trafficStat
=
getString
(
R
.
string
.
stat_summary
).
formatLocal
(
Locale
.
ENGLISH
,
...
...
src/main/scala/com/github/shadowsocks/utils/TrafficMonitor.scala
View file @
07b9cfa7
...
@@ -20,8 +20,8 @@ object TrafficMonitor {
...
@@ -20,8 +20,8 @@ object TrafficMonitor {
var
rxTotal
:
Long
=
0
var
rxTotal
:
Long
=
0
def
getTraffic
()
:
Traffic
=
{
def
getTraffic
()
:
Traffic
=
{
new
Traffic
(
TrafficStats
.
getUidTxBytes
(
uid
),
new
Traffic
(
TrafficStats
.
get
TotalTxBytes
-
TrafficStats
.
get
UidTxBytes
(
uid
),
TrafficStats
.
getUidRxBytes
(
uid
),
System
.
currentTimeMillis
())
TrafficStats
.
get
TotalRxBytes
-
TrafficStats
.
get
UidRxBytes
(
uid
),
System
.
currentTimeMillis
())
}
}
def
formatTraffic
(
n
:
Long
)
:
String
=
{
def
formatTraffic
(
n
:
Long
)
:
String
=
{
...
...
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