1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-24 17:45:50 +01:00

Add preference for save raw pebble health data.

This commit is contained in:
Daniele Gobbetti 2016-08-31 14:05:02 +02:00
parent cd535a0a45
commit 84e644fa1a
7 changed files with 39 additions and 3 deletions

View File

@ -3,11 +3,13 @@ TODO before 0.12.0 release:
* ~~Support importing Pebble Health data from old database~~ DONE, needs check.
* ~~Add onboarding activity on first startup (to merge old data)~~ DONE, needs check.
* export db/delete db improvements
* ~~optional raw health record storing (settings)~~
* ~~onboarding hint about import-db in Debug activity~~ DONE, needs check.
* TESTING!
* tx pull
Non blocking issues:
* don't store raw health data if the record is completely decoded (e.g. sleep/deep sleep overlay as of fw 3.14)
* Add back UUID_CHARACTERISTIC_PAIR support, at least optionally
* CSV Export

View File

@ -68,7 +68,7 @@ class DatalogSessionHealthOverlayData extends DatalogSessionPebbleHealth {
List<PebbleHealthActivityOverlay> overlayList = new ArrayList<>();
for (OverlayRecord overlayRecord : overlayRecords) {
overlayList.add(new PebbleHealthActivityOverlay(overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds, overlayRecord.type, deviceId, userId, overlayRecord.rawData));
overlayList.add(new PebbleHealthActivityOverlay(overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds, overlayRecord.type, deviceId, userId, overlayRecord.getRawData()));
}
overlayDao.insertOrReplaceInTx(overlayList);
} catch (Exception ex) {
@ -98,5 +98,12 @@ class DatalogSessionHealthOverlayData extends DatalogSessionPebbleHealth {
this.timestampStart = record.getInt();
this.durationSeconds = record.getInt();
}
public byte[] getRawData() {
if (storePebbleHealthRawRecord()) {
return rawData;
}
return null;
}
}
}

View File

@ -69,7 +69,7 @@ class DatalogSessionHealthSleep extends DatalogSessionPebbleHealth {
List<PebbleHealthActivityOverlay> overlayList = new ArrayList<>();
for (SleepRecord sleepRecord : sleepRecords) {
//TODO: check the firmware version and don't use the sleep record if overlay is available?
overlayList.add(new PebbleHealthActivityOverlay(sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd, sleepRecord.type, deviceId, userId, sleepRecord.rawData));
overlayList.add(new PebbleHealthActivityOverlay(sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd, sleepRecord.type, deviceId, userId, sleepRecord.getRawData()));
}
overlayDao.insertOrReplaceInTx(overlayList);
} catch (Exception ex) {
@ -100,6 +100,13 @@ class DatalogSessionHealthSleep extends DatalogSessionPebbleHealth {
this.bedTimeEnd = record.getInt();
this.deepSleepSeconds = record.getInt();
}
public byte[] getRawData() {
if (storePebbleHealthRawRecord()) {
return rawData;
}
return null;
}
}
}

View File

@ -87,7 +87,7 @@ public class DatalogSessionHealthSteps extends DatalogSessionPebbleHealth {
samples[j] = new PebbleHealthActivitySample(
stepsRecord.timestamp,
userId, deviceId,
stepsRecord.rawData,
stepsRecord.getRawData(),
stepsRecord.intensity,
stepsRecord.steps
);
@ -124,6 +124,13 @@ public class DatalogSessionHealthSteps extends DatalogSessionPebbleHealth {
this.intensity = record.getShort() & 0xffff;
this.light_intensity = record.get() & 0xff;
}
public byte[] getRawData() {
if (storePebbleHealthRawRecord()) {
return rawData;
}
return null;
}
}
}

View File

@ -23,4 +23,9 @@ abstract class DatalogSessionPebbleHealth extends DatalogSession {
Prefs prefs = GBApplication.getPrefs();
return prefs.getBoolean("pebble_sync_health", true);
}
protected boolean storePebbleHealthRawRecord() {
Prefs prefs = GBApplication.getPrefs();
return prefs.getBoolean("pebble_health_store_raw", true);
}
}

View File

@ -295,4 +295,6 @@
\n
Please note that you can import data from Mi Band, Pebble Health and Morpheuz but NOT from Pebble Misfit.
</string>
<string name="pref_title_pebble_health_store_raw">Store raw record in the database</string>
<string name="pref_summary_pebble_health_store_raw">If checked the data is stored \"as is\" and is available for later interpretation. NB: the database will be bigger in this case!</string>
</resources>

View File

@ -174,6 +174,12 @@
android:defaultValue="true"
android:key="pebble_sync_health"
android:title="@string/pref_title_pebble_sync_health" />
<CheckBoxPreference
android:defaultValue="true"
android:key="pebble_health_store_raw"
android:dependency="pebble_sync_health"
android:title="@string/pref_title_pebble_health_store_raw"
android:summary="@string/pref_summary_pebble_health_store_raw" />
<CheckBoxPreference
android:defaultValue="true"
android:key="pebble_sync_misfit"