Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab0a9722 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Progress towards splitting MediaProvider UID.

We're working towards making MediaProvider into a Mainline module,
which means it can no longer share the "android.media" UID built
into the OS.  The major reason for this is because they're signed
with separate keys, but a secondary reason is that we don't know what
database customizations an OEM has performed in their MediaProvider.

This initial pass introduces the APIs needed to support a "legacy"
MediaProvider that will be used to migrate data between the old and
new UID.  This legacy provider is implemented using the same code
as the modern provider, but hosted at the "media_legacy" authority.

Bug: 144247087
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: Ibc38a786799e138e9c3e31297c7066bab6843d89
parent 8a505cde
Loading
Loading
Loading
Loading
+26 −5
Original line number Diff line number Diff line
@@ -104,7 +104,14 @@ public final class MediaStore {
    /** The authority for the media provider */
    public static final String AUTHORITY = "media";
    /** A content:// style uri to the authority for the media provider */
    public static final @NonNull Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
    public static final @NonNull Uri AUTHORITY_URI =
            Uri.parse("content://" + AUTHORITY);

    /** @hide */
    public static final String AUTHORITY_LEGACY = "media_legacy";
    /** @hide */
    public static final @NonNull Uri AUTHORITY_LEGACY_URI =
            Uri.parse("content://" + AUTHORITY_LEGACY);

    /**
     * Synthetic volume name that provides a view of all content across the
@@ -877,6 +884,16 @@ public final class MediaStore {
        context.getContentResolver().update(uri, values, null, null);
    }

    /**
     * Rewrite the given {@link Uri} to point at
     * {@link MediaStore#AUTHORITY_LEGACY}.
     *
     * @hide
     */
    public static @NonNull Uri rewriteToLegacy(@NonNull Uri uri) {
        return uri.buildUpon().authority(MediaStore.AUTHORITY_LEGACY).build();
    }

    /**
     * Common media metadata columns.
     */
@@ -3477,12 +3494,16 @@ public final class MediaStore {
     */
    public static @NonNull String getVolumeName(@NonNull Uri uri) {
        final List<String> segments = uri.getPathSegments();
        if (uri.getAuthority().equals(AUTHORITY) && segments != null && segments.size() > 0) {
        switch (uri.getAuthority()) {
            case AUTHORITY:
            case AUTHORITY_LEGACY: {
                if (segments != null && segments.size() > 0) {
                    return segments.get(0);
        } else {
            throw new IllegalArgumentException("Missing volume name: " + uri);
                }
            }
        }
        throw new IllegalArgumentException("Missing volume name: " + uri);
    }

    /** {@hide} */
    public static @NonNull String checkArgumentVolumeName(@NonNull String volumeName) {