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
49218635
Commit
49218635
authored
Jan 19, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use coreLibraryDesugaring
parent
11a0ecd9
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
25 additions
and
39 deletions
+25
-39
build.gradle
build.gradle
+1
-1
core/build.gradle
core/build.gradle
+3
-1
core/src/main/java/com/github/shadowsocks/net/HostsFile.kt
core/src/main/java/com/github/shadowsocks/net/HostsFile.kt
+1
-2
core/src/main/java/com/github/shadowsocks/subscription/SubscriptionService.kt
...om/github/shadowsocks/subscription/SubscriptionService.kt
+6
-3
core/src/main/java/com/github/shadowsocks/utils/Utils.kt
core/src/main/java/com/github/shadowsocks/utils/Utils.kt
+0
-13
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.jar
+0
-0
gradle/wrapper/gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
+1
-1
gradlew
gradlew
+12
-17
plugin/build.gradle
plugin/build.gradle
+1
-1
No files found.
build.gradle
View file @
49218635
...
...
@@ -27,7 +27,7 @@ buildscript {
}
dependencies
{
classpath
'com.android.tools.build:gradle:
3.5.3
'
classpath
'com.android.tools.build:gradle:
4.0.0-alpha08
'
classpath
'com.github.ben-manes:gradle-versions-plugin:0.27.0'
classpath
'com.google.gms:google-services:4.3.3'
classpath
'com.vanniktech:gradle-maven-publish-plugin:0.8.0'
...
...
core/build.gradle
View file @
49218635
...
...
@@ -27,6 +27,7 @@ android {
}
compileOptions
{
coreLibraryDesugaringEnabled
true
sourceCompatibility
javaVersion
targetCompatibility
javaVersion
}
...
...
@@ -63,12 +64,13 @@ dependencies {
api
"androidx.work:work-gcm:$workVersion"
api
'com.crashlytics.sdk.android:crashlytics:2.10.1'
api
'com.google.code.gson:gson:2.8.6'
api
'com.google.firebase:firebase-analytics:17.2.
1
'
api
'com.google.firebase:firebase-analytics:17.2.
2
'
api
'com.google.firebase:firebase-config:19.1.0'
api
'dnsjava:dnsjava:2.1.9'
api
"org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
api
"org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion"
api
'org.connectbot.jsocks:jsocks:1.0.0'
coreLibraryDesugaring
'com.android.tools:desugar_jdk_libs:1.0.4'
kapt
"androidx.room:room-compiler:$roomVersion"
testImplementation
"junit:junit:$junitVersion"
androidTestImplementation
"androidx.room:room-testing:$roomVersion"
...
...
core/src/main/java/com/github/shadowsocks/net/HostsFile.kt
View file @
49218635
...
...
@@ -20,7 +20,6 @@
package
com.github.shadowsocks.net
import
com.github.shadowsocks.utils.computeIfAbsentCompat
import
com.github.shadowsocks.utils.parseNumericAddress
import
java.net.Inet4Address
import
java.net.Inet6Address
...
...
@@ -32,7 +31,7 @@ class HostsFile(input: String = "") {
for
(
line
in
input
.
lineSequence
())
{
val
entries
=
line
.
substringBefore
(
'#'
).
splitToSequence
(
' '
,
'\t'
).
filter
{
it
.
isNotEmpty
()
}
val
address
=
entries
.
firstOrNull
()
?.
parseNumericAddress
()
?:
continue
for
(
hostname
in
entries
.
drop
(
1
))
map
.
computeIfAbsent
Compat
(
hostname
)
{
LinkedHashSet
(
1
)
}.
add
(
address
)
for
(
hostname
in
entries
.
drop
(
1
))
map
.
computeIfAbsent
(
hostname
)
{
LinkedHashSet
(
1
)
}.
add
(
address
)
}
}
...
...
core/src/main/java/com/github/shadowsocks/subscription/SubscriptionService.kt
View file @
49218635
...
...
@@ -41,7 +41,10 @@ import com.github.shadowsocks.core.R
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.database.ProfileManager
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.*
import
com.github.shadowsocks.utils.Action
import
com.github.shadowsocks.utils.asIterable
import
com.github.shadowsocks.utils.readableMessage
import
com.github.shadowsocks.utils.useCancellable
import
com.google.gson.JsonStreamParser
import
kotlinx.coroutines.*
import
java.io.File
...
...
@@ -165,7 +168,7 @@ class SubscriptionService : Service() {
profiles
?.
forEach
{
profile
->
// preprocessing phase
if
(
currentId
==
profile
.
id
)
feature
=
profile
if
(
profile
.
subscription
==
Profile
.
SubscriptionStatus
.
UserConfigured
)
return
@forEach
if
(
subscriptions
.
putIfAbsent
Compat
(
profile
.
name
to
profile
.
formattedAddress
,
profile
)
!=
null
)
{
if
(
subscriptions
.
putIfAbsent
(
profile
.
name
to
profile
.
formattedAddress
,
profile
)
!=
null
)
{
ProfileManager
.
delProfile
(
profile
.
id
)
if
(
currentId
==
profile
.
id
)
DataStore
.
profileId
=
0
}
else
if
(
profile
.
subscription
==
Profile
.
SubscriptionStatus
.
Active
)
{
...
...
@@ -176,7 +179,7 @@ class SubscriptionService : Service() {
for
(
json
in
jsons
.
asIterable
())
try
{
Profile
.
parseJson
(
JsonStreamParser
(
json
.
bufferedReader
()).
asSequence
().
single
(),
feature
)
{
subscriptions
.
compute
Compat
(
it
.
name
to
it
.
formattedAddress
)
{
_
,
oldProfile
->
subscriptions
.
compute
(
it
.
name
to
it
.
formattedAddress
)
{
_
,
oldProfile
->
when
(
oldProfile
?.
subscription
)
{
Profile
.
SubscriptionStatus
.
Active
->
{
Log
.
w
(
"SubscriptionService"
,
"Duplicate profiles detected. Please use different profile "
+
...
...
core/src/main/java/com/github/shadowsocks/utils/Utils.kt
View file @
49218635
...
...
@@ -85,19 +85,6 @@ fun String?.parseNumericAddress(): InetAddress? = Os.inet_pton(OsConstants.AF_IN
if
(
Build
.
VERSION
.
SDK_INT
>=
29
)
it
else
parseNumericAddress
.
invoke
(
null
,
this
)
as
InetAddress
}
fun
<
K
,
V
>
MutableMap
<
K
,
V
>.
computeCompat
(
key
:
K
,
remappingFunction
:
(
K
,
V
?)
->
V
?)
=
if
(
Build
.
VERSION
.
SDK_INT
<
24
)
{
val
oldValue
=
get
(
key
)
remappingFunction
(
key
,
oldValue
).
also
{
newValue
->
if
(
newValue
!=
null
)
put
(
key
,
newValue
)
else
if
(
oldValue
!=
null
||
containsKey
(
key
))
remove
(
key
)
}
}
else
compute
(
key
)
{
k
,
oldValue
->
remappingFunction
(
k
,
oldValue
)
}
fun
<
K
,
V
>
MutableMap
<
K
,
V
>.
computeIfAbsentCompat
(
key
:
K
,
value
:
()
->
V
)
=
if
(
Build
.
VERSION
.
SDK_INT
<
24
)
{
this
[
key
]
?:
value
().
also
{
put
(
key
,
it
)
}
}
else
computeIfAbsent
(
key
)
{
value
()
}
fun
<
K
,
V
>
MutableMap
<
K
,
V
>.
putIfAbsentCompat
(
key
:
K
,
value
:
V
)
=
if
(
Build
.
VERSION
.
SDK_INT
<
24
)
{
this
[
key
]
?:
put
(
key
,
value
)
}
else
putIfAbsent
(
key
,
value
)
suspend
fun
<
T
>
HttpURLConnection
.
useCancellable
(
block
:
suspend
HttpURLConnection
.()
->
T
):
T
{
return
suspendCancellableCoroutine
{
cont
->
cont
.
invokeOnCancellation
{
...
...
gradle/wrapper/gradle-wrapper.jar
View file @
49218635
No preview for this file type
gradle/wrapper/gradle-wrapper.properties
View file @
49218635
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-6.
0.
1-all.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-6.1-all.zip
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
gradlew
View file @
49218635
...
...
@@ -154,19 +154,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval
`
echo
args
$i
`
=
"
\"
$arg
\"
"
fi
i
=
$((
i+1
))
i
=
`
expr
$i
+ 1
`
done
case
$i
in
(
0
)
set
--
;;
(
1
)
set
--
"
$args0
"
;;
(
2
)
set
--
"
$args0
"
"
$args1
"
;;
(
3
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
;;
(
4
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
;;
(
5
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
;;
(
6
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
;;
(
7
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
"
$args6
"
;;
(
8
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
"
$args6
"
"
$args7
"
;;
(
9
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
"
$args6
"
"
$args7
"
"
$args8
"
;;
0
)
set
--
;;
1
)
set
--
"
$args0
"
;;
2
)
set
--
"
$args0
"
"
$args1
"
;;
3
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
;;
4
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
;;
5
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
;;
6
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
;;
7
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
"
$args6
"
;;
8
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
"
$args6
"
"
$args7
"
;;
9
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
"
$args6
"
"
$args7
"
"
$args8
"
;;
esac
fi
...
...
@@ -175,14 +175,9 @@ save () {
for
i
do
printf
%s
\\
n
"
$i
"
|
sed
"s/'/'
\\\\
''/g;1s/^/'/;
\$
s/
\$
/'
\\\\
/"
;
done
echo
" "
}
APP_ARGS
=
$(
save
"
$@
"
)
APP_ARGS
=
`
save
"
$@
"
`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set
--
$DEFAULT_JVM_OPTS
$JAVA_OPTS
$GRADLE_OPTS
"
\"
-Dorg.gradle.appname=
$APP_BASE_NAME
\"
"
-classpath
"
\"
$CLASSPATH
\"
"
org.gradle.wrapper.GradleWrapperMain
"
$APP_ARGS
"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if
[
"
$(
uname
)
"
=
"Darwin"
]
&&
[
"
$HOME
"
=
"
$PWD
"
]
;
then
cd
"
$(
dirname
"
$0
"
)
"
fi
exec
"
$JAVACMD
"
"
$@
"
plugin/build.gradle
View file @
49218635
...
...
@@ -48,7 +48,7 @@ mavenPublish {
dependencies
{
api
'androidx.core:core-ktx:1.1.0'
api
'androidx.drawerlayout:drawerlayout:1.1.0-alpha03'
// https://android-developers.googleblog.com/2019/07/android-q-beta-5-update.html
api
'com.google.android.material:material:1.1.0-rc0
1
'
api
'com.google.android.material:material:1.1.0-rc0
2
'
api
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
testImplementation
"junit:junit:$junitVersion"
androidTestImplementation
"androidx.test:runner:$androidTestVersion"
...
...
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