Merge pull request #151 from smuething/daggerization-fixes
Daggerization fixes
This commit is contained in:
commit
dcb9e7bf91
4 changed files with 19 additions and 22 deletions
|
@ -10,14 +10,13 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RFSpyResponse;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RFSpyResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage;
|
||||||
|
@ -56,6 +55,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
* This was mostly rewritten from Original version, and lots of commands and
|
* This was mostly rewritten from Original version, and lots of commands and
|
||||||
* functionality added.
|
* functionality added.
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class MedtronicCommunicationManager extends RileyLinkCommunicationManager {
|
public class MedtronicCommunicationManager extends RileyLinkCommunicationManager {
|
||||||
|
|
||||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||||
|
@ -73,9 +73,13 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
private boolean doWakeUpBeforeCommand = true;
|
private boolean doWakeUpBeforeCommand = true;
|
||||||
|
|
||||||
|
// This empty constructor must be kept, otherwise dagger injection might break!
|
||||||
|
@Inject
|
||||||
|
public MedtronicCommunicationManager() {}
|
||||||
|
|
||||||
public MedtronicCommunicationManager(HasAndroidInjector injector) {
|
@Inject
|
||||||
super(injector);
|
public void onInit() {
|
||||||
|
// we can't do this in the constructor, as sp only gets injected after the constructor has returned
|
||||||
medtronicPumpStatus.previousConnection = sp.getLong(
|
medtronicPumpStatus.previousConnection = sp.getLong(
|
||||||
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
|
||||||
|
@ -34,6 +35,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
/**
|
/**
|
||||||
* RileyLinkMedtronicService is intended to stay running when the gui-app is closed.
|
* RileyLinkMedtronicService is intended to stay running when the gui-app is closed.
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class RileyLinkMedtronicService extends RileyLinkService {
|
public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
|
|
||||||
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
|
@ -41,9 +43,9 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
@Inject MedtronicUIPostprocessor medtronicUIPostprocessor;
|
@Inject MedtronicUIPostprocessor medtronicUIPostprocessor;
|
||||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||||
@Inject RFSpy rfSpy;
|
@Inject RFSpy rfSpy;
|
||||||
|
@Inject MedtronicCommunicationManager medtronicCommunicationManager;
|
||||||
|
|
||||||
private MedtronicUIComm medtronicUIComm;
|
private MedtronicUIComm medtronicUIComm;
|
||||||
private MedtronicCommunicationManager medtronicCommunicationManager;
|
|
||||||
private IBinder mBinder = new LocalBinder();
|
private IBinder mBinder = new LocalBinder();
|
||||||
|
|
||||||
private boolean serialChanged = false;
|
private boolean serialChanged = false;
|
||||||
|
@ -55,8 +57,9 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
private boolean inPreInit = true;
|
private boolean inPreInit = true;
|
||||||
|
|
||||||
|
|
||||||
|
// This empty constructor must be kept, otherwise dagger injection might break!
|
||||||
|
@Inject
|
||||||
public RileyLinkMedtronicService() {
|
public RileyLinkMedtronicService() {
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,8 +105,6 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
|
|
||||||
rfspy.startReader();
|
rfspy.startReader();
|
||||||
|
|
||||||
// init rileyLinkCommunicationManager
|
|
||||||
medtronicCommunicationManager = new MedtronicCommunicationManager(injector);
|
|
||||||
medtronicUIComm = new MedtronicUIComm(injector, aapsLogger, medtronicUtil, medtronicUIPostprocessor, medtronicCommunicationManager);
|
medtronicUIComm = new MedtronicUIComm(injector, aapsLogger, medtronicUtil, medtronicUIPostprocessor, medtronicCommunicationManager);
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly constructed");
|
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly constructed");
|
||||||
|
|
|
@ -6,15 +6,13 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType;
|
||||||
|
@ -50,14 +48,15 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
/**
|
/**
|
||||||
* Created by andy on 6/29/18.
|
* Created by andy on 6/29/18.
|
||||||
*/
|
*/
|
||||||
// TODO make singleton and rename to OmnipodRileyLinkCommunicationManager
|
// TODO rename to OmnipodRileyLinkCommunicationManager
|
||||||
|
@Singleton
|
||||||
public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
||||||
|
|
||||||
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
||||||
|
|
||||||
|
// This empty constructor must be kept, otherwise dagger injection might break!
|
||||||
@Inject
|
@Inject
|
||||||
public OmnipodCommunicationManager(HasAndroidInjector injector) {
|
public OmnipodCommunicationManager() {
|
||||||
super(injector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
@ -36,12 +36,11 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
@Inject protected RileyLinkServiceData rileyLinkServiceData;
|
@Inject protected RileyLinkServiceData rileyLinkServiceData;
|
||||||
@Inject protected ServiceTaskExecutor serviceTaskExecutor;
|
@Inject protected ServiceTaskExecutor serviceTaskExecutor;
|
||||||
@Inject protected RFSpy rfspy;
|
@Inject protected RFSpy rfspy;
|
||||||
|
@Inject protected HasAndroidInjector injector;
|
||||||
|
|
||||||
private final int SCAN_TIMEOUT = 1500;
|
private final int SCAN_TIMEOUT = 1500;
|
||||||
private final int ALLOWED_PUMP_UNREACHABLE = 10 * 60 * 1000; // 10 minutes
|
private final int ALLOWED_PUMP_UNREACHABLE = 10 * 60 * 1000; // 10 minutes
|
||||||
|
|
||||||
public final HasAndroidInjector injector;
|
|
||||||
|
|
||||||
protected int receiverDeviceAwakeForMinutes = 1; // override this in constructor of specific implementation
|
protected int receiverDeviceAwakeForMinutes = 1; // override this in constructor of specific implementation
|
||||||
protected String receiverDeviceID; // String representation of receiver device (ex. Pump (xxxxxx) or Pod (yyyyyy))
|
protected String receiverDeviceID; // String representation of receiver device (ex. Pump (xxxxxx) or Pod (yyyyyy))
|
||||||
protected long lastGoodReceiverCommunicationTime = 0;
|
protected long lastGoodReceiverCommunicationTime = 0;
|
||||||
|
@ -50,12 +49,6 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
private int timeoutCount = 0;
|
private int timeoutCount = 0;
|
||||||
|
|
||||||
|
|
||||||
public RileyLinkCommunicationManager(HasAndroidInjector injector) {
|
|
||||||
this.injector = injector;
|
|
||||||
this.injector.androidInjector().inject(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// All pump communications go through this function.
|
// All pump communications go through this function.
|
||||||
protected RLMessage sendAndListen(RLMessage msg, int timeout_ms)
|
protected RLMessage sendAndListen(RLMessage msg, int timeout_ms)
|
||||||
throws RileyLinkCommunicationException {
|
throws RileyLinkCommunicationException {
|
||||||
|
|
Loading…
Reference in a new issue