Merge pull request #139 from smuething/more-daggerization

More daggerization
This commit is contained in:
bartsopers 2020-08-18 12:44:21 +02:00 committed by GitHub
commit 228441f54c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 70 additions and 81 deletions

View file

@ -26,6 +26,7 @@ import javax.inject.Singleton
CommandQueueModule::class, CommandQueueModule::class,
ObjectivesModule::class, ObjectivesModule::class,
WizardModule::class, WizardModule::class,
RileyLinkModule::class,
MedtronicModule::class, MedtronicModule::class,
OmnipodModule::class, OmnipodModule::class,
APSModule::class, APSModule::class,

View file

@ -2,33 +2,12 @@ package info.nightscout.androidaps.dependencyInjection
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SendAndListen
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SetPreamble
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioPacket
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.*
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
@Module @Module
@Suppress("unused") @Suppress("unused")
abstract class MedtronicModule { abstract class MedtronicModule {
@ContributesAndroidInjector abstract fun rileyLinkCommunicationManagerProvider(): RileyLinkCommunicationManager
@ContributesAndroidInjector abstract fun medtronicCommunicationManagerProvider(): MedtronicCommunicationManager @ContributesAndroidInjector abstract fun medtronicCommunicationManagerProvider(): MedtronicCommunicationManager
@ContributesAndroidInjector abstract fun medtronicUITaskProvider(): MedtronicUITask @ContributesAndroidInjector abstract fun medtronicUITaskProvider(): MedtronicUITask
@ContributesAndroidInjector abstract fun serviceTaskProvider(): ServiceTask
@ContributesAndroidInjector abstract fun pumpTaskProvider(): PumpTask
@ContributesAndroidInjector abstract fun discoverGattServicesTaskProvider(): DiscoverGattServicesTask
@ContributesAndroidInjector abstract fun initializePumpManagerTaskProvider(): InitializePumpManagerTask
@ContributesAndroidInjector abstract fun resetRileyLinkConfigurationTaskProvider(): ResetRileyLinkConfigurationTask
@ContributesAndroidInjector abstract fun wakeAndTuneTaskProvider(): WakeAndTuneTask
@ContributesAndroidInjector abstract fun radioResponseProvider(): RadioResponse
@ContributesAndroidInjector abstract fun rileyLinkBLEProvider(): RileyLinkBLE
@ContributesAndroidInjector abstract fun rfSpyProvider(): RFSpy
@ContributesAndroidInjector abstract fun sendAndListenProvider(): SendAndListen
@ContributesAndroidInjector abstract fun setPreambleProvider(): SetPreamble
@ContributesAndroidInjector abstract fun radioPacketProvider(): RadioPacket
} }

View file

@ -3,8 +3,6 @@ package info.nightscout.androidaps.dependencyInjection
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager
@ -15,14 +13,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.In
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodInfoFragment import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodInfoFragment
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod.RemoveActionFragment import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod.RemoveActionFragment
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsPodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsPodStateManager
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import javax.inject.Singleton
@Module @Module
@Suppress("unused") @Suppress("unused")
@ -52,9 +45,6 @@ abstract class OmnipodModule {
companion object { companion object {
@Provides @Provides
@Singleton fun podStateManagerProvider(aapsPodStateManager: info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsPodStateManager) : info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager = aapsPodStateManager
fun podStateManagerProvider(aapsLogger: AAPSLogger, sp: SP, omnipodPumpStatus: info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus,
rxBus: RxBusWrapper, resourceHelper: ResourceHelper, dateUtil: DateUtil): info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager =
info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsPodStateManager(aapsLogger, sp, omnipodPumpStatus, rxBus, resourceHelper, dateUtil)
} }
} }

View file

@ -0,0 +1,30 @@
package info.nightscout.androidaps.dependencyInjection
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SendAndListen
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SetPreamble
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioPacket
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.*
@Module
@Suppress("unused")
abstract class RileyLinkModule {
@ContributesAndroidInjector abstract fun rileyLinkCommunicationManagerProvider(): RileyLinkCommunicationManager
@ContributesAndroidInjector abstract fun serviceTaskProvider(): ServiceTask
@ContributesAndroidInjector abstract fun pumpTaskProvider(): PumpTask
@ContributesAndroidInjector abstract fun discoverGattServicesTaskProvider(): DiscoverGattServicesTask
@ContributesAndroidInjector abstract fun initializePumpManagerTaskProvider(): InitializePumpManagerTask
@ContributesAndroidInjector abstract fun resetRileyLinkConfigurationTaskProvider(): ResetRileyLinkConfigurationTask
@ContributesAndroidInjector abstract fun wakeAndTuneTaskProvider(): WakeAndTuneTask
@ContributesAndroidInjector abstract fun radioResponseProvider(): RadioResponse
@ContributesAndroidInjector abstract fun rileyLinkBLEProvider(): RileyLinkBLE
@ContributesAndroidInjector abstract fun rfSpyProvider(): RFSpy
@ContributesAndroidInjector abstract fun sendAndListenProvider(): SendAndListen
@ContributesAndroidInjector abstract fun setPreambleProvider(): SetPreamble
@ContributesAndroidInjector abstract fun radioPacketProvider(): RadioPacket
}

