Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
c0216c06
Commit
c0216c06
authored
Nov 08, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get XMLs directly
parent
61de63a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
34 deletions
+7
-34
AndroidManifest.xml
shared/src/main/AndroidManifest.xml
+1
-3
FileProvider.java
shared/src/main/java/com/topjohnwu/magisk/FileProvider.java
+6
-31
No files found.
shared/src/main/AndroidManifest.xml
View file @
c0216c06
...
...
@@ -16,6 +16,7 @@
<activity
android:name=
"a.r"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar"
android:process=
":remote"
/>
<provider
...
...
@@ -23,9 +24,6 @@
android:authorities=
"${applicationId}.provider"
android:exported=
"false"
android:grantUriPermissions=
"true"
>
<meta-data
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:resource=
"@xml/file_paths"
/>
</provider>
</application>
</manifest>
shared/src/main/java/com/topjohnwu/magisk/FileProvider.java
View file @
c0216c06
...
...
@@ -3,7 +3,6 @@ package com.topjohnwu.magisk;
import
android.content.ContentProvider
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.content.pm.PackageManager
;
import
android.content.pm.ProviderInfo
;
import
android.content.res.XmlResourceParser
;
import
android.database.Cursor
;
...
...
@@ -17,6 +16,8 @@ import android.provider.OpenableColumns;
import
android.text.TextUtils
;
import
android.webkit.MimeTypeMap
;
import
com.topjohnwu.shared.R
;
import
org.xmlpull.v1.XmlPullParserException
;
import
java.io.File
;
...
...
@@ -35,9 +36,6 @@ public class FileProvider extends ContentProvider {
private
static
final
String
[]
COLUMNS
=
{
OpenableColumns
.
DISPLAY_NAME
,
OpenableColumns
.
SIZE
};
private
static
final
String
META_DATA_FILE_PROVIDER_PATHS
=
"android.support.FILE_PROVIDER_PATHS"
;
private
static
final
String
TAG_ROOT_PATH
=
"root-path"
;
private
static
final
String
TAG_FILES_PATH
=
"files-path"
;
private
static
final
String
TAG_CACHE_PATH
=
"cache-path"
;
...
...
@@ -56,13 +54,12 @@ public class FileProvider extends ContentProvider {
private
PathStrategy
mStrategy
;
public
static
ProviderCallHandler
callHandler
;
@Override
public
boolean
onCreate
()
{
return
true
;
}
@Override
public
void
attachInfo
(
Context
context
,
ProviderInfo
info
)
{
super
.
attachInfo
(
context
,
info
);
...
...
@@ -85,7 +82,6 @@ public class FileProvider extends ContentProvider {
return
strategy
.
getUriForFile
(
file
);
}
@Override
public
Cursor
query
(
Uri
uri
,
String
[]
projection
,
String
selection
,
String
[]
selectionArgs
,
...
...
@@ -118,7 +114,6 @@ public class FileProvider extends ContentProvider {
return
cursor
;
}
@Override
public
String
getType
(
Uri
uri
)
{
...
...
@@ -136,20 +131,17 @@ public class FileProvider extends ContentProvider {
return
"application/octet-stream"
;
}
@Override
public
Uri
insert
(
Uri
uri
,
ContentValues
values
)
{
throw
new
UnsupportedOperationException
(
"No external inserts"
);
}
@Override
public
int
update
(
Uri
uri
,
ContentValues
values
,
String
selection
,
String
[]
selectionArgs
)
{
throw
new
UnsupportedOperationException
(
"No external updates"
);
}
@Override
public
int
delete
(
Uri
uri
,
String
selection
,
String
[]
selectionArgs
)
{
...
...
@@ -158,7 +150,6 @@ public class FileProvider extends ContentProvider {
return
file
.
delete
()
?
1
:
0
;
}
@Override
public
Bundle
call
(
String
method
,
String
arg
,
Bundle
extras
)
{
if
(
callHandler
!=
null
)
...
...
@@ -166,7 +157,6 @@ public class FileProvider extends ContentProvider {
return
null
;
}
@Override
public
ParcelFileDescriptor
openFile
(
Uri
uri
,
String
mode
)
throws
FileNotFoundException
{
...
...
@@ -176,7 +166,6 @@ public class FileProvider extends ContentProvider {
return
ParcelFileDescriptor
.
open
(
file
,
fileMode
);
}
private
static
PathStrategy
getPathStrategy
(
Context
context
,
String
authority
)
{
PathStrategy
strat
;
synchronized
(
sCache
)
{
...
...
@@ -185,11 +174,9 @@ public class FileProvider extends ContentProvider {
try
{
strat
=
parsePathStrategy
(
context
,
authority
);
}
catch
(
IOException
e
)
{
throw
new
IllegalArgumentException
(
"Failed to parse "
+
META_DATA_FILE_PROVIDER_PATHS
+
" meta-data"
,
e
);
throw
new
IllegalArgumentException
(
"Failed to parse xml"
,
e
);
}
catch
(
XmlPullParserException
e
)
{
throw
new
IllegalArgumentException
(
"Failed to parse "
+
META_DATA_FILE_PROVIDER_PATHS
+
" meta-data"
,
e
);
throw
new
IllegalArgumentException
(
"Failed to parse xml"
,
e
);
}
sCache
.
put
(
authority
,
strat
);
}
...
...
@@ -197,19 +184,11 @@ public class FileProvider extends ContentProvider {
return
strat
;
}
private
static
PathStrategy
parsePathStrategy
(
Context
context
,
String
authority
)
throws
IOException
,
XmlPullParserException
{
final
SimplePathStrategy
strat
=
new
SimplePathStrategy
(
authority
);
final
ProviderInfo
info
=
context
.
getPackageManager
()
.
resolveContentProvider
(
authority
,
PackageManager
.
GET_META_DATA
);
final
XmlResourceParser
in
=
info
.
loadXmlMetaData
(
context
.
getPackageManager
(),
META_DATA_FILE_PROVIDER_PATHS
);
if
(
in
==
null
)
{
throw
new
IllegalArgumentException
(
"Missing "
+
META_DATA_FILE_PROVIDER_PATHS
+
" meta-data"
);
}
final
XmlResourceParser
in
=
context
.
getResources
().
getXml
(
R
.
xml
.
file_paths
);
int
type
;
while
((
type
=
in
.
next
())
!=
END_DOCUMENT
)
{
...
...
@@ -255,16 +234,13 @@ public class FileProvider extends ContentProvider {
return
strat
;
}
interface
PathStrategy
{
Uri
getUriForFile
(
File
file
);
File
getFileForUri
(
Uri
uri
);
}
static
class
SimplePathStrategy
implements
PathStrategy
{
private
final
String
mAuthority
;
private
final
HashMap
<
String
,
File
>
mRoots
=
new
HashMap
<>();
...
...
@@ -273,7 +249,6 @@ public class FileProvider extends ContentProvider {
mAuthority
=
authority
;
}
void
addRoot
(
String
name
,
File
root
)
{
if
(
TextUtils
.
isEmpty
(
name
))
{
throw
new
IllegalArgumentException
(
"Name must not be empty"
);
...
...
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