Prevent unnecessary call of setBluetoothA2dpOn(false)
When an active BT device is changed, instead of just notifying that the changed BT name, AudioService sometimes notify it with two steps. 1) Notify prev BT disconnected 2) Notify new BT connected By not calling setBluetoothA2dpOn(false) when BT is disconnected, we can prvent the unnecessary call of it. Bug: 144784716 Test: manual Change-Id: I31442204cd4dd4a78552e0f993e9dfa37d6fc03f
This commit is contained in:
@@ -221,12 +221,11 @@ public class MediaRouter {
|
||||
|
||||
if (!TextUtils.equals(newRoutes.bluetoothName, mCurAudioRoutesInfo.bluetoothName)) {
|
||||
forceUseDefaultRoute = false;
|
||||
mCurAudioRoutesInfo.bluetoothName = newRoutes.bluetoothName;
|
||||
if (mCurAudioRoutesInfo.bluetoothName != null) {
|
||||
if (newRoutes.bluetoothName != null) {
|
||||
if (mBluetoothA2dpRoute == null) {
|
||||
// BT connected
|
||||
final RouteInfo info = new RouteInfo(mSystemCategory);
|
||||
info.mName = mCurAudioRoutesInfo.bluetoothName;
|
||||
info.mName = newRoutes.bluetoothName;
|
||||
info.mDescription = mResources.getText(
|
||||
com.android.internal.R.string.bluetooth_a2dp_audio_route_name);
|
||||
info.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO;
|
||||
@@ -234,13 +233,14 @@ public class MediaRouter {
|
||||
mBluetoothA2dpRoute = info;
|
||||
addRouteStatic(mBluetoothA2dpRoute);
|
||||
} else {
|
||||
mBluetoothA2dpRoute.mName = mCurAudioRoutesInfo.bluetoothName;
|
||||
mBluetoothA2dpRoute.mName = newRoutes.bluetoothName;
|
||||
dispatchRouteChanged(mBluetoothA2dpRoute);
|
||||
}
|
||||
} else if (mBluetoothA2dpRoute != null) {
|
||||
// BT disconnected
|
||||
removeRouteStatic(mBluetoothA2dpRoute);
|
||||
RouteInfo btRoute = mBluetoothA2dpRoute;
|
||||
mBluetoothA2dpRoute = null;
|
||||
removeRouteStatic(btRoute);
|
||||
}
|
||||
audioRoutesChanged = true;
|
||||
}
|
||||
@@ -256,6 +256,7 @@ public class MediaRouter {
|
||||
}
|
||||
}
|
||||
}
|
||||
mCurAudioRoutesInfo.bluetoothName = newRoutes.bluetoothName;
|
||||
}
|
||||
|
||||
boolean isBluetoothA2dpOn() {
|
||||
|
||||
Reference in New Issue
Block a user