Check for null on BondedDevices call.
Change-Id: I2e5f9259ce210b2bb9854715b5a4d04a1faea185
diff --git a/src/com/android/phone/BluetoothHeadsetService.java b/src/com/android/phone/BluetoothHeadsetService.java
index b1f68ee..70e14a0 100644
--- a/src/com/android/phone/BluetoothHeadsetService.java
+++ b/src/com/android/phone/BluetoothHeadsetService.java
@@ -537,19 +537,21 @@
// Only 1 device is set to AUTO_CONNECT
BluetoothDevice savedDevice = null;
int max_priority = BluetoothHeadset.PRIORITY_AUTO_CONNECT;
- for (BluetoothDevice device : mAdapter.getBondedDevices()) {
- int priority = getPriority(device);
- if (priority >= BluetoothHeadset.PRIORITY_AUTO_CONNECT) {
- setPriority(device, BluetoothHeadset.PRIORITY_ON);
+ if (mAdapter.getBondedDevices() != null) {
+ for (BluetoothDevice device : mAdapter.getBondedDevices()) {
+ int priority = getPriority(device);
+ if (priority >= BluetoothHeadset.PRIORITY_AUTO_CONNECT) {
+ setPriority(device, BluetoothHeadset.PRIORITY_ON);
+ }
+ if (priority >= max_priority) {
+ max_priority = priority;
+ savedDevice = device;
+ }
}
- if (priority >= max_priority) {
- max_priority = priority;
- savedDevice = device;
+ if (savedDevice != null) {
+ setPriority(savedDevice, BluetoothHeadset.PRIORITY_AUTO_CONNECT);
}
}
- if (savedDevice != null) {
- setPriority(savedDevice, BluetoothHeadset.PRIORITY_AUTO_CONNECT);
- }
}
private synchronized void getSdpRecordsAndConnect(BluetoothDevice device) {