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
This commit is contained in:
Jake Hamby
2011-01-26 17:49:20 -08:00
parent e2c557d4c0
commit 632a10f470

View File

@@ -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<BluetoothDevice> getConnectedDevices() {
if (mService != null) {
return mService.getConnectedDevices();
} else {
return new ArrayList<BluetoothDevice>();
}
}
@Override