mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-25 00:30:37 +02:00
Huami: Unify recorded data fetching in HuamiSupport
This commit is contained in:
parent
8cda2f74e8
commit
07357305cb
@ -515,6 +515,10 @@ public abstract class HuamiCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
return 22; // At least, Mi Fit still allows more
|
||||
}
|
||||
|
||||
public boolean supportsDebugLogs() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<HuamiVibrationPatternNotificationType> getVibrationPatternNotificationTypes(final GBDevice device) {
|
||||
return Arrays.asList(
|
||||
HuamiVibrationPatternNotificationType.APP_ALERTS,
|
||||
|
@ -79,6 +79,11 @@ public class MiBand2Coordinator extends HuamiCoordinator {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsDebugLogs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||
return new int[]{
|
||||
|
@ -85,6 +85,11 @@ public class MiBand2HRXCoordinator extends HuamiCoordinator {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsDebugLogs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||
return new int[]{
|
||||
|
@ -333,28 +333,6 @@ public abstract class Huami2021Support extends HuamiSupport {
|
||||
calendarService.deleteEvent(type, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchRecordedData(final int dataTypes) {
|
||||
try {
|
||||
// FIXME: currently only one data type supported, these are meant to be flags
|
||||
switch (dataTypes) {
|
||||
case RecordedDataTypes.TYPE_ACTIVITY:
|
||||
new FetchActivityOperation(this).perform();
|
||||
break;
|
||||
case RecordedDataTypes.TYPE_GPS_TRACKS:
|
||||
new FetchSportsSummaryOperation(this, 1).perform();
|
||||
break;
|
||||
case RecordedDataTypes.TYPE_DEBUGLOGS:
|
||||
new HuamiFetchDebugLogsOperation(this).perform();
|
||||
break;
|
||||
default:
|
||||
LOG.warn("fetching multiple data types at once is not supported yet");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
LOG.error("Unable to fetch recorded data types {}", dataTypes, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeartRateTest() {
|
||||
// TODO onHeartRateTest - what modes? this only works sometimes
|
||||
|
@ -116,6 +116,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.FetchSportsSummaryOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.HuamiFetchDebugLogsOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsCannedMessagesService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.calendar.CalendarEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.calendar.CalendarManager;
|
||||
@ -1640,10 +1643,21 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
|
||||
@Override
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
final HuamiCoordinator coordinator = getCoordinator();
|
||||
|
||||
try {
|
||||
new FetchActivityOperation(this).perform();
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Unable to fetch activity data", ex);
|
||||
// FIXME: currently only one data type supported, these are meant to be flags
|
||||
if (dataTypes == RecordedDataTypes.TYPE_ACTIVITY) {
|
||||
new FetchActivityOperation(this).perform();
|
||||
} else if (dataTypes == RecordedDataTypes.TYPE_GPS_TRACKS && coordinator.supportsActivityTracks()) {
|
||||
new FetchSportsSummaryOperation(this, 1).perform();
|
||||
} else if (dataTypes == RecordedDataTypes.TYPE_DEBUGLOGS && coordinator.supportsDebugLogs()) {
|
||||
new HuamiFetchDebugLogsOperation(this).perform();
|
||||
} else {
|
||||
LOG.warn("fetching multiple data types at once is not supported yet");
|
||||
}
|
||||
} catch (final IOException ex) {
|
||||
LOG.error("Unable to fetch recorded data types" + dataTypes, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,24 +80,6 @@ public class AmazfitBipSupport extends HuamiSupport {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
try {
|
||||
// FIXME: currently only one data type supported, these are meant to be flags
|
||||
if (dataTypes == RecordedDataTypes.TYPE_ACTIVITY) {
|
||||
new FetchActivityOperation(this).perform();
|
||||
} else if (dataTypes == RecordedDataTypes.TYPE_GPS_TRACKS) {
|
||||
new FetchSportsSummaryOperation(this, 1).perform();
|
||||
} else if (dataTypes == RecordedDataTypes.TYPE_DEBUGLOGS) {
|
||||
new HuamiFetchDebugLogsOperation(this).perform();
|
||||
} else {
|
||||
LOG.warn("fetching multiple data types at once is not supported yet");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Unable to fetch recorded data types" + dataTypes, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void phase2Initialize(TransactionBuilder builder) {
|
||||
super.phase2Initialize(builder);
|
||||
|
Loading…
Reference in New Issue
Block a user