Loading core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -1942,4 +1942,8 @@ <string-array translatable="false" name="config_sms_convert_destination_number_support"> <item>false</item> </string-array> <!-- The maximum bitmap size that can be written to a MediaMetadata object. This value is the max width/height allowed in dips.--> <dimen name="config_mediaMetadataBitmapMaxSize">320dp</dimen> </resources> core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1810,6 +1810,8 @@ <java-symbol type="color" name="notification_progress_background_color" /> <java-symbol type="id" name="media_actions" /> <java-symbol type="dimen" name="config_mediaMetadataBitmapMaxSize" /> <!-- From SystemUI --> <java-symbol type="anim" name="push_down_in" /> <java-symbol type="anim" name="push_down_out" /> Loading media/java/android/media/MediaMetadata.java +38 −5 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.media; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ContentProviderClient; import android.content.ContentResolver; import android.graphics.Bitmap; import android.graphics.BitmapFactory; Loading @@ -25,16 +23,14 @@ import android.media.browse.MediaBrowser; import android.media.session.MediaController; import android.net.Uri; import android.os.Bundle; import android.os.CancellationSignal; import android.os.OperationCanceledException; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import android.util.Size; import android.util.SparseArray; import java.util.ArrayList; import java.util.Set; /** Loading Loading @@ -568,6 +564,29 @@ public final class MediaMetadata implements Parcelable { mBundle = new Bundle(source.mBundle); } /** * Create a Builder using a {@link MediaMetadata} instance to set * initial values, but replace bitmaps with a scaled down copy if they * are larger than maxBitmapSize. * * @param source The original metadata to copy. * @param maxBitmapSize The maximum height/width for bitmaps contained * in the metadata. * @hide */ public Builder(MediaMetadata source, int maxBitmapSize) { this(source); for (String key : mBundle.keySet()) { Object value = mBundle.get(key); if (value != null && value instanceof Bitmap) { Bitmap bmp = (Bitmap) value; if (bmp.getHeight() > maxBitmapSize || bmp.getWidth() > maxBitmapSize) { putBitmap(key, scaleBitmap(bmp, maxBitmapSize)); } } } } /** * Put a CharSequence value into the metadata. Custom keys may be used, * but if the METADATA_KEYs defined in this class are used they may only Loading Loading @@ -707,6 +726,10 @@ public final class MediaMetadata implements Parcelable { * <li>{@link #METADATA_KEY_ALBUM_ART}</li> * <li>{@link #METADATA_KEY_DISPLAY_ICON}</li> * </ul> * <p> * Large bitmaps may be scaled down by the system. To pass full * resolution images {@link Uri Uris} should be used with * {@link #putString}. * * @param key The key for referencing this value * @param value The Bitmap to store Loading @@ -731,5 +754,15 @@ public final class MediaMetadata implements Parcelable { public MediaMetadata build() { return new MediaMetadata(mBundle); } private Bitmap scaleBitmap(Bitmap bmp, int maxSize) { float maxSizeF = maxSize; float widthScale = maxSizeF / bmp.getWidth(); float heightScale = maxSizeF / bmp.getHeight(); float scale = Math.min(widthScale, heightScale); int height = (int) (bmp.getHeight() * scale); int width = (int) (bmp.getWidth() * scale); return Bitmap.createScaledBitmap(bmp, width, height, true); } } } media/java/android/media/session/MediaSession.java +4 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ public final class MediaSession { public @interface SessionFlags { } private final Object mLock = new Object(); private final int mMaxBitmapSize; private final MediaSession.Token mSessionToken; private final MediaController mController; Loading Loading @@ -147,6 +148,8 @@ public final class MediaSession { if (TextUtils.isEmpty(tag)) { throw new IllegalArgumentException("tag cannot be null or empty"); } mMaxBitmapSize = context.getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_mediaMetadataBitmapMaxSize); mCbStub = new CallbackStub(this); MediaSessionManager manager = (MediaSessionManager) context .getSystemService(Context.MEDIA_SESSION_SERVICE); Loading Loading @@ -409,6 +412,7 @@ public final class MediaSession { * @param metadata The new metadata */ public void setMetadata(@Nullable MediaMetadata metadata) { metadata = (new MediaMetadata.Builder(metadata, mMaxBitmapSize)).build(); try { mBinder.setMetadata(metadata); } catch (RemoteException e) { Loading Loading
core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -1942,4 +1942,8 @@ <string-array translatable="false" name="config_sms_convert_destination_number_support"> <item>false</item> </string-array> <!-- The maximum bitmap size that can be written to a MediaMetadata object. This value is the max width/height allowed in dips.--> <dimen name="config_mediaMetadataBitmapMaxSize">320dp</dimen> </resources>
core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1810,6 +1810,8 @@ <java-symbol type="color" name="notification_progress_background_color" /> <java-symbol type="id" name="media_actions" /> <java-symbol type="dimen" name="config_mediaMetadataBitmapMaxSize" /> <!-- From SystemUI --> <java-symbol type="anim" name="push_down_in" /> <java-symbol type="anim" name="push_down_out" /> Loading
media/java/android/media/MediaMetadata.java +38 −5 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.media; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ContentProviderClient; import android.content.ContentResolver; import android.graphics.Bitmap; import android.graphics.BitmapFactory; Loading @@ -25,16 +23,14 @@ import android.media.browse.MediaBrowser; import android.media.session.MediaController; import android.net.Uri; import android.os.Bundle; import android.os.CancellationSignal; import android.os.OperationCanceledException; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import android.util.Size; import android.util.SparseArray; import java.util.ArrayList; import java.util.Set; /** Loading Loading @@ -568,6 +564,29 @@ public final class MediaMetadata implements Parcelable { mBundle = new Bundle(source.mBundle); } /** * Create a Builder using a {@link MediaMetadata} instance to set * initial values, but replace bitmaps with a scaled down copy if they * are larger than maxBitmapSize. * * @param source The original metadata to copy. * @param maxBitmapSize The maximum height/width for bitmaps contained * in the metadata. * @hide */ public Builder(MediaMetadata source, int maxBitmapSize) { this(source); for (String key : mBundle.keySet()) { Object value = mBundle.get(key); if (value != null && value instanceof Bitmap) { Bitmap bmp = (Bitmap) value; if (bmp.getHeight() > maxBitmapSize || bmp.getWidth() > maxBitmapSize) { putBitmap(key, scaleBitmap(bmp, maxBitmapSize)); } } } } /** * Put a CharSequence value into the metadata. Custom keys may be used, * but if the METADATA_KEYs defined in this class are used they may only Loading Loading @@ -707,6 +726,10 @@ public final class MediaMetadata implements Parcelable { * <li>{@link #METADATA_KEY_ALBUM_ART}</li> * <li>{@link #METADATA_KEY_DISPLAY_ICON}</li> * </ul> * <p> * Large bitmaps may be scaled down by the system. To pass full * resolution images {@link Uri Uris} should be used with * {@link #putString}. * * @param key The key for referencing this value * @param value The Bitmap to store Loading @@ -731,5 +754,15 @@ public final class MediaMetadata implements Parcelable { public MediaMetadata build() { return new MediaMetadata(mBundle); } private Bitmap scaleBitmap(Bitmap bmp, int maxSize) { float maxSizeF = maxSize; float widthScale = maxSizeF / bmp.getWidth(); float heightScale = maxSizeF / bmp.getHeight(); float scale = Math.min(widthScale, heightScale); int height = (int) (bmp.getHeight() * scale); int width = (int) (bmp.getWidth() * scale); return Bitmap.createScaledBitmap(bmp, width, height, true); } } }
media/java/android/media/session/MediaSession.java +4 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ public final class MediaSession { public @interface SessionFlags { } private final Object mLock = new Object(); private final int mMaxBitmapSize; private final MediaSession.Token mSessionToken; private final MediaController mController; Loading Loading @@ -147,6 +148,8 @@ public final class MediaSession { if (TextUtils.isEmpty(tag)) { throw new IllegalArgumentException("tag cannot be null or empty"); } mMaxBitmapSize = context.getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_mediaMetadataBitmapMaxSize); mCbStub = new CallbackStub(this); MediaSessionManager manager = (MediaSessionManager) context .getSystemService(Context.MEDIA_SESSION_SERVICE); Loading Loading @@ -409,6 +412,7 @@ public final class MediaSession { * @param metadata The new metadata */ public void setMetadata(@Nullable MediaMetadata metadata) { metadata = (new MediaMetadata.Builder(metadata, mMaxBitmapSize)).build(); try { mBinder.setMetadata(metadata); } catch (RemoteException e) { Loading