summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--media/java/android/media/AudioManager.java54
-rw-r--r--media/java/android/media/IRemoteControlDisplay.aidl5
-rw-r--r--media/java/android/media/RemoteControlClient.java44
3 files changed, 86 insertions, 17 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index e3ef71785dba..25c4200f2a12 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -1761,6 +1761,60 @@ public class AudioManager {
}
}
+ /**
+ * @hide
+ * Registers a remote control display that will be sent information by remote control clients.
+ * @param rcd
+ */
+ public void registerRemoteControlDisplay(IRemoteControlDisplay rcd) {
+ if (rcd == null) {
+ return;
+ }
+ IAudioService service = getService();
+ try {
+ service.registerRemoteControlDisplay(rcd);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Dead object in registerRemoteControlDisplay " + e);
+ }
+ }
+
+ /**
+ * @hide
+ * Unregisters a remote control display that was sent information by remote control clients.
+ * @param rcd
+ */
+ public void unregisterRemoteControlDisplay(IRemoteControlDisplay rcd) {
+ if (rcd == null) {
+ return;
+ }
+ IAudioService service = getService();
+ try {
+ service.unregisterRemoteControlDisplay(rcd);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Dead object in unregisterRemoteControlDisplay " + e);
+ }
+ }
+
+ /**
+ * @hide
+ * Sets the artwork size a remote control display expects when receiving bitmaps.
+ * @param rcd
+ * @param w the maximum width of the expected bitmap. Negative values indicate it is
+ * useless to send artwork.
+ * @param h the maximum height of the expected bitmap. Negative values indicate it is
+ * useless to send artwork.
+ */
+ public void remoteControlDisplayUsesBitmapSize(IRemoteControlDisplay rcd, int w, int h) {
+ if (rcd == null) {
+ return;
+ }
+ IAudioService service = getService();
+ try {
+ service.remoteControlDisplayUsesBitmapSize(rcd, w, h);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Dead object in remoteControlDisplayUsesBitmapSize " + e);
+ }
+ }
// FIXME remove because we are not using intents anymore between AudioService and RcDisplay
/**
diff --git a/media/java/android/media/IRemoteControlDisplay.aidl b/media/java/android/media/IRemoteControlDisplay.aidl
index 19ea2028f114..d000906d3876 100644
--- a/media/java/android/media/IRemoteControlDisplay.aidl
+++ b/media/java/android/media/IRemoteControlDisplay.aidl
@@ -39,4 +39,9 @@ oneway interface IRemoteControlDisplay
void setTransportControlFlags(int generationId, int transportControlFlags);
void setArtwork(int generationId, in Bitmap artwork);
+
+ /**
+ * To combine metadata text and artwork in one binder call
+ */
+ void setAllMetadata(int generationId, in Bundle metadata, in Bitmap artwork);
}
diff --git a/media/java/android/media/RemoteControlClient.java b/media/java/android/media/RemoteControlClient.java
index cb5a63e61717..e6331ce4ce1c 100644
--- a/media/java/android/media/RemoteControlClient.java
+++ b/media/java/android/media/RemoteControlClient.java
@@ -345,12 +345,8 @@ public class RemoteControlClient
mMetadata = new Bundle(mEditorMetadata);
mArtwork = mEditorArtwork;
if (mMetadataChanged & mArtworkChanged) {
- // FIXME the following two send methods need to be combined in a single call
- // that pushes the metadata and artwork in one binder call
// send to remote control display if conditions are met
- sendMetadata_syncCacheLock();
- // send to remote control display if conditions are met
- sendArtwork_syncCacheLock();
+ sendMetadataWithArtwork_syncCacheLock();
} else if (mMetadataChanged) {
// send to remote control display if conditions are met
sendMetadata_syncCacheLock();
@@ -447,6 +443,7 @@ public class RemoteControlClient
*/
private Bitmap mArtwork;
private final int ARTWORK_DEFAULT_SIZE = 256;
+ private final int ARTWORK_INVALID_SIZE = -1;
private int mArtworkExpectedWidth = ARTWORK_DEFAULT_SIZE;
private int mArtworkExpectedHeight = ARTWORK_DEFAULT_SIZE;
/**
@@ -610,15 +607,19 @@ public class RemoteControlClient
}
}
+ private void detachFromDisplay_syncCacheLock() {
+ mRcDisplay = null;
+ mArtworkExpectedWidth = ARTWORK_INVALID_SIZE;
+ mArtworkExpectedHeight = ARTWORK_INVALID_SIZE;
+ }
+
private void sendPlaybackState_syncCacheLock() {
if ((mCurrentClientGenId == mInternalClientGenId) && (mRcDisplay != null)) {
try {
mRcDisplay.setPlaybackState(mInternalClientGenId, mPlaybackState);
} catch (RemoteException e) {
Log.e(TAG, "Error in setPlaybackState(), dead display "+e);
- mRcDisplay = null;
- mArtworkExpectedWidth = -1;
- mArtworkExpectedHeight = -1;
+ detachFromDisplay_syncCacheLock();
}
}
}
@@ -629,9 +630,7 @@ public class RemoteControlClient
mRcDisplay.setMetadata(mInternalClientGenId, mMetadata);
} catch (RemoteException e) {
Log.e(TAG, "Error in sendPlaybackState(), dead display "+e);
- mRcDisplay = null;
- mArtworkExpectedWidth = -1;
- mArtworkExpectedHeight = -1;
+ detachFromDisplay_syncCacheLock();
}
}
}
@@ -643,9 +642,7 @@ public class RemoteControlClient
mTransportControlFlags);
} catch (RemoteException e) {
Log.e(TAG, "Error in sendTransportControlFlags(), dead display "+e);
- mRcDisplay = null;
- mArtworkExpectedWidth = -1;
- mArtworkExpectedHeight = -1;
+ detachFromDisplay_syncCacheLock();
}
}
}
@@ -660,9 +657,22 @@ public class RemoteControlClient
mRcDisplay.setArtwork(mInternalClientGenId, mArtwork);
} catch (RemoteException e) {
Log.e(TAG, "Error in sendArtwork(), dead display "+e);
- mRcDisplay = null;
- mArtworkExpectedWidth = -1;
- mArtworkExpectedHeight = -1;
+ detachFromDisplay_syncCacheLock();
+ }
+ }
+ }
+
+ private void sendMetadataWithArtwork_syncCacheLock() {
+ if ((mCurrentClientGenId == mInternalClientGenId) && (mRcDisplay != null)) {
+ // even though we have already scaled in setArtwork(), when this client needs to
+ // send the bitmap, there might be newer and smaller expected dimensions, so we have
+ // to check again.
+ mArtwork = scaleBitmapIfTooBig(mArtwork, mArtworkExpectedWidth, mArtworkExpectedHeight);
+ try {
+ mRcDisplay.setAllMetadata(mInternalClientGenId, mMetadata, mArtwork);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error in setAllMetadata(), dead display "+e);
+ detachFromDisplay_syncCacheLock();
}
}
}