use of nodomain.freeyourgadget.gadgetbridge.entities.DeviceAttributesDao in project Gadgetbridge by Freeyourgadget.
the class DBHelper method ensureDeviceAttributes.
private static void ensureDeviceAttributes(Device device, GBDevice gbDevice, DaoSession session) {
List<DeviceAttributes> deviceAttributes = device.getDeviceAttributesList();
DeviceAttributes[] previousDeviceAttributes = new DeviceAttributes[1];
if (hasUpToDateDeviceAttributes(deviceAttributes, gbDevice, previousDeviceAttributes)) {
return;
}
Calendar now = DateTimeUtils.getCalendarUTC();
invalidateDeviceAttributes(previousDeviceAttributes[0], now, session);
DeviceAttributes attributes = new DeviceAttributes();
attributes.setDeviceId(device.getId());
attributes.setValidFromUTC(now.getTime());
attributes.setFirmwareVersion1(gbDevice.getFirmwareVersion());
attributes.setFirmwareVersion2(gbDevice.getFirmwareVersion2());
attributes.setVolatileIdentifier(gbDevice.getVolatileAddress());
DeviceAttributesDao attributesDao = session.getDeviceAttributesDao();
attributesDao.insert(attributes);
// sort order is important, so we re-fetch from the db
// deviceAttributes.add(attributes);
device.resetDeviceAttributesList();
}
Aggregations