Skip to content

Commit

Permalink
fix NegativeArraySizeException crash in SecureDfuImpl.java
Browse files Browse the repository at this point in the history
  more detail: #229
  • Loading branch information
kcttanxiaofeng authored and philips77 committed Jun 25, 2020
1 parent e29fb40 commit fc59a92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,12 @@ private void sendFirmware(final BluetoothGatt gatt) throws RemoteDfuException,
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.
Expand Down

0 comments on commit fc59a92

Please sign in to comment.