Merge "Use MediaStore.scanFile instead of manually inserting to MediaProvider." into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
26bcc0e5ae
@@ -19,7 +19,6 @@ package com.android.internal.content;
|
|||||||
import android.annotation.CallSuper;
|
import android.annotation.CallSuper;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.res.AssetFileDescriptor;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@@ -266,17 +265,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
|||||||
if (visibleFolder != null) {
|
if (visibleFolder != null) {
|
||||||
assert (visibleFolder.isDirectory());
|
assert (visibleFolder.isDirectory());
|
||||||
|
|
||||||
final long token = Binder.clearCallingIdentity();
|
MediaStore.scanFile(getContext(), visibleFolder);
|
||||||
|
|
||||||
try {
|
|
||||||
final ContentResolver resolver = getContext().getContentResolver();
|
|
||||||
final Uri uri = MediaStore.Files.getDirectoryUri("external");
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put(MediaStore.Files.FileColumns.DATA, visibleFolder.getAbsolutePath());
|
|
||||||
resolver.insert(uri, values);
|
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(token);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user