From a89fea9c7da508f10cd523e516cb3fcfe7769382 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Tue, 8 Mar 2016 12:02:00 +0100 Subject: [PATCH] Pebble: Fix crash when starting pebstyle Also make code for "push" handlers more generic --- .../service/devices/pebble/PebbleProtocol.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index 5b6ee85d1..d426740bc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -1722,7 +1722,7 @@ public class PebbleProtocol extends GBDeviceProtocol { return null; } - private GBDeviceEvent decodeAppRunState(ByteBuffer buf) { + private GBDeviceEvent[] decodeAppRunState(ByteBuffer buf) { byte command = buf.get(); long uuid_high = buf.getLong(); long uuid_low = buf.getLong(); @@ -1731,9 +1731,10 @@ public class PebbleProtocol extends GBDeviceProtocol { switch (command) { case APPRUNSTATE_START: LOG.info(ENDPOINT_NAME + ": started " + uuid); - if (UUID_PEBSTYLE.equals(uuid)) { - AppMessageHandler handler = mAppMessageHandlers.get(uuid); - return handler.pushMessage()[0]; + + AppMessageHandler handler = mAppMessageHandlers.get(uuid); + if (handler != null) { + return handler.pushMessage(); } break; case APPRUNSTATE_STOP: @@ -2091,7 +2092,7 @@ public class PebbleProtocol extends GBDeviceProtocol { devEvts = new GBDeviceEvent[]{decodeSystemMessage(buf)}; break; case ENDPOINT_APPRUNSTATE: - devEvts = new GBDeviceEvent[]{decodeAppRunState(buf)}; + devEvts = decodeAppRunState(buf); break; case ENDPOINT_BLOBDB: devEvts = new GBDeviceEvent[]{decodeBlobDb(buf)};