summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sungsoo Lim <sungsoo@google.com> 2020-06-19 14:41:17 +0900
committer Sungsoo Lim <sungsoo@google.com> 2020-06-19 14:42:08 +0900
commit0ea65316f496bdb866a50aaff5cc9f8acfd724e4 (patch)
treec75fccf8e92808504fa66349a48bb584aad26753
parent6555756e9000a8f137933973b8652593d0e081bb (diff)
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
-rw-r--r--media/java/android/media/MediaRouter.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java
index 7ae2949e6074..6fa378724240 100644
--- a/media/java/android/media/MediaRouter.java
+++ b/media/java/android/media/MediaRouter.java
@@ -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() {