Don't try to rescale when no bitmap in RemoteControlClient
If a RemoteControlClient has a null artwork, do no attempt to
rescale the bitmap, it's ok to send a null bitmap to the
IRemoteControlDisplay.
Change-Id: I8332ccfcf18107ea0b41d4e7fa232d7f68798efc
diff --git a/media/java/android/media/RemoteControlClient.java b/media/java/android/media/RemoteControlClient.java
index e6331ce..2bdd3c9 100644
--- a/media/java/android/media/RemoteControlClient.java
+++ b/media/java/android/media/RemoteControlClient.java
@@ -722,20 +722,22 @@
*/
private Bitmap scaleBitmapIfTooBig(Bitmap bitmap, int maxWidth, int maxHeight) {
- final int width = bitmap.getWidth();
- final int height = bitmap.getHeight();
- if (width > maxWidth || height > maxHeight) {
- float scale = Math.min((float) maxWidth / width, (float) maxHeight / height);
- int newWidth = Math.round(scale * width);
- int newHeight = Math.round(scale * height);
- Bitmap outBitmap = Bitmap.createBitmap(newWidth, newHeight, bitmap.getConfig());
- Canvas canvas = new Canvas(outBitmap);
- Paint paint = new Paint();
- paint.setAntiAlias(true);
- paint.setFilterBitmap(true);
- canvas.drawBitmap(bitmap, null,
- new RectF(0, 0, outBitmap.getWidth(), outBitmap.getHeight()), paint);
- bitmap = outBitmap;
+ if (bitmap != null) {
+ final int width = bitmap.getWidth();
+ final int height = bitmap.getHeight();
+ if (width > maxWidth || height > maxHeight) {
+ float scale = Math.min((float) maxWidth / width, (float) maxHeight / height);
+ int newWidth = Math.round(scale * width);
+ int newHeight = Math.round(scale * height);
+ Bitmap outBitmap = Bitmap.createBitmap(newWidth, newHeight, bitmap.getConfig());
+ Canvas canvas = new Canvas(outBitmap);
+ Paint paint = new Paint();
+ paint.setAntiAlias(true);
+ paint.setFilterBitmap(true);
+ canvas.drawBitmap(bitmap, null,
+ new RectF(0, 0, outBitmap.getWidth(), outBitmap.getHeight()), paint);
+ bitmap = outBitmap;
+ }
}
return bitmap;