View file

@ -40,6 +40,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
@Inject MedtronicUtil medtronicUtil; @Inject MedtronicUtil medtronicUtil;
@Inject MedtronicUIPostprocessor medtronicUIPostprocessor; @Inject MedtronicUIPostprocessor medtronicUIPostprocessor;
@Inject MedtronicPumpStatus medtronicPumpStatus; @Inject MedtronicPumpStatus medtronicPumpStatus;
@Inject RFSpy rfSpy;
private MedtronicUIComm medtronicUIComm; private MedtronicUIComm medtronicUIComm;
private MedtronicCommunicationManager medtronicCommunicationManager; private MedtronicCommunicationManager medtronicCommunicationManager;
@ -99,8 +100,6 @@ public class RileyLinkMedtronicService extends RileyLinkService {
// get most recently used RileyLink address // get most recently used RileyLink address
rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, ""); rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
rileyLinkBLE = new RileyLinkBLE(injector, this); // or this
rfspy = new RFSpy(injector, rileyLinkBLE);
rfspy.startReader(); rfspy.startReader();
// init rileyLinkCommunicationManager // init rileyLinkCommunicationManager

View file

@ -62,6 +62,11 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
@Inject @Inject
public OmnipodCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) { public OmnipodCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) {
super(injector, rfspy); super(injector, rfspy);
}
@Inject
public void onInit() {
// this cannot be done in the constructor, as sp is not populated at that time
omnipodPumpStatus.previousConnection = sp.getLong( omnipodPumpStatus.previousConnection = sp.getLong(
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L); RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
} }

View file

@ -47,6 +47,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
@Inject lateinit var podStateManager: PodStateManager @Inject lateinit var podStateManager: PodStateManager
@Inject lateinit var injector: HasAndroidInjector @Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData @Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
@Inject lateinit var aapsOmnipodManager: AapsOmnipodManager
private var initPodChanged = false private var initPodChanged = false
@ -141,7 +142,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
fun resetPodAction() { fun resetPodAction() {
OKDialog.showConfirmation(this, OKDialog.showConfirmation(this,
resourceHelper.gs(R.string.omnipod_cmd_reset_pod_desc), Thread { resourceHelper.gs(R.string.omnipod_cmd_reset_pod_desc), Thread {
AapsOmnipodManager.getInstance().resetPodStatus() aapsOmnipodManager.resetPodStatus()
refreshButtons() refreshButtons()
}) })
} }

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodMa
public class InitPodTask extends AsyncTask<Void, Void, String> { public class InitPodTask extends AsyncTask<Void, Void, String> {
@Inject ProfileFunction profileFunction; @Inject ProfileFunction profileFunction;
@Inject AapsOmnipodManager aapsOmnipodManager;
private InitActionFragment initActionFragment; private InitActionFragment initActionFragment;
public InitPodTask(HasAndroidInjector injector, InitActionFragment initActionFragment) { public InitPodTask(HasAndroidInjector injector, InitActionFragment initActionFragment) {
@ -34,19 +35,19 @@ public class InitPodTask extends AsyncTask<Void, Void, String> {
@Override @Override
protected String doInBackground(Void... params) { protected String doInBackground(Void... params) {
if (initActionFragment.podInitActionType == PodInitActionType.PairAndPrimeWizardStep) { if (initActionFragment.podInitActionType == PodInitActionType.PairAndPrimeWizardStep) {
initActionFragment.callResult = AapsOmnipodManager.getInstance().initPod( initActionFragment.callResult = aapsOmnipodManager.initPod(
initActionFragment.podInitActionType, initActionFragment.podInitActionType,
initActionFragment, initActionFragment,
null null
); );
} else if (initActionFragment.podInitActionType == PodInitActionType.FillCannulaSetBasalProfileWizardStep) { } else if (initActionFragment.podInitActionType == PodInitActionType.FillCannulaSetBasalProfileWizardStep) {
initActionFragment.callResult = AapsOmnipodManager.getInstance().initPod( initActionFragment.callResult = aapsOmnipodManager.initPod(
initActionFragment.podInitActionType, initActionFragment.podInitActionType,
initActionFragment, initActionFragment,
profileFunction.getProfile() profileFunction.getProfile()
); );
} else if (initActionFragment.podInitActionType == PodInitActionType.DeactivatePodWizardStep) { } else if (initActionFragment.podInitActionType == PodInitActionType.DeactivatePodWizardStep) {
initActionFragment.callResult = AapsOmnipodManager.getInstance().deactivatePod(initActionFragment); initActionFragment.callResult = aapsOmnipodManager.deactivatePod(initActionFragment);
} }
return "OK"; return "OK";

View file

@ -10,6 +10,9 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector; import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.activities.ErrorHelperActivity; import info.nightscout.androidaps.activities.ErrorHelperActivity;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
@ -73,7 +76,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP; import info.nightscout.androidaps.utils.sharedPreferences.SP;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
// TODO make singleton @Singleton
public class AapsOmnipodManager implements IOmnipodManager { public class AapsOmnipodManager implements IOmnipodManager {
private final PodStateManager podStateManager; private final PodStateManager podStateManager;
@ -87,15 +90,9 @@ public class AapsOmnipodManager implements IOmnipodManager {
private final Context context; private final Context context;
private final OmnipodManager delegate; private final OmnipodManager delegate;
//TODO: remove and use injection
private static AapsOmnipodManager instance;
private DatabaseHelperInterface databaseHelper; private DatabaseHelperInterface databaseHelper;
public static AapsOmnipodManager getInstance() { @Inject
return instance;
}
public AapsOmnipodManager(OmnipodCommunicationManager communicationService, public AapsOmnipodManager(OmnipodCommunicationManager communicationService,
PodStateManager podStateManager, PodStateManager podStateManager,
OmnipodPumpStatus pumpStatus, OmnipodPumpStatus pumpStatus,
@ -123,7 +120,6 @@ public class AapsOmnipodManager implements IOmnipodManager {
this.databaseHelper = databaseHelper; this.databaseHelper = databaseHelper;
delegate = new OmnipodManager(aapsLogger, sp, communicationService, podStateManager); delegate = new OmnipodManager(aapsLogger, sp, communicationService, podStateManager);
instance = this;
} }
public PodStateManager getPodStateManager() { public PodStateManager getPodStateManager() {

View file

@ -14,8 +14,6 @@ import info.nightscout.androidaps.logging.LTag;
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.RileyLinkBLE;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkEncodingType; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkEncodingType;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
@ -45,11 +43,8 @@ public class RileyLinkOmnipodService extends RileyLinkService {
@Inject OmnipodUIPostprocessor omnipodUIPostprocessor; @Inject OmnipodUIPostprocessor omnipodUIPostprocessor;
@Inject PodStateManager podStateManager; @Inject PodStateManager podStateManager;
@Inject DatabaseHelperInterface databaseHelper; @Inject DatabaseHelperInterface databaseHelper;
@Inject AapsOmnipodManager aapsOmnipodManager;
private static RileyLinkOmnipodService instance; @Inject OmnipodCommunicationManager omnipodCommunicationManager;
private OmnipodCommunicationManager omnipodCommunicationManager;
private AapsOmnipodManager aapsOmnipodManager;
private IBinder mBinder = new LocalBinder(); private IBinder mBinder = new LocalBinder();
private boolean rileyLinkAddressChanged = false; private boolean rileyLinkAddressChanged = false;
@ -59,11 +54,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
public RileyLinkOmnipodService() { public RileyLinkOmnipodService() {
super(); super();
instance = this;
}
public static RileyLinkOmnipodService getInstance() {
return instance;
} }
@Override @Override
@ -94,8 +84,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
// get most recently used RileyLink address // get most recently used RileyLink address
rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, ""); rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
rileyLinkBLE = new RileyLinkBLE(injector, this); // or this
rfspy = new RFSpy(injector, rileyLinkBLE);
rfspy.startReader(); rfspy.startReader();
initializeErosOmnipodManager(); initializeErosOmnipodManager();
@ -105,18 +93,8 @@ public class RileyLinkOmnipodService extends RileyLinkService {
} }
private void initializeErosOmnipodManager() { private void initializeErosOmnipodManager() {
AapsOmnipodManager instance = AapsOmnipodManager.getInstance(); if (omnipodUIComm == null) {
if (instance == null) {
OmnipodCommunicationManager omnipodCommunicationService = new OmnipodCommunicationManager(injector, rfspy);
this.omnipodCommunicationManager = omnipodCommunicationService;
aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podStateManager, omnipodPumpStatus,
omnipodUtil, aapsLogger, rxBus, sp, resourceHelper, injector, activePlugin, this, databaseHelper);
omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager, rileyLinkUtil); omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager, rileyLinkUtil);
} else {
aapsOmnipodManager = instance;
} }
rxBus.send(new EventOmnipodPumpValuesChanged()); rxBus.send(new EventOmnipodPumpValuesChanged());
} }

View file

@ -53,7 +53,6 @@ public abstract class RileyLinkCommunicationManager {
public RileyLinkCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) { public RileyLinkCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) {
this.injector = injector; this.injector = injector;
injector.androidInjector().inject(this);
this.rfspy = rfspy; this.rfspy = rfspy;
} }

View file

@ -5,6 +5,7 @@ import android.os.SystemClock;
import java.util.UUID; import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector; import dagger.android.HasAndroidInjector;
@ -40,6 +41,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
/** /**
* Created by geoff on 5/26/16. * Created by geoff on 5/26/16.
*/ */
@Singleton
public class RFSpy { public class RFSpy {
@Inject AAPSLogger aapsLogger; @Inject AAPSLogger aapsLogger;
@ -64,10 +66,14 @@ public class RFSpy {
private Double currentFrequencyMHz; private Double currentFrequencyMHz;
@Inject
public RFSpy(HasAndroidInjector injector, RileyLinkBLE rileyLinkBle) { public RFSpy(HasAndroidInjector injector, RileyLinkBLE rileyLinkBle) {
injector.androidInjector().inject(this);
this.injector = injector; this.injector = injector;
this.rileyLinkBle = rileyLinkBle; this.rileyLinkBle = rileyLinkBle;
}
@Inject
public void onInit() {
aapsLogger.debug("RileyLinkServiceData:" + rileyLinkServiceData); aapsLogger.debug("RileyLinkServiceData:" + rileyLinkServiceData);
reader = new RFSpyReader(aapsLogger, rileyLinkBle); reader = new RFSpyReader(aapsLogger, rileyLinkBle);
} }

View file

@ -18,8 +18,8 @@ import java.util.UUID;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
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.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
@ -40,6 +40,7 @@ import info.nightscout.androidaps.plugins.pump.common.utils.ThreadUtil;
* Created by geoff on 5/26/16. * Created by geoff on 5/26/16.
* Added: State handling, configuration of RF for different configuration ranges, connection handling * Added: State handling, configuration of RF for different configuration ranges, connection handling
*/ */
@Singleton
public class RileyLinkBLE { public class RileyLinkBLE {
@Inject AAPSLogger aapsLogger; @Inject AAPSLogger aapsLogger;
@ -58,13 +59,11 @@ public class RileyLinkBLE {
private Runnable radioResponseCountNotified; private Runnable radioResponseCountNotified;
private boolean mIsConnected = false; private boolean mIsConnected = false;
@Inject
public RileyLinkBLE(HasAndroidInjector injector, final Context context) { public RileyLinkBLE(final Context context) {
injector.androidInjector().inject(this);
this.context = context; this.context = context;
this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
aapsLogger.debug(LTag.PUMPBTCOMM, "BT Adapter: " + this.bluetoothAdapter);
bluetoothGattCallback = new BluetoothGattCallback() { bluetoothGattCallback = new BluetoothGattCallback() {
@Override @Override
@ -257,6 +256,11 @@ public class RileyLinkBLE {
}; };
} }
@Inject
public void onInit() {
aapsLogger.debug(LTag.PUMPBTCOMM, "BT Adapter: " + this.bluetoothAdapter);
}
private boolean isAnyRileyLinkServiceFound(BluetoothGattService service) { private boolean isAnyRileyLinkServiceFound(BluetoothGattService service) {

View file

@ -45,10 +45,10 @@ public abstract class RileyLinkService extends DaggerService {
@Inject protected ResourceHelper resourceHelper; @Inject protected ResourceHelper resourceHelper;
@Inject protected RileyLinkServiceData rileyLinkServiceData; @Inject protected RileyLinkServiceData rileyLinkServiceData;
@Inject protected ActivePluginProvider activePlugin; @Inject protected ActivePluginProvider activePlugin;
@Inject protected RileyLinkBLE rileyLinkBLE; // android-bluetooth management
@Inject protected RFSpy rfspy; // interface for RL xxx Mhz radio.
@NotNull protected RileyLinkBLE rileyLinkBLE; // android-bluetooth management, must be set in initRileyLinkServiceData
protected BluetoothAdapter bluetoothAdapter; protected BluetoothAdapter bluetoothAdapter;
protected RFSpy rfspy; // interface for RL xxx Mhz radio.
protected RileyLinkBroadcastReceiver mBroadcastReceiver; protected RileyLinkBroadcastReceiver mBroadcastReceiver;
protected RileyLinkBluetoothStateReceiver bluetoothStateReceiver; protected RileyLinkBluetoothStateReceiver bluetoothStateReceiver;