Merge "Fixing crash in emulator due to no BluetoothAdapter. (Bug 7188166)" into jb-mr1-dev

This commit is contained in:
Winson Chung
2012-09-18 15:34:37 -07:00
committed by Android (Google) Code Review

View File

@@ -96,16 +96,18 @@ public class BluetoothController extends BroadcastReceiver {
} }
private void updateBondedBluetoothDevices() { private void updateBondedBluetoothDevices() {
Set<BluetoothDevice> devices = BluetoothAdapter.getDefaultAdapter().getBondedDevices(); mBondedDevices.clear();
if (devices != null) {
mBondedDevices.clear(); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
for (BluetoothDevice device : devices) { if (adapter != null) {
if (device.getBondState() != BluetoothDevice.BOND_NONE) { Set<BluetoothDevice> devices = adapter.getBondedDevices();
mBondedDevices.add(device); if (devices != null) {
for (BluetoothDevice device : devices) {
if (device.getBondState() != BluetoothDevice.BOND_NONE) {
mBondedDevices.add(device);
}
} }
} }
} else {
mBondedDevices.clear();
} }
} }