mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Huawei: emotion enable/disable support
This commit is contained in:
+6
@@ -865,6 +865,12 @@ public class HuaweiCoordinator {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean supportsEmotion() {
|
||||
if (supportsExpandCapability())
|
||||
return supportsExpandCapability(206);
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean supportsPromptPushMessage () {
|
||||
// do not ask for capabilities under specific condition
|
||||
// if (deviceType == 10 && deviceVersion == 73617766697368 && deviceSoftVersion == 372E312E31) -> leo device
|
||||
|
||||
+17
@@ -133,6 +133,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.datasync.HuaweiDataSyncEmotion;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.datasync.HuaweiDataSyncFindDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.datasync.HuaweiDataSyncGoals;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.p2p.HuaweiP2PAppIcon;
|
||||
@@ -295,6 +296,8 @@ public class HuaweiSupportProvider {
|
||||
|
||||
private HuaweiDataSyncFindDevice huaweiDataSyncFindDevice = null;
|
||||
|
||||
private HuaweiDataSyncEmotion huaweiDataSyncEmotion = null;
|
||||
|
||||
protected HuaweiOTAManager huaweiOTAManager = new HuaweiOTAManager(this);
|
||||
|
||||
HuaweiStressCalibration stressCalibration = null;
|
||||
@@ -945,6 +948,10 @@ public class HuaweiSupportProvider {
|
||||
if (getHuaweiCoordinator().supportsFindDeviceAbility()) {
|
||||
huaweiDataSyncFindDevice = new HuaweiDataSyncFindDevice(HuaweiSupportProvider.this);
|
||||
}
|
||||
|
||||
if(getHuaweiCoordinator().supportsEmotion()) {
|
||||
huaweiDataSyncEmotion = new HuaweiDataSyncEmotion(HuaweiSupportProvider.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2411,6 +2418,16 @@ public class HuaweiSupportProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
if (huaweiDataSyncEmotion != null) {
|
||||
if (!huaweiDataSyncEmotion.changeEmotionsState(automaticStressEnabled)) {
|
||||
LOG.error("Error to set emotions");
|
||||
}
|
||||
}
|
||||
|
||||
if(huaweiDataSyncEmotion != null && !automaticStressEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
SetStressRequest req = new SetStressRequest(this, automaticStressEnabled);
|
||||
req.doPerform();
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.datasync;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiTLV;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||
|
||||
public class HuaweiDataSyncEmotion implements HuaweiDataSyncCommon.DataCallback {
|
||||
private final Logger LOG = LoggerFactory.getLogger(HuaweiDataSyncEmotion.class);
|
||||
|
||||
private final HuaweiSupportProvider support;
|
||||
|
||||
public static final int EMOTIONAL_ID = 900500028;
|
||||
|
||||
|
||||
public static final String SRC_PKG_NAME = "hw.health.emotion";
|
||||
public static final String PKG_NAME = "hw.watch.health.emotion";
|
||||
|
||||
public HuaweiDataSyncEmotion(HuaweiSupportProvider support) {
|
||||
this.support = support;
|
||||
this.support.getHuaweiDataSyncManager().registerCallback(PKG_NAME, this);
|
||||
}
|
||||
|
||||
private boolean sendCommonData(byte state) {
|
||||
HuaweiTLV tlv = new HuaweiTLV().put(0x01, state);
|
||||
HuaweiDataSyncCommon.ConfigCommandData data = new HuaweiDataSyncCommon.ConfigCommandData();
|
||||
HuaweiDataSyncCommon.ConfigData goalConfigData = new HuaweiDataSyncCommon.ConfigData();
|
||||
goalConfigData.configId = EMOTIONAL_ID;
|
||||
goalConfigData.configAction = 1;
|
||||
goalConfigData.configData = tlv.serialize();
|
||||
List<HuaweiDataSyncCommon.ConfigData> list = new ArrayList<>();
|
||||
list.add(goalConfigData);
|
||||
data.setConfigDataList(list);
|
||||
return this.support.getHuaweiDataSyncManager().sendConfigCommand(SRC_PKG_NAME, PKG_NAME, data);
|
||||
}
|
||||
|
||||
public boolean changeEmotionsState(boolean state) {
|
||||
return sendCommonData((byte) (state ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigCommand(HuaweiDataSyncCommon.ConfigCommandData data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEventCommand(HuaweiDataSyncCommon.EventCommandData data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataCommand(HuaweiDataSyncCommon.DataCommandData data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDictDataCommand(HuaweiDataSyncCommon.DictDataCommandData data) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user