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
b78c10e8
Commit
b78c10e8
authored
Jan 19, 2017
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix content provider
parent
91be4146
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
13 deletions
+36
-13
mobile/src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala
.../scala/com/github/shadowsocks/ProfileConfigFragment.scala
+1
-1
mobile/src/main/scala/com/github/shadowsocks/plugin/NativePlugin.scala
...in/scala/com/github/shadowsocks/plugin/NativePlugin.scala
+7
-7
mobile/src/main/scala/com/github/shadowsocks/plugin/PluginManager.scala
...n/scala/com/github/shadowsocks/plugin/PluginManager.scala
+11
-4
mobile/src/main/scala/com/github/shadowsocks/plugin/ProviderPlugin.scala
.../scala/com/github/shadowsocks/plugin/ProviderPlugin.scala
+16
-0
mobile/src/main/scala/com/github/shadowsocks/preference/PluginConfigurationDialogFragment.scala
...wsocks/preference/PluginConfigurationDialogFragment.scala
+1
-1
No files found.
mobile/src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala
View file @
b78c10e8
...
...
@@ -93,7 +93,7 @@ class ProfileConfigFragment extends PreferenceFragment with OnMenuItemClickListe
false
})
initPlugins
()
app
.
listenForPackageChanges
(
getView
.
post
(
initPlugins
))
app
.
listenForPackageChanges
(
if
(
getView
!=
null
)
getView
.
post
(
initPlugins
))
app
.
settings
.
registerOnSharedPreferenceChangeListener
(
this
)
}
...
...
mobile/src/main/scala/com/github/shadowsocks/plugin/NativePlugin.scala
View file @
b78c10e8
package
com.github.shadowsocks.plugin
import
android.content.pm.
{
PackageManager
,
Resolve
Info
}
import
android.content.pm.
{
PackageManager
,
Provider
Info
}
/**
* @author Mygod
*/
class
NativePlugin
(
resolveInfo
:
Resolve
Info
,
packageManager
:
PackageManager
)
extends
ResolvedPlugin
(
resolve
Info
,
packageManager
)
{
assert
(
resolveInfo
.
providerInfo
!=
null
)
assert
(
resolveInfo
.
providerInfo
.
authority
.
startsWith
(
PluginInterface
.
AUTHORITY_BASE
))
class
NativePlugin
(
providerInfo
:
Provider
Info
,
packageManager
:
PackageManager
)
extends
ResolvedPlugin
(
provider
Info
,
packageManager
)
{
assert
(
providerInfo
!=
null
)
assert
(
providerInfo
.
authority
.
startsWith
(
PluginInterface
.
AUTHORITY_BASE
))
override
final
lazy
val
id
:
String
=
resolveInfo
.
providerInfo
.
authority
.
substring
(
PluginInterface
.
AUTHORITY_BASE
.
length
)
providerInfo
.
authority
.
substring
(
PluginInterface
.
AUTHORITY_BASE
.
length
)
override
final
lazy
val
defaultConfig
:
String
=
resolveInfo
.
providerInfo
.
metaData
.
getString
(
PluginInterface
.
METADATA_KEY_DEFAULT_CONFIG
)
providerInfo
.
metaData
.
getString
(
PluginInterface
.
METADATA_KEY_DEFAULT_CONFIG
)
}
mobile/src/main/scala/com/github/shadowsocks/plugin/PluginManager.scala
View file @
b78c10e8
...
...
@@ -5,6 +5,7 @@ import java.io.{File, FileNotFoundException, FileOutputStream, IOException}
import
android.content.pm.PackageManager
import
android.content.
{
BroadcastReceiver
,
ContentResolver
,
Intent
}
import
android.net.Uri
import
android.text.TextUtils
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.utils.CloseUtils.autoClose
import
com.github.shadowsocks.utils.IOUtils
...
...
@@ -22,8 +23,10 @@ object PluginManager {
synchronized
(
if
(
cachedPlugins
==
null
)
{
val
pm
=
app
.
getPackageManager
cachedPlugins
=
(
NoPlugin
+:
pm
.
queryIntentContentProviders
(
new
Intent
().
addCategory
(
PluginInterface
.
CATEGORY_NATIVE_PLUGIN
),
PackageManager
.
GET_META_DATA
).
asScala
.
map
(
new
NativePlugin
(
_
,
pm
))).
toArray
pm
.
queryContentProviders
(
null
,
0
,
PackageManager
.
GET_META_DATA
).
asScala
.
filter
(
_
!=
null
)
.
filter
(
_
.
authority
.
startsWith
(
PluginInterface
.
AUTHORITY_BASE
))
.
map
(
new
NativePlugin
(
_
,
pm
))).
toArray
})
cachedPlugins
}
...
...
@@ -31,7 +34,7 @@ object PluginManager {
// the following parts are meant to be used by :bg
@throws
[
Throwable
]
def
initPlugin
(
id
:
String
)
:
String
=
{
if
(
id
.
isEmpty
)
return
null
if
(
TextUtils
.
isEmpty
(
id
)
)
return
null
var
throwable
:
Throwable
=
null
try
initNativePlugin
(
id
)
match
{
...
...
@@ -62,7 +65,11 @@ object PluginManager {
var
initialized
=
false
val
pluginDir
=
new
File
(
app
.
getFilesDir
,
"plugin"
)
if
(
cursor
.
moveToFirst
())
{
IOUtils
.
deleteRecursively
(
pluginDir
)
try
{
IOUtils
.
deleteRecursively
(
pluginDir
)
}
catch
{
case
ex
:
IOException
=>
// Ignore
}
if
(!
pluginDir
.
mkdirs
())
throw
new
FileNotFoundException
(
"Unable to create plugin directory"
)
val
pluginDirPath
=
pluginDir
.
getAbsolutePath
+
'/'
do
{
...
...
mobile/src/main/scala/com/github/shadowsocks/plugin/
Resolved
Plugin.scala
→
mobile/src/main/scala/com/github/shadowsocks/plugin/
Provider
Plugin.scala
View file @
b78c10e8
package
com.github.shadowsocks.plugin
import
android.content.pm.
{
PackageManager
,
Resolve
Info
}
import
android.content.pm.
{
PackageManager
,
Provider
Info
}
import
android.graphics.drawable.Drawable
import
com.github.shadowsocks.ShadowsocksApplication.app
...
...
@@ -9,8 +9,8 @@ import com.github.shadowsocks.ShadowsocksApplication.app
*
* @author Mygod
*/
abstract
class
ResolvedPlugin
(
resolveInfo
:
Resolve
Info
,
packageManager
:
PackageManager
=
app
.
getPackageManager
)
abstract
class
ResolvedPlugin
(
providerInfo
:
Provider
Info
,
packageManager
:
PackageManager
=
app
.
getPackageManager
)
extends
Plugin
{
override
final
lazy
val
label
:
CharSequence
=
resolveInfo
.
loadLabel
(
packageManager
)
override
final
lazy
val
icon
:
Drawable
=
resolveInfo
.
loadIcon
(
packageManager
)
override
final
lazy
val
label
:
CharSequence
=
packageManager
.
getApplicationLabel
(
providerInfo
.
applicationInfo
)
override
final
lazy
val
icon
:
Drawable
=
packageManager
.
getApplicationIcon
(
providerInfo
.
applicationInfo
)
}
mobile/src/main/scala/com/github/shadowsocks/preference/PluginConfigurationDialogFragment.scala
View file @
b78c10e8
...
...
@@ -39,7 +39,7 @@ class PluginConfigurationDialogFragment extends EditTextPreferenceDialogFragment
override
def
onPrepareDialogBuilder
(
builder
:
AlertDialog.Builder
)
{
super
.
onPrepareDialogBuilder
(
builder
)
val
intent
=
new
Intent
(
PluginInterface
.
ACTION_HELP
(
getArguments
.
getString
(
PLUGIN_ID_FRAGMENT_TAG
)))
if
(
intent
.
resolveActivity
(
get
Context
.
getPackageManager
)
!=
null
)
builder
.
setNeutralButton
(
"?"
,
((
_
,
_
)
=>
if
(
intent
.
resolveActivity
(
get
Activity
.
getPackageManager
)
!=
null
)
builder
.
setNeutralButton
(
"?"
,
((
_
,
_
)
=>
startActivityForResult
(
intent
.
putExtra
(
PluginInterface
.
EXTRA_OPTIONS
,
editText
.
getText
.
toString
),
REQUEST_CODE_HELP
))
:
DialogInterface.OnClickListener
)
}
...
...
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