Merge "Prevent unnecessary call of setBluetoothA2dpOn(false)" into rvc-dev am: 7bfb0c31bf am: ca2e42f5c9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11926258

Change-Id: I31fec0a7e983e29a040980360bd63e29496d58a6
This commit is contained in:
Sungsoo Lim
2020-06-22 06:51:26 +00:00
committed by Automerger Merge Worker

View File

@@ -221,12 +221,11 @@ public class MediaRouter {
if (!TextUtils.equals(newRoutes.bluetoothName, mCurAudioRoutesInfo.bluetoothName)) { if (!TextUtils.equals(newRoutes.bluetoothName, mCurAudioRoutesInfo.bluetoothName)) {
forceUseDefaultRoute = false; forceUseDefaultRoute = false;
mCurAudioRoutesInfo.bluetoothName = newRoutes.bluetoothName; if (newRoutes.bluetoothName != null) {
if (mCurAudioRoutesInfo.bluetoothName != null) {
if (mBluetoothA2dpRoute == null) { if (mBluetoothA2dpRoute == null) {
// BT connected // BT connected
final RouteInfo info = new RouteInfo(mSystemCategory); final RouteInfo info = new RouteInfo(mSystemCategory);
info.mName = mCurAudioRoutesInfo.bluetoothName; info.mName = newRoutes.bluetoothName;
info.mDescription = mResources.getText( info.mDescription = mResources.getText(
com.android.internal.R.string.bluetooth_a2dp_audio_route_name); com.android.internal.R.string.bluetooth_a2dp_audio_route_name);
info.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO; info.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO;
@@ -234,13 +233,14 @@ public class MediaRouter {
mBluetoothA2dpRoute = info; mBluetoothA2dpRoute = info;
addRouteStatic(mBluetoothA2dpRoute); addRouteStatic(mBluetoothA2dpRoute);
} else { } else {
mBluetoothA2dpRoute.mName = mCurAudioRoutesInfo.bluetoothName; mBluetoothA2dpRoute.mName = newRoutes.bluetoothName;
dispatchRouteChanged(mBluetoothA2dpRoute); dispatchRouteChanged(mBluetoothA2dpRoute);
} }
} else if (mBluetoothA2dpRoute != null) { } else if (mBluetoothA2dpRoute != null) {
// BT disconnected // BT disconnected
removeRouteStatic(mBluetoothA2dpRoute); RouteInfo btRoute = mBluetoothA2dpRoute;
mBluetoothA2dpRoute = null; mBluetoothA2dpRoute = null;
removeRouteStatic(btRoute);
} }
audioRoutesChanged = true; audioRoutesChanged = true;
} }
@@ -256,6 +256,7 @@ public class MediaRouter {
} }
} }
} }
mCurAudioRoutesInfo.bluetoothName = newRoutes.bluetoothName;
} }
boolean isBluetoothA2dpOn() { boolean isBluetoothA2dpOn() {