Fix null pointer exception for devices without Bluetooth.
Change-Id: If44089824fe48b302f6e75ccbbfb3a6843016723
This commit is contained in:
@@ -302,6 +302,10 @@ public class CommunicationService extends Service implements Runnable, MessagesL
|
||||
}
|
||||
|
||||
private void restoreBluetoothState() {
|
||||
if (!BluetoothOperator.isStateValid(mBluetoothState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mBluetoothState.wasBluetoothEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user