From 632a10f470d5086d18fab3eec89cef1d03e899c6 Mon Sep 17 00:00:00 2001 From: Jake Hamby Date: Wed, 26 Jan 2011 17:49:20 -0800 Subject: [PATCH] Fix settings NPE crash on launch. Sometimes when the settings app is resumed, HeadsetProfileManager's getConnectedDevices() method is called before the onServiceConnected() callback gives us the proxy object, causing an NPE. Check that we have the proxy object, and return an empty list otherwise. The correct states will be shown in the UI because the onServiceConnected() callback makes its own call to getConnectedDevices() to set the correct headset profile state. Bug: 3378431 Change-Id: I364ade0804fb2090378438c8721afef6cac2b0b8 --- .../settings/bluetooth/LocalBluetoothProfileManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java index 9c947c75f8d..406ac8f4505 100644 --- a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java +++ b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java @@ -30,6 +30,7 @@ import android.os.Handler; import android.os.ParcelUuid; import android.util.Log; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -466,7 +467,11 @@ abstract class LocalBluetoothProfileManager { @Override public List getConnectedDevices() { - return mService.getConnectedDevices(); + if (mService != null) { + return mService.getConnectedDevices(); + } else { + return new ArrayList(); + } } @Override