Skip to content

Commit

Permalink
fix (AndroidFileDownloader.java, IOSFileDownloader.swift): if the fil…
Browse files Browse the repository at this point in the history
…e-downloading operation fails to commence we now return error code .FAILED__ERROR_UPON_COMMENCING / .failedErrorUponCommencing (old was: .errorInvalidSettings which wasn't accurate)
  • Loading branch information
ksidirop-laerdal committed Oct 3, 2024
1 parent bec12cc commit 7d2a1e4
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,33 @@ public EAndroidFileDownloaderVerdict beginDownload(
return EAndroidFileDownloaderVerdict.FAILED__INVALID_SETTINGS;
}

try
if (initialMtuSize > 0)
{
if (initialMtuSize > 0)
{
_transport.setInitialMtu(initialMtuSize);
}
_transport.setInitialMtu(initialMtuSize);
}

_fileSystemManager = new FsManager(_transport);
_fileSystemManager = new FsManager(_transport);

setLoggingEnabled(false);
requestHighConnectionPriority();
setLoggingEnabled(false);
requestHighConnectionPriority();

setState(EAndroidFileDownloaderState.IDLE);
busyStateChangedAdvertisement(true);
fileDownloadProgressPercentageAndDataThroughputChangedAdvertisement(0, 0);
setState(EAndroidFileDownloaderState.IDLE);
busyStateChangedAdvertisement(true);
fileDownloadProgressPercentageAndDataThroughputChangedAdvertisement(0, 0);

_initialBytes = 0;
_initialBytes = 0;
_remoteFilePathSanitized = remoteFilePathSanitized;

_remoteFilePathSanitized = remoteFilePathSanitized;
try
{
_downloadingController = _fileSystemManager.fileDownload(remoteFilePathSanitized, new FileDownloaderCallbackProxy());
}
catch (final Exception ex)
{
setState(EAndroidFileDownloaderState.ERROR);
fatalErrorOccurredAdvertisement(_remoteFilePathSanitized, ex.getMessage());

return EAndroidFileDownloaderVerdict.FAILED__INVALID_SETTINGS;
return EAndroidFileDownloaderVerdict.FAILED__ERROR_UPON_COMMENCING;
}

return EAndroidFileDownloaderVerdict.SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ public enum EAndroidFileDownloaderVerdict //this must mirror the enum values of
{
SUCCESS(0),
FAILED__INVALID_SETTINGS(1),
FAILED__DOWNLOAD_ALREADY_IN_PROGRESS(2);
FAILED__ERROR_UPON_COMMENCING(2),
FAILED__DOWNLOAD_ALREADY_IN_PROGRESS(3);

@SuppressWarnings({"FieldCanBeLocal", "unused"})
private final int _value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
public enum EIOSFileDownloadingInitializationVerdict: Int {
case success = 0
case failedInvalidSettings = 1
case failedDownloadAlreadyInProgress = 2
case failedErrorUponCommencing = 2
case failedDownloadAlreadyInProgress = 3
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class IOSFileDownloader: NSObject {
setState(EIOSFileDownloaderState.error)
fatalErrorOccurredAdvertisement(_remoteFilePathSanitized, "Failed to commence file-Downloading (check logs for details)")

return EIOSFileDownloadingInitializationVerdict.failedInvalidSettings
return EIOSFileDownloadingInitializationVerdict.failedErrorUponCommencing
}

return EIOSFileDownloadingInitializationVerdict.success
Expand Down
7 changes: 6 additions & 1 deletion Laerdal.McuMgr/Droid/FileDownloader/FileDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ static private EFileDownloaderVerdict TranslateFileDownloaderVerdict(EAndroidFil
{
return EFileDownloaderVerdict.FailedInvalidSettings;
}


if (verdict == EAndroidFileDownloaderVerdict.FailedErrorUponCommencing)
{
return EFileDownloaderVerdict.FailedErrorUponCommencing;
}

if (verdict == EAndroidFileDownloaderVerdict.FailedDownloadAlreadyInProgress)
{
return EFileDownloaderVerdict.FailedDownloadAlreadyInProgress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public enum EFileDownloaderVerdict //this must mirror the java enum values of E[
{
Success = 0,
FailedInvalidSettings = 1,
FailedDownloadAlreadyInProgress = 2,
FailedErrorUponCommencing = 2,
FailedDownloadAlreadyInProgress = 3,
}
}
5 changes: 5 additions & 0 deletions Laerdal.McuMgr/iOS/FileDownloader/FileDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ static private EFileDownloaderVerdict TranslateFileDownloaderVerdict(EIOSFileDow
{
return EFileDownloaderVerdict.FailedInvalidSettings;
}

if (verdict == EIOSFileDownloadingInitializationVerdict.FailedErrorUponCommencing)
{
return EFileDownloaderVerdict.FailedErrorUponCommencing;
}

if (verdict == EIOSFileDownloadingInitializationVerdict.FailedDownloadAlreadyInProgress)
{
Expand Down

0 comments on commit 7d2a1e4

Please sign in to comment.