Fixed null pointer exception when BT is enabled from settings screen with previously bonded devices

Change-Id: Ia0cf763920fd99897994ea15445aec1dcd48853e
This commit is contained in:
fredc
2012-05-19 10:17:14 -07:00
committed by Matthew Xie
parent c7b490c7a0
commit afedeacd57
4 changed files with 38 additions and 7 deletions

View File

@@ -83,6 +83,7 @@ final class PanProfile implements LocalBluetoothProfile {
}
public boolean connect(BluetoothDevice device) {
if (mService == null) return false;
List<BluetoothDevice> sinks = mService.getConnectedDevices();
if (sinks != null) {
for (BluetoothDevice sink : sinks) {
@@ -93,10 +94,14 @@ final class PanProfile implements LocalBluetoothProfile {
}
public boolean disconnect(BluetoothDevice device) {
if (mService == null) return false;
return mService.disconnect(device);
}
public int getConnectionStatus(BluetoothDevice device) {
if (mService == null) {
return BluetoothProfile.STATE_DISCONNECTED;
}
return mService.getConnectionState(device);
}
@@ -129,7 +134,7 @@ final class PanProfile implements LocalBluetoothProfile {
}
public int getSummaryResourceForDevice(BluetoothDevice device) {
int state = mService.getConnectionState(device);
int state = getConnectionStatus(device);
switch (state) {
case BluetoothProfile.STATE_DISCONNECTED:
return R.string.bluetooth_pan_profile_summary_use_for;