summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2013-09-29 12:08:25 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2013-09-29 12:17:13 -0700
commit8ab8c2d06185dfefb5c69e614271f684e77eef63 (patch)
tree9c995ee1dcdb539e253b63945fc2c43f3604492e /media
parent33ed738d49dce3af5851d0566739e9ed593057a5 (diff)
downloadframeworks_base-8ab8c2d06185dfefb5c69e614271f684e77eef63.zip
frameworks_base-8ab8c2d06185dfefb5c69e614271f684e77eef63.tar.gz
frameworks_base-8ab8c2d06185dfefb5c69e614271f684e77eef63.tar.bz2
Cache RemoteController artwork bitmap size, use it in registration
Allow an app to set the artwork configuration at any point regardless of the registration state, and cache the width/height values. If the RemoteController is already registered, apply them. If the RemoteController is not registered, use the cached value when the object gets registered. Bug 10862527 Change-Id: If633e2b9383e7d59690288d2271113e98b195cd8
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioManager.java5
-rw-r--r--media/java/android/media/RemoteController.java50
2 files changed, 35 insertions, 20 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 1941859..c8ee5ad 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -2281,10 +2281,9 @@ public class AudioManager {
}
IAudioService service = getService();
try {
+ int[] artworkDimensions = rctlr.getArtworkSize();
boolean reg = service.registerRemoteControlDisplay(rctlr.getRcDisplay(),
- // passing a negative value for art work width and height
- // as they are still unknown at this stage
- /*w*/-1, /*h*/ -1);
+ artworkDimensions[0]/*w*/, artworkDimensions[1]/*h*/);
rctlr.setIsRegistered(reg);
return reg;
} catch (RemoteException e) {
diff --git a/media/java/android/media/RemoteController.java b/media/java/android/media/RemoteController.java
index 10e1c70..96f6a92 100644
--- a/media/java/android/media/RemoteController.java
+++ b/media/java/android/media/RemoteController.java
@@ -74,6 +74,8 @@ public final class RemoteController
private OnClientUpdateListener mOnClientUpdateListener;
private PlaybackInfo mLastPlaybackInfo;
private int mLastTransportControlFlags = TRANSPORT_UNKNOWN;
+ private int mArtworkWidth = -1;
+ private int mArtworkHeight = -1;
/**
* Class constructor.
@@ -290,7 +292,6 @@ public final class RemoteController
/**
* @hide
- * must be called on a registered RemoteController
* @param wantBitmap
* @param width
* @param height
@@ -298,22 +299,26 @@ public final class RemoteController
*/
public int setArtworkConfiguration(boolean wantBitmap, int width, int height) {
synchronized (mInfoLock) {
- if (!mIsRegistered) {
- Log.e(TAG, "Cannot specify bitmap configuration on unregistered RemoteController");
- return ERROR;
- }
- }
- if (wantBitmap) {
- if ((width > 0) && (height > 0)) {
- if (width > MAX_BITMAP_DIMENSION) { width = MAX_BITMAP_DIMENSION; }
- if (height > MAX_BITMAP_DIMENSION) { height = MAX_BITMAP_DIMENSION; }
- mAudioManager.remoteControlDisplayUsesBitmapSize(mRcd, width, height);
+ if (wantBitmap) {
+ if ((width > 0) && (height > 0)) {
+ if (width > MAX_BITMAP_DIMENSION) { width = MAX_BITMAP_DIMENSION; }
+ if (height > MAX_BITMAP_DIMENSION) { height = MAX_BITMAP_DIMENSION; }
+ mArtworkWidth = width;
+ mArtworkHeight = height;
+ } else {
+ Log.e(TAG, "Invalid dimensions");
+ return ERROR_BAD_VALUE;
+ }
} else {
- Log.e(TAG, "Invalid dimensions");
- return ERROR_BAD_VALUE;
+ mArtworkWidth = -1;
+ mArtworkHeight = -1;
}
- } else {
- mAudioManager.remoteControlDisplayUsesBitmapSize(mRcd, -1, -1);
+ if (mIsRegistered) {
+ mAudioManager.remoteControlDisplayUsesBitmapSize(mRcd,
+ mArtworkWidth, mArtworkHeight);
+ } // else new values have been stored, and will be read by AudioManager with
+ // RemoteController.getArtworkSize() when AudioManager.registerRemoteController()
+ // is called.
}
return SUCCESS;
}
@@ -321,7 +326,6 @@ public final class RemoteController
/**
* Set the maximum artwork image dimensions to be received in the metadata.
* No bitmaps will be received unless this has been specified.
- * This method can only be called on a registered RemoteController.
* @param width the maximum width in pixels
* @param height the maximum height in pixels
* @return {@link #SUCCESS}, {@link #ERROR} or {@link #ERROR_BAD_VALUE}
@@ -332,7 +336,6 @@ public final class RemoteController
/**
* Prevents this RemoteController from receiving artwork images.
- * This method can only be called on a registered RemoteController.
* @return {@link #SUCCESS}, {@link #ERROR}
*/
public int clearArtworkConfiguration() {
@@ -767,4 +770,17 @@ public final class RemoteController
protected RcDisplay getRcDisplay() {
return mRcd;
}
+
+ /**
+ * @hide
+ * Used by AudioManager to read the current artwork dimension
+ * @return array containing width (index 0) and height (index 1) of currently set artwork size
+ */
+ protected int[] getArtworkSize() {
+ synchronized (mInfoLock) {
+ int[] size = { mArtworkWidth, mArtworkHeight };
+ return size;
+ }
+ }
+
}