Query specific collections for properties.

We're now enforcing the public API schema, so clients like MTP need
to query specific collections when asking for properties that are
specific to those media types.

Also refactor MediaScanner calls to go through MediaProvider, so
they can be handled by ModernMediaScanner.  We no longer directly
try inserting items, and instead rely completely on the scanner.

Bug: 127625964, 122263824
Test: atest MediaProviderTests
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: Ic86982766606a619afafe725f9c60013a5671840
This commit is contained in:
Jeff Sharkey
2019-03-24 12:50:51 -06:00
parent 1c3ef21ab8
commit ff200957fd
4 changed files with 106 additions and 185 deletions

View File

@@ -136,6 +136,7 @@ public final class MediaStore {
* removing nomedia files
* @hide
*/
@Deprecated
public static final String UNHIDE_CALL = "unhide";
/**
@@ -3536,4 +3537,17 @@ public final class MediaStore {
throw new IOException("User " + user + " must be unlocked and running");
}
}
/** @hide */
public static Uri scanFile(Context context, File file) {
final ContentResolver resolver = context.getContentResolver();
try (ContentProviderClient client = resolver.acquireContentProviderClient(AUTHORITY)) {
final Bundle in = new Bundle();
in.putParcelable(Intent.EXTRA_STREAM, Uri.fromFile(file));
final Bundle out = client.call(SCAN_FILE_CALL, null, in);
return out.getParcelable(Intent.EXTRA_STREAM);
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
}
}
}