huawei: fileuplaod: FileUploadParams refactoring
This commit is contained in:
parent
8fd8f2324d
commit
3a8fbbe4d3
|
@ -5,6 +5,21 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiTLV;
|
|||
|
||||
public class FileUpload {
|
||||
public static final byte id = 0x28;
|
||||
|
||||
public static class FileUploadParams {
|
||||
public byte file_id = 0;
|
||||
public String protocolVersion = "";
|
||||
public short app_wait_time = 0;
|
||||
|
||||
public byte bitmap_enable = 0;
|
||||
public short unit_size = 0;
|
||||
public int max_apply_data_size = 0;
|
||||
public short interval =0;
|
||||
public int received_file_size =0;
|
||||
|
||||
public byte no_encrypt = 0;
|
||||
}
|
||||
|
||||
public static class FileInfoSend {
|
||||
public static final byte id = 0x02;
|
||||
public static class Request extends HuaweiPacket {
|
||||
|
@ -86,17 +101,7 @@ public class FileUpload {
|
|||
|
||||
public static class Response extends HuaweiPacket {
|
||||
|
||||
public byte file_id = 0;
|
||||
public String protocolVersion = "";
|
||||
public short app_wait_time = 0;
|
||||
|
||||
public byte bitmap_enable = 0;
|
||||
public short unit_size = 0;
|
||||
public int max_apply_data_size = 0;
|
||||
public short interval =0;
|
||||
public int received_file_size =0;
|
||||
|
||||
public byte no_encrypt = 0;
|
||||
public FileUploadParams fileUploadParams;
|
||||
public Response (ParamsProvider paramsProvider) {
|
||||
super(paramsProvider);
|
||||
}
|
||||
|
@ -104,23 +109,23 @@ public class FileUpload {
|
|||
@Override
|
||||
public void parseTlv() throws HuaweiPacket.ParseException {
|
||||
if (this.tlv.contains(0x01) && this.tlv.getBytes(0x01).length == 1)
|
||||
this.file_id = this.tlv.getByte(0x01);
|
||||
this.fileUploadParams.file_id = this.tlv.getByte(0x01);
|
||||
if (this.tlv.contains(0x02))
|
||||
this.protocolVersion = this.tlv.getString(0x02);
|
||||
this.fileUploadParams.protocolVersion = this.tlv.getString(0x02);
|
||||
if (this.tlv.contains(0x03) && this.tlv.getBytes(0x03).length == 2)
|
||||
this.app_wait_time = this.tlv.getShort(0x03);
|
||||
this.fileUploadParams.app_wait_time = this.tlv.getShort(0x03);
|
||||
if (this.tlv.contains(0x04))
|
||||
this.bitmap_enable = this.tlv.getByte(0x04);
|
||||
this.fileUploadParams.bitmap_enable = this.tlv.getByte(0x04);
|
||||
if (this.tlv.contains(0x05) && this.tlv.getBytes(0x05).length == 2)
|
||||
this.unit_size = this.tlv.getShort(0x05);
|
||||
this.fileUploadParams.unit_size = this.tlv.getShort(0x05);
|
||||
if (this.tlv.contains(0x06) && this.tlv.getBytes(0x06).length == 4)
|
||||
this.max_apply_data_size = this.tlv.getInteger(0x06);
|
||||
this.fileUploadParams.max_apply_data_size = this.tlv.getInteger(0x06);
|
||||
if (this.tlv.contains(0x07) && this.tlv.getBytes(0x07).length == 2)
|
||||
this.interval = this.tlv.getShort(0x07);
|
||||
this.fileUploadParams.interval = this.tlv.getShort(0x07);
|
||||
if (this.tlv.contains(0x08) && this.tlv.getBytes(0x08).length == 4)
|
||||
this.received_file_size = this.tlv.getInteger(0x08);
|
||||
this.fileUploadParams.received_file_size = this.tlv.getInteger(0x08);
|
||||
if (this.tlv.contains(0x09))
|
||||
this.no_encrypt = this.tlv.getByte(0x09);
|
||||
this.fileUploadParams.no_encrypt = this.tlv.getByte(0x09);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,18 +404,10 @@ public class AsynchronousResponse {
|
|||
throw new Request.ResponseTypeMismatchException(response, FileUpload.FileUploadConsultAck.Response.class);
|
||||
FileUpload.FileUploadConsultAck.Response resp = (FileUpload.FileUploadConsultAck.Response) response;
|
||||
|
||||
support.huaweiUploadManager.setFileId(resp.file_id);
|
||||
support.huaweiUploadManager.setProtocolVersion(resp.protocolVersion);
|
||||
support.huaweiUploadManager.setAppWaitTime(resp.app_wait_time);
|
||||
support.huaweiUploadManager.setBitmapEnable(resp.bitmap_enable);
|
||||
support.huaweiUploadManager.setUnitSize(resp.unit_size);
|
||||
support.huaweiUploadManager.setMaxApplyDataSize(resp.max_apply_data_size);
|
||||
support.huaweiUploadManager.setInterval(resp.interval);
|
||||
support.huaweiUploadManager.setReceivedFileSize(resp.received_file_size);
|
||||
support.huaweiUploadManager.setNoEncrypt(resp.no_encrypt);
|
||||
support.huaweiUploadManager.setFileUploadParams(resp.fileUploadParams);
|
||||
|
||||
try {
|
||||
SendFileUploadAck sendFileUploadAck = new SendFileUploadAck(this.support, resp.no_encrypt);
|
||||
SendFileUploadAck sendFileUploadAck = new SendFileUploadAck(this.support, resp.fileUploadParams.no_encrypt);
|
||||
sendFileUploadAck.doPerform();
|
||||
} catch (IOException e) {
|
||||
LOG.error("Could not send fileupload ack request", e);
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.io.IOException;
|
|||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.FileUpload.FileUploadParams;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.UriHelper;
|
||||
|
@ -29,17 +30,7 @@ public class HuaweiUploadManager {
|
|||
String watchfaceVersion = "1.0.0"; //FIXME generate random version
|
||||
|
||||
//ack values set from 28 4 response
|
||||
byte fileId = 0;
|
||||
String protocolVersion = "";
|
||||
short appWaitTime = 0;
|
||||
|
||||
byte bitmapEnable = 0;
|
||||
short unitSize = 0;
|
||||
int maxApplyDataSize = 0;
|
||||
short interval =0;
|
||||
int receivedFileSize =0;
|
||||
|
||||
byte noEncrypt = 0;
|
||||
FileUploadParams fileUploadParams;
|
||||
|
||||
|
||||
public HuaweiUploadManager(HuaweiSupportProvider support) {
|
||||
|
@ -124,43 +115,14 @@ public class HuaweiUploadManager {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public void setFileId(byte fileId) {
|
||||
this.fileId = fileId;
|
||||
public void setFileUploadParams(FileUploadParams params) {
|
||||
this.fileUploadParams = params;
|
||||
}
|
||||
|
||||
public void setProtocolVersion(String protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
public void setInterval(short interval) {
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
public void setMaxApplyDataSize(int maxApplyDataSize) {
|
||||
this.maxApplyDataSize = maxApplyDataSize;
|
||||
}
|
||||
|
||||
public void setAppWaitTime(short appWaitTime) {
|
||||
this.appWaitTime = appWaitTime;
|
||||
}
|
||||
|
||||
public void setBitmapEnable(byte bitmapEnable) {
|
||||
this.bitmapEnable = bitmapEnable;
|
||||
}
|
||||
|
||||
public void setUnitSize(short unitSize) {
|
||||
this.unitSize = unitSize;
|
||||
}
|
||||
|
||||
public short getUnitSize() {
|
||||
return unitSize;
|
||||
return fileUploadParams.unit_size;
|
||||
}
|
||||
|
||||
public void setNoEncrypt(byte noEncrypt) {
|
||||
this.noEncrypt = noEncrypt;
|
||||
}
|
||||
|
||||
public void setReceivedFileSize(int receivedFileSize) {
|
||||
this.receivedFileSize = receivedFileSize;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue