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
0ec69f23
Commit
0ec69f23
authored
Mar 08, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow data to be null for destroyed services
parent
23e6984c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+7
-6
No files found.
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
0ec69f23
...
@@ -106,8 +106,8 @@ object BaseService {
...
@@ -106,8 +106,8 @@ object BaseService {
private
val
bandwidthListeners
=
mutableMapOf
<
IBinder
,
Long
>()
// the binder is the real identifier
private
val
bandwidthListeners
=
mutableMapOf
<
IBinder
,
Long
>()
// the binder is the real identifier
private
val
handler
=
Handler
()
private
val
handler
=
Handler
()
override
fun
getState
():
Int
=
data
!!
.
state
.
ordinal
override
fun
getState
():
Int
=
(
data
?.
state
?:
State
.
Idle
)
.
ordinal
override
fun
getProfileName
():
String
=
data
!!
.
proxy
?.
profile
?.
name
?:
"Idle"
override
fun
getProfileName
():
String
=
data
?
.
proxy
?.
profile
?.
name
?:
"Idle"
override
fun
registerCallback
(
cb
:
IShadowsocksServiceCallback
)
{
override
fun
registerCallback
(
cb
:
IShadowsocksServiceCallback
)
{
callbacks
.
register
(
cb
)
callbacks
.
register
(
cb
)
...
@@ -133,7 +133,7 @@ object BaseService {
...
@@ -133,7 +133,7 @@ object BaseService {
.
map
{
Pair
(
it
.
profile
.
id
,
it
.
trafficMonitor
?.
requestUpdate
())
}
.
map
{
Pair
(
it
.
profile
.
id
,
it
.
trafficMonitor
?.
requestUpdate
())
}
.
filter
{
it
.
second
!=
null
}
.
filter
{
it
.
second
!=
null
}
.
map
{
Triple
(
it
.
first
,
it
.
second
!!
.
first
,
it
.
second
!!
.
second
)
}
.
map
{
Triple
(
it
.
first
,
it
.
second
!!
.
first
,
it
.
second
!!
.
second
)
}
if
(
stats
.
any
{
it
.
third
}
&&
data
!!
.
state
==
State
.
Connected
&&
bandwidthListeners
.
isNotEmpty
())
{
if
(
stats
.
any
{
it
.
third
}
&&
data
?
.
state
==
State
.
Connected
&&
bandwidthListeners
.
isNotEmpty
())
{
val
sum
=
stats
.
fold
(
TrafficStats
())
{
a
,
b
->
a
+
b
.
second
}
val
sum
=
stats
.
fold
(
TrafficStats
())
{
a
,
b
->
a
+
b
.
second
}
broadcast
{
item
->
broadcast
{
item
->
if
(
bandwidthListeners
.
contains
(
item
.
asBinder
()))
{
if
(
bandwidthListeners
.
contains
(
item
.
asBinder
()))
{
...
@@ -149,16 +149,17 @@ object BaseService {
...
@@ -149,16 +149,17 @@ object BaseService {
val
wasEmpty
=
bandwidthListeners
.
isEmpty
()
val
wasEmpty
=
bandwidthListeners
.
isEmpty
()
if
(
bandwidthListeners
.
put
(
cb
.
asBinder
(),
timeout
)
==
null
)
{
if
(
bandwidthListeners
.
put
(
cb
.
asBinder
(),
timeout
)
==
null
)
{
if
(
wasEmpty
)
registerTimeout
()
if
(
wasEmpty
)
registerTimeout
()
if
(
data
!!
.
state
!=
State
.
Connected
)
return
if
(
data
?
.
state
!=
State
.
Connected
)
return
var
sum
=
TrafficStats
()
var
sum
=
TrafficStats
()
val
proxy
=
data
!!
.
proxy
?:
return
val
data
=
data
val
proxy
=
data
?.
proxy
?:
return
proxy
.
trafficMonitor
?.
out
.
also
{
stats
->
proxy
.
trafficMonitor
?.
out
.
also
{
stats
->
cb
.
trafficUpdated
(
proxy
.
profile
.
id
,
if
(
stats
==
null
)
sum
else
{
cb
.
trafficUpdated
(
proxy
.
profile
.
id
,
if
(
stats
==
null
)
sum
else
{
sum
+=
stats
sum
+=
stats
stats
stats
})
})
}
}
data
!!
.
udpFallback
?.
also
{
udpFallback
->
data
.
udpFallback
?.
also
{
udpFallback
->
udpFallback
.
trafficMonitor
?.
out
.
also
{
stats
->
udpFallback
.
trafficMonitor
?.
out
.
also
{
stats
->
cb
.
trafficUpdated
(
udpFallback
.
profile
.
id
,
if
(
stats
==
null
)
TrafficStats
()
else
{
cb
.
trafficUpdated
(
udpFallback
.
profile
.
id
,
if
(
stats
==
null
)
TrafficStats
()
else
{
sum
+=
stats
sum
+=
stats
...
...
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