1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 10:05:49 +01:00

Keep the pebble health data on the pebble watch if the activity provider is not pebble Health.

This will nack all pebble health datalog messages. As mentioned in #322, this would allow to use multiple android device without secondary devices "sipping" the health data from the watch.
This commit is contained in:
Daniele Gobbetti 2016-06-04 18:21:49 +02:00
parent edb7471e0c
commit 968d15c8d8
4 changed files with 36 additions and 3 deletions

View File

@ -13,7 +13,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.pebble.HealthSampleProvider;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
class DatalogSessionHealthOverlayData extends DatalogSession {
class DatalogSessionHealthOverlayData extends DatalogSessionPebbleHealth {
private static final Logger LOG = LoggerFactory.getLogger(DatalogSessionHealthOverlayData.class);
@ -26,6 +26,10 @@ class DatalogSessionHealthOverlayData extends DatalogSession {
public boolean handleMessage(ByteBuffer datalogMessage, int length) {
LOG.info("DATALOG " + taginfo + GB.hexdump(datalogMessage.array(), datalogMessage.position(), length));
if (!isPebbleHealthEnabled()) {
return false;
}
int initialPosition = datalogMessage.position();
int beginOfRecordPosition;
short recordVersion; //probably

View File

@ -13,7 +13,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.pebble.HealthSampleProvider;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
class DatalogSessionHealthSleep extends DatalogSession {
class DatalogSessionHealthSleep extends DatalogSessionPebbleHealth {
private static final Logger LOG = LoggerFactory.getLogger(DatalogSessionHealthSleep.class);
@ -25,6 +25,11 @@ class DatalogSessionHealthSleep extends DatalogSession {
@Override
public boolean handleMessage(ByteBuffer datalogMessage, int length) {
LOG.info("DATALOG " + taginfo + GB.hexdump(datalogMessage.array(), datalogMessage.position(), length));
if (!isPebbleHealthEnabled()) {
return false;
}
int initialPosition = datalogMessage.position();
int beginOfRecordPosition;
short recordVersion; //probably

View File

@ -16,7 +16,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class DatalogSessionHealthSteps extends DatalogSession {
public class DatalogSessionHealthSteps extends DatalogSessionPebbleHealth {
private static final Logger LOG = LoggerFactory.getLogger(DatalogSessionHealthSteps.class);
@ -29,6 +29,10 @@ public class DatalogSessionHealthSteps extends DatalogSession {
public boolean handleMessage(ByteBuffer datalogMessage, int length) {
LOG.info("DATALOG " + taginfo + GB.hexdump(datalogMessage.array(), datalogMessage.position(), length));
if (!isPebbleHealthEnabled()) {
return false;
}
int timestamp;
byte recordLength, recordNum;
short recordVersion; //probably

View File

@ -0,0 +1,20 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
abstract class DatalogSessionPebbleHealth extends DatalogSession {
DatalogSessionPebbleHealth(byte id, UUID uuid, int tag, byte itemType, short itemSize) {
super(id, uuid, tag, itemType, itemSize);
}
protected boolean isPebbleHealthEnabled() {
Prefs prefs = GBApplication.getPrefs();
int activityTracker = prefs.getInt("pebble_activitytracker", SampleProvider.PROVIDER_PEBBLE_HEALTH);
return (activityTracker == SampleProvider.PROVIDER_PEBBLE_HEALTH);
}
}