mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Huawei: Activate Arterial Stiffness Detection. No sync
This commit is contained in:
+3
@@ -118,6 +118,9 @@ public final class HuaweiConstants {
|
||||
public static final String PREF_HUAWEI_ARRHYTHMIA_AUTOMATIC = "pref_huawei_arrhythmia_automatic";
|
||||
public static final String PREF_HUAWEI_ARRHYTHMIA_ALERT = "pref_huawei_arrhythmia_alert";
|
||||
public static final String PREF_HUAWEI_ECG_SWITCH = "pref_huawei_ecg_switch";
|
||||
public static final String PREF_HUAWEI_ARTERIAL_STIFFNESS_DETECTION_SWITCH = "pref_huawei_arterial_stiffness_detection_switch";
|
||||
|
||||
|
||||
|
||||
public static final String PKG_NAME = "com.huawei.devicegroupmanage";
|
||||
}
|
||||
|
||||
+11
@@ -327,6 +327,9 @@ public class HuaweiCoordinator {
|
||||
if(supportsECG() && isShowForceCountrySpecificFeatures(device)) {
|
||||
deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.HEALTH, R.xml.devicesettings_huawei_ecg);
|
||||
}
|
||||
if(supportsArterialStiffnessDetection() && isShowForceCountrySpecificFeatures(device)) {
|
||||
deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.HEALTH, R.xml.devicesettings_huawei_arterial_stiffness_detection);
|
||||
}
|
||||
if(supportsThreeCircle() || supportsThreeCircleLite()) {
|
||||
deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.HEALTH, R.xml.devicesettings_huawei_activity_reminders);
|
||||
}
|
||||
@@ -963,6 +966,14 @@ public class HuaweiCoordinator {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean supportsArterialStiffnessDetection() {
|
||||
if (supportsExpandCapability())
|
||||
return supportsExpandCapability(75);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean supportsPromptPushMessage () {
|
||||
// do not ask for capabilities under specific condition
|
||||
// if (deviceType == 10 && deviceVersion == 73617766697368 && deviceSoftVersion == 372E312E31) -> leo device
|
||||
|
||||
+3
@@ -60,6 +60,7 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstant
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants.PREF_HUAWEI_STRESS_SWITCH;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants.PREF_HUAWEI_TRUSLEEP;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants.PREF_HUAWEI_WORKMODE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants.PREF_HUAWEI_ARTERIAL_STIFFNESS_DETECTION_SWITCH;
|
||||
|
||||
public class HuaweiSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
|
||||
final GBDevice device;
|
||||
@@ -146,6 +147,8 @@ public class HuaweiSettingsCustomizer implements DeviceSpecificSettingsCustomize
|
||||
handler.addPreferenceHandlerFor(PREF_HUAWEI_ARRHYTHMIA_AUTOMATIC);
|
||||
handler.addPreferenceHandlerFor(PREF_HUAWEI_ARRHYTHMIA_ALERT);
|
||||
|
||||
handler.addPreferenceHandlerFor(PREF_HUAWEI_ARTERIAL_STIFFNESS_DETECTION_SWITCH);
|
||||
|
||||
|
||||
final Preference forceOptions = handler.findPreference(PREF_FORCE_OPTIONS);
|
||||
if (forceOptions != null) {
|
||||
|
||||
+21
@@ -141,6 +141,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.datasync.Huaw
|
||||
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.datasync.HuaweiDataSyncArterialStiffnessDetection;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.datasync.HuaweiDataSyncSleepApnea;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.p2p.HuaweiP2PAppIcon;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.p2p.HuaweiP2PCalendarService;
|
||||
@@ -315,6 +316,8 @@ public class HuaweiSupportProvider {
|
||||
|
||||
private HuaweiDataSyncEcg huaweiDataSyncEcg = null;
|
||||
|
||||
private HuaweiDataSyncArterialStiffnessDetection huaweiDataSyncArterialStiffnessDetection = null;
|
||||
|
||||
protected HuaweiOTAManager huaweiOTAManager = new HuaweiOTAManager(this);
|
||||
|
||||
HuaweiStressCalibration stressCalibration = null;
|
||||
@@ -885,6 +888,9 @@ public class HuaweiSupportProvider {
|
||||
if(getHuaweiCoordinator().supportsSleepApnea()) {
|
||||
huaweiDataSyncSleepApnea = new HuaweiDataSyncSleepApnea(HuaweiSupportProvider.this);
|
||||
}
|
||||
if(getHuaweiCoordinator().supportsArterialStiffnessDetection()) {
|
||||
huaweiDataSyncArterialStiffnessDetection = new HuaweiDataSyncArterialStiffnessDetection(HuaweiSupportProvider.this);
|
||||
}
|
||||
|
||||
// All of the below check that they are supported and otherwise they skip themselves
|
||||
final List<Request> initRequestQueue = new ArrayList<>();
|
||||
@@ -1228,9 +1234,13 @@ public class HuaweiSupportProvider {
|
||||
break;
|
||||
case HuaweiConstants.PREF_HUAWEI_ARRHYTHMIA_ALERT:
|
||||
setArrhythmiaAlert();
|
||||
break;
|
||||
case HuaweiConstants.PREF_HUAWEI_ECG_SWITCH:
|
||||
setECG();
|
||||
break;
|
||||
case HuaweiConstants.PREF_HUAWEI_ARTERIAL_STIFFNESS_DETECTION_SWITCH:
|
||||
setArterialStiffnessDetection();
|
||||
break;
|
||||
case DeviceSettingsPreferenceConst.PREF_FORCE_ENABLE_SMART_ALARM:
|
||||
getAlarms();
|
||||
break;
|
||||
@@ -2521,6 +2531,17 @@ public class HuaweiSupportProvider {
|
||||
}
|
||||
}
|
||||
|
||||
void setArterialStiffnessDetection() {
|
||||
boolean ecgEnabled = GBApplication
|
||||
.getDeviceSpecificSharedPrefs(getDevice().getAddress())
|
||||
.getBoolean(HuaweiConstants.PREF_HUAWEI_ARTERIAL_STIFFNESS_DETECTION_SWITCH, false);
|
||||
if (huaweiDataSyncArterialStiffnessDetection != null) {
|
||||
if (!huaweiDataSyncArterialStiffnessDetection.changeState(ecgEnabled)) {
|
||||
LOG.error("Error to set Arterial Stiffness Detection");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void storeLastStressData(HuaweiStressParser.StressData data) {
|
||||
String str = HuaweiStressParser.stressDataToJsonStr(data);
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
|
||||
+2
-3
@@ -56,9 +56,8 @@ public class HuaweiDataSyncArrhythmia implements HuaweiDataSyncCommon.DataCallba
|
||||
}
|
||||
|
||||
// TODO:
|
||||
public boolean queryState(boolean state) {
|
||||
HuaweiTLV tlv = new HuaweiTLV().put(0x01, state);
|
||||
return sendCommonData(900300004, (byte) 2, tlv.serialize());
|
||||
public boolean queryState() {
|
||||
return sendCommonData(900300004, (byte) 2, new byte[0]);
|
||||
}
|
||||
|
||||
// TODO:
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.datasync;
|
||||
|
||||
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 HuaweiDataSyncArterialStiffnessDetection implements HuaweiDataSyncCommon.DataCallback {
|
||||
private final Logger LOG = LoggerFactory.getLogger(HuaweiDataSyncArterialStiffnessDetection.class);
|
||||
|
||||
private final HuaweiSupportProvider support;
|
||||
|
||||
public static final String SRC_PKG_NAME = "hw.health.pwv";
|
||||
public static final String PKG_NAME = "com.huawei.health.pwv";
|
||||
|
||||
public HuaweiDataSyncArterialStiffnessDetection(HuaweiSupportProvider support) {
|
||||
this.support = support;
|
||||
this.support.getHuaweiDataSyncManager().registerCallback(PKG_NAME, this);
|
||||
}
|
||||
|
||||
private boolean sendCommonData(int configId, byte configAction, byte[] configData) {
|
||||
HuaweiDataSyncCommon.ConfigCommandData data = new HuaweiDataSyncCommon.ConfigCommandData();
|
||||
HuaweiDataSyncCommon.ConfigData config = new HuaweiDataSyncCommon.ConfigData();
|
||||
config.configId = configId;
|
||||
config.configAction = configAction;
|
||||
config.configData = configData;
|
||||
List<HuaweiDataSyncCommon.ConfigData> list = new ArrayList<>();
|
||||
list.add(config);
|
||||
data.setConfigDataList(list);
|
||||
return this.support.getHuaweiDataSyncManager().sendConfigCommand(SRC_PKG_NAME, PKG_NAME, data);
|
||||
}
|
||||
|
||||
public boolean changeState(boolean state) {
|
||||
HuaweiTLV tlv = new HuaweiTLV().put(0x01, state);
|
||||
return sendCommonData(900300010, (byte) 1, tlv.serialize());
|
||||
}
|
||||
|
||||
public boolean queryState() {
|
||||
return sendCommonData(900300010, (byte) 2, new byte[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigCommand(HuaweiDataSyncCommon.ConfigCommandData data) {
|
||||
LOG.info("Handle PWV command");
|
||||
//TODO:
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEventCommand(HuaweiDataSyncCommon.EventCommandData data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataCommand(HuaweiDataSyncCommon.DataCommandData data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDictDataCommand(HuaweiDataSyncCommon.DictDataCommandData data) {
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -44,9 +44,8 @@ public class HuaweiDataSyncSleepApnea implements HuaweiDataSyncCommon.DataCallba
|
||||
return sendCommonData(900300007, (byte) 1, tlv.serialize());
|
||||
}
|
||||
|
||||
public boolean querySleepApneaState(boolean state) {
|
||||
HuaweiTLV tlv = new HuaweiTLV().put(0x01, state);
|
||||
return sendCommonData(900300007, (byte) 2, tlv.serialize());
|
||||
public boolean querySleepApneaState() {
|
||||
return sendCommonData(900300007, (byte) 2, new byte[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4393,4 +4393,7 @@
|
||||
<string name="pref_screen_ecg">ECG</string>
|
||||
<string name="pref_huawei_ecg_activate_title">Activate ECG</string>
|
||||
<string name="pref_huawei_ecg_activate_summary">Activate or deactivate ECG on the device</string>
|
||||
<string name="pref_huawei_arterial_stiffness_detection">Arterial stiffness detection</string>
|
||||
<string name="pref_huawei_arterial_stiffness_detection_enable_title">Enable arterial stiffness detection</string>
|
||||
<string name="pref_huawei_arterial_stiffness_detection_enable_summary">Activate arterial stiffness detection on the device</string>
|
||||
</resources>
|
||||
|
||||
@@ -29,7 +29,5 @@
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/pref_huawei_pulse_wave_arrhythmia_alert_title"
|
||||
android:summary="@string/pref_huawei_pulse_wave_arrhythmia_alert_summary" />
|
||||
|
||||
|
||||
</PreferenceScreen>
|
||||
</androidx.preference.PreferenceScreen>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceScreen
|
||||
android:icon="@drawable/ic_heart"
|
||||
android:key="screen_huawei_arterial_stiffness_detection"
|
||||
android:persistent="false"
|
||||
android:title="@string/pref_huawei_arterial_stiffness_detection">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_heart"
|
||||
android:key="pref_huawei_arterial_stiffness_detection_switch"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/pref_huawei_arterial_stiffness_detection_enable_title"
|
||||
android:summary="@string/pref_huawei_arterial_stiffness_detection_enable_summary" />
|
||||
|
||||
</PreferenceScreen>
|
||||
</androidx.preference.PreferenceScreen>
|
||||
Reference in New Issue
Block a user