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
b634ef0d
Commit
b634ef0d
authored
Mar 30, 2018
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Name threads for better debugging experience
Also removes an unnecessary thread.
parent
32d64222
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
13 deletions
+17
-13
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
+7
-5
mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt
...le/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/bg/GuardedProcess.kt
...src/main/java/com/github/shadowsocks/bg/GuardedProcess.kt
+4
-2
mobile/src/main/java/com/github/shadowsocks/bg/LocalSocketListener.kt
...ain/java/com/github/shadowsocks/bg/LocalSocketListener.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/utils/TcpFastOpen.kt
...src/main/java/com/github/shadowsocks/utils/TcpFastOpen.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/utils/Utils.kt
mobile/src/main/java/com/github/shadowsocks/utils/Utils.kt
+2
-2
No files found.
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
View file @
b634ef0d
...
...
@@ -155,7 +155,7 @@ class AppManager : AppCompatActivity(), Toolbar.OnMenuItemClickListener {
appListView
.
visibility
=
View
.
GONE
fastScroller
.
visibility
=
View
.
GONE
loadingView
.
visibility
=
View
.
VISIBLE
thread
{
thread
(
"AppManager-loader"
)
{
val
adapter
=
appListView
.
adapter
as
AppsAdapter
do
{
appsLoading
.
set
(
true
)
...
...
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
View file @
b634ef0d
...
...
@@ -266,18 +266,20 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, Drawe
++
testCount
statusText
.
setText
(
R
.
string
.
connection_test_testing
)
val
id
=
testCount
// it would change by other code
thread
{
testConnection
(
id
)
}
thread
(
"ConnectionTest"
)
{
testConnection
(
id
)
}
}
}
fab
=
findViewById
(
R
.
id
.
fab
)
fab
.
setOnClickListener
{
if
(
state
==
BaseService
.
CONNECTED
)
app
.
stopService
()
else
thread
{
if
(
BaseService
.
usingVpnMode
)
{
when
{
state
==
BaseService
.
CONNECTED
->
app
.
stopService
()
BaseService
.
usingVpnMode
->
{
val
intent
=
VpnService
.
prepare
(
this
)
if
(
intent
!=
null
)
startActivityForResult
(
intent
,
REQUEST_CONNECT
)
else
app
.
handler
.
post
{
onActivityResult
(
REQUEST_CONNECT
,
Activity
.
RESULT_OK
,
null
)
}
}
else
app
.
startService
()
else
onActivityResult
(
REQUEST_CONNECT
,
Activity
.
RESULT_OK
,
null
)
}
else
->
app
.
startService
()
}
}
...
...
mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
b634ef0d
...
...
@@ -341,7 +341,7 @@ object BaseService {
data
.
changeState
(
CONNECTING
)
thread
{
thread
(
"$tag-Connecting"
)
{
try
{
if
(
profile
.
host
==
"198.199.101.152"
)
{
val
client
=
OkHttpClient
.
Builder
()
...
...
mobile/src/main/java/com/github/shadowsocks/bg/GuardedProcess.kt
View file @
b634ef0d
...
...
@@ -28,6 +28,7 @@ import com.github.shadowsocks.BuildConfig
import
com.github.shadowsocks.JniHelper
import
com.github.shadowsocks.utils.Commandline
import
com.github.shadowsocks.utils.thread
import
java.io.File
import
java.io.IOException
import
java.io.InputStream
import
java.util.concurrent.Semaphore
...
...
@@ -42,8 +43,9 @@ class GuardedProcess(private val cmd: List<String>) {
private
var
isDestroyed
=
false
@Volatile
private
lateinit
var
process
:
Process
private
val
name
=
File
(
cmd
.
first
()).
nameWithoutExtension
private
fun
streamLogger
(
input
:
InputStream
,
logger
:
(
String
,
String
)
->
Int
)
=
thread
{
private
fun
streamLogger
(
input
:
InputStream
,
logger
:
(
String
,
String
)
->
Int
)
=
thread
(
"StreamLogger-$name"
)
{
try
{
input
.
bufferedReader
().
useLines
{
it
.
forEach
{
logger
(
TAG
,
it
)
}
}
}
catch
(
_
:
IOException
)
{
}
// ignore
...
...
@@ -53,7 +55,7 @@ class GuardedProcess(private val cmd: List<String>) {
val
semaphore
=
Semaphore
(
1
)
semaphore
.
acquire
()
var
ioException
:
IOException
?
=
null
guardThread
=
thread
(
name
=
"GuardThread-"
+
cmd
.
first
()
)
{
guardThread
=
thread
(
"GuardThread-$name"
)
{
try
{
var
callback
:
(()
->
Unit
)?
=
null
while
(!
isDestroyed
)
{
...
...
mobile/src/main/java/com/github/shadowsocks/bg/LocalSocketListener.kt
View file @
b634ef0d
...
...
@@ -28,7 +28,7 @@ import com.github.shadowsocks.App.Companion.app
import
java.io.File
import
java.io.IOException
abstract
class
LocalSocketListener
(
protected
val
tag
:
String
)
:
Thread
()
{
abstract
class
LocalSocketListener
(
protected
val
tag
:
String
)
:
Thread
(
tag
)
{
init
{
setUncaughtExceptionHandler
(
app
::
track
)
}
...
...
mobile/src/main/java/com/github/shadowsocks/utils/TcpFastOpen.kt
View file @
b634ef0d
...
...
@@ -52,5 +52,5 @@ object TcpFastOpen {
"else"
,
" echo Failed."
,
"fi"
),
null
,
true
)
?.
joinToString
(
"\n"
)
fun
enabledAsync
(
value
:
Boolean
)
=
thread
{
enabled
(
value
)
}.
join
(
1000
)
fun
enabledAsync
(
value
:
Boolean
)
=
thread
(
"TcpFastOpen"
)
{
enabled
(
value
)
}.
join
(
1000
)
}
mobile/src/main/java/com/github/shadowsocks/utils/Utils.kt
View file @
b634ef0d
...
...
@@ -39,8 +39,8 @@ fun broadcastReceiver(callback: (Context, Intent) -> Unit): BroadcastReceiver =
/**
* Wrapper for kotlin.concurrent.thread that tracks uncaught exceptions.
*/
fun
thread
(
start
:
Boolean
=
true
,
isDaemon
:
Boolean
=
false
,
contextClassLoader
:
ClassLoader
?
=
null
,
name
:
String
?
=
null
,
priority
:
Int
=
-
1
,
block
:
()
->
Unit
):
Thread
{
fun
thread
(
name
:
String
?
=
null
,
start
:
Boolean
=
true
,
isDaemon
:
Boolean
=
false
,
contextClassLoader
:
ClassLoader
?
=
null
,
priority
:
Int
=
-
1
,
block
:
()
->
Unit
):
Thread
{
val
thread
=
kotlin
.
concurrent
.
thread
(
false
,
isDaemon
,
contextClassLoader
,
name
,
priority
,
block
)
thread
.
setUncaughtExceptionHandler
(
app
::
track
)
if
(
start
)
thread
.
start
()
...
...
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