Garmin: use developer device setting for keeping data on device

Make use of the previously added preference to toggle file archival (deletion) on the watch.

Default is true (keep data on device) until we are sure of the consequences.
This commit is contained in:
Daniele Gobbetti 2024-04-24 10:11:23 +02:00
parent 438bfa4cce
commit baec9b3040
1 changed files with 6 additions and 2 deletions

View File

@ -237,13 +237,17 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni
} else if (deviceEvent instanceof FileDownloadedDeviceEvent) {
LOG.debug("FILE DOWNLOAD COMPLETE {}", ((FileDownloadedDeviceEvent) deviceEvent).directoryEntry.getFileName());
if (false) // delete file from watch upon successful download TODO: add device setting
if (getKeepActivityDataOnDevice()) // delete file from watch upon successful download
sendOutgoingMessage(new SetFileFlagsMessage(((FileDownloadedDeviceEvent) deviceEvent).directoryEntry.getFileIndex(), SetFileFlagsMessage.FileFlags.ARCHIVE));
}
super.evaluateGBDeviceEvent(deviceEvent);
}
private boolean getKeepActivityDataOnDevice() {
return getDevicePrefs().getBoolean("keep_activity_data_on_device", true); // TODO: change to default false once we are sure of the consequences
}
@Override
public void onFetchRecordedData(final int dataTypes) {
if (this.supportedFileTypeList.isEmpty()) {
@ -419,7 +423,7 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni
FileTransferHandler.DirectoryEntry directoryEntry = filesToDownload.remove();
while (checkFileExists(directoryEntry.getFileName())) {
LOG.debug("File: {} already downloaded, not downloading again.", directoryEntry.getFileName());
if (false) // delete file from watch if already downloaded TODO: add device setting
if (getKeepActivityDataOnDevice()) // delete file from watch if already downloaded
sendOutgoingMessage(new SetFileFlagsMessage(directoryEntry.getFileIndex(), SetFileFlagsMessage.FileFlags.ARCHIVE));
directoryEntry = filesToDownload.remove();
}