Merge pull request #151 from smuething/daggerization-fixes
Daggerization fixes
This commit is contained in:
commit
dcb9e7bf91
|
@ -10,14 +10,13 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
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.hw.rileylink.RileyLinkCommunicationManager;
|
||||
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.data.RFSpyResponse;
|
||||
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
|
||||
* functionality added.
|
||||
*/
|
||||
@Singleton
|
||||
public class MedtronicCommunicationManager extends RileyLinkCommunicationManager {
|
||||
|
||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||
|
@ -73,9 +73,13 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
|
||||
private boolean doWakeUpBeforeCommand = true;
|
||||
|
||||
// This empty constructor must be kept, otherwise dagger injection might break!
|
||||
@Inject
|
||||
public MedtronicCommunicationManager() {}
|
||||
|
||||
public MedtronicCommunicationManager(HasAndroidInjector injector) {
|
||||
super(injector);
|
||||
@Inject
|
||||
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(
|
||||
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.os.Binder;
|
|||
import android.os.IBinder;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
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.
|
||||
*/
|
||||
@Singleton
|
||||
public class RileyLinkMedtronicService extends RileyLinkService {
|
||||
|
||||
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||
|
@ -41,9 +43,9 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
@Inject MedtronicUIPostprocessor medtronicUIPostprocessor;
|
||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||
@Inject RFSpy rfSpy;
|
||||
@Inject MedtronicCommunicationManager medtronicCommunicationManager;
|
||||
|
||||
private MedtronicUIComm medtronicUIComm;
|
||||
private MedtronicCommunicationManager medtronicCommunicationManager;
|
||||
private IBinder mBinder = new LocalBinder();
|
||||
|
||||
private boolean serialChanged = false;
|
||||
|
@ -55,8 +57,9 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
private boolean inPreInit = true;
|
||||
|
||||
|
||||
// This empty constructor must be kept, otherwise dagger injection might break!
|
||||
@Inject
|
||||
public RileyLinkMedtronicService() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,8 +105,6 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
|
||||
rfspy.startReader();
|
||||
|
||||
// init rileyLinkCommunicationManager
|
||||
medtronicCommunicationManager = new MedtronicCommunicationManager(injector);
|
||||
medtronicUIComm = new MedtronicUIComm(injector, aapsLogger, medtronicUtil, medtronicUIPostprocessor, medtronicCommunicationManager);
|
||||
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly constructed");
|
||||
|
|
|
@ -6,15 +6,13 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
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.plugins.pump.common.data.PumpStatus;
|
||||
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.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.data.RLMessage;
|
||||
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.
|
||||
*/
|
||||
// TODO make singleton and rename to OmnipodRileyLinkCommunicationManager
|
||||
// TODO rename to OmnipodRileyLinkCommunicationManager
|
||||
@Singleton
|
||||
public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
||||
|
||||
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
||||
|
||||
// This empty constructor must be kept, otherwise dagger injection might break!
|
||||
@Inject
|
||||
public OmnipodCommunicationManager(HasAndroidInjector injector) {
|
||||
super(injector);
|
||||
public OmnipodCommunicationManager() {
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
|
|
@ -36,12 +36,11 @@ public abstract class RileyLinkCommunicationManager {
|
|||
@Inject protected RileyLinkServiceData rileyLinkServiceData;
|
||||
@Inject protected ServiceTaskExecutor serviceTaskExecutor;
|
||||
@Inject protected RFSpy rfspy;
|
||||
@Inject protected HasAndroidInjector injector;
|
||||
|
||||
private final int SCAN_TIMEOUT = 1500;
|
||||
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 String receiverDeviceID; // String representation of receiver device (ex. Pump (xxxxxx) or Pod (yyyyyy))
|
||||
protected long lastGoodReceiverCommunicationTime = 0;
|
||||
|
@ -50,12 +49,6 @@ public abstract class RileyLinkCommunicationManager {
|
|||
private int timeoutCount = 0;
|
||||
|
||||
|
||||
public RileyLinkCommunicationManager(HasAndroidInjector injector) {
|
||||
this.injector = injector;
|
||||
this.injector.androidInjector().inject(this);
|
||||
}
|
||||
|
||||
|
||||
// All pump communications go through this function.
|
||||
protected RLMessage sendAndListen(RLMessage msg, int timeout_ms)
|
||||
throws RileyLinkCommunicationException {
|
||||
|
|
Loading…
Reference in a new issue