}
final RouteInfo btRoute = sStatic.mBluetoothA2dpRoute;
- if (btRoute != null && (types & ROUTE_TYPE_LIVE_AUDIO) != 0 &&
- (route == btRoute || route == sStatic.mDefaultAudioVideo)) {
+ if (sStatic.isPlaybackActive() && btRoute != null && (types & ROUTE_TYPE_LIVE_AUDIO) != 0
+ && (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);
}