From 116b2572dd0cc09c051298bb077577ed7248ac08 Mon Sep 17 00:00:00 2001 From: TaaviE Date: Sun, 30 Aug 2020 18:05:01 +0300 Subject: [PATCH] Avoided a NullPointerException when queue is null --- .../devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java index ba2593b49..bdfc6b7b6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lenovo/watchxplus/WatchXPlusDeviceSupport.java @@ -188,12 +188,15 @@ public class WatchXPlusDeviceSupport extends AbstractBTLEDeviceSupport { */ private void cancelNotification() { try { + if (getQueue() == null) { + LOG.warn("Unable to cancel notification, queue is null"); + return; + } getQueue().clear(); TransactionBuilder builder = performInitialized("cancelNotification"); - byte[] bArr; int mPosition = 1024; // all positions int mMessageId = 0xFF; // all messages - bArr = new byte[6]; + byte[] bArr = new byte[6]; bArr[0] = (byte) ((int) (mPosition >> 24)); bArr[1] = (byte) ((int) (mPosition >> 16)); bArr[2] = (byte) ((int) (mPosition >> 8));