1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-20 05:40:58 +02:00

Zepp OS: Handle fitness goals in Huami2021Support

HuamiSupport handles configurations with performInitialize, which may
trigger a device reinitialization if called while the device is already
initializing.

Handle fitness goals in Huami2021Support, which should be one of the
last settings still missing.
This commit is contained in:
José Rebelo 2023-07-22 14:35:54 +01:00
parent 76576af324
commit 07ec8a095b
2 changed files with 17 additions and 1 deletions

View File

@ -223,6 +223,20 @@ public abstract class Huami2021Support extends HuamiSupport implements ZeppOsFil
public void onSendConfiguration(final String config) {
final Prefs prefs = getDevicePrefs();
// FIXME: This should not be handled here
switch (config) {
case ActivityUser.PREF_USER_STEPS_GOAL:
case ActivityUser.PREF_USER_CALORIES_BURNT:
case ActivityUser.PREF_USER_SLEEP_DURATION:
case ActivityUser.PREF_USER_GOAL_WEIGHT_KG:
case ActivityUser.PREF_USER_GOAL_STANDING_TIME_HOURS:
case ActivityUser.PREF_USER_GOAL_FAT_BURN_TIME_MINUTES:
final TransactionBuilder builder = createTransactionBuilder("set fitness goal");
setFitnessGoal(builder);
builder.queue(getQueue());
return;
}
// Check if any of the services handles this config
for (AbstractZeppOsService service : mServiceMap.values()) {
if (service.onSendConfiguration(config, prefs)) {
@ -230,6 +244,8 @@ public abstract class Huami2021Support extends HuamiSupport implements ZeppOsFil
}
}
LOG.warn("Unhandled config {}, will pass to HuamiSupport", config);
super.onSendConfiguration(config);
}

View File

@ -143,7 +143,7 @@ public class ZeppOsConfigService extends AbstractZeppOsService {
if (setConfig(prefs, prefKey, configSetter)) {
try {
// If the ConfigSetter was able to set the config, just write it and return
final TransactionBuilder builder = new TransactionBuilder("Sending configuration for " + prefKey);
final TransactionBuilder builder = new TransactionBuilder("send config " + prefKey);
configSetter.write(builder);
builder.queue(getSupport().getQueue());
} catch (final Exception e) {