diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/GpsAndTime.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/GpsAndTime.java index 922fb8b4a..d2b1c1673 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/GpsAndTime.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/GpsAndTime.java @@ -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; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/AsynchronousResponse.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/AsynchronousResponse.java index 7e440dc91..64094a572 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/AsynchronousResponse.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/AsynchronousResponse.java @@ -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); } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendGpsStatusRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendGpsStatusRequest.java new file mode 100644 index 000000000..8c0f9bbe2 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendGpsStatusRequest.java @@ -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 . */ +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 createRequest() throws RequestCreationException { + try { + return new GpsAndTime.GpsStatus.Request(this.paramsProvider).serialize(); + } catch (HuaweiPacket.CryptoException e) { + throw new RequestCreationException(e); + } + } +}