MediaRouter: Add getDeviceType() to RouteInfo

Bug: 24777080
Change-Id: I5d7b44ec84371fbb9560578ece439e1a00dcdd50
This commit is contained in:
Insun Kang
2015-11-11 14:44:45 +09:00
parent dc89e079ce
commit 9dd66417ea
5 changed files with 77 additions and 0 deletions

View File

@@ -20736,6 +20736,7 @@ package android.media {
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();
@@ -20754,6 +20755,10 @@ package android.media {
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

View File

@@ -22026,6 +22026,7 @@ package android.media {
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 @@ package android.media {
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

View File

@@ -20736,6 +20736,7 @@ package android.media {
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();
@@ -20754,6 +20755,10 @@ package android.media {
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

View File

@@ -18,6 +18,7 @@ package android.media;
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.text.TextUtils;
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 @@ public class MediaRouter {
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 @@ public class MediaRouter {
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 @@ public class MediaRouter {
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 @@ public class MediaRouter {
CharSequence mDescription;
private CharSequence mStatus;
int mSupportedTypes;
int mDeviceType;
RouteGroup mGroup;
final RouteCategory mCategory;
Drawable mIcon;
@@ -1502,6 +1509,42 @@ public class MediaRouter {
/** @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 @@ public class MediaRouter {
RouteInfo(RouteCategory category) {
mCategory = category;
mDeviceType = DEVICE_TYPE_UNKNOWN;
}
/**
@@ -1670,6 +1714,18 @@ public class MediaRouter {
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;

View File

@@ -104,6 +104,7 @@ public final class MediaRouterClientState implements Parcelable {
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 @@ public final class MediaRouterClientState implements Parcelable {
playbackStream = -1;
volumeHandling = MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED;
presentationDisplayId = -1;
deviceType = MediaRouter.RouteInfo.DEVICE_TYPE_UNKNOWN;
}
public RouteInfo(RouteInfo other) {
@@ -128,6 +130,7 @@ public final class MediaRouterClientState implements Parcelable {
volumeMax = other.volumeMax;
volumeHandling = other.volumeHandling;
presentationDisplayId = other.presentationDisplayId;
deviceType = other.deviceType;
}
RouteInfo(Parcel in) {
@@ -143,6 +146,7 @@ public final class MediaRouterClientState implements Parcelable {
volumeMax = in.readInt();
volumeHandling = in.readInt();
presentationDisplayId = in.readInt();
deviceType = in.readInt();
}
@Override
@@ -164,6 +168,7 @@ public final class MediaRouterClientState implements Parcelable {
dest.writeInt(volumeMax);
dest.writeInt(volumeHandling);
dest.writeInt(presentationDisplayId);
dest.writeInt(deviceType);
}
@Override
@@ -180,6 +185,7 @@ public final class MediaRouterClientState implements Parcelable {
+ ", volumeMax=" + volumeMax
+ ", volumeHandling=" + volumeHandling
+ ", presentationDisplayId=" + presentationDisplayId
+ ", deviceType=" + deviceType
+ " }";
}