diff options
| author | Jeff Sharkey <jsharkey@google.com> | 2019-11-13 20:53:45 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-11-13 20:53:45 +0000 |
| commit | 97d3ca1e8f6c721d5976771631e20cf31b7c5fc8 (patch) | |
| tree | 8b0f402adde296d855330e474fb78371eac8e79f /core/java/android | |
| parent | 33f50a8a865f4354cb0c6fbd81c264ad1492baab (diff) | |
| parent | 7e9699f83ab405cd7fe0c6564dffea274cf1ac59 (diff) | |
Merge changes from topic "legacycodez"
* changes:
Progress towards splitting MediaProvider UID.
Progress towards splitting MediaProvider UID.
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/provider/MediaStore.java | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java index aa67d9779da4..01f9c7300fa1 100644 --- a/core/java/android/provider/MediaStore.java +++ b/core/java/android/provider/MediaStore.java @@ -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 @@ -878,6 +885,16 @@ public final class MediaStore { } /** + * 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. */ public interface MediaColumns extends BaseColumns { @@ -3477,11 +3494,15 @@ 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) { - return segments.get(0); - } else { - throw new IllegalArgumentException("Missing volume name: " + uri); + switch (uri.getAuthority()) { + case AUTHORITY: + case AUTHORITY_LEGACY: { + if (segments != null && segments.size() > 0) { + return segments.get(0); + } + } } + throw new IllegalArgumentException("Missing volume name: " + uri); } /** {@hide} */ |
