1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 12:56:49 +01:00

Xiaomi: Dump fetched files to storage

This commit is contained in:
José Rebelo 2024-08-01 22:54:40 +01:00
parent 29f57758fa
commit d6d956b748
2 changed files with 6 additions and 7 deletions

View File

@ -477,7 +477,7 @@ public class XiaomiSupport extends AbstractDeviceSupport {
LOG.info("Parsing all activity files from storage"); LOG.info("Parsing all activity files from storage");
try { try {
final File externalFilesDir = FileUtils.getExternalFilesDir(); final File externalFilesDir = getCoordinator().getWritableExportDirectory(getDevice());
final File targetDir = new File(externalFilesDir, "rawFetchOperations"); final File targetDir = new File(externalFilesDir, "rawFetchOperations");
if (!targetDir.exists()) { if (!targetDir.exists()) {

View File

@ -32,6 +32,7 @@ import java.util.Queue;
import nodomain.freeyourgadget.gadgetbridge.BuildConfig; import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions; import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiPreferences; import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiPreferences;
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiSupport;
@ -96,10 +97,7 @@ public class XiaomiActivityFileFetcher {
final byte[] fileIdBytes = Arrays.copyOfRange(data, 0, 7); final byte[] fileIdBytes = Arrays.copyOfRange(data, 0, 7);
final XiaomiActivityFileId fileId = XiaomiActivityFileId.from(fileIdBytes); final XiaomiActivityFileId fileId = XiaomiActivityFileId.from(fileIdBytes);
if (BuildConfig.DEBUG) {
// FIXME comment this out
dumpBytesToExternalStorage(fileId, data); dumpBytesToExternalStorage(fileId, data);
}
if (!XiaomiPreferences.keepActivityDataOnDevice(mHealthService.getSupport().getDevice())) { if (!XiaomiPreferences.keepActivityDataOnDevice(mHealthService.getSupport().getDevice())) {
LOG.debug("Acking recorded data {}", fileId); LOG.debug("Acking recorded data {}", fileId);
@ -162,8 +160,9 @@ public class XiaomiActivityFileFetcher {
protected void dumpBytesToExternalStorage(final XiaomiActivityFileId fileId, final byte[] bytes) { protected void dumpBytesToExternalStorage(final XiaomiActivityFileId fileId, final byte[] bytes) {
try { try {
final File externalFilesDir = FileUtils.getExternalFilesDir(); final GBDevice device = mHealthService.getSupport().getDevice();
final File targetDir = new File(externalFilesDir, "rawFetchOperations"); final File exportDirectory = device.getDeviceCoordinator().getWritableExportDirectory(device);
final File targetDir = new File(exportDirectory, "rawFetchOperations");
targetDir.mkdirs(); targetDir.mkdirs();
final File outputFile = new File(targetDir, fileId.getFilename()); final File outputFile = new File(targetDir, fileId.getFilename());