summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2013-09-30 23:24:01 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-30 23:24:01 +0000
commitb4c6b241fb96e4482dd7c29f5ec54e40aacbbd25 (patch)
treed60103f61e43bc1a91385c4581a018d6007f3c5f /media
parent60e7f8191e75b8029da72f5248d6b4480bc0beac (diff)
parent8ab8c2d06185dfefb5c69e614271f684e77eef63 (diff)
downloadframeworks_base-b4c6b241fb96e4482dd7c29f5ec54e40aacbbd25.zip
frameworks_base-b4c6b241fb96e4482dd7c29f5ec54e40aacbbd25.tar.gz
frameworks_base-b4c6b241fb96e4482dd7c29f5ec54e40aacbbd25.tar.bz2
Merge "Cache RemoteController artwork bitmap size, use it in registration" into klp-dev
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;
+ }
+ }
+
}