summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kyunglyul Hyun <klhyun@google.com> 2022-06-16 04:41:02 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-06-16 04:41:02 +0000
commitd92ac4907bf8e5a946bdde96eaa0f18d6bc23a9e (patch)
tree881446e7f254a6bb5c6f2ac68bf5555e754033a2
parentc3822079a188d21386a99bdb947ab852a822fa35 (diff)
parentc890ab56da13c9bdafbcc1802a0884b766c7bf1f (diff)
Merge "Handle NPE from BluetoothRouteProvider" am: 5a1f9e675b am: c890ab56da
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2121494 Change-Id: I79b7e407a20a9917e791308543ca416a8c3aa8fa Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--services/core/java/com/android/server/media/BluetoothRouteProvider.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/media/BluetoothRouteProvider.java b/services/core/java/com/android/server/media/BluetoothRouteProvider.java
index d0651ed176cf..d4d3a39c724e 100644
--- a/services/core/java/com/android/server/media/BluetoothRouteProvider.java
+++ b/services/core/java/com/android/server/media/BluetoothRouteProvider.java
@@ -348,18 +348,14 @@ class BluetoothRouteProvider {
private void addActiveRoute(BluetoothRouteInfo btRoute) {
if (btRoute == null) {
- if (DEBUG) {
- Log.d(TAG, " btRoute is null");
- }
+ Slog.w(TAG, "addActiveRoute: btRoute is null");
return;
}
if (DEBUG) {
Log.d(TAG, "Adding active route: " + btRoute.route);
}
if (mActiveRoutes.contains(btRoute)) {
- if (DEBUG) {
- Log.d(TAG, " btRoute is already added.");
- }
+ Slog.w(TAG, "addActiveRoute: btRoute is already added.");
return;
}
setRouteConnectionState(btRoute, STATE_CONNECTED);
@@ -392,6 +388,12 @@ class BluetoothRouteProvider {
private void addActiveDevices(BluetoothDevice device) {
// Let the given device be the first active device
BluetoothRouteInfo activeBtRoute = mBluetoothRoutes.get(device.getAddress());
+ // This could happen if ACTION_ACTIVE_DEVICE_CHANGED is sent before
+ // ACTION_CONNECTION_STATE_CHANGED is sent.
+ if (activeBtRoute == null) {
+ activeBtRoute = createBluetoothRoute(device);
+ mBluetoothRoutes.put(device.getAddress(), activeBtRoute);
+ }
addActiveRoute(activeBtRoute);
// A bluetooth route with the same route ID should be added.