From cb644cc2e75a994a3977662626060acf4803bbce Mon Sep 17 00:00:00 2001 From: Nicholas Sauer Date: Wed, 26 Mar 2014 10:23:11 -0700 Subject: [PATCH] Skip bluetooth device iteration if LocalBluetoothManager is null bug:13653239 Change-Id: I163c47b626825b2f83bb63d9f6900216ce44ae41 --- .../settings/bluetooth/BluetoothSettings.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index cc0371fa512..1285e7a2e5b 100755 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -443,17 +443,20 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem // Add cached paired BT devices LocalBluetoothManager lbtm = LocalBluetoothManager.getInstance(context); - Set bondedDevices = - lbtm.getBluetoothAdapter().getBondedDevices(); + // LocalBluetoothManager.getInstance can return null if the device does not + // support bluetooth (e.g. the emulator). + if (lbtm != null) { + Set bondedDevices = + lbtm.getBluetoothAdapter().getBondedDevices(); - for (BluetoothDevice device : bondedDevices) { - data = new SearchIndexableRaw(context); - data.title = device.getName(); - data.screenTitle = res.getString(R.string.bluetooth_settings); - data.enabled = enabled; - result.add(data); + for (BluetoothDevice device : bondedDevices) { + data = new SearchIndexableRaw(context); + data.title = device.getName(); + data.screenTitle = res.getString(R.string.bluetooth_settings); + data.enabled = enabled; + result.add(data); + } } - return result; } };