Merge pull request #253 from NordicSemiconductor/bugfix/252

Ignoring OPERATION NOT PERMITTED error when re-executing data object
This commit is contained in:
Aleksander Nowakowski 2020-06-25 09:30:08 +02:00 committed by GitHub
commit 82fa8cf189
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -554,8 +554,18 @@ class SecureDfuImpl extends BaseCustomDfuImpl {
// If the whole page was sent and CRC match, we have to make sure it was executed
if (bytesSentNotExecuted == info.maxSize && info.offset < mImageSizeInBytes) {
logi("Executing data object (Op Code = 4)");
writeExecute();
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_APPLICATION, "Data object executed");
try {
writeExecute();
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_APPLICATION, "Data object executed");
} catch (final RemoteDfuException e) {
// In DFU bootloader from SDK 15.x, 16 and 17 there's a bug, which
// prevents executing an object that has already been executed.
// See: https://github.com/NordicSemiconductor/Android-DFU-Library/issues/252
if (e.getErrorNumber() != SecureDfuError.OPERATION_NOT_PERMITTED) {
throw e;
}
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_APPLICATION, "Data object already executed");
}
} else {
resumeSendingData = true;
}