Loading media/java/android/media/MediaMetadata.java +44 −22 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.media; import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Size; import android.annotation.StringDef; import android.compat.annotation.UnsupportedAppUsage; import android.content.ContentResolver; Loading Loading @@ -590,31 +591,10 @@ public final class MediaMetadata implements Parcelable { String mediaId = getString(METADATA_KEY_MEDIA_ID); CharSequence[] text = new CharSequence[3]; CharSequence[] text = getTitleSubtitleAndDescription(); Bitmap icon = null; Uri iconUri = null; // First handle the case where display data is set already CharSequence displayText = getText(METADATA_KEY_DISPLAY_TITLE); if (!TextUtils.isEmpty(displayText)) { // If they have a display title use only display data, otherwise use // our best bets text[0] = displayText; text[1] = getText(METADATA_KEY_DISPLAY_SUBTITLE); text[2] = getText(METADATA_KEY_DISPLAY_DESCRIPTION); } else { // Use whatever fields we can int textIndex = 0; int keyIndex = 0; while (textIndex < text.length && keyIndex < PREFERRED_DESCRIPTION_ORDER.length) { CharSequence next = getText(PREFERRED_DESCRIPTION_ORDER[keyIndex++]); if (!TextUtils.isEmpty(next)) { // Fill in the next empty bit of text text[textIndex++] = next; } } } // Get the best art bitmap we can find for (int i = 0; i < PREFERRED_BITMAP_ORDER.length; i++) { Bitmap next = getBitmap(PREFERRED_BITMAP_ORDER[i]); Loading Loading @@ -658,6 +638,19 @@ public final class MediaMetadata implements Parcelable { return mDescription; } /** * Returns a description string of this metadata. * * Note: this is for MediaSession.setMetadata() to get the description of the * metadata, and it matches the previous beahvior as MediaDescription#toString() * * @hide */ public String getDescriptionString() { CharSequence[] text = getTitleSubtitleAndDescription(); return text[0] + ", " + text[1] + ", " + text[2]; } /** * Helper for getting the String key used by {@link MediaMetadata} from the * integer key that {@link MediaMetadataEditor} uses. Loading Loading @@ -750,6 +743,35 @@ public final class MediaMetadata implements Parcelable { return hashCode; } /** * Returns title, subtitle, description in this metadata */ @NonNull @Size(3) private CharSequence[] getTitleSubtitleAndDescription() { CharSequence[] text = new CharSequence[3]; // First handle the case where display data is set already CharSequence displayText = getText(METADATA_KEY_DISPLAY_TITLE); if (!TextUtils.isEmpty(displayText)) { // If they have a display title use only display data, otherwise use // our best bets text[0] = displayText; text[1] = getText(METADATA_KEY_DISPLAY_SUBTITLE); text[2] = getText(METADATA_KEY_DISPLAY_DESCRIPTION); } else { // Use whatever fields we can int textIndex = 0; int keyIndex = 0; while (textIndex < text.length && keyIndex < PREFERRED_DESCRIPTION_ORDER.length) { CharSequence next = getText(PREFERRED_DESCRIPTION_ORDER[keyIndex++]); if (!TextUtils.isEmpty(next)) { // Fill in the next empty bit of text text[textIndex++] = next; } } } return text; } /** * Use to build MediaMetadata objects. The system defined metadata keys must * use the appropriate data type. Loading media/java/android/media/session/MediaSession.java +2 −2 Original line number Diff line number Diff line Loading @@ -506,7 +506,7 @@ public final class MediaSession { public void setMetadata(@Nullable MediaMetadata metadata) { long duration = -1; int fields = 0; MediaDescription description = null; String description = null; if (metadata != null) { metadata = new MediaMetadata.Builder(metadata) .setBitmapDimensionLimit(mMaxBitmapSize) Loading @@ -515,7 +515,7 @@ public final class MediaSession { duration = metadata.getLong(MediaMetadata.METADATA_KEY_DURATION); } fields = metadata.size(); description = metadata.getDescription(); description = metadata.getDescriptionString(); } String metadataDescription = "size=" + fields + ", description=" + description; Loading Loading
media/java/android/media/MediaMetadata.java +44 −22 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.media; import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Size; import android.annotation.StringDef; import android.compat.annotation.UnsupportedAppUsage; import android.content.ContentResolver; Loading Loading @@ -590,31 +591,10 @@ public final class MediaMetadata implements Parcelable { String mediaId = getString(METADATA_KEY_MEDIA_ID); CharSequence[] text = new CharSequence[3]; CharSequence[] text = getTitleSubtitleAndDescription(); Bitmap icon = null; Uri iconUri = null; // First handle the case where display data is set already CharSequence displayText = getText(METADATA_KEY_DISPLAY_TITLE); if (!TextUtils.isEmpty(displayText)) { // If they have a display title use only display data, otherwise use // our best bets text[0] = displayText; text[1] = getText(METADATA_KEY_DISPLAY_SUBTITLE); text[2] = getText(METADATA_KEY_DISPLAY_DESCRIPTION); } else { // Use whatever fields we can int textIndex = 0; int keyIndex = 0; while (textIndex < text.length && keyIndex < PREFERRED_DESCRIPTION_ORDER.length) { CharSequence next = getText(PREFERRED_DESCRIPTION_ORDER[keyIndex++]); if (!TextUtils.isEmpty(next)) { // Fill in the next empty bit of text text[textIndex++] = next; } } } // Get the best art bitmap we can find for (int i = 0; i < PREFERRED_BITMAP_ORDER.length; i++) { Bitmap next = getBitmap(PREFERRED_BITMAP_ORDER[i]); Loading Loading @@ -658,6 +638,19 @@ public final class MediaMetadata implements Parcelable { return mDescription; } /** * Returns a description string of this metadata. * * Note: this is for MediaSession.setMetadata() to get the description of the * metadata, and it matches the previous beahvior as MediaDescription#toString() * * @hide */ public String getDescriptionString() { CharSequence[] text = getTitleSubtitleAndDescription(); return text[0] + ", " + text[1] + ", " + text[2]; } /** * Helper for getting the String key used by {@link MediaMetadata} from the * integer key that {@link MediaMetadataEditor} uses. Loading Loading @@ -750,6 +743,35 @@ public final class MediaMetadata implements Parcelable { return hashCode; } /** * Returns title, subtitle, description in this metadata */ @NonNull @Size(3) private CharSequence[] getTitleSubtitleAndDescription() { CharSequence[] text = new CharSequence[3]; // First handle the case where display data is set already CharSequence displayText = getText(METADATA_KEY_DISPLAY_TITLE); if (!TextUtils.isEmpty(displayText)) { // If they have a display title use only display data, otherwise use // our best bets text[0] = displayText; text[1] = getText(METADATA_KEY_DISPLAY_SUBTITLE); text[2] = getText(METADATA_KEY_DISPLAY_DESCRIPTION); } else { // Use whatever fields we can int textIndex = 0; int keyIndex = 0; while (textIndex < text.length && keyIndex < PREFERRED_DESCRIPTION_ORDER.length) { CharSequence next = getText(PREFERRED_DESCRIPTION_ORDER[keyIndex++]); if (!TextUtils.isEmpty(next)) { // Fill in the next empty bit of text text[textIndex++] = next; } } } return text; } /** * Use to build MediaMetadata objects. The system defined metadata keys must * use the appropriate data type. Loading
media/java/android/media/session/MediaSession.java +2 −2 Original line number Diff line number Diff line Loading @@ -506,7 +506,7 @@ public final class MediaSession { public void setMetadata(@Nullable MediaMetadata metadata) { long duration = -1; int fields = 0; MediaDescription description = null; String description = null; if (metadata != null) { metadata = new MediaMetadata.Builder(metadata) .setBitmapDimensionLimit(mMaxBitmapSize) Loading @@ -515,7 +515,7 @@ public final class MediaSession { duration = metadata.getLong(MediaMetadata.METADATA_KEY_DURATION); } fields = metadata.size(); description = metadata.getDescription(); description = metadata.getDescriptionString(); } String metadataDescription = "size=" + fields + ", description=" + description; Loading