This commit is contained in:
Aleksander Nowakowski 2018-12-04 10:31:57 +01:00
parent b8c88d0ecd
commit a37e5328d7
2 changed files with 22 additions and 1 deletions

View File

@ -305,7 +305,11 @@ import no.nordicsemi.android.dfu.internal.scanner.BootloaderScannerFactory;
mInitPacketSizeInBytes = size;
try {
if (firmwareStream.markSupported()) {
firmwareStream.reset();
if (firmwareStream instanceof ArchiveInputStream) {
((ArchiveInputStream) firmwareStream).fullReset();
} else {
firmwareStream.reset();
}
}
size = firmwareStream.available();
} catch (final Exception e) {

View File

@ -403,6 +403,23 @@ public class ArchiveInputStream extends InputStream {
crc32.update(currentSource, 0, bytesReadFromCurrentSource);
}
/**
* Resets to the beginning of current stream.
* If SD and BL were updated, the stream will be reset to the beginning.
* If SD and BL were already sent and the current stream was changed to application,
* this method will reset to the beginning of the application stream.
*/
public void fullReset() {
// Reset stream to SoftDevice if SD and BL firmware were given separately
if (softDeviceBytes != null && bootloaderBytes != null && currentSource == bootloaderBytes) {
currentSource = softDeviceBytes;
}
// Reset the bytes count to 0
bytesReadFromCurrentSource = 0;
mark(0);
reset();
}
/**
* Returns number of bytes read until now.
*/