From da01a76594a853ee798274a7f6a205fac5d1ee09 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Mon, 19 Sep 2016 16:37:45 +0200 Subject: [PATCH] fix BatteryInfoProfile NPE, show battery level for Vibratissimo --- .../service/btle/profiles/battery/BatteryInfoProfile.java | 2 +- .../service/devices/vibratissimo/VibratissimoSupport.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java index 10df73148..160c83eff 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java @@ -27,7 +27,7 @@ public class BatteryInfoProfile extends Abs public static final UUID SERVICE_UUID = GattService.UUID_SERVICE_BATTERY_SERVICE; public static final UUID UUID_CHARACTERISTIC_BATTERY_LEVEL = GattCharacteristic.UUID_CHARACTERISTIC_BATTERY_LEVEL; - private BatteryInfo batteryInfo; + private final BatteryInfo batteryInfo = new BatteryInfo(); public BatteryInfoProfile(T support) { super(support); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vibratissimo/VibratissimoSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vibratissimo/VibratissimoSupport.java index 4da7583d0..cb609c8d8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vibratissimo/VibratissimoSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vibratissimo/VibratissimoSupport.java @@ -57,6 +57,7 @@ public class VibratissimoSupport extends AbstractBTLEDeviceSupport { addSupportedService(GattService.UUID_SERVICE_GENERIC_ACCESS); addSupportedService(GattService.UUID_SERVICE_GENERIC_ATTRIBUTE); addSupportedService(GattService.UUID_SERVICE_DEVICE_INFORMATION); + addSupportedService(GattService.UUID_SERVICE_BATTERY_SERVICE); addSupportedService(UUID.fromString("00001523-1212-efde-1523-785feabcd123")); deviceInfoProfile = new DeviceInfoProfile<>(this); @@ -88,6 +89,7 @@ public class VibratissimoSupport extends AbstractBTLEDeviceSupport { builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext())); requestDeviceInfo(builder); setInitialized(builder); + batteryInfoProfile.requestBatteryInfo(builder); return builder; }