- problems found on crashalytics

This commit is contained in:
Andy Rozman 2021-01-05 20:52:45 +00:00
parent 8b86489499
commit 66db7bc89b
11 changed files with 74 additions and 15 deletions

View file

@ -422,13 +422,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@Override
public void getPumpStatus(String reason) {
boolean needRefresh = true;
if (firstRun) {
initializePump(!isRefresh);
needRefresh = initializePump(!isRefresh);
} else {
refreshAnyStatusThatNeedsToBeRefreshed();
}
if (needRefresh)
rxBus.send(new EventMedtronicPumpValuesChanged());
}
@ -556,7 +558,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
}
private void initializePump(boolean realInit) {
private boolean initializePump(boolean realInit) {
if (rileyLinkMedtronicService==null)
return false;
aapsLogger.info(LTag.PUMP, getLogPrefix() + "initializePump - start");
@ -571,7 +576,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
setRefreshButtonEnabled(true);
return;
return true;
}
medtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
@ -614,7 +619,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
aapsLogger.error("Number of error counts was 5 or more. Starting tunning.");
setRefreshButtonEnabled(true);
serviceTaskExecutor.startTask(new WakeAndTuneTask(getInjector()));
return;
return true;
}
medtronicPumpStatus.setLastCommunicationToNow();
@ -628,6 +633,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// this.pumpState = PumpDriverState.Initialized;
this.firstRun = false;
return true;
}
private void getBasalProfiles() {

View file

@ -149,8 +149,14 @@ public class MedtronicConverter {
if (rawData.length > 1) {
Double d = null;
// if response in 3 bytes then we add additional information
double d = (ByteUtil.toInt(rawData[1], rawData[2]) * 1.0d) / 100.0d;
if (rawData.length == 2) {
d = (rawData[1] * 1.0d) / 100.0d;
} else {
d = (ByteUtil.toInt(rawData[1], rawData[2]) * 1.0d) / 100.0d;
}
batteryStatus.voltage = d;
batteryStatus.extendedDataReceived = true;
@ -171,7 +177,14 @@ public class MedtronicConverter {
startIdx = 2;
}
float value = ByteUtil.toInt(rawData[startIdx], rawData[startIdx + 1]) / (1.0f * strokes);
int reqLength = startIdx+1;
float value = 0;
if (reqLength >= rawData.length) {
value = rawData[startIdx] / (1.0f * strokes);
} else {
value = ByteUtil.toInt(rawData[startIdx], rawData[startIdx + 1]) / (1.0f * strokes);
}
aapsLogger.debug(LTag.PUMPCOMM, "Remaining insulin: " + value);
return value;

View file

@ -106,9 +106,11 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
int els = getUnsignedInt(elements);
for (int k = 0; k < (els - 2); k++) {
if (counter<1022) {
listRawData.add(dataClear.get(counter));
counter++;
}
}
special = true;
} else {

View file

@ -133,8 +133,12 @@ public class PumpMessage implements RLMessage {
public byte[] getRawContentOfFrame() {
byte[] raw = messageBody.getTxData();
if (raw==null || raw.length==0) {
return new byte[0];
} else {
return ByteUtil.substring(raw, 1, Math.min(FRAME_DATA_LENGTH, raw.length - 1));
}
}
public boolean isValid() {

View file

@ -1478,8 +1478,10 @@ public class MedtronicHistoryData {
// HELPER METHODS
private void sort(List<PumpHistoryEntry> list) {
if (list!=null && !list.isEmpty()) {
Collections.sort(list, new PumpHistoryEntry.Comparator());
}
}
private List<PumpHistoryEntry> preProcessTBRs(List<PumpHistoryEntry> TBRs_Input) {

View file

@ -391,7 +391,8 @@ public class RFSpy {
private void setMedtronicEncoding() {
RileyLinkEncodingType encoding = RileyLinkEncodingType.FourByteSixByteLocal;
if (rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) {
if (rileyLinkServiceData.firmwareVersion!=null &&
rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) {
if (sp.getString(RileyLinkConst.Prefs.Encoding, "None")
.equals(resourceHelper.gs(R.string.key_medtronic_pump_encoding_4b6b_rileylink))) {
encoding = RileyLinkEncodingType.FourByteSixByteRileyLink;

View file

@ -12,7 +12,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
*/
public class DiscoverGattServicesTask extends ServiceTask {
@Inject ActivePluginProvider activePlugin;
@Inject AAPSLogger aapsLogger;
public boolean needToConnect = false;
@ -31,6 +31,11 @@ public class DiscoverGattServicesTask extends ServiceTask {
@Override
public void run() {
if (!isRileyLinkDevice()) {
return;
}
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
if (needToConnect) {

View file

@ -29,7 +29,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
public class InitializePumpManagerTask extends ServiceTask {
@Inject AAPSLogger aapsLogger;
@Inject ActivePluginProvider activePlugin;
//@Inject ActivePluginProvider activePlugin;
@Inject SP sp;
@Inject RileyLinkServiceData rileyLinkServiceData;
@Inject RileyLinkUtil rileyLinkUtil;
@ -49,6 +49,10 @@ public class InitializePumpManagerTask extends ServiceTask {
@Override
public void run() {
if (!isRileyLinkDevice()) {
return;
}
double lastGoodFrequency;
if (rileyLinkServiceData.lastGoodFrequency == null) {

View file

@ -24,6 +24,11 @@ public class ResetRileyLinkConfigurationTask extends PumpTask {
@Override
public void run() {
if (!isRileyLinkDevice()) {
return;
}
RileyLinkPumpDevice rileyLinkPumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
rxBus.send(new EventRefreshButtonState(false));

View file

@ -1,6 +1,10 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
/**
@ -8,6 +12,8 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.
*/
public class ServiceTask implements Runnable {
@Inject protected ActivePluginProvider activePlugin;
public boolean completed = false;
protected ServiceTransport mTransport;
protected HasAndroidInjector injector;
@ -56,4 +62,10 @@ public class ServiceTask implements Runnable {
* RoundtripService.getInstance().sendServiceTransportResponse(mTransport,result);
* }
*/
public boolean isRileyLinkDevice() {
return (activePlugin.getActivePump() instanceof RileyLinkPumpDevice);
}
}

View file

@ -13,7 +13,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
*/
public class WakeAndTuneTask extends PumpTask {
@Inject ActivePluginProvider activePlugin;
//@Inject ActivePluginProvider activePlugin;
@Inject RxBusWrapper rxBus;
private static final String TAG = "WakeAndTuneTask";
@ -24,6 +24,10 @@ public class WakeAndTuneTask extends PumpTask {
@Override
public void run() {
if (!isRileyLinkDevice()) {
return;
}
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
rxBus.send(new EventRefreshButtonState(false));
pumpDevice.setBusy(true);