Skip to content

Commit ae20ae1

Browse files
committed
More MediaRouter features.
Add RemoteControlClient to user routes. This will allow the UI layered on top to access info about the remote volume channel associated with a user route. Add icons for user routes and route groups. Change-Id: I438aa60fc8c93f878ec7638897225738155f0746
1 parent 68cefd2 commit ae20ae1

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

api/current.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11548,11 +11548,14 @@ package android.media {
1154811548
method public int getRouteCount();
1154911549
method public void removeRoute(android.media.MediaRouter.RouteInfo);
1155011550
method public void removeRoute(int);
11551+
method public void setIconDrawable(android.graphics.drawable.Drawable);
11552+
method public void setIconResource(int);
1155111553
}
1155211554

1155311555
public static class MediaRouter.RouteInfo {
1155411556
method public android.media.MediaRouter.RouteCategory getCategory();
1155511557
method public android.media.MediaRouter.RouteGroup getGroup();
11558+
method public android.graphics.drawable.Drawable getIconDrawable();
1155611559
method public java.lang.CharSequence getName();
1155711560
method public java.lang.CharSequence getStatus();
1155811561
method public int getSupportedTypes();
@@ -11570,7 +11573,10 @@ package android.media {
1157011573
}
1157111574

1157211575
public static class MediaRouter.UserRouteInfo extends android.media.MediaRouter.RouteInfo {
11576+
method public void setIconDrawable(android.graphics.drawable.Drawable);
11577+
method public void setIconResource(int);
1157311578
method public void setName(java.lang.CharSequence);
11579+
method public void setRemoteControlClient(android.media.RemoteControlClient);
1157411580
method public void setStatus(java.lang.CharSequence);
1157511581
}
1157611582

media/java/android/media/MediaRouter.java

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.content.Intent;
2323
import android.content.IntentFilter;
2424
import android.content.res.Resources;
25+
import android.graphics.drawable.Drawable;
2526
import android.os.Handler;
2627
import android.util.Log;
2728

@@ -492,6 +493,7 @@ public static class RouteInfo {
492493
int mSupportedTypes;
493494
RouteGroup mGroup;
494495
final RouteCategory mCategory;
496+
Drawable mIcon;
495497

496498
RouteInfo(RouteCategory category) {
497499
mCategory = category;
@@ -534,6 +536,16 @@ public RouteCategory getCategory() {
534536
return mCategory;
535537
}
536538

539+
/**
540+
* Get the icon representing this route.
541+
* This icon will be used in picker UIs if available.
542+
*
543+
* @return the icon representing this route or null if no icon is available
544+
*/
545+
public Drawable getIconDrawable() {
546+
return mIcon;
547+
}
548+
537549
void setStatusInt(CharSequence status) {
538550
if (!status.equals(mStatus)) {
539551
mStatus = status;
@@ -564,6 +576,7 @@ public String toString() {
564576
* @see MediaRouter.RouteInfo
565577
*/
566578
public static class UserRouteInfo extends RouteInfo {
579+
RemoteControlClient mRcc;
567580

568581
UserRouteInfo(RouteCategory category) {
569582
super(category);
@@ -587,6 +600,40 @@ public void setName(CharSequence name) {
587600
public void setStatus(CharSequence status) {
588601
setStatusInt(status);
589602
}
603+
604+
/**
605+
* Set the RemoteControlClient responsible for reporting playback info for this
606+
* user route.
607+
*
608+
* <p>If this route manages remote playback, the data exposed by this
609+
* RemoteControlClient will be used to reflect and update information
610+
* such as route volume info in related UIs.</p>
611+
*
612+
* @param rcc RemoteControlClient associated with this route
613+
*/
614+
public void setRemoteControlClient(RemoteControlClient rcc) {
615+
mRcc = rcc;
616+
}
617+
618+
/**
619+
* Set an icon that will be used to represent this route.
620+
* The system may use this icon in picker UIs or similar.
621+
*
622+
* @param icon icon drawable to use to represent this route
623+
*/
624+
public void setIconDrawable(Drawable icon) {
625+
mIcon = icon;
626+
}
627+
628+
/**
629+
* Set an icon that will be used to represent this route.
630+
* The system may use this icon in picker UIs or similar.
631+
*
632+
* @param icon Resource ID of an icon drawable to use to represent this route
633+
*/
634+
public void setIconResource(int resId) {
635+
setIconDrawable(sStatic.mResources.getDrawable(resId));
636+
}
590637
}
591638

592639
/**
@@ -695,6 +742,26 @@ public RouteInfo getRouteAt(int index) {
695742
return mRoutes.get(index);
696743
}
697744

745+
/**
746+
* Set an icon that will be used to represent this group.
747+
* The system may use this icon in picker UIs or similar.
748+
*
749+
* @param icon icon drawable to use to represent this group
750+
*/
751+
public void setIconDrawable(Drawable icon) {
752+
mIcon = icon;
753+
}
754+
755+
/**
756+
* Set an icon that will be used to represent this group.
757+
* The system may use this icon in picker UIs or similar.
758+
*
759+
* @param icon Resource ID of an icon drawable to use to represent this group
760+
*/
761+
public void setIconResource(int resId) {
762+
setIconDrawable(sStatic.mResources.getDrawable(resId));
763+
}
764+
698765
void memberNameChanged(RouteInfo info, CharSequence name) {
699766
mUpdateName = true;
700767
routeUpdated();

0 commit comments

Comments
 (0)