1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-02 11:26:09 +02:00

fixup! huawei: Many fixes after pull review

This commit is contained in:
Vitaliy Tomin 2024-04-28 01:10:53 +08:00
parent ca026239e8
commit 0015b539c1
3 changed files with 16 additions and 17 deletions

View File

@ -54,17 +54,18 @@ public class FileUpload {
super(paramsProvider);
this.serviceId = FileUpload.id;
this.commandId = id;
String watchfaceName = fileName.split("_")[0];
String watchfaceVersion = fileName.split("_")[1];
this.tlv = new HuaweiTLV()
.put(0x01, fileName)
.put(0x02, fileSize)
.put(0x03, (byte) fileType);
if (fileType == Filetype.watchface)
if (fileType == Filetype.watchface) {
String watchfaceName = fileName.split("_")[0];
String watchfaceVersion = fileName.split("_")[1];
this.tlv.put(0x05, watchfaceName)
.put(0x06, watchfaceVersion);
.put(0x06, watchfaceVersion);
}
this.complete = true;
}

View File

@ -437,11 +437,13 @@ public class AsynchronousResponse {
try {
support.huaweiUploadManager.unsetDeviceBusy();
support.onUploadProgress(R.string.updatefirmwareoperation_update_complete, 100, false);
SendFileUploadComplete sendFileUploadComplete = new SendFileUploadComplete(this.support, this.support.huaweiUploadManager.getFileType());
SendWatchfaceOperation sendWatchfaceOperation = new SendWatchfaceOperation(this.support, this.support.huaweiUploadManager.getFileName(), Watchface.WatchfaceOperation.operationActive);
SendFileUploadComplete sendFileUploadComplete = new SendFileUploadComplete(this.support, support.huaweiUploadManager.getFileType());
sendFileUploadComplete.doPerform();
sendWatchfaceOperation.doPerform();
if (support.huaweiUploadManager.getFileType() == FileUpload.Filetype.watchface) {
//make uploaded watchface active
SendWatchfaceOperation sendWatchfaceOperation = new SendWatchfaceOperation(this.support, support.huaweiUploadManager.getFileName(), Watchface.WatchfaceOperation.operationActive);
sendWatchfaceOperation.doPerform();
}
} catch (IOException e) {
LOG.error("Could not send fileupload result request", e);
}

View File

@ -40,8 +40,6 @@ public class HuaweiFwHelper {
private byte[] fw;
private int fileSize = 0;
private boolean typeWatchface;
private byte fileType = 0;
String fileName = "";
@ -68,7 +66,6 @@ public class HuaweiFwHelper {
if (parseAsWatchFace()) {
assert watchfaceDescription.screen != null;
assert watchfaceDescription.title != null;
typeWatchface = true;
fileType = FileUpload.Filetype.watchface;
}
}
@ -82,6 +79,8 @@ public class HuaweiFwHelper {
}
boolean parseAsWatchFace() {
boolean isWatchface = false;
try {
final UriHelper uriHelper = UriHelper.get(uri, this.mContext);
@ -94,26 +93,23 @@ public class HuaweiFwHelper {
}
fw = watchfacePackage.getFileFromZip("com.huawei.watchface");
fileSize = fw.length;
isWatchface = true;
} catch (ZipFileException e) {
LOG.error("Unable to read watchface file.", e);
return false;
} catch (FileNotFoundException e) {
LOG.error("The watchface file was not found.", e);
return false;
} catch (IOException e) {
LOG.error("General IO error occurred.", e);
return false;
} catch (Exception e) {
LOG.error("Unknown error occurred.", e);
return false;
}
return true;
return isWatchface;
}
public boolean isWatchface() {
return typeWatchface;
return fileType == FileUpload.Filetype.watchface;
}
public boolean isValid() {
return isWatchface();