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
98774ac6
Commit
98774ac6
authored
Jan 21, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix deprecation
parent
5b9af4e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
.../src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
+1
-1
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
+15
-14
No files found.
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
View file @
98774ac6
...
...
@@ -142,7 +142,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
fun
scheduleUpdate
()
{
if
(
route
!
in
arrayOf
(
Acl
.
ALL
,
Acl
.
CUSTOM_RULES
))
AclSyncer
.
schedule
(
route
)
if
(
scheduleConfigUpdate
)
RemoteConfig
.
scheduleFetch
()
if
(
scheduleConfigUpdate
)
RemoteConfig
.
fetchAsync
()
}
fun
shutdown
(
scope
:
CoroutineScope
)
{
...
...
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
View file @
98774ac6
...
...
@@ -25,25 +25,26 @@ import androidx.core.os.bundleOf
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.core.R
import
com.google.firebase.remoteconfig.FirebaseRemoteConfig
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.async
import
kotlinx.coroutines.tasks.await
object
RemoteConfig
{
private
val
config
=
FirebaseRemoteConfig
.
getInstance
().
apply
{
setDefaults
(
R
.
xml
.
default_configs
)
}
private
fun
Exception
.
log
()
{
Log
.
w
(
"RemoteConfig"
,
this
)
Core
.
analytics
.
logEvent
(
"femote_config_failure"
,
bundleOf
(
Pair
(
javaClass
.
simpleName
,
message
)))
private
val
config
=
GlobalScope
.
async
(
Dispatchers
.
Main
.
immediate
)
{
FirebaseRemoteConfig
.
getInstance
().
apply
{
setDefaultsAsync
(
R
.
xml
.
default_configs
).
await
()
}
}
fun
scheduleFetch
()
=
config
.
fetch
().
addOnCompleteListener
{
if
(
it
.
isSuccessful
)
config
.
activate
()
else
it
.
exception
?.
log
()
}
fun
fetchAsync
()
=
GlobalScope
.
async
(
Dispatchers
.
Main
.
immediate
)
{
fetch
()
}
suspend
fun
fetch
()
=
try
{
config
.
fetch
().
await
()
config
to
true
}
catch
(
e
:
Exception
)
{
e
.
log
()
config
to
false
suspend
fun
fetch
()
=
config
.
await
().
run
{
try
{
fetch
().
await
()
this
to
true
}
catch
(
e
:
Exception
)
{
Log
.
w
(
"RemoteConfig"
,
e
)
Core
.
analytics
.
logEvent
(
"femote_config_failure"
,
bundleOf
(
Pair
(
javaClass
.
simpleName
,
e
.
message
)))
this
to
false
}
}
}
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