Lint errors fixed

This commit is contained in:
Aleksander Nowakowski 2015-01-27 11:36:31 +01:00
parent f62a4b45af
commit a2707cd31b
4 changed files with 15 additions and 17 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/../../nRFMasterControlPanel" external.system.id="GRADLE" type="JAVA_MODULE" version="4"> <module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/../../nRFToolbox" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager"> <component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle"> <facet type="android-gradle" name="Android-Gradle">
<configuration> <configuration>

View File

@ -422,7 +422,7 @@ public abstract class DfuBaseService extends IntentService {
*/ */
private int mPacketsBeforeNotification = 10; private int mPacketsBeforeNotification = 10;
private byte[] mBuffer = new byte[MAX_PACKET_SIZE]; private final byte[] mBuffer = new byte[MAX_PACKET_SIZE];
private InputStream mInputStream; private InputStream mInputStream;
/** /**
* Size of BIN content of all hex files that are going to be transmitted. * Size of BIN content of all hex files that are going to be transmitted.

View File

@ -33,16 +33,15 @@ public class HexInputStream extends FilterInputStream {
private int size; private int size;
private int lastAddress; private int lastAddress;
private int available, bytesRead; private int available, bytesRead;
private int MBRsize; private final int MBRSize;
/** /**
* Creates the HEX Input Stream. The constructor calculates the size of the BIN content which is available through {@link #sizeInBytes()}. If HEX file is invalid then the bin size is 0. * Creates the HEX Input Stream. The constructor calculates the size of the BIN content which is available through {@link #sizeInBytes()}. If HEX file is invalid then the bin size is 0.
* *
* @param in * @param in
* the input stream to read from * the input stream to read from
* @param trim * @param mbrSize
* if <code>true</code> the bin data will be trimmed. All data from addresses < 0x1000 will be skipped. In the Soft Device 7.0.0 it's MBR space and this HEX fragment should not be * The MBR (Master Boot Record) size in bytes. Data with addresses below than number will be trimmed and not transferred to DFU target.
* transmitted. However, other DFU implementations (f.e. without Soft Device) may require uploading the whole file.
* @throws HexFileValidationException * @throws HexFileValidationException
* if HEX file is invalid. F.e. there is no semicolon (':') on the beginning of each line. * if HEX file is invalid. F.e. there is no semicolon (':') on the beginning of each line.
* @throws java.io.IOException * @throws java.io.IOException
@ -54,7 +53,7 @@ public class HexInputStream extends FilterInputStream {
this.localPos = LINE_LENGTH; // we are at the end of the local buffer, new one must be obtained this.localPos = LINE_LENGTH; // we are at the end of the local buffer, new one must be obtained
this.size = localBuf.length; this.size = localBuf.length;
this.lastAddress = 0; this.lastAddress = 0;
this.MBRsize = mbrSize; this.MBRSize = mbrSize;
this.available = calculateBinSize(mbrSize); this.available = calculateBinSize(mbrSize);
} }
@ -65,7 +64,7 @@ public class HexInputStream extends FilterInputStream {
this.localPos = LINE_LENGTH; // we are at the end of the local buffer, new one must be obtained this.localPos = LINE_LENGTH; // we are at the end of the local buffer, new one must be obtained
this.size = localBuf.length; this.size = localBuf.length;
this.lastAddress = 0; this.lastAddress = 0;
this.MBRsize = mbrSize; this.MBRSize = mbrSize;
this.available = calculateBinSize(mbrSize); this.available = calculateBinSize(mbrSize);
} }
@ -77,7 +76,7 @@ public class HexInputStream extends FilterInputStream {
int b, lineSize, offset, type; int b, lineSize, offset, type;
int lastBaseAddress = 0; // last Base Address, default 0 int lastBaseAddress = 0; // last Base Address, default 0
int lastAddress = 0; int lastAddress;
try { try {
b = in.read(); b = in.read();
while (true) { while (true) {
@ -214,7 +213,7 @@ public class HexInputStream extends FilterInputStream {
final InputStream in = this.in; final InputStream in = this.in;
// temporary value // temporary value
int b = 0; int b;
int lineSize, type, offset; int lineSize, type, offset;
do { do {
@ -249,7 +248,7 @@ public class HexInputStream extends FilterInputStream {
switch (type) { switch (type) {
case 0x00: case 0x00:
// data type // data type
if (lastAddress + offset < MBRsize) { // skip MBR if (lastAddress + offset < MBRSize) { // skip MBR
type = -1; // some other than 0 type = -1; // some other than 0
pos += in.skip(lineSize * 2 /* 2 hex per one byte */+ 2 /* check sum */); pos += in.skip(lineSize * 2 /* 2 hex per one byte */+ 2 /* check sum */);
} }

View File

@ -43,11 +43,10 @@ public class ZipHexInputStream extends ZipInputStream {
* *
* @param stream * @param stream
* the Zip Input Stream * the Zip Input Stream
* @param mbrSize
* The size of the MRB segment (Master Boot Record) on the device. The parser will cut data from addresses below that number from all HEX files.
* @param types * @param types
* files to read * File types that are to be read from the ZIP. Use {@link DfuBaseService#TYPE_APPLICATION} etc.
* @param trim
* if <code>true</code> the bin data will be trimmed. All data from addresses < 0x1000 will be skipped. In the Soft Device 7.0.0 it's MBR space and this HEX fragment should not be
* transmitted. However, other DFU implementations (f.e. without Soft Device) may require uploading the whole file.
* @throws java.io.IOException * @throws java.io.IOException
*/ */
public ZipHexInputStream(final InputStream stream, final int mbrSize, final int types) throws IOException { public ZipHexInputStream(final InputStream stream, final int mbrSize, final int types) throws IOException {
@ -127,7 +126,7 @@ public class ZipHexInputStream extends ZipInputStream {
currentSource = source; currentSource = source;
} else if (systemInit) { } else if (systemInit) {
systemInitBytes = source; systemInitBytes = source;
} else if (applicationInit) { } else { // if (applicationInit) - always true
applicationInitBytes = source; applicationInitBytes = source;
} }
} }
@ -220,7 +219,7 @@ public class ZipHexInputStream extends ZipInputStream {
* @return the new source, the same as {@link #currentSource} * @return the new source, the same as {@link #currentSource}
*/ */
private byte[] startNextFile() { private byte[] startNextFile() {
byte[] ret = null; byte[] ret;
if (currentSource == softDeviceBytes && bootloaderBytes != null) { if (currentSource == softDeviceBytes && bootloaderBytes != null) {
ret = currentSource = bootloaderBytes; ret = currentSource = bootloaderBytes;
} else if (currentSource != applicationBytes && applicationBytes != null) { } else if (currentSource != applicationBytes && applicationBytes != null) {