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

Commit b97dfc67 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add missing nullness annotations to MediaMetadata API" into main

parents 81fa9953 7fdacf56
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -24667,13 +24667,13 @@ package android.media {
  public final class MediaMetadata implements android.os.Parcelable {
    method public boolean containsKey(String);
    method public int describeContents();
    method public android.graphics.Bitmap getBitmap(String);
    method @Nullable public android.graphics.Bitmap getBitmap(String);
    method @IntRange(from=1) public int getBitmapDimensionLimit();
    method @NonNull public android.media.MediaDescription getDescription();
    method public long getLong(String);
    method public android.media.Rating getRating(String);
    method public String getString(String);
    method public CharSequence getText(String);
    method @Nullable public android.media.Rating getRating(String);
    method @Nullable public String getString(String);
    method @Nullable public CharSequence getText(String);
    method public java.util.Set<java.lang.String> keySet();
    method public int size();
    method public void writeToParcel(android.os.Parcel, int);
@@ -24713,11 +24713,11 @@ package android.media {
    ctor public MediaMetadata.Builder();
    ctor public MediaMetadata.Builder(android.media.MediaMetadata);
    method public android.media.MediaMetadata build();
    method public android.media.MediaMetadata.Builder putBitmap(String, android.graphics.Bitmap);
    method public android.media.MediaMetadata.Builder putBitmap(String, @Nullable android.graphics.Bitmap);
    method public android.media.MediaMetadata.Builder putLong(String, long);
    method public android.media.MediaMetadata.Builder putRating(String, android.media.Rating);
    method public android.media.MediaMetadata.Builder putString(String, String);
    method public android.media.MediaMetadata.Builder putText(String, CharSequence);
    method public android.media.MediaMetadata.Builder putRating(String, @Nullable android.media.Rating);
    method public android.media.MediaMetadata.Builder putString(String, @Nullable String);
    method public android.media.MediaMetadata.Builder putText(String, @Nullable CharSequence);
    method @NonNull public android.media.MediaMetadata.Builder setBitmapDimensionLimit(@IntRange(from=1) int);
  }
+14 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package android.media;

import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringDef;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ContentResolver;
@@ -459,6 +460,7 @@ public final class MediaMetadata implements Parcelable {
     * @param key The key the value is stored under
     * @return a CharSequence value, or null
     */
    @Nullable
    public CharSequence getText(@TextKey String key) {
        return mBundle.getCharSequence(key);
    }
@@ -472,6 +474,7 @@ public final class MediaMetadata implements Parcelable {
     * @param key The key the value is stored under
     * @return a String value, or null
     */
    @Nullable
    public String getString(@TextKey String key) {
        CharSequence text = getText(key);
        if (text != null) {
@@ -498,12 +501,13 @@ public final class MediaMetadata implements Parcelable {
     * @param key The key the value is stored under
     * @return A {@link Rating} or null
     */
    @Nullable
    public Rating getRating(@RatingKey String key) {
        Rating rating = null;
        try {
            rating = mBundle.getParcelable(key, android.media.Rating.class);
        } catch (Exception e) {
            // ignore, value was not a bitmap
            // ignore, value was not a rating
            Log.w(TAG, "Failed to retrieve a key as Rating.", e);
        }
        return rating;
@@ -516,6 +520,7 @@ public final class MediaMetadata implements Parcelable {
     * @param key The key the value is stored under
     * @return A {@link Bitmap} or null
     */
    @Nullable
    public Bitmap getBitmap(@BitmapKey String key) {
        Bitmap bmp = null;
        try {
@@ -662,6 +667,7 @@ public final class MediaMetadata implements Parcelable {
     * @hide
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @Nullable
    public static String getKeyFromMetadataEditorKey(int editorKey) {
        return EDITOR_KEY_MAPPING.get(editorKey, null);
    }
@@ -798,7 +804,8 @@ public final class MediaMetadata implements Parcelable {
         * @param value The CharSequence value to store
         * @return The Builder to allow chaining
         */
        public Builder putText(@TextKey String key, CharSequence value) {
        public Builder putText(
                    @TextKey String key, @Nullable CharSequence value) {
            if (METADATA_KEYS_TYPE.containsKey(key)) {
                if (METADATA_KEYS_TYPE.get(key) != METADATA_TYPE_TEXT) {
                    throw new IllegalArgumentException("The " + key
@@ -840,7 +847,7 @@ public final class MediaMetadata implements Parcelable {
         * @param value The String value to store
         * @return The Builder to allow chaining
         */
        public Builder putString(@TextKey String key, String value) {
        public Builder putString(@TextKey String key, @Nullable String value) {
            if (METADATA_KEYS_TYPE.containsKey(key)) {
                if (METADATA_KEYS_TYPE.get(key) != METADATA_TYPE_TEXT) {
                    throw new IllegalArgumentException("The " + key
@@ -891,7 +898,8 @@ public final class MediaMetadata implements Parcelable {
         * @param value The Rating value to store
         * @return The Builder to allow chaining
         */
        public Builder putRating(@RatingKey String key, Rating value) {
        public Builder putRating(
                    @RatingKey String key, @Nullable Rating value) {
            if (METADATA_KEYS_TYPE.containsKey(key)) {
                if (METADATA_KEYS_TYPE.get(key) != METADATA_TYPE_RATING) {
                    throw new IllegalArgumentException("The " + key
@@ -921,7 +929,8 @@ public final class MediaMetadata implements Parcelable {
         * @param value The Bitmap to store
         * @return The Builder to allow chaining
         */
        public Builder putBitmap(@BitmapKey String key, Bitmap value) {
        public Builder putBitmap(
                    @BitmapKey String key, @Nullable Bitmap value) {
            if (METADATA_KEYS_TYPE.containsKey(key)) {
                if (METADATA_KEYS_TYPE.get(key) != METADATA_TYPE_BITMAP) {
                    throw new IllegalArgumentException("The " + key