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
494d35ee
Commit
494d35ee
authored
Aug 08, 2018
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow TFO toggling without changing system if possible
Fix #1906.
parent
35f5f65b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
8 deletions
+12
-8
mobile/src/main/java/com/github/shadowsocks/App.kt
mobile/src/main/java/com/github/shadowsocks/App.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/GlobalSettingsPreferenceFragment.kt
...om/github/shadowsocks/GlobalSettingsPreferenceFragment.kt
+6
-4
mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt
...le/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/preference/DataStore.kt
.../main/java/com/github/shadowsocks/preference/DataStore.kt
+2
-0
mobile/src/main/res/values/strings.xml
mobile/src/main/res/values/strings.xml
+1
-1
No files found.
mobile/src/main/java/com/github/shadowsocks/App.kt
View file @
494d35ee
...
...
@@ -123,7 +123,7 @@ class App : Application() {
// handle data restored/crash
if
(
Build
.
VERSION
.
SDK_INT
>=
24
&&
DataStore
.
directBootAware
&&
getSystemService
<
UserManager
>()
?.
isUserUnlocked
==
true
)
DirectBoot
.
flushTrafficStats
()
TcpFastOpen
.
enabledAsync
(
DataStore
.
publicStore
.
getBoolean
(
Key
.
tfo
,
TcpFastOpen
.
sendEnabled
)
)
if
(
DataStore
.
tcpFastOpen
)
TcpFastOpen
.
enabledAsync
(
true
)
if
(
DataStore
.
publicStore
.
getLong
(
Key
.
assetUpdateTime
,
-
1
)
!=
info
.
lastUpdateTime
)
{
val
assetManager
=
assets
for
(
dir
in
arrayOf
(
"acl"
,
"overture"
))
...
...
mobile/src/main/java/com/github/shadowsocks/GlobalSettingsPreferenceFragment.kt
View file @
494d35ee
...
...
@@ -50,11 +50,13 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompat() {
}
else
canToggleLocked
.
parent
!!
.
removePreference
(
canToggleLocked
)
val
tfo
=
findPreference
(
Key
.
tfo
)
as
SwitchPreference
tfo
.
isChecked
=
TcpFastOpen
.
sendEnabled
tfo
.
isChecked
=
DataStore
.
tcpFastOpen
tfo
.
setOnPreferenceChangeListener
{
_
,
value
->
val
result
=
TcpFastOpen
.
enabled
(
value
as
Boolean
)
if
(
result
!=
null
&&
result
!=
"Success."
)
(
activity
as
MainActivity
).
snackbar
(
result
).
show
()
value
==
TcpFastOpen
.
sendEnabled
if
(
value
as
Boolean
)
{
val
result
=
TcpFastOpen
.
enabled
(
true
)
if
(
result
!=
null
&&
result
!=
"Success."
)
(
activity
as
MainActivity
).
snackbar
(
result
).
show
()
TcpFastOpen
.
sendEnabled
}
else
true
}
if
(!
TcpFastOpen
.
supported
)
{
tfo
.
isEnabled
=
false
...
...
mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
494d35ee
...
...
@@ -189,7 +189,7 @@ object BaseService {
val
pluginPath
=
pluginPath
if
(
pluginPath
!=
null
)
{
val
pluginCmd
=
arrayListOf
(
pluginPath
)
if
(
TcpFastOpen
.
sendEnabled
)
pluginCmd
.
add
(
"--fast-open"
)
if
(
DataStore
.
tcpFastOpen
)
pluginCmd
.
add
(
"--fast-open"
)
config
.
put
(
"plugin"
,
Commandline
.
toString
(
service
.
buildAdditionalArguments
(
pluginCmd
)))
.
put
(
"plugin_opts"
,
plugin
.
toString
())
...
...
@@ -268,7 +268,7 @@ object BaseService {
if
(
profile
.
udpdns
)
cmd
+=
"-D"
if
(
TcpFastOpen
.
sendEnabled
)
cmd
+=
"--fast-open"
if
(
DataStore
.
tcpFastOpen
)
cmd
+=
"--fast-open"
data
.
processes
.
start
(
cmd
)
}
...
...
mobile/src/main/java/com/github/shadowsocks/preference/DataStore.kt
View file @
494d35ee
...
...
@@ -27,6 +27,7 @@ import com.github.shadowsocks.database.PrivateDatabase
import
com.github.shadowsocks.database.PublicDatabase
import
com.github.shadowsocks.utils.DirectBoot
import
com.github.shadowsocks.utils.Key
import
com.github.shadowsocks.utils.TcpFastOpen
import
com.github.shadowsocks.utils.parsePort
object
DataStore
{
...
...
@@ -52,6 +53,7 @@ object DataStore {
}
val
canToggleLocked
:
Boolean
get
()
=
publicStore
.
getBoolean
(
Key
.
directBootAware
)
==
true
val
directBootAware
:
Boolean
get
()
=
app
.
directBootSupported
&&
canToggleLocked
val
tcpFastOpen
:
Boolean
get
()
=
TcpFastOpen
.
sendEnabled
&&
DataStore
.
publicStore
.
getBoolean
(
Key
.
tfo
,
true
)
@AppCompatDelegate
.
NightMode
val
nightMode
get
()
=
when
(
publicStore
.
getString
(
Key
.
nightMode
))
{
Key
.
nightModeAuto
->
AppCompatDelegate
.
MODE_NIGHT_AUTO
...
...
mobile/src/main/res/values/strings.xml
View file @
494d35ee
...
...
@@ -53,7 +53,7 @@
instead
</string>
<string
name=
"direct_boot_aware"
>
Allow Toggling in Lock Screen
</string>
<string
name=
"direct_boot_aware_summary"
>
Your selected profile information will be less protected
</string>
<string
name=
"tcp_fastopen_summary"
>
Toggling
requires
ROOT permission
</string>
<string
name=
"tcp_fastopen_summary"
>
Toggling
might require
ROOT permission
</string>
<string
name=
"tcp_fastopen_summary_unsupported"
>
Unsupported kernel version: %s
<
3.7.1
</string>
<string
name=
"udp_dns"
>
DNS Forwarding
</string>
<string
name=
"udp_dns_summary"
>
Forward all DNS requests to remote
</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