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

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8805f00edfc3f01e39703063bb3ae66b26f686e7
This commit is contained in:
Treehugger Robot
2020-12-14 02:23:39 +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);
}
} }
} }
} }