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
6c047eca
Commit
6c047eca
authored
Aug 22, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add error message if failed
parent
a31e7538
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
...in/scala/com/github/shadowsocks/ShadowsocksSettings.scala
+4
-1
src/main/scala/com/github/shadowsocks/utils/TcpFastOpen.scala
...main/scala/com/github/shadowsocks/utils/TcpFastOpen.scala
+21
-6
No files found.
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
View file @
6c047eca
...
...
@@ -7,6 +7,7 @@ import android.content.{Intent, SharedPreferences}
import
android.net.Uri
import
android.os.Bundle
import
android.preference.
{
Preference
,
PreferenceFragment
,
SwitchPreference
}
import
android.support.design.widget.Snackbar
import
android.support.v7.app.AlertDialog
import
android.webkit.
{
WebView
,
WebViewClient
}
import
com.github.shadowsocks.ShadowsocksApplication.app
...
...
@@ -158,7 +159,9 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
tfo
.
setChecked
(
TcpFastOpen
.
sendEnabled
)
tfo
.
setOnPreferenceChangeListener
((
_
,
v
)
=>
{
val
value
=
v
.
asInstanceOf
[
Boolean
]
TcpFastOpen
.
enabled
(
value
)
val
result
=
TcpFastOpen
.
enabled
(
value
)
if
(
result
!=
null
&&
result
!=
"Success."
)
Snackbar
.
make
(
activity
.
findViewById
(
android
.
R
.
id
.
content
),
result
,
Snackbar
.
LENGTH_LONG
).
show
()
value
==
TcpFastOpen
.
sendEnabled
})
if
(!
TcpFastOpen
.
supported
)
{
...
...
src/main/scala/com/github/shadowsocks/utils/TcpFastOpen.scala
View file @
6c047eca
...
...
@@ -4,6 +4,8 @@ import java.io.File
import
eu.chainfire.libsuperuser.Shell
import
scala.collection.JavaConverters._
/**
* @author Mygod
*/
...
...
@@ -26,11 +28,24 @@ object TcpFastOpen {
file
.
canRead
&&
(
Utils
.
readAllLines
(
file
).
toInt
&
1
)
>
0
}
def
enabled
(
value
:
Boolean
)
=
if
(
supported
)
{
def
enabled
(
value
:
Boolean
)
=
if
(
true
)
{
val
fastopen
=
"echo "
+
(
if
(
value
)
3
else
0
)
+
" > /proc/sys/net/ipv4/tcp_fastopen"
Shell
.
SU
.
run
(
Array
(
"mount -o remount,rw /system && "
+
fastopen
+
" && echo '#!/system/bin/sh\n"
+
fastopen
+
"' > /etc/init.d/tcp_fastopen && chmod 755 /etc/init.d/tcp_fastopen"
,
"mount -o remount,ro /system"
))
}
Shell
.
run
(
"su"
,
Array
(
"if "
+
fastopen
+
"; then"
,
" success=-1"
,
" if mount -o remount,rw /system; then"
,
" echo '#!/system/bin/sh"
,
fastopen
+
"' > /etc/init.d/tcp_fastopen && chmod 755 /etc/init.d/tcp_fastopen"
,
" success=$?"
,
" mount -o remount,ro /system"
,
" fi"
,
" if [ $success -eq 0 ]; then"
,
" echo Success."
,
" else"
,
" echo Warning: Unable to create boot script."
,
" fi"
,
"else"
,
" echo Failed."
,
"fi"
),
null
,
true
).
asScala
.
mkString
(
"\n"
)
}
else
null
}
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