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
19083dc0
Commit
19083dc0
authored
Jan 15, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bindSocketToNetwork optimized out in API 22
parent
0e8888d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
core/src/main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
.../main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
+22
-1
No files found.
core/src/main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
View file @
19083dc0
...
...
@@ -30,6 +30,7 @@ import android.os.Looper
import
android.system.ErrnoException
import
android.system.Os
import
android.system.OsConstants
import
com.crashlytics.android.Crashlytics
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.utils.closeQuietly
import
com.github.shadowsocks.utils.int
...
...
@@ -52,7 +53,8 @@ sealed class DnsResolverCompat {
when
(
Build
.
VERSION
.
SDK_INT
)
{
in
29
..
Int
.
MAX_VALUE
->
DnsResolverCompat29
in
23
until
29
->
DnsResolverCompat23
in
21
until
23
->
DnsResolverCompat21
()
22
->
DnsResolverCompat22
21
->
DnsResolverCompat21
()
else
->
error
(
"Unsupported API level"
)
}
}
...
...
@@ -138,6 +140,25 @@ sealed class DnsResolverCompat {
GlobalScope
.
async
(
unboundedIO
)
{
InetAddress
.
getAllByName
(
host
)
}.
await
()
}
@TargetApi
(
22
)
private
object
DnsResolverCompat22
:
DnsResolverCompat21
()
{
private
val
bindSocketFd
by
lazy
{
Network
::
class
.
java
.
getDeclaredMethod
(
"bindSocketFd"
).
apply
{
isAccessible
=
true
}
}
override
fun
bindSocket
(
network
:
Network
,
socket
:
FileDescriptor
)
{
try
{
bindSocketFd
.
invoke
(
network
,
socket
)
}
catch
(
e1
:
ReflectiveOperationException
)
{
try
{
super
.
bindSocket
(
network
,
socket
)
Crashlytics
.
logException
(
e1
)
}
catch
(
e2
:
ReflectiveOperationException
)
{
throw
e1
.
apply
{
addSuppressed
(
e2
)
}
}
}
}
}
@TargetApi
(
23
)
private
object
DnsResolverCompat23
:
DnsResolverCompat21
()
{
override
fun
bindSocket
(
network
:
Network
,
socket
:
FileDescriptor
)
=
network
.
bindSocket
(
socket
)
...
...
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