[Huawei] Initial AcceptAgreement packet and request

This commit is contained in:
Vitaliy Tomin 2024-03-14 23:32:47 +08:00 committed by Damien 'Psolyca' Gaignon
parent 924088e5a3
commit 6167f3f781
No known key found for this signature in database
GPG Key ID: 9E9404E5D9E11843
4 changed files with 113 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2024 Damien Gaignon, Martin.JM
/* Copyright (C) 2024 Damien Gaignon, Martin.JM, Vitalii Tomin
This file is part of Gadgetbridge.
@ -243,6 +243,10 @@ public class HuaweiCoordinator {
return supportsCommandForService(0x01, 0x1d);
}
public boolean supportsAcceptAgreement() {
return supportsCommandForService(0x01, 0x30);
}
public boolean supportsSettingRelated() {
return supportsCommandForService(0x01, 0x31);
}

View File

@ -1410,6 +1410,46 @@ public class DeviceConfig {
// TODO: implement parsing this request for the log parser support
}
public static class AcceptAgreement {
public static final int id = 0x30;
public static class Request extends HuaweiPacket {
public Request(ParamsProvider paramsProvider) {
super(paramsProvider);
this.serviceId = DeviceConfig.id;
this.commandId = id;
int timestamp = (int) (System.currentTimeMillis() / 1000);
HuaweiTLV software = new HuaweiTLV()
.put(0x03, "software_update_service_statement")
.put(0x04, 0x01)
.put(0x05, "20230508-20230508-0-0")
.put(0x06, timestamp);
HuaweiTLV device_information = new HuaweiTLV()
.put(0x03, "device_information_management")
.put(0x04,0x01)
.put(0x05, "20230508-20230508-0-0")
.put(0x06,timestamp);
HuaweiTLV user_license = new HuaweiTLV()
.put(0x03, "user_license_agreement")
.put(0x04,0x01)
.put(0x05, "20230508-20230508-0-0")
.put(0x06,timestamp);
HuaweiTLV tlvList = new HuaweiTLV()
.put(0x82, software)
.put(0x82,device_information)
.put(0x82,user_license);
this.tlv = new HuaweiTLV()
.put(0x81, tlvList);
}
}
}
public static class SettingRelated {
public static final int id = 0x31;

View File

@ -75,6 +75,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
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.requests.AcceptAgreementsRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetEventAlarmList;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetNotificationConstraintsRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetSmartAlarmList;
@ -596,22 +597,27 @@ public class HuaweiSupportProvider {
GetExpandCapabilityRequest expandCapabilityReq = new GetExpandCapabilityRequest(this);
expandCapabilityReq.doPerform();
}
if (getHuaweiCoordinator().supportsAccount()) {
SendAccountRequest sendAccountReq = new SendAccountRequest(this);
sendAccountReq.doPerform();
}
if (getHuaweiCoordinator().supportsAccountJudgment() && getHuaweiCoordinator().supportsAccountSwitch()) {
SendExtendedAccountRequest sendExtendedAccountRequest = new SendExtendedAccountRequest(this);
sendExtendedAccountRequest.doPerform();
}
if (getHuaweiCoordinator().supportsActivityType()) {
GetActivityTypeRequest activityTypeReq = new GetActivityTypeRequest(this);
activityTypeReq.doPerform();
}
if (getHuaweiCoordinator().supportsSettingRelated()) { // GetSettingRelated
GetSettingRelatedRequest getSettingRelatedReq = new GetSettingRelatedRequest(this);
getSettingRelatedReq.doPerform();
}
if (getHuaweiCoordinator().supportsAcceptAgreement()) {
AcceptAgreementsRequest acceptAgreementsRequest = new AcceptAgreementsRequest(this);
acceptAgreementsRequest.doPerform();
}
if (getHuaweiCoordinator().supportsAccount()) {
SendAccountRequest sendAccountReq = new SendAccountRequest(this);
sendAccountReq.doPerform();
}
if (getHuaweiCoordinator().supportsActivityType()) {
GetActivityTypeRequest activityTypeReq = new GetActivityTypeRequest(this);
activityTypeReq.doPerform();
}
if (getHuaweiCoordinator().supportsConnectStatus()) {
GetConnectStatusRequest getConnectStatusReq = new GetConnectStatusRequest(this);
getConnectStatusReq.doPerform();

View File

@ -0,0 +1,54 @@
/* Copyright (C) 2024 Vitalii Tomin
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
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);
this.serviceId = DeviceConfig.id;
this.commandId = DeviceConfig.AcceptAgreement.id;
}
protected List<byte[]> createRequest() throws RequestCreationException {
try {
return new DeviceConfig.AcceptAgreement.Request(paramsProvider).serialize();
} catch (HuaweiPacket.CryptoException e) {
throw new RequestCreationException(e);
}
}
}