mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Huawei: Handle device status response for upload error state.
This commit is contained in:
+6
-3
@@ -30,7 +30,6 @@ import java.util.Objects;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Alarms;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.AccountRelated;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.App;
|
||||
@@ -147,7 +146,7 @@ public class HuaweiPacket {
|
||||
public void setAuthMode(byte authMode) { this.authMode = authMode; }
|
||||
|
||||
public byte[] getIv() {
|
||||
byte[] iv = null;
|
||||
byte[] iv;
|
||||
if (this.deviceSupportType == 0x04) {
|
||||
iv = HuaweiCrypto.generateNonce();
|
||||
} else {
|
||||
@@ -663,6 +662,10 @@ public class HuaweiPacket {
|
||||
return new FileUpload.FileUploadConsultAck.Response(paramsProvider).fromPacket(this);
|
||||
case FileUpload.FileNextChunkParams.id:
|
||||
return new FileUpload.FileNextChunkParams(paramsProvider).fromPacket(this);
|
||||
case FileUpload.FileUploadResult.id:
|
||||
return new FileUpload.FileUploadResult.Response(paramsProvider).fromPacket(this);
|
||||
case FileUpload.FileUploadDeviceResponse.id:
|
||||
return new FileUpload.FileUploadDeviceResponse.Response(paramsProvider).fromPacket(this);
|
||||
default:
|
||||
this.isEncrypted = this.attemptDecrypt(); // Helps with debugging
|
||||
return this;
|
||||
@@ -889,7 +892,7 @@ public class HuaweiPacket {
|
||||
int length = packet.position() - start;
|
||||
if (length != packetSize - footerLength) {
|
||||
// TODO: exception?
|
||||
LOG.error(String.format(GBApplication.getLanguage(), "Packet lengths don't match! %d != %d", length, packetSize + headerLength));
|
||||
LOG.error("Packet lengths don't match! {} != {}", length, packetSize + headerLength);
|
||||
}
|
||||
|
||||
byte[] complete = new byte[length];
|
||||
|
||||
+20
@@ -236,4 +236,24 @@ public class FileUpload {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FileUploadDeviceResponse {
|
||||
public static final byte id = 0x08;
|
||||
|
||||
public static class Response extends HuaweiPacket {
|
||||
public byte fileId = 0;
|
||||
public int code = 0;
|
||||
|
||||
public Response(ParamsProvider paramsProvider) {
|
||||
super(paramsProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseTlv() throws HuaweiPacket.ParseException {
|
||||
this.fileId = this.tlv.getByte(0x01, (byte) 0);
|
||||
this.code = this.tlv.getAsInteger(0x7f, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+17
@@ -528,6 +528,23 @@ public class AsynchronousResponse {
|
||||
LOG.error("Could not send file upload result request", e);
|
||||
}
|
||||
}
|
||||
} else if(response.commandId == FileUpload.FileUploadDeviceResponse.id) {
|
||||
// TODO: I don't currently know how to recover from this state. The proper solution is restart the watch or wait while timeout is expired in the watch
|
||||
// Usually happened on the programmer error on the previous state.
|
||||
// The value of timeout is unknown
|
||||
LOG.error("File upload error. Possible error in the previous state. Try to restart your watch.");
|
||||
if (support.huaweiUploadManager.getFileUploadInfo() == null) {
|
||||
LOG.error("No current upload");
|
||||
} else {
|
||||
FileUpload.FileUploadDeviceResponse.Response resp = (FileUpload.FileUploadDeviceResponse.Response) response;
|
||||
if(support.huaweiUploadManager.getFileUploadInfo().getFileId() == resp.fileId) {
|
||||
if (support.huaweiUploadManager.getFileUploadInfo().getFileUploadCallback() != null) {
|
||||
support.huaweiUploadManager.getFileUploadInfo().getFileUploadCallback().onError(resp.code);
|
||||
}
|
||||
//Cleanup
|
||||
support.huaweiUploadManager.setFileUploadInfo(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user