kotlin lints
This commit is contained in:
parent
62462b4f83
commit
6b4ee247b3
5 changed files with 15 additions and 30 deletions
|
@ -25,6 +25,7 @@ public class HistoryEvent implements Comparable<HistoryEvent> {
|
|||
event = eventClass.newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
//log.error("Unhandled exception", e);
|
||||
event = new HistoryEvent();
|
||||
}
|
||||
}
|
||||
event.parseHeader(byteBuf);
|
||||
|
|
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps.danar;
|
|||
import android.bluetooth.BluetoothSocket;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -31,6 +33,8 @@ public class SerialIOThread extends Thread {
|
|||
private final MessageHashTableBase hashTable;
|
||||
private final DanaPump danaPump;
|
||||
|
||||
private final Object lock = new Object();
|
||||
|
||||
public SerialIOThread(AAPSLogger aapsLogger, BluetoothSocket rfcommSocket, MessageHashTableBase hashTable, DanaPump danaPump) {
|
||||
super();
|
||||
this.hashTable = hashTable;
|
||||
|
@ -80,7 +84,7 @@ public class SerialIOThread extends Thread {
|
|||
// process the message content
|
||||
message.setReceived(true);
|
||||
message.handleMessage(extractedBuff);
|
||||
synchronized (message) {
|
||||
synchronized (lock) {
|
||||
message.notifyAll();
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +105,7 @@ public class SerialIOThread extends Thread {
|
|||
mReadBuff = newReadBuff;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private byte[] cutMessageFromBuffer() {
|
||||
if (mReadBuff[0] == (byte) 0x7E && mReadBuff[1] == (byte) 0x7E) {
|
||||
int length = (mReadBuff[2] & 0xFF) + 7;
|
||||
|
@ -109,7 +114,7 @@ public class SerialIOThread extends Thread {
|
|||
return null;
|
||||
}
|
||||
if (mReadBuff[length - 2] != (byte) 0x2E || mReadBuff[length - 1] != (byte) 0x2E) {
|
||||
aapsLogger.error("wrong packet lenght=" + length + " data " + MessageBase.Companion.toHexString(mReadBuff));
|
||||
aapsLogger.error("wrong packet length=" + length + " data " + MessageBase.Companion.toHexString(mReadBuff));
|
||||
disconnect("wrong packet");
|
||||
return null;
|
||||
}
|
||||
|
@ -157,12 +162,10 @@ public class SerialIOThread extends Thread {
|
|||
aapsLogger.error("sendMessage write exception: ", e);
|
||||
}
|
||||
|
||||
synchronized (message) {
|
||||
try {
|
||||
message.wait(5000);
|
||||
} catch (InterruptedException e) {
|
||||
aapsLogger.error("sendMessage InterruptedException", e);
|
||||
}
|
||||
try {
|
||||
message.wait(5000);
|
||||
} catch (InterruptedException e) {
|
||||
aapsLogger.error("sendMessage InterruptedException", e);
|
||||
}
|
||||
|
||||
SystemClock.sleep(200);
|
||||
|
@ -194,11 +197,6 @@ public class SerialIOThread extends Thread {
|
|||
} catch (Exception e) {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, e.getMessage());
|
||||
}
|
||||
try {
|
||||
System.runFinalization();
|
||||
} catch (Exception e) {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, e.getMessage());
|
||||
}
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Disconnected: " + reason);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.io.IOException;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin;
|
||||
import info.nightscout.androidaps.danar.SerialIOThread;
|
||||
|
@ -46,38 +45,26 @@ import info.nightscout.interfaces.profile.Profile;
|
|||
import info.nightscout.interfaces.profile.ProfileFunction;
|
||||
import info.nightscout.interfaces.pump.BolusProgressData;
|
||||
import info.nightscout.interfaces.pump.PumpEnactResult;
|
||||
import info.nightscout.interfaces.pump.PumpSync;
|
||||
import info.nightscout.interfaces.pump.defs.PumpType;
|
||||
import info.nightscout.interfaces.queue.Callback;
|
||||
import info.nightscout.interfaces.queue.Command;
|
||||
import info.nightscout.interfaces.queue.CommandQueue;
|
||||
import info.nightscout.pump.dana.DanaPump;
|
||||
import info.nightscout.pump.dana.events.EventDanaRNewStatus;
|
||||
import info.nightscout.rx.bus.RxBus;
|
||||
import info.nightscout.rx.events.EventInitializationChanged;
|
||||
import info.nightscout.rx.events.EventOverviewBolusProgress;
|
||||
import info.nightscout.rx.events.EventProfileSwitchChanged;
|
||||
import info.nightscout.rx.events.EventPumpStatusChanged;
|
||||
import info.nightscout.rx.logging.AAPSLogger;
|
||||
import info.nightscout.rx.logging.LTag;
|
||||
import info.nightscout.shared.interfaces.ResourceHelper;
|
||||
import info.nightscout.shared.sharedPreferences.SP;
|
||||
|
||||
public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject RxBus rxBus;
|
||||
@Inject ResourceHelper rh;
|
||||
@Inject DanaPump danaPump;
|
||||
@Inject DanaRPlugin danaRPlugin;
|
||||
@Inject DanaRKoreanPlugin danaRKoreanPlugin;
|
||||
@Inject CommandQueue commandQueue;
|
||||
@Inject MessageHashTableR messageHashTableR;
|
||||
@Inject ProfileFunction profileFunction;
|
||||
@Inject PumpSync pumpSync;
|
||||
@Inject SP sp;
|
||||
@Inject HasAndroidInjector injector;
|
||||
|
||||
public DanaRExecutionService() {
|
||||
// non params constructor must exist
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,7 +95,6 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
try {
|
||||
mRfcommSocket.connect();
|
||||
} catch (IOException e) {
|
||||
//log.error("Unhandled exception", e);
|
||||
if (e.getMessage().contains("socket closed")) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class PodInfoFaultAndInitializationTime extends PodInfo {
|
|||
}
|
||||
|
||||
faultEventCode = FaultEventCode.fromByte(encodedData[1]);
|
||||
timeFaultEvent = Duration.standardMinutes(((encodedData[2] & 0b1) << 8) + encodedData[3]);
|
||||
timeFaultEvent = Duration.standardMinutes(((encodedData[2] & 0b1) << 8) + (encodedData[3] & 0xff));
|
||||
// We ignore time zones here because we don't keep the time zone in which the pod was initially set up
|
||||
// Which is fine because we don't use the initialization time for anything important anyway
|
||||
initializationTime = new DateTime(2000 + encodedData[14], encodedData[12], encodedData[13], encodedData[15], encodedData[16]);
|
||||
|
|
|
@ -527,7 +527,7 @@ public class OmnipodManager {
|
|||
return communicationService;
|
||||
}
|
||||
|
||||
public DateTime getTime() {
|
||||
public synchronized DateTime getTime() {
|
||||
return podStateManager.getTime();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue