fix NegativeArraySizeException crash in SecureDfuImpl.java

more detail: https://github.com/NordicSemiconductor/Android-DFU-Library/issues/229
This commit is contained in:
谭小凤 2020-06-12 17:08:59 +08:00 committed by philips77
parent e29fb40607
commit fc59a92203
2 changed files with 13 additions and 0 deletions

View File

@ -627,6 +627,13 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
* Thrown when device had to be paired before the DFU process was started.
*/
public static final int ERROR_DEVICE_NOT_BONDED = ERROR_MASK | 0x0E;
/**
* Thrown when breakpoint resume fw
* <p>
* Check https://github.com/NordicSemiconductor/Android-DFU-Library/issues/229
* </p>
*/
public static final int ERROR_BREAKPOINT_RESUME = ERROR_MASK | 0x0F;
/**
* Flag set when the DFU target returned a DFU error. Look for DFU specification to get error
* codes. The error code is binary OR-ed with one of: {@link #ERROR_REMOTE_TYPE_LEGACY},

View File

@ -653,6 +653,12 @@ class SecureDfuImpl extends BaseCustomDfuImpl {
loge("Error while reading firmware stream", e);
mService.terminateConnection(gatt, DfuBaseService.ERROR_FILE_IO_EXCEPTION);
return;
} catch (final Throwable tr) {
// crash fix
// Check https://github.com/NordicSemiconductor/Android-DFU-Library/issues/229
loge("Error while reading firmware stream", tr);
mService.terminateConnection(gatt, DfuBaseService.ERROR_BREAKPOINT_RESUME);
return;
}
// To decrease the chance of loosing data next time let's set PRN to 1.
// This will make the update very long, but perhaps it will succeed.