From 561dc16b286f703168d0d2f6ccd2ce851655db8e Mon Sep 17 00:00:00 2001 From: MrYoranimo Date: Tue, 5 Dec 2023 20:13:13 +0100 Subject: [PATCH] DeviceCommunicationService: catch uncaught exceptions from handleActions Exceptions raised while handling actions in the device's support class may result in the DeviceCommunicationService crashing as a whole and not being started again until the user forces GB to make a connection by pressing the device from the list. This change is made, because Xiaomi devices make use of proto2 messages, where optional fields cannot be set to null values as that will make it throw NPEs. --- .../gadgetbridge/service/DeviceCommunicationService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java index e92b1f70f..fbe8c263c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java @@ -689,6 +689,8 @@ public class DeviceCommunicationService extends Service implements SharedPrefere handleAction(intent, action, device1); } catch (DeviceNotFoundException e) { e.printStackTrace(); + } catch (Exception e) { + LOG.error("An exception was raised while handling the action {} for the device {}: ", action, device1, e); } } break;