Merge "MediaRouter: Introduce and use getFallbackRoute method" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7b3bd1d547
@@ -142,7 +142,11 @@ public class MediaRouteControllerDialog extends AlertDialog {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int id) {
|
||||
if (mRoute.isSelected()) {
|
||||
mRouter.getDefaultRoute().select();
|
||||
if (mRoute.isBluetooth()) {
|
||||
mRouter.getDefaultRoute().select();
|
||||
} else {
|
||||
mRouter.getFallbackRoute().select();
|
||||
}
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@@ -731,6 +731,15 @@ public class MediaRouter {
|
||||
return sStatic.mDefaultAudioVideo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Bluetooth route if available, otherwise the default route.
|
||||
* @hide
|
||||
*/
|
||||
public RouteInfo getFallbackRoute() {
|
||||
return (sStatic.mBluetoothA2dpRoute != null)
|
||||
? sStatic.mBluetoothA2dpRoute : sStatic.mDefaultAudioVideo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide for use by framework routing UI
|
||||
*/
|
||||
@@ -913,6 +922,19 @@ public class MediaRouter {
|
||||
(route == btRoute || route == sStatic.mDefaultAudioVideo)) {
|
||||
try {
|
||||
sStatic.mAudioService.setBluetoothA2dpOn(route == btRoute);
|
||||
// TODO: Remove the following logging when no longer needed.
|
||||
if (route != btRoute) {
|
||||
StackTraceElement[] callStack = Thread.currentThread().getStackTrace();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
// callStack[3] is the caller of this method.
|
||||
for (int i = 3; i < callStack.length; i++) {
|
||||
StackTraceElement caller = callStack[i];
|
||||
sb.append(caller.getClassName() + "." + caller.getMethodName()
|
||||
+ ":" + caller.getLineNumber()).append(" ");
|
||||
}
|
||||
Log.w(TAG, "Default route is selected while a BT route is available: pkgName="
|
||||
+ sStatic.mPackageName + ", callers=" + sb.toString());
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error changing Bluetooth A2DP state", e);
|
||||
}
|
||||
@@ -1998,6 +2020,11 @@ public class MediaRouter {
|
||||
return this == sStatic.mDefaultAudioVideo;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public boolean isBluetooth() {
|
||||
return this == sStatic.mBluetoothA2dpRoute;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void select() {
|
||||
selectRouteStatic(mSupportedTypes, this, true);
|
||||
|
||||
@@ -182,7 +182,7 @@ public class CastControllerImpl implements CastController {
|
||||
Log.w(TAG, "Projection is no longer active: " + projection);
|
||||
}
|
||||
} else {
|
||||
mMediaRouter.getDefaultRoute().select();
|
||||
mMediaRouter.getFallbackRoute().select();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ public final class MediaProjectionManagerService extends SystemService
|
||||
mProjectionGrant.stop();
|
||||
}
|
||||
if (mMediaRouteInfo != null) {
|
||||
mMediaRouter.getDefaultRoute().select();
|
||||
mMediaRouter.getFallbackRoute().select();
|
||||
}
|
||||
mProjectionToken = projection.asBinder();
|
||||
mProjectionGrant = projection;
|
||||
|
||||
Reference in New Issue
Block a user