SmsDetector doesnt check how many bytes where read from input
Created by: agilob
while (getSmsDetectionState()) {
try {
int bufferlen = dis.available();
if (bufferlen != 0) {
byte[] b = new byte[bufferlen];
dis.read(b);
String split[] = new String(b).split("\n");
checkForSilentSms(split);
} else {
Thread.sleep(1000);
}
You're reading data from dis
and doing nothing with it. It looks like you should do something with the input and this introduces a potential and very difficult to reproduce bug.
You cannot assume that any given stream reading call will fill the byte[] passed in to the method. Instead, you must check the value returned by the read method to see how many bytes were read.