diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiPacket.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiPacket.java
index 46260f990..87a24c6d2 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiPacket.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiPacket.java
@@ -578,12 +578,14 @@ public class HuaweiPacket {
}
case FileUpload.id:
switch(this.commandId) {
- case FileUpload.FileNextChunkParams.id:
- return new FileUpload.FileNextChunkParams(paramsProvider).fromPacket(this);
- case FileUpload.FileUploadConsultAck.id:
- return new FileUpload.FileUploadConsultAck.Response(paramsProvider).fromPacket(this);
+ case FileUpload.FileInfoSend.id:
+ return new FileUpload.FileInfoSend.Response(paramsProvider).fromPacket(this);
case FileUpload.FileHashSend.id:
return new FileUpload.FileHashSend.Response(paramsProvider).fromPacket(this);
+ case FileUpload.FileUploadConsultAck.id:
+ return new FileUpload.FileUploadConsultAck.Response(paramsProvider).fromPacket(this);
+ case FileUpload.FileNextChunkParams.id:
+ return new FileUpload.FileNextChunkParams(paramsProvider).fromPacket(this);
default:
this.isEncrypted = this.attemptDecrypt(); // Helps with debugging
return this;
@@ -594,10 +596,10 @@ public class HuaweiPacket {
return new Watchface.WatchfaceParams.Response(paramsProvider).fromPacket(this);
case Watchface.DeviceWatchInfo.id:
return new Watchface.DeviceWatchInfo.Response(paramsProvider).fromPacket(this);
- case Watchface.WatchfaceNameInfo.id:
- return new Watchface.WatchfaceNameInfo.Response(paramsProvider).fromPacket(this);
case Watchface.WatchfaceConfirm.id:
return new Watchface.WatchfaceConfirm.Response(paramsProvider).fromPacket(this);
+ case Watchface.WatchfaceNameInfo.id:
+ return new Watchface.WatchfaceNameInfo.Response(paramsProvider).fromPacket(this);
default:
this.isEncrypted = this.attemptDecrypt(); // Helps with debugging
return this;
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/FileUpload.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/FileUpload.java
index b94401bfc..5c5793c02 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/FileUpload.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/FileUpload.java
@@ -72,9 +72,14 @@ public class FileUpload {
}
public static class Response extends HuaweiPacket {
+ public int result = 0;
public Response (ParamsProvider paramsProvider) {
super(paramsProvider);
}
+ @Override
+ public void parseTlv() throws HuaweiPacket.ParseException {
+ this.result = this.tlv.getInteger(0x7f);
+ }
}
}
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 64094a572..3b99f0918 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
@@ -42,6 +42,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.CameraActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
+import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
@@ -415,7 +416,18 @@ public class AsynchronousResponse {
private void handleFileUpload(HuaweiPacket response) throws Request.ResponseParseException {
if (response.serviceId == FileUpload.id) {
- if (response.commandId == FileUpload.FileHashSend.id) {
+ if (response.commandId == FileUpload.FileInfoSend.id) {
+ if (!(response instanceof FileUpload.FileInfoSend.Response))
+ throw new Request.ResponseTypeMismatchException(response, FileUpload.FileInfoSend.Response.class);
+ FileUpload.FileInfoSend.Response resp = (FileUpload.FileInfoSend.Response) response;
+ if (resp.result == 140004) {
+ LOG.error("Too many watchfaces installed");
+ support.handleGBDeviceEvent(new GBDeviceEventDisplayMessage(support.getContext().getString(R.string.cannot_upload_watchface_too_many_watchfaces_installed), Toast.LENGTH_LONG, GB.ERROR));
+ } else if (resp.result == 140009) {
+ LOG.error("Insufficient space for upload");
+ support.handleGBDeviceEvent(new GBDeviceEventDisplayMessage(support.getContext().getString(R.string.insufficient_space_for_upload), Toast.LENGTH_LONG, GB.ERROR));
+ }
+ } else if (response.commandId == FileUpload.FileHashSend.id) {
if (!(response instanceof FileUpload.FileHashSend.Response))
throw new Request.ResponseTypeMismatchException(response, FileUpload.FileHashSend.Response.class);
FileUpload.FileHashSend.Response resp = (FileUpload.FileHashSend.Response) response;
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java
index 8ac7891ee..8de2af2a4 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java
@@ -47,6 +47,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
+import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiCoordinator;
@@ -258,6 +259,14 @@ public class HuaweiSupportProvider {
}
}
+ public void handleGBDeviceEvent(GBDeviceEventDisplayMessage message) {
+ if (isBLE()) {
+ leSupport.handleGBDeviceEvent(message);
+ } else {
+ brSupport.handleGBDeviceEvent(message);
+ }
+ }
+
public void setGps(boolean start) {
if (start) {
if (!GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_WORKOUT_SEND_GPS_TO_BAND, false))
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f5eb2e1cc..2cfa2107a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -3147,4 +3147,6 @@
%1$s%%
Fetch unknown files
Fetch unknown activity files from the watch. They will not be processed, but will be saved in the phone.
+ "Cannot upload watchface, too many watchfaces installed"
+ "Insufficient space for upload"