Merge "[Bugfix]audio:fix NPE when buildBluetoothRoutes" am: b801d3549f

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I849ac5c7d88cbde748881d4aa85f5bacf9345d91
This commit is contained in:
Treehugger Robot
2020-12-14 01:46:14 +00:00
committed by Automerger Merge Worker

View File

@@ -165,11 +165,13 @@ class BluetoothRouteProvider {
private void buildBluetoothRoutes() { private void buildBluetoothRoutes() {
mBluetoothRoutes.clear(); mBluetoothRoutes.clear();
for (BluetoothDevice device : mBluetoothAdapter.getBondedDevices()) { if (mBluetoothAdapter.getBondedDevices() != null) {
if (device.isConnected()) { for (BluetoothDevice device : mBluetoothAdapter.getBondedDevices()) {
BluetoothRouteInfo newBtRoute = createBluetoothRoute(device); if (device.isConnected()) {
if (newBtRoute.connectedProfiles.size() > 0) { BluetoothRouteInfo newBtRoute = createBluetoothRoute(device);
mBluetoothRoutes.put(device.getAddress(), newBtRoute); if (newBtRoute.connectedProfiles.size() > 0) {
mBluetoothRoutes.put(device.getAddress(), newBtRoute);
}
} }
} }
} }