Merge "MediaRouter: Add getDeviceType() to RouteInfo"
diff --git a/api/current.txt b/api/current.txt
index 1e99d56..9d9b2f5 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -20733,6 +20733,7 @@
public static class MediaRouter.RouteInfo {
method public android.media.MediaRouter.RouteCategory getCategory();
method public java.lang.CharSequence getDescription();
+ method public int getDeviceType();
method public android.media.MediaRouter.RouteGroup getGroup();
method public android.graphics.drawable.Drawable getIconDrawable();
method public java.lang.CharSequence getName();
@@ -20751,6 +20752,10 @@
method public void requestSetVolume(int);
method public void requestUpdateVolume(int);
method public void setTag(java.lang.Object);
+ field public static final int DEVICE_TYPE_BLUETOOTH = 3; // 0x3
+ field public static final int DEVICE_TYPE_SPEAKER = 2; // 0x2
+ field public static final int DEVICE_TYPE_TV = 1; // 0x1
+ field public static final int DEVICE_TYPE_UNKNOWN = 0; // 0x0
field public static final int PLAYBACK_TYPE_LOCAL = 0; // 0x0
field public static final int PLAYBACK_TYPE_REMOTE = 1; // 0x1
field public static final int PLAYBACK_VOLUME_FIXED = 0; // 0x0
diff --git a/api/system-current.txt b/api/system-current.txt
index 8be751c..f9c8137 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -22026,6 +22026,7 @@
public static class MediaRouter.RouteInfo {
method public android.media.MediaRouter.RouteCategory getCategory();
method public java.lang.CharSequence getDescription();
+ method public int getDeviceType();
method public android.media.MediaRouter.RouteGroup getGroup();
method public android.graphics.drawable.Drawable getIconDrawable();
method public java.lang.CharSequence getName();
@@ -22044,6 +22045,10 @@
method public void requestSetVolume(int);
method public void requestUpdateVolume(int);
method public void setTag(java.lang.Object);
+ field public static final int DEVICE_TYPE_BLUETOOTH = 3; // 0x3
+ field public static final int DEVICE_TYPE_SPEAKER = 2; // 0x2
+ field public static final int DEVICE_TYPE_TV = 1; // 0x1
+ field public static final int DEVICE_TYPE_UNKNOWN = 0; // 0x0
field public static final int PLAYBACK_TYPE_LOCAL = 0; // 0x0
field public static final int PLAYBACK_TYPE_REMOTE = 1; // 0x1
field public static final int PLAYBACK_VOLUME_FIXED = 0; // 0x0
diff --git a/api/test-current.txt b/api/test-current.txt
index 3e455102..a59d03d 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -20733,6 +20733,7 @@
public static class MediaRouter.RouteInfo {
method public android.media.MediaRouter.RouteCategory getCategory();
method public java.lang.CharSequence getDescription();
+ method public int getDeviceType();
method public android.media.MediaRouter.RouteGroup getGroup();
method public android.graphics.drawable.Drawable getIconDrawable();
method public java.lang.CharSequence getName();
@@ -20751,6 +20752,10 @@
method public void requestSetVolume(int);
method public void requestUpdateVolume(int);
method public void setTag(java.lang.Object);
+ field public static final int DEVICE_TYPE_BLUETOOTH = 3; // 0x3
+ field public static final int DEVICE_TYPE_SPEAKER = 2; // 0x2
+ field public static final int DEVICE_TYPE_TV = 1; // 0x1
+ field public static final int DEVICE_TYPE_UNKNOWN = 0; // 0x0
field public static final int PLAYBACK_TYPE_LOCAL = 0; // 0x0
field public static final int PLAYBACK_TYPE_REMOTE = 1; // 0x1
field public static final int PLAYBACK_VOLUME_FIXED = 0; // 0x0
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java
index a046512..bcc2b406 100644
--- a/media/java/android/media/MediaRouter.java
+++ b/media/java/android/media/MediaRouter.java
@@ -18,6 +18,7 @@
import android.Manifest;
import android.annotation.DrawableRes;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.app.ActivityThread;
import android.content.BroadcastReceiver;
@@ -41,6 +42,8 @@
import android.util.Log;
import android.view.Display;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -201,6 +204,7 @@
info.mDescription = sStatic.mResources.getText(
com.android.internal.R.string.bluetooth_a2dp_audio_route_name);
info.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO;
+ info.mDeviceType = RouteInfo.DEVICE_TYPE_BLUETOOTH;
sStatic.mBluetoothA2dpRoute = info;
addRouteStatic(sStatic.mBluetoothA2dpRoute);
} else {
@@ -480,6 +484,7 @@
route.mName = globalRoute.name;
route.mDescription = globalRoute.description;
route.mSupportedTypes = globalRoute.supportedTypes;
+ route.mDeviceType = globalRoute.deviceType;
route.mEnabled = globalRoute.enabled;
route.setRealStatusCode(globalRoute.statusCode);
route.mPlaybackType = globalRoute.playbackType;
@@ -1411,6 +1416,7 @@
newRoute.mDescription = sStatic.mResources.getText(
com.android.internal.R.string.wireless_display_route_description);
newRoute.updatePresentationDisplay();
+ newRoute.mDeviceType = RouteInfo.DEVICE_TYPE_TV;
return newRoute;
}
@@ -1470,6 +1476,7 @@
CharSequence mDescription;
private CharSequence mStatus;
int mSupportedTypes;
+ int mDeviceType;
RouteGroup mGroup;
final RouteCategory mCategory;
Drawable mIcon;
@@ -1502,6 +1509,42 @@
/** @hide */ public static final int STATUS_IN_USE = 5;
/** @hide */ public static final int STATUS_CONNECTED = 6;
+ /** @hide */
+ @IntDef({DEVICE_TYPE_UNKNOWN, DEVICE_TYPE_TV, DEVICE_TYPE_SPEAKER, DEVICE_TYPE_BLUETOOTH})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface DeviceType {}
+
+ /**
+ * The default receiver device type of the route indicating the type is unknown.
+ *
+ * @see #getDeviceType
+ */
+ public static final int DEVICE_TYPE_UNKNOWN = 0;
+
+ /**
+ * A receiver device type of the route indicating the presentation of the media is happening
+ * on a TV.
+ *
+ * @see #getDeviceType
+ */
+ public static final int DEVICE_TYPE_TV = 1;
+
+ /**
+ * A receiver device type of the route indicating the presentation of the media is happening
+ * on a speaker.
+ *
+ * @see #getDeviceType
+ */
+ public static final int DEVICE_TYPE_SPEAKER = 2;
+
+ /**
+ * A receiver device type of the route indicating the presentation of the media is happening
+ * on a bluetooth device such as a bluetooth speaker.
+ *
+ * @see #getDeviceType
+ */
+ public static final int DEVICE_TYPE_BLUETOOTH = 3;
+
private Object mTag;
/**
@@ -1533,6 +1576,7 @@
RouteInfo(RouteCategory category) {
mCategory = category;
+ mDeviceType = DEVICE_TYPE_UNKNOWN;
}
/**
@@ -1670,6 +1714,18 @@
return mSupportedTypes;
}
+ /**
+ * Gets the type of the receiver device associated with this route.
+ *
+ * @return The type of the receiver device associated with this route:
+ * {@link #DEVICE_TYPE_BLUETOOTH}, {@link #DEVICE_TYPE_TV}, {@link #DEVICE_TYPE_SPEAKER},
+ * or {@link #DEVICE_TYPE_UNKNOWN}.
+ */
+ @DeviceType
+ public int getDeviceType() {
+ return mDeviceType;
+ }
+
/** @hide */
public boolean matchesTypes(int types) {
return (mSupportedTypes & types) != 0;
diff --git a/media/java/android/media/MediaRouterClientState.java b/media/java/android/media/MediaRouterClientState.java
index 54b8276..34e18f6 100644
--- a/media/java/android/media/MediaRouterClientState.java
+++ b/media/java/android/media/MediaRouterClientState.java
@@ -104,6 +104,7 @@
public int volumeMax;
public int volumeHandling;
public int presentationDisplayId;
+ public @MediaRouter.RouteInfo.DeviceType int deviceType;
public RouteInfo(String id) {
this.id = id;
@@ -113,6 +114,7 @@
playbackStream = -1;
volumeHandling = MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED;
presentationDisplayId = -1;
+ deviceType = MediaRouter.RouteInfo.DEVICE_TYPE_UNKNOWN;
}
public RouteInfo(RouteInfo other) {
@@ -128,6 +130,7 @@
volumeMax = other.volumeMax;
volumeHandling = other.volumeHandling;
presentationDisplayId = other.presentationDisplayId;
+ deviceType = other.deviceType;
}
RouteInfo(Parcel in) {
@@ -143,6 +146,7 @@
volumeMax = in.readInt();
volumeHandling = in.readInt();
presentationDisplayId = in.readInt();
+ deviceType = in.readInt();
}
@Override
@@ -164,6 +168,7 @@
dest.writeInt(volumeMax);
dest.writeInt(volumeHandling);
dest.writeInt(presentationDisplayId);
+ dest.writeInt(deviceType);
}
@Override
@@ -180,6 +185,7 @@
+ ", volumeMax=" + volumeMax
+ ", volumeHandling=" + volumeHandling
+ ", presentationDisplayId=" + presentationDisplayId
+ + ", deviceType=" + deviceType
+ " }";
}