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
d8ab3733
Commit
d8ab3733
authored
Dec 27, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix getCallbackCount is not available on API 16
parent
b6fc013a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
src/main/scala/com/github/shadowsocks/BaseService.scala
src/main/scala/com/github/shadowsocks/BaseService.scala
+12
-11
No files found.
src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
d8ab3733
...
...
@@ -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
)
{
timer
.
cancel
()
timer
=
null
if
(
cb
!=
null
&&
callbacks
.
unregister
(
cb
)
)
{
callbacks
Count
-=
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
{
...
...
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