1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 04:46:51 +01:00

Huawei: Send OK when starting GPS

I hope this will solve #3990.
This commit is contained in:
Martin.JM 2024-08-16 23:22:37 +02:00
parent cd46e24819
commit 75047ecdea
3 changed files with 67 additions and 0 deletions

View File

@ -88,6 +88,21 @@ public class GpsAndTime {
public static class GpsStatus {
public static final byte id = 0x02;
public static class Request extends HuaweiPacket {
public Request(ParamsProvider paramsProvider) {
super(paramsProvider);
this.serviceId = GpsAndTime.id;
this.commandId = id;
// Currently only sends "OK" value
this.tlv = new HuaweiTLV().put(0x7f, 0x186A0);
this.isEncrypted = true;
this.complete = true;
}
}
public static class Response extends HuaweiPacket {
public boolean enableGps;

View File

@ -58,6 +58,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Weather;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.Request;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetPhoneInfoRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendFileUploadComplete;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendGpsStatusRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendMenstrualModifyTimeRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendFileUploadAck;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendFileUploadChunk;
@ -510,6 +511,15 @@ public class AsynchronousResponse {
// TODO: exception?
return;
}
// Send back OK
try {
SendGpsStatusRequest sendGpsStatusRequest = new SendGpsStatusRequest(this.support);
sendGpsStatusRequest.doPerform();
} catch (IOException e) {
LOG.error("Could not send back OK");
}
support.setGps(((GpsAndTime.GpsStatus.Response) response).enableGps);
}
}

View File

@ -0,0 +1,42 @@
/* Copyright (C) 2024 Martin.JM
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 java.util.List;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.GpsAndTime;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
public class SendGpsStatusRequest extends Request {
public SendGpsStatusRequest(HuaweiSupportProvider support) {
super(support);
this.serviceId = GpsAndTime.id;
this.commandId = GpsAndTime.GpsStatus.id;
this.addToResponse = false;
}
@Override
protected List<byte[]> createRequest() throws RequestCreationException {
try {
return new GpsAndTime.GpsStatus.Request(this.paramsProvider).serialize();
} catch (HuaweiPacket.CryptoException e) {
throw new RequestCreationException(e);
}
}
}