mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-24 17:45:50 +01:00
Remove battery data when device is being removed
This commit is contained in:
parent
809cd30f0e
commit
dad7d66965
@ -40,6 +40,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BatteryLevelDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DeviceAttributesDao;
|
||||
@ -100,6 +101,8 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||
deleteDevice(gbDevice, device, session);
|
||||
QueryBuilder<?> qb = session.getDeviceAttributesDao().queryBuilder();
|
||||
qb.where(DeviceAttributesDao.Properties.DeviceId.eq(device.getId())).buildDelete().executeDeleteWithoutDetachingEntities();
|
||||
QueryBuilder<?> batteryLevelQueryBuilder = session.getBatteryLevelDao().queryBuilder();
|
||||
batteryLevelQueryBuilder.where(BatteryLevelDao.Properties.DeviceId.eq(device.getId())).buildDelete().executeDeleteWithoutDetachingEntities();
|
||||
session.getDeviceDao().delete(device);
|
||||
} else {
|
||||
LOG.info("device to delete not found in db: " + gbDevice);
|
||||
|
Loading…
Reference in New Issue
Block a user