Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
packages_providers_MediaProvider
Commits
6ad96629
Commit
6ad96629
authored
10 years ago
by
Marco Nelissen
Browse files
Options
Download
Email Patches
Plain Diff
Check access before creating thumbnail
Bug: 17943556 Change-Id: I1ee026fc0f6248dab2e678e478ba76e8d464dba6
parent
168c9e90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
src/com/android/providers/media/MediaProvider.java
src/com/android/providers/media/MediaProvider.java
+9
-3
No files found.
src/com/android/providers/media/MediaProvider.java
View file @
6ad96629
...
...
@@ -3785,11 +3785,17 @@ public class MediaProvider extends ContentProvider {
}
}
private
boolean
ensureFileExists
(
String
path
)
{
private
boolean
ensureFileExists
(
Uri
uri
,
String
path
)
{
File
file
=
new
File
(
path
);
if
(
file
.
exists
())
{
return
true
;
}
else
{
try
{
checkAccess
(
uri
,
file
,
ParcelFileDescriptor
.
MODE_READ_WRITE
|
ParcelFileDescriptor
.
MODE_CREATE
);
}
catch
(
FileNotFoundException
e
)
{
return
false
;
}
// we will not attempt to create the first directory in the path
// (for example, do not create /sdcard if the SD card is not mounted)
int
secondSlash
=
path
.
indexOf
(
'/'
,
1
);
...
...
@@ -4911,7 +4917,7 @@ public class MediaProvider extends ContentProvider {
try
{
if
(
c
!=
null
&&
c
.
moveToFirst
())
{
String
albumart_path
=
c
.
getString
(
0
);
if
(
ensureFileExists
(
albumart_path
))
{
if
(
ensureFileExists
(
albumart_uri
,
albumart_path
))
{
out
=
albumart_uri
;
}
}
else
{
...
...
@@ -4932,7 +4938,7 @@ public class MediaProvider extends ContentProvider {
out
=
ContentUris
.
withAppendedId
(
ALBUMART_URI
,
rowId
);
// ensure the parent directory exists
String
albumart_path
=
values
.
getAsString
(
MediaStore
.
MediaColumns
.
DATA
);
ensureFileExists
(
albumart_path
);
ensureFileExists
(
out
,
albumart_path
);
}
}
catch
(
IllegalStateException
ex
)
{
Log
.
e
(
TAG
,
"error creating album thumb file"
);
...
...
This diff is collapsed.
Click to expand it.
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