Merge "Handle NPE from BluetoothRouteProvider" am: 5a1f9e675b am: c890ab56da am: d92ac4907b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2121494 Change-Id: Iac90219c42f60d77363030d708e2677108938c6a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -348,18 +348,14 @@ class BluetoothRouteProvider {
|
|||||||
|
|
||||||
private void addActiveRoute(BluetoothRouteInfo btRoute) {
|
private void addActiveRoute(BluetoothRouteInfo btRoute) {
|
||||||
if (btRoute == null) {
|
if (btRoute == null) {
|
||||||
if (DEBUG) {
|
Slog.w(TAG, "addActiveRoute: btRoute is null");
|
||||||
Log.d(TAG, " btRoute is null");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Adding active route: " + btRoute.route);
|
Log.d(TAG, "Adding active route: " + btRoute.route);
|
||||||
}
|
}
|
||||||
if (mActiveRoutes.contains(btRoute)) {
|
if (mActiveRoutes.contains(btRoute)) {
|
||||||
if (DEBUG) {
|
Slog.w(TAG, "addActiveRoute: btRoute is already added.");
|
||||||
Log.d(TAG, " btRoute is already added.");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setRouteConnectionState(btRoute, STATE_CONNECTED);
|
setRouteConnectionState(btRoute, STATE_CONNECTED);
|
||||||
@@ -392,6 +388,12 @@ class BluetoothRouteProvider {
|
|||||||
private void addActiveDevices(BluetoothDevice device) {
|
private void addActiveDevices(BluetoothDevice device) {
|
||||||
// Let the given device be the first active device
|
// Let the given device be the first active device
|
||||||
BluetoothRouteInfo activeBtRoute = mBluetoothRoutes.get(device.getAddress());
|
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);
|
addActiveRoute(activeBtRoute);
|
||||||
|
|
||||||
// A bluetooth route with the same route ID should be added.
|
// A bluetooth route with the same route ID should be added.
|
||||||
|
|||||||
Reference in New Issue
Block a user