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
52d0d7ed
Commit
52d0d7ed
authored
Oct 02, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add isV2 to PluginManager.InitResult
parent
6563e0ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
core/src/main/java/com/github/shadowsocks/plugin/PluginManager.kt
.../main/java/com/github/shadowsocks/plugin/PluginManager.kt
+13
-5
plugin/src/main/java/com/github/shadowsocks/plugin/PluginContract.kt
...main/java/com/github/shadowsocks/plugin/PluginContract.kt
+7
-0
No files found.
core/src/main/java/com/github/shadowsocks/plugin/PluginManager.kt
View file @
52d0d7ed
...
@@ -118,9 +118,15 @@ object PluginManager {
...
@@ -118,9 +118,15 @@ object PluginManager {
.
build
()
.
build
()
fun
buildIntent
(
id
:
String
,
action
:
String
):
Intent
=
Intent
(
action
,
buildUri
(
id
))
fun
buildIntent
(
id
:
String
,
action
:
String
):
Intent
=
Intent
(
action
,
buildUri
(
id
))
data class
InitResult
(
val
path
:
String
,
val
options
:
PluginOptions
,
val
isV2
:
Boolean
=
false
,
)
// the following parts are meant to be used by :bg
// the following parts are meant to be used by :bg
@Throws
(
Throwable
::
class
)
@Throws
(
Throwable
::
class
)
fun
init
(
configuration
:
PluginConfiguration
):
Pair
<
String
,
PluginOptions
>
?
{
fun
init
(
configuration
:
PluginConfiguration
):
InitResult
?
{
if
(
configuration
.
selected
.
isEmpty
())
return
null
if
(
configuration
.
selected
.
isEmpty
())
return
null
var
throwable
:
Throwable
?
=
null
var
throwable
:
Throwable
?
=
null
...
@@ -136,7 +142,7 @@ object PluginManager {
...
@@ -136,7 +142,7 @@ object PluginManager {
throw
throwable
?:
PluginNotFoundException
(
configuration
.
selected
)
throw
throwable
?:
PluginNotFoundException
(
configuration
.
selected
)
}
}
private
fun
initNative
(
configuration
:
PluginConfiguration
):
Pair
<
String
,
PluginOptions
>
?
{
private
fun
initNative
(
configuration
:
PluginConfiguration
):
InitResult
?
{
var
flags
=
PackageManager
.
GET_META_DATA
var
flags
=
PackageManager
.
GET_META_DATA
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
flags
=
flags
or
PackageManager
.
MATCH_DIRECT_BOOT_UNAWARE
or
PackageManager
.
MATCH_DIRECT_BOOT_AWARE
flags
=
flags
or
PackageManager
.
MATCH_DIRECT_BOOT_UNAWARE
or
PackageManager
.
MATCH_DIRECT_BOOT_AWARE
...
@@ -152,9 +158,11 @@ object PluginManager {
...
@@ -152,9 +158,11 @@ object PluginManager {
}
}
val
provider
=
providers
.
single
().
providerInfo
val
provider
=
providers
.
single
().
providerInfo
val
options
=
configuration
.
getOptions
{
provider
.
loadString
(
PluginContract
.
METADATA_KEY_DEFAULT_CONFIG
)
}
val
options
=
configuration
.
getOptions
{
provider
.
loadString
(
PluginContract
.
METADATA_KEY_DEFAULT_CONFIG
)
}
val
isV2
=
(
provider
.
applicationInfo
.
metaData
?.
getString
(
PluginContract
.
METADATA_KEY_VERSION
)
?.
substringBefore
(
'.'
)
?.
toIntOrNull
()
?:
0
)
>=
2
var
failure
:
Throwable
?
=
null
var
failure
:
Throwable
?
=
null
try
{
try
{
initNativeFaster
(
provider
)
?.
also
{
return
it
to
options
}
initNativeFaster
(
provider
)
?.
also
{
return
InitResult
(
it
,
options
,
isV2
)
}
}
catch
(
t
:
Throwable
)
{
}
catch
(
t
:
Throwable
)
{
Timber
.
w
(
"Initializing native plugin faster mode failed"
)
Timber
.
w
(
"Initializing native plugin faster mode failed"
)
failure
=
t
failure
=
t
...
@@ -165,7 +173,7 @@ object PluginManager {
...
@@ -165,7 +173,7 @@ object PluginManager {
authority
(
provider
.
authority
)
authority
(
provider
.
authority
)
}.
build
()
}.
build
()
try
{
try
{
return
initNativeFast
(
app
.
contentResolver
,
options
,
uri
)
?.
let
{
it
to
options
}
return
initNativeFast
(
app
.
contentResolver
,
options
,
uri
)
?.
let
{
InitResult
(
it
,
options
,
isV2
)
}
}
catch
(
t
:
Throwable
)
{
}
catch
(
t
:
Throwable
)
{
Timber
.
w
(
"Initializing native plugin fast mode failed"
)
Timber
.
w
(
"Initializing native plugin fast mode failed"
)
failure
?.
also
{
t
.
addSuppressed
(
it
)
}
failure
?.
also
{
t
.
addSuppressed
(
it
)
}
...
@@ -173,7 +181,7 @@ object PluginManager {
...
@@ -173,7 +181,7 @@ object PluginManager {
}
}
try
{
try
{
return
initNativeSlow
(
app
.
contentResolver
,
options
,
uri
)
?.
let
{
it
to
options
}
return
initNativeSlow
(
app
.
contentResolver
,
options
,
uri
)
?.
let
{
InitResult
(
it
,
options
,
isV2
)
}
}
catch
(
t
:
Throwable
)
{
}
catch
(
t
:
Throwable
)
{
failure
?.
also
{
t
.
addSuppressed
(
it
)
}
failure
?.
also
{
t
.
addSuppressed
(
it
)
}
throw
t
throw
t
...
...
plugin/src/main/java/com/github/shadowsocks/plugin/PluginContract.kt
View file @
52d0d7ed
...
@@ -72,6 +72,13 @@ object PluginContract {
...
@@ -72,6 +72,13 @@ object PluginContract {
</host_name> */
</host_name> */
const
val
EXTRA_HELP_MESSAGE
=
"com.github.shadowsocks.plugin.EXTRA_HELP_MESSAGE"
const
val
EXTRA_HELP_MESSAGE
=
"com.github.shadowsocks.plugin.EXTRA_HELP_MESSAGE"
/**
* The metadata key to retrieve plugin version. Required for plugin applications.
*
* Constant Value: "com.github.shadowsocks.plugin.version"
*/
const
val
METADATA_KEY_VERSION
=
"com.github.shadowsocks.plugin.version"
/**
/**
* The metadata key to retrieve plugin id. Required for plugins.
* The metadata key to retrieve plugin id. Required for plugins.
*
*
...
...
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