From a4b2ce32a59a617eed9ad006e85efdeec51cd899 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 16 Aug 2020 11:13:48 +0200 Subject: [PATCH 01/40] 2.7.0-rc3 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 58c4d73eac..ec0d34d020 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -125,7 +125,7 @@ android { targetSdkVersion 28 multiDexEnabled true versionCode 1500 - version "2.6.7-dev" + version "2.7.0-rc3" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' From b5c46e3bcf00e015626e707bce8d523556b35629 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Sun, 16 Aug 2020 23:54:41 +0200 Subject: [PATCH 02/40] WIP on moving Omnipod to a separate module --- app/build.gradle | 8 +- app/src/main/AndroidManifest.xml | 11 -- .../dependencyInjection/FragmentsModule.kt | 2 +- .../dependencyInjection/OmnipodModule.kt | 30 +-- .../dependencyInjection/PluginsModule.kt | 2 +- .../dependencyInjection/ServicesModule.kt | 2 +- app/src/main/res/values/strings.xml | 178 +----------------- app/src/main/res/values/styles.xml | 31 --- omnipod/.gitignore | 1 + omnipod/build.gradle | 100 ++++++++++ omnipod/consumer-rules.pro | 0 ...ware.android.library.wizardpager-1.1.4.aar | Bin 0 -> 97170 bytes omnipod/proguard-rules.pro | 21 +++ omnipod/src/main/AndroidManifest.xml | 16 ++ .../plugins/pump/omnipod/OmnipodFragment.kt | 0 .../pump/omnipod/OmnipodPumpPlugin.java | 0 .../comm/OmnipodCommunicationManager.java | 0 .../pump/omnipod/comm/OmnipodManager.java | 0 .../pump/omnipod/comm/SetupActionResult.java | 0 .../comm/action/AcknowledgeAlertsAction.java | 0 .../comm/action/AssignAddressAction.java | 0 .../pump/omnipod/comm/action/BolusAction.java | 0 .../comm/action/CancelDeliveryAction.java | 0 .../comm/action/ConfigureAlertsAction.java | 0 .../comm/action/DeactivatePodAction.java | 0 .../omnipod/comm/action/GetPodInfoAction.java | 0 .../omnipod/comm/action/GetStatusAction.java | 0 .../comm/action/InsertCannulaAction.java | 0 .../omnipod/comm/action/OmnipodAction.java | 0 .../pump/omnipod/comm/action/PrimeAction.java | 0 .../comm/action/SetBasalScheduleAction.java | 0 .../comm/action/SetTempBasalAction.java | 0 .../omnipod/comm/action/SetupPodAction.java | 0 .../action/service/InsertCannulaService.java | 0 .../comm/action/service/PrimeService.java | 0 .../ActionInitializationException.java | 0 .../CommandInitializationException.java | 0 .../exception/CommunicationException.java | 0 .../comm/exception/CrcMismatchException.java | 0 .../IllegalDeliveryStatusException.java | 1 - .../IllegalMessageAddressException.java | 0 ...IllegalMessageSequenceNumberException.java | 0 .../exception/IllegalPacketTypeException.java | 0 .../IllegalPodProgressException.java | 0 .../exception/IllegalResponseException.java | 0 .../IllegalVersionResponseTypeException.java | 0 .../exception/MessageDecodingException.java | 0 .../exception/NonceOutOfSyncException.java | 0 .../comm/exception/NonceResyncException.java | 0 .../exception/NotEnoughDataException.java | 0 .../comm/exception/PodFaultException.java | 0 .../PodReturnedErrorResponseException.java | 0 .../comm/message/IRawRepresentable.java | 0 .../omnipod/comm/message/MessageBlock.java | 0 .../message/NonceResyncableMessageBlock.java | 0 .../omnipod/comm/message/OmnipodMessage.java | 0 .../omnipod/comm/message/OmnipodPacket.java | 0 .../command/AcknowledgeAlertsCommand.java | 0 .../message/command/AssignAddressCommand.java | 0 .../command/BasalScheduleExtraCommand.java | 0 .../message/command/BeepConfigCommand.java | 0 .../message/command/BolusExtraCommand.java | 0 .../command/CancelDeliveryCommand.java | 0 .../command/ConfigureAlertsCommand.java | 0 .../message/command/DeactivatePodCommand.java | 0 .../message/command/FaultConfigCommand.java | 0 .../message/command/GetStatusCommand.java | 0 .../command/SetInsulinScheduleCommand.java | 0 .../comm/message/command/SetupPodCommand.java | 0 .../command/TempBasalExtraCommand.java | 0 .../comm/message/response/ErrorResponse.java | 0 .../comm/message/response/StatusResponse.java | 0 .../message/response/VersionResponse.java | 0 .../message/response/podinfo/PodInfo.java | 0 .../response/podinfo/PodInfoActiveAlerts.java | 0 .../response/podinfo/PodInfoDataLog.java | 0 .../PodInfoFaultAndInitializationTime.java | 0 .../response/podinfo/PodInfoFaultEvent.java | 0 .../podinfo/PodInfoOlderPulseLog.java | 0 .../podinfo/PodInfoRecentPulseLog.java | 0 .../response/podinfo/PodInfoResponse.java | 0 .../omnipod/data/RLHistoryItemOmnipod.java | 6 +- .../pump/omnipod/defs/AlertConfiguration.java | 0 .../defs/AlertConfigurationFactory.java | 0 .../plugins/pump/omnipod/defs/AlertSet.java | 0 .../plugins/pump/omnipod/defs/AlertSlot.java | 0 .../pump/omnipod/defs/AlertTrigger.java | 0 .../plugins/pump/omnipod/defs/AlertType.java | 0 .../pump/omnipod/defs/BeepConfigType.java | 0 .../plugins/pump/omnipod/defs/BeepRepeat.java | 0 .../plugins/pump/omnipod/defs/BeepType.java | 0 .../pump/omnipod/defs/DeliveryStatus.java | 0 .../pump/omnipod/defs/DeliveryType.java | 0 .../pump/omnipod/defs/FaultEventCode.java | 0 .../pump/omnipod/defs/FirmwareVersion.java | 0 .../pump/omnipod/defs/IOmnipodManager.java | 0 .../pump/omnipod/defs/LogEventErrorCode.java | 0 .../pump/omnipod/defs/MessageBlockType.java | 0 .../plugins/pump/omnipod/defs/NonceState.java | 0 .../pump/omnipod/defs/OmnipodCommandType.java | 0 .../omnipod/defs/OmnipodCustomActionType.java | 0 .../defs/OmnipodPumpPluginInterface.java | 0 .../omnipod/defs/OmnipodStatusRequest.java | 0 .../omnipod/defs/OmnipodUIResponseType.java | 0 .../plugins/pump/omnipod/defs/PacketType.java | 0 .../pump/omnipod/defs/PodInfoType.java | 0 .../pump/omnipod/defs/PodInitActionType.java | 0 .../pump/omnipod/defs/PodInitReceiver.java | 0 .../pump/omnipod/defs/PodProgressStatus.java | 0 .../pump/omnipod/defs/PodResponseType.java | 0 .../pump/omnipod/defs/TimerAlertTrigger.java | 0 .../defs/UnitsRemainingAlertTrigger.java | 0 .../defs/schedule/BasalDeliverySchedule.java | 0 .../defs/schedule/BasalDeliveryTable.java | 0 .../omnipod/defs/schedule/BasalSchedule.java | 0 .../defs/schedule/BasalScheduleEntry.java | 0 .../defs/schedule/BasalTableEntry.java | 0 .../defs/schedule/BolusDeliverySchedule.java | 0 .../defs/schedule/DeliverySchedule.java | 0 .../defs/schedule/InsulinScheduleType.java | 0 .../pump/omnipod/defs/schedule/RateEntry.java | 0 .../schedule/TempBasalDeliverySchedule.java | 0 .../omnipod/defs/state/PodStateManager.java | 0 .../omnipod/dialogs/PodHistoryActivity.java | 0 .../omnipod/dialogs/PodManagementActivity.kt | 0 .../dialogs/wizard/defs/PodActionType.java | 0 .../wizard/initpod/InitActionFragment.java | 0 .../wizard/initpod/InitActionPage.java | 0 .../dialogs/wizard/initpod/InitPodTask.java | 0 .../wizard/model/FullInitPodWizardModel.java | 0 .../wizard/model/InitPodWizardModel.java | 0 .../wizard/model/RemovePodWizardModel.java | 0 .../wizard/model/ShortInitPodWizardModel.java | 0 .../wizard/pages/InitPodRefreshAction.java | 0 .../dialogs/wizard/pages/PodInfoFragment.java | 0 .../dialogs/wizard/pages/PodInfoPage.java | 0 .../removepod/RemoveActionFragment.java | 4 +- .../wizard/removepod/RemovePodActionPage.java | 0 .../omnipod/driver/OmnipodDriverState.java | 0 .../omnipod/driver/OmnipodPumpStatus.java | 0 .../driver/comm/AapsOmnipodManager.java | 0 .../driver/comm/AapsPodStateManager.java | 0 .../pump/omnipod/driver/db/PodHistory.java | 0 .../driver/db/PodHistoryEntryType.java | 0 .../pump/omnipod/driver/ui/OmnipodUIComm.java | 0 .../driver/ui/OmnipodUIPostprocessor.java | 0 .../pump/omnipod/driver/ui/OmnipodUITask.java | 0 .../EventOmnipodAcknowledgeAlertsChanged.kt | 0 .../events/EventOmnipodPumpValuesChanged.kt | 0 .../events/EventOmnipodRefreshButtonState.kt | 0 .../omnipod/exception/OmnipodException.java | 0 .../service/RileyLinkOmnipodService.java | 0 .../plugins/pump/omnipod/util/OmniCRC.java | 0 .../pump/omnipod/util/OmnipodConst.java | 0 .../pump/omnipod/util/OmnipodUtil.java | 0 .../src/main/res/layout/omnipod_fragment.xml | 0 .../src/main/res/layout/omnipod_initpod.xml | 0 .../layout/omnipod_initpod_init_action.xml | 0 .../res/layout/omnipod_initpod_pod_info.xml | 0 .../layout/omnipod_initpod_pod_info_item.xml | 0 .../layout/omnipod_pod_history_activity.xml | 0 .../res/layout/omnipod_pod_history_item.xml | 0 .../src/main/res/layout/omnipod_pod_mgmt.xml | 0 omnipod/src/main/res/values/strings.xml | 159 ++++++++++++++++ omnipod/src/main/res/values/styles.xml | 30 +++ .../src/main/res/xml/pref_omnipod.xml | 0 .../command/AcknowledgeAlertsCommandTest.java | 0 .../command/AssignAddressCommandTest.java | 0 .../BasalScheduleExtraCommandTest.java | 0 .../command/BeepConfigCommandTest.java | 0 .../command/BolusExtraCommandTest.java | 0 .../command/CancelDeliveryCommandTest.java | 0 .../command/ConfigureAlertsCommandTest.java | 0 .../command/DeactivatePodCommandTest.java | 0 .../command/FaultConfigCommandTest.java | 0 .../message/command/GetStatusCommandTest.java | 0 .../SetInsulinScheduleCommandTest.java | 0 .../message/command/SetupPodCommandTest.java | 0 .../command/TempBasalExtraCommandTest.java | 0 .../defs/schedule/BasalTableEntryTest.java | 0 .../message/response/ErrorResponseTest.java | 0 .../message/response/StatusResponseTest.java | 0 .../message/response/VersionResponseTest.java | 0 .../podinfo/PodInfoActiveAlertsTest.java | 0 .../response/podinfo/PodInfoDataLogTest.java | 0 ...PodInfoFaultAndInitializationTimeTest.java | 11 +- .../podinfo/PodInfoFaultEventTest.java | 0 .../podinfo/PodInfoOlderPulseLogTest.java | 0 .../podinfo/PodInfoRecentPulseLogTest.java | 0 .../response/podinfo/PodInfoResponseTest.java | 0 .../defs/state/AapsPodStateManagerTest.java | 0 .../driver/comm/AapsOmnipodManagerTest.java | 42 ++--- settings.gradle | 1 + 193 files changed, 389 insertions(+), 267 deletions(-) create mode 100644 omnipod/.gitignore create mode 100644 omnipod/build.gradle create mode 100644 omnipod/consumer-rules.pro create mode 100644 omnipod/libs/com.atech-software.android.library.wizardpager-1.1.4.aar create mode 100644 omnipod/proguard-rules.pro create mode 100644 omnipod/src/main/AndroidManifest.xml rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodManager.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/SetupActionResult.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/AcknowledgeAlertsAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/AssignAddressAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/BolusAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/CancelDeliveryAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/ConfigureAlertsAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/DeactivatePodAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/GetPodInfoAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/GetStatusAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/InsertCannulaAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/OmnipodAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/PrimeAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/SetBasalScheduleAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/SetTempBasalAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/SetupPodAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/service/InsertCannulaService.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/service/PrimeService.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/ActionInitializationException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/CommandInitializationException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/CommunicationException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/CrcMismatchException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalDeliveryStatusException.java (91%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalMessageAddressException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalMessageSequenceNumberException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalPacketTypeException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalPodProgressException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalResponseException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalVersionResponseTypeException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/MessageDecodingException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/NonceOutOfSyncException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/NonceResyncException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/NotEnoughDataException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/PodFaultException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/PodReturnedErrorResponseException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/IRawRepresentable.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/MessageBlock.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/NonceResyncableMessageBlock.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/OmnipodMessage.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/OmnipodPacket.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AcknowledgeAlertsCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AssignAddressCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BasalScheduleExtraCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BeepConfigCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BolusExtraCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/CancelDeliveryCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/ConfigureAlertsCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/DeactivatePodCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/FaultConfigCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/GetStatusCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetInsulinScheduleCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetupPodCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/TempBasalExtraCommand.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/ErrorResponse.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/StatusResponse.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/VersionResponse.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfo.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoActiveAlerts.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoDataLog.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultAndInitializationTime.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultEvent.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoOlderPulseLog.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoRecentPulseLog.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoResponse.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java (89%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/AlertConfiguration.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/AlertConfigurationFactory.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/AlertSet.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/AlertSlot.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/AlertTrigger.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/AlertType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/BeepConfigType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/BeepRepeat.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/BeepType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/DeliveryStatus.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/DeliveryType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/FaultEventCode.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/FirmwareVersion.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/IOmnipodManager.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/LogEventErrorCode.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/MessageBlockType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/NonceState.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommandType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCustomActionType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodPumpPluginInterface.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodStatusRequest.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodUIResponseType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PacketType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInfoType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInitActionType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInitReceiver.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodProgressStatus.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodResponseType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/TimerAlertTrigger.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/UnitsRemainingAlertTrigger.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/schedule/BasalDeliverySchedule.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/schedule/BasalDeliveryTable.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/schedule/BasalSchedule.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/schedule/BasalScheduleEntry.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/schedule/BasalTableEntry.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/schedule/BolusDeliverySchedule.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/schedule/DeliverySchedule.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/schedule/InsulinScheduleType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/schedule/RateEntry.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/schedule/TempBasalDeliverySchedule.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodStateManager.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodHistoryActivity.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/defs/PodActionType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/InitPodWizardModel.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoPage.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemoveActionFragment.java (92%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodDriverState.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsPodStateManager.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistory.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUITask.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.kt (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.kt (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/exception/OmnipodException.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java (100%) rename {app => omnipod}/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java (100%) rename {app => omnipod}/src/main/res/layout/omnipod_fragment.xml (100%) rename {app => omnipod}/src/main/res/layout/omnipod_initpod.xml (100%) rename {app => omnipod}/src/main/res/layout/omnipod_initpod_init_action.xml (100%) rename {app => omnipod}/src/main/res/layout/omnipod_initpod_pod_info.xml (100%) rename {app => omnipod}/src/main/res/layout/omnipod_initpod_pod_info_item.xml (100%) rename {app => omnipod}/src/main/res/layout/omnipod_pod_history_activity.xml (100%) rename {app => omnipod}/src/main/res/layout/omnipod_pod_history_item.xml (100%) rename {app => omnipod}/src/main/res/layout/omnipod_pod_mgmt.xml (100%) create mode 100644 omnipod/src/main/res/values/strings.xml create mode 100644 omnipod/src/main/res/values/styles.xml rename {app => omnipod}/src/main/res/xml/pref_omnipod.xml (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AcknowledgeAlertsCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AssignAddressCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BasalScheduleExtraCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BeepConfigCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BolusExtraCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/CancelDeliveryCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/ConfigureAlertsCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/DeactivatePodCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/FaultConfigCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/GetStatusCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetInsulinScheduleCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetupPodCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/TempBasalExtraCommandTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/defs/schedule/BasalTableEntryTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/ErrorResponseTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/StatusResponseTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/VersionResponseTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoActiveAlertsTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoDataLogTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultAndInitializationTimeTest.java (77%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultEventTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoOlderPulseLogTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoRecentPulseLogTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoResponseTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/AapsPodStateManagerTest.java (100%) rename {app => omnipod}/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManagerTest.java (71%) diff --git a/app/build.gradle b/app/build.gradle index 4b4aaa1876..1ba6eed95e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -134,11 +134,6 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // if you change minSdkVersion to less than 11, you need to change executeTask for wear - // OMNIPOD: Keep track of what commit from the main repository we're on, these fields aren't actually used anywhere - buildConfigField "String", "DEV_VERSION", '"2.6.7-dev"' - buildConfigField "String", "DEV_VERSION_COMMIT", '"65c8cc98804cfc366239ad2bedb2dd98e3e4f3c2"' - buildConfigField "String", "DEV_VERSION_COMMIT_DATE", '"16.8.2020"' // 16th of August - ndk { moduleName "BleCommandUtil" } @@ -250,6 +245,7 @@ dependencies { implementation project(':danar') implementation project(':rileylink') implementation project(':medtronic') + implementation project(':omnipod') implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.google.android.gms:play-services-wearable:17.0.0' @@ -285,8 +281,6 @@ dependencies { implementation "com.jjoe64:graphview:4.0.1" implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2" implementation 'com.madgag.spongycastle:core:1.58.0.0' - // Omnipod wizard - implementation(name: "com.atech-software.android.library.wizardpager-1.1.4", ext: "aar") implementation("com.google.android:flexbox:0.3.0") { exclude group: "com.android.support" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8f3db8e179..531e88e83a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -263,17 +263,6 @@ - - - - - - - diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt index cde5137ac9..cf9f7577fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt @@ -66,7 +66,7 @@ abstract class FragmentsModule { @ContributesAndroidInjector abstract fun contributesLoopFragment(): LoopFragment @ContributesAndroidInjector abstract fun contributesMaintenanceFragment(): MaintenanceFragment @ContributesAndroidInjector abstract fun contributesMedtronicFragment(): MedtronicFragment - @ContributesAndroidInjector abstract fun contributesOmnipodFragment(): OmnipodFragment + @ContributesAndroidInjector abstract fun contributesOmnipodFragment(): info.nightscout.androidaps.plugins.pump.omnipod.OmnipodFragment @ContributesAndroidInjector abstract fun contributesNSProfileFragment(): NSProfileFragment @ContributesAndroidInjector abstract fun contributesNSClientFragment(): NSClientFragment @ContributesAndroidInjector abstract fun contributesSmsCommunicatorFragment(): SmsCommunicatorFragment diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt index 0e73cea942..400d38d403 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt @@ -30,31 +30,31 @@ abstract class OmnipodModule { // Activities @ContributesAndroidInjector - abstract fun contributesPodManagementActivity(): PodManagementActivity - @ContributesAndroidInjector abstract fun contributesPodHistoryActivity(): PodHistoryActivity + abstract fun contributesPodManagementActivity(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity + @ContributesAndroidInjector abstract fun contributesPodHistoryActivity(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodHistoryActivity // Fragments - @ContributesAndroidInjector abstract fun initActionFragment(): InitActionFragment - @ContributesAndroidInjector abstract fun removeActionFragment(): RemoveActionFragment - @ContributesAndroidInjector abstract fun podInfoFragment(): PodInfoFragment + @ContributesAndroidInjector abstract fun initActionFragment(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitActionFragment + @ContributesAndroidInjector abstract fun removeActionFragment(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod.RemoveActionFragment + @ContributesAndroidInjector abstract fun podInfoFragment(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodInfoFragment // Service @ContributesAndroidInjector - abstract fun omnipodCommunicationManagerProvider(): OmnipodCommunicationManager - @ContributesAndroidInjector abstract fun aapsOmnipodManagerProvider(): AapsOmnipodManager + abstract fun omnipodCommunicationManagerProvider(): info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager + @ContributesAndroidInjector abstract fun aapsOmnipodManagerProvider(): info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager // Data - @ContributesAndroidInjector abstract fun omnipodUITaskProvider(): OmnipodUITask - @ContributesAndroidInjector abstract fun initPodRefreshAction(): InitPodRefreshAction - @ContributesAndroidInjector abstract fun podStateManager(): PodStateManager - @ContributesAndroidInjector abstract fun initPodTask(): InitPodTask - @ContributesAndroidInjector abstract fun omnipodPumpPlugin(): OmnipodPumpPlugin + @ContributesAndroidInjector abstract fun omnipodUITaskProvider(): info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask + @ContributesAndroidInjector abstract fun initPodRefreshAction(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction + @ContributesAndroidInjector abstract fun podStateManager(): info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager + @ContributesAndroidInjector abstract fun initPodTask(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodTask + @ContributesAndroidInjector abstract fun omnipodPumpPlugin(): info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin companion object { @Provides @Singleton - fun podStateManagerProvider(aapsLogger: AAPSLogger, sp: SP, omnipodPumpStatus: OmnipodPumpStatus, - rxBus: RxBusWrapper, resourceHelper: ResourceHelper, dateUtil: DateUtil): PodStateManager = - AapsPodStateManager(aapsLogger, sp, omnipodPumpStatus, rxBus, resourceHelper, dateUtil) + 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) } } diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt index 41c1615fe0..60faae9344 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt @@ -344,7 +344,7 @@ abstract class PluginsModule { @PumpDriver @IntoMap @IntKey(490) - abstract fun bindOmnipodPumpPlugin(plugin: OmnipodPumpPlugin): PluginBase + abstract fun bindOmnipodPumpPlugin(plugin: info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin): PluginBase @Qualifier annotation class AllConfigs diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ServicesModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ServicesModule.kt index f961c3a863..d5cd6a6c34 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ServicesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ServicesModule.kt @@ -30,5 +30,5 @@ abstract class ServicesModule { @ContributesAndroidInjector abstract fun contributesInsightConnectionService(): InsightConnectionService @ContributesAndroidInjector abstract fun contributesRileyLinkService(): RileyLinkService @ContributesAndroidInjector abstract fun contributesRileyLinkMedtronicService(): RileyLinkMedtronicService - @ContributesAndroidInjector abstract fun contributesRileyLinkOmnipodService(): RileyLinkOmnipodService + @ContributesAndroidInjector abstract fun contributesRileyLinkOmnipodService(): info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1daa8393b2..19d8c7966b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -744,7 +744,7 @@ Extended bolus delivery error Sight ago - enableSMB_always + enableSMB_always enableSMB_with_COB enableSMB_with_temptarget enableSMB_after_carbs @@ -915,18 +915,18 @@ Max daily safety multiplier Current basal safety multiplier n/a - virtualpump_type + virtualpump_type Virtual Pump Type Pump Definition Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s Autobackfill BG Wizard Settings - wearwizard_bg - wearwizard_tt - wearwizard_trend - wearwizard_cob - wearwizard_bolusiob - wearwizard_basaliob + wearwizard_bg + wearwizard_tt + wearwizard_trend + wearwizard_cob + wearwizard_bolusiob + wearwizard_basaliob Calculations included in the Wizard result: Display Settings General Settings @@ -965,8 +965,8 @@ Poctech Receive BG values from Poctech app Receive BG values from Tomato app (MiaoMiao device) - high_temptarget_raises_sensitivity - low_temptarget_lowers_sensitivity + high_temptarget_raises_sensitivity + low_temptarget_lowers_sensitivity High temptarget raises sensitivity = 100]]> Low temptarget lowers sensitivity @@ -1397,7 +1397,6 @@ skin Skin - Never contacted Waking up @@ -1408,163 +1407,6 @@ Active Sleeping - - - - - Omnipod - POD - Pump integration for Omnipod, requires RileyLink (with at least 2.0 firmware) device. - - - pref_omnipod_beep_bolus_enabled - pref_omnipod_beep_basal_enabled - pref_omnipod_beep_smb_enabled - pref_omnipod_beep_tbr_enabled - pref_omnipod_pod_debugging_options_enabled - pref_omnipod_timechange_enabled - Bolus Beep Enabled - Basal Beep Enabled - SMB Beep Enabled - TBR Beep Enabled - Pod Debugging Options Enabled - DST/Timezone Detection Enabled - - - Now - Pod Mgmt - Pod Status - %1$.2f U left - Over 50 U - Pod Address - Pod Expires - Warning - No Pod connected - Pod setup in progress (Pod progress status: %1$s) - Pod not initialized - Pod Fault - Pod Fault: %1$s %2$s - Pod running (last delivery status: %1$s) - Active Pod Alerts - Ack Alerts - %1$.2f %2$s (%3$s) - Initializing - Active - Unknown - - - - Omnipod (433.91 MHz) - - - - RileyLink Address invalid. - Operation is not possible.\n\nYou need to configure Omnipod first, before you can use this operation. - Operation is not possible.\n\n You need to wait few minutes, until AAPS tries to set profile for first time. - Illegal PodInitActionType: %1$s - No active pod. - - Command verification failed. - An unexpected error occurred. Please report! (type: %1$s). - Communication failed: received invalid input parameters. - Communication failed: timeout. - Communication failed: an unexpected error occurred. Please report! - Communication failed: message integrity verification failed. - Communication failed: received an invalid packet from the Pod. - Communication failed: the Pod is in a wrong state. - Communication failed: received an invalid response from the Pod. - Communication failed: received a message with an invalid sequence number from the Pod. - Communication failed: received a message with an invalid address from the Pod. - Communication failed: failed to decode message from the Pod. - Communication failed: nonce resync failed. - Communication failed: nonce out of sync. - Communication failed: not enough data received from the Pod. - A Pod fault (%1$03d %2$s) has been detected. Please deactivate your Pod and start a new one. - Communication failed: the Pod returned an error response. - - - Pod Management - Init Pod - Deactivate Pod - Reset Pod - Pod History - - Set Bolus - Cancel Bolus - Set Temporary Basal - Cancel Temporary Basal (Internally by driver) - Cancel Temporary Basal (Forced by user) - Set Basal Schedule - Get Pod Status - Get Pod Info - Set Time - Configure Alerts - Acknowledge Alerts - Suspend Delivery - Resume Delivery - Unknown Entry - - %1$.1f U - %1$.1f U, CH=%2$.1f g - Rate: %1$.1f U, Duration: %2$d min - - If you press OK, the Pod state will be forcibly reset and you will not be able to communicate with the Pod anymore. Do this only if you can not communicate with the Pod anymore. If you can still communicate with the Pod, please use the Deactivate Pod option. - Pod History not available at the moment. - - Omnipod - Omnipod - Omnipod - - - Fill the Pod - \nFill the new Pod with enough insulin for 3 days.\n\nListen for two beeps from the Pod during the filling process. These indicate that the minimum amount of 85U has been inserted. Be sure to completely empty the fill syringe, even after hearing the two beeps.\n\nAfter filling the Pod, please press Next.\n\nNote: do not remove the Pod\'s needle cap at this time. - Priming - Trying to pair with the new Pod and prime it.\n\nWhen all items are checked, you can press Next.\n\nNote: please keep the Pod and the RileyLink a few inches apart at this time. - Attach the Pod - \nPrepare the infusion site. Remove the Pod\'s needle cap and adhesive backing and attach the Pod to the infusion site.\n\nIf the cannula sticks out, please press Cancel and discard your Pod.\n\nPress Next to insert the cannula and begin basal delivery. - Inserting cannula - Trying to set initial basal schedule and insert the cannula.\n\nWhen all items are checked, you can press Next. - - Pod Info - \nThe Pod is now active.\n\nYour basal schedule has been programmed and the cannula has been inserted.\n\nPlease verify that the cannula has been inserted correctly and replace your Pod if you feel hasn\'t. - - Deactivate Pod - \nPress Next to deactivate the Pod.\n\nNote: This will suspend all insulin delivery and deactivate the Pod. - Deactivating the Pod - Deactivating the Pod.\n\nWhen all items are checked, you can press Next.\n\nNote: If deactivating continuously fails, please press Cancel and use the Reset Pod option to forcibly reset the Pod state. - - Pod deactivated.\n\nPlease remove the Pod from your body and discard it. - - Pair Pod - Prime Pod - Fill Cannula - Set Basal Profile - Cancel Delivery - Deactivate Pod - - - - Omnipod Dash - DASH - Pump integration for Omnipod Dash. - Finish pairing reminder - Finish setup reminder - Pod will expire soon - Pod will expire soon - Shutdown is imminent - Low reservoir - Unknown alert - Setting basal profile might have failed. Delivery might be suspended! Please refresh Pod status. - Setting temp basal might have failed. If there was a temp basal already running, that may have been cancelled! Please refresh pod status. - Setting time might have failed. Delivery might be suspended! Please refresh Pod status. - Unable to verify whether the bolus succeeded. Please verify that your Pod is bolusing or cancel the bolus. - RL Stats - Pulse Log - LOT - TID - PM / PI version - Errors - Compare profiles Profile helper Default profile diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 29f4ef5bc7..7425a772b4 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -52,36 +52,5 @@ #ff0000 - - - - - - + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/pref_omnipod.xml b/omnipod/src/main/res/xml/pref_omnipod.xml similarity index 100% rename from app/src/main/res/xml/pref_omnipod.xml rename to omnipod/src/main/res/xml/pref_omnipod.xml diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AcknowledgeAlertsCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AcknowledgeAlertsCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AcknowledgeAlertsCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AcknowledgeAlertsCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AssignAddressCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AssignAddressCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AssignAddressCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/AssignAddressCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BasalScheduleExtraCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BasalScheduleExtraCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BasalScheduleExtraCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BasalScheduleExtraCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BeepConfigCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BeepConfigCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BeepConfigCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BeepConfigCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BolusExtraCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BolusExtraCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BolusExtraCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BolusExtraCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/CancelDeliveryCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/CancelDeliveryCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/CancelDeliveryCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/CancelDeliveryCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/ConfigureAlertsCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/ConfigureAlertsCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/ConfigureAlertsCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/ConfigureAlertsCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/DeactivatePodCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/DeactivatePodCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/DeactivatePodCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/DeactivatePodCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/FaultConfigCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/FaultConfigCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/FaultConfigCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/FaultConfigCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/GetStatusCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/GetStatusCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/GetStatusCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/GetStatusCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetInsulinScheduleCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetInsulinScheduleCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetInsulinScheduleCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetInsulinScheduleCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetupPodCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetupPodCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetupPodCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetupPodCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/TempBasalExtraCommandTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/TempBasalExtraCommandTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/TempBasalExtraCommandTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/TempBasalExtraCommandTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/defs/schedule/BasalTableEntryTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/defs/schedule/BasalTableEntryTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/defs/schedule/BasalTableEntryTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/defs/schedule/BasalTableEntryTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/ErrorResponseTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/ErrorResponseTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/ErrorResponseTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/ErrorResponseTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/StatusResponseTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/StatusResponseTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/StatusResponseTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/StatusResponseTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/VersionResponseTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/VersionResponseTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/VersionResponseTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/VersionResponseTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoActiveAlertsTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoActiveAlertsTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoActiveAlertsTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoActiveAlertsTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoDataLogTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoDataLogTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoDataLogTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoDataLogTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultAndInitializationTimeTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultAndInitializationTimeTest.java similarity index 77% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultAndInitializationTimeTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultAndInitializationTimeTest.java index a7baff4f06..2998dc4f83 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultAndInitializationTimeTest.java +++ b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultAndInitializationTimeTest.java @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.po import org.joda.time.DateTime; import org.joda.time.Duration; +import org.junit.Assert; import org.junit.Test; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; @@ -19,10 +20,10 @@ public class PodInfoFaultAndInitializationTimeTest { assertTrue(Duration.standardMinutes(1).isEqual(podInfoFaultAndInitializationTime.getTimeFaultEvent())); DateTime dateTime = podInfoFaultAndInitializationTime.getInitializationTime(); - assertEquals(2018, dateTime.getYear()); - assertEquals(9, dateTime.getMonthOfYear()); - assertEquals(25, dateTime.getDayOfMonth()); - assertEquals(23, dateTime.getHourOfDay()); - assertEquals(14, dateTime.getMinuteOfHour()); + Assert.assertEquals(2018, dateTime.getYear()); + Assert.assertEquals(9, dateTime.getMonthOfYear()); + Assert.assertEquals(25, dateTime.getDayOfMonth()); + Assert.assertEquals(23, dateTime.getHourOfDay()); + Assert.assertEquals(14, dateTime.getMinuteOfHour()); } } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultEventTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultEventTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultEventTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoFaultEventTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoOlderPulseLogTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoOlderPulseLogTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoOlderPulseLogTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoOlderPulseLogTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoRecentPulseLogTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoRecentPulseLogTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoRecentPulseLogTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoRecentPulseLogTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoResponseTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoResponseTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoResponseTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/response/podinfo/PodInfoResponseTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/AapsPodStateManagerTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/AapsPodStateManagerTest.java similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/AapsPodStateManagerTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/AapsPodStateManagerTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManagerTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManagerTest.java similarity index 71% rename from app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManagerTest.java rename to omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManagerTest.java index 5def4c92d4..fcfd6c7d7a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManagerTest.java +++ b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManagerTest.java @@ -21,21 +21,21 @@ public class AapsOmnipodManagerTest { @Test public void validProfile() { - Profile profile = mock(Profile.class); + Profile profile = Mockito.mock(Profile.class); - Profile.ProfileValue value1 = mock(Profile.ProfileValue.class); + Profile.ProfileValue value1 = Mockito.mock(Profile.ProfileValue.class); value1.timeAsSeconds = 0; value1.value = 0.5D; - Profile.ProfileValue value2 = mock(Profile.ProfileValue.class); + Profile.ProfileValue value2 = Mockito.mock(Profile.ProfileValue.class); value2.timeAsSeconds = 18000; value2.value = 1.0D; - Profile.ProfileValue value3 = mock(Profile.ProfileValue.class); + Profile.ProfileValue value3 = Mockito.mock(Profile.ProfileValue.class); value3.timeAsSeconds = 50400; value3.value = 3.05D; - when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[]{ + PowerMockito.when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[]{ value1, value2, value3 @@ -70,16 +70,16 @@ public class AapsOmnipodManagerTest { public void invalidProfileNullEntries() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Basal values can not be null"); - AapsOmnipodManager.mapProfileToBasalSchedule(mock(Profile.class)); + AapsOmnipodManager.mapProfileToBasalSchedule(Mockito.mock(Profile.class)); } @Test public void invalidProfileZeroEntries() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Entries can not be empty"); - Profile profile = mock(Profile.class); + Profile profile = Mockito.mock(Profile.class); - when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[0]); + PowerMockito.when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[0]); AapsOmnipodManager.mapProfileToBasalSchedule(profile); } @@ -89,13 +89,13 @@ public class AapsOmnipodManagerTest { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("First basal schedule entry should have 0 offset"); - Profile profile = mock(Profile.class); + Profile profile = Mockito.mock(Profile.class); - Profile.ProfileValue value = mock(Profile.ProfileValue.class); + Profile.ProfileValue value = Mockito.mock(Profile.ProfileValue.class); value.timeAsSeconds = 1800; value.value = 0.5D; - when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[]{ + PowerMockito.when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[]{ value, }); @@ -107,17 +107,17 @@ public class AapsOmnipodManagerTest { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Invalid start time"); - Profile profile = mock(Profile.class); + Profile profile = Mockito.mock(Profile.class); - Profile.ProfileValue value1 = mock(Profile.ProfileValue.class); + Profile.ProfileValue value1 = Mockito.mock(Profile.ProfileValue.class); value1.timeAsSeconds = 0; value1.value = 0.5D; - Profile.ProfileValue value2 = mock(Profile.ProfileValue.class); + Profile.ProfileValue value2 = Mockito.mock(Profile.ProfileValue.class); value2.timeAsSeconds = 86400; value2.value = 0.5D; - when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[]{ + PowerMockito.when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[]{ value1, value2 }); @@ -130,13 +130,13 @@ public class AapsOmnipodManagerTest { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Invalid start time"); - Profile profile = mock(Profile.class); + Profile profile = Mockito.mock(Profile.class); - Profile.ProfileValue value = mock(Profile.ProfileValue.class); + Profile.ProfileValue value = Mockito.mock(Profile.ProfileValue.class); value.timeAsSeconds = -1; value.value = 0.5D; - when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[]{ + PowerMockito.when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[]{ value, }); @@ -145,13 +145,13 @@ public class AapsOmnipodManagerTest { @Test public void roundsToSupportedPrecision() { - Profile profile = mock(Profile.class); + Profile profile = Mockito.mock(Profile.class); - Profile.ProfileValue value = mock(Profile.ProfileValue.class); + Profile.ProfileValue value = Mockito.mock(Profile.ProfileValue.class); value.timeAsSeconds = 0; value.value = 0.04D; - when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[]{ + PowerMockito.when(profile.getBasalValues()).thenReturn(new Profile.ProfileValue[]{ value, }); diff --git a/settings.gradle b/settings.gradle index 19da851b52..f24d3e8922 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,3 @@ +include ':omnipod' include ':app', ':wear', ':core', ':dana', ':danar', ':danars', ':rileylink', ':medtronic' From 2a55c6413c4ac5a4bb02a492b5c0a0ea069c0b63 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 17 Aug 2020 00:07:56 +0200 Subject: [PATCH 03/40] Remove redundant DeviceCommandExecutor interface --- .../plugins/pump/common/defs/DeviceCommandExecutor.java | 4 ---- .../plugins/pump/omnipod/driver/ui/OmnipodUIComm.java | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/DeviceCommandExecutor.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/DeviceCommandExecutor.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/DeviceCommandExecutor.java deleted file mode 100644 index 8145d7f13b..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/DeviceCommandExecutor.java +++ /dev/null @@ -1,4 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.common.defs; - -public interface DeviceCommandExecutor { -} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java index 637f884500..fabd71b08d 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java @@ -3,14 +3,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.ui; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.pump.common.defs.DeviceCommandExecutor; import info.nightscout.androidaps.plugins.pump.omnipod.defs.IOmnipodManager; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType; /** * Created by andy on 4.8.2019 */ -public class OmnipodUIComm implements DeviceCommandExecutor { +public class OmnipodUIComm { private final HasAndroidInjector injector; private final AAPSLogger aapsLogger; From 5c4b9846e67dcbac59810f3d71bcf1685b22aa98 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 17 Aug 2020 19:53:43 +0200 Subject: [PATCH 04/40] WIP on moving Omnipod into a separate module --- .../androidaps/db/DatabaseHelper.java | 26 ++-- .../androidaps/db/DatabaseHelperProvider.java | 13 +- .../androidaps/db/OmnipodHistoryRecord.java | 42 ++---- .../interfaces/DatabaseHelperInterface.kt | 8 +- .../pump/common/PumpPluginAbstract.java | 10 +- .../plugins/pump/omnipod/OmnipodFragment.kt | 36 +++-- .../pump/omnipod/OmnipodPumpPlugin.java | 123 +++--------------- .../omnipod/comm/action/GetStatusAction.java | 2 +- .../exception/CommunicationException.java | 2 +- .../IllegalMessageAddressException.java | 2 +- ...IllegalMessageSequenceNumberException.java | 2 +- .../IllegalVersionResponseTypeException.java | 2 +- .../omnipod/comm/message/OmnipodMessage.java | 6 +- .../omnipod/comm/message/OmnipodPacket.java | 2 +- .../message/command/BolusExtraCommand.java | 2 +- .../command/SetInsulinScheduleCommand.java | 2 +- .../command/TempBasalExtraCommand.java | 2 +- .../omnipod/data/RLHistoryItemOmnipod.java | 9 +- .../defs/OmnipodPumpPluginInterface.java | 7 - .../omnipod/defs/OmnipodStatusRequest.java | 3 +- .../pump/omnipod/defs/PodInitActionType.java | 2 +- .../omnipod/dialogs/PodHistoryActivity.java | 35 ++--- .../omnipod/dialogs/PodManagementActivity.kt | 4 +- .../wizard/initpod/InitActionFragment.java | 2 +- .../wizard/initpod/InitActionPage.java | 2 +- .../wizard/model/FullInitPodWizardModel.java | 2 +- .../wizard/model/RemovePodWizardModel.java | 2 +- .../wizard/model/ShortInitPodWizardModel.java | 2 +- .../wizard/pages/InitPodRefreshAction.java | 18 +-- .../dialogs/wizard/pages/PodInfoFragment.java | 2 +- .../wizard/removepod/RemovePodActionPage.java | 1 - .../omnipod/driver/OmnipodDriverState.java | 11 -- .../omnipod/driver/OmnipodPumpStatus.java | 11 +- .../driver/comm/AapsOmnipodManager.java | 39 ++++-- .../driver/db/PodHistoryEntryType.java | 10 +- .../driver/ui/OmnipodUIPostprocessor.java | 71 ++-------- .../events/EventOmnipodRefreshButtonState.kt | 2 +- .../service/RileyLinkOmnipodService.java | 2 +- .../plugins/pump/omnipod/util/OmniCRC.java | 2 +- .../pump/omnipod/util/OmnipodConst.java | 2 +- .../pump/omnipod/util/OmnipodUtil.java | 40 +----- omnipod/src/main/res/values/strings.xml | 18 +-- 42 files changed, 172 insertions(+), 409 deletions(-) rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistory.java => core/src/main/java/info/nightscout/androidaps/db/OmnipodHistoryRecord.java (62%) delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodDriverState.java diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index 7ba9957ed8..d96fda8d3b 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -57,7 +57,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHi import info.nightscout.androidaps.plugins.pump.insight.database.InsightBolusID; import info.nightscout.androidaps.plugins.pump.insight.database.InsightHistoryOffset; import info.nightscout.androidaps.plugins.pump.insight.database.InsightPumpID; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistory; import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin; import info.nightscout.androidaps.utils.JsonHelper; import info.nightscout.androidaps.utils.PercentageSplitter; @@ -88,7 +87,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public static final String DATABASE_INSIGHT_HISTORY_OFFSETS = "InsightHistoryOffsets"; public static final String DATABASE_INSIGHT_BOLUS_IDS = "InsightBolusIDs"; public static final String DATABASE_INSIGHT_PUMP_IDS = "InsightPumpIDs"; - public static final String DATABASE_POD_HISTORY = "PodHistory"; private static final int DATABASE_VERSION = 12; @@ -142,7 +140,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class); TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class); TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class); - TableUtils.createTableIfNotExists(connectionSource, PodHistory.class); + TableUtils.createTableIfNotExists(connectionSource, OmnipodHistoryRecord.class); database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_BOLUS_IDS + "\", " + System.currentTimeMillis() + " " + "WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_BOLUS_IDS + "\")"); database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_PUMP_IDS + "\", " + System.currentTimeMillis() + " " + @@ -219,7 +217,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { TableUtils.dropTable(connectionSource, CareportalEvent.class, true); TableUtils.dropTable(connectionSource, ProfileSwitch.class, true); TableUtils.dropTable(connectionSource, TDD.class, true); - TableUtils.dropTable(connectionSource, PodHistory.class, true); + TableUtils.dropTable(connectionSource, OmnipodHistoryRecord.class, true); TableUtils.createTableIfNotExists(connectionSource, TempTarget.class); TableUtils.createTableIfNotExists(connectionSource, BgReading.class); TableUtils.createTableIfNotExists(connectionSource, DanaRHistoryRecord.class); @@ -229,7 +227,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class); TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class); TableUtils.createTableIfNotExists(connectionSource, TDD.class); - TableUtils.createTableIfNotExists(connectionSource, PodHistory.class); + TableUtils.createTableIfNotExists(connectionSource, OmnipodHistoryRecord.class); updateEarliestDataChange(0); } catch (SQLException e) { aapsLogger.error("Unhandled exception", e); @@ -364,8 +362,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { return getDao(InsightHistoryOffset.class); } - private Dao getDaoPodHistory() throws SQLException { - return getDao(PodHistory.class); + private Dao getDaoPodHistory() throws SQLException { + return getDao(OmnipodHistoryRecord.class); } public long roundDateToSec(long date) { @@ -1865,25 +1863,25 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { // ---------------- PodHistory handling --------------- - public void createOrUpdate(PodHistory podHistory) { + public void createOrUpdate(OmnipodHistoryRecord omnipodHistoryRecord) { try { - getDaoPodHistory().createOrUpdate(podHistory); + getDaoPodHistory().createOrUpdate(omnipodHistoryRecord); } catch (SQLException e) { aapsLogger.error("Unhandled exception", e); } } - public List getPodHistoryFromTime(long from, boolean ascending) { + public List getAllOmnipodHistoryRecordsFromTimeStamp(long from, boolean ascending) { try { - Dao daoPodHistory = getDaoPodHistory(); - List podHistories; - QueryBuilder queryBuilder = daoPodHistory.queryBuilder(); + Dao daoPodHistory = getDaoPodHistory(); + List podHistories; + QueryBuilder queryBuilder = daoPodHistory.queryBuilder(); queryBuilder.orderBy("date", ascending); //queryBuilder.limit(100L); Where where = queryBuilder.where(); where.ge("date", from); - PreparedQuery preparedQuery = queryBuilder.prepare(); + PreparedQuery preparedQuery = queryBuilder.prepare(); podHistories = daoPodHistory.query(preparedQuery); return podHistories; } catch (SQLException e) { diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java index 0e9f9d82b2..4468692189 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java @@ -16,7 +16,8 @@ import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; @Singleton public class DatabaseHelperProvider implements DatabaseHelperInterface { - @Inject DatabaseHelperProvider() {} + @Inject DatabaseHelperProvider() { + } @NotNull @Override public List getAllBgreadingsDataFromTime(long mills, boolean ascending) { return MainApp.getDbHelper().getAllBgreadingsDataFromTime(mills, ascending); @@ -30,6 +31,10 @@ public class DatabaseHelperProvider implements DatabaseHelperInterface { MainApp.getDbHelper().createOrUpdate(record); } + @Override public void createOrUpdate(@NotNull OmnipodHistoryRecord record) { + MainApp.getDbHelper().createOrUpdate(record); + } + @NotNull @Override public List getDanaRHistoryRecordsByType(byte type) { return MainApp.getDbHelper().getDanaRHistoryRecordsByType(type); } @@ -86,10 +91,14 @@ public class DatabaseHelperProvider implements DatabaseHelperInterface { return MainApp.getDbHelper().getTemporaryBasalsDataFromTime(mills, ascending); } - @NotNull @Override public CareportalEvent getCareportalEventFromTimestamp(long timestamp) { + @Override public CareportalEvent getCareportalEventFromTimestamp(long timestamp) { return MainApp.getDbHelper().getCareportalEventFromTimestamp(timestamp); } + @NotNull @Override public List getAllOmnipodHistoryRecordsFromTimestamp(long timestamp, boolean ascending) { + return MainApp.getDbHelper().getAllOmnipodHistoryRecordsFromTimeStamp(timestamp, ascending); + } + @NotNull @Override public List getTDDsForLastXDays(int days) { return MainApp.getDbHelper().getTDDsForLastXDays(days); } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistory.java b/core/src/main/java/info/nightscout/androidaps/db/OmnipodHistoryRecord.java similarity index 62% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistory.java rename to core/src/main/java/info/nightscout/androidaps/db/OmnipodHistoryRecord.java index e064fb5c24..0f4b56b096 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistory.java +++ b/core/src/main/java/info/nightscout/androidaps/db/OmnipodHistoryRecord.java @@ -1,23 +1,19 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.driver.db; +package info.nightscout.androidaps.db; import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; -import info.nightscout.androidaps.db.DatabaseHelper; -import info.nightscout.androidaps.db.DbObjectBase; import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; /** * Created by andy on 30.11.2019. */ -@DatabaseTable(tableName = DatabaseHelper.DATABASE_POD_HISTORY) -public class PodHistory implements DbObjectBase, Comparable { +@DatabaseTable(tableName = "PodHistory") +public class OmnipodHistoryRecord implements DbObjectBase, Comparable { @DatabaseField(id = true) public long date; - private PodHistoryEntryType podHistoryEntryType; - @DatabaseField private long podEntryTypeCode; @@ -36,27 +32,16 @@ public class PodHistory implements DbObjectBase, Comparable { @DatabaseField private Boolean successConfirmed; - public PodHistory() { + public OmnipodHistoryRecord() { generatePumpId(); } - - public PodHistory(PodHistoryEntryType podDbEntryType) { - this.date = System.currentTimeMillis(); - this.podHistoryEntryType = podDbEntryType; - this.podEntryTypeCode = podDbEntryType.getCode(); - generatePumpId(); - } - - - public PodHistory(long dateTimeInMillis, PodHistoryEntryType podDbEntryType) { + public OmnipodHistoryRecord(long dateTimeInMillis, long podEntryTypeCode) { this.date = dateTimeInMillis; - this.podHistoryEntryType = podDbEntryType; - this.podEntryTypeCode = podDbEntryType.getCode(); + this.podEntryTypeCode = podEntryTypeCode; generatePumpId(); } - @Override public long getDate() { return this.date; @@ -70,19 +55,14 @@ public class PodHistory implements DbObjectBase, Comparable { return DateTimeUtil.toStringFromTimeInMillis(this.date); } - public PodHistoryEntryType getPodDbEntryType() { - return PodHistoryEntryType.getByCode((int) this.podEntryTypeCode); - } - - public void setPodDbEntryType(PodHistoryEntryType podDbEntryType) { - //this.podHistoryEntryType = podDbEntryType; - this.podEntryTypeCode = podDbEntryType.getCode(); - } - public long getPodEntryTypeCode() { return podEntryTypeCode; } + public void setPodEntryTypeCode(long podEntryTypeCode) { + this.podEntryTypeCode = podEntryTypeCode; + } + public String getData() { return data; } @@ -130,7 +110,7 @@ public class PodHistory implements DbObjectBase, Comparable { } @Override - public int compareTo(PodHistory otherOne) { + public int compareTo(OmnipodHistoryRecord otherOne) { return (int) (otherOne.date - this.date); } } diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt index df90e03586..007ff88b90 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt @@ -8,6 +8,7 @@ interface DatabaseHelperInterface { fun getAllBgreadingsDataFromTime(mills: Long, ascending: Boolean): List fun createOrUpdate(careportalEvent: CareportalEvent) fun createOrUpdate(record: DanaRHistoryRecord) + fun createOrUpdate(record: OmnipodHistoryRecord) fun create(record: DbRequest) fun getDanaRHistoryRecordsByType(type: Byte): List fun getTDDs(): List @@ -19,9 +20,10 @@ interface DatabaseHelperInterface { fun roundDateToSec(date: Long): Long fun createOrUpdateTDD(record: TDD) fun createOrUpdate(tempBasal: TemporaryBasal) - fun findTempBasalByPumpId(id: Long) : TemporaryBasal - fun getTemporaryBasalsDataFromTime(mills: Long, ascending: Boolean) : List - fun getCareportalEventFromTimestamp(timestamp: Long): CareportalEvent + fun findTempBasalByPumpId(id: Long): TemporaryBasal + fun getTemporaryBasalsDataFromTime(mills: Long, ascending: Boolean): List + fun getCareportalEventFromTimestamp(timestamp: Long): CareportalEvent? + fun getAllOmnipodHistoryRecordsFromTimestamp(timestamp: Long, ascending: Boolean): List fun getTDDsForLastXDays(days: Int): List fun getProfileSwitchData(from: Long, ascending: Boolean): List } diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java index ed44321d7d..c45036df73 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java @@ -64,17 +64,9 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI protected CommandQueueProvider commandQueue; protected SP sp; protected DateUtil dateUtil; - - /* - protected static final PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult().success(false) - .enacted(false).comment(MainApp.gs(R.string.pump_operation_not_supported_by_pump_driver)); - protected static final PumpEnactResult OPERATION_NOT_YET_SUPPORTED = new PumpEnactResult().success(false) - .enacted(false).comment(MainApp.gs(R.string.pump_operation_not_yet_supported_by_pump)); - */ protected PumpDescription pumpDescription = new PumpDescription(); - protected ServiceConnection serviceConnection = null; + protected ServiceConnection serviceConnection; protected boolean serviceRunning = false; - // protected boolean isInitialized = false; protected PumpDriverState pumpState = PumpDriverState.NotInitialized; protected boolean displayConnectionMessages = false; protected PumpType pumpType; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt index e80f95d292..f35de6426d 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt @@ -9,8 +9,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import dagger.android.support.DaggerFragment -import info.nightscout.androidaps.MainApp -import info.nightscout.androidaps.R import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider @@ -34,7 +32,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.LocalAlertUtils import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.WarnColors import info.nightscout.androidaps.utils.alertDialogs.OKDialog @@ -55,7 +52,6 @@ import javax.inject.Inject class OmnipodFragment : DaggerFragment() { @Inject lateinit var aapsLogger: AAPSLogger - @Inject lateinit var mainApp: MainApp @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var rxBus: RxBusWrapper @@ -68,7 +64,9 @@ class OmnipodFragment : DaggerFragment() { @Inject lateinit var sp: SP @Inject lateinit var omnipodUtil: OmnipodUtil @Inject lateinit var rileyLinkServiceData: RileyLinkServiceData - @Inject lateinit var localAlertUtils: LocalAlertUtils + + // TODO somehow obtain the pumpUnreachableThreshold in order to display last connection time red or white + // @Inject lateinit var localAlertUtils: LocalAlertUtils @Inject lateinit var protectionCheck: ProtectionCheck private var disposable: CompositeDisposable = CompositeDisposable() @@ -98,8 +96,8 @@ class OmnipodFragment : DaggerFragment() { if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) { activity?.let { activity -> protectionCheck.queryProtection( - activity,ProtectionCheck.Protection.PREFERENCES, - UIRunnable(Runnable{startActivity(Intent(context, PodManagementActivity::class.java))}) + activity, ProtectionCheck.Protection.PREFERENCES, + UIRunnable(Runnable { startActivity(Intent(context, PodManagementActivity::class.java)) }) ) } } else { @@ -330,11 +328,15 @@ class OmnipodFragment : DaggerFragment() { private fun updateLastConnectionUiElements() { if (podStateManager.isPodInitialized && podStateManager.lastSuccessfulCommunication != null) { // Null check for backwards compatibility omnipod_lastconnection.text = readableDuration(podStateManager.lastSuccessfulCommunication) + omnipod_lastconnection.setTextColor(Color.WHITE) + /* + // TODO if (omnipodPumpPlugin.isUnreachableAlertTimeoutExceeded(localAlertUtils.pumpUnreachableThreshold())) { omnipod_lastconnection.setTextColor(Color.RED) } else { omnipod_lastconnection.setTextColor(Color.WHITE) } + */ } else { omnipod_lastconnection.setTextColor(Color.WHITE) if (podStateManager.hasPodState() && podStateManager.lastSuccessfulCommunication != null) { @@ -356,25 +358,19 @@ class OmnipodFragment : DaggerFragment() { } private fun readableDuration(dateTime: DateTime): String { - val min = Duration(dateTime, DateTime.now()).standardMinutes + val minutes = Duration(dateTime, DateTime.now()).standardMinutes when { - min == 0L -> { + minutes == 0L -> { return resourceHelper.gs(R.string.omnipod_connected_now) } - min < 60 -> { - return resourceHelper.gs(R.string.minago, min) + minutes < 60 -> { + return resourceHelper.gs(R.string.minago, minutes) } - min < 1440 -> { - val h = (min / 60).toInt() - return resourceHelper.gq(R.plurals.objective_hours, h, h) + " " + resourceHelper.gs(R.string.ago) - } - - else -> { - val h = (min / 60).toInt() - val d = h / 24 - return resourceHelper.gq(R.plurals.objective_days, d, d) + " " + resourceHelper.gs(R.string.ago) + else -> { + val hours = (minutes / 60).toInt() + return resourceHelper.gs(R.string.hoursago, hours) } } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index c1e0eea476..f7dfe16e99 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -4,7 +4,6 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.os.Bundle; import android.os.IBinder; import android.os.SystemClock; @@ -24,8 +23,6 @@ import javax.inject.Inject; import javax.inject.Singleton; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.BuildConfig; -import info.nightscout.androidaps.R; import info.nightscout.androidaps.activities.ErrorHelperActivity; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.Profile; @@ -49,7 +46,6 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract; import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus; import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair; -import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState; import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice; @@ -59,12 +55,10 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.IOmnipodManager; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIComm; import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask; @@ -72,7 +66,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpVa import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState; import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; -import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.Round; @@ -89,41 +82,29 @@ import io.reactivex.schedulers.Schedulers; */ @Singleton public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPumpPluginInterface, RileyLinkPumpDevice { - protected PodStateManager podStateManager; - private static OmnipodPumpPlugin plugin = null; - private RileyLinkServiceData rileyLinkServiceData; - private ServiceTaskExecutor serviceTaskExecutor; - private RileyLinkOmnipodService rileyLinkOmnipodService; - private OmnipodUtil omnipodUtil; - protected OmnipodPumpStatus omnipodPumpStatus = null; - //protected OmnipodUIComm omnipodUIComm; + private final PodStateManager podStateManager; + private final RileyLinkServiceData rileyLinkServiceData; + private final ServiceTaskExecutor serviceTaskExecutor; + private final OmnipodPumpStatus omnipodPumpStatus; private CompositeDisposable disposable = new CompositeDisposable(); - // variables for handling statuses and history protected boolean firstRun = true; protected boolean isRefresh = false; - private boolean isBasalProfileInvalid = false; - private boolean basalProfileChanged = false; private boolean isInitialized = false; - protected IOmnipodManager omnipodCommunicationManager; - // TODO make non-static just inject the Singleton and use a getter) - public static boolean isBusy = false; + + private RileyLinkOmnipodService rileyLinkOmnipodService; + + private boolean isBusy = false; // TODO it seems that we never add anything to this list? // I Wouldn't know why we need it anyway protected List busyTimestamps = new ArrayList<>(); - protected boolean sentIdToFirebase = false; protected boolean hasTimeDateOrTimeZoneChanged = false; private int timeChangeRetries = 0; - private Profile currentProfile; - - boolean omnipodServiceRunning = false; - private long nextPodCheck = 0L; - //OmnipodDriverState driverState = OmnipodDriverState.NotInitalized; @Inject public OmnipodPumpPlugin( @@ -134,7 +115,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump ResourceHelper resourceHelper, ActivePluginProvider activePlugin, SP sp, - OmnipodUtil omnipodUtil, OmnipodPumpStatus omnipodPumpStatus, PodStateManager podStateManager, CommandQueueProvider commandQueue, @@ -157,23 +137,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump this.podStateManager = podStateManager; this.rileyLinkServiceData = rileyLinkServiceData; this.serviceTaskExecutor = serviceTaskExecutor; - - displayConnectionMessages = false; - this.omnipodUtil = omnipodUtil; this.omnipodPumpStatus = omnipodPumpStatus; - //OmnipodUtil.setDriverState(); - -// TODO loop -// if (OmnipodUtil.isOmnipodEros()) { -// OmnipodUtil.setPlugin(this); -// OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros); -// OmnipodUtil.setPumpType(PumpType.Insulet_Omnipod); -// } - -// // TODO ccc - - serviceConnection = new ServiceConnection() { + displayConnectionMessages = false; + this.serviceConnection = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { @@ -230,28 +197,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } - protected OmnipodPumpPlugin(PluginDescription pluginDescription, PumpType pumpType, - HasAndroidInjector injector, - AAPSLogger aapsLogger, - RxBusWrapper rxBus, - Context context, - ResourceHelper resourceHelper, - ActivePluginProvider activePlugin, - info.nightscout.androidaps.utils.sharedPreferences.SP sp, - CommandQueueProvider commandQueue, - FabricPrivacy fabricPrivacy, - DateUtil dateUtil) { - super(pluginDescription, pumpType, injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy, dateUtil); - -// this.rileyLinkUtil = rileyLinkUtil; -// this.medtronicUtil = medtronicUtil; -// this.sp = sp; -// this.medtronicPumpStatus = medtronicPumpStatus; -// this.medtronicHistoryData = medtronicHistoryData; -// this.rileyLinkServiceData = rileyLinkServiceData; -// this.serviceTaskExecutor = serviceTaskExecutor; - } - public PodStateManager getPodStateManager() { return podStateManager; } @@ -566,26 +511,15 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } } - - public void setIsBusy(boolean isBusy_) { - isBusy = isBusy_; + public void setIsBusy(boolean isBusy) { + this.isBusy = isBusy; } - private void getPodPumpStatus() { // TODO read pod status aapsLogger.error(LTag.PUMP, "getPodPumpStatus() NOT IMPLEMENTED"); - - //addPodStatusRequest(OmnipodStatusRequest.GetPodState); - - //getPodPumpStatusObject().driverState = OmnipodDriverState.Initalized_PodAvailable; - //driverState = OmnipodDriverState.Initalized_PodAvailable; - // FIXME this does not seem to make sense - omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAttached); - // we would probably need to read Basal Profile here too } - List omnipodStatusRequestList = new ArrayList<>(); public void addPodStatusRequest(OmnipodStatusRequest pumpStatusRequest) { @@ -596,12 +530,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } } - @Override - public void setDriverState(OmnipodDriverState state) { - //this.driverState = state; - } - - public void resetStatusState() { firstRun = true; isRefresh = true; @@ -625,29 +553,14 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump if (podStateManager.isPodInitialized()) { aapsLogger.debug(LTag.PUMP, "PodStateManager (saved): " + podStateManager); - - if (!isRefresh) { - pumpState = PumpDriverState.Initialized; - } - // TODO handle if session state too old getPodPumpStatus(); } else { aapsLogger.debug(LTag.PUMP, "No Pod running"); - omnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod); } finishAction("Omnipod Pump"); - if (!sentIdToFirebase) { - Bundle params = new Bundle(); - params.putString("version", BuildConfig.VERSION); - - getFabricPrivacy().getFirebaseAnalytics().logEvent("OmnipodPumpInit", params); - - sentIdToFirebase = true; - } - isInitialized = true; this.firstRun = false; @@ -917,7 +830,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return new PumpEnactResult(getInjector()) // .success(true) // .enacted(false) // - .comment(resourceHelper.gs(R.string.medtronic_cmd_basal_profile_not_set_is_same)); + .comment(resourceHelper.gs(R.string.omnipod_cmd_basal_profile_not_set_is_same)); } setRefreshButtonEnabled(false); @@ -952,7 +865,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump protected List customActions = null; private CustomAction customActionResetRLConfig = new CustomAction( - R.string.medtronic_custom_action_reset_rileylink, OmnipodCustomActionType.ResetRileyLinkConfiguration, true); + R.string.omnipod_custom_action_reset_rileylink, OmnipodCustomActionType.ResetRileyLinkConfiguration, true); @Override @@ -988,11 +901,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump public void timezoneOrDSTChanged(TimeChangeType timeChangeType) { aapsLogger.warn(LTag.PUMP, getLogPrefix() + "Time, Date and/or TimeZone changed. [changeType=" + timeChangeType.name() + ", eventHandlingEnabled=" + omnipodPumpStatus.timeChangeEventEnabled + "]"); - if (omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_PodAttached) { - if (omnipodPumpStatus.timeChangeEventEnabled) { - aapsLogger.info(LTag.PUMP, getLogPrefix() + "Time,and/or TimeZone changed event received and will be consumed by driver."); - this.hasTimeDateOrTimeZoneChanged = true; - } + if (omnipodPumpStatus.timeChangeEventEnabled && podStateManager.isPodRunning()) { + aapsLogger.info(LTag.PUMP, getLogPrefix() + "Time,and/or TimeZone changed event received and will be consumed by driver."); + this.hasTimeDateOrTimeZoneChanged = true; } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/GetStatusAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/GetStatusAction.java index 35431cea8b..6cad5798a2 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/GetStatusAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/GetStatusAction.java @@ -1,10 +1,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.action; import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager; +import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.GetStatusCommand; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType; -import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager; public class GetStatusAction implements OmnipodAction { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/CommunicationException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/CommunicationException.java index c7392fd42e..8b1215b1aa 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/CommunicationException.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/CommunicationException.java @@ -11,7 +11,7 @@ public class CommunicationException extends OmnipodException { } public CommunicationException(Type type, Throwable cause) { - super(type.getDescription() + ": "+ cause, cause, false); + super(type.getDescription() + ": " + cause, cause, false); this.type = type; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalMessageAddressException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalMessageAddressException.java index 9c674cd8ca..cd8385d442 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalMessageAddressException.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalMessageAddressException.java @@ -7,7 +7,7 @@ public class IllegalMessageAddressException extends OmnipodException { private final int actual; public IllegalMessageAddressException(int expected, int actual) { - super("Invalid message address. Expected="+ expected +", actual="+ actual, false); + super("Invalid message address. Expected=" + expected + ", actual=" + actual, false); this.expected = expected; this.actual = actual; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalMessageSequenceNumberException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalMessageSequenceNumberException.java index b26d2b6ff8..4080ef9764 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalMessageSequenceNumberException.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalMessageSequenceNumberException.java @@ -7,7 +7,7 @@ public class IllegalMessageSequenceNumberException extends OmnipodException { private final int actual; public IllegalMessageSequenceNumberException(int expected, int actual) { - super("Invalid message sequence number. Expected="+ expected +", actual="+ actual, false); + super("Invalid message sequence number. Expected=" + expected + ", actual=" + actual, false); this.expected = expected; this.actual = actual; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalVersionResponseTypeException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalVersionResponseTypeException.java index 0dbe0805d5..79c42a948d 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalVersionResponseTypeException.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/exception/IllegalVersionResponseTypeException.java @@ -4,6 +4,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodExceptio public class IllegalVersionResponseTypeException extends OmnipodException { public IllegalVersionResponseTypeException(String expected, String actual) { - super("Invalid Version Response type. Expected="+ expected +", actual="+ actual, false); + super("Invalid Version Response type. Expected=" + expected + ", actual=" + actual, false); } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/OmnipodMessage.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/OmnipodMessage.java index 78cfa72e19..e302d90461 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/OmnipodMessage.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/OmnipodMessage.java @@ -4,12 +4,12 @@ import java.util.ArrayList; import java.util.List; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; -import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.GetStatusCommand; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.MessageBlockType; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType; import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CrcMismatchException; import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.MessageDecodingException; import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NotEnoughDataException; +import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.GetStatusCommand; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.MessageBlockType; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmniCRC; public class OmnipodMessage { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/OmnipodPacket.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/OmnipodPacket.java index 3764cf7b60..4bbe035519 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/OmnipodPacket.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/OmnipodPacket.java @@ -2,9 +2,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.message; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.PacketType; import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CrcMismatchException; import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalPacketTypeException; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.PacketType; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmniCRC; /** diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BolusExtraCommand.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BolusExtraCommand.java index 3554f85e0a..a19b8b7651 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BolusExtraCommand.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/BolusExtraCommand.java @@ -3,9 +3,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command; import org.joda.time.Duration; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; +import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommandInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock; import info.nightscout.androidaps.plugins.pump.omnipod.defs.MessageBlockType; -import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommandInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; public class BolusExtraCommand extends MessageBlock { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetInsulinScheduleCommand.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetInsulinScheduleCommand.java index 301435e6a2..bebca2e7d7 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetInsulinScheduleCommand.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/SetInsulinScheduleCommand.java @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command; import org.joda.time.Duration; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; +import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommandInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.NonceResyncableMessageBlock; import info.nightscout.androidaps.plugins.pump.omnipod.defs.MessageBlockType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalDeliverySchedule; @@ -11,7 +12,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedu import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BolusDeliverySchedule; import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.DeliverySchedule; import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.TempBasalDeliverySchedule; -import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommandInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; public class SetInsulinScheduleCommand extends NonceResyncableMessageBlock { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/TempBasalExtraCommand.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/TempBasalExtraCommand.java index 212f748bf1..e076750399 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/TempBasalExtraCommand.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/message/command/TempBasalExtraCommand.java @@ -6,10 +6,10 @@ import java.util.ArrayList; import java.util.List; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; +import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommandInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock; import info.nightscout.androidaps.plugins.pump.omnipod.defs.MessageBlockType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.RateEntry; -import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommandInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; public class TempBasalExtraCommand extends MessageBlock { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java index 9b861675bd..c85c28d253 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java @@ -4,7 +4,6 @@ import org.joda.time.LocalDateTime; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; -import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -20,14 +19,14 @@ public class RLHistoryItemOmnipod extends RLHistoryItem { public String getDescription(ResourceHelper resourceHelper) { switch (this.source) { - case RLHistoryItemSource.RileyLink: + case RileyLink: return "State: " + resourceHelper.gs(serviceState.getResourceId(targetDevice)) + (this.errorCode == null ? "" : ", Error Code: " + errorCode); - case RLHistoryItemSource.MedtronicPump: + case MedtronicPump: return resourceHelper.gs(pumpDeviceState.getResourceId()); - case RLHistoryItemSource.OmnipodCommand: + case OmnipodCommand: return omnipodCommandType.name(); default: @@ -35,6 +34,4 @@ public class RLHistoryItemOmnipod extends RLHistoryItem { } } - - } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodPumpPluginInterface.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodPumpPluginInterface.java index 0026d41f97..50cfec2d88 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodPumpPluginInterface.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodPumpPluginInterface.java @@ -1,16 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs; import info.nightscout.androidaps.interfaces.PumpInterface; -import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState; public interface OmnipodPumpPluginInterface extends PumpInterface { void addPodStatusRequest(OmnipodStatusRequest pumpStatusRequest); - void setDriverState(OmnipodDriverState state); - - @Deprecated - RxBusWrapper getRxBus(); - } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodStatusRequest.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodStatusRequest.java index 80f7e4ecfc..2ab1ca024f 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodStatusRequest.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodStatusRequest.java @@ -4,8 +4,7 @@ public enum OmnipodStatusRequest { ResetState(OmnipodCommandType.ResetPodStatus), // AcknowledgeAlerts(OmnipodCommandType.AcknowledgeAlerts), // GetPodState(OmnipodCommandType.GetPodStatus), // - GetPodPulseLog(OmnipodCommandType.GetPodPulseLog) - ; + GetPodPulseLog(OmnipodCommandType.GetPodPulseLog); private OmnipodCommandType commandType; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInitActionType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInitActionType.java index 6543bcc84f..1e614ee779 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInitActionType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInitActionType.java @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs; import java.util.ArrayList; import java.util.List; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.pump.omnipod.R; public enum PodInitActionType { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodHistoryActivity.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodHistoryActivity.java index bfbdbfc9d6..51052e72eb 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodHistoryActivity.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodHistoryActivity.java @@ -23,17 +23,18 @@ import java.util.List; import javax.inject.Inject; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; import info.nightscout.androidaps.activities.NoSplashAppCompatActivity; import info.nightscout.androidaps.data.Profile; +import info.nightscout.androidaps.db.OmnipodHistoryRecord; +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair; import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup; import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.plugins.pump.common.utils.ProfileUtil; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistory; +import info.nightscout.androidaps.plugins.pump.omnipod.R; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistoryEntryType; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -42,6 +43,7 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { @Inject AAPSLogger aapsLogger; @Inject OmnipodUtil omnipodUtil; @Inject ResourceHelper resourceHelper; + @Inject DatabaseHelperInterface databaseHelper; private Spinner historyTypeSpinner; private TextView statusView; @@ -50,8 +52,8 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { static TypeList showingType = null; static PumpHistoryEntryGroup selectedGroup = PumpHistoryEntryGroup.All; - List fullHistoryList = new ArrayList<>(); - List filteredHistoryList = new ArrayList<>(); + List fullHistoryList = new ArrayList<>(); + List filteredHistoryList = new ArrayList<>(); RecyclerViewAdapter recyclerViewAdapter; boolean manualChange = false; @@ -68,9 +70,9 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { GregorianCalendar gc = new GregorianCalendar(); gc.add(Calendar.HOUR_OF_DAY, -24); - MainApp.getDbHelper().getPodHistoryFromTime(gc.getTimeInMillis(), false); + databaseHelper.getAllOmnipodHistoryRecordsFromTimestamp(gc.getTimeInMillis(), false); - fullHistoryList.addAll(MainApp.getDbHelper().getPodHistoryFromTime(gc.getTimeInMillis(), true)); + fullHistoryList.addAll(databaseHelper.getAllOmnipodHistoryRecordsFromTimestamp(gc.getTimeInMillis(), true)); } @@ -83,8 +85,8 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { if (group == PumpHistoryEntryGroup.All) { this.filteredHistoryList.addAll(fullHistoryList); } else { - for (PodHistory pumpHistoryEntry : fullHistoryList) { - if (pumpHistoryEntry.getPodDbEntryType().getGroup() == group) { + for (OmnipodHistoryRecord pumpHistoryEntry : fullHistoryList) { + if (PodHistoryEntryType.getByCode(pumpHistoryEntry.getPodEntryTypeCode()).getGroup() == group) { this.filteredHistoryList.add(pumpHistoryEntry); } } @@ -207,14 +209,14 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { public class RecyclerViewAdapter extends RecyclerView.Adapter { - List historyList; + List historyList; - RecyclerViewAdapter(List historyList) { + RecyclerViewAdapter(List historyList) { this.historyList = historyList; } - public void setHistoryList(List historyList) { + public void setHistoryList(List historyList) { this.historyList = historyList; Collections.sort(this.historyList); } @@ -231,21 +233,22 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { @Override public void onBindViewHolder(@NotNull HistoryViewHolder holder, int position) { - PodHistory record = historyList.get(position); + OmnipodHistoryRecord record = historyList.get(position); if (record != null) { holder.timeView.setText(record.getDateTimeString()); - holder.typeView.setText(record.getPodDbEntryType().getResourceId()); + holder.typeView.setText(PodHistoryEntryType.getByCode(record.getPodEntryTypeCode()).getResourceId()); setValue(record, holder.valueView); } } - private void setValue(PodHistory historyEntry, TextView valueView) { + private void setValue(OmnipodHistoryRecord historyEntry, TextView valueView) { //valueView.setText(""); if (historyEntry.isSuccess()) { - switch (historyEntry.getPodDbEntryType()) { + PodHistoryEntryType entryType = PodHistoryEntryType.getByCode(historyEntry.getPodEntryTypeCode()); + switch (entryType) { case SetTemporaryBasal: { TempBasalPair tempBasalPair = omnipodUtil.getGsonInstance().fromJson(historyEntry.getData(), TempBasalPair.class); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt index b6e60a707f..f75ffc291d 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt @@ -8,7 +8,6 @@ import com.atech.android.library.wizardpager.WizardPagerContext import com.atech.android.library.wizardpager.data.WizardPagerSettings import com.atech.android.library.wizardpager.defs.WizardStepsWayType import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.interfaces.CommandQueueProvider @@ -16,6 +15,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData +import info.nightscout.androidaps.plugins.pump.omnipod.R import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType @@ -23,7 +23,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.Full import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.RemovePodWizardModel import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.ShortInitPodWizardModel import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction -import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil @@ -143,7 +142,6 @@ class PodManagementActivity : NoSplashAppCompatActivity() { OKDialog.showConfirmation(this, resourceHelper.gs(R.string.omnipod_cmd_reset_pod_desc), Thread { AapsOmnipodManager.getInstance().resetPodStatus() - omnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod) refreshButtons() }) } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java index 8dce02d7e0..192dde6c26 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java @@ -30,8 +30,8 @@ import javax.inject.Inject; import dagger.android.HasAndroidInjector; import dagger.android.support.DaggerFragment; -import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.plugins.pump.omnipod.R; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java index 8b34b99193..3ba9145749 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionPage.java @@ -14,7 +14,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; /** * Created by andy on 12/11/2019 - * + *

* This page is for InitPod and RemovePod, but Fragments called for this 2 actions are different */ public class InitActionPage extends Page { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java index a2e7383091..7c70f64c2c 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/FullInitPodWizardModel.java @@ -5,7 +5,7 @@ import android.content.Context; import com.atech.android.library.wizardpager.model.DisplayTextPage; import com.tech.freak.wizardpager.model.PageList; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.pump.omnipod.R; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitActionPage; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java index 1350ae1a49..c0088984b4 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/RemovePodWizardModel.java @@ -24,7 +24,7 @@ import com.atech.android.library.wizardpager.model.DisplayTextPage; import com.tech.freak.wizardpager.model.AbstractWizardModel; import com.tech.freak.wizardpager.model.PageList; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.pump.omnipod.R; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodInfoFragment; import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod.RemovePodActionPage; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java index 5499fdf8ec..51676a20a6 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/model/ShortInitPodWizardModel.java @@ -5,7 +5,7 @@ import android.content.Context; import com.atech.android.library.wizardpager.model.DisplayTextPage; import com.tech.freak.wizardpager.model.PageList; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.pump.omnipod.R; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitActionPage; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java index c6837f1644..cb7344daba 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java @@ -9,17 +9,15 @@ import org.json.JSONObject; import javax.inject.Inject; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.Source; +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity; import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState; -import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -32,11 +30,11 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish private PodManagementActivity podManagementActivity; private PodActionType actionType; - @Inject OmnipodUtil omnipodUtil; @Inject PodStateManager podStateManager; @Inject AAPSLogger aapsLogger; @Inject SP sp; @Inject NSUpload nsUpload; + @Inject DatabaseHelperInterface databaseHelper; public InitPodRefreshAction(HasAndroidInjector injector, PodManagementActivity podManagementActivity, PodActionType actionType) { injector.androidInjector().inject(this); @@ -60,21 +58,17 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish @Override public void execute() { if (actionType == PodActionType.InitPod) { - if (!podStateManager.isPodRunning()) { - omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodInitializing); - } else { - omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAttached); + if (podStateManager.isPodRunning()) { uploadCareportalEvent(System.currentTimeMillis(), CareportalEvent.SITECHANGE); } - } else { - omnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod); } + // TODO do this in PodManagerMentActivity itself by listening to OmnipodPumpValuesChanged events podManagementActivity.refreshButtons(); } private void uploadCareportalEvent(long date, String event) { - if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date) != null) + if (databaseHelper.getCareportalEventFromTimestamp(date) != null) return; try { JSONObject data = new JSONObject(); @@ -87,7 +81,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish careportalEvent.source = Source.USER; careportalEvent.eventType = event; careportalEvent.json = data.toString(); - MainApp.getDbHelper().createOrUpdate(careportalEvent); + databaseHelper.createOrUpdate(careportalEvent); nsUpload.uploadCareportalEntryToNS(data); } catch (JSONException e) { aapsLogger.error(LTag.PUMPCOMM, "Unhandled exception when uploading SiteChange event.", e); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java index 128211c6fd..0d4f3c52c6 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/PodInfoFragment.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import javax.inject.Inject; import dagger.android.support.DaggerFragment; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.pump.omnipod.R; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java index 7f5b2b8503..444c8a4b11 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/removepod/RemovePodActionPage.java @@ -11,7 +11,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.In /** * Created by andy on 12/11/2019 - * */ public class RemovePodActionPage extends InitActionPage { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodDriverState.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodDriverState.java deleted file mode 100644 index daa51b3685..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodDriverState.java +++ /dev/null @@ -1,11 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.driver; - -// TODO replace with method calls on PodStateManager -public enum OmnipodDriverState { - - NotInitalized, // when we start - Initalized_NoPod, // driver is initalized, but there is no pod - Initalized_PodInitializing, // driver is initalized, pod is initalizing - Initalized_PodAttached, // driver is initalized, pod is there - -} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java index 0e1ab17b05..c7d9f24da1 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java @@ -15,7 +15,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; -import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; /** @@ -27,7 +26,6 @@ public class OmnipodPumpStatus extends PumpStatus { // TODO remove all fields that can also be obtained via PodStateManager // We can probably get rid of this class altogether - private final ResourceHelper resourceHelper; private final SP sp; private final RileyLinkUtil rileyLinkUtil; private final RxBusWrapper rxBus; @@ -47,9 +45,6 @@ public class OmnipodPumpStatus extends PumpStatus { public String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}"; - public boolean ackAlertsAvailable = false; - public String ackAlertsText = null; - public boolean beepBolusEnabled = true; public boolean beepBasalEnabled = true; public boolean beepSMBEnabled = true; @@ -57,16 +52,13 @@ public class OmnipodPumpStatus extends PumpStatus { public boolean podDebuggingOptionsEnabled = false; public boolean timeChangeEventEnabled = true; - public OmnipodDriverState driverState = OmnipodDriverState.NotInitalized; private PumpDeviceState pumpDeviceState; @Inject - public OmnipodPumpStatus(ResourceHelper resourceHelper, - info.nightscout.androidaps.utils.sharedPreferences.SP sp, + public OmnipodPumpStatus(SP sp, RxBusWrapper rxBus, RileyLinkUtil rileyLinkUtil) { super(PumpType.Insulet_Omnipod); - this.resourceHelper = resourceHelper; this.sp = sp; this.rxBus = rxBus; this.rileyLinkUtil = rileyLinkUtil; @@ -139,7 +131,6 @@ public class OmnipodPumpStatus extends PumpStatus { "rileyLinkErrorDescription='" + rileyLinkErrorDescription + '\'' + ", rileyLinkAddress='" + rileyLinkAddress + '\'' + ", inPreInit=" + inPreInit + - ", currentBasal=" + currentBasal + ", tempBasalStart=" + tempBasalStart + ", tempBasalEnd=" + tempBasalEnd + ", tempBasalAmount=" + tempBasalAmount + diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java index c9725df95a..61c6bb9299 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java @@ -11,16 +11,16 @@ import java.util.Date; import java.util.List; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; import info.nightscout.androidaps.activities.ErrorHelperActivity; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.db.OmnipodHistoryRecord; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.interfaces.ActivePluginProvider; +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; @@ -33,6 +33,7 @@ import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair; import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; +import info.nightscout.androidaps.plugins.pump.omnipod.R; import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager; import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager; import info.nightscout.androidaps.plugins.pump.omnipod.comm.SetupActionResult; @@ -65,7 +66,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedu import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalScheduleEntry; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistory; import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistoryEntryType; import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; @@ -90,6 +90,7 @@ public class AapsOmnipodManager implements IOmnipodManager { //TODO: remove and use injection private static AapsOmnipodManager instance; + private DatabaseHelperInterface databaseHelper; public static AapsOmnipodManager getInstance() { return instance; @@ -105,7 +106,8 @@ public class AapsOmnipodManager implements IOmnipodManager { ResourceHelper resourceHelper, HasAndroidInjector injector, ActivePluginProvider activePlugin, - Context context) { + Context context, + DatabaseHelperInterface databaseHelper) { if (podStateManager == null) { throw new IllegalArgumentException("Pod state manager can not be null"); } @@ -118,6 +120,7 @@ public class AapsOmnipodManager implements IOmnipodManager { this.activePlugin = activePlugin; this.pumpStatus = pumpStatus; this.context = context; + this.databaseHelper = databaseHelper; delegate = new OmnipodManager(aapsLogger, sp, communicationService, podStateManager); instance = this; @@ -287,7 +290,7 @@ public class AapsOmnipodManager implements IOmnipodManager { activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false); if (podStateManager.hasFaultEvent()) { - showPodFaultErrorDialog(podStateManager.getFaultEvent().getFaultEventCode(), R.raw.urgentalarm); + showPodFaultErrorDialog(podStateManager.getFaultEvent().getFaultEventCode()); } return new PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(unitsDelivered); @@ -493,22 +496,22 @@ public class AapsOmnipodManager implements IOmnipodManager { } private long addToHistory(long requestTime, PodHistoryEntryType entryType, Object data, boolean success) { - PodHistory podHistory = new PodHistory(requestTime, entryType); + OmnipodHistoryRecord omnipodHistoryRecord = new OmnipodHistoryRecord(requestTime, entryType.getCode()); if (data != null) { if (data instanceof String) { - podHistory.setData((String) data); + omnipodHistoryRecord.setData((String) data); } else { - podHistory.setData(omnipodUtil.getGsonInstance().toJson(data)); + omnipodHistoryRecord.setData(omnipodUtil.getGsonInstance().toJson(data)); } } - podHistory.setSuccess(success); - podHistory.setPodSerial(podStateManager.hasPodState() ? String.valueOf(podStateManager.getAddress()) : "None"); + omnipodHistoryRecord.setSuccess(success); + omnipodHistoryRecord.setPodSerial(podStateManager.hasPodState() ? String.valueOf(podStateManager.getAddress()) : "None"); - MainApp.getDbHelper().createOrUpdate(podHistory); + databaseHelper.createOrUpdate(omnipodHistoryRecord); - return podHistory.getPumpId(); + return omnipodHistoryRecord.getPumpId(); } private void handleSetupActionResult(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, SetupActionResult res, long time, Profile profile) { @@ -571,7 +574,7 @@ public class AapsOmnipodManager implements IOmnipodManager { comment = getStringResource(R.string.omnipod_driver_error_not_enough_data); } else if (ex instanceof PodFaultException) { FaultEventCode faultEventCode = ((PodFaultException) ex).getFaultEvent().getFaultEventCode(); - showPodFaultErrorDialog(faultEventCode, R.raw.urgentalarm); + showPodFaultErrorDialog(faultEventCode); comment = createPodFaultErrorMessage(faultEventCode); } else if (ex instanceof PodReturnedErrorResponseException) { comment = getStringResource(R.string.omnipod_driver_error_pod_returned_error_response); @@ -599,13 +602,21 @@ public class AapsOmnipodManager implements IOmnipodManager { rxBus.send(event); } + private void showPodFaultErrorDialog(FaultEventCode faultEventCode) { + showErrorDialog(createPodFaultErrorMessage(faultEventCode), null); + } + private void showPodFaultErrorDialog(FaultEventCode faultEventCode, Integer sound) { showErrorDialog(createPodFaultErrorMessage(faultEventCode), sound); } + private void showErrorDialog(String message) { + showErrorDialog(message, null); + } + private void showErrorDialog(String message, Integer sound) { Intent intent = new Intent(context, ErrorHelperActivity.class); - intent.putExtra("soundid", sound == null ? 0 : sound); + intent.putExtra("soundid", sound); intent.putExtra("status", message); intent.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java index 981796b497..351a845e8d 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/db/PodHistoryEntryType.java @@ -5,8 +5,8 @@ import androidx.annotation.StringRes; import java.util.HashMap; import java.util.Map; -import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup; +import info.nightscout.androidaps.plugins.pump.omnipod.R; /** * Created by andy on 24.11.2019 @@ -37,8 +37,7 @@ public enum PodHistoryEntryType { SuspendDelivery(60, R.string.omnipod_cmd_suspend_delivery, PumpHistoryEntryGroup.Basal), ResumeDelivery(61, R.string.omnipod_cmd_resume_delivery, PumpHistoryEntryGroup.Basal), - UnknownEntryType(99, R.string.omnipod_cmd_unknown_entry) - ; + UnknownEntryType(99, R.string.omnipod_cmd_unknown_entry); private int code; private static Map instanceMap; @@ -48,7 +47,6 @@ public enum PodHistoryEntryType { private PumpHistoryEntryGroup group; - static { instanceMap = new HashMap<>(); @@ -57,7 +55,6 @@ public enum PodHistoryEntryType { } } - PodHistoryEntryType(int code, @StringRes int resourceId) { this.code = code; this.resourceId = resourceId; @@ -77,6 +74,9 @@ public enum PodHistoryEntryType { return this.group; } + public static PodHistoryEntryType getByCode(long code) { + return getByCode((int) code); + } public static PodHistoryEntryType getByCode(int code) { if (instanceMap.containsKey(code)) { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java index cf14405dcc..33d734bdde 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIPostprocessor.java @@ -1,8 +1,5 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.ui; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.Date; import javax.inject.Inject; @@ -10,10 +7,8 @@ import javax.inject.Singleton; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; /** @@ -22,19 +17,13 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; // TODO remove once OmnipodPumpStatus has been removed @Singleton public class OmnipodUIPostprocessor { - - - private static final Logger LOG = LoggerFactory.getLogger(LTag.PUMP.name()); - - private OmnipodPumpStatus pumpStatus; - private OmnipodPumpPluginInterface omnipodPumpPlugin; - private RxBusWrapper rxBus; + private final AAPSLogger aapsLogger; + private final OmnipodPumpStatus pumpStatus; @Inject - public OmnipodUIPostprocessor(OmnipodPumpPlugin plugin, OmnipodPumpStatus pumpStatus) { + public OmnipodUIPostprocessor(AAPSLogger aapsLogger, OmnipodPumpStatus pumpStatus) { + this.aapsLogger = aapsLogger; this.pumpStatus = pumpStatus; - this.omnipodPumpPlugin = plugin; - this.rxBus = plugin.getRxBus(); } // this is mostly intended for command that return certain statuses (Remaining Insulin, ...), and @@ -42,8 +31,7 @@ public class OmnipodUIPostprocessor { public void postProcessData(OmnipodUITask uiTask) { switch (uiTask.commandType) { - - case SetBolus: { + case SetBolus: if (uiTask.returnData != null) { PumpEnactResult result = uiTask.returnData; @@ -59,57 +47,18 @@ public class OmnipodUIPostprocessor { } } } - } - break; + break; - case CancelTemporaryBasal: { + case CancelTemporaryBasal: pumpStatus.tempBasalStart = 0; pumpStatus.tempBasalEnd = 0; pumpStatus.tempBasalAmount = null; pumpStatus.tempBasalLength = null; - } - break; - -// case PairAndPrimePod: { -// if (uiTask.returnData.success) { -// omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.PairAndPrime, false); -// omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.FillCanulaSetBasalProfile, true); -// } -// omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.DeactivatePod, true); -// } -// break; -// -// case FillCanulaAndSetBasalProfile: { -// if (uiTask.returnData.success) { -// omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.FillCanulaSetBasalProfile, false); -// } -// omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.DeactivatePod, true); -// } -// break; -// -// case DeactivatePod: -// case ResetPodStatus: { -// omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.PairAndPrime, true); -// omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.DeactivatePod, false); -// } -// break; - + break; default: - if (isLogEnabled()) - LOG.trace("Post-processing not implemented for {}.", uiTask.commandType.name()); + aapsLogger.debug(LTag.PUMP, "Post-processing not implemented for {}.", uiTask.commandType.name()); } - - - } - - - private boolean isLogEnabled() { - return true; //L.isEnabled(LTag.PUMP); - } - - public RxBusWrapper getRxBus() { - return this.rxBus; } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt index 8bbbfd33e6..9ad6f2129e 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodRefreshButtonState.kt @@ -2,4 +2,4 @@ package info.nightscout.androidaps.plugins.pump.omnipod.events import info.nightscout.androidaps.events.Event -class EventOmnipodRefreshButtonState (val newState : Boolean): Event() \ No newline at end of file +class EventOmnipodRefreshButtonState(val newState: Boolean) : Event() \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java index 73209ce876..5879bcdb0f 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java @@ -9,7 +9,6 @@ import org.apache.commons.lang3.StringUtils; import javax.inject.Inject; -import info.nightscout.androidaps.R; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager; @@ -21,6 +20,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.Rile import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService; import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin; +import info.nightscout.androidaps.plugins.pump.omnipod.R; 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.driver.OmnipodPumpStatus; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java index ba5c91c0b5..77d0cc1aad 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmniCRC.java @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.util; public class OmniCRC { - public static final int[] crc16lookup = new int[] { + public static final int[] crc16lookup = new int[]{ 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java index 35889383c2..256a186714 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.util; import org.joda.time.Duration; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.pump.omnipod.R; /** * Created by andy on 4.8.2019 diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java index 599deb8197..ddc0022372 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java @@ -16,16 +16,12 @@ import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.logging.AAPSLogger; +import info.nightscout.androidaps.plugins.pump.omnipod.R; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSlot; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; import info.nightscout.androidaps.utils.resources.ResourceHelper; -import info.nightscout.androidaps.utils.sharedPreferences.SP; /** * Created by andy on 4/8/19. @@ -33,39 +29,15 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; @Singleton public class OmnipodUtil { - private final AAPSLogger aapsLogger; - private final OmnipodPumpStatus omnipodPumpStatus; private final ResourceHelper resourceHelper; - private final SP sp; private Gson gsonInstance = createGson(); - private OmnipodDriverState driverState = OmnipodDriverState.NotInitalized; @Inject - public OmnipodUtil( - AAPSLogger aapsLogger, - OmnipodPumpStatus omnipodPumpStatus, - SP sp, - ResourceHelper resourceHelper - ) { - this.aapsLogger = aapsLogger; - this.omnipodPumpStatus = omnipodPumpStatus; - this.sp = sp; + public OmnipodUtil(ResourceHelper resourceHelper) { this.resourceHelper = resourceHelper; } - public OmnipodDriverState getDriverState() { - return driverState; - } - - public void setDriverState(OmnipodDriverState state) { - if (driverState == state) - return; - - driverState = state; - omnipodPumpStatus.driverState = state; - } - private Gson createGson() { GsonBuilder gsonBuilder = new GsonBuilder() .registerTypeAdapter(DateTime.class, (JsonSerializer) (dateTime, typeOfSrc, context) -> @@ -84,14 +56,6 @@ public class OmnipodUtil { return this.gsonInstance; } - public AAPSLogger getAapsLogger() { - return this.aapsLogger; - } - - public SP getSp() { - return this.sp; - } - public List getTranslatedActiveAlerts(PodStateManager podStateManager) { List translatedAlerts = new ArrayList<>(); AlertSet activeAlerts = podStateManager.getActiveAlerts(); diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index dc99fdd0ae..1a74c2b64d 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -55,7 +55,6 @@ Operation is not possible.\n\n You need to wait few minutes, until AAPS tries to set profile for first time. Illegal PodInitActionType: %1$s No active pod. - Command verification failed. An unexpected error occurred. Please report! (type: %1$s). Communication failed: received invalid input parameters. @@ -80,7 +79,6 @@ Deactivate Pod Reset Pod Pod History - Set Bolus Cancel Bolus Set Temporary Basal @@ -95,19 +93,11 @@ Suspend Delivery Resume Delivery Unknown Entry - %1$.1f U %1$.1f U, CH=%2$.1f g Rate: %1$.1f U, Duration: %2$d min - If you press OK, the Pod state will be forcibly reset and you will not be able to communicate with the Pod anymore. Do this only if you can not communicate with the Pod anymore. If you can still communicate with the Pod, please use the Deactivate Pod option. Pod History not available at the moment. - - Omnipod - Omnipod - Omnipod - - Fill the Pod \nFill the new Pod with enough insulin for 3 days.\n\nListen for two beeps from the Pod during the filling process. These indicate that the minimum amount of 85U has been inserted. Be sure to completely empty the fill syringe, even after hearing the two beeps.\n\nAfter filling the Pod, please press Next.\n\nNote: do not remove the Pod\'s needle cap at this time. Priming @@ -116,17 +106,13 @@ \nPrepare the infusion site. Remove the Pod\'s needle cap and adhesive backing and attach the Pod to the infusion site.\n\nIf the cannula sticks out, please press Cancel and discard your Pod.\n\nPress Next to insert the cannula and begin basal delivery. Inserting cannula Trying to set initial basal schedule and insert the cannula.\n\nWhen all items are checked, you can press Next. - Pod Info \nThe Pod is now active.\n\nYour basal schedule has been programmed and the cannula has been inserted.\n\nPlease verify that the cannula has been inserted correctly and replace your Pod if you feel hasn\'t. - Deactivate Pod \nPress Next to deactivate the Pod.\n\nNote: This will suspend all insulin delivery and deactivate the Pod. Deactivating the Pod Deactivating the Pod.\n\nWhen all items are checked, you can press Next.\n\nNote: If deactivating continuously fails, please press Cancel and use the Reset Pod option to forcibly reset the Pod state. - Pod deactivated.\n\nPlease remove the Pod from your body and discard it. - Pair Pod Prime Pod Fill Cannula @@ -134,7 +120,6 @@ Cancel Delivery Deactivate Pod - Omnipod Dash DASH @@ -156,4 +141,7 @@ TID PM / PI version Errors + Basal profile is the same, so it will not be set again. + Reset RileyLink Config + \ No newline at end of file From 18a515e5f7dbfa7d38e07e82cf366eb1856a8f1a Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 17 Aug 2020 19:55:19 +0200 Subject: [PATCH 05/40] Removed redundant method on OmnipodPumpPlugin --- .../androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index f7dfe16e99..466c9c62f4 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -929,11 +929,4 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return false; } - - @Override - public RxBusWrapper getRxBus() { - return this.rxBus; - } - - } From 7b9cbe7497a58a86eda7b9bbeec0796b35103d15 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 17 Aug 2020 22:00:56 +0200 Subject: [PATCH 06/40] Restore RL history for Omnipod --- .../data/dto/RLHistoryItemMedtronic.java | 23 +++------- .../omnipod/data/RLHistoryItemOmnipod.java | 18 ++------ .../pump/omnipod/driver/ui/OmnipodUIComm.java | 35 ++++----------- .../service/RileyLinkOmnipodService.java | 18 +++----- .../hw/rileylink/data/RLHistoryItem.java | 43 +------------------ 5 files changed, 23 insertions(+), 114 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/RLHistoryItemMedtronic.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/RLHistoryItemMedtronic.java index 399f58e8ac..b19335964f 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/RLHistoryItemMedtronic.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/RLHistoryItemMedtronic.java @@ -3,8 +3,6 @@ package info.nightscout.androidaps.plugins.pump.medtronic.data.dto; import org.joda.time.LocalDateTime; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -18,24 +16,13 @@ public class RLHistoryItemMedtronic extends RLHistoryItem { this.medtronicCommandType = medtronicCommandType; } + @Override public String getDescription(ResourceHelper resourceHelper) { - - switch (this.source) { - case RileyLink: - return "State: " + resourceHelper.gs(serviceState.getResourceId(targetDevice)) - + (this.errorCode == null ? "" : ", Error Code: " + errorCode); - - case MedtronicPump: - return resourceHelper.gs(pumpDeviceState.getResourceId()); - - case MedtronicCommand: - return medtronicCommandType.name(); - - default: - return "Unknown Description"; + if (RLHistoryItemSource.MedtronicCommand.equals(source)) { + return medtronicCommandType.name(); } + + return super.getDescription(resourceHelper); } - - } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java index c85c28d253..ace31f26d8 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/data/RLHistoryItemOmnipod.java @@ -16,22 +16,12 @@ public class RLHistoryItemOmnipod extends RLHistoryItem { this.omnipodCommandType = omnipodCommandType; } + @Override public String getDescription(ResourceHelper resourceHelper) { - - switch (this.source) { - case RileyLink: - return "State: " + resourceHelper.gs(serviceState.getResourceId(targetDevice)) - + (this.errorCode == null ? "" : ", Error Code: " + errorCode); - - case MedtronicPump: - return resourceHelper.gs(pumpDeviceState.getResourceId()); - - case OmnipodCommand: - return omnipodCommandType.name(); - - default: - return "Unknown Description"; + if (RLHistoryItemSource.OmnipodCommand.equals(source)) { + return omnipodCommandType.name(); } + return super.getDescription(resourceHelper); } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java index fabd71b08d..d39559e4b5 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/ui/OmnipodUIComm.java @@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.ui; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; +import info.nightscout.androidaps.plugins.pump.omnipod.data.RLHistoryItemOmnipod; import info.nightscout.androidaps.plugins.pump.omnipod.defs.IOmnipodManager; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType; @@ -13,19 +15,22 @@ public class OmnipodUIComm { private final HasAndroidInjector injector; private final AAPSLogger aapsLogger; - private final IOmnipodManager omnipodCommunicationManager; private final OmnipodUIPostprocessor omnipodUIPostprocessor; + private final IOmnipodManager omnipodCommunicationManager; + private RileyLinkUtil rileyLinkUtil; public OmnipodUIComm( HasAndroidInjector injector, AAPSLogger aapsLogger, OmnipodUIPostprocessor omnipodUIPostprocessor, - IOmnipodManager omnipodCommunicationManager + IOmnipodManager omnipodCommunicationManager, + RileyLinkUtil rileyLinkUtil ) { this.injector = injector; this.aapsLogger = aapsLogger; this.omnipodUIPostprocessor = omnipodUIPostprocessor; this.omnipodCommunicationManager = omnipodCommunicationManager; + this.rileyLinkUtil = rileyLinkUtil; } @@ -35,34 +40,10 @@ public class OmnipodUIComm { OmnipodUITask task = new OmnipodUITask(injector, commandType, parameters); - // new Thread(() -> { - // LOG.warn("@@@ Start Thread"); - // - // task.execute(getCommunicationManager()); - // - // LOG.warn("@@@ End Thread"); - // }); + rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItemOmnipod(commandType)); task.execute(this.omnipodCommunicationManager); - // for (int i = 0; i < getMaxWaitTime(commandType); i++) { - // synchronized (task) { - // // try { - // // - // // //task.wait(1000); - // // } catch (InterruptedException e) { - // // LOG.error("executeCommand InterruptedException", e); - // // } - // - // - // SystemClock.sleep(1000); - // } - // - // if (task.isReceived()) { - // break; - // } - // } - if (!task.isReceived()) { aapsLogger.warn(LTag.PUMP, "Reply not received for " + commandType); } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java index 5879bcdb0f..1d26f9330a 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java @@ -9,6 +9,7 @@ import org.apache.commons.lang3.StringUtils; import javax.inject.Inject; +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager; @@ -43,6 +44,7 @@ public class RileyLinkOmnipodService extends RileyLinkService { @Inject OmnipodUtil omnipodUtil; @Inject OmnipodUIPostprocessor omnipodUIPostprocessor; @Inject PodStateManager podStateManager; + @Inject DatabaseHelperInterface databaseHelper; private static RileyLinkOmnipodService instance; @@ -70,22 +72,20 @@ public class RileyLinkOmnipodService extends RileyLinkService { super.onConfigurationChanged(newConfig); } - @Override public IBinder onBind(Intent intent) { return mBinder; } - @Override public RileyLinkEncodingType getEncoding() { return RileyLinkEncodingType.Manchester; } - /** * If you have customized RileyLinkServiceData you need to override this */ + @Override public void initRileyLinkServiceData() { rileyLinkServiceData.targetDevice = RileyLinkTargetDevice.Omnipod; @@ -111,7 +111,7 @@ public class RileyLinkOmnipodService extends RileyLinkService { this.omnipodCommunicationManager = omnipodCommunicationService; aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podStateManager, omnipodPumpStatus, - omnipodUtil, aapsLogger, rxBus, sp, resourceHelper, injector, activePlugin, this); + omnipodUtil, aapsLogger, rxBus, sp, resourceHelper, injector, activePlugin, this, databaseHelper); omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager); @@ -121,7 +121,6 @@ public class RileyLinkOmnipodService extends RileyLinkService { rxBus.send(new EventOmnipodPumpValuesChanged()); } - public OmnipodUIComm getDeviceCommandExecutor() { return this.omnipodUIComm; } @@ -130,7 +129,6 @@ public class RileyLinkOmnipodService extends RileyLinkService { rfspy.resetRileyLinkConfiguration(); } - @Override public RileyLinkCommunicationManager getDeviceCommunicationManager() { return omnipodCommunicationManager; @@ -141,15 +139,12 @@ public class RileyLinkOmnipodService extends RileyLinkService { this.omnipodPumpStatus.setPumpDeviceState(pumpDeviceState); } - public class LocalBinder extends Binder { - public RileyLinkOmnipodService getServiceInstance() { return RileyLinkOmnipodService.this; } } - /* private functions */ // PumpInterface - REMOVE @@ -158,7 +153,7 @@ public class RileyLinkOmnipodService extends RileyLinkService { return rileyLinkServiceData.rileyLinkServiceState.isReady(); } - + @Override public boolean verifyConfiguration() { try { omnipodPumpStatus.rileyLinkErrorDescription = null; @@ -202,11 +197,8 @@ public class RileyLinkOmnipodService extends RileyLinkService { } } - private boolean reconfigureService() { - if (!inPreInit) { - if (rileyLinkAddressChanged) { rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this); rileyLinkAddressChanged = false; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/data/RLHistoryItem.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/data/RLHistoryItem.java index c845a3afe2..b72537d004 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/data/RLHistoryItem.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/data/RLHistoryItem.java @@ -2,17 +2,11 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data; import org.joda.time.LocalDateTime; - - - import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; -//import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType; -//import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState; import info.nightscout.androidaps.utils.resources.ResourceHelper; -//import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType; /** @@ -21,7 +15,6 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper; public class RLHistoryItem { - //private MedtronicCommandType medtronicCommandType; protected LocalDateTime dateTime; protected RLHistoryItemSource source; protected RileyLinkServiceState serviceState; @@ -29,9 +22,8 @@ public class RLHistoryItem { protected RileyLinkTargetDevice targetDevice; protected PumpDeviceState pumpDeviceState; - //private OmnipodCommandType omnipodCommandType; - public RLHistoryItem(LocalDateTime dateTime, RLHistoryItemSource source, RileyLinkTargetDevice targetDevice) { + public RLHistoryItem(LocalDateTime dateTime, RLHistoryItemSource source, RileyLinkTargetDevice targetDevice) { this.dateTime = dateTime; this.source = source; this.targetDevice = targetDevice; @@ -46,7 +38,6 @@ public class RLHistoryItem { this.source = RLHistoryItemSource.RileyLink; } - public RLHistoryItem(PumpDeviceState pumpDeviceState, RileyLinkTargetDevice targetDevice) { this.pumpDeviceState = pumpDeviceState; this.dateTime = new LocalDateTime(); @@ -54,64 +45,34 @@ public class RLHistoryItem { this.source = RLHistoryItemSource.MedtronicPump; } - -// public RLHistoryItem(MedtronicCommandType medtronicCommandType) { -// this.dateTime = new LocalDateTime(); -// this.medtronicCommandType = medtronicCommandType; -// source = RLHistoryItemSource.MedtronicCommand; -// } -// -// -// public RLHistoryItem(OmnipodCommandType omnipodCommandType) { -// this.dateTime = new LocalDateTime(); -// this.omnipodCommandType = omnipodCommandType; -// source = RLHistoryItemSource.OmnipodCommand; -// } - - public LocalDateTime getDateTime() { return dateTime; } - public RileyLinkServiceState getServiceState() { return serviceState; } - public RileyLinkError getErrorCode() { return errorCode; } - public String getDescription(ResourceHelper resourceHelper) { - - // TODO extend when we have Omnipod switch (this.source) { case RileyLink: return "State: " + resourceHelper.gs(serviceState.getResourceId(targetDevice)) + (this.errorCode == null ? "" : ", Error Code: " + errorCode); - case MedtronicPump: return resourceHelper.gs(pumpDeviceState.getResourceId()); - -// case MedtronicCommand: -// return medtronicCommandType.name(); -// -// case OmnipodCommand: -// return omnipodCommandType.name(); - default: return "Unknown Description"; } } - public RLHistoryItemSource getSource() { return source; } - public PumpDeviceState getPumpDeviceState() { return pumpDeviceState; } @@ -129,14 +90,12 @@ public class RLHistoryItem { this.desc = desc; } - public String getDesc() { return desc; } } public static class Comparator implements java.util.Comparator { - @Override public int compare(RLHistoryItem o1, RLHistoryItem o2) { return o2.dateTime.compareTo(o1.getDateTime()); From fb95f267e8b2d7436cb02b75e0b50d0e9b66de39 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 17 Aug 2020 22:22:15 +0200 Subject: [PATCH 07/40] Use updated constructor in RileyLinkOmnipodService --- .../plugins/pump/omnipod/service/RileyLinkOmnipodService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java index 1d26f9330a..49c629b84e 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java @@ -113,7 +113,7 @@ public class RileyLinkOmnipodService extends RileyLinkService { aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podStateManager, omnipodPumpStatus, omnipodUtil, aapsLogger, rxBus, sp, resourceHelper, injector, activePlugin, this, databaseHelper); - omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager); + omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager, rileyLinkUtil); } else { aapsOmnipodManager = instance; From 8452840cfd155043d3d113d114c222d68c1cb280 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 17 Aug 2020 22:39:44 +0200 Subject: [PATCH 08/40] Fix missing string resources in Omnipod module --- app/src/main/res/values/strings.xml | 1 - .../androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java | 4 ++-- .../plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java | 2 +- omnipod/src/main/res/values/strings.xml | 1 + 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 19d8c7966b..a6c4e65831 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1284,7 +1284,6 @@ Clear finished Clear started Do you want reset objective start? You may lose your progress. - Time and/or Timezone change on pump No pump selected Select units you want to display values in Upload local profile changes to NS diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 466c9c62f4..5f29613719 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -470,7 +470,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump Intent i = new Intent(context, ErrorHelperActivity.class); i.putExtra("soundid", 0); i.putExtra("status", "Pulse Log (copied to clipboard):\n" + result.toString()); - i.putExtra("title", resourceHelper.gs(R.string.combo_warning)); + i.putExtra("title", resourceHelper.gs(R.string.omnipod_warning)); i.putExtra("clipboardContent", result.toString()); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); @@ -496,7 +496,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump Notification notification = new Notification( Notification.TIME_OR_TIMEZONE_CHANGE, - resourceHelper.gs(R.string.time_or_timezone_change), + resourceHelper.gs(R.string.omnipod_time_or_timezone_change), Notification.INFO, 60); rxBus.send(new EventNewNotification(notification)); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java index 61c6bb9299..153af29008 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java @@ -618,7 +618,7 @@ public class AapsOmnipodManager implements IOmnipodManager { Intent intent = new Intent(context, ErrorHelperActivity.class); intent.putExtra("soundid", sound); intent.putExtra("status", message); - intent.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror)); + intent.putExtra("title", resourceHelper.gs(R.string.error)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index 1a74c2b64d..39fa580849 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -143,5 +143,6 @@ Errors Basal profile is the same, so it will not be set again. Reset RileyLink Config + Time and/or Timezone change on pump \ No newline at end of file From 6442271320a681241c8f9e66534ead11715432ec Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 17 Aug 2020 22:40:17 +0200 Subject: [PATCH 09/40] Make OmnipodConst inner classes static --- .../androidaps/plugins/pump/omnipod/util/OmnipodConst.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java index 256a186714..3f2aa3afca 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java @@ -12,7 +12,7 @@ public class OmnipodConst { static final String Prefix = "AAPS.Omnipod."; - public class Prefs { + public static class Prefs { public static final String PodState = Prefix + "pod_state"; public static final int BeepBasalEnabled = R.string.key_omnipod_beep_basal_enabled; public static final int BeepBolusEnabled = R.string.key_omnipod_beep_bolus_enabled; @@ -22,7 +22,7 @@ public class OmnipodConst { public static final int TimeChangeEventEnabled = R.string.key_omnipod_timechange_enabled; } - public class Statistics { + public static class Statistics { public static final String StatsPrefix = "omnipod_"; public static final String FirstPumpStart = Prefix + "first_pump_use"; public static final String LastGoodPumpCommunicationTime = Prefix + "lastGoodPumpCommunicationTime"; From 2b10524217e9adbce1337a2265391214ca5fafcf Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 17 Aug 2020 22:56:01 +0200 Subject: [PATCH 10/40] Restore Omnipod wizard dependency in app/build.gradle --- app/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 1ba6eed95e..4ce21e51c3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -281,6 +281,8 @@ dependencies { implementation "com.jjoe64:graphview:4.0.1" implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2" implementation 'com.madgag.spongycastle:core:1.58.0.0' + // Omnipod wizard + implementation(name: "com.atech-software.android.library.wizardpager-1.1.4", ext: "aar") implementation("com.google.android:flexbox:0.3.0") { exclude group: "com.android.support" } From 02e818c92d66b56a0dc602075cf1c7bc62c90ec9 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 17 Aug 2020 23:46:55 +0200 Subject: [PATCH 11/40] Restore Omnipod firebase event --- omnipod/build.gradle | 4 ++++ .../plugins/pump/omnipod/OmnipodPumpPlugin.java | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/omnipod/build.gradle b/omnipod/build.gradle index a8320d0571..e3b599e52b 100644 --- a/omnipod/build.gradle +++ b/omnipod/build.gradle @@ -15,6 +15,8 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles 'consumer-rules.pro' + // OMNIPOD: for usage in Firebase event during testing phase + buildConfigField "String", "VERSION", '"2.7-omnipod-0.4.1-SNAPSHOT"' // OMNIPOD: Keep track of what commit from the main repository we're on, these fields aren't actually used anywhere buildConfigField "String", "DEV_VERSION", '"2.6.7-dev"' buildConfigField "String", "DEV_VERSION_COMMIT", '"65c8cc98804cfc366239ad2bedb2dd98e3e4f3c2"' @@ -71,6 +73,8 @@ dependencies { implementation "androidx.activity:activity-ktx:${activityVersion}" implementation 'com.google.android.material:material:1.1.0' + implementation 'com.google.firebase:firebase-analytics-ktx:17.4.3' + implementation "io.reactivex.rxjava2:rxandroid:${rxandroid_version}" // Graphview cannot be upgraded diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 5f29613719..6f7ccba6e2 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -4,6 +4,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; +import android.os.Bundle; import android.os.IBinder; import android.os.SystemClock; @@ -105,6 +106,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump private int timeChangeRetries = 0; private Profile currentProfile; private long nextPodCheck = 0L; + private boolean sentIdToFirebase; @Inject public OmnipodPumpPlugin( @@ -561,6 +563,15 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump finishAction("Omnipod Pump"); + if (!sentIdToFirebase) { + Bundle params = new Bundle(); + params.putString("version", BuildConfig.VERSION); + + getFabricPrivacy().getFirebaseAnalytics().logEvent("OmnipodPumpInit", params); + + sentIdToFirebase = true; + } + isInitialized = true; this.firstRun = false; From 8c5683faaa5fe8b715d6bc96c1c02f3d154aeaf2 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 17 Aug 2020 23:57:24 +0200 Subject: [PATCH 12/40] Improve readable durations in Omnipod fragment --- .../plugins/pump/omnipod/OmnipodFragment.kt | 30 ++++++++++++++----- omnipod/src/main/res/values/strings.xml | 16 +++++++++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt index f35de6426d..5a0b67bee9 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt @@ -358,19 +358,33 @@ class OmnipodFragment : DaggerFragment() { } private fun readableDuration(dateTime: DateTime): String { - val minutes = Duration(dateTime, DateTime.now()).standardMinutes + val minutes = Duration(dateTime, DateTime.now()).standardMinutes.toInt() when { - minutes == 0L -> { - return resourceHelper.gs(R.string.omnipod_connected_now) + minutes == 0 -> { + return resourceHelper.gs(R.string.omnipod_moments_ago) } - minutes < 60 -> { - return resourceHelper.gs(R.string.minago, minutes) + minutes < 60 -> { + return resourceHelper.gs(R.string.omnipod_time_ago, resourceHelper.gq(R.plurals.omnipod_minutes, minutes, minutes)) } - else -> { - val hours = (minutes / 60).toInt() - return resourceHelper.gs(R.string.hoursago, hours) + minutes < 1440 -> { + val hours = minutes / 60 + val minutesLeft = minutes % 60 + if (minutesLeft > 0) + return resourceHelper.gs(R.string.omnipod_time_ago, + resourceHelper.gs(R.string.omnipod_composite_time, resourceHelper.gq(R.plurals.omnipod_hours, hours, hours), resourceHelper.gq(R.plurals.omnipod_minutes, minutesLeft, minutesLeft))) + return resourceHelper.gs(R.string.omnipod_time_ago, resourceHelper.gq(R.plurals.omnipod_hours, hours, hours)) + } + + else -> { + val hours = minutes / 60 + val days = hours / 24 + val hoursLeft = hours % 24 + if (hoursLeft > 0) + return resourceHelper.gs(R.string.omnipod_time_ago, + resourceHelper.gs(R.string.omnipod_composite_time, resourceHelper.gq(R.plurals.omnipod_days, days, days), resourceHelper.gq(R.plurals.omnipod_hours, hoursLeft, hoursLeft))) + return resourceHelper.gs(R.string.omnipod_time_ago, resourceHelper.gq(R.plurals.omnipod_days, days, days)) } } } diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index 39fa580849..925ee0069f 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -23,7 +23,7 @@ DST/Timezone Detection Enabled - Now + Moments ago Pod Mgmt Pod Status %1$.2f U left @@ -144,5 +144,19 @@ Basal profile is the same, so it will not be set again. Reset RileyLink Config Time and/or Timezone change on pump + %1$s and %2$s + %1$s ago + + %1$d minute + %1$d minutes + + + %1$d hour + %1$d hours + + + %1$d day + %1$d days + \ No newline at end of file From 69da89b19bee0f778bfd1ecd6c1eb02a1cc53b16 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Tue, 18 Aug 2020 00:12:42 +0200 Subject: [PATCH 13/40] Improve display of Firmware version in Omnipod fragment --- .../androidaps/plugins/pump/omnipod/OmnipodFragment.kt | 4 ++-- omnipod/src/main/res/layout/omnipod_fragment.xml | 4 ++-- omnipod/src/main/res/values/strings.xml | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt index 5a0b67bee9..fa369fb052 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt @@ -248,7 +248,7 @@ class OmnipodFragment : DaggerFragment() { } omnipod_pod_lot.text = "-" omnipod_pod_tid.text = "-" - omnipod_pod_fw_version.text = "-" + omnipod_pod_firmware_version.text = "-" omnipod_pod_expiry.text = "-" omnipod_basabasalrate.text = "-" omnipod_reservoir.text = "-" @@ -264,7 +264,7 @@ class OmnipodFragment : DaggerFragment() { omnipod_pod_address.text = podStateManager.address.toString() omnipod_pod_lot.text = podStateManager.lot.toString() omnipod_pod_tid.text = podStateManager.tid.toString() - omnipod_pod_fw_version.text = podStateManager.pmVersion.toString() + " / " + podStateManager.piVersion.toString() + omnipod_pod_firmware_version.text = resourceHelper.gs(R.string.omnipod_pod_firmware_version_value, podStateManager.pmVersion.toString(), podStateManager.piVersion.toString()) omnipod_pod_expiry.text = podStateManager.expiryDateAsString val stateText: String diff --git a/omnipod/src/main/res/layout/omnipod_fragment.xml b/omnipod/src/main/res/layout/omnipod_fragment.xml index 7502f89d92..72c3910ad9 100644 --- a/omnipod/src/main/res/layout/omnipod_fragment.xml +++ b/omnipod/src/main/res/layout/omnipod_fragment.xml @@ -219,7 +219,7 @@ android:layout_weight="1.5" android:gravity="end" android:paddingRight="5dp" - android:text="@string/omnipod_pod_fw_version" + android:text="@string/omnipod_pod_firmware_version" android:textSize="14sp" /> Pulse Log LOT TID - PM / PI version + Firmware version + PM %1$s / PI %2$s Errors Basal profile is the same, so it will not be set again. Reset RileyLink Config From 7d52228e15994d26d02f312326948e18d6da55ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Mon, 17 Aug 2020 00:10:37 +0200 Subject: [PATCH 14/40] Move RileyLink components to a separate dependency injection module Having them in the Medtronic module will only create confusion later on. --- .../dependencyInjection/AppComponent.kt | 1 + .../dependencyInjection/MedtronicModule.kt | 21 ------------- .../dependencyInjection/RileyLinkModule.kt | 30 +++++++++++++++++++ 3 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/dependencyInjection/RileyLinkModule.kt diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt index e45db6c006..345ab5a615 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt @@ -26,6 +26,7 @@ import javax.inject.Singleton CommandQueueModule::class, ObjectivesModule::class, WizardModule::class, + RileyLinkModule::class, MedtronicModule::class, OmnipodModule::class, APSModule::class, diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/MedtronicModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/MedtronicModule.kt index f813a6d49d..cadac7d13c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/MedtronicModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/MedtronicModule.kt @@ -2,33 +2,12 @@ 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.* import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask @Module @Suppress("unused") abstract class MedtronicModule { - @ContributesAndroidInjector abstract fun rileyLinkCommunicationManagerProvider(): RileyLinkCommunicationManager @ContributesAndroidInjector abstract fun medtronicCommunicationManagerProvider(): MedtronicCommunicationManager @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 } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/RileyLinkModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/RileyLinkModule.kt new file mode 100644 index 0000000000..b74b2e4263 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/RileyLinkModule.kt @@ -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 +} \ No newline at end of file From 3646ef083e79b94cab73c9cdc1eb8c6cdac68374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Mon, 17 Aug 2020 00:11:24 +0200 Subject: [PATCH 15/40] Simplify provisioning of PodStateManager PodStateManager can be provided by AapsPodStateManager, that's much easier than getting the constructor signature right in the dependency injection module. --- .../androidaps/dependencyInjection/OmnipodModule.kt | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt index 400d38d403..05903fcf8e 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt @@ -3,8 +3,6 @@ package info.nightscout.androidaps.dependencyInjection import dagger.Module import dagger.Provides 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.comm.OmnipodCommunicationManager 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.PodInfoFragment 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.AapsPodStateManager 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 @Suppress("unused") @@ -52,9 +45,6 @@ abstract class OmnipodModule { companion object { @Provides - @Singleton - 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) + fun podStateManagerProvider(aapsPodStateManager: info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsPodStateManager) : info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager = aapsPodStateManager } } From e432346fc53d9d8677826c78eea99c648d2d0507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Mon, 17 Aug 2020 00:21:56 +0200 Subject: [PATCH 16/40] Turn RFSpy and RileyLinkBLE into Dagger singletons --- .../medtronic/service/RileyLinkMedtronicService.java | 3 +-- .../pump/omnipod/service/RileyLinkOmnipodService.java | 4 ---- .../hw/rileylink/RileyLinkCommunicationManager.java | 1 - .../plugins/pump/common/hw/rileylink/ble/RFSpy.java | 8 +++++++- .../pump/common/hw/rileylink/ble/RileyLinkBLE.java | 11 ++++++++--- .../common/hw/rileylink/service/RileyLinkService.java | 4 ++-- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java index 2342e0aaa5..9013b578f4 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java @@ -40,6 +40,7 @@ public class RileyLinkMedtronicService extends RileyLinkService { @Inject MedtronicUtil medtronicUtil; @Inject MedtronicUIPostprocessor medtronicUIPostprocessor; @Inject MedtronicPumpStatus medtronicPumpStatus; + @Inject RFSpy rfSpy; private MedtronicUIComm medtronicUIComm; private MedtronicCommunicationManager medtronicCommunicationManager; @@ -99,8 +100,6 @@ public class RileyLinkMedtronicService extends RileyLinkService { // get most recently used RileyLink address rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, ""); - rileyLinkBLE = new RileyLinkBLE(injector, this); // or this - rfspy = new RFSpy(injector, rileyLinkBLE); rfspy.startReader(); // init rileyLinkCommunicationManager diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java index 49c629b84e..d44fc80785 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java @@ -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.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.RileyLinkBLE; 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.defs.RileyLinkTargetDevice; @@ -94,8 +92,6 @@ public class RileyLinkOmnipodService extends RileyLinkService { // get most recently used RileyLink address rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, ""); - rileyLinkBLE = new RileyLinkBLE(injector, this); // or this - rfspy = new RFSpy(injector, rileyLinkBLE); rfspy.startReader(); initializeErosOmnipodManager(); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java index 8a47453ad3..aeb77cb014 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java @@ -53,7 +53,6 @@ public abstract class RileyLinkCommunicationManager { public RileyLinkCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) { this.injector = injector; - injector.androidInjector().inject(this); this.rfspy = rfspy; } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java index dc5e648194..128152aa31 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java @@ -5,6 +5,7 @@ import android.os.SystemClock; import java.util.UUID; import javax.inject.Inject; +import javax.inject.Singleton; import dagger.android.HasAndroidInjector; @@ -40,6 +41,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; /** * Created by geoff on 5/26/16. */ +@Singleton public class RFSpy { @Inject AAPSLogger aapsLogger; @@ -64,10 +66,14 @@ public class RFSpy { private Double currentFrequencyMHz; + @Inject public RFSpy(HasAndroidInjector injector, RileyLinkBLE rileyLinkBle) { - injector.androidInjector().inject(this); this.injector = injector; this.rileyLinkBle = rileyLinkBle; + } + + @Inject + public void onInit() { aapsLogger.debug("RileyLinkServiceData:" + rileyLinkServiceData); reader = new RFSpyReader(aapsLogger, rileyLinkBle); } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java index a132218751..77359fe4f9 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java @@ -18,6 +18,7 @@ import java.util.UUID; import java.util.concurrent.Semaphore; import javax.inject.Inject; +import javax.inject.Singleton; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.logging.AAPSLogger; @@ -40,6 +41,7 @@ import info.nightscout.androidaps.plugins.pump.common.utils.ThreadUtil; * Created by geoff on 5/26/16. * Added: State handling, configuration of RF for different configuration ranges, connection handling */ +@Singleton public class RileyLinkBLE { @Inject AAPSLogger aapsLogger; @@ -58,13 +60,11 @@ public class RileyLinkBLE { private Runnable radioResponseCountNotified; private boolean mIsConnected = false; - + @Inject public RileyLinkBLE(HasAndroidInjector injector, final Context context) { - injector.androidInjector().inject(this); this.context = context; this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - aapsLogger.debug(LTag.PUMPBTCOMM, "BT Adapter: " + this.bluetoothAdapter); bluetoothGattCallback = new BluetoothGattCallback() { @Override @@ -257,6 +257,11 @@ public class RileyLinkBLE { }; } + @Inject + public void onInit() { + aapsLogger.debug(LTag.PUMPBTCOMM, "BT Adapter: " + this.bluetoothAdapter); + } + private boolean isAnyRileyLinkServiceFound(BluetoothGattService service) { diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java index c0ae9d3140..986bbf4d9d 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkService.java @@ -45,10 +45,10 @@ public abstract class RileyLinkService extends DaggerService { @Inject protected ResourceHelper resourceHelper; @Inject protected RileyLinkServiceData rileyLinkServiceData; @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 RFSpy rfspy; // interface for RL xxx Mhz radio. protected RileyLinkBroadcastReceiver mBroadcastReceiver; protected RileyLinkBluetoothStateReceiver bluetoothStateReceiver; From 0fef4128ef698d40775dd2ede5f64d44a285949c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Mon, 17 Aug 2020 00:22:38 +0200 Subject: [PATCH 17/40] Don't try to access injected omnipodPumpStatus in constructor --- .../pump/omnipod/comm/OmnipodCommunicationManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java index 625ce5433f..abecf6689b 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java @@ -62,6 +62,11 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager { @Inject public OmnipodCommunicationManager(HasAndroidInjector injector, RFSpy 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( RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L); } From 8f7ba93c476271396ad171a57598fc6917dbdf9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Mon, 17 Aug 2020 00:24:33 +0200 Subject: [PATCH 18/40] Daggerize AapsOmnipodManager --- .../omnipod/dialogs/PodManagementActivity.kt | 3 ++- .../dialogs/wizard/initpod/InitPodTask.java | 7 +++--- .../driver/comm/AapsOmnipodManager.java | 14 ++++------- .../service/RileyLinkOmnipodService.java | 24 +++---------------- 4 files changed, 14 insertions(+), 34 deletions(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt index f75ffc291d..208009e99a 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt @@ -47,6 +47,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() { @Inject lateinit var podStateManager: PodStateManager @Inject lateinit var injector: HasAndroidInjector @Inject lateinit var rileyLinkServiceData: RileyLinkServiceData + @Inject lateinit var aapsOmnipodManager: AapsOmnipodManager private var initPodChanged = false @@ -141,7 +142,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() { fun resetPodAction() { OKDialog.showConfirmation(this, resourceHelper.gs(R.string.omnipod_cmd_reset_pod_desc), Thread { - AapsOmnipodManager.getInstance().resetPodStatus() + aapsOmnipodManager.resetPodStatus() refreshButtons() }) } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java index 129d551985..5496843cf9 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java @@ -16,6 +16,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodMa public class InitPodTask extends AsyncTask { @Inject ProfileFunction profileFunction; + @Inject AapsOmnipodManager aapsOmnipodManager; private InitActionFragment initActionFragment; public InitPodTask(HasAndroidInjector injector, InitActionFragment initActionFragment) { @@ -34,19 +35,19 @@ public class InitPodTask extends AsyncTask { @Override protected String doInBackground(Void... params) { if (initActionFragment.podInitActionType == PodInitActionType.PairAndPrimeWizardStep) { - initActionFragment.callResult = AapsOmnipodManager.getInstance().initPod( + initActionFragment.callResult = aapsOmnipodManager.initPod( initActionFragment.podInitActionType, initActionFragment, null ); } else if (initActionFragment.podInitActionType == PodInitActionType.FillCannulaSetBasalProfileWizardStep) { - initActionFragment.callResult = AapsOmnipodManager.getInstance().initPod( + initActionFragment.callResult = aapsOmnipodManager.initPod( initActionFragment.podInitActionType, initActionFragment, profileFunction.getProfile() ); } else if (initActionFragment.podInitActionType == PodInitActionType.DeactivatePodWizardStep) { - initActionFragment.callResult = AapsOmnipodManager.getInstance().deactivatePod(initActionFragment); + initActionFragment.callResult = aapsOmnipodManager.deactivatePod(initActionFragment); } return "OK"; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java index 153af29008..3e5e2db4f7 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java @@ -10,6 +10,9 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import javax.inject.Inject; +import javax.inject.Singleton; + import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.activities.ErrorHelperActivity; 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 io.reactivex.disposables.Disposable; -// TODO make singleton +@Singleton public class AapsOmnipodManager implements IOmnipodManager { private final PodStateManager podStateManager; @@ -87,15 +90,9 @@ public class AapsOmnipodManager implements IOmnipodManager { private final Context context; private final OmnipodManager delegate; - - //TODO: remove and use injection - private static AapsOmnipodManager instance; private DatabaseHelperInterface databaseHelper; - public static AapsOmnipodManager getInstance() { - return instance; - } - + @Inject public AapsOmnipodManager(OmnipodCommunicationManager communicationService, PodStateManager podStateManager, OmnipodPumpStatus pumpStatus, @@ -123,7 +120,6 @@ public class AapsOmnipodManager implements IOmnipodManager { this.databaseHelper = databaseHelper; delegate = new OmnipodManager(aapsLogger, sp, communicationService, podStateManager); - instance = this; } public PodStateManager getPodStateManager() { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java index d44fc80785..58e35dd8fd 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java @@ -43,11 +43,8 @@ public class RileyLinkOmnipodService extends RileyLinkService { @Inject OmnipodUIPostprocessor omnipodUIPostprocessor; @Inject PodStateManager podStateManager; @Inject DatabaseHelperInterface databaseHelper; - - private static RileyLinkOmnipodService instance; - - private OmnipodCommunicationManager omnipodCommunicationManager; - private AapsOmnipodManager aapsOmnipodManager; + @Inject AapsOmnipodManager aapsOmnipodManager; + @Inject OmnipodCommunicationManager omnipodCommunicationManager; private IBinder mBinder = new LocalBinder(); private boolean rileyLinkAddressChanged = false; @@ -57,11 +54,6 @@ public class RileyLinkOmnipodService extends RileyLinkService { public RileyLinkOmnipodService() { super(); - instance = this; - } - - public static RileyLinkOmnipodService getInstance() { - return instance; } @Override @@ -101,18 +93,8 @@ public class RileyLinkOmnipodService extends RileyLinkService { } private void initializeErosOmnipodManager() { - AapsOmnipodManager instance = AapsOmnipodManager.getInstance(); - 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); - + if (omnipodUIComm == null) { omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager, rileyLinkUtil); - - } else { - aapsOmnipodManager = instance; } rxBus.send(new EventOmnipodPumpValuesChanged()); } From 3ad41d07c57b9968f317201cb34a615ee4454493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Tue, 18 Aug 2020 01:02:49 +0200 Subject: [PATCH 19/40] Remove unused injector argument in RileyLinkBLE --- .../plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java index 77359fe4f9..6c90c62e24 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java @@ -20,7 +20,6 @@ import java.util.concurrent.Semaphore; 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.hw.rileylink.RileyLinkConst; @@ -61,7 +60,7 @@ public class RileyLinkBLE { private boolean mIsConnected = false; @Inject - public RileyLinkBLE(HasAndroidInjector injector, final Context context) { + public RileyLinkBLE(final Context context) { this.context = context; this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); From ffb0611682cce84e7bbb4f26d32fc712c40c1504 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Tue, 18 Aug 2020 12:33:01 +0200 Subject: [PATCH 20/40] Remove redundant string resources --- app/src/main/res/values/strings.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a6c4e65831..9fa956c86c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1396,16 +1396,6 @@ skin Skin - - Never contacted - Waking up - Error with communication - Timeout on communication - Pump unreachable - Invalid configuration - Active - Sleeping - Compare profiles Profile helper Default profile From 48ad85ae6aeddd1720a06c54abffc31b2845de77 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Tue, 18 Aug 2020 12:33:26 +0200 Subject: [PATCH 21/40] Move Omnipod tab closer to Overview tab --- .../androidaps/dependencyInjection/PluginsModule.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt index 60faae9344..efb59be7c3 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt @@ -148,6 +148,12 @@ abstract class PluginsModule { @IntKey(150) abstract fun bindMedtronicPumpPlugin(plugin: MedtronicPumpPlugin): PluginBase + @Binds + @PumpDriver + @IntoMap + @IntKey(155) + abstract fun bindOmnipodPumpPlugin(plugin: OmnipodPumpPlugin): PluginBase + @Binds @NotNSClient @IntoMap @@ -340,12 +346,6 @@ abstract class PluginsModule { @IntKey(480) abstract fun bindConfigBuilderPlugin(plugin: ConfigBuilderPlugin): PluginBase - @Binds - @PumpDriver - @IntoMap - @IntKey(490) - abstract fun bindOmnipodPumpPlugin(plugin: info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin): PluginBase - @Qualifier annotation class AllConfigs From 80f1ed52b33f6916cb854bbbf085e4c14f736201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Tue, 18 Aug 2020 12:36:25 +0200 Subject: [PATCH 22/40] Move CryptoUtil to core CryptoUtil is a dependency of ProtectionCheck, so it needs to move to core. --- core/build.gradle | 3 +++ .../main/java/info/nightscout/androidaps/utils/CryptoUtil.kt | 0 2 files changed, 3 insertions(+) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/CryptoUtil.kt (100%) diff --git a/core/build.gradle b/core/build.gradle index b79909271a..e74a2eae73 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -65,6 +65,9 @@ dependencies { implementation "io.reactivex.rxjava2:rxandroid:${rxandroid_version}" implementation 'org.apache.commons:commons-lang3:3.10' + //CryptoUtil + implementation 'com.madgag.spongycastle:core:1.58.0.0' + // Graphview cannot be upgraded implementation "com.jjoe64:graphview:4.0.1" diff --git a/app/src/main/java/info/nightscout/androidaps/utils/CryptoUtil.kt b/core/src/main/java/info/nightscout/androidaps/utils/CryptoUtil.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/CryptoUtil.kt rename to core/src/main/java/info/nightscout/androidaps/utils/CryptoUtil.kt From 75cbc87b4a039a344e925bdcfc3ed5e295264cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Tue, 18 Aug 2020 15:09:14 +0200 Subject: [PATCH 23/40] Move SingleClickButton to core SingleClickButton is a utility used in a number of modules and such should be in core. While the app seems to built with the button in app, this wrong structure should be fixed. As the button is a UI element, the patch also moves the class to the package info.nightscout.androidaps.utils.ui. --- .../general/actions/ActionsFragment.kt | 2 +- app/src/main/res/layout/actions_fragment.xml | 32 +++++++-------- .../layout/activity_smscommunicator_otp.xml | 2 +- .../main/res/layout/careportal_fragment.xml | 40 +++++++++---------- .../main/res/layout/combopump_fragment.xml | 2 +- .../res/layout/overview_buttons_layout.xml | 16 ++++---- .../overview_fragment_nsclient_tablet.xml | 10 ++--- .../utils/ui}/SingleClickButton.java | 3 +- .../src/main/res/layout/omnipod_pod_mgmt.xml | 8 ++-- 9 files changed, 57 insertions(+), 58 deletions(-) rename {app/src/main/java/info/nightscout/androidaps/utils => core/src/main/java/info/nightscout/androidaps/utils/ui}/SingleClickButton.java (96%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index 22973b3caf..20a6493ea8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -25,7 +25,7 @@ import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.SingleClickButton +import info.nightscout.androidaps.utils.ui.SingleClickButton import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.extensions.plusAssign diff --git a/app/src/main/res/layout/actions_fragment.xml b/app/src/main/res/layout/actions_fragment.xml index ebb517dcb7..427000813d 100644 --- a/app/src/main/res/layout/actions_fragment.xml +++ b/app/src/main/res/layout/actions_fragment.xml @@ -25,7 +25,7 @@ android:padding="10dip" app:columnCount="2"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Date: Tue, 18 Aug 2020 19:09:07 +0200 Subject: [PATCH 24/40] Refresh buttons in Pod Management fragment on EventRileyLinkDeviceStatusChange and indicate when we're still waiting for a RL connection --- .../pump/medtronic/MedtronicFragment.kt | 4 +- .../plugins/pump/omnipod/OmnipodFragment.kt | 22 +++--- .../pump/omnipod/OmnipodPumpPlugin.java | 68 ------------------- .../omnipod/defs/state/PodStateManager.java | 7 ++ .../omnipod/dialogs/PodManagementActivity.kt | 52 +++++++------- .../wizard/pages/InitPodRefreshAction.java | 5 -- .../src/main/res/layout/omnipod_pod_mgmt.xml | 57 ++++++++++++---- omnipod/src/main/res/values/strings.xml | 1 + .../hw/rileylink/data/RLHistoryItem.java | 2 +- .../rileylink/defs/RileyLinkServiceState.java | 28 +------- .../RileyLinkStatusGeneralFragment.java | 3 +- rileylink/src/main/res/values/strings.xml | 1 + 12 files changed, 96 insertions(+), 154 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt index cb1e246e0e..056581a801 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt @@ -80,7 +80,7 @@ class MedtronicFragment : DaggerFragment() { medtronic_pumpstatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder)) - medtronic_rl_status.text = resourceHelper.gs(RileyLinkServiceState.NotStarted.getResourceId(RileyLinkTargetDevice.MedtronicPump)) + medtronic_rl_status.text = resourceHelper.gs(RileyLinkServiceState.NotStarted.getResourceId()) medtronic_pump_status.setTextColor(Color.WHITE) medtronic_pump_status.text = "{fa-bed}" @@ -172,7 +172,7 @@ class MedtronicFragment : DaggerFragment() { @Synchronized private fun setDeviceStatus() { - val resourceId = rileyLinkServiceData.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.MedtronicPump) + val resourceId = rileyLinkServiceData.rileyLinkServiceState.getResourceId() val rileyLinkError = medtronicPumpPlugin.rileyLinkService?.error medtronic_rl_status.text = when { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt index fa369fb052..3b39f1ab2e 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodFragment.kt @@ -35,13 +35,13 @@ import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.WarnColors import info.nightscout.androidaps.utils.alertDialogs.OKDialog +import info.nightscout.androidaps.utils.extensions.plusAssign import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.ui.UIRunnable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable -import io.reactivex.disposables.Disposable import io.reactivex.schedulers.Schedulers import kotlinx.android.synthetic.main.omnipod_fragment.* import org.apache.commons.lang3.StringUtils @@ -69,15 +69,11 @@ class OmnipodFragment : DaggerFragment() { // @Inject lateinit var localAlertUtils: LocalAlertUtils @Inject lateinit var protectionCheck: ProtectionCheck - private var disposable: CompositeDisposable = CompositeDisposable() + private var disposables: CompositeDisposable = CompositeDisposable() private val loopHandler = Handler() private lateinit var refreshLoop: Runnable - operator fun CompositeDisposable.plusAssign(disposable: Disposable) { - add(disposable) - } - init { refreshLoop = Runnable { activity?.runOnUiThread { updateUi() } @@ -157,23 +153,23 @@ class OmnipodFragment : DaggerFragment() { override fun onResume() { super.onResume() loopHandler.postDelayed(refreshLoop, T.mins(1).msecs()) - disposable += rxBus + disposables += rxBus .toObservable(EventOmnipodRefreshButtonState::class.java) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ omnipod_refresh.isEnabled = it.newState }, { fabricPrivacy.logException(it) }) - disposable += rxBus + disposables += rxBus .toObservable(EventRileyLinkDeviceStatusChange::class.java) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ updateRileyLinkUiElements() }, { fabricPrivacy.logException(it) }) - disposable += rxBus + disposables += rxBus .toObservable(EventOmnipodPumpValuesChanged::class.java) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ updateOmipodUiElements() }, { fabricPrivacy.logException(it) }) - disposable += rxBus + disposables += rxBus .toObservable(EventOmnipodAcknowledgeAlertsChanged::class.java) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ updateAcknowledgeAlertsUiElements() }, { fabricPrivacy.logException(it) }) - disposable += rxBus + disposables += rxBus .toObservable(EventPreferenceChange::class.java) .observeOn(Schedulers.io()) .subscribe({ @@ -200,7 +196,7 @@ class OmnipodFragment : DaggerFragment() { override fun onPause() { super.onPause() - disposable.clear() + disposables.clear() loopHandler.removeCallbacks(refreshLoop) } @@ -215,7 +211,7 @@ class OmnipodFragment : DaggerFragment() { val rileyLinkServiceState = rileyLinkServiceData.rileyLinkServiceState - val resourceId = rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod) + val resourceId = rileyLinkServiceState.getResourceId() val rileyLinkError = rileyLinkServiceData.rileyLinkError omnipod_rl_status.text = diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 6f7ccba6e2..7a861f8878 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -169,30 +169,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump break; } } - - -// if (OmnipodPumpPlugin.this.omnipodPumpStatus != null) { -// -// aapsLogger.debug(LTag.PUMP, "Starting OmniPod-RileyLink service"); -// if (omnipodService.setNotInPreInit()) { -// if (omnipodCommunicationManager == null) { -// omnipodCommunicationManager = AapsOmnipodManager.getInstance(); -// omnipodCommunicationManager.setPumpStatus(OmnipodPumpPlugin.this.omnipodPumpStatus); -// omnipodServiceRunning = true; -// } else { -// omnipodCommunicationManager.setPumpStatus(OmnipodPumpPlugin.this.omnipodPumpStatus); -// } -// -// omnipodUtil.setOmnipodPodType(OmnipodPodType.Eros); -// //omnipodUtil.setPlugin(OmnipodPumpPlugin.this); -// -// omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager, plugin, OmnipodPumpPlugin.this.omnipodPumpStatus); -// break; -// } -// } -// -// SystemClock.sleep(5000); - //} }).start(); } }; @@ -225,24 +201,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump ); super.onStart(); - - - //rileyLinkOmnipodService.verifyConfiguration(); - //initPumpStatusData(); } -// @Override -// protected void onResume() { -// -// } - -// private void refreshConfiguration() { -// if (pumpStatusLocal != null) { -// pumpStatusLocal.refreshConfiguration(); -// } -// verifyConfiguration() -// } - @Override protected void onStop() { disposable.clear(); @@ -253,7 +213,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return "OmnipodPlugin::"; } - @Override public void initPumpStatusData() { @@ -269,16 +228,12 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump if (!sp.contains(OmnipodConst.Statistics.FirstPumpStart)) { sp.putLong(OmnipodConst.Statistics.FirstPumpStart, System.currentTimeMillis()); } - } - @Override public void onStartCustomActions() { - // check status every minute (if any status needs refresh we send readStatus command) new Thread(() -> { - do { SystemClock.sleep(60000); @@ -726,29 +681,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } } - // if TBR is running we will cancel it. -// if (tbrCurrent != null) { -// -// aapsLogger.info(LTag.PUMP,getLogPrefix() + "setTempBasalAbsolute - TBR running - so canceling it."); -// -// // CANCEL -// OmnipodUITask responseTask2 = omnipodUIComm.executeCommand(OmnipodCommandType.CancelTemporaryBasal); -// -// PumpEnactResult result = responseTask2.getResult(); -// -// if (result.success) { -// -// aapsLogger.info(LTag.PUMP,getLogPrefix() + "setTempBasalAbsolute - Current TBR cancelled."); -// } else { -// -// aapsLogger.error(LTag.PUMP,getLogPrefix() + "setTempBasalAbsolute - Cancel TBR failed."); -// -// finishAction("TBR"); -// -// return result; -// } -// } - // now start new TBR OmnipodUITask responseTask = getDeviceCommandExecutor().executeCommand(OmnipodCommandType.SetTemporaryBasal, absoluteRate, durationInMinutes); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodStateManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodStateManager.java index 70ce06498a..dce7c36936 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodStateManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodStateManager.java @@ -78,6 +78,13 @@ public abstract class PodStateManager { && podState.getPodProgressStatus() != null; } + /** + * @return true if we have a Pod state and the Pod activation has been completed. The pod could also be dead at this point + */ + public final boolean isPodActivationCompleted() { + return isPodInitialized() && podState.getPodProgressStatus().isAtLeast(PodProgressStatus.ABOVE_FIFTY_UNITS); + } + /** * @return true if we have a Pod state and the Pod is running, meaning the activation process has completed and the Pod is not deactivated or in a fault state */ diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt index 208009e99a..25843f8d80 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt @@ -2,6 +2,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dialogs import android.content.Intent import android.os.Bundle +import android.view.View +import android.widget.LinearLayout import androidx.fragment.app.FragmentStatePagerAdapter import com.atech.android.library.wizardpager.WizardPagerActivity import com.atech.android.library.wizardpager.WizardPagerContext @@ -11,9 +13,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.interfaces.CommandQueueProvider -import info.nightscout.androidaps.interfaces.ProfileFunction -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData import info.nightscout.androidaps.plugins.pump.omnipod.R import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus @@ -24,11 +25,12 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.Remo import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.ShortInitPodWizardModel import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager -import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged -import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.alertDialogs.OKDialog +import info.nightscout.androidaps.utils.extensions.plusAssign import info.nightscout.androidaps.utils.resources.ResourceHelper +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.CompositeDisposable import kotlinx.android.synthetic.main.omnipod_pod_mgmt.* import javax.inject.Inject @@ -38,18 +40,15 @@ import javax.inject.Inject class PodManagementActivity : NoSplashAppCompatActivity() { @Inject lateinit var rxBus: RxBusWrapper - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var commandQueue: CommandQueueProvider - @Inject lateinit var omnipodUtil: OmnipodUtil @Inject lateinit var podStateManager: PodStateManager @Inject lateinit var injector: HasAndroidInjector @Inject lateinit var rileyLinkServiceData: RileyLinkServiceData @Inject lateinit var aapsOmnipodManager: AapsOmnipodManager - private var initPodChanged = false + private var disposables: CompositeDisposable = CompositeDisposable() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -57,33 +56,39 @@ class PodManagementActivity : NoSplashAppCompatActivity() { initpod_init_pod.setOnClickListener { initPodAction() - initPodChanged = true } initpod_remove_pod.setOnClickListener { removePodAction() - initPodChanged = true } initpod_reset_pod.setOnClickListener { resetPodAction() - initPodChanged = true } initpod_pod_history.setOnClickListener { showPodHistory() } + } - refreshButtons(); + override fun onResume() { + super.onResume() + disposables += rxBus + .toObservable(EventRileyLinkDeviceStatusChange::class.java) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe({ refreshButtons() }, { fabricPrivacy.logException(it) }) + + refreshButtons() + } + + override fun onPause() { + super.onPause() + disposables.clear() } override fun onDestroy() { super.onDestroy() - - if (initPodChanged) { - rxBus.send(EventOmnipodPumpValuesChanged()) - rxBus.send(EventRefreshOverview("Omnipod Pod Management")) - } + rxBus.send(EventRefreshOverview("Omnipod Pod Management")) } fun initPodAction() { @@ -148,20 +153,21 @@ class PodManagementActivity : NoSplashAppCompatActivity() { } fun showPodHistory() { -// OKDialog.showConfirmation(this, -// MainApp.gs(R.string.omnipod_cmd_pod_history_na), null) - startActivity(Intent(applicationContext, PodHistoryActivity::class.java)) } fun refreshButtons() { - initpod_init_pod.isEnabled = !podStateManager.isPodRunning() - + initpod_init_pod.isEnabled = !podStateManager.isPodActivationCompleted initpod_remove_pod.isEnabled = podStateManager.isPodInitialized initpod_reset_pod.isEnabled = podStateManager.hasPodState() - if (!rileyLinkServiceData.rileyLinkServiceState.isReady) { + val waitingForRlView = findViewById(R.id.initpod_waiting_for_rl_layout) + + if (rileyLinkServiceData.rileyLinkServiceState.isReady) { + waitingForRlView.visibility = View.GONE + } else { // if rileylink is not running we disable all operations that require a RL connection + waitingForRlView.visibility = View.VISIBLE initpod_init_pod.isEnabled = false initpod_remove_pod.isEnabled = false initpod_reset_pod.isEnabled = false diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java index cb7344daba..794a40100d 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java @@ -51,8 +51,6 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish if (this.cancelActionText.equals("Cancel")) { //AapsOmnipodManager.getInstance().resetPodStatus(); } - - podManagementActivity.refreshButtons(); } @Override @@ -62,9 +60,6 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish uploadCareportalEvent(System.currentTimeMillis(), CareportalEvent.SITECHANGE); } } - - // TODO do this in PodManagerMentActivity itself by listening to OmnipodPumpValuesChanged events - podManagementActivity.refreshButtons(); } private void uploadCareportalEvent(long date, String event) { diff --git a/omnipod/src/main/res/layout/omnipod_pod_mgmt.xml b/omnipod/src/main/res/layout/omnipod_pod_mgmt.xml index eb3d2dc5cb..fcb5b02b7b 100644 --- a/omnipod/src/main/res/layout/omnipod_pod_mgmt.xml +++ b/omnipod/src/main/res/layout/omnipod_pod_mgmt.xml @@ -23,25 +23,54 @@ android:layout_marginRight="10dp" android:layout_marginBottom="3dp" android:layout_weight="0.5" + android:gravity="center" android:text="@string/omnipod_pod_mgmt_title" android:textAlignment="center" android:textSize="12pt" - android:gravity="center" android:textStyle="bold" /> + + + + + + + + android:text="@string/omnipod_cmd_init_pod" + android:textAllCaps="false" /> + android:text="@string/omnipod_cmd_deactivate_pod" + android:textAllCaps="false" /> + android:text="@string/omnipod_cmd_reset_pod" + android:textAllCaps="false" /> - - + android:text="@string/omnipod_cmd_pod_history" + android:textAllCaps="false" /> diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index cf356548b2..f21de6a9e9 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -147,6 +147,7 @@ Time and/or Timezone change on pump %1$s and %2$s %1$s ago + Waiting for RileyLink connection... %1$d minute diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/data/RLHistoryItem.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/data/RLHistoryItem.java index b72537d004..7b25cf63ec 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/data/RLHistoryItem.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/data/RLHistoryItem.java @@ -60,7 +60,7 @@ public class RLHistoryItem { public String getDescription(ResourceHelper resourceHelper) { switch (this.source) { case RileyLink: - return "State: " + resourceHelper.gs(serviceState.getResourceId(targetDevice)) + return "State: " + resourceHelper.gs(serviceState.getResourceId()) + (this.errorCode == null ? "" : ", Error Code: " + errorCode); case MedtronicPump: return resourceHelper.gs(pumpDeviceState.getResourceId()); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkServiceState.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkServiceState.java index 76c31f9cf2..97ce0c6ce1 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkServiceState.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/defs/RileyLinkServiceState.java @@ -22,7 +22,7 @@ public enum RileyLinkServiceState { RileyLinkInitializing(R.string.rileylink_state_rl_init), // (S) start Gatt discovery (OK -> RileyLinkReady, Error -> // BluetoothEnabled) ?? RileyLinkError(R.string.rileylink_state_rl_error), // (E) - RileyLinkReady(R.string.rileylink_state_connected), // (OK) if tunning was already done we go to PumpConnectorReady + RileyLinkReady(R.string.rileylink_state_rl_ready), // (OK) if tunning was already done we go to PumpConnectorReady // Tunning TuneUpDevice(R.string.rileylink_state_pc_tune_up), // (S) @@ -40,43 +40,23 @@ public enum RileyLinkServiceState { // RileyLinkConnected, // -> TuneUpPump (on 1st), else PumpConnectorReady // PumpConnected, // - ; int resourceId; - Integer resourceIdPod; - RileyLinkServiceState(int resourceId) { this.resourceId = resourceId; } - - RileyLinkServiceState(int resourceId, int resourceIdPod) { - this.resourceId = resourceId; - this.resourceIdPod = resourceIdPod; - } - - public boolean isReady() { return (this == PumpConnectorReady); } - - public int getResourceId(RileyLinkTargetDevice targetDevice) { - if (this.resourceIdPod != null) { - - return (targetDevice == null || targetDevice == RileyLinkTargetDevice.MedtronicPump) ? // - this.resourceId - : this.resourceIdPod; - } else { - return this.resourceId; - } + public int getResourceId() { + return this.resourceId; } - public boolean isConnecting() { - return (this == RileyLinkServiceState.BluetoothInitializing || // // this == RileyLinkServiceState.BluetoothError || // this == RileyLinkServiceState.BluetoothReady || // @@ -86,9 +66,7 @@ public enum RileyLinkServiceState { ); } - public boolean isError() { - return (this == RileyLinkServiceState.BluetoothError || // // this == RileyLinkServiceState.PumpConnectorError || // this == RileyLinkServiceState.RileyLinkError); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java index f48dfe95de..49094c3bcc 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java @@ -36,7 +36,6 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re @Inject ActivePluginProvider activePlugin; @Inject ResourceHelper resourceHelper; - //@Inject MedtronicUtil medtronicUtil; @Inject AAPSLogger aapsLogger; @Inject RileyLinkServiceData rileyLinkServiceData; @Inject DateUtil dateUtil; @@ -103,7 +102,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re RileyLinkTargetDevice targetDevice = rileyLinkServiceData.targetDevice; - this.connectionStatus.setText(resourceHelper.gs(rileyLinkServiceData.rileyLinkServiceState.getResourceId(targetDevice))); + this.connectionStatus.setText(resourceHelper.gs(rileyLinkServiceData.rileyLinkServiceState.getResourceId())); if (rileyLinkServiceData != null) { this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress); diff --git a/rileylink/src/main/res/values/strings.xml b/rileylink/src/main/res/values/strings.xml index ddb9beaf9b..8e7445464b 100644 --- a/rileylink/src/main/res/values/strings.xml +++ b/rileylink/src/main/res/values/strings.xml @@ -42,6 +42,7 @@ Tuning up RileyLink and Pump Problem connecting to Pump Connected + RileyLink ready Device is not RileyLink From 56efc3e23090972cada267ab2a0eedb3bbdb3064 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Tue, 18 Aug 2020 19:15:50 +0200 Subject: [PATCH 25/40] Add missing icons in Omnipod --- omnipod/src/main/res/drawable/ic_actions_temptarget.xml | 9 +++++++++ omnipod/src/main/res/drawable/ic_cp_pump_canula.xml | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 omnipod/src/main/res/drawable/ic_actions_temptarget.xml create mode 100644 omnipod/src/main/res/drawable/ic_cp_pump_canula.xml diff --git a/omnipod/src/main/res/drawable/ic_actions_temptarget.xml b/omnipod/src/main/res/drawable/ic_actions_temptarget.xml new file mode 100644 index 0000000000..5dbd5d8b0c --- /dev/null +++ b/omnipod/src/main/res/drawable/ic_actions_temptarget.xml @@ -0,0 +1,9 @@ + + + diff --git a/omnipod/src/main/res/drawable/ic_cp_pump_canula.xml b/omnipod/src/main/res/drawable/ic_cp_pump_canula.xml new file mode 100644 index 0000000000..b43de7ceaa --- /dev/null +++ b/omnipod/src/main/res/drawable/ic_cp_pump_canula.xml @@ -0,0 +1,9 @@ + + + From d0cbaeeb3212b7b7d559dae4b872db048b5dba36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Tue, 18 Aug 2020 14:16:13 +0200 Subject: [PATCH 26/40] Move protection infrastructure to core The protection infrastructure is useful for other modules like pump drivers, so it should be in core. --- app/src/main/res/values/strings.xml | 1 - core/build.gradle | 1 + .../utils/protection/BiometricCheck.kt | 2 +- .../utils/protection/PasswordCheck.kt | 2 +- .../utils/protection/ProtectionCheck.kt | 18 +++++++++--------- .../src/main/res/drawable/ic_header_key.xml | 0 .../src/main/res/layout/passwordprompt.xml | 0 .../src/main/res/values-af-rZA/protection.xml | 0 .../src/main/res/values-ar-rSA/protection.xml | 0 .../src/main/res/values-bg-rBG/protection.xml | 0 .../src/main/res/values-cs-rCZ/protection.xml | 0 .../src/main/res/values-cy-rGB/protection.xml | 0 .../src/main/res/values-de-rDE/protection.xml | 0 .../src/main/res/values-el-rGR/protection.xml | 0 .../src/main/res/values-es-rES/protection.xml | 0 .../src/main/res/values-fi-rFI/protection.xml | 0 .../src/main/res/values-fr-rFR/protection.xml | 0 .../src/main/res/values-ga-rIE/protection.xml | 0 .../src/main/res/values-hr-rHR/protection.xml | 0 .../src/main/res/values-it-rIT/protection.xml | 0 .../src/main/res/values-iw-rIL/protection.xml | 0 .../src/main/res/values-ja-rJP/protection.xml | 0 .../src/main/res/values-ko-rKR/protection.xml | 0 .../src/main/res/values-lt-rLT/protection.xml | 0 .../src/main/res/values-nl-rNL/protection.xml | 0 .../src/main/res/values-pl-rPL/protection.xml | 0 .../src/main/res/values-pt-rBR/protection.xml | 0 .../src/main/res/values-pt-rPT/protection.xml | 0 .../src/main/res/values-ro-rRO/protection.xml | 0 .../src/main/res/values-ru-rRU/protection.xml | 0 .../src/main/res/values-sk-rSK/protection.xml | 0 .../src/main/res/values-sl-rSI/protection.xml | 0 .../src/main/res/values-sv-rSE/protection.xml | 0 .../src/main/res/values-tr-rTR/protection.xml | 0 .../src/main/res/values-zh-rCN/protection.xml | 0 .../src/main/res/values/protection.xml | 0 core/src/main/res/values/strings.xml | 4 ++++ dana/src/main/res/values/strings.xml | 1 - 38 files changed, 16 insertions(+), 13 deletions(-) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt (98%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt (99%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt (79%) rename {app => core}/src/main/res/drawable/ic_header_key.xml (100%) rename {app => core}/src/main/res/layout/passwordprompt.xml (100%) rename {app => core}/src/main/res/values-af-rZA/protection.xml (100%) rename {app => core}/src/main/res/values-ar-rSA/protection.xml (100%) rename {app => core}/src/main/res/values-bg-rBG/protection.xml (100%) rename {app => core}/src/main/res/values-cs-rCZ/protection.xml (100%) rename {app => core}/src/main/res/values-cy-rGB/protection.xml (100%) rename {app => core}/src/main/res/values-de-rDE/protection.xml (100%) rename {app => core}/src/main/res/values-el-rGR/protection.xml (100%) rename {app => core}/src/main/res/values-es-rES/protection.xml (100%) rename {app => core}/src/main/res/values-fi-rFI/protection.xml (100%) rename {app => core}/src/main/res/values-fr-rFR/protection.xml (100%) rename {app => core}/src/main/res/values-ga-rIE/protection.xml (100%) rename {app => core}/src/main/res/values-hr-rHR/protection.xml (100%) rename {app => core}/src/main/res/values-it-rIT/protection.xml (100%) rename {app => core}/src/main/res/values-iw-rIL/protection.xml (100%) rename {app => core}/src/main/res/values-ja-rJP/protection.xml (100%) rename {app => core}/src/main/res/values-ko-rKR/protection.xml (100%) rename {app => core}/src/main/res/values-lt-rLT/protection.xml (100%) rename {app => core}/src/main/res/values-nl-rNL/protection.xml (100%) rename {app => core}/src/main/res/values-pl-rPL/protection.xml (100%) rename {app => core}/src/main/res/values-pt-rBR/protection.xml (100%) rename {app => core}/src/main/res/values-pt-rPT/protection.xml (100%) rename {app => core}/src/main/res/values-ro-rRO/protection.xml (100%) rename {app => core}/src/main/res/values-ru-rRU/protection.xml (100%) rename {app => core}/src/main/res/values-sk-rSK/protection.xml (100%) rename {app => core}/src/main/res/values-sl-rSI/protection.xml (100%) rename {app => core}/src/main/res/values-sv-rSE/protection.xml (100%) rename {app => core}/src/main/res/values-tr-rTR/protection.xml (100%) rename {app => core}/src/main/res/values-zh-rCN/protection.xml (100%) rename {app => core}/src/main/res/values/protection.xml (100%) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a6c4e65831..21b8217669 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1383,7 +1383,6 @@ Authorization failed Absolute insulin Master password is used for backup encryption and to override security in application. Remember it or store on a safe place. - Passwords don\'t match Current master password Status lights Copy settings from NS diff --git a/core/build.gradle b/core/build.gradle index e74a2eae73..6c0c4ee32a 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -44,6 +44,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.1.0' implementation "androidx.preference:preference-ktx:1.1.1" + implementation 'androidx.biometric:biometric:1.0.1' implementation "androidx.activity:activity:${activityVersion}" implementation "androidx.activity:activity-ktx:${activityVersion}" implementation 'com.google.android.material:material:1.1.0' diff --git a/app/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt b/core/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt rename to core/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt index c58b5628d1..22ef6a1b4a 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.utils.protection import androidx.biometric.BiometricConstants import androidx.biometric.BiometricPrompt import androidx.fragment.app.FragmentActivity -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.extensions.runOnUiThread import java.util.concurrent.Executors diff --git a/app/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt b/core/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt rename to core/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt index 5f80c54480..04399eb95f 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt @@ -7,7 +7,7 @@ import android.view.LayoutInflater import android.view.View import android.widget.EditText import androidx.annotation.StringRes -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.utils.CryptoUtil import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.alertDialogs.AlertDialogHelper diff --git a/app/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt b/core/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt similarity index 79% rename from app/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt rename to core/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt index e8dd73d7fb..ca0a3402a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.utils.protection import androidx.fragment.app.FragmentActivity -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.utils.sharedPreferences.SP import javax.inject.Inject import javax.inject.Singleton @@ -42,10 +42,10 @@ class ProtectionCheck @Inject constructor( fun isLocked(protection: Protection): Boolean { return when (ProtectionType.values()[sp.getInt(protectionTypeResourceIDs[protection.ordinal], ProtectionType.NONE.ordinal)]) { - ProtectionType.NONE -> false - ProtectionType.BIOMETRIC -> true - ProtectionType.MASTER_PASSWORD -> sp.getString(R.string.key_master_password, "") != "" - ProtectionType.CUSTOM_PASSWORD -> sp.getString(passwordsResourceIDs[protection.ordinal], "") != "" + ProtectionType.NONE -> false + ProtectionType.BIOMETRIC -> true + ProtectionType.MASTER_PASSWORD -> sp.getString(R.string.key_master_password, "") != "" + ProtectionType.CUSTOM_PASSWORD -> sp.getString(passwordsResourceIDs[protection.ordinal], "") != "" } } @@ -53,13 +53,13 @@ class ProtectionCheck @Inject constructor( fun queryProtection(activity: FragmentActivity, protection: Protection, ok: Runnable?, cancel: Runnable? = null, fail: Runnable? = null) { when (ProtectionType.values()[sp.getInt(protectionTypeResourceIDs[protection.ordinal], ProtectionType.NONE.ordinal)]) { - ProtectionType.NONE -> + ProtectionType.NONE -> ok?.run() - ProtectionType.BIOMETRIC -> + ProtectionType.BIOMETRIC -> BiometricCheck.biometricPrompt(activity, titleResourceIDs[protection.ordinal], ok, cancel, fail, passwordCheck) - ProtectionType.MASTER_PASSWORD -> + ProtectionType.MASTER_PASSWORD -> passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() }) - ProtectionType.CUSTOM_PASSWORD -> + ProtectionType.CUSTOM_PASSWORD -> passwordCheck.queryPassword(activity, titleResourceIDs[protection.ordinal], passwordsResourceIDs[protection.ordinal], { ok?.run() }, { cancel?.run() }, { fail?.run() }) } } diff --git a/app/src/main/res/drawable/ic_header_key.xml b/core/src/main/res/drawable/ic_header_key.xml similarity index 100% rename from app/src/main/res/drawable/ic_header_key.xml rename to core/src/main/res/drawable/ic_header_key.xml diff --git a/app/src/main/res/layout/passwordprompt.xml b/core/src/main/res/layout/passwordprompt.xml similarity index 100% rename from app/src/main/res/layout/passwordprompt.xml rename to core/src/main/res/layout/passwordprompt.xml diff --git a/app/src/main/res/values-af-rZA/protection.xml b/core/src/main/res/values-af-rZA/protection.xml similarity index 100% rename from app/src/main/res/values-af-rZA/protection.xml rename to core/src/main/res/values-af-rZA/protection.xml diff --git a/app/src/main/res/values-ar-rSA/protection.xml b/core/src/main/res/values-ar-rSA/protection.xml similarity index 100% rename from app/src/main/res/values-ar-rSA/protection.xml rename to core/src/main/res/values-ar-rSA/protection.xml diff --git a/app/src/main/res/values-bg-rBG/protection.xml b/core/src/main/res/values-bg-rBG/protection.xml similarity index 100% rename from app/src/main/res/values-bg-rBG/protection.xml rename to core/src/main/res/values-bg-rBG/protection.xml diff --git a/app/src/main/res/values-cs-rCZ/protection.xml b/core/src/main/res/values-cs-rCZ/protection.xml similarity index 100% rename from app/src/main/res/values-cs-rCZ/protection.xml rename to core/src/main/res/values-cs-rCZ/protection.xml diff --git a/app/src/main/res/values-cy-rGB/protection.xml b/core/src/main/res/values-cy-rGB/protection.xml similarity index 100% rename from app/src/main/res/values-cy-rGB/protection.xml rename to core/src/main/res/values-cy-rGB/protection.xml diff --git a/app/src/main/res/values-de-rDE/protection.xml b/core/src/main/res/values-de-rDE/protection.xml similarity index 100% rename from app/src/main/res/values-de-rDE/protection.xml rename to core/src/main/res/values-de-rDE/protection.xml diff --git a/app/src/main/res/values-el-rGR/protection.xml b/core/src/main/res/values-el-rGR/protection.xml similarity index 100% rename from app/src/main/res/values-el-rGR/protection.xml rename to core/src/main/res/values-el-rGR/protection.xml diff --git a/app/src/main/res/values-es-rES/protection.xml b/core/src/main/res/values-es-rES/protection.xml similarity index 100% rename from app/src/main/res/values-es-rES/protection.xml rename to core/src/main/res/values-es-rES/protection.xml diff --git a/app/src/main/res/values-fi-rFI/protection.xml b/core/src/main/res/values-fi-rFI/protection.xml similarity index 100% rename from app/src/main/res/values-fi-rFI/protection.xml rename to core/src/main/res/values-fi-rFI/protection.xml diff --git a/app/src/main/res/values-fr-rFR/protection.xml b/core/src/main/res/values-fr-rFR/protection.xml similarity index 100% rename from app/src/main/res/values-fr-rFR/protection.xml rename to core/src/main/res/values-fr-rFR/protection.xml diff --git a/app/src/main/res/values-ga-rIE/protection.xml b/core/src/main/res/values-ga-rIE/protection.xml similarity index 100% rename from app/src/main/res/values-ga-rIE/protection.xml rename to core/src/main/res/values-ga-rIE/protection.xml diff --git a/app/src/main/res/values-hr-rHR/protection.xml b/core/src/main/res/values-hr-rHR/protection.xml similarity index 100% rename from app/src/main/res/values-hr-rHR/protection.xml rename to core/src/main/res/values-hr-rHR/protection.xml diff --git a/app/src/main/res/values-it-rIT/protection.xml b/core/src/main/res/values-it-rIT/protection.xml similarity index 100% rename from app/src/main/res/values-it-rIT/protection.xml rename to core/src/main/res/values-it-rIT/protection.xml diff --git a/app/src/main/res/values-iw-rIL/protection.xml b/core/src/main/res/values-iw-rIL/protection.xml similarity index 100% rename from app/src/main/res/values-iw-rIL/protection.xml rename to core/src/main/res/values-iw-rIL/protection.xml diff --git a/app/src/main/res/values-ja-rJP/protection.xml b/core/src/main/res/values-ja-rJP/protection.xml similarity index 100% rename from app/src/main/res/values-ja-rJP/protection.xml rename to core/src/main/res/values-ja-rJP/protection.xml diff --git a/app/src/main/res/values-ko-rKR/protection.xml b/core/src/main/res/values-ko-rKR/protection.xml similarity index 100% rename from app/src/main/res/values-ko-rKR/protection.xml rename to core/src/main/res/values-ko-rKR/protection.xml diff --git a/app/src/main/res/values-lt-rLT/protection.xml b/core/src/main/res/values-lt-rLT/protection.xml similarity index 100% rename from app/src/main/res/values-lt-rLT/protection.xml rename to core/src/main/res/values-lt-rLT/protection.xml diff --git a/app/src/main/res/values-nl-rNL/protection.xml b/core/src/main/res/values-nl-rNL/protection.xml similarity index 100% rename from app/src/main/res/values-nl-rNL/protection.xml rename to core/src/main/res/values-nl-rNL/protection.xml diff --git a/app/src/main/res/values-pl-rPL/protection.xml b/core/src/main/res/values-pl-rPL/protection.xml similarity index 100% rename from app/src/main/res/values-pl-rPL/protection.xml rename to core/src/main/res/values-pl-rPL/protection.xml diff --git a/app/src/main/res/values-pt-rBR/protection.xml b/core/src/main/res/values-pt-rBR/protection.xml similarity index 100% rename from app/src/main/res/values-pt-rBR/protection.xml rename to core/src/main/res/values-pt-rBR/protection.xml diff --git a/app/src/main/res/values-pt-rPT/protection.xml b/core/src/main/res/values-pt-rPT/protection.xml similarity index 100% rename from app/src/main/res/values-pt-rPT/protection.xml rename to core/src/main/res/values-pt-rPT/protection.xml diff --git a/app/src/main/res/values-ro-rRO/protection.xml b/core/src/main/res/values-ro-rRO/protection.xml similarity index 100% rename from app/src/main/res/values-ro-rRO/protection.xml rename to core/src/main/res/values-ro-rRO/protection.xml diff --git a/app/src/main/res/values-ru-rRU/protection.xml b/core/src/main/res/values-ru-rRU/protection.xml similarity index 100% rename from app/src/main/res/values-ru-rRU/protection.xml rename to core/src/main/res/values-ru-rRU/protection.xml diff --git a/app/src/main/res/values-sk-rSK/protection.xml b/core/src/main/res/values-sk-rSK/protection.xml similarity index 100% rename from app/src/main/res/values-sk-rSK/protection.xml rename to core/src/main/res/values-sk-rSK/protection.xml diff --git a/app/src/main/res/values-sl-rSI/protection.xml b/core/src/main/res/values-sl-rSI/protection.xml similarity index 100% rename from app/src/main/res/values-sl-rSI/protection.xml rename to core/src/main/res/values-sl-rSI/protection.xml diff --git a/app/src/main/res/values-sv-rSE/protection.xml b/core/src/main/res/values-sv-rSE/protection.xml similarity index 100% rename from app/src/main/res/values-sv-rSE/protection.xml rename to core/src/main/res/values-sv-rSE/protection.xml diff --git a/app/src/main/res/values-tr-rTR/protection.xml b/core/src/main/res/values-tr-rTR/protection.xml similarity index 100% rename from app/src/main/res/values-tr-rTR/protection.xml rename to core/src/main/res/values-tr-rTR/protection.xml diff --git a/app/src/main/res/values-zh-rCN/protection.xml b/core/src/main/res/values-zh-rCN/protection.xml similarity index 100% rename from app/src/main/res/values-zh-rCN/protection.xml rename to core/src/main/res/values-zh-rCN/protection.xml diff --git a/app/src/main/res/values/protection.xml b/core/src/main/res/values/protection.xml similarity index 100% rename from app/src/main/res/values/protection.xml rename to core/src/main/res/values/protection.xml diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index af37bbf430..7ee787c54d 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -127,6 +127,10 @@ m d + + Wrong password + Passwords don\'t match + Basal values not aligned to hours: %1$s Basal value replaced by minimal supported value: %1$s diff --git a/dana/src/main/res/values/strings.xml b/dana/src/main/res/values/strings.xml index bf26707ffc..d086aab28f 100644 --- a/dana/src/main/res/values/strings.xml +++ b/dana/src/main/res/values/strings.xml @@ -67,7 +67,6 @@ Updating basal rates Setting temp basal Waiting for time synchronization (%1$d sec) - Wrong password Wrong pump password! Alarms Basal Hours From c753ed6859a59c6a5d99a4231b347ceec455a6f2 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Tue, 18 Aug 2020 22:39:52 +0200 Subject: [PATCH 27/40] Remove some more unused Omnipod code --- .../pump/omnipod/dialogs/PodManagementActivity.kt | 4 ++-- .../dialogs/wizard/pages/InitPodRefreshAction.java | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt index 25843f8d80..47ef877239 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt @@ -94,7 +94,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() { fun initPodAction() { val pagerSettings = WizardPagerSettings() - var refreshAction = InitPodRefreshAction(injector, this, PodActionType.InitPod) + var refreshAction = InitPodRefreshAction(injector, PodActionType.InitPod) pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext) pagerSettings.setFinishStringResourceId(R.string.close) @@ -122,7 +122,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() { fun removePodAction() { val pagerSettings = WizardPagerSettings() - var refreshAction = InitPodRefreshAction(injector, this, PodActionType.RemovePod) + var refreshAction = InitPodRefreshAction(injector, PodActionType.RemovePod) pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext) pagerSettings.setFinishStringResourceId(R.string.close) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java index 794a40100d..80935bad7c 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java @@ -16,7 +16,6 @@ import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager; -import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity; import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -27,7 +26,6 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; */ public class InitPodRefreshAction extends AbstractCancelAction implements FinishActionInterface { - private PodManagementActivity podManagementActivity; private PodActionType actionType; @Inject PodStateManager podStateManager; @@ -36,9 +34,8 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish @Inject NSUpload nsUpload; @Inject DatabaseHelperInterface databaseHelper; - public InitPodRefreshAction(HasAndroidInjector injector, PodManagementActivity podManagementActivity, PodActionType actionType) { + public InitPodRefreshAction(HasAndroidInjector injector, PodActionType actionType) { injector.androidInjector().inject(this); - this.podManagementActivity = podManagementActivity; this.actionType = actionType; } @@ -47,10 +44,6 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish if (cancelReason != null && cancelReason.trim().length() > 0) { this.cancelActionText = cancelReason; } - - if (this.cancelActionText.equals("Cancel")) { - //AapsOmnipodManager.getInstance().resetPodStatus(); - } } @Override @@ -83,7 +76,6 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish } } - @Override public String getFinishActionText() { return "Finish_OK"; From f58874d666e961289e62b485f5a532e4c9c8a8d4 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Tue, 18 Aug 2020 22:33:02 +0100 Subject: [PATCH 28/40] - added injection into RileyLinkCommunicationManager... It must have been removed... --- .../pump/common/hw/rileylink/RileyLinkCommunicationManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java index aeb77cb014..60faf2c9aa 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java @@ -53,6 +53,7 @@ public abstract class RileyLinkCommunicationManager { public RileyLinkCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) { this.injector = injector; + this.injector.androidInjector().inject(this); this.rfspy = rfspy; } From e39c222203f3f3e22d276fb94e6d80ec77a953f2 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Tue, 18 Aug 2020 23:47:58 +0200 Subject: [PATCH 29/40] Small Dagger improvements --- .../medtronic/comm/MedtronicCommunicationManager.java | 4 ++-- .../pump/medtronic/service/RileyLinkMedtronicService.java | 2 +- .../pump/omnipod/comm/OmnipodCommunicationManager.java | 8 ++------ .../hw/rileylink/RileyLinkCommunicationManager.java | 8 +++----- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java index b71dec4621..0742cb85c1 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java @@ -74,8 +74,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager private boolean doWakeUpBeforeCommand = true; - public MedtronicCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) { - super(injector, rfspy); + public MedtronicCommunicationManager(HasAndroidInjector injector) { + super(injector); medtronicPumpStatus.previousConnection = sp.getLong( RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L); } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java index 9013b578f4..a75981d1f2 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java @@ -103,7 +103,7 @@ public class RileyLinkMedtronicService extends RileyLinkService { rfspy.startReader(); // init rileyLinkCommunicationManager - medtronicCommunicationManager = new MedtronicCommunicationManager(injector, rfspy); + medtronicCommunicationManager = new MedtronicCommunicationManager(injector); medtronicUIComm = new MedtronicUIComm(injector, aapsLogger, medtronicUtil, medtronicUIPostprocessor, medtronicCommunicationManager); aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly constructed"); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java index abecf6689b..c75f5f01c5 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java @@ -53,15 +53,11 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; // TODO make singleton and rename to OmnipodRileyLinkCommunicationManager public class OmnipodCommunicationManager extends RileyLinkCommunicationManager { - @Inject public AAPSLogger aapsLogger; @Inject OmnipodPumpStatus omnipodPumpStatus; - //@Inject OmnipodPumpPlugin omnipodPumpPlugin; - //@Inject RileyLinkServiceData rileyLinkServiceData; - //@Inject ServiceTaskExecutor serviceTaskExecutor; @Inject - public OmnipodCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) { - super(injector, rfspy); + public OmnipodCommunicationManager(HasAndroidInjector injector) { + super(injector); } @Inject diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java index 60faf2c9aa..54cc23d779 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java @@ -35,26 +35,24 @@ public abstract class RileyLinkCommunicationManager { @Inject protected SP sp; @Inject protected RileyLinkServiceData rileyLinkServiceData; @Inject protected ServiceTaskExecutor serviceTaskExecutor; - + @Inject protected RFSpy rfspy; private final int SCAN_TIMEOUT = 1500; private final int ALLOWED_PUMP_UNREACHABLE = 10 * 60 * 1000; // 10 minutes public final HasAndroidInjector injector; - protected final RFSpy rfspy; + 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; // protected PumpStatus pumpStatus; private long nextWakeUpRequired = 0L; - private int timeoutCount = 0; - public RileyLinkCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) { + public RileyLinkCommunicationManager(HasAndroidInjector injector) { this.injector = injector; this.injector.androidInjector().inject(this); - this.rfspy = rfspy; } From 5d83e2a26b986bfe275afedf3ce86271f1912e4f Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Wed, 19 Aug 2020 02:36:33 +0200 Subject: [PATCH 30/40] Omnipod: if Cancel bolus has been pressed before the bolus command has been executed, await bolus command execution before cancelling --- .../pump/omnipod/comm/OmnipodManager.java | 15 +++++++++++++ .../driver/comm/AapsOmnipodManager.java | 22 ++++++++++++++++++- omnipod/src/main/res/values/strings.xml | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodManager.java index 876472fd1f..a6576583ae 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodManager.java @@ -61,6 +61,8 @@ public class OmnipodManager { private PodStateManager podStateManager; private ActiveBolusData activeBolusData; + private SingleSubject bolusCommandExecutionSubject; + private final Object bolusDataMutex = new Object(); private AAPSLogger aapsLogger; @@ -277,12 +279,16 @@ public class OmnipodManager { logStartingCommandExecution("bolus [units=" + units + ", acknowledgementBeep=" + acknowledgementBeep + ", completionBeep=" + completionBeep + "]"); + bolusCommandExecutionSubject = SingleSubject.create(); + CommandDeliveryStatus commandDeliveryStatus = CommandDeliveryStatus.SUCCESS; try { executeAndVerify(() -> communicationService.executeAction(new BolusAction(podStateManager, units, acknowledgementBeep, completionBeep))); } catch (OmnipodException ex) { if (ex.isCertainFailure()) { + bolusCommandExecutionSubject.onSuccess(false); + bolusCommandExecutionSubject = null; throw ex; } @@ -319,6 +325,11 @@ public class OmnipodManager { activeBolusData = new ActiveBolusData(units, startDate, bolusCompletionSubject, disposables); } + // Return successful command execution AFTER storing activeBolusData + // Otherwise, hasActiveBolus() would return false and the caller would not cancel the bolus. + bolusCommandExecutionSubject.onSuccess(true); + bolusCommandExecutionSubject = null; + disposables.add(Completable.complete() // .delay(estimatedRemainingBolusDuration.getMillis() + 250, TimeUnit.MILLISECONDS) // .observeOn(Schedulers.io()) // @@ -486,6 +497,10 @@ public class OmnipodManager { } } + public SingleSubject getBolusCommandExecutionSubject() { + return bolusCommandExecutionSubject; + } + // Only works for commands with nonce resyncable message blocks // FIXME method is too big, needs refactoring private StatusResponse executeAndVerify(Supplier supplier) { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java index 3e5e2db4f7..bfd1900e67 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java @@ -75,6 +75,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; import io.reactivex.disposables.Disposable; +import io.reactivex.subjects.SingleSubject; @Singleton public class AapsOmnipodManager implements IOmnipodManager { @@ -294,18 +295,37 @@ public class AapsOmnipodManager implements IOmnipodManager { @Override public PumpEnactResult cancelBolus() { + SingleSubject bolusCommandExecutionSubject = delegate.getBolusCommandExecutionSubject(); + if (bolusCommandExecutionSubject != null) { + // Wait until the bolus command has actually been executed before sending the cancel bolus command + aapsLogger.debug(LTag.PUMP, "Cancel bolus was requested, but the bolus command is still being executed. Awaiting bolus command execution"); + boolean bolusCommandSuccessfullyExecuted = bolusCommandExecutionSubject.blockingGet(); + if (bolusCommandSuccessfullyExecuted) { + aapsLogger.debug(LTag.PUMP, "Bolus command successfully executed. Proceeding bolus cancellation"); + } else { + aapsLogger.debug(LTag.PUMP, "Not cancelling bolus: bolus command failed"); + String comment = getStringResource(R.string.omnipod_bolus_did_not_succeed); + addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, comment); + return new PumpEnactResult(injector).success(true).enacted(false).comment(comment); + } + } + long time = System.currentTimeMillis(); String comment = null; - while (delegate.hasActiveBolus()) { + for (int i = 1; delegate.hasActiveBolus(); i++) { + aapsLogger.debug(LTag.PUMP, "Attempting to cancel bolus (#{})", i); try { delegate.cancelBolus(isBolusBeepsEnabled()); + aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus", i); addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null); return new PumpEnactResult(injector).success(true).enacted(true); } catch (PodFaultException ex) { + aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus (implicitly because of a Pod Fault)"); showPodFaultErrorDialog(ex.getFaultEvent().getFaultEventCode(), null); addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null); return new PumpEnactResult(injector).success(true).enacted(true); } catch (Exception ex) { + aapsLogger.debug(LTag.PUMP, "Failed to cancel bolus", ex); comment = handleAndTranslateException(ex); } } diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index f21de6a9e9..5b971f7fef 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -148,6 +148,7 @@ %1$s and %2$s %1$s ago Waiting for RileyLink connection... + Bolus did not succeed %1$d minute From 680f3f94d6b1881a92a06712197e003608d5c164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Wed, 19 Aug 2020 13:06:21 +0200 Subject: [PATCH 31/40] Inject AndroidInjector into RileyLinkCommunicationManager using dagger --- .../medtronic/comm/MedtronicCommunicationManager.java | 9 ++++++--- .../pump/omnipod/comm/OmnipodCommunicationManager.java | 5 ++--- .../hw/rileylink/RileyLinkCommunicationManager.java | 9 +-------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java index 0742cb85c1..c77736c587 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java @@ -11,7 +11,6 @@ import java.util.Map; import javax.inject.Inject; -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; @@ -73,9 +72,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); } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java index c75f5f01c5..bea8e53f46 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java @@ -7,7 +7,6 @@ import java.util.List; import javax.inject.Inject; -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; @@ -55,9 +54,9 @@ 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 diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java index 54cc23d779..729ecf9f1a 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkCommunicationManager.java @@ -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 { From ba69b2ffd3ed5357102446b6babecda6a3970b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Wed, 19 Aug 2020 13:08:34 +0200 Subject: [PATCH 32/40] Turn MedtronicCommunicationManager into a singleton --- .../pump/medtronic/comm/MedtronicCommunicationManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java index c77736c587..59211dfa9d 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus; @@ -55,6 +56,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; From 3191b542085582924d14a625954b5b113220a260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Wed, 19 Aug 2020 13:09:01 +0200 Subject: [PATCH 33/40] Turn OmnipodCommunicationManager into a singleton --- .../pump/omnipod/comm/OmnipodCommunicationManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java index bea8e53f46..661f8b8140 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java @@ -6,6 +6,7 @@ import java.util.Collections; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; @@ -49,7 +50,8 @@ 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; From 303faf825a21627db2426374a3e2d6f7e73cc30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Wed, 19 Aug 2020 13:09:27 +0200 Subject: [PATCH 34/40] Clean up imports --- .../pump/medtronic/comm/MedtronicCommunicationManager.java | 1 - .../plugins/pump/omnipod/comm/OmnipodCommunicationManager.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java index 59211dfa9d..0a0fb98e22 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java @@ -17,7 +17,6 @@ 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; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java index 661f8b8140..48cd74016c 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/OmnipodCommunicationManager.java @@ -8,13 +8,11 @@ import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; -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; From f3bb80c25bd890a896a505ed00b676e4a456b741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Wed, 19 Aug 2020 13:10:02 +0200 Subject: [PATCH 35/40] Use dagger to inject MedtronicCommunicationManager into RileyLinkMedtronicService --- .../pump/medtronic/service/RileyLinkMedtronicService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java index a75981d1f2..c354b7ff4c 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java @@ -41,9 +41,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; @@ -102,8 +102,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"); From a42c5e701e74a025857ae5d7e9502e735b28fc0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Wed, 19 Aug 2020 13:10:27 +0200 Subject: [PATCH 36/40] Add @Inject to RileyLinkMedtronicService constructor `@Inject`ed types should always have the annotation on their constructor, otherwise dependency resolution might break. --- .../pump/medtronic/service/RileyLinkMedtronicService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java index c354b7ff4c..f59e529de6 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java @@ -55,8 +55,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(); } From eb909ab9240dc65fd169660a156fa84f636a98c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= Date: Wed, 19 Aug 2020 13:11:29 +0200 Subject: [PATCH 37/40] Turn RileyLinkMedtronicService into a singleton --- .../pump/medtronic/service/RileyLinkMedtronicService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java index f59e529de6..636d138a6f 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java @@ -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; From 557e5ee0e9295513d90af416693364a2e24ef353 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Thu, 20 Aug 2020 01:22:03 +0200 Subject: [PATCH 38/40] Update Omnipod upstream version info --- omnipod/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/omnipod/build.gradle b/omnipod/build.gradle index e3b599e52b..96198d34ec 100644 --- a/omnipod/build.gradle +++ b/omnipod/build.gradle @@ -18,8 +18,8 @@ android { // OMNIPOD: for usage in Firebase event during testing phase buildConfigField "String", "VERSION", '"2.7-omnipod-0.4.1-SNAPSHOT"' // OMNIPOD: Keep track of what commit from the main repository we're on, these fields aren't actually used anywhere - buildConfigField "String", "DEV_VERSION", '"2.6.7-dev"' - buildConfigField "String", "DEV_VERSION_COMMIT", '"65c8cc98804cfc366239ad2bedb2dd98e3e4f3c2"' + buildConfigField "String", "DEV_VERSION", '"2.7.0-rc3"' + buildConfigField "String", "DEV_VERSION_COMMIT", '"a4b2ce32a59a617eed9ad006e85efdeec51cd899"' buildConfigField "String", "DEV_VERSION_COMMIT_DATE", '"16.8.2020"' // 16th of August } From 0e9adda3a4d9b23eb71380a31d7aad781a8c4e28 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Thu, 20 Aug 2020 02:20:05 +0200 Subject: [PATCH 39/40] Make sure that after restart, bolus treatment is added when the app is killed during a bolus --- .../androidaps/events/EventAppInitialized.kt | 0 .../pump/omnipod/OmnipodPumpPlugin.java | 75 ++++++++----------- .../driver/comm/AapsOmnipodManager.java | 59 ++++++++++----- .../pump/omnipod/util/OmnipodConst.java | 3 +- omnipod/src/main/res/values/strings.xml | 6 +- 5 files changed, 79 insertions(+), 64 deletions(-) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventAppInitialized.kt (100%) diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventAppInitialized.kt b/core/src/main/java/info/nightscout/androidaps/events/EventAppInitialized.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/events/EventAppInitialized.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventAppInitialized.kt diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 7a861f8878..e82d8aeffc 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -30,6 +30,7 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.events.EventAppInitialized; import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.interfaces.ActivePluginProvider; @@ -61,12 +62,14 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInt import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager; 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.ui.OmnipodUIComm; import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask; import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged; import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState; import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; +import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.Round; @@ -87,6 +90,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump private final RileyLinkServiceData rileyLinkServiceData; private final ServiceTaskExecutor serviceTaskExecutor; private final OmnipodPumpStatus omnipodPumpStatus; + private final AapsOmnipodManager aapsOmnipodManager; + private final OmnipodUtil omnipodUtil; private CompositeDisposable disposable = new CompositeDisposable(); @@ -95,7 +100,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump protected boolean isRefresh = false; private boolean isInitialized = false; - private RileyLinkOmnipodService rileyLinkOmnipodService; private boolean isBusy = false; @@ -119,13 +123,14 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump SP sp, OmnipodPumpStatus omnipodPumpStatus, PodStateManager podStateManager, + AapsOmnipodManager aapsOmnipodManager, CommandQueueProvider commandQueue, FabricPrivacy fabricPrivacy, RileyLinkServiceData rileyLinkServiceData, ServiceTaskExecutor serviceTaskExecutor, - DateUtil dateUtil + DateUtil dateUtil, + OmnipodUtil omnipodUtil ) { - super(new PluginDescription() // .mainType(PluginType.PUMP) // .fragmentClass(OmnipodFragment.class.getName()) // @@ -134,26 +139,25 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump .preferencesId(R.xml.pref_omnipod) // .description(R.string.description_pump_omnipod), // PumpType.Insulet_Omnipod, - injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy, dateUtil - ); + injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy, dateUtil); this.podStateManager = podStateManager; this.rileyLinkServiceData = rileyLinkServiceData; this.serviceTaskExecutor = serviceTaskExecutor; this.omnipodPumpStatus = omnipodPumpStatus; + this.aapsOmnipodManager = aapsOmnipodManager; + this.omnipodUtil = omnipodUtil; displayConnectionMessages = false; this.serviceConnection = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { - aapsLogger.debug(LTag.PUMP, "RileyLinkOmnipodService is disconnected"); rileyLinkOmnipodService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { - aapsLogger.debug(LTag.PUMP, "RileyLinkOmnipodService is connected"); RileyLinkOmnipodService.LocalBinder mLocalBinder = (RileyLinkOmnipodService.LocalBinder) service; rileyLinkOmnipodService = mLocalBinder.getServiceInstance(); @@ -172,7 +176,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump }).start(); } }; - } public PodStateManager getPodStateManager() { @@ -199,6 +202,27 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump rileyLinkOmnipodService.verifyConfiguration(); }, fabricPrivacy::logException) ); + disposable.add(rxBus + .toObservable(EventAppInitialized.class) + .observeOn(Schedulers.io()) + .subscribe(event -> { + // See if a bolus was active before the app previously exited + // If so, add it to history + // Needs to be done after EventAppInitialized because otherwise, TreatmentsPlugin.onStart() hasn't been called yet + // so it didn't initialize a TreatmentService yet, resulting in a NullPointerException + if (sp.contains(OmnipodConst.Prefs.CurrentBolus)) { + String currentBolusString = sp.getString(OmnipodConst.Prefs.CurrentBolus, ""); + aapsLogger.warn(LTag.PUMP, "Found active bolus in SP. Adding Treatment: {}", currentBolusString); + try { + DetailedBolusInfo detailedBolusInfo = omnipodUtil.getGsonInstance().fromJson(currentBolusString, DetailedBolusInfo.class); + aapsOmnipodManager.addBolusToHistory(detailedBolusInfo); + } catch (Exception ex) { + aapsLogger.error(LTag.PUMP, "Failed to add active bolus to history", ex); + } + sp.remove(OmnipodConst.Prefs.CurrentBolus); + } + }, fabricPrivacy::logException) + ); super.onStart(); } @@ -215,7 +239,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump @Override public void initPumpStatusData() { - omnipodPumpStatus.lastConnection = sp.getLong(RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L); omnipodPumpStatus.lastDataTime = omnipodPumpStatus.lastConnection; omnipodPumpStatus.previousConnection = omnipodPumpStatus.lastConnection; @@ -267,7 +290,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } } - @Override public Class getServiceClass() { return RileyLinkOmnipodService.class; @@ -278,20 +300,17 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return this.omnipodPumpStatus; } - @Override public String deviceID() { return "Omnipod"; } - // Pump Plugin private boolean isServiceSet() { return rileyLinkOmnipodService != null; } - @Override public boolean isInitialized() { if (displayConnectionMessages) @@ -299,7 +318,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return isServiceSet() && isInitialized; } - @Override public boolean isBusy() { if (displayConnectionMessages) @@ -321,19 +339,16 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return false; } - @Override public void resetRileyLinkConfiguration() { rileyLinkOmnipodService.resetRileyLinkConfiguration(); } - @Override public boolean hasTuneUp() { return false; } - @Override public void doTuneUpDevice() { //rileyLinkOmnipodService.doTuneUpDevice(); @@ -344,7 +359,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump rxBus.send(new EventOmnipodPumpValuesChanged()); } - @Override public RileyLinkOmnipodService getRileyLinkService() { return rileyLinkOmnipodService; @@ -354,7 +368,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return rileyLinkOmnipodService.getDeviceCommandExecutor(); } - private synchronized void clearBusyQueue() { if (busyTimestamps.size() == 0) { @@ -381,7 +394,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } - @Override public boolean isConnected() { if (displayConnectionMessages) @@ -389,7 +401,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return isServiceSet() && rileyLinkOmnipodService.isInitialized(); } - @Override public boolean isConnecting() { if (displayConnectionMessages) @@ -397,7 +408,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return !isServiceSet() || !rileyLinkOmnipodService.isInitialized(); } - @Override public boolean isSuspended() { return !podStateManager.isPodRunning() || podStateManager.isSuspended(); @@ -405,10 +415,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump @Override public void getPumpStatus() { - if (firstRun) { initializePump(!isRefresh); triggerUIChange(); + } else if (!omnipodStatusRequestList.isEmpty()) { List removeList = new ArrayList<>(); @@ -492,14 +502,12 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump isRefresh = true; } - // FIXME do we actually need this? If a user presses refresh during an action, // I suppose the GetStatusCommand would just be queued? private void setRefreshButtonEnabled(boolean enabled) { rxBus.send(new EventOmnipodRefreshButtonState(enabled)); } - private void initializePump(boolean realInit) { aapsLogger.info(LTag.PUMP, getLogPrefix() + "initializePump - start"); @@ -532,7 +540,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump this.firstRun = false; } - @Override public boolean isThisProfileSet(Profile profile) { @@ -546,7 +553,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return (currentProfile.areProfileBasalPatternsSame(profile)); } - @Override public long lastDataTime() { if (omnipodPumpStatus.lastConnection != 0) { @@ -556,7 +562,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return System.currentTimeMillis(); } - @Override public double getBaseBasalRate() { @@ -568,35 +573,29 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } } - @Override public double getReservoirLevel() { return omnipodPumpStatus.reservoirRemainingUnits; } - @Override public int getBatteryLevel() { return 75; } - @Override protected void triggerUIChange() { rxBus.send(new EventOmnipodPumpValuesChanged()); } - @Override public boolean isFakingTempsByExtendedBoluses() { return false; } - @Override @NonNull protected PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) { - aapsLogger.info(LTag.PUMP, getLogPrefix() + "deliverBolus - {}", detailedBolusInfo); setRefreshButtonEnabled(false); @@ -647,20 +646,17 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump //finishAction("Bolus"); } - private void incrementStatistics(String statsKey) { long currentCount = sp.getLong(statsKey, 0L); currentCount++; sp.putLong(statsKey, currentCount); } - // if enforceNew===true current temp basal is canceled and new TBR set (duration is prolonged), // if false and the same rate is requested enacted=false and success=true is returned and TBR is not changed @Override public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) { - setRefreshButtonEnabled(false); aapsLogger.info(LTag.PUMP, getLogPrefix() + "setTempBasalAbsolute: rate: {}, duration={}", absoluteRate, durationInMinutes); @@ -709,7 +705,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return omnipodPumpStatus.getTemporaryBasal(); } - protected void finishAction(String overviewKey) { if (overviewKey != null) rxBus.send(new EventRefreshOverview(overviewKey, false)); @@ -719,7 +714,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump setRefreshButtonEnabled(true); } - @Override public PumpEnactResult cancelTempBasal(boolean enforceNew) { @@ -802,7 +796,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return result; } - // OPERATIONS not supported by Pump or Plugin protected List customActions = null; @@ -813,7 +806,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump @Override public List getCustomActions() { - if (customActions == null) { this.customActions = Arrays.asList( customActionResetRLConfig //, @@ -829,7 +821,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump OmnipodCustomActionType mcat = (OmnipodCustomActionType) customActionType; switch (mcat) { - case ResetRileyLinkConfiguration: { serviceTaskExecutor.startTask(new ResetRileyLinkConfigurationTask(getInjector())); } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java index bfd1900e67..645802bd87 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java @@ -71,6 +71,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManage import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistoryEntryType; import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException; +import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -89,6 +90,7 @@ public class AapsOmnipodManager implements IOmnipodManager { private final ActivePluginProvider activePlugin; private final OmnipodPumpStatus pumpStatus; private final Context context; + private final SP sp; private final OmnipodManager delegate; private DatabaseHelperInterface databaseHelper; @@ -119,6 +121,7 @@ public class AapsOmnipodManager implements IOmnipodManager { this.pumpStatus = pumpStatus; this.context = context; this.databaseHelper = databaseHelper; + this.sp = sp; delegate = new OmnipodManager(aapsLogger, sp, communicationService, podStateManager); } @@ -271,26 +274,43 @@ public class AapsOmnipodManager implements IOmnipodManager { showErrorDialog(getStringResource(R.string.omnipod_bolus_failed_uncertain), R.raw.boluserror); } + detailedBolusInfo.date = bolusStarted.getTime(); + detailedBolusInfo.source = Source.PUMP; + + // Store the current bolus for in case the app crashes, gets killed, the phone dies or whatever before the bolus finishes + // If we have a stored value for the current bolus on startup, we'll create a Treatment for it + // However this can potentially be hours later if for example your phone died and you can't charge it + // FIXME !!! + // The proper solution here would be to create a treatment right after the bolus started, + // and update that treatment after the bolus has finished in case the actual units delivered don't match the requested bolus units + // That way, the bolus would immediately be sent to NS so in case the phone dies you could still see the bolus + // Unfortunately this doesn't work because + // a) when cancelling a bolus within a few seconds of starting it, after updating the Treatment, + // we get a new treatment event from NS containing the originally created treatment with the original insulin amount. + // This event is processed in TreatmentService.createTreatmentFromJsonIfNotExists(). + // Opposed to what the name of this method suggests, it does createOrUpdate, + // overwriting the insulin delivered with the original value. + // So practically it seems impossible to update a Treatment when using NS + // b) we only send newly created treatments to NS, so the insulin amount in NS would never be updated + // + // I discussed this with the AAPS team but nobody seems to care so we're stuck with this ugly workaround for now + try { + sp.putString(OmnipodConst.Prefs.CurrentBolus, omnipodUtil.getGsonInstance().toJson(detailedBolusInfo)); + } catch (Exception ex) { + aapsLogger.error(LTag.PUMP, "Failed to store current bolus to SP", ex); + } + // Wait for the bolus to finish OmnipodManager.BolusDeliveryResult bolusDeliveryResult = bolusCommandResult.getDeliveryResultSubject().blockingGet(); - double unitsDelivered = bolusDeliveryResult.getUnitsDelivered(); + detailedBolusInfo.insulin = bolusDeliveryResult.getUnitsDelivered(); - long pumpId = addSuccessToHistory(bolusStarted.getTime(), PodHistoryEntryType.SetBolus, unitsDelivered + ";" + detailedBolusInfo.carbs); + addBolusToHistory(detailedBolusInfo); - detailedBolusInfo.date = bolusStarted.getTime(); - detailedBolusInfo.insulin = unitsDelivered; - detailedBolusInfo.pumpId = pumpId; - detailedBolusInfo.source = Source.PUMP; + sp.remove(OmnipodConst.Prefs.CurrentBolus); - activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false); - - if (podStateManager.hasFaultEvent()) { - showPodFaultErrorDialog(podStateManager.getFaultEvent().getFaultEventCode()); - } - - return new PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(unitsDelivered); + return new PumpEnactResult(injector).success(true).enacted(true).bolusDelivered(detailedBolusInfo.insulin); } @Override @@ -310,19 +330,18 @@ public class AapsOmnipodManager implements IOmnipodManager { } } - long time = System.currentTimeMillis(); String comment = null; for (int i = 1; delegate.hasActiveBolus(); i++) { aapsLogger.debug(LTag.PUMP, "Attempting to cancel bolus (#{})", i); try { delegate.cancelBolus(isBolusBeepsEnabled()); aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus", i); - addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null); + addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, null); return new PumpEnactResult(injector).success(true).enacted(true); } catch (PodFaultException ex) { aapsLogger.debug(LTag.PUMP, "Successfully cancelled bolus (implicitly because of a Pod Fault)"); showPodFaultErrorDialog(ex.getFaultEvent().getFaultEventCode(), null); - addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null); + addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, null); return new PumpEnactResult(injector).success(true).enacted(true); } catch (Exception ex) { aapsLogger.debug(LTag.PUMP, "Failed to cancel bolus", ex); @@ -330,7 +349,7 @@ public class AapsOmnipodManager implements IOmnipodManager { } } - addFailureToHistory(time, PodHistoryEntryType.CancelBolus, comment); + addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CancelBolus, comment); return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); } @@ -483,6 +502,12 @@ public class AapsOmnipodManager implements IOmnipodManager { return delegate.isPodRunning(); } + public void addBolusToHistory(DetailedBolusInfo detailedBolusInfo) { + long pumpId = addSuccessToHistory(detailedBolusInfo.date, PodHistoryEntryType.SetBolus, detailedBolusInfo.insulin + ";" + detailedBolusInfo.carbs); + detailedBolusInfo.pumpId = pumpId; + activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false); + } + private void reportImplicitlyCanceledTbr() { //TreatmentsPlugin plugin = TreatmentsPlugin.getPlugin(); TreatmentsInterface plugin = activePlugin.getActiveTreatments(); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java index 3f2aa3afca..81bbf5d501 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java @@ -14,6 +14,7 @@ public class OmnipodConst { public static class Prefs { public static final String PodState = Prefix + "pod_state"; + public static final String CurrentBolus = Prefix + "current_bolus"; public static final int BeepBasalEnabled = R.string.key_omnipod_beep_basal_enabled; public static final int BeepBolusEnabled = R.string.key_omnipod_beep_bolus_enabled; public static final int BeepSMBEnabled = R.string.key_omnipod_beep_smb_enabled; @@ -26,11 +27,9 @@ public class OmnipodConst { public static final String StatsPrefix = "omnipod_"; public static final String FirstPumpStart = Prefix + "first_pump_use"; public static final String LastGoodPumpCommunicationTime = Prefix + "lastGoodPumpCommunicationTime"; - //public static final String LastGoodPumpFrequency = Prefix + "LastGoodPumpFrequency"; public static final String TBRsSet = StatsPrefix + "tbrs_set"; public static final String StandardBoluses = StatsPrefix + "std_boluses_delivered"; public static final String SMBBoluses = StatsPrefix + "smb_boluses_delivered"; - //public static final String LastPumpHistoryEntry = StatsPrefix + "pump_history_entry"; } public static final double POD_PULSE_SIZE = 0.05; diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index 5b971f7fef..17a4c6d407 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -93,9 +93,9 @@ Suspend Delivery Resume Delivery Unknown Entry - %1$.1f U - %1$.1f U, CH=%2$.1f g - Rate: %1$.1f U, Duration: %2$d min + %1$.2f U + %1$.2f U, CH=%2$.1f g + Rate: %1$.2f U, Duration: %2$d min If you press OK, the Pod state will be forcibly reset and you will not be able to communicate with the Pod anymore. Do this only if you can not communicate with the Pod anymore. If you can still communicate with the Pod, please use the Deactivate Pod option. Pod History not available at the moment. Fill the Pod From 7d63671d7b6da0ea9bcf4cf97f657d738c359e33 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Thu, 20 Aug 2020 02:30:15 +0200 Subject: [PATCH 40/40] fix import --- .../dependencyInjection/FragmentsModule.kt | 2 +- .../dependencyInjection/OmnipodModule.kt | 26 +++++++++---------- .../dependencyInjection/ServicesModule.kt | 2 +- settings.gradle | 3 +-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt index cf9f7577fc..cde5137ac9 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt @@ -66,7 +66,7 @@ abstract class FragmentsModule { @ContributesAndroidInjector abstract fun contributesLoopFragment(): LoopFragment @ContributesAndroidInjector abstract fun contributesMaintenanceFragment(): MaintenanceFragment @ContributesAndroidInjector abstract fun contributesMedtronicFragment(): MedtronicFragment - @ContributesAndroidInjector abstract fun contributesOmnipodFragment(): info.nightscout.androidaps.plugins.pump.omnipod.OmnipodFragment + @ContributesAndroidInjector abstract fun contributesOmnipodFragment(): OmnipodFragment @ContributesAndroidInjector abstract fun contributesNSProfileFragment(): NSProfileFragment @ContributesAndroidInjector abstract fun contributesNSClientFragment(): NSClientFragment @ContributesAndroidInjector abstract fun contributesSmsCommunicatorFragment(): SmsCommunicatorFragment diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt index 05903fcf8e..e7a8f31cfa 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt @@ -23,28 +23,28 @@ abstract class OmnipodModule { // Activities @ContributesAndroidInjector - abstract fun contributesPodManagementActivity(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity - @ContributesAndroidInjector abstract fun contributesPodHistoryActivity(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodHistoryActivity + abstract fun contributesPodManagementActivity(): PodManagementActivity + @ContributesAndroidInjector abstract fun contributesPodHistoryActivity(): PodHistoryActivity // Fragments - @ContributesAndroidInjector abstract fun initActionFragment(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitActionFragment - @ContributesAndroidInjector abstract fun removeActionFragment(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.removepod.RemoveActionFragment - @ContributesAndroidInjector abstract fun podInfoFragment(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodInfoFragment + @ContributesAndroidInjector abstract fun initActionFragment(): InitActionFragment + @ContributesAndroidInjector abstract fun removeActionFragment(): RemoveActionFragment + @ContributesAndroidInjector abstract fun podInfoFragment(): PodInfoFragment // Service @ContributesAndroidInjector - abstract fun omnipodCommunicationManagerProvider(): info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager - @ContributesAndroidInjector abstract fun aapsOmnipodManagerProvider(): info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager + abstract fun omnipodCommunicationManagerProvider(): OmnipodCommunicationManager + @ContributesAndroidInjector abstract fun aapsOmnipodManagerProvider(): AapsOmnipodManager // Data - @ContributesAndroidInjector abstract fun omnipodUITaskProvider(): info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask - @ContributesAndroidInjector abstract fun initPodRefreshAction(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction - @ContributesAndroidInjector abstract fun podStateManager(): info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager - @ContributesAndroidInjector abstract fun initPodTask(): info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodTask - @ContributesAndroidInjector abstract fun omnipodPumpPlugin(): info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin + @ContributesAndroidInjector abstract fun omnipodUITaskProvider(): OmnipodUITask + @ContributesAndroidInjector abstract fun initPodRefreshAction(): InitPodRefreshAction + @ContributesAndroidInjector abstract fun podStateManager(): PodStateManager + @ContributesAndroidInjector abstract fun initPodTask(): InitPodTask + @ContributesAndroidInjector abstract fun omnipodPumpPlugin(): OmnipodPumpPlugin companion object { @Provides - fun podStateManagerProvider(aapsPodStateManager: info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsPodStateManager) : info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager = aapsPodStateManager + fun podStateManagerProvider(aapsPodStateManager: AapsPodStateManager) : PodStateManager = aapsPodStateManager } } diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ServicesModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ServicesModule.kt index d5cd6a6c34..f961c3a863 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ServicesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ServicesModule.kt @@ -30,5 +30,5 @@ abstract class ServicesModule { @ContributesAndroidInjector abstract fun contributesInsightConnectionService(): InsightConnectionService @ContributesAndroidInjector abstract fun contributesRileyLinkService(): RileyLinkService @ContributesAndroidInjector abstract fun contributesRileyLinkMedtronicService(): RileyLinkMedtronicService - @ContributesAndroidInjector abstract fun contributesRileyLinkOmnipodService(): info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService + @ContributesAndroidInjector abstract fun contributesRileyLinkOmnipodService(): RileyLinkOmnipodService } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index f24d3e8922..4fb6743f5f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,2 @@ -include ':omnipod' -include ':app', ':wear', ':core', ':dana', ':danar', ':danars', ':rileylink', ':medtronic' +include ':app', ':wear', ':core', ':dana', ':danar', ':danars', ':rileylink', ':medtronic', ':omnipod'