Loading media/java/android/media/RemoteControlClient.java +131 −88 Original line number Original line Diff line number Diff line Loading @@ -240,50 +240,25 @@ public class RemoteControlClient * Class used to modify metadata in a {@link RemoteControlClient} object. * Class used to modify metadata in a {@link RemoteControlClient} object. */ */ public class MetadataEditor { public class MetadataEditor { protected boolean mMetadataChanged; protected boolean mArtworkChanged; protected Bitmap mEditorArtwork; protected Bundle mEditorMetadata; private boolean mApplied = false; private MetadataEditor() { /* only use factory */ } // only use RemoteControlClient.editMetadata() to get a MetadataEditor instance private MetadataEditor() { } public MetadataEditor putString(int key, String value) { return this; } public MetadataEditor putBitmap(int key, Bitmap bitmap) { return this; } public void clear() { } public void apply() { } } public MetadataEditor editMetadata(boolean startEmpty) { return (new MetadataEditor()); } /** /** * @hide * @hide * FIXME migrate this functionality under MetadataEditor * Start collecting information to be displayed. * Use {@link #commitMetadata()} to signal the end of the collection which has been created * through one or multiple calls to {@link #addMetadataString(int, int, String)}. */ */ public void startMetadata() { public Object clone() throws CloneNotSupportedException { synchronized(mCacheLock) { throw new CloneNotSupportedException(); mMetadata.clear(); } } } /** /** * @hide * FIXME migrate this functionality under MetadataEditor * Adds textual information to be displayed. * Adds textual information to be displayed. * Note that none of the information added before {@link #startMetadata()}, * Note that none of the information added after {@link #apply()} has been called, * and after {@link #commitMetadata()} has been called, will be displayed. * will be displayed. * @param key the identifier of a the metadata field to set. Valid values are * @param key the identifier of a the metadata field to set. Valid values are * {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUM}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUM}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUMARTIST}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUMARTIST}, Loading @@ -300,49 +275,113 @@ public class RemoteControlClient * {@link android.media.MediaMetadataRetriever#METADATA_KEY_TITLE}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_TITLE}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_WRITER}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_WRITER}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_YEAR}. * {@link android.media.MediaMetadataRetriever#METADATA_KEY_YEAR}. * @param value the String for the field value, or null to signify there is no valid * @param value the text for the given key, or null to signify there is no valid * information for the field. * information for the field. * @return FIXME description */ */ public void addMetadataString(int key, String value) { public synchronized MetadataEditor putString(int key, String value) { synchronized(mCacheLock) { if (mApplied) { // store locally Log.e(TAG, "Can't edit a previously applied MetadataEditor"); mMetadata.putString(String.valueOf(key), value); return this; } } mEditorMetadata.putString(String.valueOf(key), value); mMetadataChanged = true; return this; } } /** /** * @hide * The metadata key for the content artwork / album art. * FIXME migrate this functionality under MetadataEditor * Marks all the metadata previously set with {@link #addMetadataString(int, int, String)} as * eligible to be displayed. */ */ public void commitMetadata() { public final int METADATA_KEY_ARTWORK = 100; synchronized(mCacheLock) { // send to remote control display if conditions are met sendMetadata_syncCacheLock(); } } /** /** * @hide * FIXME migrate this functionality under MetadataEditor * Sets the album / artwork picture to be displayed on the remote control. * Sets the album / artwork picture to be displayed on the remote control. * @param artwork the bitmap for the artwork, or null if there isn't any. * @param key FIXME description * @param bitmap the bitmap for the artwork, or null if there isn't any. * @return FIXME description * @see android.graphics.Bitmap * @see android.graphics.Bitmap */ */ public void setArtwork(Bitmap artwork) { public synchronized MetadataEditor putBitmap(int key, Bitmap bitmap) { synchronized(mCacheLock) { if (mApplied) { // resize and store locally Log.e(TAG, "Can't edit a previously applied MetadataEditor"); if (mArtworkExpectedWidth > 0) { return this; mArtwork = scaleBitmapIfTooBig(artwork, } if (key != METADATA_KEY_ARTWORK) { return this; } if ((mArtworkExpectedWidth > 0) && (mArtworkExpectedHeight > 0)) { mEditorArtwork = scaleBitmapIfTooBig(bitmap, mArtworkExpectedWidth, mArtworkExpectedHeight); mArtworkExpectedWidth, mArtworkExpectedHeight); } else { } else { // no valid resize dimensions, store as is // no valid resize dimensions, store as is mArtwork = artwork; mEditorArtwork = bitmap; } } mArtworkChanged = true; return this; } /** * FIXME description */ public synchronized void clear() { if (mApplied) { Log.e(TAG, "Can't clear a previously applied MetadataEditor"); return; } mEditorMetadata.clear(); mEditorArtwork = null; } /** * FIXME description */ public synchronized void apply() { if (mApplied) { Log.e(TAG, "Can't apply a previously applied MetadataEditor"); return; } synchronized(mCacheLock) { // assign the edited data 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(); } else if (mMetadataChanged) { // send to remote control display if conditions are met sendMetadata_syncCacheLock(); } else if (mArtworkChanged) { // send to remote control display if conditions are met // send to remote control display if conditions are met sendArtwork_syncCacheLock(); sendArtwork_syncCacheLock(); } } mApplied = true; } } } /** * FIXME description * @param startEmpty * @return */ public MetadataEditor editMetadata(boolean startEmpty) { MetadataEditor editor = new MetadataEditor(); if (startEmpty) { editor.mEditorMetadata = new Bundle(); editor.mEditorArtwork = null; editor.mMetadataChanged = true; editor.mArtworkChanged = true; } else { editor.mEditorMetadata = new Bundle(mMetadata); editor.mEditorArtwork = mArtwork; editor.mMetadataChanged = false; editor.mArtworkChanged = false; } return editor; } } /** /** Loading Loading @@ -402,6 +441,9 @@ public class RemoteControlClient /** /** * Cache for the artwork bitmap. * Cache for the artwork bitmap. * Access synchronized on mCacheLock * Access synchronized on mCacheLock * Artwork and metadata are not kept in one Bundle because the bitmap sometimes needs to be * accessed to be resized, in which case a copy will be made. This would add overhead in * Bundle operations. */ */ private Bitmap mArtwork; private Bitmap mArtwork; private final int ARTWORK_DEFAULT_SIZE = 256; private final int ARTWORK_DEFAULT_SIZE = 256; Loading @@ -417,6 +459,7 @@ public class RemoteControlClient * Access synchronized on mCacheLock * Access synchronized on mCacheLock */ */ private Bundle mMetadata = new Bundle(); private Bundle mMetadata = new Bundle(); /** /** * The current remote control client generation ID across the system * The current remote control client generation ID across the system */ */ Loading Loading
media/java/android/media/RemoteControlClient.java +131 −88 Original line number Original line Diff line number Diff line Loading @@ -240,50 +240,25 @@ public class RemoteControlClient * Class used to modify metadata in a {@link RemoteControlClient} object. * Class used to modify metadata in a {@link RemoteControlClient} object. */ */ public class MetadataEditor { public class MetadataEditor { protected boolean mMetadataChanged; protected boolean mArtworkChanged; protected Bitmap mEditorArtwork; protected Bundle mEditorMetadata; private boolean mApplied = false; private MetadataEditor() { /* only use factory */ } // only use RemoteControlClient.editMetadata() to get a MetadataEditor instance private MetadataEditor() { } public MetadataEditor putString(int key, String value) { return this; } public MetadataEditor putBitmap(int key, Bitmap bitmap) { return this; } public void clear() { } public void apply() { } } public MetadataEditor editMetadata(boolean startEmpty) { return (new MetadataEditor()); } /** /** * @hide * @hide * FIXME migrate this functionality under MetadataEditor * Start collecting information to be displayed. * Use {@link #commitMetadata()} to signal the end of the collection which has been created * through one or multiple calls to {@link #addMetadataString(int, int, String)}. */ */ public void startMetadata() { public Object clone() throws CloneNotSupportedException { synchronized(mCacheLock) { throw new CloneNotSupportedException(); mMetadata.clear(); } } } /** /** * @hide * FIXME migrate this functionality under MetadataEditor * Adds textual information to be displayed. * Adds textual information to be displayed. * Note that none of the information added before {@link #startMetadata()}, * Note that none of the information added after {@link #apply()} has been called, * and after {@link #commitMetadata()} has been called, will be displayed. * will be displayed. * @param key the identifier of a the metadata field to set. Valid values are * @param key the identifier of a the metadata field to set. Valid values are * {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUM}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUM}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUMARTIST}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUMARTIST}, Loading @@ -300,49 +275,113 @@ public class RemoteControlClient * {@link android.media.MediaMetadataRetriever#METADATA_KEY_TITLE}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_TITLE}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_WRITER}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_WRITER}, * {@link android.media.MediaMetadataRetriever#METADATA_KEY_YEAR}. * {@link android.media.MediaMetadataRetriever#METADATA_KEY_YEAR}. * @param value the String for the field value, or null to signify there is no valid * @param value the text for the given key, or null to signify there is no valid * information for the field. * information for the field. * @return FIXME description */ */ public void addMetadataString(int key, String value) { public synchronized MetadataEditor putString(int key, String value) { synchronized(mCacheLock) { if (mApplied) { // store locally Log.e(TAG, "Can't edit a previously applied MetadataEditor"); mMetadata.putString(String.valueOf(key), value); return this; } } mEditorMetadata.putString(String.valueOf(key), value); mMetadataChanged = true; return this; } } /** /** * @hide * The metadata key for the content artwork / album art. * FIXME migrate this functionality under MetadataEditor * Marks all the metadata previously set with {@link #addMetadataString(int, int, String)} as * eligible to be displayed. */ */ public void commitMetadata() { public final int METADATA_KEY_ARTWORK = 100; synchronized(mCacheLock) { // send to remote control display if conditions are met sendMetadata_syncCacheLock(); } } /** /** * @hide * FIXME migrate this functionality under MetadataEditor * Sets the album / artwork picture to be displayed on the remote control. * Sets the album / artwork picture to be displayed on the remote control. * @param artwork the bitmap for the artwork, or null if there isn't any. * @param key FIXME description * @param bitmap the bitmap for the artwork, or null if there isn't any. * @return FIXME description * @see android.graphics.Bitmap * @see android.graphics.Bitmap */ */ public void setArtwork(Bitmap artwork) { public synchronized MetadataEditor putBitmap(int key, Bitmap bitmap) { synchronized(mCacheLock) { if (mApplied) { // resize and store locally Log.e(TAG, "Can't edit a previously applied MetadataEditor"); if (mArtworkExpectedWidth > 0) { return this; mArtwork = scaleBitmapIfTooBig(artwork, } if (key != METADATA_KEY_ARTWORK) { return this; } if ((mArtworkExpectedWidth > 0) && (mArtworkExpectedHeight > 0)) { mEditorArtwork = scaleBitmapIfTooBig(bitmap, mArtworkExpectedWidth, mArtworkExpectedHeight); mArtworkExpectedWidth, mArtworkExpectedHeight); } else { } else { // no valid resize dimensions, store as is // no valid resize dimensions, store as is mArtwork = artwork; mEditorArtwork = bitmap; } } mArtworkChanged = true; return this; } /** * FIXME description */ public synchronized void clear() { if (mApplied) { Log.e(TAG, "Can't clear a previously applied MetadataEditor"); return; } mEditorMetadata.clear(); mEditorArtwork = null; } /** * FIXME description */ public synchronized void apply() { if (mApplied) { Log.e(TAG, "Can't apply a previously applied MetadataEditor"); return; } synchronized(mCacheLock) { // assign the edited data 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(); } else if (mMetadataChanged) { // send to remote control display if conditions are met sendMetadata_syncCacheLock(); } else if (mArtworkChanged) { // send to remote control display if conditions are met // send to remote control display if conditions are met sendArtwork_syncCacheLock(); sendArtwork_syncCacheLock(); } } mApplied = true; } } } /** * FIXME description * @param startEmpty * @return */ public MetadataEditor editMetadata(boolean startEmpty) { MetadataEditor editor = new MetadataEditor(); if (startEmpty) { editor.mEditorMetadata = new Bundle(); editor.mEditorArtwork = null; editor.mMetadataChanged = true; editor.mArtworkChanged = true; } else { editor.mEditorMetadata = new Bundle(mMetadata); editor.mEditorArtwork = mArtwork; editor.mMetadataChanged = false; editor.mArtworkChanged = false; } return editor; } } /** /** Loading Loading @@ -402,6 +441,9 @@ public class RemoteControlClient /** /** * Cache for the artwork bitmap. * Cache for the artwork bitmap. * Access synchronized on mCacheLock * Access synchronized on mCacheLock * Artwork and metadata are not kept in one Bundle because the bitmap sometimes needs to be * accessed to be resized, in which case a copy will be made. This would add overhead in * Bundle operations. */ */ private Bitmap mArtwork; private Bitmap mArtwork; private final int ARTWORK_DEFAULT_SIZE = 256; private final int ARTWORK_DEFAULT_SIZE = 256; Loading @@ -417,6 +459,7 @@ public class RemoteControlClient * Access synchronized on mCacheLock * Access synchronized on mCacheLock */ */ private Bundle mMetadata = new Bundle(); private Bundle mMetadata = new Bundle(); /** /** * The current remote control client generation ID across the system * The current remote control client generation ID across the system */ */ Loading