summaryrefslogtreecommitdiffstats
path: root/v4/api21/android
diff options
context:
space:
mode:
authorJae Seo <jaeseo@google.com>2015-11-05 00:29:39 -0800
committerJae Seo <jaeseo@google.com>2015-11-05 09:56:32 -0800
commitfef15ea991ce111e43b165ad5f12dccd6be9f1f2 (patch)
treed0a54366aca0a17f2417a4dde3d0a81b0fda3536 /v4/api21/android
parentc9d7594ade1d727f6e1c4bd797aaaeb553826db9 (diff)
downloadandroid_frameworks_support-fef15ea991ce111e43b165ad5f12dccd6be9f1f2.tar.gz
android_frameworks_support-fef15ea991ce111e43b165ad5f12dccd6be9f1f2.tar.bz2
android_frameworks_support-fef15ea991ce111e43b165ad5f12dccd6be9f1f2.zip
MediaRouter: Black magic to bring custom media metadata back
MediaMetadataCompat and MediaMetadata are internally converted into each other on platform version 21 or higher as the framework (e.g. MediaSession) does not understand MediaMetadataCompat. When this happens, custom key-value pairs are lost. The difficulty here is that the current framework API does not provide a way to tell the type of each custom key-value pair in MediaMetadata making it impossible to extract them while converting. This could've been avoided if there is a way to retrieve data as a generic object such as Object or Bundle but the current design offers get-methods only for specific types. The code change here tries to overcome this problem by copying the underlying Bundle object that represents the whole media metadata as is when performing the conversion hence preserving the entirety of the data. Care was taken to replace RatingCompat values in metadata with Rating values such that the metadata Bundle can be unmarshalled on the framework side. Bug: 25328581 Change-Id: Ic83b73e18e31baf9446ca845b7e49aa508b3f108
Diffstat (limited to 'v4/api21/android')
-rw-r--r--v4/api21/android/support/v4/media/MediaMetadataCompatApi21.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/v4/api21/android/support/v4/media/MediaMetadataCompatApi21.java b/v4/api21/android/support/v4/media/MediaMetadataCompatApi21.java
index eddcf76944..fd51f783ce 100644
--- a/v4/api21/android/support/v4/media/MediaMetadataCompatApi21.java
+++ b/v4/api21/android/support/v4/media/MediaMetadataCompatApi21.java
@@ -19,6 +19,7 @@ package android.support.v4.media;
import android.graphics.Bitmap;
import android.media.MediaMetadata;
import android.media.Rating;
+import android.os.Parcel;
import java.util.Set;
@@ -43,6 +44,14 @@ class MediaMetadataCompatApi21 {
return ((MediaMetadata) metadataObj).getText(key);
}
+ public static void writeToParcel(Object metadataObj, Parcel dest, int flags) {
+ ((MediaMetadata) metadataObj).writeToParcel(dest, flags);
+ }
+
+ public static Object createFromParcel(Parcel in) {
+ return MediaMetadata.CREATOR.createFromParcel(in);
+ }
+
public static class Builder {
public static Object newInstance() {
return new MediaMetadata.Builder();