Merge "Further work on MediaRouter" into jb-dev
This commit is contained in:
91
api/16.txt
91
api/16.txt
@@ -675,6 +675,7 @@ package android {
|
||||
field public static final int maxWidth = 16843039; // 0x101011f
|
||||
field public static final int measureAllChildren = 16843018; // 0x101010a
|
||||
field public static final int measureWithLargestChild = 16843476; // 0x10102d4
|
||||
field public static final int mediaRouteButtonStyle = 16843693; // 0x10103ad
|
||||
field public static final int menuCategory = 16843230; // 0x10101de
|
||||
field public static final int mimeType = 16842790; // 0x1010026
|
||||
field public static final int minDate = 16843583; // 0x101033f
|
||||
@@ -1789,6 +1790,7 @@ package android {
|
||||
field public static final int Widget_DeviceDefault_Light_ListPopupWindow = 16974235; // 0x103019b
|
||||
field public static final int Widget_DeviceDefault_Light_ListView = 16974210; // 0x1030182
|
||||
field public static final int Widget_DeviceDefault_Light_ListView_DropDown = 16974205; // 0x103017d
|
||||
field public static final int Widget_DeviceDefault_Light_MediaRouteButton = 16974296; // 0x10301d8
|
||||
field public static final int Widget_DeviceDefault_Light_PopupMenu = 16974236; // 0x103019c
|
||||
field public static final int Widget_DeviceDefault_Light_PopupWindow = 16974211; // 0x1030183
|
||||
field public static final int Widget_DeviceDefault_Light_ProgressBar = 16974212; // 0x1030184
|
||||
@@ -1814,6 +1816,7 @@ package android {
|
||||
field public static final int Widget_DeviceDefault_ListPopupWindow = 16974180; // 0x1030164
|
||||
field public static final int Widget_DeviceDefault_ListView = 16974158; // 0x103014e
|
||||
field public static final int Widget_DeviceDefault_ListView_DropDown = 16974153; // 0x1030149
|
||||
field public static final int Widget_DeviceDefault_MediaRouteButton = 16974295; // 0x10301d7
|
||||
field public static final int Widget_DeviceDefault_PopupMenu = 16974181; // 0x1030165
|
||||
field public static final int Widget_DeviceDefault_PopupWindow = 16974159; // 0x103014f
|
||||
field public static final int Widget_DeviceDefault_ProgressBar = 16974160; // 0x1030150
|
||||
@@ -1905,6 +1908,7 @@ package android {
|
||||
field public static final int Widget_Holo_Light_ListPopupWindow = 16974043; // 0x10300db
|
||||
field public static final int Widget_Holo_Light_ListView = 16974018; // 0x10300c2
|
||||
field public static final int Widget_Holo_Light_ListView_DropDown = 16974013; // 0x10300bd
|
||||
field public static final int Widget_Holo_Light_MediaRouteButton = 16974294; // 0x10301d6
|
||||
field public static final int Widget_Holo_Light_PopupMenu = 16974044; // 0x10300dc
|
||||
field public static final int Widget_Holo_Light_PopupWindow = 16974019; // 0x10300c3
|
||||
field public static final int Widget_Holo_Light_ProgressBar = 16974020; // 0x10300c4
|
||||
@@ -1930,6 +1934,7 @@ package android {
|
||||
field public static final int Widget_Holo_ListPopupWindow = 16973997; // 0x10300ad
|
||||
field public static final int Widget_Holo_ListView = 16973975; // 0x1030097
|
||||
field public static final int Widget_Holo_ListView_DropDown = 16973970; // 0x1030092
|
||||
field public static final int Widget_Holo_MediaRouteButton = 16974293; // 0x10301d5
|
||||
field public static final int Widget_Holo_PopupMenu = 16973998; // 0x10300ae
|
||||
field public static final int Widget_Holo_PopupWindow = 16973976; // 0x1030098
|
||||
field public static final int Widget_Holo_ProgressBar = 16973977; // 0x1030099
|
||||
@@ -3671,6 +3676,20 @@ package android.app {
|
||||
method public android.view.Window startActivity(java.lang.String, android.content.Intent);
|
||||
}
|
||||
|
||||
public class MediaRouteActionProvider extends android.view.ActionProvider {
|
||||
ctor public MediaRouteActionProvider(android.content.Context);
|
||||
method public android.view.View onCreateActionView();
|
||||
method public void setRouteTypes(int);
|
||||
}
|
||||
|
||||
public class MediaRouteButton extends android.view.View {
|
||||
ctor public MediaRouteButton(android.content.Context);
|
||||
ctor public MediaRouteButton(android.content.Context, android.util.AttributeSet);
|
||||
ctor public MediaRouteButton(android.content.Context, android.util.AttributeSet, int);
|
||||
method public int getRouteTypes();
|
||||
method public void setRouteTypes(int);
|
||||
}
|
||||
|
||||
public class NativeActivity extends android.app.Activity implements android.view.InputQueue.Callback android.view.SurfaceHolder.Callback2 android.view.ViewTreeObserver.OnGlobalLayoutListener {
|
||||
ctor public NativeActivity();
|
||||
method public void onGlobalLayout();
|
||||
@@ -11486,6 +11505,75 @@ package android.media {
|
||||
field public static final int DEFAULT = 0; // 0x0
|
||||
}
|
||||
|
||||
public class MediaRouter {
|
||||
method public void addCallback(int, android.media.MediaRouter.Callback);
|
||||
method public void addUserRoute(android.media.MediaRouter.UserRouteInfo);
|
||||
method public void clearUserRoutes();
|
||||
method public android.media.MediaRouter.RouteCategory createRouteCategory(java.lang.CharSequence, boolean);
|
||||
method public android.media.MediaRouter.UserRouteInfo createUserRoute(android.media.MediaRouter.RouteCategory);
|
||||
method public static android.media.MediaRouter forApplication(android.content.Context);
|
||||
method public android.media.MediaRouter.RouteCategory getCategoryAt(int);
|
||||
method public int getCategoryCount();
|
||||
method public android.media.MediaRouter.RouteInfo getRouteAt(int);
|
||||
method public int getRouteCount();
|
||||
method public android.media.MediaRouter.RouteInfo getSelectedRoute(int);
|
||||
method public void removeCallback(android.media.MediaRouter.Callback);
|
||||
method public void removeUserRoute(android.media.MediaRouter.UserRouteInfo);
|
||||
method public void selectRoute(int, android.media.MediaRouter.RouteInfo);
|
||||
field public static final int ROUTE_TYPE_LIVE_AUDIO = 1; // 0x1
|
||||
field public static final int ROUTE_TYPE_USER = 8388608; // 0x800000
|
||||
}
|
||||
|
||||
public static abstract interface MediaRouter.Callback {
|
||||
method public abstract void onRouteAdded(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteChanged(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteGrouped(android.media.MediaRouter, android.media.MediaRouter.RouteInfo, android.media.MediaRouter.RouteGroup, int);
|
||||
method public abstract void onRouteRemoved(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteSelected(android.media.MediaRouter, int, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteUngrouped(android.media.MediaRouter, android.media.MediaRouter.RouteInfo, android.media.MediaRouter.RouteGroup);
|
||||
method public abstract void onRouteUnselected(android.media.MediaRouter, int, android.media.MediaRouter.RouteInfo);
|
||||
}
|
||||
|
||||
public class MediaRouter.RouteCategory {
|
||||
method public java.lang.CharSequence getName();
|
||||
method public java.util.List<android.media.MediaRouter.RouteInfo> getRoutes(java.util.List<android.media.MediaRouter.RouteInfo>);
|
||||
method public int getSupportedTypes();
|
||||
method public boolean isGroupable();
|
||||
}
|
||||
|
||||
public class MediaRouter.RouteGroup extends android.media.MediaRouter.RouteInfo {
|
||||
method public void addRoute(android.media.MediaRouter.RouteInfo);
|
||||
method public void addRoute(android.media.MediaRouter.RouteInfo, int);
|
||||
method public android.media.MediaRouter.RouteInfo getRouteAt(int);
|
||||
method public int getRouteCount();
|
||||
method public void removeRoute(android.media.MediaRouter.RouteInfo);
|
||||
method public void removeRoute(int);
|
||||
}
|
||||
|
||||
public class MediaRouter.RouteInfo {
|
||||
method public android.media.MediaRouter.RouteCategory getCategory();
|
||||
method public android.media.MediaRouter.RouteGroup getGroup();
|
||||
method public java.lang.CharSequence getName();
|
||||
method public java.lang.CharSequence getStatus();
|
||||
method public int getSupportedTypes();
|
||||
}
|
||||
|
||||
public static class MediaRouter.SimpleCallback implements android.media.MediaRouter.Callback {
|
||||
ctor public MediaRouter.SimpleCallback();
|
||||
method public void onRouteAdded(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteChanged(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteGrouped(android.media.MediaRouter, android.media.MediaRouter.RouteInfo, android.media.MediaRouter.RouteGroup, int);
|
||||
method public void onRouteRemoved(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteSelected(android.media.MediaRouter, int, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteUngrouped(android.media.MediaRouter, android.media.MediaRouter.RouteInfo, android.media.MediaRouter.RouteGroup);
|
||||
method public void onRouteUnselected(android.media.MediaRouter, int, android.media.MediaRouter.RouteInfo);
|
||||
}
|
||||
|
||||
public class MediaRouter.UserRouteInfo extends android.media.MediaRouter.RouteInfo {
|
||||
method public void setName(java.lang.CharSequence);
|
||||
method public void setStatus(java.lang.CharSequence);
|
||||
}
|
||||
|
||||
public class MediaScannerConnection implements android.content.ServiceConnection {
|
||||
ctor public MediaScannerConnection(android.content.Context, android.media.MediaScannerConnection.MediaScannerConnectionClient);
|
||||
method public void connect();
|
||||
@@ -22710,7 +22798,8 @@ package android.view {
|
||||
public abstract class ActionProvider {
|
||||
ctor public ActionProvider(android.content.Context);
|
||||
method public boolean hasSubMenu();
|
||||
method public abstract android.view.View onCreateActionView();
|
||||
method public abstract deprecated android.view.View onCreateActionView();
|
||||
method public android.view.View onCreateActionView(android.view.MenuItem);
|
||||
method public boolean onPerformDefaultAction();
|
||||
method public void onPrepareSubMenu(android.view.SubMenu);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,6 @@ package android {
|
||||
field public static final java.lang.String RECORD_AUDIO = "android.permission.RECORD_AUDIO";
|
||||
field public static final java.lang.String REORDER_TASKS = "android.permission.REORDER_TASKS";
|
||||
field public static final deprecated java.lang.String RESTART_PACKAGES = "android.permission.RESTART_PACKAGES";
|
||||
field public static final java.lang.String ROUTE_MEDIA_OUTPUT = "android.permission.ROUTE_MEDIA_OUTPUT";
|
||||
field public static final java.lang.String SEND_SMS = "android.permission.SEND_SMS";
|
||||
field public static final java.lang.String SET_ACTIVITY_WATCHER = "android.permission.SET_ACTIVITY_WATCHER";
|
||||
field public static final java.lang.String SET_ALARM = "com.android.alarm.permission.SET_ALARM";
|
||||
@@ -11521,24 +11520,23 @@ package android.media {
|
||||
method public void removeCallback(android.media.MediaRouter.Callback);
|
||||
method public void removeUserRoute(android.media.MediaRouter.UserRouteInfo);
|
||||
method public void selectRoute(int, android.media.MediaRouter.RouteInfo);
|
||||
method public void setSelectedRouteVolume(int, float);
|
||||
field public static final int ROUTE_TYPE_LIVE_AUDIO = 1; // 0x1
|
||||
field public static final int ROUTE_TYPE_USER = 8388608; // 0x800000
|
||||
}
|
||||
|
||||
public static abstract interface MediaRouter.Callback {
|
||||
method public abstract void onRouteAdded(int, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteChanged(android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteRemoved(int, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteSelected(int, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteUnselected(int, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onVolumeChanged(int, float);
|
||||
method public abstract void onRouteAdded(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteChanged(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteGrouped(android.media.MediaRouter, android.media.MediaRouter.RouteInfo, android.media.MediaRouter.RouteGroup, int);
|
||||
method public abstract void onRouteRemoved(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteSelected(android.media.MediaRouter, int, android.media.MediaRouter.RouteInfo);
|
||||
method public abstract void onRouteUngrouped(android.media.MediaRouter, android.media.MediaRouter.RouteInfo, android.media.MediaRouter.RouteGroup);
|
||||
method public abstract void onRouteUnselected(android.media.MediaRouter, int, android.media.MediaRouter.RouteInfo);
|
||||
}
|
||||
|
||||
public class MediaRouter.RouteCategory {
|
||||
method public java.lang.CharSequence getName();
|
||||
method public android.media.MediaRouter.RouteInfo getRouteAt(int);
|
||||
method public int getRouteCount();
|
||||
method public java.util.List<android.media.MediaRouter.RouteInfo> getRoutes(java.util.List<android.media.MediaRouter.RouteInfo>);
|
||||
method public int getSupportedTypes();
|
||||
method public boolean isGroupable();
|
||||
}
|
||||
@@ -11546,6 +11544,8 @@ package android.media {
|
||||
public class MediaRouter.RouteGroup extends android.media.MediaRouter.RouteInfo {
|
||||
method public void addRoute(android.media.MediaRouter.RouteInfo);
|
||||
method public void addRoute(android.media.MediaRouter.RouteInfo, int);
|
||||
method public android.media.MediaRouter.RouteInfo getRouteAt(int);
|
||||
method public int getRouteCount();
|
||||
method public void removeRoute(android.media.MediaRouter.RouteInfo);
|
||||
method public void removeRoute(int);
|
||||
}
|
||||
@@ -11556,17 +11556,17 @@ package android.media {
|
||||
method public java.lang.CharSequence getName();
|
||||
method public java.lang.CharSequence getStatus();
|
||||
method public int getSupportedTypes();
|
||||
method public float getVolume();
|
||||
}
|
||||
|
||||
public static class MediaRouter.SimpleCallback implements android.media.MediaRouter.Callback {
|
||||
ctor public MediaRouter.SimpleCallback();
|
||||
method public void onRouteAdded(int, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteChanged(android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteRemoved(int, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteSelected(int, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteUnselected(int, android.media.MediaRouter.RouteInfo);
|
||||
method public void onVolumeChanged(int, float);
|
||||
method public void onRouteAdded(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteChanged(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteGrouped(android.media.MediaRouter, android.media.MediaRouter.RouteInfo, android.media.MediaRouter.RouteGroup, int);
|
||||
method public void onRouteRemoved(android.media.MediaRouter, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteSelected(android.media.MediaRouter, int, android.media.MediaRouter.RouteInfo);
|
||||
method public void onRouteUngrouped(android.media.MediaRouter, android.media.MediaRouter.RouteInfo, android.media.MediaRouter.RouteGroup);
|
||||
method public void onRouteUnselected(android.media.MediaRouter, int, android.media.MediaRouter.RouteInfo);
|
||||
}
|
||||
|
||||
public class MediaRouter.UserRouteInfo extends android.media.MediaRouter.RouteInfo {
|
||||
|
||||
@@ -87,12 +87,12 @@ public class MediaRouteActionProvider extends ActionProvider {
|
||||
|
||||
private class RouterCallback extends MediaRouter.SimpleCallback {
|
||||
@Override
|
||||
public void onRouteAdded(int type, RouteInfo info) {
|
||||
public void onRouteAdded(MediaRouter router, RouteInfo info) {
|
||||
mMenuItem.setVisible(mRouter.getRouteCount() > 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRouteRemoved(int type, RouteInfo info) {
|
||||
public void onRouteRemoved(MediaRouter router, RouteInfo info) {
|
||||
mMenuItem.setVisible(mRouter.getRouteCount() > 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,22 +262,22 @@ public class MediaRouteButton extends View {
|
||||
|
||||
private class MediaRouteCallback extends MediaRouter.SimpleCallback {
|
||||
@Override
|
||||
public void onRouteSelected(int type, RouteInfo info) {
|
||||
public void onRouteSelected(MediaRouter router, int type, RouteInfo info) {
|
||||
updateRemoteIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRouteUnselected(int type, RouteInfo info) {
|
||||
public void onRouteUnselected(MediaRouter router, int type, RouteInfo info) {
|
||||
updateRemoteIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRouteAdded(int type, RouteInfo info) {
|
||||
public void onRouteAdded(MediaRouter router, RouteInfo info) {
|
||||
updateRouteCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRouteRemoved(int type, RouteInfo info) {
|
||||
public void onRouteRemoved(MediaRouter router, RouteInfo info) {
|
||||
updateRouteCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -636,12 +636,6 @@
|
||||
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<!-- Allows an application to route media output to other devices. -->
|
||||
<permission android:name="android.permission.ROUTE_MEDIA_OUTPUT"
|
||||
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
|
||||
android:label="@string/permlab_route_media_output"
|
||||
android:description="@string/permdesc_route_media_output" />
|
||||
|
||||
<!-- =========================================== -->
|
||||
<!-- Permissions associated with telephony state -->
|
||||
<!-- =========================================== -->
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MediaRouter allows applications to control the routing of media channels
|
||||
@@ -119,16 +120,10 @@ public class MediaRouter {
|
||||
ROUTE_TYPE_LIVE_AUDIO, false);
|
||||
|
||||
registerReceivers();
|
||||
|
||||
createDefaultRoutes();
|
||||
}
|
||||
|
||||
private void registerReceivers() {
|
||||
final BroadcastReceiver volumeReceiver = new VolumeChangedBroadcastReceiver();
|
||||
mAppContext.registerReceiver(volumeReceiver,
|
||||
new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION));
|
||||
mRegisteredReceivers.add(volumeReceiver);
|
||||
|
||||
final IntentFilter speakerFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
|
||||
speakerFilter.addAction(Intent.ACTION_ANALOG_AUDIO_DOCK_PLUG);
|
||||
speakerFilter.addAction(Intent.ACTION_DIGITAL_AUDIO_DOCK_PLUG);
|
||||
@@ -152,11 +147,6 @@ public class MediaRouter {
|
||||
mDefaultAudio.mName = mAppContext.getText(
|
||||
com.android.internal.R.string.default_audio_route_name);
|
||||
mDefaultAudio.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO;
|
||||
final int maxMusicVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||
if (maxMusicVolume > 0) {
|
||||
mDefaultAudio.mVolume =
|
||||
mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) / maxMusicVolume;
|
||||
}
|
||||
addRoute(mDefaultAudio);
|
||||
}
|
||||
|
||||
@@ -183,23 +173,6 @@ public class MediaRouter {
|
||||
dispatchRouteChanged(mDefaultAudio);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set volume for the specified selected route types.
|
||||
*
|
||||
* @param types Volume will be set for these route types
|
||||
* @param volume Volume to set in the range 0.f (inaudible) to 1.f (full volume).
|
||||
*/
|
||||
public void setSelectedRouteVolume(int types, float volume) {
|
||||
if ((types & ROUTE_TYPE_LIVE_AUDIO) != 0 && mSelectedRoute == mDefaultAudio) {
|
||||
final int index = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, index, 0);
|
||||
}
|
||||
if ((types & ROUTE_TYPE_USER) != 0 && mSelectedRoute instanceof UserRouteInfo) {
|
||||
mSelectedRoute.mVolume = volume;
|
||||
dispatchVolumeChanged(ROUTE_TYPE_USER, volume);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a callback to listen to events about specific kinds of media routes.
|
||||
* If the specified callback is already registered, its registration will be updated for any
|
||||
@@ -236,6 +209,13 @@ public class MediaRouter {
|
||||
Log.w(TAG, "removeCallback(" + cb + "): callback not registered");
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the specified route to use for output of the given media types.
|
||||
*
|
||||
* @param types type flags indicating which types this route should be used for.
|
||||
* The route must support at least a subset.
|
||||
* @param route Route to select
|
||||
*/
|
||||
public void selectRoute(int types, RouteInfo route) {
|
||||
if (mSelectedRoute == route) return;
|
||||
|
||||
@@ -267,15 +247,23 @@ public class MediaRouter {
|
||||
if (!mCategories.contains(cat)) {
|
||||
mCategories.add(cat);
|
||||
}
|
||||
if (info.getCategory().isGroupable() && !(info instanceof RouteGroup)) {
|
||||
final boolean onlyRoute = mRoutes.isEmpty();
|
||||
if (cat.isGroupable() && !(info instanceof RouteGroup)) {
|
||||
// Enforce that any added route in a groupable category must be in a group.
|
||||
final RouteGroup group = new RouteGroup(info.getCategory());
|
||||
mRoutes.add(group);
|
||||
dispatchRouteAdded(group);
|
||||
|
||||
final int at = group.getRouteCount();
|
||||
group.addRoute(info);
|
||||
dispatchRouteGrouped(info, group, at);
|
||||
|
||||
info = group;
|
||||
} else {
|
||||
mRoutes.add(info);
|
||||
dispatchRouteAdded(info);
|
||||
}
|
||||
final boolean onlyRoute = mRoutes.isEmpty();
|
||||
mRoutes.add(info);
|
||||
dispatchRouteAdded(info);
|
||||
|
||||
if (onlyRoute) {
|
||||
selectRoute(info.getSupportedTypes(), info);
|
||||
}
|
||||
@@ -420,7 +408,7 @@ public class MediaRouter {
|
||||
for (int i = 0; i < count; i++) {
|
||||
final CallbackInfo cbi = mCallbacks.get(i);
|
||||
if ((cbi.type & type) != 0) {
|
||||
cbi.cb.onRouteSelected(type, info);
|
||||
cbi.cb.onRouteSelected(this, type, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -430,7 +418,7 @@ public class MediaRouter {
|
||||
for (int i = 0; i < count; i++) {
|
||||
final CallbackInfo cbi = mCallbacks.get(i);
|
||||
if ((cbi.type & type) != 0) {
|
||||
cbi.cb.onRouteUnselected(type, info);
|
||||
cbi.cb.onRouteUnselected(this, type, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -440,7 +428,7 @@ public class MediaRouter {
|
||||
for (int i = 0; i < count; i++) {
|
||||
final CallbackInfo cbi = mCallbacks.get(i);
|
||||
if ((cbi.type & info.mSupportedTypes) != 0) {
|
||||
cbi.cb.onRouteChanged(info);
|
||||
cbi.cb.onRouteChanged(this, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -450,7 +438,7 @@ public class MediaRouter {
|
||||
for (int i = 0; i < count; i++) {
|
||||
final CallbackInfo cbi = mCallbacks.get(i);
|
||||
if ((cbi.type & info.mSupportedTypes) != 0) {
|
||||
cbi.cb.onRouteAdded(info.mSupportedTypes, info);
|
||||
cbi.cb.onRouteAdded(this, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -460,17 +448,27 @@ public class MediaRouter {
|
||||
for (int i = 0; i < count; i++) {
|
||||
final CallbackInfo cbi = mCallbacks.get(i);
|
||||
if ((cbi.type & info.mSupportedTypes) != 0) {
|
||||
cbi.cb.onRouteRemoved(info.mSupportedTypes, info);
|
||||
cbi.cb.onRouteRemoved(this, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dispatchVolumeChanged(int type, float volume) {
|
||||
void dispatchRouteGrouped(RouteInfo info, RouteGroup group, int index) {
|
||||
final int count = mCallbacks.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final CallbackInfo cbi = mCallbacks.get(i);
|
||||
if ((cbi.type & type) != 0) {
|
||||
cbi.cb.onVolumeChanged(type, volume);
|
||||
if ((cbi.type & group.mSupportedTypes) != 0) {
|
||||
cbi.cb.onRouteGrouped(this, info, group, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dispatchRouteUngrouped(RouteInfo info, RouteGroup group) {
|
||||
final int count = mCallbacks.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final CallbackInfo cbi = mCallbacks.get(i);
|
||||
if ((cbi.type & group.mSupportedTypes) != 0) {
|
||||
cbi.cb.onRouteUngrouped(this, info, group);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -496,11 +494,9 @@ public class MediaRouter {
|
||||
int mSupportedTypes;
|
||||
RouteGroup mGroup;
|
||||
final RouteCategory mCategory;
|
||||
float mVolume;
|
||||
|
||||
RouteInfo(RouteCategory category) {
|
||||
mCategory = category;
|
||||
category.mRoutes.add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,13 +536,6 @@ public class MediaRouter {
|
||||
return mCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return This route's current volume setting.
|
||||
*/
|
||||
public float getVolume() {
|
||||
return mVolume;
|
||||
}
|
||||
|
||||
void setStatusInt(CharSequence status) {
|
||||
if (!status.equals(mStatus)) {
|
||||
mStatus = status;
|
||||
@@ -634,8 +623,10 @@ public class MediaRouter {
|
||||
"(Route category=" + route.getCategory() +
|
||||
" group category=" + mCategory + ")");
|
||||
}
|
||||
final int at = mRoutes.size();
|
||||
mRoutes.add(route);
|
||||
mUpdateName = true;
|
||||
dispatchRouteGrouped(route, this, at);
|
||||
routeUpdated();
|
||||
}
|
||||
|
||||
@@ -657,6 +648,7 @@ public class MediaRouter {
|
||||
}
|
||||
mRoutes.add(insertAt, route);
|
||||
mUpdateName = true;
|
||||
dispatchRouteGrouped(route, this, insertAt);
|
||||
routeUpdated();
|
||||
}
|
||||
|
||||
@@ -672,6 +664,7 @@ public class MediaRouter {
|
||||
}
|
||||
mRoutes.remove(route);
|
||||
mUpdateName = true;
|
||||
dispatchRouteUngrouped(route, this);
|
||||
routeUpdated();
|
||||
}
|
||||
|
||||
@@ -681,11 +674,29 @@ public class MediaRouter {
|
||||
* @param index index of the route to remove
|
||||
*/
|
||||
public void removeRoute(int index) {
|
||||
mRoutes.remove(index);
|
||||
RouteInfo route = mRoutes.remove(index);
|
||||
mUpdateName = true;
|
||||
dispatchRouteUngrouped(route, this);
|
||||
routeUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number of routes in this group
|
||||
*/
|
||||
public int getRouteCount() {
|
||||
return mRoutes.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the route in this group at the specified index
|
||||
*
|
||||
* @param index Index to fetch
|
||||
* @return The route at index
|
||||
*/
|
||||
public RouteInfo getRouteAt(int index) {
|
||||
return mRoutes.get(index);
|
||||
}
|
||||
|
||||
void memberNameChanged(RouteInfo info, CharSequence name) {
|
||||
mUpdateName = true;
|
||||
routeUpdated();
|
||||
@@ -712,7 +723,6 @@ public class MediaRouter {
|
||||
* Definition of a category of routes. All routes belong to a category.
|
||||
*/
|
||||
public class RouteCategory {
|
||||
final ArrayList<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
|
||||
CharSequence mName;
|
||||
int mTypes;
|
||||
final boolean mGroupable;
|
||||
@@ -731,20 +741,33 @@ public class MediaRouter {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of routes in this category
|
||||
*/
|
||||
public int getRouteCount() {
|
||||
return mRoutes.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a route from this category
|
||||
* Return the current list of routes in this category that have been added
|
||||
* to the MediaRouter.
|
||||
*
|
||||
* @param index Index from [0-getRouteCount)
|
||||
* @return the route at the given index
|
||||
* <p>This list will not include routes that are nested within RouteGroups.
|
||||
* A RouteGroup is treated as a single route within its category.</p>
|
||||
*
|
||||
* @param out a List to fill with the routes in this category. If this parameter is
|
||||
* non-null, it will be cleared, filled with the current routes with this
|
||||
* category, and returned. If this parameter is null, a new List will be
|
||||
* allocated to report the category's current routes.
|
||||
* @return A list with the routes in this category that have been added to the MediaRouter.
|
||||
*/
|
||||
public RouteInfo getRouteAt(int index) {
|
||||
return mRoutes.get(index);
|
||||
public List<RouteInfo> getRoutes(List<RouteInfo> out) {
|
||||
if (out == null) {
|
||||
out = new ArrayList<RouteInfo>();
|
||||
} else {
|
||||
out.clear();
|
||||
}
|
||||
|
||||
final int count = getRouteCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final RouteInfo route = getRouteAt(i);
|
||||
if (route.mCategory == this) {
|
||||
out.add(route);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -758,7 +781,7 @@ public class MediaRouter {
|
||||
* Return whether or not this category supports grouping.
|
||||
*
|
||||
* <p>If this method returns true, all routes obtained from this category
|
||||
* via calls to {@link #getRouteAt(int)} will be {@link MediaRouter.RouteGroup}s.
|
||||
* via calls to {@link #getRouteAt(int)} will be {@link MediaRouter.RouteGroup}s.</p>
|
||||
*
|
||||
* @return true if this category supports
|
||||
*/
|
||||
@@ -797,43 +820,37 @@ public class MediaRouter {
|
||||
* Called when the supplied route becomes selected as the active route
|
||||
* for the given route type.
|
||||
*
|
||||
* @param router the MediaRouter reporting the event
|
||||
* @param type Type flag set indicating the routes that have been selected
|
||||
* @param info Route that has been selected for the given route types
|
||||
*/
|
||||
public void onRouteSelected(int type, RouteInfo info);
|
||||
public void onRouteSelected(MediaRouter router, int type, RouteInfo info);
|
||||
|
||||
/**
|
||||
* Called when the supplied route becomes unselected as the active route
|
||||
* for the given route type.
|
||||
*
|
||||
* @param router the MediaRouter reporting the event
|
||||
* @param type Type flag set indicating the routes that have been unselected
|
||||
* @param info Route that has been unselected for the given route types
|
||||
*/
|
||||
public void onRouteUnselected(int type, RouteInfo info);
|
||||
|
||||
/**
|
||||
* Called when the volume is changed for the specified route types.
|
||||
*
|
||||
* @param type Type flags indicating which volume type was changed
|
||||
* @param volume New volume value in the range 0 (inaudible) to 1 (full)
|
||||
*/
|
||||
public void onVolumeChanged(int type, float volume);
|
||||
public void onRouteUnselected(MediaRouter router, int type, RouteInfo info);
|
||||
|
||||
/**
|
||||
* Called when a route for the specified type was added.
|
||||
*
|
||||
* @param type Type flags indicating which types the added route supports
|
||||
* @param router the MediaRouter reporting the event
|
||||
* @param info Route that has become available for use
|
||||
*/
|
||||
public void onRouteAdded(int type, RouteInfo info);
|
||||
public void onRouteAdded(MediaRouter router, RouteInfo info);
|
||||
|
||||
/**
|
||||
* Called when a route for the specified type was removed.
|
||||
*
|
||||
* @param type Type flags indicating which types the removed route supported
|
||||
* @param router the MediaRouter reporting the event
|
||||
* @param info Route that has been removed from availability
|
||||
*/
|
||||
public void onRouteRemoved(int type, RouteInfo info);
|
||||
public void onRouteRemoved(MediaRouter router, RouteInfo info);
|
||||
|
||||
/**
|
||||
* Called when an aspect of the indicated route has changed.
|
||||
@@ -841,9 +858,29 @@ public class MediaRouter {
|
||||
* <p>This will not indicate that the types supported by this route have
|
||||
* changed, only that cosmetic info such as name or status have been updated.</p>
|
||||
*
|
||||
* @param router the MediaRouter reporting the event
|
||||
* @param info The route that was changed
|
||||
*/
|
||||
public void onRouteChanged(RouteInfo info);
|
||||
public void onRouteChanged(MediaRouter router, RouteInfo info);
|
||||
|
||||
/**
|
||||
* Called when a route is added to a group.
|
||||
*
|
||||
* @param router the MediaRouter reporting the event
|
||||
* @param info The route that was added
|
||||
* @param group The group the route was added to
|
||||
* @param index The route index within group that info was added at
|
||||
*/
|
||||
public void onRouteGrouped(MediaRouter router, RouteInfo info, RouteGroup group, int index);
|
||||
|
||||
/**
|
||||
* Called when a route is removed from a group.
|
||||
*
|
||||
* @param router the MediaRouter reporting the event
|
||||
* @param info The route that was removed
|
||||
* @param group The group the route was removed from
|
||||
*/
|
||||
public void onRouteUngrouped(MediaRouter router, RouteInfo info, RouteGroup group);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -854,51 +891,34 @@ public class MediaRouter {
|
||||
public static class SimpleCallback implements Callback {
|
||||
|
||||
@Override
|
||||
public void onRouteSelected(int type, RouteInfo info) {
|
||||
|
||||
public void onRouteSelected(MediaRouter router, int type, RouteInfo info) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRouteUnselected(int type, RouteInfo info) {
|
||||
|
||||
public void onRouteUnselected(MediaRouter router, int type, RouteInfo info) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVolumeChanged(int type, float volume) {
|
||||
|
||||
public void onRouteAdded(MediaRouter router, RouteInfo info) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRouteAdded(int type, RouteInfo info) {
|
||||
|
||||
public void onRouteRemoved(MediaRouter router, RouteInfo info) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRouteRemoved(int type, RouteInfo info) {
|
||||
|
||||
public void onRouteChanged(MediaRouter router, RouteInfo info) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRouteChanged(RouteInfo info) {
|
||||
|
||||
public void onRouteGrouped(MediaRouter router, RouteInfo info, RouteGroup group,
|
||||
int index) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class VolumeChangedBroadcastReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final String action = intent.getAction();
|
||||
if (AudioManager.VOLUME_CHANGED_ACTION.equals(action) &&
|
||||
AudioManager.STREAM_MUSIC == intent.getIntExtra(
|
||||
AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1)) {
|
||||
final int maxVol = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||
final int volExtra = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, 0);
|
||||
final float volume = (float) volExtra / maxVol;
|
||||
mDefaultAudio.mVolume = volume;
|
||||
dispatchVolumeChanged(ROUTE_TYPE_LIVE_AUDIO, volume);
|
||||
}
|
||||
public void onRouteUngrouped(MediaRouter router, RouteInfo info, RouteGroup group) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class BtChangedBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
Reference in New Issue
Block a user