Fix null pointer exception for devices without Bluetooth.

Change-Id: If44089824fe48b302f6e75ccbbfb3a6843016723
This commit is contained in:
Artur Dryomov
2013-09-09 11:12:55 +03:00
parent ff802c08b5
commit 2dfaabc1ba
2 changed files with 12 additions and 0 deletions

View File

@@ -302,6 +302,10 @@ public class CommunicationService extends Service implements Runnable, MessagesL
}
private void restoreBluetoothState() {
if (!BluetoothOperator.isStateValid(mBluetoothState)) {
return;
}
if (mBluetoothState.wasBluetoothEnabled()) {
return;
}

View File

@@ -39,9 +39,17 @@ public final class BluetoothOperator {
}
public static State getState() {
if (!isAvailable()) {
return null;
}
return new State(getAdapter().isEnabled());
}
public static boolean isStateValid(State aState) {
return aState != null;
}
public static void enable() {
if (!isAvailable()) {
return;