Merge "Skip bluetooth device iteration if LocalBluetoothManager is null"

This commit is contained in:
Nicholas Sauer
2014-03-27 21:37:19 +00:00
committed by Android (Google) Code Review

View File

@@ -443,17 +443,20 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
// Add cached paired BT devices // Add cached paired BT devices
LocalBluetoothManager lbtm = LocalBluetoothManager.getInstance(context); LocalBluetoothManager lbtm = LocalBluetoothManager.getInstance(context);
Set<BluetoothDevice> bondedDevices = // LocalBluetoothManager.getInstance can return null if the device does not
lbtm.getBluetoothAdapter().getBondedDevices(); // support bluetooth (e.g. the emulator).
if (lbtm != null) {
Set<BluetoothDevice> bondedDevices =
lbtm.getBluetoothAdapter().getBondedDevices();
for (BluetoothDevice device : bondedDevices) { for (BluetoothDevice device : bondedDevices) {
data = new SearchIndexableRaw(context); data = new SearchIndexableRaw(context);
data.title = device.getName(); data.title = device.getName();
data.screenTitle = res.getString(R.string.bluetooth_settings); data.screenTitle = res.getString(R.string.bluetooth_settings);
data.enabled = enabled; data.enabled = enabled;
result.add(data); result.add(data);
}
} }
return result; return result;
} }
}; };