Loading media/java/android/media/AudioManager.java +54 −0 Original line number Diff line number Diff line Loading @@ -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 /** Loading media/java/android/media/IRemoteControlDisplay.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -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); } media/java/android/media/RemoteControlClient.java +27 −17 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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; /** Loading Loading @@ -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(); } } } Loading @@ -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(); } } } Loading @@ -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(); } } } Loading @@ -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(); } } } Loading Loading
media/java/android/media/AudioManager.java +54 −0 Original line number Diff line number Diff line Loading @@ -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 /** Loading
media/java/android/media/IRemoteControlDisplay.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -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); }
media/java/android/media/RemoteControlClient.java +27 −17 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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; /** Loading Loading @@ -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(); } } } Loading @@ -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(); } } } Loading @@ -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(); } } } Loading @@ -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(); } } } Loading