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
7e9b937b
Commit
7e9b937b
authored
Aug 08, 2018
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix platform nullability checks
parent
5841e26e
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
74 additions
and
79 deletions
+74
-79
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/AppManager.kt
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
+8
-5
mobile/src/main/java/com/github/shadowsocks/ProfileConfigActivity.kt
...main/java/com/github/shadowsocks/ProfileConfigActivity.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+3
-4
mobile/src/main/java/com/github/shadowsocks/ScannerActivity.kt
...e/src/main/java/com/github/shadowsocks/ScannerActivity.kt
+1
-2
mobile/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
...rc/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
+41
-44
mobile/src/main/java/com/github/shadowsocks/bg/ProxyService.kt
...e/src/main/java/com/github/shadowsocks/bg/ProxyService.kt
+1
-2
mobile/src/main/java/com/github/shadowsocks/bg/ServiceNotification.kt
...ain/java/com/github/shadowsocks/bg/ServiceNotification.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/bg/TransproxyService.kt
.../main/java/com/github/shadowsocks/bg/TransproxyService.kt
+1
-2
mobile/src/main/java/com/github/shadowsocks/bg/VpnService.kt
mobile/src/main/java/com/github/shadowsocks/bg/VpnService.kt
+1
-2
mobile/src/main/java/com/github/shadowsocks/plugin/PluginConfiguration.kt
...java/com/github/shadowsocks/plugin/PluginConfiguration.kt
+3
-3
mobile/src/main/java/com/github/shadowsocks/plugin/PluginManager.kt
.../main/java/com/github/shadowsocks/plugin/PluginManager.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/preference/PluginConfigurationDialogFragment.kt
...adowsocks/preference/PluginConfigurationDialogFragment.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/utils/Commandline.kt
...src/main/java/com/github/shadowsocks/utils/Commandline.kt
+2
-2
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
+1
-1
plugin/src/main/java/com/github/shadowsocks/plugin/NativePluginProvider.kt
...ava/com/github/shadowsocks/plugin/NativePluginProvider.kt
+1
-1
plugin/src/main/java/com/github/shadowsocks/plugin/PluginOptions.kt
.../main/java/com/github/shadowsocks/plugin/PluginOptions.kt
+1
-1
No files found.
mobile/src/main/java/com/github/shadowsocks/App.kt
View file @
7e9b937b
...
...
@@ -128,7 +128,7 @@ class App : Application() {
val
assetManager
=
assets
for
(
dir
in
arrayOf
(
"acl"
,
"overture"
))
try
{
for
(
file
in
assetManager
.
list
(
dir
))
assetManager
.
open
(
"$dir/$file"
).
use
{
input
->
for
(
file
in
assetManager
.
list
(
dir
)
!!
)
assetManager
.
open
(
"$dir/$file"
).
use
{
input
->
File
(
deviceStorage
.
filesDir
,
file
).
outputStream
().
use
{
output
->
input
.
copyTo
(
output
)
}
}
}
catch
(
e
:
IOException
)
{
...
...
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
View file @
7e9b937b
...
...
@@ -174,8 +174,8 @@ class AppManager : AppCompatActivity(), Toolbar.OnMenuItemClickListener {
toolbar
.
setNavigationIcon
(
theme
.
resolveResourceId
(
R
.
attr
.
homeAsUpIndicator
))
toolbar
.
setNavigationOnClickListener
{
val
intent
=
parentActivityIntent
if
(
shouldUpRecreateTask
(
intent
)
||
isTaskRoot
)
TaskStackBuilder
.
create
(
this
).
addNextIntentWithParentStack
(
intent
).
startActivities
()
else
finish
()
if
(
intent
==
null
||
!
shouldUpRecreateTask
(
intent
)
&&
!
isTaskRoot
)
finish
()
else
TaskStackBuilder
.
create
(
this
).
addNextIntentWithParentStack
(
intent
).
startActivities
()
}
toolbar
.
inflateMenu
(
R
.
menu
.
app_manager_menu
)
toolbar
.
setOnMenuItemClickListener
(
this
)
...
...
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
View file @
7e9b937b
...
...
@@ -142,12 +142,15 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, OnPre
}
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
if
(
requestCode
!=
REQUEST_CONNECT
)
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
else
if
(
resultCode
==
Activity
.
RESULT_OK
)
app
.
startService
()
else
{
when
{
requestCode
!=
REQUEST_CONNECT
->
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
resultCode
==
Activity
.
RESULT_OK
->
app
.
startService
()
else
->
{
snackbar
().
setText
(
R
.
string
.
vpn_permission_denied
).
show
()
Crashlytics
.
log
(
Log
.
ERROR
,
TAG
,
"Failed to start VpnService from onActivityResult: $data"
)
}
}
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
...
...
@@ -194,7 +197,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, OnPre
}
private
fun
handleShareIntent
(
intent
:
Intent
)
{
val
sharedStr
=
when
(
intent
.
action
)
{
Intent
.
ACTION_VIEW
->
intent
.
data
.
toString
()
Intent
.
ACTION_VIEW
->
intent
.
data
?
.
toString
()
NfcAdapter
.
ACTION_NDEF_DISCOVERED
->
{
val
rawMsgs
=
intent
.
getParcelableArrayExtra
(
NfcAdapter
.
EXTRA_NDEF_MESSAGES
)
if
(
rawMsgs
!=
null
&&
rawMsgs
.
isNotEmpty
())
String
((
rawMsgs
[
0
]
as
NdefMessage
).
records
[
0
].
payload
)
...
...
mobile/src/main/java/com/github/shadowsocks/ProfileConfigActivity.kt
View file @
7e9b937b
...
...
@@ -50,8 +50,8 @@ class ProfileConfigActivity : AppCompatActivity() {
override
fun
onBackPressed
()
{
if
(
DataStore
.
dirty
)
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
unsaved_changes_prompt
)
.
setPositiveButton
(
R
.
string
.
yes
,
{
_
,
_
->
child
.
saveAndExit
()
})
.
setNegativeButton
(
R
.
string
.
no
,
{
_
,
_
->
finish
()
})
.
setPositiveButton
(
R
.
string
.
yes
)
{
_
,
_
->
child
.
saveAndExit
()
}
.
setNegativeButton
(
R
.
string
.
no
)
{
_
,
_
->
finish
()
}
.
setNeutralButton
(
android
.
R
.
string
.
cancel
,
null
)
.
create
()
.
show
()
else
super
.
onBackPressed
()
...
...
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
7e9b937b
...
...
@@ -85,12 +85,11 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
@SuppressLint
(
"ValidFragment"
)
class
QRCodeDialog
()
:
DialogFragment
()
{
constructor
(
url
:
String
)
:
this
()
{
arguments
=
bundleOf
(
Pair
(
KEY_URL
,
url
))
}
private
val
url
get
()
=
arguments
!!
.
getString
(
KEY_URL
)
private
val
url
get
()
=
arguments
?.
getString
(
KEY_URL
)
!!
private
val
nfcShareItem
by
lazy
{
url
.
toByteArray
()
}
private
var
adapter
:
NfcAdapter
?
=
null
...
...
@@ -424,7 +423,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
var
success
=
false
val
activity
=
activity
as
MainActivity
for
(
uri
in
data
!!
.
datas
)
try
{
Profile
.
parseJson
(
activity
.
contentResolver
.
openInputStream
(
uri
).
bufferedReader
().
readText
(),
Profile
.
parseJson
(
activity
.
contentResolver
.
openInputStream
(
uri
)
!!
.
bufferedReader
().
readText
(),
feature
).
forEach
{
ProfileManager
.
createProfile
(
it
)
success
=
true
...
...
@@ -438,7 +437,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
REQUEST_EXPORT_PROFILES
->
{
val
profiles
=
ProfileManager
.
getAllProfiles
()
if
(
profiles
!=
null
)
try
{
requireContext
().
contentResolver
.
openOutputStream
(
data
!!
.
data
)
.
bufferedWriter
().
use
{
requireContext
().
contentResolver
.
openOutputStream
(
data
?.
data
!!
)
!!
.
bufferedWriter
().
use
{
it
.
write
(
JSONArray
(
profiles
.
map
{
it
.
toJson
()
}.
toTypedArray
()).
toString
(
2
))
}
}
catch
(
e
:
Exception
)
{
...
...
mobile/src/main/java/com/github/shadowsocks/ScannerActivity.kt
View file @
7e9b937b
...
...
@@ -64,9 +64,8 @@ class ScannerActivity : AppCompatActivity(), Toolbar.OnMenuItemClickListener, Ba
private
fun
navigateUp
()
{
val
intent
=
parentActivityIntent
if
(
shouldUpRecreateTask
(
intent
)
||
isTaskRoot
)
if
(
intent
==
null
||
!
shouldUpRecreateTask
(
intent
)
&&
!
isTaskRoot
)
finish
()
else
TaskStackBuilder
.
create
(
this
).
addNextIntentWithParentStack
(
intent
).
startActivities
()
else
finish
()
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
...
...
mobile/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
View file @
7e9b937b
...
...
@@ -36,60 +36,57 @@ object LocalDnsService {
val
data
=
data
val
profile
=
data
.
profile
!!
fun
makeDns
(
name
:
String
,
address
:
String
,
timeout
:
Int
,
edns
:
Boolean
=
true
):
JSONObject
{
val
dns
=
JSONObject
()
.
put
(
"Name"
,
name
)
.
put
(
"Address"
,
when
(
address
.
parseNumericAddress
())
{
fun
makeDns
(
name
:
String
,
address
:
String
,
timeout
:
Int
,
edns
:
Boolean
=
true
)
=
JSONObject
().
apply
{
put
(
"Name"
,
name
)
put
(
"Address"
,
when
(
address
.
parseNumericAddress
())
{
is
Inet6Address
->
"[$address]"
else
->
address
})
.
put
(
"Timeout"
,
timeout
)
.
put
(
"EDNSClientSubnet"
,
JSONObject
().
put
(
"Policy"
,
"disable"
))
if
(
edns
)
dns
.
put
(
"Protocol"
,
"tcp"
)
.
put
(
"Socks5Address"
,
"127.0.0.1:"
+
DataStore
.
portProxy
)
else
dns
.
put
(
"Protocol"
,
"udp"
)
return
dns
put
(
"Timeout"
,
timeout
)
put
(
"EDNSClientSubnet"
,
JSONObject
().
put
(
"Policy"
,
"disable"
))
put
(
"Protocol"
,
if
(
edns
)
{
put
(
"Socks5Address"
,
"127.0.0.1:"
+
DataStore
.
portProxy
)
"tcp"
}
else
"udp"
)
}
fun
buildOvertureConfig
(
file
:
String
)
:
String
{
val
config
=
JSONObject
()
.
put
(
"BindAddress"
,
"127.0.0.1:"
+
DataStore
.
portLocalDns
)
.
put
(
"RedirectIPv6Record"
,
true
)
.
put
(
"DomainBase64Decode"
,
false
)
.
put
(
"HostsFile"
,
"hosts"
)
.
put
(
"MinimumTTL"
,
120
)
.
put
(
"CacheSize"
,
4096
)
fun
buildOvertureConfig
(
file
:
String
)
=
file
.
also
{
File
(
app
.
deviceStorage
.
filesDir
,
it
).
writeText
(
JSONObject
().
run
{
put
(
"BindAddress"
,
"127.0.0.1:"
+
DataStore
.
portLocalDns
)
put
(
"RedirectIPv6Record"
,
true
)
put
(
"DomainBase64Decode"
,
false
)
put
(
"HostsFile"
,
"hosts"
)
put
(
"MinimumTTL"
,
120
)
put
(
"CacheSize"
,
4096
)
val
remoteDns
=
JSONArray
(
profile
.
remoteDns
.
split
(
","
)
.
mapIndexed
{
i
,
dns
->
makeDns
(
"UserDef-$i"
,
dns
.
trim
()
+
":53"
,
12
)
})
val
localDns
=
JSONArray
(
arrayOf
(
makeDns
(
"Primary-1"
,
"208.67.222.222:443"
,
9
,
false
),
makeDns
(
"Primary-2"
,
"119.29.29.29:53"
,
9
,
false
),
makeDns
(
"Primary-3"
,
"114.114.114.114:53"
,
9
,
false
)
))
makeDns
(
"Primary-3"
,
"114.114.114.114:53"
,
9
,
false
)))
when
(
profile
.
route
)
{
Acl
.
BYPASS_CHN
,
Acl
.
BYPASS_LAN_CHN
,
Acl
.
GFWLIST
,
Acl
.
CUSTOM_RULES
->
config
.
put
(
"PrimaryDNS"
,
localDns
)
.
put
(
"AlternativeDNS"
,
remoteDns
)
.
put
(
"IPNetworkFile"
,
"china_ip_list.txt"
)
Acl
.
CHINALIST
->
config
.
put
(
"PrimaryDNS"
,
localDns
)
.
put
(
"AlternativeDNS"
,
remoteDns
)
else
->
config
.
put
(
"PrimaryDNS"
,
remoteDns
)
Acl
.
BYPASS_CHN
,
Acl
.
BYPASS_LAN_CHN
,
Acl
.
GFWLIST
,
Acl
.
CUSTOM_RULES
->
{
put
(
"PrimaryDNS"
,
localDns
)
put
(
"AlternativeDNS"
,
remoteDns
)
put
(
"IPNetworkFile"
,
"china_ip_list.txt"
)
}
Acl
.
CHINALIST
->
{
put
(
"PrimaryDNS"
,
localDns
)
put
(
"AlternativeDNS"
,
remoteDns
)
}
else
->
{
put
(
"PrimaryDNS"
,
remoteDns
)
// no need to setup AlternativeDNS in Acl.ALL/BYPASS_LAN mode
.
put
(
"OnlyPrimaryDNS"
,
true
)
put
(
"OnlyPrimaryDNS"
,
true
)
}
}
File
(
app
.
deviceStorage
.
filesDir
,
file
).
writeText
(
config
.
toString
()
)
return
file
toString
(
)
})
}
if
(!
profile
.
udpdns
)
data
.
processes
.
start
(
buildAdditionalArguments
(
arrayListOf
(
File
(
app
.
applicationInfo
.
nativeLibraryDir
,
Executable
.
OVERTURE
).
absolutePath
,
"-c"
,
buildOvertureConfig
(
"overture.conf"
)
)))
"-c"
,
buildOvertureConfig
(
"overture.conf"
))))
}
}
}
mobile/src/main/java/com/github/shadowsocks/bg/ProxyService.kt
View file @
7e9b937b
...
...
@@ -22,7 +22,6 @@ package com.github.shadowsocks.bg
import
android.app.Service
import
android.content.Intent
import
android.os.IBinder
/**
* Shadowsocks service at its minimum.
...
...
@@ -36,7 +35,7 @@ class ProxyService : Service(), BaseService.Interface {
override
fun
createNotification
(
profileName
:
String
):
ServiceNotification
=
ServiceNotification
(
this
,
profileName
,
"service-proxy"
,
true
)
override
fun
onBind
(
intent
:
Intent
)
:
IBinder
?
=
super
.
onBind
(
intent
)
override
fun
onBind
(
intent
:
Intent
)
=
super
.
onBind
(
intent
)
override
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
=
super
<
BaseService
.
Interface
>.
onStartCommand
(
intent
,
flags
,
startId
)
}
mobile/src/main/java/com/github/shadowsocks/bg/ServiceNotification.kt
View file @
7e9b937b
...
...
@@ -91,7 +91,7 @@ class ServiceNotification(private val service: BaseService.Interface, profileNam
service
.
registerReceiver
(
lockReceiver
,
screenFilter
)
}
private
fun
update
(
action
:
String
,
forceShow
:
Boolean
=
false
)
{
private
fun
update
(
action
:
String
?
,
forceShow
:
Boolean
=
false
)
{
if
(
forceShow
||
service
.
data
.
state
==
BaseService
.
CONNECTED
)
when
(
action
)
{
Intent
.
ACTION_SCREEN_OFF
->
{
setVisible
(
false
,
forceShow
)
...
...
mobile/src/main/java/com/github/shadowsocks/bg/TransproxyService.kt
View file @
7e9b937b
...
...
@@ -22,7 +22,6 @@ package com.github.shadowsocks.bg
import
android.app.Service
import
android.content.Intent
import
android.os.IBinder
import
com.github.shadowsocks.App.Companion.app
import
com.github.shadowsocks.preference.DataStore
import
java.io.File
...
...
@@ -36,7 +35,7 @@ class TransproxyService : Service(), LocalDnsService.Interface {
override
fun
createNotification
(
profileName
:
String
):
ServiceNotification
=
ServiceNotification
(
this
,
profileName
,
"service-transproxy"
,
true
)
override
fun
onBind
(
intent
:
Intent
)
:
IBinder
?
=
super
.
onBind
(
intent
)
override
fun
onBind
(
intent
:
Intent
)
=
super
.
onBind
(
intent
)
override
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
=
super
<
LocalDnsService
.
Interface
>.
onStartCommand
(
intent
,
flags
,
startId
)
...
...
mobile/src/main/java/com/github/shadowsocks/bg/VpnService.kt
View file @
7e9b937b
...
...
@@ -26,7 +26,6 @@ import android.content.Intent
import
android.content.pm.PackageManager
import
android.net.*
import
android.os.Build
import
android.os.IBinder
import
android.os.ParcelFileDescriptor
import
androidx.core.content.getSystemService
import
com.github.shadowsocks.App.Companion.app
...
...
@@ -127,7 +126,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
}
private
var
listeningForDefaultNetwork
=
false
override
fun
onBind
(
intent
:
Intent
)
:
IBinder
?
=
when
(
intent
.
action
)
{
override
fun
onBind
(
intent
:
Intent
)
=
when
(
intent
.
action
)
{
SERVICE_INTERFACE
->
super
<
BaseVpnService
>.
onBind
(
intent
)
else
->
super
<
LocalDnsService
.
Interface
>.
onBind
(
intent
)
}
...
...
mobile/src/main/java/com/github/shadowsocks/plugin/PluginConfiguration.kt
View file @
7e9b937b
...
...
@@ -38,9 +38,9 @@ class PluginConfiguration(val pluginsOptions: Map<String, PluginOptions>, val se
while
(
iterator
.
hasNext
())
{
val
option
=
iterator
.
next
()
when
{
option
==
"--nocomp"
->
opt
.
put
(
"nocomp"
,
null
)
option
.
startsWith
(
"--"
)
->
opt
.
put
(
option
.
substring
(
2
),
iterator
.
next
()
)
else
->
throw
IllegalArgumentException
(
"Unknown kcptun parameter:
"
+
option
)
option
==
"--nocomp"
->
opt
[
"nocomp"
]
=
null
option
.
startsWith
(
"--"
)
->
opt
[
option
.
substring
(
2
)]
=
iterator
.
next
(
)
else
->
throw
IllegalArgumentException
(
"Unknown kcptun parameter:
$option"
)
}
}
}
catch
(
exc
:
Exception
)
{
...
...
mobile/src/main/java/com/github/shadowsocks/plugin/PluginManager.kt
View file @
7e9b937b
...
...
@@ -152,7 +152,7 @@ object PluginManager {
private
fun
initNativeFast
(
cr
:
ContentResolver
,
options
:
PluginOptions
,
uri
:
Uri
):
String
{
val
result
=
cr
.
call
(
uri
,
PluginContract
.
METHOD_GET_EXECUTABLE
,
null
,
bundleOf
(
Pair
(
PluginContract
.
EXTRA_OPTIONS
,
options
.
id
)))
.
getString
(
PluginContract
.
EXTRA_ENTRY
)
bundleOf
(
Pair
(
PluginContract
.
EXTRA_OPTIONS
,
options
.
id
)))
!!
.
getString
(
PluginContract
.
EXTRA_ENTRY
)
!!
check
(
File
(
result
).
canExecute
())
return
result
}
...
...
@@ -173,7 +173,7 @@ object PluginManager {
val
path
=
cursor
.
getString
(
0
)
val
file
=
File
(
pluginDir
,
path
)
check
(
file
.
absolutePath
.
startsWith
(
pluginDirPath
))
cr
.
openInputStream
(
uri
.
buildUpon
().
path
(
path
).
build
()).
use
{
inStream
->
cr
.
openInputStream
(
uri
.
buildUpon
().
path
(
path
).
build
())
!!
.
use
{
inStream
->
file
.
outputStream
().
use
{
outStream
->
inStream
.
copyTo
(
outStream
)
}
}
list
+=
Commandline
.
toString
(
arrayOf
(
"chmod"
,
cursor
.
getString
(
1
),
file
.
absolutePath
))
...
...
mobile/src/main/java/com/github/shadowsocks/preference/PluginConfigurationDialogFragment.kt
View file @
7e9b937b
...
...
@@ -38,7 +38,7 @@ class PluginConfigurationDialogFragment : EditTextPreferenceDialogFragmentCompat
override
fun
onPrepareDialogBuilder
(
builder
:
AlertDialog
.
Builder
)
{
super
.
onPrepareDialogBuilder
(
builder
)
val
intent
=
PluginManager
.
buildIntent
(
arguments
!!
.
getString
(
PLUGIN_ID_FRAGMENT_TAG
)
,
val
intent
=
PluginManager
.
buildIntent
(
arguments
?.
getString
(
PLUGIN_ID_FRAGMENT_TAG
)
!!
,
PluginContract
.
ACTION_HELP
)
val
activity
=
requireActivity
()
if
(
intent
.
resolveActivity
(
activity
.
packageManager
)
!=
null
)
builder
.
setNeutralButton
(
"?"
)
{
_
,
_
->
...
...
mobile/src/main/java/com/github/shadowsocks/utils/Commandline.kt
View file @
7e9b937b
...
...
@@ -165,9 +165,9 @@ object Commandline {
result
.
add
(
current
.
toString
())
}
if
(
state
==
inQuote
||
state
==
inDoubleQuote
)
{
throw
IllegalArgumentException
(
"unbalanced quotes in
"
+
toProcess
)
throw
IllegalArgumentException
(
"unbalanced quotes in
$toProcess"
)
}
if
(
lastTokenIsSlash
)
throw
IllegalArgumentException
(
"escape character following nothing in
"
+
toProcess
)
if
(
lastTokenIsSlash
)
throw
IllegalArgumentException
(
"escape character following nothing in
$toProcess"
)
return
result
.
toTypedArray
()
}
}
mobile/src/main/java/com/github/shadowsocks/utils/TcpFastOpen.kt
View file @
7e9b937b
...
...
@@ -28,7 +28,7 @@ object TcpFastOpen {
* Is kernel version >= 3.7.1.
*/
val
supported
by
lazy
{
val
match
=
"""^(\d+)\.(\d+)\.(\d+)"""
.
toRegex
().
find
(
System
.
getProperty
(
"os.version"
))
val
match
=
"""^(\d+)\.(\d+)\.(\d+)"""
.
toRegex
().
find
(
System
.
getProperty
(
"os.version"
)
?:
""
)
if
(
match
==
null
)
false
else
when
(
match
.
groupValues
[
1
].
toInt
())
{
in
Int
.
MIN_VALUE
..
2
->
false
3
->
when
(
match
.
groupValues
[
2
].
toInt
())
{
...
...
mobile/src/main/java/com/github/shadowsocks/utils/Utils.kt
View file @
7e9b937b
...
...
@@ -62,7 +62,7 @@ fun Resources.Theme.resolveResourceId(@AttrRes resId: Int): Int {
return
typedValue
.
resourceId
}
val
Intent
.
datas
get
()
=
listOfNotNull
(
data
)
+
(
clipData
?.
asIterable
()
?.
map
{
it
.
uri
}
?.
filterNotNull
()
?:
emptyList
())
val
Intent
.
datas
get
()
=
listOfNotNull
(
data
)
+
(
clipData
?.
asIterable
()
?.
map
NotNull
{
it
.
uri
}
?:
emptyList
())
fun
printLog
(
t
:
Throwable
)
{
Crashlytics
.
logException
(
t
)
...
...
plugin/src/main/java/com/github/shadowsocks/plugin/NativePluginProvider.kt
View file @
7e9b937b
...
...
@@ -84,7 +84,7 @@ abstract class NativePluginProvider : ContentProvider() {
return
openFile
(
uri
)
}
override
fun
call
(
method
:
String
?
,
arg
:
String
?,
extras
:
Bundle
?):
Bundle
?
=
when
(
method
)
{
override
fun
call
(
method
:
String
,
arg
:
String
?,
extras
:
Bundle
?):
Bundle
?
=
when
(
method
)
{
PluginContract
.
METHOD_GET_EXECUTABLE
->
bundleOf
(
Pair
(
PluginContract
.
EXTRA_ENTRY
,
getExecutable
()))
else
->
super
.
call
(
method
,
arg
,
extras
)
}
...
...
plugin/src/main/java/com/github/shadowsocks/plugin/PluginOptions.kt
View file @
7e9b937b
...
...
@@ -38,7 +38,7 @@ class PluginOptions : HashMap<String, String?> {
@Suppress
(
"NAME_SHADOWING"
)
var
parseId
=
parseId
if
(
options
.
isNullOrEmpty
())
return
val
tokenizer
=
StringTokenizer
(
options
+
';'
,
"\\=;"
,
true
)
val
tokenizer
=
StringTokenizer
(
"$options;"
,
"\\=;"
,
true
)
val
current
=
StringBuilder
()
var
key
:
String
?
=
null
while
(
tokenizer
.
hasMoreTokens
())
{
...
...
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