Merge changes If4c38bfe,Id9878186 into lmp-mr1-dev

* changes:
  Update metadata artwork and uri docs
  skip MediaController callbacks if it's been unregistered
This commit is contained in:
RoboErik
2014-11-06 21:20:17 +00:00
committed by Android (Google) Code Review
2 changed files with 35 additions and 0 deletions

View File

@@ -122,6 +122,10 @@ public final class MediaMetadata implements Parcelable {
/** /**
* The artwork for the media as a {@link Bitmap}. * The artwork for the media as a {@link Bitmap}.
* <p>
* The artwork should be relatively small and may be scaled down by the
* system if it is too large. For higher resolution artwork
* {@link #METADATA_KEY_ART_URI} should be used instead.
*/ */
public static final String METADATA_KEY_ART = "android.media.metadata.ART"; public static final String METADATA_KEY_ART = "android.media.metadata.ART";
@@ -129,12 +133,20 @@ public final class MediaMetadata implements Parcelable {
* The artwork for the media as a Uri formatted String. The artwork can be * The artwork for the media as a Uri formatted String. The artwork can be
* loaded using a combination of {@link ContentResolver#openInputStream} and * loaded using a combination of {@link ContentResolver#openInputStream} and
* {@link BitmapFactory#decodeStream}. * {@link BitmapFactory#decodeStream}.
* <p>
* For the best results, Uris should use the content:// style and support
* {@link ContentResolver#EXTRA_SIZE} for retrieving scaled artwork through
* {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
*/ */
public static final String METADATA_KEY_ART_URI = "android.media.metadata.ART_URI"; public static final String METADATA_KEY_ART_URI = "android.media.metadata.ART_URI";
/** /**
* The artwork for the album of the media's original source as a * The artwork for the album of the media's original source as a
* {@link Bitmap}. * {@link Bitmap}.
* <p>
* The artwork should be relatively small and may be scaled down by the
* system if it is too large. For higher resolution artwork
* {@link #METADATA_KEY_ALBUM_ART_URI} should be used instead.
*/ */
public static final String METADATA_KEY_ALBUM_ART = "android.media.metadata.ALBUM_ART"; public static final String METADATA_KEY_ALBUM_ART = "android.media.metadata.ALBUM_ART";
@@ -143,6 +155,10 @@ public final class MediaMetadata implements Parcelable {
* formatted String. The artwork can be loaded using a combination of * formatted String. The artwork can be loaded using a combination of
* {@link ContentResolver#openInputStream} and * {@link ContentResolver#openInputStream} and
* {@link BitmapFactory#decodeStream}. * {@link BitmapFactory#decodeStream}.
* <p>
* For the best results, Uris should use the content:// style and support
* {@link ContentResolver#EXTRA_SIZE} for retrieving scaled artwork through
* {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
*/ */
public static final String METADATA_KEY_ALBUM_ART_URI = "android.media.metadata.ALBUM_ART_URI"; public static final String METADATA_KEY_ALBUM_ART_URI = "android.media.metadata.ALBUM_ART_URI";
@@ -188,6 +204,10 @@ public final class MediaMetadata implements Parcelable {
* An icon or thumbnail that is suitable for display to the user. When * An icon or thumbnail that is suitable for display to the user. When
* displaying an icon for media described by this metadata this should be * displaying an icon for media described by this metadata this should be
* preferred to other fields if present. This must be a {@link Bitmap}. * preferred to other fields if present. This must be a {@link Bitmap}.
* <p>
* The icon should be relatively small and may be scaled down by the system
* if it is too large. For higher resolution artwork
* {@link #METADATA_KEY_DISPLAY_ICON_URI} should be used instead.
*/ */
public static final String METADATA_KEY_DISPLAY_ICON public static final String METADATA_KEY_DISPLAY_ICON
= "android.media.metadata.DISPLAY_ICON"; = "android.media.metadata.DISPLAY_ICON";
@@ -199,6 +219,10 @@ public final class MediaMetadata implements Parcelable {
* fields when present. The icon can be loaded using a combination of * fields when present. The icon can be loaded using a combination of
* {@link ContentResolver#openInputStream} and * {@link ContentResolver#openInputStream} and
* {@link BitmapFactory#decodeStream}. * {@link BitmapFactory#decodeStream}.
* <p>
* For the best results, Uris should use the content:// style and support
* {@link ContentResolver#EXTRA_SIZE} for retrieving scaled artwork through
* {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
*/ */
public static final String METADATA_KEY_DISPLAY_ICON_URI public static final String METADATA_KEY_DISPLAY_ICON_URI
= "android.media.metadata.DISPLAY_ICON_URI"; = "android.media.metadata.DISPLAY_ICON_URI";
@@ -602,6 +626,11 @@ public final class MediaMetadata implements Parcelable {
* <li>{@link #METADATA_KEY_DISPLAY_DESCRIPTION}</li> * <li>{@link #METADATA_KEY_DISPLAY_DESCRIPTION}</li>
* <li>{@link #METADATA_KEY_DISPLAY_ICON_URI}</li> * <li>{@link #METADATA_KEY_DISPLAY_ICON_URI}</li>
* </ul> * </ul>
* <p>
* Uris for artwork should use the content:// style and support
* {@link ContentResolver#EXTRA_SIZE} for retrieving scaled artwork
* through {@link ContentResolver#openTypedAssetFileDescriptor(Uri,
* String, Bundle)}.
* *
* @param key The key for referencing this value * @param key The key for referencing this value
* @param value The String value to store * @param value The String value to store

View File

@@ -449,6 +449,7 @@ public final class MediaController {
} }
MessageHandler holder = new MessageHandler(handler.getLooper(), cb); MessageHandler holder = new MessageHandler(handler.getLooper(), cb);
mCallbacks.add(holder); mCallbacks.add(holder);
holder.mRegistered = true;
if (!mCbRegistered) { if (!mCbRegistered) {
try { try {
@@ -467,6 +468,7 @@ public final class MediaController {
if (cb == handler.mCallback) { if (cb == handler.mCallback) {
mCallbacks.remove(i); mCallbacks.remove(i);
success = true; success = true;
handler.mRegistered = false;
} }
} }
if (mCbRegistered && mCallbacks.size() == 0) { if (mCbRegistered && mCallbacks.size() == 0) {
@@ -956,6 +958,7 @@ public final class MediaController {
private final static class MessageHandler extends Handler { private final static class MessageHandler extends Handler {
private final MediaController.Callback mCallback; private final MediaController.Callback mCallback;
private boolean mRegistered = false;
public MessageHandler(Looper looper, MediaController.Callback cb) { public MessageHandler(Looper looper, MediaController.Callback cb) {
super(looper, null, true); super(looper, null, true);
@@ -964,6 +967,9 @@ public final class MediaController {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
if (!mRegistered) {
return;
}
switch (msg.what) { switch (msg.what) {
case MSG_EVENT: case MSG_EVENT:
mCallback.onSessionEvent((String) msg.obj, msg.getData()); mCallback.onSessionEvent((String) msg.obj, msg.getData());