mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Huawei: Chain initialize dynamic services requests
Also includes a bit of cleanup. Thanks to José Rebelo for cleaning my code.
This commit is contained in:
parent
098ab77cc6
commit
1315931ff8
@ -285,6 +285,7 @@ public class HuaweiCoordinator {
|
||||
public boolean supportsDoNotDisturb() {
|
||||
return supportsCommandForService(0x01, 0x0a);
|
||||
}
|
||||
|
||||
public boolean supportsDoNotDisturb(GBDevice gbDevice) {
|
||||
return supportsDoNotDisturb() || getForceOption(gbDevice, PREF_FORCE_DND_SUPPORT);
|
||||
}
|
||||
@ -296,6 +297,7 @@ public class HuaweiCoordinator {
|
||||
public boolean supportsWearLocation() {
|
||||
return supportsCommandForService(0x01, 0x1a);
|
||||
}
|
||||
|
||||
public boolean supportsWearLocation(GBDevice gbDevice) {
|
||||
return supportsWearLocation() || getForceOption(gbDevice, PREF_FORCE_ENABLE_WEAR_LOCATION);
|
||||
}
|
||||
|
@ -178,6 +178,8 @@ import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
|
||||
public class HuaweiSupportProvider {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HuaweiSupportProvider.class);
|
||||
|
||||
private final int initTimeout = 1000;
|
||||
|
||||
private HuaweiBRSupport brSupport;
|
||||
private HuaweiLESupport leSupport;
|
||||
|
||||
@ -546,26 +548,18 @@ public class HuaweiSupportProvider {
|
||||
}
|
||||
|
||||
protected void initializeDeviceConfigure() {
|
||||
nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder leBuilder = null;
|
||||
nodomain.freeyourgadget.gadgetbridge.service.btbr.TransactionBuilder brBuilder = null;
|
||||
if (isBLE()) {
|
||||
leBuilder = createLeTransactionBuilder("Initializing");
|
||||
nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder leBuilder = createLeTransactionBuilder("Initializing");
|
||||
leBuilder.setCallback(leSupport);
|
||||
if (!GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean("force_new_protocol", false))
|
||||
leBuilder.notify(leSupport.getCharacteristic(HuaweiConstants.UUID_CHARACTERISTIC_HUAWEI_READ), true);
|
||||
leBuilder.add(new nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction(gbDevice, GBDevice.State.INITIALIZING, context));
|
||||
} else {
|
||||
brBuilder = createBrTransactionBuilder("Initializing");
|
||||
nodomain.freeyourgadget.gadgetbridge.service.btbr.TransactionBuilder brBuilder = createBrTransactionBuilder("Initializing");
|
||||
brBuilder.setCallback(brSupport);
|
||||
brBuilder.add(new nodomain.freeyourgadget.gadgetbridge.service.btbr.actions.SetDeviceStateAction(gbDevice, GBDevice.State.INITIALIZING, context));
|
||||
}
|
||||
try {
|
||||
GetProductInformationRequest productInformationReq = new GetProductInformationRequest(this);
|
||||
Request setTimeReq = setTime();
|
||||
GetSupportedServicesRequest supportedServicesReq = new GetSupportedServicesRequest(this);
|
||||
productInformationReq.nextRequest(setTimeReq);
|
||||
setTimeReq.nextRequest(supportedServicesReq);
|
||||
productInformationReq.doPerform();
|
||||
if (firstConnection) {
|
||||
// Workaround to enable PREF_HUAWEI_ROTATE_WRIST_TO_SWITCH_INFO preference
|
||||
SharedPreferences sharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(deviceMac);
|
||||
@ -573,17 +567,33 @@ public class HuaweiSupportProvider {
|
||||
editor.putString(DeviceSettingsPreferenceConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, "p_on");
|
||||
editor.apply();
|
||||
}
|
||||
getBatteryLevel();
|
||||
sendUserInfo();
|
||||
if (isBLE()) {
|
||||
assert leBuilder != null;
|
||||
leBuilder.add(new nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction(gbDevice, GBDevice.State.INITIALIZED, context));
|
||||
leSupport.performConnected(leBuilder.getTransaction());
|
||||
} else {
|
||||
assert brBuilder != null;
|
||||
brBuilder.add(new nodomain.freeyourgadget.gadgetbridge.service.btbr.actions.SetDeviceStateAction(gbDevice, GBDevice.State.INITIALIZED, context));
|
||||
brSupport.performConnected(brBuilder.getTransaction());
|
||||
|
||||
stopBatteryRunnerDelayed();
|
||||
GetBatteryLevelRequest batteryLevelReq = new GetBatteryLevelRequest(this);
|
||||
batteryLevelReq.setFinalizeReq(new RequestCallback() {
|
||||
@Override
|
||||
public void timeout(Request request) {
|
||||
request.handleNext();
|
||||
// Start the battery runner again so it keeps running even if the timeout is hit
|
||||
startBatteryRunnerDelayed();
|
||||
}
|
||||
});
|
||||
|
||||
final List<Request> initRequestQueue = new ArrayList<>();
|
||||
initRequestQueue.add(new GetProductInformationRequest(this));
|
||||
initRequestQueue.add(new SetTimeRequest(this, true));
|
||||
initRequestQueue.add(batteryLevelReq);
|
||||
initRequestQueue.add(new SendFitnessUserInfoRequest(this));
|
||||
initRequestQueue.add(new GetSupportedServicesRequest(this)); // MUST BE LAST - it indirectly kicks off initializeDynamicServices
|
||||
|
||||
// Queue all the requests
|
||||
for (int i = 1; i < initRequestQueue.size(); i++) {
|
||||
initRequestQueue.get(i - 1).setupTimeoutUntilNext(initTimeout);
|
||||
initRequestQueue.get(i - 1).nextRequest(initRequestQueue.get(i));
|
||||
}
|
||||
initRequestQueue.get(initRequestQueue.size() - 1).setupTimeoutUntilNext(initTimeout);
|
||||
|
||||
initRequestQueue.get(0).doPerform();
|
||||
} catch (IOException e) {
|
||||
// TODO: Use translatable string
|
||||
GB.toast(context, "Final initialization of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||
@ -694,178 +704,70 @@ public class HuaweiSupportProvider {
|
||||
* To be called after the commandsPerService is filled in the coordinator
|
||||
*/
|
||||
public void initializeDynamicServices() {
|
||||
try {
|
||||
// All of the below check that they are supported and otherwise they skip themselves
|
||||
final List<Request> initRequestQueue = new ArrayList<>();
|
||||
initRequestQueue.add(new GetExpandCapabilityRequest(this));
|
||||
initRequestQueue.add(new SendExtendedAccountRequest(this));
|
||||
initRequestQueue.add(new GetSettingRelatedRequest(this));
|
||||
initRequestQueue.add(new AcceptAgreementsRequest(this));
|
||||
initRequestQueue.add(new GetActivityTypeRequest(this));
|
||||
initRequestQueue.add(new GetConnectStatusRequest(this));
|
||||
initRequestQueue.add(new GetDndLiftWristTypeRequest(this));
|
||||
initRequestQueue.add(new SendDndDeleteRequest(this));
|
||||
initRequestQueue.add(new SendDndAddRequest(this));
|
||||
initRequestQueue.add(new SendSetUpDeviceStatusRequest(this));
|
||||
initRequestQueue.add(new GetWearStatusRequest(this));
|
||||
initRequestQueue.add(new SendMenstrualCapabilityRequest(this));
|
||||
initRequestQueue.add(new SendNotifyHeartRateCapabilityRequest(this));
|
||||
initRequestQueue.add(new SendNotifyRestHeartRateCapabilityRequest(this));
|
||||
initRequestQueue.add(new SetMediumToStrengthThresholdRequest(this));
|
||||
initRequestQueue.add(new SendFitnessGoalRequest(this));
|
||||
initRequestQueue.add(new GetNotificationCapabilitiesRequest(this));
|
||||
initRequestQueue.add(new GetNotificationConstraintsRequest(this));
|
||||
initRequestQueue.add(new GetWatchfaceParams(this));
|
||||
initRequestQueue.add(new SendCameraRemoteSetupEvent(this, CameraRemote.CameraRemoteSetup.Request.Event.ENABLE_CAMERA));
|
||||
initRequestQueue.add(new GetAppInfoParams(this));
|
||||
initRequestQueue.add(new SetActivateOnLiftRequest(this));
|
||||
initRequestQueue.add(new SetWearLocationRequest(this));
|
||||
initRequestQueue.add(new SetNavigateOnRotateRequest(this));
|
||||
initRequestQueue.add(new SetNotificationRequest(this));
|
||||
initRequestQueue.add(new SetWearMessagePushRequest(this));
|
||||
initRequestQueue.add(new SetTimeZoneIdRequest(this));
|
||||
initRequestQueue.add(new SetLanguageSettingRequest(this));
|
||||
initRequestQueue.add(new SetDateFormatRequest(this));
|
||||
initRequestQueue.add(new SetActivityReminderRequest(this));
|
||||
initRequestQueue.add(new SetTruSleepRequest(this));
|
||||
initRequestQueue.add(new GetContactsCount(this));
|
||||
initRequestQueue.add(new GetEventAlarmList(this));
|
||||
initRequestQueue.add(new GetSmartAlarmList(this));
|
||||
|
||||
// Setup the alarms
|
||||
if (!getHuaweiCoordinator().supportsChangingAlarm()) {
|
||||
if (firstConnection) {
|
||||
// TODO: not really sure if this is necessary, but it probably won't do any harm
|
||||
// Setup the alarms if necessary
|
||||
if (!getHuaweiCoordinator().supportsChangingAlarm() && firstConnection)
|
||||
initializeAlarms();
|
||||
}
|
||||
} else {
|
||||
getAlarms();
|
||||
}
|
||||
try {
|
||||
if (getHuaweiCoordinator().supportsExpandCapability()) {
|
||||
GetExpandCapabilityRequest expandCapabilityReq = new GetExpandCapabilityRequest(this);
|
||||
expandCapabilityReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsAccountJudgment() && getHuaweiCoordinator().supportsAccountSwitch()) {
|
||||
SendExtendedAccountRequest sendExtendedAccountRequest = new SendExtendedAccountRequest(this);
|
||||
sendExtendedAccountRequest.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsSettingRelated()) { // GetSettingRelated
|
||||
GetSettingRelatedRequest getSettingRelatedReq = new GetSettingRelatedRequest(this);
|
||||
getSettingRelatedReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsAcceptAgreement()) {
|
||||
AcceptAgreementsRequest acceptAgreementsRequest = new AcceptAgreementsRequest(this);
|
||||
acceptAgreementsRequest.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsActivityType()) {
|
||||
GetActivityTypeRequest activityTypeReq = new GetActivityTypeRequest(this);
|
||||
activityTypeReq.doPerform();
|
||||
|
||||
// Queue all the requests
|
||||
for (int i = 1; i < initRequestQueue.size(); i++) {
|
||||
initRequestQueue.get(i - 1).setupTimeoutUntilNext(initTimeout);
|
||||
initRequestQueue.get(i - 1).nextRequest(initRequestQueue.get(i));
|
||||
}
|
||||
|
||||
if (getHuaweiCoordinator().supportsConnectStatus()) {
|
||||
GetConnectStatusRequest getConnectStatusReq = new GetConnectStatusRequest(this);
|
||||
getConnectStatusReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsActivateOnLift()) {
|
||||
setActivateOnLift();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsWearLocation(getDevice())) {
|
||||
setWearLocation();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsRotateToCycleInfo()) {
|
||||
setNavigateOnRotate();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsQueryDndLiftWristDisturbType()) {
|
||||
GetDndLiftWristTypeRequest getDndLiftWristTypeReq = new GetDndLiftWristTypeRequest(this);
|
||||
getDndLiftWristTypeReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsDoNotDisturb(gbDevice)) {
|
||||
SendDndDeleteRequest sendDndDeleteReq = new SendDndDeleteRequest(this);
|
||||
SendDndAddRequest sendDndAddReq = new SendDndAddRequest(this);
|
||||
sendDndDeleteReq.nextRequest(sendDndAddReq);
|
||||
sendDndDeleteReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsNotification()) { // 0x02 - 0x04
|
||||
setNotificationStatus();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsDoNotDisturb(gbDevice) && getHuaweiCoordinator().supportsWearMessagePush()) {
|
||||
setDndNotWear();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsTimeAndZoneId()) {
|
||||
setTimeZoneId();
|
||||
}
|
||||
// Nothing usefull yet with this requests
|
||||
if (getHuaweiCoordinator().supportsMultiDevice()) {
|
||||
SendSetUpDeviceStatusRequest sendSetUpDeviceStatusReq = new SendSetUpDeviceStatusRequest(this);
|
||||
sendSetUpDeviceStatusReq.doPerform();
|
||||
GetWearStatusRequest getWearStatusReq = new GetWearStatusRequest(this);
|
||||
getWearStatusReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsMenstrual()) {
|
||||
SendMenstrualCapabilityRequest sendMenstrualCapabilityReq = new SendMenstrualCapabilityRequest(this);
|
||||
sendMenstrualCapabilityReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsLanguageSetting()) { // 0x0c - 0x01
|
||||
setLanguageSetting();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsWorkoutsTrustHeartRate()) {
|
||||
SendNotifyHeartRateCapabilityRequest sendNotifyHeartRateCapabilityReq = new SendNotifyHeartRateCapabilityRequest(this);
|
||||
sendNotifyHeartRateCapabilityReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsFitnessRestHeartRate()) {
|
||||
SendNotifyRestHeartRateCapabilityRequest sendNotifyRestHeartRateCapabilityReq = new SendNotifyRestHeartRateCapabilityRequest(this);
|
||||
sendNotifyRestHeartRateCapabilityReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsFitnessThresholdValue()) {
|
||||
SetMediumToStrengthThresholdRequest setMediumToStrengthThresholdReq = new SetMediumToStrengthThresholdRequest(this);
|
||||
setMediumToStrengthThresholdReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsDateFormat()) { //0x01 - 0x04
|
||||
setDateFormat();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsMotionGoal()) {
|
||||
SendFitnessGoalRequest sendFitnessGoalReq = new SendFitnessGoalRequest(this);
|
||||
sendFitnessGoalReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsActivityReminder()) {
|
||||
setActivityReminder();
|
||||
}
|
||||
|
||||
if (getHuaweiCoordinator().supportsTruSleep()) {
|
||||
setTrusleep();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsPromptPushMessage() && getProtocolVersion() == 2) {
|
||||
GetNotificationCapabilitiesRequest getNotificationCapabilitiesReq = new GetNotificationCapabilitiesRequest(this);
|
||||
getNotificationCapabilitiesReq.doPerform();
|
||||
}
|
||||
if (getHuaweiCoordinator().supportsNotificationAlert() && getProtocolVersion() == 2) {
|
||||
GetNotificationConstraintsRequest getNotificationConstraintsReq = new GetNotificationConstraintsRequest(this);
|
||||
getNotificationConstraintsReq.doPerform();
|
||||
}
|
||||
|
||||
if (getHuaweiCoordinator().supportsCameraRemote() && GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_CAMERA_REMOTE, false)) {
|
||||
SendCameraRemoteSetupEvent sendCameraRemoteSetupEvent = new SendCameraRemoteSetupEvent(this, CameraRemote.CameraRemoteSetup.Request.Event.ENABLE_CAMERA);
|
||||
sendCameraRemoteSetupEvent.doPerform();
|
||||
}
|
||||
|
||||
// FIXME: Limit number of simultaneous commands
|
||||
// Huawei watch, for example the Watch GT4 has limited buffer for incoming commands.
|
||||
// So sending a lot of command broke connection or cause that watch does not answer to requests.
|
||||
// To avoid this issue I perform some commands in the chain, but we should limit number of simultaneous commands
|
||||
|
||||
RequestCallback contactsCallback = new RequestCallback() {
|
||||
initRequestQueue.get(initRequestQueue.size() - 1).setupTimeoutUntilNext(initTimeout);
|
||||
initRequestQueue.get(initRequestQueue.size() - 1).setFinalizeReq(new RequestCallback() {
|
||||
@Override
|
||||
public void call() {
|
||||
if (getHuaweiCoordinator().supportsContacts()) {
|
||||
GetContactsCount getContactsCount = new GetContactsCount(HuaweiSupportProvider.this);
|
||||
try {
|
||||
getContactsCount.doPerform();
|
||||
gbDevice.setState(GBDevice.State.INITIALIZED);
|
||||
gbDevice.sendDeviceUpdateIntent(getContext(), GBDevice.DeviceUpdateSubject.DEVICE_STATE);
|
||||
}
|
||||
});
|
||||
|
||||
initRequestQueue.get(0).doPerform();
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error perform contacts count request", e);
|
||||
// TODO: Translatable string
|
||||
GB.toast("Initialize dynamic services of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||
LOG.error("Initializing dynamic services failed", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
RequestCallback appsCallback= new RequestCallback() {
|
||||
@Override
|
||||
public void call() {
|
||||
if (getHuaweiCoordinator().supportsAppParams()) {
|
||||
GetAppInfoParams getAppInfoParams = new GetAppInfoParams(HuaweiSupportProvider.this);
|
||||
getAppInfoParams.setFinalizeReq(contactsCallback);
|
||||
try {
|
||||
getAppInfoParams.doPerform();
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error perform app info request", e);
|
||||
}
|
||||
} else {
|
||||
contactsCallback.call();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (getHuaweiCoordinator().supportsWatchfaceParams()) {
|
||||
GetWatchfaceParams getWatchfaceParams = new GetWatchfaceParams(this);
|
||||
getWatchfaceParams.setFinalizeReq(appsCallback);
|
||||
getWatchfaceParams.doPerform();
|
||||
} else {
|
||||
appsCallback.call();
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Initialize dynamic services of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR,
|
||||
e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Properly update the device card
|
||||
gbDevice.sendDeviceUpdateIntent(GBApplication.getContext());
|
||||
GB.signalActivityDataFinish(getDevice());
|
||||
}
|
||||
|
||||
public void setProtocolVersion(byte protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
@ -917,7 +819,6 @@ public class HuaweiSupportProvider {
|
||||
return;
|
||||
|
||||
GetEventAlarmList getEventAlarmList = new GetEventAlarmList(this);
|
||||
responseManager.addHandler(getEventAlarmList);
|
||||
getEventAlarmList.setFinalizeReq(new RequestCallback() {
|
||||
@Override
|
||||
public void call() {
|
||||
@ -925,7 +826,6 @@ public class HuaweiSupportProvider {
|
||||
return; // Don't get smart alarms when not supported
|
||||
|
||||
GetSmartAlarmList getSmartAlarmList = new GetSmartAlarmList(HuaweiSupportProvider.this);
|
||||
responseManager.addHandler(getSmartAlarmList);
|
||||
try {
|
||||
getSmartAlarmList.doPerform();
|
||||
} catch (IOException e) {
|
||||
@ -1401,7 +1301,7 @@ public class HuaweiSupportProvider {
|
||||
|
||||
public void onSetTime() {
|
||||
try {
|
||||
setTime().doPerform();
|
||||
new SetTimeRequest(this, true).doPerform();
|
||||
} catch (IOException e) {
|
||||
// TODO: Use translatable string
|
||||
GB.toast(context, "Failed to configure time", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||
@ -1409,21 +1309,6 @@ public class HuaweiSupportProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private Request setTime() {
|
||||
SetTimeRequest setTimeReq = new SetTimeRequest(this, true);
|
||||
return setTimeReq;
|
||||
}
|
||||
|
||||
public void setTimeZoneId() {
|
||||
try {
|
||||
SetTimeZoneIdRequest setTimeZoneIdReq = new SetTimeZoneIdRequest(this);
|
||||
setTimeZoneIdReq.doPerform();
|
||||
} catch (IOException e) {
|
||||
// TODO: Use translatable string
|
||||
GB.toast(context, "Failed to configure time and zoneId", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSetAlarms(ArrayList<? extends nodomain.freeyourgadget.gadgetbridge.model.Alarm> alarms) {
|
||||
boolean smartAlarmEnabled = getHuaweiCoordinator().supportsSmartAlarm(getDevice());
|
||||
|
||||
@ -1727,7 +1612,6 @@ public class HuaweiSupportProvider {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setActivateOnLift() {
|
||||
try {
|
||||
SetActivateOnLiftRequest setActivateOnLiftReq = new SetActivateOnLiftRequest(this);
|
||||
|
@ -16,25 +16,18 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.DeviceConfig.AcceptAgreement;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Alarms.SmartAlarmRequest;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Alarms;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.DeviceConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||
|
||||
public class AcceptAgreementsRequest extends Request {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AcceptAgreementsRequest.class);
|
||||
|
||||
|
||||
public AcceptAgreementsRequest(HuaweiSupportProvider support) {
|
||||
super(support);
|
||||
|
||||
@ -42,6 +35,12 @@ public class AcceptAgreementsRequest extends Request {
|
||||
this.commandId = DeviceConfig.AcceptAgreement.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsAcceptAgreement();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
return new DeviceConfig.AcceptAgreement.Request(paramsProvider).serialize();
|
||||
|
@ -27,7 +27,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.DeviceConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||
@ -41,6 +40,11 @@ public class GetActivityTypeRequest extends Request {
|
||||
this.commandId = DeviceConfig.ActivityType.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsActivityType();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
DeviceConfig.ActivityType.Request activityRequest = new DeviceConfig.ActivityType.Request(paramsProvider);
|
||||
|
@ -15,6 +15,11 @@ public class GetAppInfoParams extends Request{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsAppParams();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket.CryptoException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.DeviceConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||
@ -35,6 +34,11 @@ public class GetConnectStatusRequest extends Request {
|
||||
this.commandId = DeviceConfig.ConnectStatusRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsConnectStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -18,6 +18,11 @@ public class GetContactsCount extends Request {
|
||||
this.commandId = Contacts.ContactsCount.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsContacts();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -38,6 +38,11 @@ public class GetDndLiftWristTypeRequest extends Request {
|
||||
this.commandId = DeviceConfig.DndLiftWristType.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsQueryDndLiftWristDisturbType();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -33,6 +33,11 @@ public class GetEventAlarmList extends Request {
|
||||
this.commandId = Alarms.EventAlarmsList.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsChangingAlarm();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -40,6 +40,11 @@ public class GetExpandCapabilityRequest extends Request {
|
||||
this.commandId = DeviceConfig.ExpandCapability.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsExpandCapability();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
DeviceConfig.ExpandCapability.Request expandRequest = new DeviceConfig.ExpandCapability.Request(paramsProvider);
|
||||
|
@ -35,6 +35,11 @@ public class GetNotificationCapabilitiesRequest extends Request {
|
||||
this.commandId = NotificationCapabilities.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsPromptPushMessage() && supportProvider.getProtocolVersion() == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -35,6 +35,11 @@ public class GetNotificationConstraintsRequest extends Request {
|
||||
this.commandId = NotificationConstraints.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsNotificationAlert() && supportProvider.getProtocolVersion() == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket.CryptoException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.DeviceConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||
@ -35,6 +34,11 @@ public class GetSettingRelatedRequest extends Request {
|
||||
this.commandId = DeviceConfig.SettingRelated.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsSettingRelated();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -16,10 +16,6 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||
@ -28,7 +24,6 @@ import nodomain.freeyourgadget.gadgetbridge.entities.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||
|
||||
public class GetSmartAlarmList extends Request {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GetSmartAlarmList.class);
|
||||
|
||||
public GetSmartAlarmList(HuaweiSupportProvider support) {
|
||||
super(support);
|
||||
@ -37,6 +32,12 @@ public class GetSmartAlarmList extends Request {
|
||||
this.commandId = Alarms.SmartAlarmList.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsChangingAlarm() &&
|
||||
supportProvider.getHuaweiCoordinator().supportsSmartAlarm(supportProvider.getDevice());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -17,9 +17,6 @@
|
||||
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||
@ -28,8 +25,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupport
|
||||
|
||||
public class GetWatchfaceParams extends Request{
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GetWatchfaceParams.class);
|
||||
|
||||
public GetWatchfaceParams(HuaweiSupportProvider support) {
|
||||
super(support);
|
||||
this.serviceId = Watchface.id;
|
||||
@ -37,6 +32,11 @@ public class GetWatchfaceParams extends Request{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsWatchfaceParams();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -35,6 +35,11 @@ public class GetWearStatusRequest extends Request {
|
||||
this.commandId = WearStatus.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsMultiDevice();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -18,6 +18,8 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
||||
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -109,6 +111,10 @@ public class Request {
|
||||
protected HuaweiCrypto huaweiCrypto = null;
|
||||
protected boolean addToResponse = true;
|
||||
|
||||
private final Handler handler;
|
||||
private final Runnable timeoutRunner;
|
||||
private Integer timeout = null;
|
||||
|
||||
public static class RequestCallback {
|
||||
protected HuaweiSupportProvider support = null;
|
||||
public RequestCallback() {}
|
||||
@ -122,6 +128,9 @@ public class Request {
|
||||
public void handleException(ResponseParseException e) {
|
||||
LOG.error("Callback request exception", e);
|
||||
}
|
||||
public void timeout(Request request) {
|
||||
request.handleNext();
|
||||
}
|
||||
}
|
||||
|
||||
public Request(HuaweiSupportProvider supportProvider, nodomain.freeyourgadget.gadgetbridge.service.btbr.TransactionBuilder builder) {
|
||||
@ -131,6 +140,15 @@ public class Request {
|
||||
this.builderBr = builder;
|
||||
|
||||
this.isSelfQueue = true;
|
||||
|
||||
this.handler = new Handler(Looper.getMainLooper());
|
||||
this.timeoutRunner = () -> {
|
||||
LOG.debug("Timeout on Service {} command {}", this.serviceId, this.commandId);
|
||||
if (finalizeReq != null)
|
||||
finalizeReq.timeout(this);
|
||||
else
|
||||
this.handleNext();
|
||||
};
|
||||
}
|
||||
|
||||
public Request(HuaweiSupportProvider supportProvider, nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder builder) {
|
||||
@ -140,6 +158,15 @@ public class Request {
|
||||
this.builderLe = builder;
|
||||
|
||||
this.isSelfQueue = true;
|
||||
|
||||
this.handler = new Handler(Looper.getMainLooper());
|
||||
this.timeoutRunner = () -> {
|
||||
LOG.debug("Timeout on Service {} command {}", this.serviceId, this.commandId);
|
||||
if (finalizeReq != null)
|
||||
finalizeReq.timeout(this);
|
||||
else
|
||||
this.handleNext();
|
||||
};
|
||||
}
|
||||
|
||||
public Request(HuaweiSupportProvider supportProvider) {
|
||||
@ -152,9 +179,27 @@ public class Request {
|
||||
this.builderLe = supportProvider.createLeTransactionBuilder(getName());
|
||||
|
||||
this.isSelfQueue = true;
|
||||
|
||||
this.handler = new Handler(Looper.getMainLooper());
|
||||
this.timeoutRunner = () -> {
|
||||
LOG.debug("Timeout on Service {} command {}", this.serviceId, this.commandId);
|
||||
if (finalizeReq != null)
|
||||
finalizeReq.timeout(this);
|
||||
else
|
||||
this.handleNext();
|
||||
};
|
||||
}
|
||||
|
||||
protected boolean requestSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void doPerform() throws IOException {
|
||||
if (!requestSupported()) {
|
||||
this.handleNext();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.addToResponse) {
|
||||
supportProvider.addInProgressRequest(this);
|
||||
}
|
||||
@ -191,6 +236,9 @@ public class Request {
|
||||
protected void processResponse() throws ResponseParseException {}
|
||||
|
||||
public void handleResponse() {
|
||||
// Stop timeout timer
|
||||
this.handler.removeCallbacks(this.timeoutRunner);
|
||||
|
||||
try {
|
||||
this.receivedPacket.parseTlv();
|
||||
} catch (HuaweiPacket.ParseException e) {
|
||||
@ -206,6 +254,10 @@ public class Request {
|
||||
finalizeReq.handleException(e);
|
||||
return;
|
||||
}
|
||||
handleNext();
|
||||
}
|
||||
|
||||
public void handleNext() {
|
||||
if (nextRequest != null && !stopChain) {
|
||||
try {
|
||||
nextRequest.doPerform();
|
||||
@ -299,6 +351,10 @@ public class Request {
|
||||
private void performConnected() throws IOException {
|
||||
LOG.debug("Perform connected");
|
||||
|
||||
// Start the timeout timer
|
||||
if (this.timeout != null)
|
||||
handler.postDelayed(this.timeoutRunner, this.timeout);
|
||||
|
||||
if (!this.supportProvider.isBLE()) {
|
||||
nodomain.freeyourgadget.gadgetbridge.service.btbr.Transaction transaction = this.builderBr.getTransaction();
|
||||
this.supportProvider.performConnected(transaction);
|
||||
@ -311,4 +367,16 @@ public class Request {
|
||||
public boolean autoRemoveFromResponseHandler() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setupTimeoutUntilNext(int timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
// Stop timeout timer
|
||||
this.handler.removeCallbacks(this.timeoutRunner);
|
||||
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.CameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||
@ -33,6 +35,11 @@ public class SendCameraRemoteSetupEvent extends Request {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsCameraRemote() && GBApplication.getDeviceSpecificSharedPrefs(supportProvider.getDevice().getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_CAMERA_REMOTE, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -41,6 +41,11 @@ public class SendDndAddRequest extends Request {
|
||||
this.commandId = DeviceConfig.DndAddRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsDoNotDisturb(supportProvider.getDevice());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
SharedPreferences sharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(supportProvider.getDeviceMac());
|
||||
|
@ -34,6 +34,11 @@ public class SendDndDeleteRequest extends Request {
|
||||
this.commandId = DeviceConfig.DndDeleteRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsDoNotDisturb(supportProvider.getDevice());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -37,6 +37,11 @@ public class SendExtendedAccountRequest extends Request {
|
||||
this.commandId = AccountRelated.SendExtendedAccountToDevice.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsAccountJudgment() && supportProvider.getHuaweiCoordinator().supportsAccountSwitch();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws Request.RequestCreationException {
|
||||
String account = GBApplication
|
||||
|
@ -37,6 +37,11 @@ public class SendFitnessGoalRequest extends Request {
|
||||
this.commandId = MotionGoal.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsMotionGoal();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -35,6 +35,11 @@ public class SendMenstrualCapabilityRequest extends Request {
|
||||
this.commandId = CapabilityRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsMenstrual();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -35,6 +35,11 @@ public class SendNotifyHeartRateCapabilityRequest extends Request {
|
||||
this.commandId = NotifyHeartRate.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsWorkoutsTrustHeartRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -35,6 +35,11 @@ public class SendNotifyRestHeartRateCapabilityRequest extends Request {
|
||||
this.commandId = NotifyRestHeartRate.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsFitnessRestHeartRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -35,6 +35,11 @@ public class SendSetUpDeviceStatusRequest extends Request {
|
||||
this.commandId = SetUpDeviceStatusRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsMultiDevice();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
int relationShip = 1; // Hardcoded value for now - 1 = mainDevice
|
||||
|
@ -36,6 +36,11 @@ public class SetActivateOnLiftRequest extends Request {
|
||||
this.commandId = DeviceConfig.ActivateOnLiftRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsActivateOnLift();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
boolean activate = GBApplication
|
||||
|
@ -40,6 +40,11 @@ public class SetActivityReminderRequest extends Request {
|
||||
this.commandId = FitnessData.ActivityReminder.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsActivityReminder();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
SharedPreferences sharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(supportProvider.getDeviceMac());
|
||||
|
@ -37,6 +37,11 @@ public class SetDateFormatRequest extends Request {
|
||||
this.commandId = DateFormat.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsDateFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
int time = DeviceConfig.Time.hours12;
|
||||
|
@ -41,6 +41,11 @@ public class SetLanguageSettingRequest extends Request {
|
||||
this.commandId = SetLanguageSetting.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsLanguageSetting();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
String localeString = GBApplication
|
||||
|
@ -35,6 +35,11 @@ public class SetMediumToStrengthThresholdRequest extends Request {
|
||||
this.commandId = MediumToStrengthThreshold.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsFitnessThresholdValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -36,6 +36,11 @@ public class SetNavigateOnRotateRequest extends Request {
|
||||
this.commandId = DeviceConfig.NavigateOnRotateRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsRotateToCycleInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
boolean navigate = GBApplication
|
||||
|
@ -36,6 +36,11 @@ public class SetNotificationRequest extends Request {
|
||||
this.commandId = Notifications.NotificationStateRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsNotification();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
boolean status = GBApplication
|
||||
|
@ -34,6 +34,11 @@ public class SetTimeZoneIdRequest extends Request {
|
||||
this.commandId = DeviceConfig.TimeZoneIdRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsTimeAndZoneId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
|
@ -36,6 +36,11 @@ public class SetTruSleepRequest extends Request {
|
||||
this.commandId = FitnessData.TruSleep.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsTruSleep();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
boolean truSleepSwitch = GBApplication
|
||||
|
@ -36,6 +36,11 @@ public class SetWearLocationRequest extends Request {
|
||||
this.commandId = DeviceConfig.WearLocationRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsWearLocation(supportProvider.getDevice());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
String locationString = GBApplication
|
||||
|
@ -36,6 +36,11 @@ public class SetWearMessagePushRequest extends Request {
|
||||
this.commandId = Notifications.WearMessagePushRequest.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestSupported() {
|
||||
return supportProvider.getHuaweiCoordinator().supportsDoNotDisturb(supportProvider.getDevice()) && supportProvider.getHuaweiCoordinator().supportsWearMessagePush();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
boolean status = GBApplication
|
||||
|
Loading…
Reference in New Issue
Block a user