diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/generic_headphones/GenericHeadphonesCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/generic_headphones/GenericHeadphonesCoordinator.java index 1bb6473f4d..f6a5b4bb9b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/generic_headphones/GenericHeadphonesCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/generic_headphones/GenericHeadphonesCoordinator.java @@ -42,6 +42,7 @@ public class GenericHeadphonesCoordinator extends AbstractDeviceCoordinator { try { final BluetoothDevice device = candidate.getDevice(); final BluetoothClass deviceClass = device.getBluetoothClass(); + if (deviceClass == null) return false; int deviceType = deviceClass.getDeviceClass(); return deviceType == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET || deviceType == BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES || diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btbr/BtBRQueue.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btbr/BtBRQueue.java index 7518d66bdc..5820be65e8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btbr/BtBRQueue.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btbr/BtBRQueue.java @@ -64,12 +64,15 @@ public final class BtBRQueue { @Override public void run() { final byte[] buffer = new byte[mBufferSize]; - int nRead; + int nRead = 0; LOG.debug("Read thread started, entering loop"); while (!mDisposed) { try { + if (mBtSocket == null) + throw new IOException("mBtSocket was null"); + nRead = mBtSocket.getInputStream().read(buffer); // safety measure