mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-27 04:16:49 +01:00
PR-related improvements
- rename service identifiers for clarity - define BLE scan filter in the coordinator (even though GB does not use those currently) - rename `DownloadedFitFile` to `GarminFitFile` - bump DB schema version to 49
This commit is contained in:
parent
dccb8ed1c4
commit
a4ec3a62aa
@ -43,7 +43,7 @@ public class GBDaoGenerator {
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
final Schema schema = new Schema(48, MAIN_PACKAGE + ".entities");
|
||||
final Schema schema = new Schema(49, MAIN_PACKAGE + ".entities");
|
||||
|
||||
Entity userAttributes = addUserAttributes(schema);
|
||||
Entity user = addUserInfo(schema, userAttributes);
|
||||
@ -92,7 +92,7 @@ public class GBDaoGenerator {
|
||||
addPineTimeActivitySample(schema, user, device);
|
||||
addHybridHRActivitySample(schema, user, device);
|
||||
addVivomoveHrActivitySample(schema, user, device);
|
||||
addDownloadedFitFile(schema, user, device);
|
||||
addGarminFitFile(schema, user, device);
|
||||
|
||||
addCalendarSyncState(schema, device);
|
||||
addAlarms(schema, user, device);
|
||||
@ -476,10 +476,10 @@ public class GBDaoGenerator {
|
||||
return activitySample;
|
||||
}
|
||||
|
||||
private static Entity addDownloadedFitFile(Schema schema, Entity user, Entity device) {
|
||||
final Entity downloadedFitFile = addEntity(schema, "DownloadedFitFile");
|
||||
private static Entity addGarminFitFile(Schema schema, Entity user, Entity device) {
|
||||
final Entity downloadedFitFile = addEntity(schema, "GarminFitFile");
|
||||
downloadedFitFile.implementsSerializable();
|
||||
downloadedFitFile.setJavaDoc("This class represents a single FIT file downloaded from a FIT-compatible device.");
|
||||
downloadedFitFile.setJavaDoc("This class represents a single FIT file downloaded from a FIT-compatible Garmin device.");
|
||||
downloadedFitFile.addIdProperty().autoincrement();
|
||||
downloadedFitFile.addLongProperty("downloadTimestamp").notNull();
|
||||
final Property deviceId = downloadedFitFile.addLongProperty("deviceId").notNull().getProperty();
|
||||
|
@ -6,8 +6,8 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VivomoveConstants {
|
||||
public static final UUID UUID_SERVICE_GARMIN_1 = UUID.fromString("6A4E2401-667B-11E3-949A-0800200C9A66");
|
||||
public static final UUID UUID_SERVICE_GARMIN_2 = UUID.fromString("6A4E2500-667B-11E3-949A-0800200C9A66");
|
||||
public static final UUID UUID_SERVICE_GARMIN_GFDI = UUID.fromString("6A4E2401-667B-11E3-949A-0800200C9A66");
|
||||
public static final UUID UUID_SERVICE_GARMIN_REALTIME = UUID.fromString("6A4E2500-667B-11E3-949A-0800200C9A66");
|
||||
|
||||
public static final UUID UUID_CHARACTERISTIC_GARMIN_GFDI_SEND = UUID.fromString("6a4e4c80-667b-11e3-949a-0800200c9a66");
|
||||
public static final UUID UUID_CHARACTERISTIC_GARMIN_GFDI_RECEIVE = UUID.fromString("6a4ecd28-667b-11e3-949a-0800200c9a66");
|
||||
|
@ -1,11 +1,14 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.bluetooth.le.ScanFilter;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.ParcelUuid;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
@ -16,14 +19,25 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
|
||||
public class VivomoveHrCoordinator extends AbstractDeviceCoordinator {
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class VivomoveHrCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
@NonNull
|
||||
@Override
|
||||
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
||||
if ("vívomove HR".equals(candidate.getName())) return DeviceType.VIVOMOVE_HR;
|
||||
|
||||
final boolean hasServiceUuids = candidate.getServiceUuids().length > 0;
|
||||
return hasServiceUuids && candidate.supportsService(VivomoveConstants.UUID_SERVICE_GARMIN_2) ? DeviceType.VIVOMOVE_HR : DeviceType.UNKNOWN;
|
||||
return hasServiceUuids && candidate.supportsService(VivomoveConstants.UUID_SERVICE_GARMIN_GFDI) ? DeviceType.VIVOMOVE_HR : DeviceType.UNKNOWN;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<? extends ScanFilter> createBLEScanFilters() {
|
||||
final ParcelUuid garminService = new ParcelUuid(VivomoveConstants.UUID_SERVICE_GARMIN_GFDI);
|
||||
final ScanFilter filter = new ScanFilter.Builder().setServiceUuid(garminService).build();
|
||||
return Collections.singletonList(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,8 +17,8 @@ import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.VivomoveConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DownloadedFitFile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DownloadedFitFileDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.GarminFitFile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.GarminFitFileDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.User;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||
@ -137,8 +137,8 @@ public class VivomoveHrSupport extends AbstractBTLEDeviceSupport implements File
|
||||
public VivomoveHrSupport() {
|
||||
super(LOG);
|
||||
|
||||
addSupportedService(VivomoveConstants.UUID_SERVICE_GARMIN_1);
|
||||
addSupportedService(VivomoveConstants.UUID_SERVICE_GARMIN_2);
|
||||
addSupportedService(VivomoveConstants.UUID_SERVICE_GARMIN_GFDI);
|
||||
addSupportedService(VivomoveConstants.UUID_SERVICE_GARMIN_REALTIME);
|
||||
}
|
||||
|
||||
private int getNextProtobufRequestId() {
|
||||
@ -928,19 +928,19 @@ public class VivomoveHrSupport extends AbstractBTLEDeviceSupport implements File
|
||||
private long totalDownloadSize;
|
||||
private long lastTransferNotificationTimestamp;
|
||||
|
||||
private DownloadedFitFile findDownloadedFitFile(DaoSession session, Device device, User user, int fileNumber, int fileDataType, int fileSubType) {
|
||||
final DownloadedFitFileDao fileDao = session.getDownloadedFitFileDao();
|
||||
final Query<DownloadedFitFile> query = fileDao.queryBuilder()
|
||||
private GarminFitFile findDownloadedFitFile(DaoSession session, Device device, User user, int fileNumber, int fileDataType, int fileSubType) {
|
||||
final GarminFitFileDao fileDao = session.getGarminFitFileDao();
|
||||
final Query<GarminFitFile> query = fileDao.queryBuilder()
|
||||
.where(
|
||||
DownloadedFitFileDao.Properties.DeviceId.eq(device.getId()),
|
||||
DownloadedFitFileDao.Properties.UserId.eq(user.getId()),
|
||||
DownloadedFitFileDao.Properties.FileNumber.eq(fileNumber),
|
||||
DownloadedFitFileDao.Properties.FileDataType.eq(fileDataType),
|
||||
DownloadedFitFileDao.Properties.FileSubType.eq(fileSubType)
|
||||
GarminFitFileDao.Properties.DeviceId.eq(device.getId()),
|
||||
GarminFitFileDao.Properties.UserId.eq(user.getId()),
|
||||
GarminFitFileDao.Properties.FileNumber.eq(fileNumber),
|
||||
GarminFitFileDao.Properties.FileDataType.eq(fileDataType),
|
||||
GarminFitFileDao.Properties.FileSubType.eq(fileSubType)
|
||||
)
|
||||
.build();
|
||||
|
||||
final List<DownloadedFitFile> files = query.list();
|
||||
final List<GarminFitFile> files = query.list();
|
||||
return files.size() > 0 ? files.get(0) : null;
|
||||
}
|
||||
|
||||
@ -967,7 +967,7 @@ public class VivomoveHrSupport extends AbstractBTLEDeviceSupport implements File
|
||||
}
|
||||
|
||||
final long timestamp = entry.fileDate.getTime();
|
||||
final DownloadedFitFile alreadyDownloadedFile = findDownloadedFitFile(session, device, user, entry.fileNumber, entry.fileDataType, entry.fileSubType);
|
||||
final GarminFitFile alreadyDownloadedFile = findDownloadedFitFile(session, device, user, entry.fileNumber, entry.fileDataType, entry.fileSubType);
|
||||
if (alreadyDownloadedFile == null) {
|
||||
LOG.debug("File not yet downloaded");
|
||||
} else {
|
||||
@ -1007,8 +1007,8 @@ public class VivomoveHrSupport extends AbstractBTLEDeviceSupport implements File
|
||||
final User user = DBHelper.getUser(session);
|
||||
final int ts = (int) (System.currentTimeMillis() / 1000);
|
||||
|
||||
final DownloadedFitFile downloadedFitFile = new DownloadedFitFile(null, ts, device.getId(), user.getId(), downloadedDirectoryEntry.fileNumber, downloadedDirectoryEntry.fileDataType, downloadedDirectoryEntry.fileSubType, downloadedDirectoryEntry.fileDate.getTime(), downloadedDirectoryEntry.specificFlags, downloadedDirectoryEntry.fileSize, STORE_FIT_FILES ? data : null);
|
||||
session.getDownloadedFitFileDao().insert(downloadedFitFile);
|
||||
final GarminFitFile garminFitFile = new GarminFitFile(null, ts, device.getId(), user.getId(), downloadedDirectoryEntry.fileNumber, downloadedDirectoryEntry.fileDataType, downloadedDirectoryEntry.fileSubType, downloadedDirectoryEntry.fileDate.getTime(), downloadedDirectoryEntry.specificFlags, downloadedDirectoryEntry.fileSize, STORE_FIT_FILES ? data : null);
|
||||
session.getGarminFitFileDao().insert(garminFitFile);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error saving downloaded file to database", e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user