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

Commit 7fdacf56 authored by Toni Heidenreich's avatar Toni Heidenreich
Browse files

Add missing nullness annotations to MediaMetadata API

Test: no behavior change
Flag: EXEMPT bugfix
Change-Id: I2ec938f7b8152a800a94cec8527de258ea06cb65
FCRS_CODE : mbl3q78on00uf1
parent e7864abe
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -24648,13 +24648,13 @@ package android.media {
  public final class MediaMetadata implements android.os.Parcelable {
  public final class MediaMetadata implements android.os.Parcelable {
    method public boolean containsKey(String);
    method public boolean containsKey(String);
    method public int describeContents();
    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 @IntRange(from=1) public int getBitmapDimensionLimit();
    method @NonNull public android.media.MediaDescription getDescription();
    method @NonNull public android.media.MediaDescription getDescription();
    method public long getLong(String);
    method public long getLong(String);
    method public android.media.Rating getRating(String);
    method @Nullable public android.media.Rating getRating(String);
    method public String getString(String);
    method @Nullable public String getString(String);
    method public CharSequence getText(String);
    method @Nullable public CharSequence getText(String);
    method public java.util.Set<java.lang.String> keySet();
    method public java.util.Set<java.lang.String> keySet();
    method public int size();
    method public int size();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
@@ -24694,11 +24694,11 @@ package android.media {
    ctor public MediaMetadata.Builder();
    ctor public MediaMetadata.Builder();
    ctor public MediaMetadata.Builder(android.media.MediaMetadata);
    ctor public MediaMetadata.Builder(android.media.MediaMetadata);
    method public android.media.MediaMetadata build();
    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 putLong(String, long);
    method public android.media.MediaMetadata.Builder putRating(String, android.media.Rating);
    method public android.media.MediaMetadata.Builder putRating(String, @Nullable android.media.Rating);
    method public android.media.MediaMetadata.Builder putString(String, String);
    method public android.media.MediaMetadata.Builder putString(String, @Nullable String);
    method public android.media.MediaMetadata.Builder putText(String, CharSequence);
    method public android.media.MediaMetadata.Builder putText(String, @Nullable CharSequence);
    method @NonNull public android.media.MediaMetadata.Builder setBitmapDimensionLimit(@IntRange(from=1) int);
    method @NonNull public android.media.MediaMetadata.Builder setBitmapDimensionLimit(@IntRange(from=1) int);
  }
  }
+14 −5
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@ package android.media;


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