mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-09 03:37:03 +01:00
huawei: Handle some watchface install errors
* handle too many watchface installed * handle insufficient space * sort related code while at it
This commit is contained in:
parent
cea51e6ef8
commit
1940db7204
@ -578,12 +578,14 @@ public class HuaweiPacket {
|
|||||||
}
|
}
|
||||||
case FileUpload.id:
|
case FileUpload.id:
|
||||||
switch(this.commandId) {
|
switch(this.commandId) {
|
||||||
case FileUpload.FileNextChunkParams.id:
|
case FileUpload.FileInfoSend.id:
|
||||||
return new FileUpload.FileNextChunkParams(paramsProvider).fromPacket(this);
|
return new FileUpload.FileInfoSend.Response(paramsProvider).fromPacket(this);
|
||||||
case FileUpload.FileUploadConsultAck.id:
|
|
||||||
return new FileUpload.FileUploadConsultAck.Response(paramsProvider).fromPacket(this);
|
|
||||||
case FileUpload.FileHashSend.id:
|
case FileUpload.FileHashSend.id:
|
||||||
return new FileUpload.FileHashSend.Response(paramsProvider).fromPacket(this);
|
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:
|
default:
|
||||||
this.isEncrypted = this.attemptDecrypt(); // Helps with debugging
|
this.isEncrypted = this.attemptDecrypt(); // Helps with debugging
|
||||||
return this;
|
return this;
|
||||||
@ -594,10 +596,10 @@ public class HuaweiPacket {
|
|||||||
return new Watchface.WatchfaceParams.Response(paramsProvider).fromPacket(this);
|
return new Watchface.WatchfaceParams.Response(paramsProvider).fromPacket(this);
|
||||||
case Watchface.DeviceWatchInfo.id:
|
case Watchface.DeviceWatchInfo.id:
|
||||||
return new Watchface.DeviceWatchInfo.Response(paramsProvider).fromPacket(this);
|
return new Watchface.DeviceWatchInfo.Response(paramsProvider).fromPacket(this);
|
||||||
case Watchface.WatchfaceNameInfo.id:
|
|
||||||
return new Watchface.WatchfaceNameInfo.Response(paramsProvider).fromPacket(this);
|
|
||||||
case Watchface.WatchfaceConfirm.id:
|
case Watchface.WatchfaceConfirm.id:
|
||||||
return new Watchface.WatchfaceConfirm.Response(paramsProvider).fromPacket(this);
|
return new Watchface.WatchfaceConfirm.Response(paramsProvider).fromPacket(this);
|
||||||
|
case Watchface.WatchfaceNameInfo.id:
|
||||||
|
return new Watchface.WatchfaceNameInfo.Response(paramsProvider).fromPacket(this);
|
||||||
default:
|
default:
|
||||||
this.isEncrypted = this.attemptDecrypt(); // Helps with debugging
|
this.isEncrypted = this.attemptDecrypt(); // Helps with debugging
|
||||||
return this;
|
return this;
|
||||||
|
@ -72,9 +72,14 @@ public class FileUpload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Response extends HuaweiPacket {
|
public static class Response extends HuaweiPacket {
|
||||||
|
public int result = 0;
|
||||||
public Response (ParamsProvider paramsProvider) {
|
public Response (ParamsProvider paramsProvider) {
|
||||||
super(paramsProvider);
|
super(paramsProvider);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void parseTlv() throws HuaweiPacket.ParseException {
|
||||||
|
this.result = this.tlv.getInteger(0x7f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.CameraActivity;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||||
@ -415,7 +416,18 @@ public class AsynchronousResponse {
|
|||||||
|
|
||||||
private void handleFileUpload(HuaweiPacket response) throws Request.ResponseParseException {
|
private void handleFileUpload(HuaweiPacket response) throws Request.ResponseParseException {
|
||||||
if (response.serviceId == FileUpload.id) {
|
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))
|
if (!(response instanceof FileUpload.FileHashSend.Response))
|
||||||
throw new Request.ResponseTypeMismatchException(response, FileUpload.FileHashSend.Response.class);
|
throw new Request.ResponseTypeMismatchException(response, FileUpload.FileHashSend.Response.class);
|
||||||
FileUpload.FileHashSend.Response resp = (FileUpload.FileHashSend.Response) response;
|
FileUpload.FileHashSend.Response resp = (FileUpload.FileHashSend.Response) response;
|
||||||
|
@ -47,6 +47,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiCoordinator;
|
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) {
|
public void setGps(boolean start) {
|
||||||
if (start) {
|
if (start) {
|
||||||
if (!GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_WORKOUT_SEND_GPS_TO_BAND, false))
|
if (!GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_WORKOUT_SEND_GPS_TO_BAND, false))
|
||||||
|
@ -3147,4 +3147,6 @@
|
|||||||
<string name="battery_percentage_str">%1$s%%</string>
|
<string name="battery_percentage_str">%1$s%%</string>
|
||||||
<string name="pref_fetch_unknown_files_title">Fetch unknown files</string>
|
<string name="pref_fetch_unknown_files_title">Fetch unknown files</string>
|
||||||
<string name="pref_fetch_unknown_files_summary">Fetch unknown activity files from the watch. They will not be processed, but will be saved in the phone.</string>
|
<string name="pref_fetch_unknown_files_summary">Fetch unknown activity files from the watch. They will not be processed, but will be saved in the phone.</string>
|
||||||
|
<string name="cannot_upload_watchface_too_many_watchfaces_installed">"Cannot upload watchface, too many watchfaces installed"</string>
|
||||||
|
<string name="insufficient_space_for_upload">"Insufficient space for upload"</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user