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
6bff4f1a
Commit
6bff4f1a
authored
Dec 26, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce battery usage - transmit traffic stat with binary
parent
8dcfd5a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
12 deletions
+6
-12
src/main/jni/shadowsocks-libev
src/main/jni/shadowsocks-libev
+1
-1
src/main/scala/com/github/shadowsocks/utils/TrafficMonitorThread.scala
...a/com/github/shadowsocks/utils/TrafficMonitorThread.scala
+5
-11
No files found.
shadowsocks-libev
@
68eaf3b1
Subproject commit
48a063ef1e1a886e274a0fbb797e88358deca35b
Subproject commit
68eaf3b12d385381130c046547163b81e1807ba4
src/main/scala/com/github/shadowsocks/utils/TrafficMonitorThread.scala
View file @
6bff4f1a
...
...
@@ -40,11 +40,11 @@
package
com.github.shadowsocks.utils
import
java.io.
{
File
,
IOException
}
import
java.nio.
{
ByteBuffer
,
ByteOrder
}
import
java.util.concurrent.Executors
import
android.net.
{
LocalServerSocket
,
LocalSocket
,
LocalSocketAddress
}
import
android.util.Log
import
com.github.shadowsocks.BaseService
class
TrafficMonitorThread
()
extends
Thread
{
...
...
@@ -99,16 +99,10 @@ class TrafficMonitorThread() extends Thread {
val
input
=
socket
.
getInputStream
val
output
=
socket
.
getOutputStream
val
buffer
=
new
Array
[
Byte
](
256
)
val
size
=
input
.
read
(
buffer
)
val
array
=
new
Array
[
Byte
](
size
)
Array
.
copy
(
buffer
,
0
,
array
,
0
,
size
)
val
stat
=
new
String
(
array
,
"UTF-8"
).
split
(
"\\|"
)
if
(
stat
.
length
==
2
)
{
TrafficMonitor
.
update
(
stat
(
0
).
toLong
,
stat
(
1
).
toLong
)
}
val
buffer
=
new
Array
[
Byte
](
16
)
if
(
input
.
read
(
buffer
)
!=
16
)
throw
new
IOException
(
"Unexpected traffic stat length"
)
val
stat
=
ByteBuffer
.
wrap
(
buffer
).
order
(
ByteOrder
.
LITTLE_ENDIAN
)
TrafficMonitor
.
update
(
stat
.
getLong
(
0
),
stat
.
getLong
(
8
))
output
.
write
(
0
)
...
...
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