From a87f2fd7d82e5055e0f9ea2c93704ed0b58f27ef Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Thu, 10 Dec 2009 16:05:59 -0800 Subject: [PATCH] b/2320107 Fixed NPE for class bits. Docks do not have class bits. Change-Id: Ibe4f697a906010f8f3ee270b891db286a4976f8a --- .../settings/bluetooth/BluetoothSettings.java | 7 ++-- .../bluetooth/CachedBluetoothDevice.java | 32 ++++++++++--------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index 8a0795be8ab..43647954837 100644 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -326,7 +326,10 @@ public class BluetoothSettings extends PreferenceActivity if (uuids != null) if (BluetoothUuid.containsAnyUuid(uuids, LocalBluetoothProfileManager.OPP_PROFILE_UUIDS)) return true; - if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_OPP)) return true; + if (bluetoothClass != null + && bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_OPP)) { + return true; + } break; case BluetoothDevicePicker.FILTER_TYPE_AUDIO: if (uuids != null) { @@ -335,7 +338,7 @@ public class BluetoothSettings extends PreferenceActivity if (BluetoothUuid.containsAnyUuid(uuids, LocalBluetoothProfileManager.HEADSET_PROFILE_UUIDS)) return true; - } else { + } else if (bluetoothClass != null) { if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) return true; if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) return true; diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index ca72d8a6958..57bffa98910 100644 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -691,26 +691,28 @@ public class CachedBluetoothDevice implements Comparable boolean printUuids = true; BluetoothClass bluetoothClass = mDevice.getBluetoothClass(); - if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET) != - mProfiles.contains(Profile.HEADSET)) { - Log.v(TAG, "headset classbits != uuid"); - printUuids = true; - } + if (bluetoothClass != null) { + if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET) != + mProfiles.contains(Profile.HEADSET)) { + Log.v(TAG, "headset classbits != uuid"); + printUuids = true; + } - if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_A2DP) != - mProfiles.contains(Profile.A2DP)) { - Log.v(TAG, "a2dp classbits != uuid"); - printUuids = true; - } + if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_A2DP) != + mProfiles.contains(Profile.A2DP)) { + Log.v(TAG, "a2dp classbits != uuid"); + printUuids = true; + } - if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_OPP) != - mProfiles.contains(Profile.OPP)) { - Log.v(TAG, "opp classbits != uuid"); - printUuids = true; + if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_OPP) != + mProfiles.contains(Profile.OPP)) { + Log.v(TAG, "opp classbits != uuid"); + printUuids = true; + } } if (printUuids) { - Log.v(TAG, "Class: " + bluetoothClass.toString()); + if (bluetoothClass != null) Log.v(TAG, "Class: " + bluetoothClass.toString()); Log.v(TAG, "UUID:"); for (int i = 0; i < uuids.length; i++) { Log.v(TAG, " " + uuids[i]);