From 063d3685e1d68698593b2e39013c94129906278e Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Tue, 10 Mar 2020 11:24:40 +0000 Subject: [PATCH 001/400] Show carb suggestions from OpenAPS --- .../main/assets/OpenAPSSMB/determine-basal.js | 2 + .../plugins/aps/loop/APSResult.java | 39 ++++++++- .../plugins/aps/loop/LoopPlugin.java | 83 ++++++++++++------- .../openAPSSMB/DetermineBasalResultSMB.java | 10 ++- app/src/main/res/values/strings.xml | 9 ++ app/src/main/res/xml/pref_openapssmb.xml | 19 +++++ 6 files changed, 127 insertions(+), 35 deletions(-) diff --git a/app/src/main/assets/OpenAPSSMB/determine-basal.js b/app/src/main/assets/OpenAPSSMB/determine-basal.js index c2db0f270b..11a66df891 100644 --- a/app/src/main/assets/OpenAPSSMB/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMB/determine-basal.js @@ -862,8 +862,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ console.error("naive_eventualBG:",naive_eventualBG,"bgUndershoot:",bgUndershoot,"zeroTempDuration:",zeroTempDuration,"zeroTempEffect:",zeroTempEffect,"carbsReq:",carbsReq); if ( carbsReq >= profile.carbsReqThreshold && minutesAboveThreshold <= 45 ) { rT.carbsReq = carbsReq; + rT.carbsReqWithin = minutesAboveThreshold; rT.reason += carbsReq + " add'l carbs req w/in " + minutesAboveThreshold + "m; "; } + // don't low glucose suspend if IOB is already super negative and BG is rising faster than predicted if (bg < threshold && iob_data.iob < -profile.current_basal*20/60 && minDelta > 0 && minDelta > expectedDelta) { rT.reason += "IOB "+iob_data.iob+" < " + round(-profile.current_basal*20/60,2); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java index 0c91d0723c..27ebb5dd84 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java @@ -62,6 +62,9 @@ public class APSResult { public double smb = 0d; // super micro bolus in units public long deliverAt = 0; + public int carbsReq = 0; + public int carbsReqWithin = 0; + public Constraint inputConstraints; public Constraint rateConstraint; @@ -98,6 +101,10 @@ public class APSResult { return this; } + public String getCarbsRequiredText() { + return String.format(resourceHelper.gs(R.string.carbsreq), carbsReq, carbsReqWithin); + } + @Override public String toString() { final PumpInterface pump = activePluginProvider.getActivePump(); @@ -121,11 +128,20 @@ public class APSResult { if (smb != 0) ret += ("SMB: " + DecimalFormatter.toPumpSupportedBolus(smb) + " U\n"); + if (isCarbsRequired()) { + ret += getCarbsRequiredText()+"\n"; + } + // reason ret += resourceHelper.gs(R.string.reason) + ": " + reason; return ret; - } else - return resourceHelper.gs(R.string.nochangerequested); + } + + if (isCarbsRequired()) { + return getCarbsRequiredText(); + } + + return resourceHelper.gs(R.string.nochangerequested); } public Spanned toSpanned() { @@ -150,11 +166,20 @@ public class APSResult { if (smb != 0) ret += ("" + "SMB" + ": " + DecimalFormatter.toPumpSupportedBolus(smb) + " U
"); + if (isCarbsRequired()) { + ret += getCarbsRequiredText()+"
"; + } + // reason ret += "" + resourceHelper.gs(R.string.reason) + ": " + reason.replace("<", "<").replace(">", ">"); return Html.fromHtml(ret); - } else - return Html.fromHtml(resourceHelper.gs(R.string.nochangerequested)); + } + + if (isCarbsRequired()) { + return Html.fromHtml(getCarbsRequiredText()); + } + + return Html.fromHtml(resourceHelper.gs(R.string.nochangerequested)); } public APSResult newAndClone(HasAndroidInjector injector) { @@ -183,6 +208,8 @@ public class APSResult { newResult.smbConstraint = smbConstraint; newResult.percent = percent; newResult.usePercent = usePercent; + newResult.carbsReq = carbsReq; + newResult.carbsReqWithin = carbsReqWithin; } @@ -297,6 +324,10 @@ public class APSResult { return latest; } + public boolean isCarbsRequired() { + return carbsReq > 0; + } + public boolean isChangeRequested() { Constraint closedLoopEnabled = constraintChecker.isClosedLoopAllowed(); // closed loop mode: handle change at driver level diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java index 40ba607cd1..c386ce6f0a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java @@ -405,6 +405,24 @@ public class LoopPlugin extends PluginBase { Constraint closedLoopEnabled = constraintChecker.isClosedLoopAllowed(); if (closedLoopEnabled.value()) { + + if (allowNotification) { + if (resultAfterConstraints.isCarbsRequired()) { + NotificationCompat.Builder builder = + new NotificationCompat.Builder(MainApp.instance().getApplicationContext(), CHANNEL_ID); + builder.setSmallIcon(R.drawable.notif_icon) + .setContentTitle(MainApp.gs(R.string.carbssuggestion)) + .setContentText(resultAfterConstraints.getCarbsRequiredText()) + .setAutoCancel(true) + .setPriority(Notification.PRIORITY_MAX) + .setCategory(Notification.CATEGORY_ALARM) + .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); + presentSuggestion(builder); + } else { + dismissSuggestion(); + } + } + if (resultAfterConstraints.isChangeRequested() && !commandQueue.bolusInQueue() && !commandQueue.isRunning(Command.CommandType.BOLUS)) { @@ -463,36 +481,9 @@ public class LoopPlugin extends PluginBase { if (sp.getBoolean("wearcontrol", false)) { builder.setLocalOnly(true); } - - // Creates an explicit intent for an Activity in your app - Intent resultIntent = new Intent(context, MainActivity.class); - - // The stack builder object will contain an artificial back stack for the - // started Activity. - // This ensures that navigating backward from the Activity leads out of - // your application to the Home screen. - TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); - stackBuilder.addParentStack(MainActivity.class); - // Adds the Intent that starts the Activity to the top of the stack - stackBuilder.addNextIntent(resultIntent); - PendingIntent resultPendingIntent = - stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); - builder.setContentIntent(resultPendingIntent); - builder.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000}); - NotificationManager mNotificationManager = - (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - // mId allows you to update the notification later on. - mNotificationManager.notify(Constants.notificationID, builder.build()); - rxBus.send(new EventNewOpenLoopNotification()); - - // Send to Wear - actionStringHandler.get().handleInitiate("changeRequest"); + presentSuggestion(builder); } else if (allowNotification) { - // dismiss notifications - NotificationManager notificationManager = - (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.cancel(Constants.notificationID); - actionStringHandler.get().handleInitiate("cancelChangeRequest"); + dismissSuggestion(); } } @@ -502,6 +493,40 @@ public class LoopPlugin extends PluginBase { } } + private void presentSuggestion(NotificationCompat.Builder builder) { + // Creates an explicit intent for an Activity in your app + Intent resultIntent = new Intent(context, MainActivity.class); + + // The stack builder object will contain an artificial back stack for the + // started Activity. + // This ensures that navigating backward from the Activity leads out of + // your application to the Home screen. + TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); + stackBuilder.addParentStack(MainActivity.class); + // Adds the Intent that starts the Activity to the top of the stack + stackBuilder.addNextIntent(resultIntent); + PendingIntent resultPendingIntent = + stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); + builder.setContentIntent(resultPendingIntent); + builder.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000}); + NotificationManager mNotificationManager = + (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + // mId allows you to update the notification later on. + mNotificationManager.notify(Constants.notificationID, builder.build()); + rxBus.send(new EventNewOpenLoopNotification()); + + // Send to Wear + actionStringHandler.get().handleInitiate("changeRequest"); + } + + private void dismissSuggestion() { + // dismiss notifications + NotificationManager notificationManager = + (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + notificationManager.cancel(Constants.notificationID); + actionStringHandler.get().handleInitiate("cancelChangeRequest"); + } + public void acceptChangeRequest() { Profile profile = profileFunction.getProfile(); final LoopPlugin lp = this; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java index dae170d5d9..746737ec0f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java @@ -4,10 +4,11 @@ import org.json.JSONException; import org.json.JSONObject; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; +import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.aps.loop.APSResult; import info.nightscout.androidaps.utils.DateUtil; +import info.nightscout.androidaps.utils.SP; public class DetermineBasalResultSMB extends APSResult { @@ -33,7 +34,12 @@ public class DetermineBasalResultSMB extends APSResult { if (result.has("eventualBG")) eventualBG = result.getDouble("eventualBG"); if (result.has("snoozeBG")) snoozeBG = result.getDouble("snoozeBG"); //if (result.has("insulinReq")) insulinReq = result.getDouble("insulinReq"); - //if (result.has("carbsReq")) carbsReq = result.getDouble("carbsReq"); + + if (SP.getBoolean(R.string.key_smb_enable_carbs_suggestions, false)) { + if (result.has("carbsReq") && result.getInt("carbsReq") >= SP.getInt(R.string.key_smb_enable_carbs_suggestions_threshold, 0)) + carbsReq = result.getInt("carbsReq"); + if (result.has("carbsReqWithin")) carbsReqWithin = result.getInt("carbsReqWithin"); + } if (result.has("rate") && result.has("duration")) { tempBasalRequested = true; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1f15a23d70..d9d0e04ab3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -194,6 +194,8 @@ Enable loop New suggestion available + Carbs Suggestion + Unsupported version of NSClient Unsupported version of Nightscout LOOP DISABLED BY CONSTRAINTS Basal IOB @@ -279,6 +281,7 @@ Percent Absolute Cancel temp basal + "%dg Additional Carbs Required Within %d Minutes SMS Communicator Waiting for result Allowed phone numbers @@ -714,10 +717,16 @@ SMB use_smb use_uam + key_smb_enable_carbs_suggestions + key_smb_enable_carbs_suggestions_threshold Enable UAM Enable SMB + Enable Carbs Suggestions + Minimum Carbs Required For Suggestion + Minimum grams of carbs to display a carbs suggestion alert. Carbs suggestions below this number will not trigger a notification. Use Super Micro Boluses instead of temp basal for faster action Detection of Unannounced meals + Enable carbs suggestions when BG is predicted to go below threshold insulin_oref_peak IOB Curve Peak Time Peak Time [min] diff --git a/app/src/main/res/xml/pref_openapssmb.xml b/app/src/main/res/xml/pref_openapssmb.xml index 0cecf93c73..b020a0a9b1 100644 --- a/app/src/main/res/xml/pref_openapssmb.xml +++ b/app/src/main/res/xml/pref_openapssmb.xml @@ -103,6 +103,25 @@ android:summary="@string/low_temptarget_lowers_sensitivity_summary" android:title="@string/low_temptarget_lowers_sensitivity_title" /> + + + + From b1097880f4db42e93c47a3fe67a73b94f21bccf0 Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Tue, 10 Mar 2020 18:46:14 +0000 Subject: [PATCH 002/400] Add carbs required to overview. Add notification with option to ignore carbs suggestions for 5, 15 or 30min --- app/src/main/AndroidManifest.xml | 3 ++ .../dependencyInjection/ReceiversModule.kt | 3 ++ .../aps/loop/CarbSuggestionReceiver.java | 20 ++++++++ .../plugins/aps/loop/LoopPlugin.java | 51 ++++++++++++++++--- .../general/overview/OverviewFragment.java | 14 +++++ app/src/main/res/layout/overview_fragment.xml | 12 +++++ app/src/main/res/values/strings.xml | 2 + 7 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/CarbSuggestionReceiver.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7dae93317c..8e8c96b965 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -113,6 +113,9 @@ + + + 0) { + cobRequiredView.setVisibility(View.VISIBLE); + String carbsRequiredString = String.format(resourceHelper.gs(R.string.overview_carbs_required), loopPlugin.lastRun.constraintsProcessed.carbsReq, loopPlugin.lastRun.constraintsProcessed.carbsReqWithin); + cobRequiredView.setText(carbsRequiredString); + } else { + cobRequiredView.setVisibility(View.GONE); + } + } + if (statuslightsLayout != null) if (sp.getBoolean(R.string.key_show_statuslights, false)) { if (sp.getBoolean(R.string.key_show_statuslights_extended, false)) { diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 467c8c171a..70e1255275 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -266,6 +266,18 @@ app:layout_constraintBottom_toBottomOf="@+id/overview_cob_label" app:layout_constraintStart_toEndOf="@+id/overview_cob_colon" /> + + SMB execution time Temp basal request time Temp basal execution time + (20g needed in 45min) + (%dg needed in %dmin) From 72a3e825e3a0f52f252f5aca41f2208ab44e0258 Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Tue, 10 Mar 2020 18:59:39 +0000 Subject: [PATCH 003/400] Move carbs_suggestions_threshold to LoopPlugin so that non-critical carbs still show on overview (but no system notification) --- .../nightscout/androidaps/plugins/aps/loop/LoopPlugin.java | 4 +++- .../plugins/aps/openAPSSMB/DetermineBasalResultSMB.java | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java index eecb0d3e25..d245bdd816 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java @@ -409,7 +409,9 @@ public class LoopPlugin extends PluginBase { if (closedLoopEnabled.value()) { if (allowNotification) { - if (resultAfterConstraints.isCarbsRequired() && carbsSuggestionsSuspendedUntil < System.currentTimeMillis()) { + if (resultAfterConstraints.isCarbsRequired() + && resultAfterConstraints.carbsReq >= sp.getInt(R.string.key_smb_enable_carbs_suggestions_threshold, 0) + && carbsSuggestionsSuspendedUntil < System.currentTimeMillis()) { Intent intentAction5m = new Intent(context, CarbSuggestionReceiver.class); intentAction5m.putExtra("ignoreDuration",5); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java index 746737ec0f..0c0c5e17ed 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java @@ -36,8 +36,7 @@ public class DetermineBasalResultSMB extends APSResult { //if (result.has("insulinReq")) insulinReq = result.getDouble("insulinReq"); if (SP.getBoolean(R.string.key_smb_enable_carbs_suggestions, false)) { - if (result.has("carbsReq") && result.getInt("carbsReq") >= SP.getInt(R.string.key_smb_enable_carbs_suggestions_threshold, 0)) - carbsReq = result.getInt("carbsReq"); + if (result.has("carbsReq")) carbsReq = result.getInt("carbsReq"); if (result.has("carbsReqWithin")) carbsReqWithin = result.getInt("carbsReqWithin"); } From 7b0bc81c476d9ff7a8253ab844fb6cea091bfdbe Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 24 Mar 2020 09:01:10 +0100 Subject: [PATCH 004/400] Upgrade RS encryption library --- .gitignore | 1 - app/build.gradle | 26 - .../plugins/pump/danaRS/DanaRSPlugin.java | 4 +- .../pump/danaRS/comm/DanaRS_Packet.java | 5 +- ...RS_Packet_APS_Basal_Set_Temporary_Basal.kt | 4 +- .../comm/DanaRS_Packet_APS_History_Events.kt | 4 +- .../DanaRS_Packet_APS_Set_Event_History.kt | 4 +- .../DanaRS_Packet_Basal_Get_Basal_Rate.kt | 4 +- ...aRS_Packet_Basal_Get_Profile_Basal_Rate.kt | 4 +- .../DanaRS_Packet_Basal_Get_Profile_Number.kt | 4 +- ..._Packet_Basal_Get_Temporary_Basal_State.kt | 4 +- .../DanaRS_Packet_Basal_Set_Basal_Rate.kt | 4 +- ...Packet_Basal_Set_Cancel_Temporary_Basal.kt | 4 +- ...aRS_Packet_Basal_Set_Profile_Basal_Rate.kt | 4 +- .../DanaRS_Packet_Basal_Set_Profile_Number.kt | 4 +- .../DanaRS_Packet_Basal_Set_Suspend_Off.kt | 4 +- .../DanaRS_Packet_Basal_Set_Suspend_On.kt | 4 +- ...DanaRS_Packet_Basal_Set_Temporary_Basal.kt | 4 +- .../DanaRS_Packet_Bolus_Get_Bolus_Option.kt | 4 +- .../DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt | 4 +- ...acket_Bolus_Get_Calculation_Information.kt | 4 +- ...et_Carbohydrate_Calculation_Information.kt | 4 +- .../DanaRS_Packet_Bolus_Get_Dual_Bolus.kt | 4 +- .../DanaRS_Packet_Bolus_Get_Extended_Bolus.kt | 4 +- ...S_Packet_Bolus_Get_Extended_Bolus_State.kt | 4 +- ...et_Bolus_Get_Extended_Menu_Option_State.kt | 4 +- .../DanaRS_Packet_Bolus_Get_Initial_Bolus.kt | 4 +- ...Packet_Bolus_Get_Step_Bolus_Information.kt | 4 +- .../DanaRS_Packet_Bolus_Set_Bolus_Option.kt | 4 +- .../DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt | 4 +- .../DanaRS_Packet_Bolus_Set_Dual_Bolus.kt | 4 +- .../DanaRS_Packet_Bolus_Set_Extended_Bolus.kt | 4 +- ..._Packet_Bolus_Set_Extended_Bolus_Cancel.kt | 4 +- .../DanaRS_Packet_Bolus_Set_Initial_Bolus.kt | 4 +- ...anaRS_Packet_Bolus_Set_Step_Bolus_Start.kt | 4 +- ...DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt | 4 +- .../comm/DanaRS_Packet_Etc_Keep_Connection.kt | 4 +- .../DanaRS_Packet_Etc_Set_History_Save.kt | 4 +- .../DanaRS_Packet_General_Delivery_Status.kt | 4 +- ...aRS_Packet_General_Get_More_Information.kt | 4 +- .../DanaRS_Packet_General_Get_Password.kt | 4 +- .../DanaRS_Packet_General_Get_Pump_Check.kt | 4 +- ...Packet_General_Get_Shipping_Information.kt | 4 +- ...Packet_General_Get_Today_Delivery_Total.kt | 4 +- ...acket_General_Get_User_Time_Change_Flag.kt | 4 +- ...cket_General_Initial_Screen_Information.kt | 6 +- ..._Packet_General_Set_History_Upload_Mode.kt | 4 +- ...General_Set_User_Time_Change_Flag_Clear.kt | 7 +- .../comm/DanaRS_Packet_History_Alarm.kt | 4 +- .../comm/DanaRS_Packet_History_All_History.kt | 4 +- .../comm/DanaRS_Packet_History_Basal.kt | 4 +- .../DanaRS_Packet_History_Blood_Glucose.kt | 4 +- .../comm/DanaRS_Packet_History_Bolus.kt | 4 +- .../DanaRS_Packet_History_Carbohydrate.kt | 4 +- .../comm/DanaRS_Packet_History_Daily.kt | 4 +- .../comm/DanaRS_Packet_History_Prime.kt | 4 +- .../comm/DanaRS_Packet_History_Refill.kt | 4 +- .../comm/DanaRS_Packet_History_Suspend.kt | 4 +- .../comm/DanaRS_Packet_History_Temporary.kt | 4 +- .../danaRS/comm/DanaRS_Packet_Notify_Alarm.kt | 6 +- .../DanaRS_Packet_Notify_Delivery_Complete.kt | 6 +- ...aRS_Packet_Notify_Delivery_Rate_Display.kt | 6 +- ...DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt | 6 +- .../DanaRS_Packet_Option_Get_Pump_Time.kt | 4 +- .../DanaRS_Packet_Option_Get_User_Option.kt | 4 +- .../DanaRS_Packet_Option_Set_Pump_Time.kt | 4 +- .../DanaRS_Packet_Option_Set_User_Option.kt | 4 +- .../comm/DanaRS_Packet_Review_Bolus_Avg.kt | 4 +- .../danaRS/encryption/BleEncryption.java} | 62 +- .../plugins/pump/danaRS/services/BLEComm.java | 681 ------------------ .../plugins/pump/danaRS/services/BLEComm.kt | 556 ++++++++++++++ .../pump/danaRS/services/DanaRSService.java | 14 +- .../jniLibs/arm64-v8a/libBleEncryption.so | Bin 0 -> 22680 bytes .../jniLibs/armeabi-v7a/libBleEncryption.so | Bin 0 -> 26448 bytes app/src/main/jniLibs/x86/libBleEncryption.so | Bin 0 -> 22296 bytes .../main/jniLibs/x86_64/libBleEncryption.so | Bin 0 -> 22944 bytes .../danaRS/comm/DanaRSMessageHashTableTest.kt | 4 +- 77 files changed, 745 insertions(+), 877 deletions(-) rename app/src/main/java/{com/cozmo/danar/util/BleCommandUtil.java => info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java} (76%) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt create mode 100644 app/src/main/jniLibs/arm64-v8a/libBleEncryption.so create mode 100644 app/src/main/jniLibs/armeabi-v7a/libBleEncryption.so create mode 100644 app/src/main/jniLibs/x86/libBleEncryption.so create mode 100644 app/src/main/jniLibs/x86_64/libBleEncryption.so diff --git a/.gitignore b/.gitignore index c7ed9df2f5..961dd40194 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ build/ .idea/* !.idea/codeStyles/ -app/src/main/jniLibs full/ debug/ release/ diff --git a/app/build.gradle b/app/build.gradle index adc28fb221..73524734ed 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -340,30 +340,6 @@ dependencies { androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' } - -task downloadZipFile(type: Download) { - src 'https://github.com/MilosKozak/danars-support-lib/archive/master.zip' - dest new File(buildDir, 'danars.zip') -} - -task downloadAndUnzipFile(dependsOn: downloadZipFile, type: Copy) { - from zipTree(downloadZipFile.dest) - def outputDir = file("${buildDir}/unpacked/dist") - into outputDir -} - - -task copyLibs(dependsOn: downloadAndUnzipFile, type: Copy) { - def src = file("${buildDir}/unpacked/dist/danars-support-lib-master") - def target = file("src/main/jniLibs/") - - from src - into target -} - -task full_clean(type: Delete) { - delete file("src/main/jniLibs") -} /* // Run 'adb' shell command to clear application data of main app for 'debug' variant task clearMainAppData(type: Exec) { @@ -395,8 +371,6 @@ tasks.whenTaskAdded { task -> } } */ -clean.dependsOn full_clean -preBuild.dependsOn copyLibs printf('--------------\n') printf('isMaster: %s\n', isMaster().toString()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java index 13c41933f5..b9d4af7497 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java @@ -195,9 +195,7 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR public void connect(String from) { getAapsLogger().debug(LTag.PUMP, "RS connect from: " + from); if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) { - final Object o = new Object(); - - danaRSService.connect(from, mDeviceAddress, o); + danaRSService.connect(from, mDeviceAddress); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java index 0e77d7588b..9bb70720fb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java @@ -3,9 +3,8 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm; import android.annotation.TargetApi; import android.os.Build; -import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.nio.charset.StandardCharsets; import java.util.Date; @@ -21,7 +20,7 @@ public class DanaRS_Packet { private boolean received; public boolean failed; - protected int type = BleCommandUtil.DANAR_PACKET__TYPE_RESPONSE; // most of the messages, should be changed for others + protected int type = BleEncryption.DANAR_PACKET__TYPE_RESPONSE; // most of the messages, should be changed for others protected int opCode; public DanaRS_Packet() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt index d223641bba..89a2c3fac3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -14,7 +14,7 @@ class DanaRS_Packet_APS_Basal_Set_Temporary_Basal( var error = 0 init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__APS_SET_TEMPORARY_BASAL + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__APS_SET_TEMPORARY_BASAL aapsLogger.debug(LTag.PUMPCOMM, "New message: percent: $percent") if (percent < 0) percent = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt index 08b4502daa..27b88c1380 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.db.ExtendedBolus @@ -36,7 +36,7 @@ open class DanaRS_Packet_APS_History_Events( private var sec = 0 init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS + opCode = BleEncryption.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS val cal = GregorianCalendar() if (from > DateUtil.now()) { aapsLogger.debug(LTag.PUMPCOMM, "Asked to load from the future") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt index 266554d3be..861854d77b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -16,7 +16,7 @@ class DanaRS_Packet_APS_Set_Event_History( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY + opCode = BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY if ((packetType == DanaRPump.CARBS || packetType == DanaRPump.BOLUS) && param1 <= 0) this.param1 = 0 aapsLogger.debug(LTag.PUMPCOMM, "Set history entry: " + DateUtil.dateAndTimeString(time) + " type: " + packetType + " param1: " + param1 + " param2: " + param2) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt index aa0a74e97c..8cdbbe2d65 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -20,7 +20,7 @@ class DanaRS_Packet_Basal_Get_Basal_Rate( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE aapsLogger.debug(LTag.PUMPCOMM, "Requesting basal rates") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt index 54793b555d..9b0de5603c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -13,7 +13,7 @@ open class DanaRS_Packet_Basal_Get_Profile_Basal_Rate( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_BASAL_RATE + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_BASAL_RATE aapsLogger.debug(LTag.PUMPCOMM, "Requesting basal rates for profile $profileNumber") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt index c37242b740..bdd586e948 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,7 +11,7 @@ class DanaRS_Packet_Basal_Get_Profile_Number( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER aapsLogger.debug(LTag.PUMPCOMM, "Requesting active profile") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt index fdc5c16480..bb5f0d8d98 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -13,7 +13,7 @@ class DanaRS_Packet_Basal_Get_Temporary_Basal_State( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE aapsLogger.debug(LTag.PUMPCOMM, "Requesting temporary basal status") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt index ea5dd4ee29..28d7b6b693 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -11,7 +11,7 @@ class DanaRS_Packet_Basal_Set_Basal_Rate( init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_BASAL_RATE + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_BASAL_RATE aapsLogger.debug(LTag.PUMPCOMM, "Setting new basal rates") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt index 1d67a20a89..c30b938002 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -9,7 +9,7 @@ class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL aapsLogger.debug(LTag.PUMPCOMM, "Canceling temp basal") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt index a65746f8e8..189a704e0c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -11,7 +11,7 @@ class DanaRS_Packet_Basal_Set_Profile_Basal_Rate( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_BASAL_RATE + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_BASAL_RATE aapsLogger.debug(LTag.PUMPCOMM, "Setting new basal rates for profile $profileNumber") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt index b61c046682..2056889532 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -10,7 +10,7 @@ class DanaRS_Packet_Basal_Set_Profile_Number( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER aapsLogger.debug(LTag.PUMPCOMM, "Setting profile number $profileNumber") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt index 85e2f70456..eff81eb0bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -9,7 +9,7 @@ class DanaRS_Packet_Basal_Set_Suspend_Off( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF aapsLogger.debug(LTag.PUMPCOMM, "Turning off suspend") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt index c603549d91..e3a3f9d228 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -9,7 +9,7 @@ class DanaRS_Packet_Basal_Set_Suspend_On( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON aapsLogger.debug(LTag.PUMPCOMM, "Turning on suspend") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt index cde564fbc0..f4318fb0b3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -11,7 +11,7 @@ open class DanaRS_Packet_Basal_Set_Temporary_Basal( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_TEMPORARY_BASAL + opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_TEMPORARY_BASAL aapsLogger.debug(LTag.PUMPCOMM, "Setting temporary basal of $temporaryBasalRatio% for $temporaryBasalDuration hours") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt index 36512ccec1..8918094938 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -20,7 +20,7 @@ class DanaRS_Packet_Bolus_Get_Bolus_Option( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt index b157ad9978..d981da5033 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_CIR_CF_Array( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CIR_CF_ARRAY + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CIR_CF_ARRAY aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt index 7dacd08599..6c19045a2f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -12,7 +12,7 @@ class DanaRS_Packet_Bolus_Get_Calculation_Information( init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CALCULATION_INFORMATION + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CALCULATION_INFORMATION aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt index ba69221673..c1bd0aeb40 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt index 2fbe624322..97d40dd0af 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_Dual_Bolus( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt index 3cd50febdb..9d96debe56 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_Extended_Bolus( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt index c48b08150b..ef24b5cec1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_Extended_Bolus_State( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt index 44bcaea4c6..cd16a68bb7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt index 5b3fe17f1f..50f5864e81 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -9,7 +9,7 @@ class DanaRS_Packet_Bolus_Get_Initial_Bolus( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt index e6c8121506..395d90b6ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -13,7 +13,7 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_STEP_BOLUS_INFORMATION + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_STEP_BOLUS_INFORMATION aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt index 34f3967351..21d9b39d56 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -29,7 +29,7 @@ class DanaRS_Packet_Bolus_Set_Bolus_Option( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_OPTION + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_OPTION aapsLogger.debug(LTag.PUMPCOMM, "Setting bolus options") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt index e31a770db7..137c1633b6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -23,7 +23,7 @@ class DanaRS_Packet_Bolus_Set_CIR_CF_Array( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_CIR_CF_ARRAY + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_CIR_CF_ARRAY aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt index d0fef47f82..919039319b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -13,7 +13,7 @@ class DanaRS_Packet_Bolus_Set_Dual_Bolus( init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_DUAL_BOLUS + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_DUAL_BOLUS aapsLogger.debug(LTag.PUMPCOMM, "Dual bolus start : $amount U extended: $extendedAmount U halfhours: $extendedBolusDurationInHalfHours") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt index 620a4722ab..222152c2a8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -12,7 +12,7 @@ class DanaRS_Packet_Bolus_Set_Extended_Bolus( init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus start : $extendedAmount U halfhours: $extendedBolusDurationInHalfHours") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt index 8596219ba4..868dd5f7b6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -9,7 +9,7 @@ class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL aapsLogger.debug(LTag.PUMPCOMM, "Cancel extended bolus") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt index fb1154c43f..eecd43c6ca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -13,7 +13,7 @@ class DanaRS_Packet_Bolus_Set_Initial_Bolus( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_RATE + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_RATE aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt index ce9aaf9e1b..ef14999e22 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -17,7 +17,7 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_Start( init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_START + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_START // Speed 0 => 12 sec/U, 1 => 30 sec/U, 2 => 60 sec/U // HARDCODED LIMIT - if there is one that could be created amount = constraintChecker.applyBolusConstraints(Constraint(amount)).value() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt index f84becafc5..462d639a0c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -18,7 +18,7 @@ open class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop( init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_STOP + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_STOP } override fun handleMessage(data: ByteArray) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt index dd29887ef0..1038881c2e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -9,7 +9,7 @@ class DanaRS_Packet_Etc_Keep_Connection( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION + opCode = BleEncryption.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt index 99fe5da588..ae1fac6bff 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -19,7 +19,7 @@ class DanaRS_Packet_Etc_Set_History_Save( init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE + opCode = BleEncryption.DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt index 524b8e13c8..21937923fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -9,7 +9,7 @@ class DanaRS_Packet_General_Delivery_Status( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt index b8e7e6bb53..875b91f397 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -13,7 +13,7 @@ class DanaRS_Packet_General_Get_More_Information( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt index 5a1358c38b..58cdf77ae9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,7 +11,7 @@ class DanaRS_Packet_General_Get_Password( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt index 7c6f2fab5c..bf3338b52f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -18,7 +18,7 @@ class DanaRS_Packet_General_Get_Pump_Check( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_CHECK + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_CHECK aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt index 00ebd4118a..6bf3296af1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -12,7 +12,7 @@ class DanaRS_Packet_General_Get_Shipping_Information( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt index 31310e3d08..fe9c676ca9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,7 +11,7 @@ class DanaRS_Packet_General_Get_Today_Delivery_Total( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt index 99c0cc2879..45e68600d7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -9,7 +9,7 @@ class DanaRS_Packet_General_Get_User_Time_Change_Flag( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt index fab00aca3d..574791a005 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,8 +11,8 @@ class DanaRS_Packet_General_Initial_Screen_Information( ) : DanaRS_Packet() { init { - type = BleCommandUtil.DANAR_PACKET__TYPE_RESPONSE - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION + type = BleEncryption.DANAR_PACKET__TYPE_RESPONSE + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt index b6b884f27d..e26e13e6f0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -10,7 +10,7 @@ class DanaRS_Packet_General_Set_History_Upload_Mode( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_HISTORY_UPLOAD_MODE + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SET_HISTORY_UPLOAD_MODE aapsLogger.debug(LTag.PUMPCOMM, "New message: mode: $mode") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt index 132141b808..969f226fb0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt @@ -1,18 +1,15 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger -import info.nightscout.androidaps.logging.L -import info.nightscout.androidaps.logging.L.isEnabled import info.nightscout.androidaps.logging.LTag -import org.slf4j.LoggerFactory class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear( private val aapsLogger: AAPSLogger ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR aapsLogger.debug(LTag.PUMPCOMM, "New message") } override fun handleMessage(data: ByteArray) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt index 9b0c7ef4c6..bcf3ffc1df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_Alarm @JvmOverloads constructor( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__ALARM aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt index a8010b2127..2b42507888 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_All_History( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt index 0ac22574d5..09173ed5c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_Basal @JvmOverloads constructor( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BASAL aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt index 6ebbeaed53..7f07e71680 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_Blood_Glucose @JvmOverloads constructor( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt index 47996fc8c6..d6f8b51707 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_Bolus @JvmOverloads constructor( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BOLUS aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt index 1084434962..ed3b49a8d7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_Carbohydrate @JvmOverloads constructor( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt index 93e974728d..645cab8272 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_Daily @JvmOverloads constructor( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__DAILY aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt index 0306e6f129..da209b0a8a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_Prime @JvmOverloads constructor( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__PRIME aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt index 672c5e2cc4..8b470a0170 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_Refill @JvmOverloads constructor( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__REFILL aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt index 9868cd10a4..2e5ad23dd9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_Suspend @JvmOverloads constructor( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SUSPEND aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt index b185748495..5689ca82c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -12,7 +12,7 @@ class DanaRS_Packet_History_Temporary( ) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt index 5cc82d93a5..7650ff3704 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -13,8 +13,8 @@ class DanaRS_Packet_Notify_Alarm( ) : DanaRS_Packet() { init { - type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__ALARM + type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY + opCode = BleEncryption.DANAR_PACKET__OPCODE_NOTIFY__ALARM aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt index 246f2c7fe5..03d884933b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -18,8 +18,8 @@ class DanaRS_Packet_Notify_Delivery_Complete( ) : DanaRS_Packet() { init { - type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_COMPLETE + type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY + opCode = BleEncryption.DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_COMPLETE aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt index 9705c53669..a63bad6f23 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -19,8 +19,8 @@ class DanaRS_Packet_Notify_Delivery_Rate_Display( init { - type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_RATE_DISPLAY + type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY + opCode = BleEncryption.DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_RATE_DISPLAY } override fun handleMessage(data: ByteArray) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt index ad5fdbdef6..f15582f3d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -9,8 +9,8 @@ class DanaRS_Packet_Notify_Missed_Bolus_Alarm( ) : DanaRS_Packet() { init { - type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__MISSED_BOLUS_ALARM + type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY + opCode = BleEncryption.DANAR_PACKET__OPCODE_NOTIFY__MISSED_BOLUS_ALARM aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt index 2b18603d11..b582a0b492 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -13,7 +13,7 @@ class DanaRS_Packet_Option_Get_Pump_Time( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME + opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME aapsLogger.debug(LTag.PUMPCOMM, "Requesting pump time") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt index 07694f6380..a012b1302b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -11,7 +11,7 @@ class DanaRS_Packet_Option_Get_User_Option( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION + opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION aapsLogger.debug(LTag.PUMPCOMM, "Requesting user settings") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt index ec1a44c789..54a38af3de 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.utils.DateUtil @@ -14,7 +14,7 @@ class DanaRS_Packet_Option_Set_Pump_Time( var error = 0 init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_PUMP_TIME + opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__SET_PUMP_TIME aapsLogger.debug(LTag.PUMPCOMM, "Setting pump time " + DateUtil.dateAndTimeString(time)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt index 2ca965fc60..d266bf765b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -12,7 +12,7 @@ class DanaRS_Packet_Option_Set_User_Option( init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_USER_OPTION + opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__SET_USER_OPTION aapsLogger.debug(LTag.PUMPCOMM, "Setting user settings") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt index c99a56a2b8..ee953d8581 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -9,7 +9,7 @@ class DanaRS_Packet_Review_Bolus_Avg( ) : DanaRS_Packet() { init { - opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/com/cozmo/danar/util/BleCommandUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java similarity index 76% rename from app/src/main/java/com/cozmo/danar/util/BleCommandUtil.java rename to app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java index a417b379e8..edd36f583e 100644 --- a/app/src/main/java/com/cozmo/danar/util/BleCommandUtil.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java @@ -1,10 +1,18 @@ -package com.cozmo.danar.util; +package info.nightscout.androidaps.plugins.pump.danaRS.encryption; import android.content.Context; -import info.nightscout.androidaps.MainApp; +import javax.inject.Inject; +import javax.inject.Singleton; + +@Singleton +public class BleEncryption { + private Context context; + + @Inject BleEncryption(Context context) { + this.context = context; + } -public class BleCommandUtil { public static final int DANAR_PACKET__TYPE_ENCRYPTION_REQUEST = 0x01; public static final int DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE = 0x02; public static final int DANAR_PACKET__TYPE_COMMAND = 0xA1; @@ -12,10 +20,13 @@ public class BleCommandUtil { public static final int DANAR_PACKET__TYPE_NOTIFY = 0xC3; public static final int DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK = 0x00; + public static final int DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION = 0x01; public static final int DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY = 0xD0; public static final int DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST = 0xD1; public static final int DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN = 0xD2; - public static final int DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION = 0x01; + // Easy Mode + public static final int DANAR_PACKET__OPCODE_ENCRYPTION__GET_PUMP_CHECK = 0xF3; + public static final int DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK = 0xF4; public static final int DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_COMPLETE = 0x01; public static final int DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_RATE_DISPLAY = 0x02; @@ -86,35 +97,50 @@ public class BleCommandUtil { public static final int DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS = 0xC2; public static final int DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY = 0xC3; + // Easy Mode + public static final int DANAR_PACKET__OPCODE_OPTION__GET_EASY_MENU_OPTION = 0x74; + public static final int DANAR_PACKET__OPCODE_OPTION__SET_EASY_MENU_OPTION = 0x75; + public static final int DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE = 0xE0; public static final int DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION = 0xFF; static { - System.loadLibrary("BleCommandUtil"); + System.loadLibrary("BleEncryption"); } - private static native byte[] getEncryptedPacketJni(Object context, int opcode, byte[] bytes, String deviceName); + private static native byte[] encryptPacketJni(Object context, int opcode, byte[] bytes, String deviceName); - private static native byte[] getDecryptedPacketJni(Object context, byte[] bytes); + private static native byte[] decryptPacketJni(Object context, byte[] bytes); - // --------------------------------------------------------- + private static native void setPairingKeysJni(byte[] pairingKey, byte[] randomPairingKey, byte randomSyncKey); - private static BleCommandUtil mInstance = null; + private static native void setEnhancedEncryptionJni(boolean isSecurityVersion); - public static BleCommandUtil getInstance() { - if (mInstance == null) { - mInstance = new BleCommandUtil(); - } - return mInstance; - } + private static native byte[] encryptSecondLevelPacketJni(Object context, byte[] bytes); - // --------------------------------------------------------- + private static native byte[] decryptSecondLevelPacketJni(Object context, byte[] bytes); public byte[] getEncryptedPacket(int opcode, byte[] bytes, String deviceName) { - return getEncryptedPacketJni(MainApp.instance().getApplicationContext(), opcode, bytes, deviceName); + return encryptPacketJni(context, opcode, bytes, deviceName); } public byte[] getDecryptedPacket(byte[] bytes) { - return getDecryptedPacketJni(MainApp.instance().getApplicationContext(), bytes); + return decryptPacketJni(context, bytes); + } + + public void setPairingKeys(byte[] pairingKey, byte[] randomPairingKey, byte randomSyncKey) { + setPairingKeysJni(pairingKey, randomPairingKey, randomSyncKey); + } + + public void setEnhancedEncryption(boolean isSecureVersion) { + setEnhancedEncryptionJni(isSecureVersion); + } + + public byte[] encryptSecondLevelPacket(byte[] bytes) { + return encryptSecondLevelPacketJni(context, bytes); + } + + public byte[] ecryptSecondLevelPacket(byte[] bytes) { + return decryptSecondLevelPacketJni(context, bytes); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.java deleted file mode 100644 index 75ceba52ee..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.java +++ /dev/null @@ -1,681 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.danaRS.services; - -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothGatt; -import android.bluetooth.BluetoothGattCallback; -import android.bluetooth.BluetoothGattCharacteristic; -import android.bluetooth.BluetoothGattService; -import android.bluetooth.BluetoothManager; -import android.bluetooth.BluetoothProfile; -import android.content.Context; -import android.content.Intent; -import android.os.SystemClock; - -import com.cozmo.danar.util.BleCommandUtil; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.ScheduledFuture; - -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.events.EventPumpStatusChanged; -import info.nightscout.androidaps.logging.L; -import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; -import info.nightscout.androidaps.plugins.bus.RxBus; -import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; -import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; -import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; -import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump; -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin; -import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSMessageHashTable; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet; -import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess; -import info.nightscout.androidaps.utils.SP; - -/** - * Created by mike on 23.09.2017. - */ - -public class BLEComm { - private Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPBTCOMM); - - private final long WRITE_DELAY_MILLIS = 50; - - private String UART_READ_UUID = "0000fff1-0000-1000-8000-00805f9b34fb"; - private String UART_WRITE_UUID = "0000fff2-0000-1000-8000-00805f9b34fb"; - - private final byte PACKET_START_BYTE = (byte) 0xA5; - private final byte PACKET_END_BYTE = (byte) 0x5A; - private Context context; - private DanaRPump danaRPump; - private DanaRSMessageHashTable danaRSMessageHashTable; - - public BLEComm(Context context, DanaRSMessageHashTable danaRSMessageHashTable, DanaRPump danaRPump) { - this.context = context; - this.danaRPump = danaRPump; - this.danaRSMessageHashTable = danaRSMessageHashTable; - initialize(); - } - - private ScheduledFuture scheduledDisconnection = null; - - private DanaRS_Packet processsedMessage = null; - private final ArrayList mSendQueue = new ArrayList<>(); - - private BluetoothManager mBluetoothManager = null; - private BluetoothAdapter mBluetoothAdapter = null; - private String mBluetoothDeviceName = null; - private BluetoothGatt mBluetoothGatt = null; - - protected boolean isConnected = false; - protected boolean isConnecting = false; - - private BluetoothGattCharacteristic UART_Read; - private BluetoothGattCharacteristic UART_Write; - - private boolean initialize() { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("Initializing BLEComm."); - - if (mBluetoothManager == null) { - mBluetoothManager = ((BluetoothManager) MainApp.instance().getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE)); - if (mBluetoothManager == null) { - log.error("Unable to initialize BluetoothManager."); - return false; - } - } - - mBluetoothAdapter = mBluetoothManager.getAdapter(); - if (mBluetoothAdapter == null) { - log.error("Unable to obtain a BluetoothAdapter."); - return false; - } - - return true; - } - - public boolean isConnected() { - return isConnected; - } - - public boolean isConnecting() { - return isConnecting; - } - - public boolean connect(String from, String address, Object confirmConnect) { - BluetoothManager tBluetoothManager = ((BluetoothManager) MainApp.instance().getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE)); - if (tBluetoothManager == null) { - return false; - } - - BluetoothAdapter tBluetoothAdapter = tBluetoothManager.getAdapter(); - if (tBluetoothAdapter == null) { - return false; - } - - if (mBluetoothAdapter == null) { - if (!initialize()) { - return false; - } - } - - if (address == null) { - log.error("unspecified address."); - return false; - } - - isConnecting = true; - - BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); - if (device == null) { - log.error("Device not found. Unable to connect from: " + from); - return false; - } - - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("Trying to create a new connection from: " + from); - mBluetoothDeviceName = device.getName(); - mBluetoothGatt = device.connectGatt(context, false, mGattCallback); - setCharacteristicNotification(getUARTReadBTGattChar(), true); - return true; - } - - public void stopConnecting() { - isConnecting = false; - } - - public synchronized void disconnect(String from) { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("disconnect from: " + from); - - // cancel previous scheduled disconnection to prevent closing upcomming connection - if (scheduledDisconnection != null) - scheduledDisconnection.cancel(false); - scheduledDisconnection = null; - - if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.error("disconnect not possible: (mBluetoothAdapter == null) " + (mBluetoothAdapter == null)); - log.error("disconnect not possible: (mBluetoothGatt == null) " + (mBluetoothGatt == null)); - return; - } - setCharacteristicNotification(getUARTReadBTGattChar(), false); - mBluetoothGatt.disconnect(); - isConnected = false; - SystemClock.sleep(2000); - } - - public synchronized void close() { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("BluetoothAdapter close"); - if (mBluetoothGatt == null) { - return; - } - - mBluetoothGatt.close(); - mBluetoothGatt = null; - } - - - private String getConnectDeviceName() { - return mBluetoothDeviceName; - } - - private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() { - public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { - onConnectionStateChangeSynchronized(gatt, status, newState); // call it synchronized - } - - public void onServicesDiscovered(BluetoothGatt gatt, int status) { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("onServicesDiscovered"); - if (status == BluetoothGatt.GATT_SUCCESS) { - findCharacteristic(); - } - SendPumpCheck(); - // 1st message sent to pump after connect - } - - public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("onCharacteristicRead" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); - addToReadBuffer(characteristic.getValue()); - readDataParsing(); - } - - public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("onCharacteristicChanged" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); - addToReadBuffer(characteristic.getValue()); - new Thread(() -> readDataParsing()).start(); - } - - public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("onCharacteristicWrite" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); - new Thread(() -> { - synchronized (mSendQueue) { - // after message sent, check if there is the rest of the message waiting and send it - if (mSendQueue.size() > 0) { - byte[] bytes = mSendQueue.get(0); - mSendQueue.remove(0); - writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); - } - } - }).start(); - } - }; - - private synchronized void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("setCharacteristicNotification"); - if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.error("BluetoothAdapter not initialized_ERROR"); - isConnecting = false; - isConnected = false; - return; - } - mBluetoothGatt.setCharacteristicNotification(characteristic, enabled); - } - - public synchronized void readCharacteristic(BluetoothGattCharacteristic characteristic) { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("readCharacteristic"); - if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.error("BluetoothAdapter not initialized_ERROR"); - isConnecting = false; - isConnected = false; - return; - } - mBluetoothGatt.readCharacteristic(characteristic); - } - - private synchronized void writeCharacteristic_NO_RESPONSE(final BluetoothGattCharacteristic characteristic, final byte[] data) { - new Thread(() -> { - SystemClock.sleep(WRITE_DELAY_MILLIS); - - if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.error("BluetoothAdapter not initialized_ERROR"); - isConnecting = false; - isConnected = false; - return; - } - - characteristic.setValue(data); - characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data)); - mBluetoothGatt.writeCharacteristic(characteristic); - }).start(); - } - - private BluetoothGattCharacteristic getUARTReadBTGattChar() { - if (UART_Read == null) { - UART_Read = new BluetoothGattCharacteristic(UUID.fromString(UART_READ_UUID), BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_NOTIFY, 0); - } - return UART_Read; - } - - private BluetoothGattCharacteristic getUARTWriteBTGattChar() { - if (UART_Write == null) { - UART_Write = new BluetoothGattCharacteristic(UUID.fromString(UART_WRITE_UUID), BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE, 0); - } - return UART_Write; - } - - private List getSupportedGattServices() { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("getSupportedGattServices"); - if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.error("BluetoothAdapter not initialized_ERROR"); - isConnecting = false; - isConnected = false; - return null; - } - - return mBluetoothGatt.getServices(); - } - - private void findCharacteristic() { - List gattServices = getSupportedGattServices(); - - if (gattServices == null) { - return; - } - String uuid; - - for (BluetoothGattService gattService : gattServices) { - List gattCharacteristics = gattService.getCharacteristics(); - for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { - uuid = gattCharacteristic.getUuid().toString(); - if (UART_READ_UUID.equals(uuid)) { - UART_Read = gattCharacteristic; - setCharacteristicNotification(UART_Read, true); - } - if (UART_WRITE_UUID.equals(uuid)) { - UART_Write = gattCharacteristic; - } - } - } - } - - private synchronized void onConnectionStateChangeSynchronized(BluetoothGatt gatt, int status, int newState) { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("onConnectionStateChange"); - - if (newState == BluetoothProfile.STATE_CONNECTED) { - mBluetoothGatt.discoverServices(); - } else if (newState == BluetoothProfile.STATE_DISCONNECTED) { - close(); - isConnected = false; - isConnecting = false; - RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED)); - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected - } - } - - private final byte[] readBuffer = new byte[1024]; - private int bufferLength = 0; - - private void addToReadBuffer(byte[] buffer) { - //log.debug("addToReadBuffer " + DanaRS_Packet.toHexString(buffer)); - if (buffer == null || buffer.length == 0) { - return; - } - synchronized (readBuffer) { - // Append incomming data to input buffer - System.arraycopy(buffer, 0, readBuffer, bufferLength, buffer.length); - bufferLength += buffer.length; - } - } - - private void readDataParsing() { - boolean startSignatureFound = false, packetIsValid = false; - boolean isProcessing; - - isProcessing = true; - - while (isProcessing) { - int length = 0; - byte[] inputBuffer = null; - synchronized (readBuffer) { - // Find packet start [A5 A5] - if (bufferLength >= 6) { - for (int idxStartByte = 0; idxStartByte < bufferLength - 2; idxStartByte++) { - if ((readBuffer[idxStartByte] == PACKET_START_BYTE) && (readBuffer[idxStartByte + 1] == PACKET_START_BYTE)) { - if (idxStartByte > 0) { - // if buffer doesn't start with signature remove the leading trash - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("Shifting the input buffer by " + idxStartByte + " bytes"); - System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte); - bufferLength -= idxStartByte; - } - startSignatureFound = true; - break; - } - } - } - // A5 A5 LEN TYPE CODE PARAMS CHECKSUM1 CHECKSUM2 5A 5A - // ^---- LEN -----^ - // total packet length 2 + 1 + readBuffer[2] + 2 + 2 - if (startSignatureFound) { - length = readBuffer[2]; - // test if there is enough data loaded - if (length + 7 > bufferLength) - return; - // Verify packed end [5A 5A] - if ((readBuffer[length + 5] == PACKET_END_BYTE) && (readBuffer[length + 6] == PACKET_END_BYTE)) { - packetIsValid = true; - } - } - if (packetIsValid) { - inputBuffer = new byte[length + 7]; - // copy packet to input buffer - System.arraycopy(readBuffer, 0, inputBuffer, 0, length + 7); - // Cut off the message from readBuffer - try { - System.arraycopy(readBuffer, length + 7, readBuffer, 0, bufferLength - (length + 7)); - } catch (Exception e) { - log.error("length: " + length + "bufferLength: " + bufferLength); - throw e; - } - bufferLength -= (length + 7); - // now we have encrypted packet in inputBuffer - } - } - if (packetIsValid) { - try { - // decrypt the packet - inputBuffer = BleCommandUtil.getInstance().getDecryptedPacket(inputBuffer); - - if (inputBuffer == null) { - log.error("Null decryptedInputBuffer"); - return; - } - - switch (inputBuffer[0]) { - // initial handshake packet - case (byte) BleCommandUtil.DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE: - switch (inputBuffer[1]) { - // 1st packet - case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK: - if (inputBuffer.length == 4 && inputBuffer[2] == 'O' && inputBuffer[3] == 'K') { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer)); - // Grab pairing key from preferences if exists - String pairingKey = SP.getString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null); - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("Using stored pairing key: " + pairingKey); - if (pairingKey != null) { - byte[] encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey); - byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null); - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug(">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)); - writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); - } else { - // Stored pairing key does not exists, request pairing - SendPairingRequest(); - } - - } else if (inputBuffer.length == 6 && inputBuffer[2] == 'P' && inputBuffer[3] == 'U' && inputBuffer[4] == 'M' && inputBuffer[5] == 'P') { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer)); - mSendQueue.clear(); - RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.pumperror))); - NSUpload.uploadError(MainApp.gs(R.string.pumperror)); - Notification n = new Notification(Notification.PUMPERROR, MainApp.gs(R.string.pumperror), Notification.URGENT); - RxBus.Companion.getINSTANCE().send(new EventNewNotification(n)); - } else if (inputBuffer.length == 6 && inputBuffer[2] == 'B' && inputBuffer[3] == 'U' && inputBuffer[4] == 'S' && inputBuffer[5] == 'Y') { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer)); - mSendQueue.clear(); - RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.pumpbusy))); - } else { - // ERROR in response, wrong serial number - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer)); - mSendQueue.clear(); - RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.connectionerror))); - SP.remove(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName); - Notification n = new Notification(Notification.WRONGSERIALNUMBER, MainApp.gs(R.string.wrongpassword), Notification.URGENT); - RxBus.Companion.getINSTANCE().send(new EventNewNotification(n)); - } - break; - // 2nd packet, pairing key - case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY: - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(inputBuffer)); - if (inputBuffer[2] == (byte) 0x00) { - // Paring is not requested, sending time info - SendTimeInfo(); - } else { - // Pairing on pump is requested - SendPairingRequest(); - } - break; - case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST: - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(inputBuffer)); - if (inputBuffer[2] != (byte) 0x00) { - disconnect("passkey request failed"); - } - break; - // Paring response, OK button on pump pressed - case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN: - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(inputBuffer)); - // Paring is successfull, sending time info - RxBus.Companion.getINSTANCE().send(new EventDanaRSPairingSuccess()); - SendTimeInfo(); - byte[] pairingKey = {inputBuffer[2], inputBuffer[3]}; - // store pairing key to preferences - SP.putString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)); - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)); - break; - // time and user password information. last packet in handshake - case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION: - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */ DanaRS_Packet.toHexString(inputBuffer)); - int size = inputBuffer.length; - int pass = ((inputBuffer[size - 1] & 0x000000FF) << 8) + ((inputBuffer[size - 2] & 0x000000FF)); - pass = pass ^ 3463; - danaRPump.setRsPassword(Integer.toHexString(pass)); - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("Pump user password: " + Integer.toHexString(pass)); - - RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)); - isConnected = true; - isConnecting = false; - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("RS connected and status read"); - break; - } - break; - // common data packet - default: - DanaRS_Packet message; - // Retrieve message code from received buffer and last message sent - int originalCommand = processsedMessage != null ? processsedMessage.getCommand() : 0xFFFF; - int receivedCommand = DanaRS_Packet.getCommand(inputBuffer); - if (originalCommand == receivedCommand) { - // it's response to last message - message = processsedMessage; - } else { - // it's not response to last message, create new instance - message = danaRSMessageHashTable.findMessage(receivedCommand); - } - if (message != null) { - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug("<<<<< " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(inputBuffer)); - // process received data - message.handleMessage(inputBuffer); - message.setReceived(); - synchronized (message) { - // notify to sendMessage - message.notify(); - } - } else { - log.error("Unknown message received " + DanaRS_Packet.toHexString(inputBuffer)); - } - break; - } - } catch (Exception e) { - log.error("Unhandled exception", e); - } - startSignatureFound = false; - packetIsValid = false; - if (bufferLength < 6) { - // stop the loop - isProcessing = false; - } - } else { - // stop the loop - isProcessing = false; - } - } - } - - public void sendMessage(DanaRS_Packet message) { - processsedMessage = message; - if (message == null) - return; - - byte[] command = {(byte) message.getType(), (byte) message.getOpCode()}; - byte[] params = message.getRequestParams(); - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug(">>>>> " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params)); - byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(message.getOpCode(), params, null); - // If there is another message not completely sent, add to queue only - if (mSendQueue.size() > 0) { - // Split to parts per 20 bytes max - for (; ; ) { - if (bytes.length > 20) { - byte[] addBytes = new byte[20]; - System.arraycopy(bytes, 0, addBytes, 0, addBytes.length); - byte[] reBytes = new byte[bytes.length - addBytes.length]; - System.arraycopy(bytes, addBytes.length, reBytes, 0, reBytes.length); - bytes = reBytes; - synchronized (mSendQueue) { - mSendQueue.add(addBytes); - } - } else { - synchronized (mSendQueue) { - mSendQueue.add(bytes); - } - break; - } - } - - } else { - if (bytes.length > 20) { - // Cut first 20 bytes - byte[] sendBytes = new byte[20]; - System.arraycopy(bytes, 0, sendBytes, 0, sendBytes.length); - byte[] reBytes = new byte[bytes.length - sendBytes.length]; - System.arraycopy(bytes, sendBytes.length, reBytes, 0, reBytes.length); - bytes = reBytes; - // and send - writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), sendBytes); - // The rest split to parts per 20 bytes max - for (; ; ) { - if (bytes.length > 20) { - byte[] addBytes = new byte[20]; - System.arraycopy(bytes, 0, addBytes, 0, addBytes.length); - reBytes = new byte[bytes.length - addBytes.length]; - System.arraycopy(bytes, addBytes.length, reBytes, 0, reBytes.length); - bytes = reBytes; - synchronized (mSendQueue) { - mSendQueue.add(addBytes); - } - } else { - synchronized (mSendQueue) { - mSendQueue.add(bytes); - } - break; - } - } - } else { - writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); - } - } - // The rest from queue is send from onCharasteristicWrite (after sending 1st part) - synchronized (message) { - try { - message.wait(5000); - } catch (InterruptedException e) { - log.error("sendMessage InterruptedException", e); - log.error("Unhandled exception", e); - } - } - - //SystemClock.sleep(200); - if (!message.isReceived()) { - log.warn("Reply not received " + message.getFriendlyName()); - message.handleMessageNotReceived(); - } - } - - private void SendPairingRequest() { - // Start activity which is waiting 20sec - // On pump pairing request is displayed and is waiting for conformation - Intent i = new Intent(); - i.setClass(MainApp.instance(), PairingHelperActivity.class); - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - MainApp.instance().startActivity(i); - - byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null); - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug(">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes)); - writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); - } - - private void SendPumpCheck() { - // 1st message sent to pump after connect - String devicename = getConnectDeviceName(); - if (devicename == null || devicename.equals("")) { - Notification n = new Notification(Notification.DEVICENOTPAIRED, MainApp.gs(R.string.pairfirst), Notification.URGENT); - RxBus.Companion.getINSTANCE().send(new EventNewNotification(n)); - return; - } - byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, devicename); - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes)); - writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); - } - - private void SendTimeInfo() { - byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null); - if (L.isEnabled(L.PUMPBTCOMM)) - log.debug(">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)); - writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); - } - -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt new file mode 100644 index 0000000000..b079d5c241 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -0,0 +1,556 @@ +package info.nightscout.androidaps.plugins.pump.danaRS.services + +import android.bluetooth.* +import android.content.Context +import android.content.Intent +import android.os.SystemClock +import info.nightscout.androidaps.R +import info.nightscout.androidaps.events.EventPumpStatusChanged +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.general.nsclient.NSUpload +import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification +import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity +import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSMessageHashTable +import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess +import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.androidaps.utils.sharedPreferences.SP +import okhttp3.internal.notify +import okhttp3.internal.waitMillis +import java.util.* +import java.util.concurrent.ScheduledFuture +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class BLEComm @Inject internal constructor( + private val aapsLogger: AAPSLogger, + private val resourceHelper: ResourceHelper, + private val context: Context, + private val rxBus: RxBusWrapper, + private val sp: SP, + private val danaRSMessageHashTable: DanaRSMessageHashTable, + private val danaRPump: DanaRPump, + private val bleEncryption: BleEncryption +) { + + companion object { + private const val WRITE_DELAY_MILLIS: Long = 50 + private const val UART_READ_UUID = "0000fff1-0000-1000-8000-00805f9b34fb" + private const val UART_WRITE_UUID = "0000fff2-0000-1000-8000-00805f9b34fb" + + private const val PACKET_START_BYTE = 0xA5.toByte() + private const val PACKET_END_BYTE = 0x5A.toByte() + } + + private var scheduledDisconnection: ScheduledFuture<*>? = null + private var processedMessage: DanaRS_Packet? = null + private val mSendQueue = ArrayList() + private var mBluetoothManager: BluetoothManager? = null + private var mBluetoothAdapter: BluetoothAdapter? = null + private var connectDeviceName: String? = null + private var mBluetoothGatt: BluetoothGatt? = null + + var isConnected = false + var isConnecting = false + private var uartRead: BluetoothGattCharacteristic? = null + private var uartWrite: BluetoothGattCharacteristic? = null + + init { + initialize() + } + + private fun initialize(): Boolean { + aapsLogger.debug(LTag.PUMPBTCOMM, "Initializing BLEComm.") + if (mBluetoothManager == null) { + mBluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager + if (mBluetoothManager == null) { + aapsLogger.error("Unable to initialize BluetoothManager.") + return false + } + } + mBluetoothAdapter = mBluetoothManager?.adapter + if (mBluetoothAdapter == null) { + aapsLogger.error("Unable to obtain a BluetoothAdapter.") + return false + } + return true + } + + fun connect(from: String, address: String?): Boolean { + // test existing BT device + val tBluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager? + ?: return false + tBluetoothManager.adapter ?: return false + + if (address == null) { + aapsLogger.error("unspecified address.") + return false + } + + if (mBluetoothAdapter == null) { + if (!initialize()) { + return false + } + } + isConnecting = true + val device = mBluetoothAdapter?.getRemoteDevice(address) + if (device == null) { + aapsLogger.error("Device not found. Unable to connect from: $from") + return false + } + aapsLogger.debug(LTag.PUMPBTCOMM, "Trying to create a new connection from: $from") + connectDeviceName = device.name + mBluetoothGatt = device.connectGatt(context, false, mGattCallback) + setCharacteristicNotification(uartReadBTGattChar, true) + return true + } + + fun stopConnecting() { + isConnecting = false + } + + @Synchronized + fun disconnect(from: String) { + aapsLogger.debug(LTag.PUMPBTCOMM, "disconnect from: $from") + + // cancel previous scheduled disconnection to prevent closing upcoming connection + scheduledDisconnection?.cancel(false) + scheduledDisconnection = null + + if (mBluetoothAdapter == null || mBluetoothGatt == null) { + aapsLogger.error("disconnect not possible: (mBluetoothAdapter == null) " + (mBluetoothAdapter == null)) + aapsLogger.error("disconnect not possible: (mBluetoothGatt == null) " + (mBluetoothGatt == null)) + return + } + setCharacteristicNotification(uartReadBTGattChar, false) + mBluetoothGatt?.disconnect() + isConnected = false + SystemClock.sleep(2000) + } + + @Synchronized fun close() { + aapsLogger.debug(LTag.PUMPBTCOMM, "BluetoothAdapter close") + mBluetoothGatt?.close() + mBluetoothGatt = null + } + + private val mGattCallback: BluetoothGattCallback = object : BluetoothGattCallback() { + override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int) { + onConnectionStateChangeSynchronized(gatt, newState) // call it synchronized + } + + override fun onServicesDiscovered(gatt: BluetoothGatt, status: Int) { + aapsLogger.debug(LTag.PUMPBTCOMM, "onServicesDiscovered") + if (status == BluetoothGatt.GATT_SUCCESS) { + findCharacteristic() + } + sendPumpCheck() + // 1st message sent to pump after connect + } + + override fun onCharacteristicRead(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, status: Int) { + aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicRead: " + DanaRS_Packet.toHexString(characteristic.value)) + addToReadBuffer(characteristic.value) + readDataParsing() + } + + override fun onCharacteristicChanged(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic) { + aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicChanged: " + DanaRS_Packet.toHexString(characteristic.value)) + addToReadBuffer(characteristic.value) + Thread(Runnable { readDataParsing() }).start() + } + + override fun onCharacteristicWrite(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, status: Int) { + aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicWrite: " + DanaRS_Packet.toHexString(characteristic.value)) + Thread(Runnable { + synchronized(mSendQueue) { + // after message sent, check if there is the rest of the message waiting and send it + if (mSendQueue.size > 0) { + val bytes = mSendQueue[0] + mSendQueue.removeAt(0) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + } + }).start() + } + } + + @Synchronized + private fun setCharacteristicNotification(characteristic: BluetoothGattCharacteristic?, enabled: Boolean) { + aapsLogger.debug(LTag.PUMPBTCOMM, "setCharacteristicNotification") + if (mBluetoothAdapter == null || mBluetoothGatt == null) { + aapsLogger.error("BluetoothAdapter not initialized_ERROR") + isConnecting = false + isConnected = false + return + } + mBluetoothGatt!!.setCharacteristicNotification(characteristic, enabled) + } + + @Synchronized + private fun writeCharacteristicNoResponse(characteristic: BluetoothGattCharacteristic, data: ByteArray) { + Thread(Runnable { + SystemClock.sleep(WRITE_DELAY_MILLIS) + if (mBluetoothAdapter == null || mBluetoothGatt == null) { + aapsLogger.error("BluetoothAdapter not initialized_ERROR") + isConnecting = false + isConnected = false + return@Runnable + } + characteristic.value = data + characteristic.writeType = BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE + aapsLogger.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data)) + mBluetoothGatt!!.writeCharacteristic(characteristic) + }).start() + } + + private val uartReadBTGattChar: BluetoothGattCharacteristic + get() = uartRead + ?: BluetoothGattCharacteristic(UUID.fromString(UART_READ_UUID), BluetoothGattCharacteristic.PROPERTY_READ or BluetoothGattCharacteristic.PROPERTY_NOTIFY, 0).also { uartRead = it } + + private val uartWriteBTGattChar: BluetoothGattCharacteristic + get() = uartWrite + ?: BluetoothGattCharacteristic(UUID.fromString(UART_WRITE_UUID), BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE, 0).also { uartWrite = it } + + private fun getSupportedGattServices(): List? { + aapsLogger.debug(LTag.PUMPBTCOMM, "getSupportedGattServices") + if (mBluetoothAdapter == null || mBluetoothGatt == null) { + aapsLogger.error("BluetoothAdapter not initialized_ERROR") + isConnecting = false + isConnected = false + return null + } + return mBluetoothGatt?.services + } + + private fun findCharacteristic() { + val gattServices = getSupportedGattServices() ?: return + var uuid: String + for (gattService in gattServices) { + val gattCharacteristics = gattService.characteristics + for (gattCharacteristic in gattCharacteristics) { + uuid = gattCharacteristic.uuid.toString() + if (UART_READ_UUID == uuid) { + uartRead = gattCharacteristic + setCharacteristicNotification(uartRead, true) + } + if (UART_WRITE_UUID == uuid) { + uartWrite = gattCharacteristic + } + } + } + } + + @Synchronized + private fun onConnectionStateChangeSynchronized(gatt: BluetoothGatt, newState: Int) { + aapsLogger.debug(LTag.PUMPBTCOMM, "onConnectionStateChange") + if (newState == BluetoothProfile.STATE_CONNECTED) { + gatt.discoverServices() + } else if (newState == BluetoothProfile.STATE_DISCONNECTED) { + close() + isConnected = false + isConnecting = false + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED)) + aapsLogger.debug(LTag.PUMPBTCOMM, "Device was disconnected " + gatt.device.name) //Device was disconnected + } + } + + private val readBuffer = ByteArray(1024) + private var bufferLength = 0 + + private fun addToReadBuffer(buffer: ByteArray) { + //log.debug("addToReadBuffer " + DanaRS_Packet.toHexString(buffer)); + if (buffer.isEmpty()) { + return + } + synchronized(readBuffer) { + // Append incoming data to input buffer + System.arraycopy(buffer, 0, readBuffer, bufferLength, buffer.size) + bufferLength += buffer.size + } + } + + private fun readDataParsing() { + var startSignatureFound = false + var packetIsValid = false + var isProcessing: Boolean + isProcessing = true + var inputBuffer: ByteArray? = null + + while (isProcessing) { + var length = 0 + synchronized(readBuffer) { + + // Find packet start [A5 A5] + if (bufferLength >= 6) { + for (idxStartByte in 0 until bufferLength - 2) { + if (readBuffer[idxStartByte] == PACKET_START_BYTE && readBuffer[idxStartByte + 1] == PACKET_START_BYTE) { + if (idxStartByte > 0) { + // if buffer doesn't start with signature remove the leading trash + aapsLogger.debug(LTag.PUMPBTCOMM, "Shifting the input buffer by $idxStartByte bytes") + System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte) + bufferLength -= idxStartByte + } + startSignatureFound = true + break + } + } + } + // A5 A5 LEN TYPE CODE PARAMS CHECKSUM1 CHECKSUM2 5A 5A + // ^---- LEN -----^ + // total packet length 2 + 1 + readBuffer[2] + 2 + 2 + if (startSignatureFound) { + length = readBuffer[2].toInt() + // test if there is enough data loaded + if (length + 7 > bufferLength) return + // Verify packed end [5A 5A] + if (readBuffer[length + 5] == PACKET_END_BYTE && readBuffer[length + 6] == PACKET_END_BYTE) { + packetIsValid = true + } + } + if (packetIsValid) { + inputBuffer = ByteArray(length + 7) + // copy packet to input buffer + System.arraycopy(readBuffer, 0, inputBuffer, 0, length + 7) + // Cut off the message from readBuffer + try { + System.arraycopy(readBuffer, length + 7, readBuffer, 0, bufferLength - (length + 7)) + } catch (e: Exception) { + aapsLogger.error("length: " + length + "bufferLength: " + bufferLength) + throw e + } + bufferLength -= length + 7 + // now we have encrypted packet in inputBuffer + } + } + if (packetIsValid) { + try { + // decrypt the packet + bleEncryption.getDecryptedPacket(inputBuffer)?.let { decryptedBuffer -> + when (decryptedBuffer[0]) { + BleEncryption.DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE.toByte() -> when (decryptedBuffer[1]) { + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK.toByte() -> if (decryptedBuffer.size == 4 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + // Grab pairing key from preferences if exists + val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, "") + aapsLogger.debug(LTag.PUMPBTCOMM, "Using stored pairing key: $pairingKey") + if (pairingKey.isNotEmpty()) { + val encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey) + val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } else { + // Stored pairing key does not exists, request pairing + sendPairingRequest() + } + } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'P'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'M'.toByte() && decryptedBuffer[5] == 'P'.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + mSendQueue.clear() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumperror))) + NSUpload.uploadError(resourceHelper.gs(R.string.pumperror)) + val n = Notification(Notification.PUMPERROR, resourceHelper.gs(R.string.pumperror), Notification.URGENT) + rxBus.send(EventNewNotification(n)) + } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'S'.toByte() && decryptedBuffer[5] == 'Y'.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + mSendQueue.clear() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumpbusy))) + } else { + // ERROR in response, wrong serial number + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + mSendQueue.clear() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.connectionerror))) + sp.remove(resourceHelper.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName) + val n = Notification(Notification.WRONGSERIALNUMBER, resourceHelper.gs(R.string.wrongpassword), Notification.URGENT) + rxBus.send(EventNewNotification(n)) + } + + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY.toByte() -> { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + if (decryptedBuffer[2] == 0x00.toByte()) { + // Paring is not requested, sending time info + sendTimeInfo() + } else { + // Pairing on pump is requested + sendPairingRequest() + } + } + + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST.toByte() -> { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(decryptedBuffer)) + if (decryptedBuffer[2] != 0x00.toByte()) { + disconnect("passkey request failed") + } + } + + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN.toByte() -> { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(decryptedBuffer)) + // Paring is successful, sending time info + rxBus.send(EventDanaRSPairingSuccess()) + sendTimeInfo() + val pairingKey = byteArrayOf(decryptedBuffer[2], decryptedBuffer[3]) + // store pairing key to preferences + sp.putString(resourceHelper.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)) + aapsLogger.debug(LTag.PUMPBTCOMM, "Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)) + } + + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION.toByte() -> { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */DanaRS_Packet.toHexString(decryptedBuffer)) + val size = decryptedBuffer.size + var pass: Int = (decryptedBuffer[size - 1].toInt() and 0x000000FF shl 8) + (decryptedBuffer[size - 2].toInt() and 0x000000FF) + pass = pass xor 3463 + danaRPump.rsPassword = Integer.toHexString(pass) + aapsLogger.debug(LTag.PUMPBTCOMM, "Pump user password: " + Integer.toHexString(pass)) + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)) + isConnected = true + isConnecting = false + aapsLogger.debug(LTag.PUMPBTCOMM, "RS connected and status read") + } + } + + else -> { + // Retrieve message code from received buffer and last message sent + val originalCommand = processedMessage?.command ?: 0xFFFF + val receivedCommand = DanaRS_Packet.getCommand(decryptedBuffer) + val message: DanaRS_Packet? = if (originalCommand == receivedCommand) { + // it's response to last message + processedMessage + } else { + // it's not response to last message, create new instance + danaRSMessageHashTable.findMessage(receivedCommand) + } + if (message != null) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + message.friendlyName + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + // process received data + message.handleMessage(decryptedBuffer) + message.setReceived() + synchronized(message) { + // notify to sendMessage + message.notify() + } + } else { + aapsLogger.error("Unknown message received " + DanaRS_Packet.toHexString(decryptedBuffer)) + } + } + } + } ?: throw IllegalStateException("Null decryptedInputBuffer") + } catch (e: Exception) { + aapsLogger.error("Unhandled exception", e) + } + startSignatureFound = false + packetIsValid = false + if (bufferLength < 6) { + // stop the loop + isProcessing = false + } + } else { + // stop the loop + isProcessing = false + } + } + } + + fun sendMessage(message: DanaRS_Packet?) { + processedMessage = message + if (message == null) return + val command = byteArrayOf(message.type.toByte(), message.opCode.toByte()) + val params = message.requestParams + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + message.friendlyName + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params)) + var bytes = bleEncryption.getEncryptedPacket(message.opCode, params, null) + // If there is another message not completely sent, add to queue only + if (mSendQueue.size > 0) { + // Split to parts per 20 bytes max + while (true) { + if (bytes.size > 20) { + val addBytes = ByteArray(20) + System.arraycopy(bytes, 0, addBytes, 0, addBytes.size) + val reBytes = ByteArray(bytes.size - addBytes.size) + System.arraycopy(bytes, addBytes.size, reBytes, 0, reBytes.size) + bytes = reBytes + synchronized(mSendQueue) { mSendQueue.add(addBytes) } + } else { + synchronized(mSendQueue) { mSendQueue.add(bytes) } + break + } + } + } else { + if (bytes.size > 20) { + // Cut first 20 bytes + val sendBytes = ByteArray(20) + System.arraycopy(bytes, 0, sendBytes, 0, sendBytes.size) + var reBytes = ByteArray(bytes.size - sendBytes.size) + System.arraycopy(bytes, sendBytes.size, reBytes, 0, reBytes.size) + bytes = reBytes + // and send + writeCharacteristicNoResponse(uartWriteBTGattChar, sendBytes) + // The rest split to parts per 20 bytes max + while (true) { + if (bytes.size > 20) { + val addBytes = ByteArray(20) + System.arraycopy(bytes, 0, addBytes, 0, addBytes.size) + reBytes = ByteArray(bytes.size - addBytes.size) + System.arraycopy(bytes, addBytes.size, reBytes, 0, reBytes.size) + bytes = reBytes + synchronized(mSendQueue) { mSendQueue.add(addBytes) } + } else { + synchronized(mSendQueue) { mSendQueue.add(bytes) } + break + } + } + } else { + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + } + // The rest from queue is send from onCharacteristicWrite (after sending 1st part) + synchronized(message) { + try { + message.waitMillis(5000) + } catch (e: InterruptedException) { + aapsLogger.error("sendMessage InterruptedException", e) + } + } + + //SystemClock.sleep(200); + if (!message.isReceived) { + aapsLogger.warn(LTag.PUMPBTCOMM, "Reply not received " + message.friendlyName) + message.handleMessageNotReceived() + } + } + + private fun sendPairingRequest() { + // Start activity which is waiting 20sec + // On pump pairing request is displayed and is waiting for conformation + val i = Intent() + i.setClass(context, PairingHelperActivity::class.java) + i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + context.startActivity(i) + val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + + private fun sendPumpCheck() { + // 1st message sent to pump after connect + val deviceName = connectDeviceName + if (deviceName == null || deviceName == "") { + val n = Notification(Notification.DEVICENOTPAIRED, resourceHelper.gs(R.string.pairfirst), Notification.URGENT) + rxBus.send(EventNewNotification(n)) + return + } + val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, deviceName) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + + private fun sendTimeInfo() { + val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java index df12f7b0c3..cb6484bafd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java @@ -101,10 +101,11 @@ public class DanaRSService extends DaggerService { @Inject ActivePluginProvider activePlugin; @Inject ConstraintChecker constraintChecker; @Inject DetailedBolusInfoStorage detailedBolusInfoStorage; + @Inject BLEComm bleComm; + @Inject FabricPrivacy fabricPrivacy; private CompositeDisposable disposable = new CompositeDisposable(); - private BLEComm bleComm; private IBinder mBinder = new LocalBinder(); @@ -116,14 +117,13 @@ public class DanaRSService extends DaggerService { @Override public void onCreate() { super.onCreate(); - bleComm = new BLEComm(this, danaRSMessageHashTable, danaRPump); disposable.add(rxBus .toObservable(EventAppExit.class) .observeOn(Schedulers.io()) .subscribe(event -> { aapsLogger.debug(LTag.PUMPCOMM, "EventAppExit received"); stopSelf(); - }, exception -> FabricPrivacy.getInstance().logException(exception)) + }, fabricPrivacy::logException) ); } @@ -134,15 +134,15 @@ public class DanaRSService extends DaggerService { } public boolean isConnected() { - return bleComm.isConnected; + return bleComm.isConnected(); } public boolean isConnecting() { - return bleComm.isConnecting; + return bleComm.isConnecting(); } - public boolean connect(String from, String address, Object confirmConnect) { - return bleComm.connect(from, address, confirmConnect); + public boolean connect(String from, String address) { + return bleComm.connect(from, address); } public void stopConnecting() { diff --git a/app/src/main/jniLibs/arm64-v8a/libBleEncryption.so b/app/src/main/jniLibs/arm64-v8a/libBleEncryption.so new file mode 100644 index 0000000000000000000000000000000000000000..641efb745b5c23483796bfc031ce1cf7bf1ae240 GIT binary patch literal 22680 zcmeHP3wTu3wceA%V;%|5@Q_ym+BP#lcnM^DF=RlK2pAJos>ozA8JL;8$O9yTC3S2s zD)th!)moK+*v<@~RH-J_ThZ8Fu)aX0N^flvZ97Tu(N?`PYMlG8efFN53=>el`t`ft z$H_O@XRp^@d+oK>ew>-Jb?LH8Q*=5eFNHnHsP^hG6=D;JdyB*k3LDE|di)>H#&O!g zeW+9J*4tE&EZGRPPHhaqCug}@&$+&Td00{F;|HmwyNG$Iae6o~$g@36pqx-`bsRW7TKEWqT$#*6AsDEGf z66Rz@qP+p_Df)X@lybzW-E@4&+?TDmij8~x%EyO{8SQ+n@x9l!esuhWr@wc_&q$Y% z_?$~OxW?f_cAbdN76~vjM zG>OuPGELkYL^)iP)DQB;e=QN}T=}J0KyHc*y7a(pAvIDhEcB1}Jd%W#O&kui?KWOJKAD#8v zH|D?c=nX3`y8F$+(YCj0R!zEe*4)cieQ;01Q}5ilWsu7|FZAw5TX#3Tw)l;MZ_j`J z{)b1}m%efGftz+)u3K4p{15MK*i!Yo2_HOj;+lyS(MKBp_Q=!0;|u>;*mikI)`6l> zs^P)fU1)N^OJSyXoNI{`SS3%ym4uVO$bL!~l^4O_$>2{90RP1Ra2oeya?ZuTj9`C{ z6*{%8GPaY`o7mm+Rroq~;z%N5P)NbY+RX{!H=(<7lD^KJT8;3IX2)Cz+ z9U_HsjTd@Ws+bri#GJ67$8K zQXgS|y=Zrs(Ep&YPlf2$v;pjJwUD#zLbbs|qTM2tq))}UDqxR*R|)#V7pQmv;=dD7yp>n;W%vt3uDt5T5T(u4BNs=SC!i~PlTA7>Qsy#2L@_r-I zi`}m3sl>qg`KX|kz6huz@eW5_Jv_|e z@{~K)I=vOl<#D^p;eSl{2OOseE>>Mx+)(ABxao7K{_u6~Dt9e{&R*+c-YRds*ICh@ zpwd}UQSD;TVTpUA*QL62U45;qay_f?mR3}+%dV@YJK@oy<`QM4DC_FWT+^qEN?8Tn zINW8g zO#{!2LmAtlfy;Frq3_kewd<*74P3j93~1nDD&nmi(7;9N=kOK{T$qBx4{6{c^>g@P z4P3j=c~t|aHL$$i)WEgt_;w9ku1AR{tbxllG{HaAz{S)=VD{nWXM(dCJ23LsmqkZB zcX3l@O2+YwOyv#v;ke%b*Qw%o{W;WAF5$Gi{yWsCY3eVao~x<9jC!f2ehl@SHTC1D z@7B~$p#Geu{x<5JntCVdDU15r|10X#H1%%Ob2at%Q7_fh|AG3=n))ZG@7B~mMg2Lo zo(bEq%=t~v#bVR99N&^KM!1fMvN3%U-4h1wN;=zY+Ae#LKs zy_0u=!6!1@utW{WgoJP4WvKKS~`|6f$!&JH~Y`43V42wah zYxSix7KPd-w1nEOZ3!zzOAmC|t4xTPE@n;THCygHiTdq2Q_of%YdWczApe{Q(H2Z* zHAJ5Vy8WPgA9OG2(t4f&-TO*fD4>8Yy|KurV^-f_W|cfX1G8Ef;AwyX7qYL;@r^_Y znqb@bmV8}fQP4lWrD6q(Ru!-)^()Y}swL=O)uPuK%6%zpCBe{#1NtA>qQSO%Te=m4 z#pLzo6pUdbJu7Tc(-BKf2s{M_Hqu*Qi%v&f%Fz#IBLirs2lfx3A3F4-1T;Rfqka6Q zK=G=aAmHYati}gfc}L7S0sE>=9G1pvcpZ4Xfz{-j8jJFeWaW??$gQFKUAUhP-AbWb zyJ8HLL2d}+b-B(KEq^vQN_c{o=oTGs_K%Ciaf|KIUH)q#4*~x!#)fD*l|hy==s>g~ z;6fPNkaBIr0UN)U0=r;L^^297sbl+WBF8moAJ-D_Ul+;KG1{u62cUxiI+*uE2f)b( zGf4-~alHMS7X7zi8wGsIH7#9=-qMXR4f)4LEEwYgj4}C!PiO3*_IsdTP#GH`T0Lw? z^fN%W9dz%3Zl5l-XD8{Yq=th2F_8d#0lHZ8FwT-E55ABEU&w-Gbk!DZE8%Y|xxZNyDetOCuez-#l)5Pk^R+z-=R{z85z$3{m!a9w1#auvoW z!&0)5wUWNBjkZ?OH%@oGt=|}`<9m(j%V_sW=+$gbhcBFGD}omsf7$FzL&{ z_w!|{OJByl)|YdO}7gphqS#;CY2NBKu3%~1hmRD|eceo9T^lL7z8{<%reYje|Wn%s07mj1T3c%w+9$ezzc4~`LBL-W z$v_--=tRCio4bbh+1QMDqIrPwM$kUuOXiFbB4-qeoB=+iFrG7fPq64fIm7!HixTab za)$R2(Dln1D$nV1M!*gl^sjs_az-|bmW#O}9yi)tU=g{%qUM5<5Q}<3wy05OvwG&D z9K)>MY+KZV9Hqurp&DO+{kb=GPsx2L4W0!{twHpK#}{}gzC8EkHgH%xzMzwKuAsih zLRZb)FX>MgUqlm+uN8=|X)O8!vhxKg z4c?7QtXu}g*EBW0ycgs)aF~cMFZi|b#p@!zoWN=0Yb)f&V+eVS@G`ziZX^E`u}5~k z%@%bDeCZ0r7uqKqdjO~S^4w>OQhZ^4Qs?8Nr?K%c*m#)6#y1aOtp1G)&g3mjOtq-djO+#i3hSzCRvx1LLOh2j1}vWv1eYFkUjVs8|^fG4qv-g*Wh^~ z*XjkF=S}Ft^X9dS8#qklO>Rd`-sE+WH=W?^^EG4WcF3i5R-SW-H7|uNq%kKN+9RYi z!I#j+8qmaHKUQHIw6LG5uvLJm`Cg0#Ls+zfspDTV#1?(V&W`qOUL5@Visu5f zf6RkEF}n`1LBU={*M$A#tNN*Pn+&Y+ShJE5*@b;#=V%rU4`C$+NuhXXvYHIdF7wEGa`cU5-I(<*ixSbQa(8lkFu!RA?Mi1QY z0uA+{Q!#`{U#<`J1G<@;K_>I0PD0``ne;fb~e!%g~P!^Pw01yS$DI1zmha#x6D(r5~9euj}WiI2jk)6t;lcq?j=17PodWcD}Ywd3>=>>DJ;gzCseGlYFePM4{%)rdV{55^CBVpBKd;G8f$ zOtjc1B&9_^IW5{l9H;k_Gf&{42k9U`Tpsx+bUQ(|L33d6F)9Xwo{b0Qb zepMb;Fb61&t^4P(qXBP4&OXFz7v!4L*vNLAx1?>c-F2(CGKYL{n|CJP*CKY*Sb`pZ zhOX2HITjR0(4}XW7(;FB45#t)v!i$gIiwr$Ux4_>cL36XFA6VW z));I-cF8c~3<|N1vx9}G^D#jiJl1;_344NGYr}t#4T0<0ddNz;htXd9R+|;=tNE=> z=rIm)`yJLwe$$2V*6M;7Qgv}am(kE=G;}#fqYL@R=*D>7>2U~MKu@&X*TF}+#D;@^ zIC9r_U|Wor%wJ*Z6ZnwRqKN(00@$6#tNbS0U25(+WX*&ASvtrBp38)+_edsk5YN@p zrj&z_BRi3cF^2v6g0p9}FB!;9z-8&sCQ8d-%1cHQ@}e~cUkEE|emzCU4A7&$-N2t# zN8q`Rki~VB_C8(S6gr2YkBnQ)H|bQz9AQOX%;ERYHHcW?IaU(`upPH4#Xvzk25hYc z#FG(gpXoZB=lyEi1bsussAN8WlE(2X`20I(^!dJ=RrG1>o?e`-_bNF1Rg|MLP6C)m zdCpR%U@o1EGnC1w(|PY2)US`6559iqy_j=? zuvXz`&@_iNE0ZGd=N(4O3Eh2j!Va1v%$O5&BIh+Lt0TMGR<{ss3eLZ>p$EQaf^+8n z@GQWI#^79H%@=F2el%E*eHKL@w0u~PjiP>OVOWoS3_6(y1Hc&!hj5O(nxE}pPAG>R z_*pP=AI_UIB4uO;;N_aV8@3JkCni0=3@Q^NlrsZ3`wl{O7GwwfI0sk8MW{_W(+&D@ zu1on-&WoT6w%y0io5|OWM|?Rr%ZwPkW^t~^&w+8iJfY=7_yXxdYu{$j9HTzlC*Vx( zTJTKB3D~dQ6lgmK_a|^hw>rZ6g}s;MNOun6t~@>$x4qSe$J$up+Y|au=Qu(CIW3u5 zUwAe*N^;dbpE&QOb9unz-qL{cF|#<^^&&qn!d^DuAFrN^+Q+v@+K@6H_86<$#*XuN zMLm!2XB)eE79Y0_&iCTB0T0E005Z94{K6-7IP-*0?uHF$Z_#WY%g?$VvR{q9&^eZ% zqccy9Uk6CG?vNFGm>PVSg!=)(41*6@&CjwqPI+!iFpO z%Z|*Ss^`hvhjDIeL7pM_bny6)YxRH`k#Dk4H{x87`wF!IU1)FoeR=*Yb!laDI>i2t zWD=f+wh!(?YJEDUbJgSvsvjJIUj8jynxzI=)-a;=PUMs^wJ@wgJ?I? zfb|5<>vJKC?8$Kc74%;fnF>6E4i`x{_O*$9*9}V;2jmZDnhKLS!J86ahwjinfW4pS z1GmjCTlBD4pHW?&P2xEyty_2G!^i2YlG*try;&j;@H2Ge zfpOf|dArDQvfVt7H@5H*{9l7^4X=o5v zd~Zi`u#RMWZ`U_h$J$7zA;Dh1PV;;g^EBq@U6`XgC!+0fwAU8)!yMd!b(@@n+p&&} z<2qDa|2a4Vb`-qG*&SF5#(AkP(2M7~O5L1Y(hmXSxehQnM-yHCaEcLTrF*P%)ELEm z7p*UmpA1L3a?D;`jWd2WE^vrdiTl2$4axVyVD-5L$>lK6)3Xa2XEk1?sN>(ZriJh{ zZ-)AwOYSfr*2xcp;NRQ!V9N~bVQ5Q%irWJOy`Vd1I3EBiDOs<6myX_)D14+Y{Fz6>vSieqzF$;1f1U z(oaR>f?;Lmzmx3o=Z$)`1)j8o)D$|>)_*Y}`Lw03F7 zeud(;6Z;OzkF>u(n8u;S9Erc~h$c<7IPXlZ&a|+qJQnfc? zV}_b1L>@}SQC=aKPosOK6beCG#inQ#)ggc;$NabJWz`TSzfXbHj>+pRz>>ubkADstw zVy!{X{kpK1=|-%U(3*qqUs#mpUNh*;f}Zvxomh|X9D(tmXJ{vP9 z;hi=s*JbM9rY!6s41m+VsCVKG+bZk-GjYk>XgPJ;#rP11F&^AK8MBm zG>2hq1Psp?@V!6a@1XO3d{TcHH_SqGS3q7EW3H9QVelOR zE0^**xU6SSFAM&tl|_2!%`b7D>9{XP`{lfS6K}r&?dQSo3Fi_0p|f?$d3xBX3w<}D z@9Mf|a8oMis9)P}8Z>&l&R`sdy4okBaXb2yiau3C=1IT__o6P7 z3cdo#w;lT5ind6`cIc12laZd;(L6;yB008TX@4L^B+G?};%6UxDPK@5}8+p9bR7gD(y8NGABo zCEq^tixa3HGpKF!3Ex3B;=IB_XBd6YHZTUxK~40W8}n4Olb&JVd4zc~E5;5?7m+dv32x=lD;1(Wto@x@EfIB70#-4vx@8Kr&jol zm~NtS;Xa0-!Dq>_SnM#$iuPD6j52~!j|KFI&R7h-$#&quKpx6MeA&~3@=cVDDEIs| z7P}W^-rr&|`hDAya4hyJ%2jv}{UOSeDCu{_t3HawW}|#D5{nh0Z2UA9TaWUh&ttJ2 zC?hBjpk!Y_50r;cwxevsm(e2x$3=S5rMt0+>9$PKO-#+;b^0wWed>=wSNe^{%GAjt z9!z;)&|O3BhmUg{{RD6e9_VdH$(9K`-QyzO)%b*g9}k_A;kN+X4x3P)li}|N*all2 zN`fc7pC*3Ta2ratWLPE@1b-c$!gpga{u{d`!|+oB6@C)sAlP^h0R;UdfM7PZanh`jNc`!53`s9r8_i5quKhvp<9VB@iXS&j>plKk?b^BGhoyjjoom6IIrA1Q5I^qxIs(q}oVCDN3!JsU zSqq%Cz*!5NwZK^moVCDN3!JsU|1%57_a`L2FF|hQ+Qdr`Wc{Ut`X3YO_^t%MBz;dp zJtFGjwGHe-@$v%sE&=&|2ijNDH9{?zAY)nBBhvNp7qM!7Bjm|<8f1x=49IsDv`r+|C9A4id@YtU7y6lH&?i()-h!>dsyGr@K zJlB>RHvgl%`nR)n>!yG4hrJtLxcSIUpMLkU5BI;m`_cRN)E;`W_pWa*SoFUyp8xP) z{$BIuoH2v```otiKN)=A&{2(@J>Pk3gTX&z!o;d;n~N?y{$rp zzyFQ3VA-lyUi~2SnSJ@ZA1sZgY%RQKXW+_*Z2x)Z134c*{ltl>BVzwN_EPHTla70q zjC=kU-@CZ%`g7_^zJJC4Otb9RcIo>q>2I$w{jq)S1;+d#=dFJ3wSA>cKYq92Z-*CF z-toqYV8zuRb-QnTME~ne-^!l!^Mk(&|EWIX^8dR1w)L0%YHgnK$uQ^qYg&K!?BoYK zBKMB;zV)NKe>UYmx?a92>(ASF-J15yUvoW+e>!vcft62<6=x%vS@W&4XV0E*%`A1+ zxyv%Et1@fnEttPx-W-=X(?v&(nH$};b$C%trZszZc1~uNr@nrD-37B|$rs72tFB&G z;jXLRQ0sDMyQ(W^)mK+nxI9j8)vSt&jg>Rk*H-)7uKLWmvlo^vbe6j2IOjS`*UodV z%_%#7-t0LG=Pf8(;9Te~bc^%H$T4w`V$9r=~JOpu7 zoRwY|ny&_#Dj09nVPvvOV*M9g6yB6uMB3}S5rFd&+L3uuf~Vnza--yz`BRo}3PQ;z z^O3Amp2E>#wdCh7SR@{iXxix>m!y~cDwMG-+)y7Rzs$$7%oB1*N4k~#GEdUsE5Rkd z%g;YnD8-bvEX}^KqKPveX+rK4&f78V( zr7TONU?D)-Ps;ldZnW_?(0fxQePa8&ff$aDaC0WtH}d_a($11!wlB*^fS~?M{ycp7 zn6A9#YANZ|THpA~`ct@}v6uXEzLf8s9U=Np{!5pXC-r(BFm3yCeN=Jly7{{xbIe60Wg literal 0 HcmV?d00001 diff --git a/app/src/main/jniLibs/armeabi-v7a/libBleEncryption.so b/app/src/main/jniLibs/armeabi-v7a/libBleEncryption.so new file mode 100644 index 0000000000000000000000000000000000000000..560c7a890510c5a429c6fd95ae2192a192035533 GIT binary patch literal 26448 zcmeHw3wTu3)%HGfNhZl8nFNrCQ6^kuB1xD8Z4^Arp6{AF{KPI4bx9zW@bR%HEaZnLK5Yv zz$>7V4rv5xeFXV4Y$0O=dWxCk{3AbL>`0XiQ?-oU4IsLduK_aO4X9QC1kC`-S9wfA zT!pPN~q33&u6e*(M^Xzs*k<_XPr z-Wh#4apke=tL~WipFr-$i`;6vhgWNAXpVU-%A#ugmde zz|*d0%&){ZA%9v#ekbCeOlGV|$^Q=8Cwx!#VWJlU`ZFTRKZN)hdr)4FxJ!wD zfOs$Dalzjxe>mu$xKZ{uidUk38RR!B<-ddW{T^|n67Leg|0>4X;^g`#KyTO0kPqop ze;(;$h3xA|Y#3`rbmdrd2&Mk-KtB!irYrH^gMWJ(V~dseI?$P6Wo!)6iQYD($B#k3 zQs{q(xN{<7HYFYdyeosT5~Ndk3*<>3#n?_I{wetVV8(zw?nC+)kY|CCZ$$Yj=vS5R zNyKMEpWBrDw-CSMrU808K<|FgqkcgAs8jz5{H7}Mn34Y(^i94%`CAbmYa6itYUoD? z{m^4#ec?8=GZXeu?R!7+Z-~hMF3N4kK$xe{9}WEW^^B2U68#T=pSBIqUrOx(e^lZ5 zcO(A<@~0~CU9kI)!Ox<^&!fBm`!y?Z&t>x6M(qPV)&5rGzl!#&@jleMcI<%t3P3+8 zlQApWMe^MX{#CXCd6uI7e$)rz`452p(-HDshm5VrPgU|+adDZ~UTm*(ddurr;q2U* ztg^hcEUUJLaBih@R&|+YwY#porkc{^(o4&$?Um*CIN2<(v#dDZSy!CrtSu`pvX^_x ztC!v4T+JMnc89}5Bpj7gufHJ3pi_;`)H>^CRlDrfWljg&MDg?g>sA4mfv!tail(Fyh~UWTC# zapy9o#@wEoGCrX6r$pqU=VC0b<5^^oVrbu9$)g^*y+o$gzRFp=YN@-}UR%7FXTm@c zY$&D@t*vvSxk~e@oK-eEoDE^A9y+lMrRra2hkp0O_9T5-`NTi%`Rk3r*}7kd6LM~Ors0Db|Jd`%_Ag)B`~07KSFZW! z*dK~KSDiaIcjy7X;VIA4b6)?+GZ#beeDdLn#i^C&U-G^A_swgL>(9T{JpTpb?XY2Px$BdfaXZGF zif^8Gx9)Cg<19crfYx5>lZyc5jR0f=NGJ5rIyUm5brr4c=^?ud09xye1YnuSu++jH zSAMXB?za!6(3*`N(ltE^fMEc#eHMTovYYzQ8VM`VD?YJE%>j^qV7bR_PJW|4SYi!& z$XCd>Xah$+M7~CknZLjNMeAUCZ2XP2EHHUDwg~(oKP4Z+GO+(4AEZYMP<@UkC@=Ee zL?uk?R`pT+6-&%-Jl2R5b&p9tKTb)fzM}4YRsW5s!h_`Z<1bHC;Q>m=#W0b=p-8mqZ8H>hGI7ohD!Z};cQz7V*qF*3}vVGm(A>T87IbbAS7plBtGPJNIt29m>sF_;`7j84)<7=zYP!f^KEgfUQk zOc(=2fN&OLpA$~N{*iDzV?Bh?*@J{JxSb)4jwumFN4`in5q1h>exVEe;){g9BLPG3 zw_mLJK9qmxk-zER+4#3L|JeJ58m@~7S4M;#5#c2f;RO-l!iaEQM0k2ccv3_-BO*K| zBAgl#9vTrgMuc?{;fogrW8 zF|gP5?yW!0%XDSB@};3m@}(4GzGP0#m&Rn|OP1-25MPA&BE%0#J6jJ)I|7HKXKmro z(UZ)gZx44cbH0>nWWh)Gsbw#?!l8FgE|M%pX0Zhi_`)5p7I^bmnou$XWivo8!&o8a zOV*47*NzHCYnF>mBOVinAY~HI+twFtGzX*EN%5s_obQMaAZO~4xxwwm^%84cFA1%n zaAYS+t(P>dbAtk~w$+Ec;gaRZdP#?{(3&qzPmKjXoAHpe&3Z_BA`tFaBuxhgTWWpo z@V|sR8b~S^(o$_pj!E0hNqGe;D0WPG!g_UHy<09XSV7778R}*jqo?lQja(KEm7E+W zh{I3lsY+#o{>x1dHT(zdh) z@-@vU2P>wcrqy`A$b!GyOV((EH8R$PJMK`dkuMddzUE?<#5QWF%wuQr8?Hl=pY!)~ z{)I-$Ei}eJ4@IC@WGsh07NqXKHZ2$}REYCNY!YLUvY6++HIgjXBktsu+ko^X)3=X~ zbKl}d&FRrMKkODp|G}+w!&1}ZR?Kuypv@cLl|E|#x+*aqlYA^+azK_s_^>OLYEjGun@@qw7oiMN zQf&*b0{s|x>Q8$qehmC&`%}1{+dq+)K<*JiGBTMGd4t1vw1c&bxs$O6?!p)i>;*{Z zlXZZ*0O!!xjssM!vLSE4&q}6~t@@Uc)Mb!+4QwTsc)RKi*Dj>*uJPv+pCZN6>fs$3 zz2l?`cv?B>SCLcpvv>$&O7AsWvo~V%~X?S>OpBhGxZrHfvg!9 z*Gx7_o~}M7l_*-NSG3}VRt#J#0<^LhS}6lJ0iz&|m>Z4M^Wrb-d3{dMsv@o%d9T~Z zdz~K=_<66}@{L~C$nys4kb2z{{k_hAgs8;R?%_Fu^?VHT;Ss68s`~5BEBY&? zezbdq<7zR-5f0@+V{brXuM@r0oJv(=Z}7OPv7Hebqp+;8ovH6|jae(hq3Z`}Y-dJa z88o)spAVT#1_$X(<9c7RjgF}VA4Ov}uCZfMUhD3%QgP4nZI~%go(YwhD=;fHr*0Bo z{*3f>2Kw^DV?XWJ4a%9@%G#DM7auKq>)O%5Xf2KLTJ4i!5mGOou@6XA%*)%2_hC-H z4|DPR()3oEukTal>-!?+>-&`XS}jw2VdKRWWp;65Svd4k*Es2YXsaFL`cBh3%O@@$ zk*DFa?EA)dcvx#ZygViEu2Gm_GbjX2WxTz7H`h~&7!GajQvIhjncDEd^1jlm#jh$F zxu)t%2Q>9y1@f&QEtmVYRngU?*4?GhRfVdnbrqzmb;~!2BR*qhlB%GTdUC>LJ$Xeb z#*Yfw9tEZ04wPgwDq^yQQlX+kJYauk(8_0>U8r~(`k@(>Ry~5SN&KnUDh=gYR98K1 zl9_8!UiCc9S3T<@Rz2&W=@}J5`oz*hQfi>^8~u8hU7jyfT5IhA*;DN9^1~%_Djq74 zCEV{??`p^$ig}Xc70M5|9$Yf9Vnp7&6$h|ZNo_67YrqIVdHY>L_WqL3F;~gGlV&)i zTR)IYt!#8QI8l!@4VvNlO5md|n&CM0is)%??+%uSLvNfICtZM*&vPrsRuD(o$`_2W zJghYuDpV^|h^!n_aZ|sQx1E@ZF!Q!XGmE)h8|b>7v0Q-6Cuhz*dC4woML6`-2{|RJ zKcz`Y8Q-7Mc!FkNxmB{y45`>va<%x1OZFK<$$-zq@HSslA^VKEe?;<>Q0sMkJmMU& zwoXmmU%p8s+NnkpUs=RpO)xa0A=g?$s~)TCSA8bkcJT+2?#l?LO>vN6ptf)r)R@)L2 z*LTqZ$`P!3|H%%cOebxfN9MF6Il3w8ae;FZz$x4j3+Y(POSfSk5AXt(0!RlBG{=hK zEkDY;#&wNL|ESg(LHsL!9DI`lg0l!LK8` zHu`o)L0_MtdqkcJtfrKco8>0v1T*Y&)G8zJE+2K58IP5|H;EPtR z|9#koI7P!g#4QSVII!Nx%o_03G)8UJPpi+p26odl&N{tt-tSJ|F|X(!LZ8sxzC!4p zA=pL;exdRFNW+rot(vB!ym!1sw!>~JEm$@Fzk*Y=Y#~<+yikMokuQB6+Hs1tSfC5r z9GoRJYs5`bBGWWz6dha(9c+?t>;xGY+8&QKBM)tUQi?Vi@+gmT1S^C8B8@#MC7KFs zL?ztu9(2QQtpxvxhsAh1gaZCVJp;6DNQlBKMahz%#Y73w$fGRV~+;v<7 z@z4NDG5uB+(Mnl@9<(wF{O)ho`Lzw2&1x&IQ(B?f8ta|yO(LmHGEHp+&1k0k7Mgm{ zl*bvf;w#aQ4sOvn*qwRFZrVm0@POT9sjuR8gO+jSK#ahvd zwP;-WI@EUZVgX~D0d22pUVf_iXyKZ?qnQ6b2INb|BRIdn$}a``zSInyVNA#9id9t# zRyL^_Ux(J)RS`qJeQ5e-V*sE zP@-fyt&1&2ex`wOkNW&8N}rDfeOf=^v?TRqKEiz+ntw7Qpr-wol2&l?1**a4tJH`( z+m-w|C)FCyC@Erp%2P^8-bv~~RL*~1gPrD>)M)e(9i)+4I2OiLW-7)=6Kp2SFbO@j)r(zl294H>a7IIW z;7P_#gvaom0P>7qhmQA-lWs!Kora!!Ge*vvfTtUWpT8LtE#NgKBPlQGybiRDXz}p# zbP_X=u0?uuzw82RWHau@T2!_I?FzTPct9j21?=t$??!koZ9#II%#> zDtXHaQMzbQ%L$oO1)hr`%fL0 ztPYYb0!ROOX40gmbK6o(Fj=!%dRl*6V`Awe5PMPfbUu4(%wLCWz0WJN=MLlut{CsH zVDBNWtKH0H^Cr0p+++ilzO$d6V9EmhA0Yn3WfW6-w<;8=-a7Bk6ngu;$*y_sEqvx6 zS&{>+r4oH>_iW4)fS&=@1AKsLKnY+zfTTRx^Am;U1B#UQUnZq2qXxBC=fz_6z^*TQ4H8A-0ML+|l48m$M~MY}aME|`RLTkv7TtEpwY&kTpBELYkYhc=fh zVLFdoMiOC{tqUwgNP|$gqXIo}j4{b_xreO_+^v-PfkJ^+F;QsYnw~qA7E*6oz&&Vz zQEy4Y9Iyy+YDaF$X74;cCXV1eV*&S{1;!H{g%Q+9UkiI?M^IbLsV&A1T&6}RXGAUe z9(gvFsUaWzY%!=!2Q|SJ>s=rGi6$0)FvGhp7%$9##z+>~Q|W9lF9WT_Zj)A{pxC3H z4&tN*+Al@g8h9<84(4H;G#TYyMl>?8QzmROj)I&qE?Suyu`}QeoAS_8KAz&2pbqN7s#v9(c&kP z0V{8vQlj1z)ufA9M;e;j_WcAuMs5ZWeSh=8h{N~ZxQ5uxF^?KKhn>kWO;O+) z1+E6aoEAVD8?EPSQ$5zE2}*ivvY|53b5~6an1uBQcU16(r7~CJ!yhF zp^>bZ&}i6d$TOYS81J$S<#}>kK%B-(IX{b^A|u=+p9j!5AMX!$#G`h7uJ5!4C%c=u zr^I*@n&KZ%#vXfJmr-b6@Kfr8-h{_LktVec!HNG%-5QNnGMag*^V-%UUumzqt;?9I zK@E*-end%69+lI$Hb}qY$^xg@(H!b-@ zn%at%1yZF1TdB<`B|zT!-ofdk^5pc*m!&^5g3=S3NHfXjje+;R(hkk*O1Mq~E#ds+ zveGK`6y#tCHk^u z>3qFy0nzp?F~Eo7v0jY#OJBdQD4ATN58o zqEn|XBRjl+XwF>t)>qop!Y=KQnF}7_lxMGwtgljy8I-D0#b`8$+q$j<&W-bl=u`L= zs8w)1IH;^j`O5OroDVsg5+i!Bi}&Dx77z4-`K!N~%IikRAouI!E0iQ3AE+<)_AA%k z98oTUdqk?*+pknVHlm!&gF!EjiZJUJ1boan#wrHPN8_wW&r!UDU;LL;ZC zaXUs%6CXKE@Dq9D%;F=b8W)UNNO6xFl1gkin?b+O09OFV;sYewD{W|=10PLxCA+kn1wU(0_puCKeGgXFGnH{# zXwpPj`Fq^T0wgjF8mD=wZ`gCbccA3JI6aW2TItHQ-;b!RT8_r)f2}@^b*k*L^$gy@ zaiLM8j7;(#+}B}1n_+bqodeMhT!%f~rO=nB+VI`PW_-Z40q|RVoFt#;+@k1Dzgg?o zKz}-n3c5xO>aKzQv^eFWF(JvAOPcg*F~bkcci$yFy5_IeLX#%0NmUoT++~`KMXSGA zG8R2!AXU}SmFsVgD5-J+|A>CaHF-uIb_aap>U%11;H!(W@POA}LispU|OC z==}Hg>rk)gkWP3mh4N1Mp|>LV-Xy?1)6}z_Kf{j<{^*9N&H6`iK6AvNjKxtHi)l8X zvDnzE!C0IGjTuVRe0>w0x@nr|)Q#o|L&@;-!|+=^%@UVF=2OuDIG!{TjL!PGqX#ROli=dlKVbFO(O>9 z!ah8AphgS^M2&ZzO>n#Oe+^#G0qFcw@W#gEb_q#>n|`~Mxn9l-cKHUi2fd&+f~c_; z5ws?$^e}SMN#zjl)p<$oBySuf7Lttf?$jtZmWN_3-(B;ClE z1a0>^A*rNoALcB_f?e7S)Xj)%f9tF0nYuB$?)!9_(Lz8Nts676Bo3vRxosbP>yddv zO4NxzE7&S-7QJ~1BGv(M%!LujrSsF6RNVCkw=Kxl-66g+%NM-pyFaL9`aU7{Dv9}u zy9_1qN3}1Q#rU*KA?wMxUG=QEtH7RlREsfHb8QyBJPI=3RQ%DCg`NJ`_h}~!YO}<} zKYD^_9rZl~T64P$*$?ivE`c_Z@v&s^ZJ$}hhp?kbj!PlqNkh=UG+Xt38l1tl37Upq zcWAe=;6-K_p&3bhwVN-6*hwn=d`Cf0gAZ5|S)zpnxBIj^48cSV^GDJP_G+7CX}|1k z=rG{K!>sTUF0deY38tyGuKlB^&ZW?My=yym^fe37>9-w^G2<(exKBHUpiV!x>Onj! zI^LPJ;(cmE&XO22yWvM|$-$uDZI9%)vzH`a0#0AE!k=Ezu%Ss4N%BTVj5$7_X>5&-X(wAJfbUIQkBJE7_8QE>))<$r z>A?}27Jc)+PL>$Nh-2(!Edsu*wM`lLrf7ZhUe_=&N)*y#+orv#F(+o4kN@L!tC%j1 z5-){Jy~6@CgF2?S#Iy_J_3eq7`r}rlr}km6uNGm3xPcX`1EV zLyQHs(|2ck^WHtdOtA&Av%Pt-bK-7UjTz;hydUMUz8yLrHzBMaaWM`g&vajrJhTn-94=3OUQQ^-zMsT4*)ER zyqPDyPFyeEQgEHl?g@>l zi2Lq>9^po2>1xxMAuD#^YF3e%^#g8_< zcs8a=Cyp+NKija>n+MDIj>9r^4o$xOd3WrK%p54m7RgIK@2&>U=Aj+0YaeIhLv5^4 z*H>UPY}GgI?2Kj@uEZO}#(V?x7G+6li@`537<&R*GpL$y(vv}2j0aEjiHE5l7IcGi zN$m5ZU{@B@NgDHsjsU(hmB)UT_(-!+6vXKTP2w>44&-b82=XOh)VvgWqC39N7y~~s zj0g%0I4Y$@bA4>vYke#+y8VW7GiHl$_N9=m8>3KcJjR9^oZVjvWptax*{Hw1+xlkI z2D!gC=11dmGXvJ^mWueT>vB`ucJv8`cRFIQD#!TJtpPQex~^N( zXt9$#CEZ-Mtv0kVvENgUb&>T)^jqJEzGR$p1?xj9^!jd$P2H@;1|57b1m6o=8G9Yy zAMZl=V_?j&jBNkn*{G`Z&GBb9Id$ANrf$vi7K}W?=y1p$rm^O|G`07B+gNj?i#Wd5 zbt&|I*9Fjy1+RSI9{?%>m=j>Y_LbfvlC8ieOBg*v+g5o2a2Gq??MT)DPR7b#sI0F=@O=+n8| z`lB#=b?N$w*xWN)S5TPGioqMs)4HPR@ zWl?@PkEEmW&Mhb2HqLuJ52Gytan~r^SxZE{O~ikg*eE85x!@^Fkd3}MQ*6Um5N0uu z-(MH~P_B!8dxasNw1+8VUUQ0(xQ&G|aZJ;4A0(yidCApR+eK z>%^f2@qFCy=0&-zF0J3}lI1XC1QTAEbxjHUgar?tpSnwEwCoZv%252T=S{B*@MoWZ zI(&T5DXWT0q31g5GB7Vd#?Rgm(tJ{ZiN=VJU)8<*P-;xuoYa(-#B`y3x-~A4kgjcu zPuI3jvg!jF_}-%MJy7=XK9z4S!s`LX^e0+uQkoed@cjC}<>}=-?*Y$yJ9EIJ6g+^@#JrXeA+@D_iz4*~V9c#-iz4+#NWDdodIPYIOZ`Bv zuKQ5G)T@+OsHF7-TdaB@Y582ghjY81v*Q-Scj<^^w_-erORGV{A91a?&N3Kv7CPknMi7%hlI=k%#`mlm^w&|;V> z_gY=Ep{04>#n5f1_JFQ3MhEqhS=`szW@EtvZ>l|c1}oS_t)|u|?P9^_x`hA>KGjXF zx9p;J%QbersqPUk#tkXJnDu-k)(BULB$*y7go~j)r@Xtgk1yX9KgTN05OJE|zbEfv zsQHwx(LCa9tRn=BpUj-@((~0_6wTRjLCARVWGZB|pv~l41~FmwP;qr$yer)$G+?}L zC@?Pl+e=qqHO2N9vh*Yh%nQ;eiSL zVO>B?7sk^5eIr)tuUxqA+^U#`U2##FZLIq~aL@#O;z9TY%gpT(HA#7fpf9(eD_1io z@8F4rX$Ma%{w`K)V`Wal*n?8#JYg)?2F5p`#UjQiE2xX1$tRQH!CBe(IxH{@p&JpR zT~vHQ0@hLqa}q9FNnZ@zeUhwSdh%ju=}F9Ou)*PR_?{i`6Zo?gxGILRc?kE?-#{V0 z72#&geD%%rJKPx8SXcC8Q7`Hq`*FGUvG0^?9=qfc9^2<)kFj8^WOhYEMqP`6+xW}g zEZUJ*Z(YQKS08l%KOE_9WZJe#xF=&*L_d zm)UOiDl28LA^)fU=6`Rp-?IJeAp1RghrP?%*az$w`;dLiK4pJnU$9Qr%}%mDc7}!6 z1$GIYN-IPOF>tO#Az2tEqzD_)7I*&Bn7>C_#vK2&(-btbX7&pEHG3WRAhoaq?04)i z`vZHAwX>t_&+ISk6Bb~9XJ4`ttcRUqr`cI1v460ynM(ONPVpdruj22O5$`%4mf!SO zD(-yw?crhhy@H43x0{FMcL@*E@AU5cs)%7|3u>6+gl;6cXU4GNo0Pg(Au$)3) z2e|X)_YxkK-{0q9`F$4;%kMjRSbi_&Vfnp?hvoM|9+uzq7dh^H`MrRL<@fD8EWhXT zu>20i;k=i}<@a13mf!2qC$o`%4EO^;8{l2QJAmH<4g&TAehYXL@EYLPfIWbnfad|v z0e%VC26z(C1o$~%3!nk;Q@}>RLx6g~1Aq+x;_U<63s?iV2jB&)0@MLK05_l-Pzk62 zxByE54#0ZI?F23b6a$t3?gT6Z+zu!L+zOZjC;*6nJU}kM2KX*uI^ZV2RKR4wBtQ

!wT2Bp_igxdcx`jD)_0U+y>I$) zitBv!z?5(LFub-6<%53>uRRJ}@M(DMabWk~!fQVU-uQ)FZeu6aYxZq9A=BFfjBK_O zxD|mO;Df-0J>j*7frG$DfE#;d`hk;jeZrJ(I3>qTz*K$*Fr~j1l+*VBQ~J<8Io$?K za#jM99ByEe{~ll@vuA<#BJepd$zwV#%TokQbbP=>e-AL#->sw{0VX=ffl2-zB_0H( zawnDeX(fKcSK+lgP;M14<<|p0OLUcV(-}EE1(?$7fvNl%;GMvYXORzFcrLtl53nEj zHQ*T%%d-TS|c#dT;|1|DBiQ_Rsveu&(*Pd_Jgx&7g2|{D%KY zSmbnqoK7Uo$Z%vCnO7X=C6_Vry5CmjUy&`6*FO)-y#95Xa`{M_|Ge%u+ZEZ~Z>u|t z>#&*YA+r3p=_FEbbiY&9!2M2H1NS>IT;M|Y9I4kqS<(wDa3j=&N?c?!;r2SZ@#%k0(T>dd$sXQijQKUcjDXJvKmO1B$#+&CR5vaB4J$au_U zmAJBNP*J)`N8#*tLD(GTSVg@xu9J5$b3ah|9euX9Ba7UTr1^pdSTN_L>%TidugT9 z?7;O zjm$Hdd8RPWROXq6EXqcHb`Gnxvf6A`i@-!yJBiia$Z99E+9|AdDyyA_EXqbcmCQzo zY!t~xnQRowMyYHR%SO2zl*6r{wK*u4gK{}2mxFRSD3^nBIVhKdauZQ*Vm5PFnFDY1 zf{DyAi8*d$j>*h1g*m1&$24S7HuAyM0j>^kb%3h_Tpi%*09OaNI>6Ndt`2Z@fU5&s z9pLH!R|mK{z|{e+4sdmVtEzmppVIvEpXWas_>Ttuqk;cu;6EDpj|Tq#&;Z>9ram9e zVC*BnCxC81A0PyX#&_KDfFXcofR%tB0oDOt1ze5qyGH`r@O{Ky0KQ6N3u^E^E3i$F z@ARt2Z`nf;Pg0;20VLtfQNH`o0DK`FuAwqffFSD8F$#WOVtRlLi8xwezX3k`b+`tf z#4{b@&G>x)MH$_9M))D*6W*d={AADL&nWR1fKi3tr8WYX?jTDACjN9s9pQgK4x$kR zJ`Mpc0y`it?n&b5UjzFP$5BiTwekPYep( z|MDKJ)Su&w5&abLr9RCx0(=WYYF8`c@pz9;W;K=(kdSrf-T)_WiAU-0qbz z_hpQ@ruwdJ^KU-(O8Va?Y`DFh^_nm4`hLY9emiYW;o?8GoqFLPGjE-E|E%+xwMEl^ zv18sZZI5hza_ZT=zy3>_Dg4#@?;3~n6#qPL_`zS@`yIy*uC6UvH}~UFH~8ztldlc^ z>)ml51#)hRogFo1$$<}cmNq>0`Rb0tQ>r%o>9*%97oO>I-t&^-4e!{j)aUjb>inc` z%cKGpRAD{KKDadHlMcoOtgJ%cmQkelWh}%Usut zt(l3<3*NjceFZE&L%xjJY`Jlo)oQ(QnzN~_RafV(y=j8F?aq?7Ir(y5L~6Rp`(CQf!twoh@EmgVG3vgb^*rkgGOq7)V`yjA8~ zyQ&($rpbKi!Q^T^B;*#59yT@Z+&1JDym6w4{4M@p_aZ4;CQ&bIZ25EW$DQUoKwa&8fOXU+>*w1dWbH82%xc<=+QV#U_s>aa)roO z$4VMc2_8b4T8`=y+zFsDmclgN642Nj*$zbU*&$;z22(j2hY4&5Q#nc_OwSJidZ*fXd|pXr3alDea~CNG-PkVbT$)OdX%ks7h1H0kH=GYB`z@2@c{L zSM?!!^gIGUIrn{sucQEGm)qU F{|{vETmS$7 literal 0 HcmV?d00001 diff --git a/app/src/main/jniLibs/x86/libBleEncryption.so b/app/src/main/jniLibs/x86/libBleEncryption.so new file mode 100644 index 0000000000000000000000000000000000000000..59487f74cfe4019219eac6aebcc9ba7f73088e1e GIT binary patch literal 22296 zcmeHPe|%Kcm4A~AIOxC&HFYVbHQKZ#Erulg5}_2(M?o2iz@SB97$y^v8j>`bP;|*k zb~1Ke9I8N^QDJHDJUU2pEJ4sCD-Hz3;u5$z(#6 z-R@t!eD2&|=bn4+Irp4|3taOq0?jn>0zfR+=b{ zMiJ}GAR3^N6=e)&dnCnUTOdgcqnJz4>jO(ADR7S-HYG{YV+h2{dL*SsQ2z+(8Pb7} zf%Rq|(~vjA9+Wefb<5uL7Ob2vNoHt59fMha2kMa>_7Fe1mzJY`2z}^lQ%wIhz|c=+2B%BXejxsYG**&P-+&># zg>vSLSpQi`+GpgyhPZ8}B>m2SKS6vh1UxCy=`g2e`eaFZ9C@}shx*UO)bAwR^^)WO z9P95xycS~E3T80>Q%t7vFH6!?qy0;0U;Y_M3LE)Sx}+6Ps%?lNe>w9zXkY)Ig-?C0gchr2KsMCRe`8>)BN7m6j}CaEnw@yw06f zS;lxliAO1QSKL?bEiNl%nGRi8T=a-k46uVs+zr3Vs zeQ_z`stx7&1+G%p@)h}>2)FWw@Gif=BiN{q{I=5KzYF#i9(P%3!4l6#Ps!h@BV&Aj zU+jPXVN`m&N@KgyU63d7t>8LrUPc&a?Gf*4J+;|byH2E z^Ji%JdQYjR0!n&IgN`?Y#aFvvlxg~UYt7l`eTc5#|-U|1Iaw*?a;PSel ztm`T(sjwAZ6qOcG!Ar{48>((hY$Lb9h%3DX?k|1G$P|efAzX_vxY+umXMaBB zH-DJ^($9NGUD)@hZ{C%*a7ym&zkcJpn-4X;Hr?tjp89nE*$19@_?7t`+n*eNi}Hto z$EqLy;@vCPz52(KRh!E?C%%2`XM29S;lj_hym0&4Nq?MqW?AF%r|o0@tzsu>fXNmQ z*C0OZpLCKI;b$P8fRKg&Q!HJH0MjYKbc-=?olo?T_Hjl9Ol;&KKga{}gAd0p{1wFH zAg{UMgD4e7eZbW4?&_6p_D``EuqZktgb+P0SB| z7!I%S4cLOnNO#xlyK1E*)%y;iRJCRVk0SPU*zVrf5c>?xH8g}y0BHR6m)e`B?>KXrfBJHN&cj3Z!hBK&d|V0r|C0tv}Cr+gbkZCTG>X1NaT@ z|0~&;;yW+NeonP6Wq|AsIa5HSV$&RU&6&m?tr_Z)46C{lm>(mt!JS6S>Qpp+4dc^$ z?Ao%#FdSV<@M@sa96|M{>g-ov^t~Yajt;8FGGA5Cs*XNZpzMOL-R3(osJ@l?lKO$_ zJlr|@$IeY8U#%qpVU;8L+8{q?KSBh+swwnzDY2(n=*Je?b-cYmPa?lsN z0>jqoS+CkN?NUq-~i88zw*xXnBB6H;{H=a)4AxU6WzgDOJ50DLM|dz7NBt zGNfzD0aY2$lzz1%v8qX~$+ekC86-SIYC*Vj0;#oU zL|Mo_QdFf|Q@VX^V^pO>Q##Zms-sP9_qEHM4@Wa!R1c}j9#)|2g0Icy>*MU{|>^HmchWQ;fTN@hkgj@<30Q zHG|8RA=0Gxg-Eq}HdAZZ%vaql$q!wJR8E`0{yq-KY1692fKoHSI;+W0gN1%tC?O10 zY3foM(FNGitt!uGO5<$h8M%IgC~49hjdiJpo@!#Ef+)H59mD(ClHi(IkPai-hU#o7SNc0h4 zuGugO>c7Db)!$=|LKo${H5ZYiE(GAy>Pgfvb$RfDsV+}LU7n6nmkyyWVqijDo;KB` z!&Da}40S=uP?rv!)d|(*i+W%2>e9i{>RP2Yj;PD7cy-yO)?C0$*1 z33X|Mx_kc(N zbhGD+vV6oab!rgoDD?hXfbVii;qu8Jp zvV#kP>i3cs@mnWp^~4&Ok7baEVKzafxze#@nCkBTi!pEf6~H4uU(YB;fop{V3#?S& zZLBtRxYpERBn%x!%FyB3i|BBn-f6rJ*N&va{t}LH=&H9@l;xpKVoet8jnU*La!hEl zz$WI<7R;d~*xo>y&p-mQzcrCE`-{+0=yN?&Q0Z+2jEDL=^=nb4=@7$od)pdRn(8fJ zM$qub*h3;EZv^?l&zv=dwHjdZ^Sc?vs`_rxoZ3!!q3r@DqVNWQ(0L=RtG$uYHD6>d zs{FgoBvO7INo3g>s{j6#AU0NrFaf(o*1L&gE(}pPZj3G*9E-K1DolYo9fn+36&LPqmeWWNw*deSm%Rhs^`sT~v1HC81?(N$?1 zF*dO<5yDuQ_KIqKJ7%Qy<;lqCE0oAwWRYq=C1}uf=iQpSAV)YF4T9BTK8c-# z_V5~1a3s5h)Zv0+n{K#BKQmD1^Ur`^J2L!3iQo%HhA%bXbxjmoM{LG)?m%^i?Z>ct z^rwPP@v1Azbmoj;g~ixn+_47ATVGAtSg5X0E9~o-dEd%ge&<2=PTFvmPhd3QeAIZ`yI9b4V{mcc)xv+4n@ z+NR~v4aO!H8!1)kQyqs@XRlgyC|C@H+$IN&QSLIgbip`BQ_DlEo^X$<^n+;4(U0Ze zHmjP1^58Tei8(VFgbbt*4????LDH!ygT9VAVjT6&EQq6jvPu7pSo(d{DLD1%lWPy4 zMMTpg1e)75(-S6v%Hi-qaZuFfYoQwsCuIVDvA5-MFiFiEfIuC6Y7MK6;~gB$pcc7) zo}plLvz30i{_`R|s5u5`Ae26RQ>s-B1X6PVBQ}%+q2G%MVpMj{zfx@QaWe6g$;T9} zdN5{VsqUk-nk;zHpr42N2GSzqpNGpr9x~ZH+H`U1RW;bDoRkW?l;e`b6xc5}D<|b< zhkaJJTz@@Afyz@D>GR6*_VYIED37-vv5o1*Y0N3OjB>LR!1nPtd^wf#Vxj6h1&CAn zhNk_375kf0IlnJdt3)vxwjV)R^{Jef3e{?~?>AMs_I|;ReqW0?(2{FYV)Ib-8<7VM zr#?sP+uoNP+f7pYkx^s1S(4LUs5(xCCJhB16$@-_KazAY;EQ4|)Ra>g`SCjCq}38o zPKI8BKB4e7urLlweutHYLqDx2J@*l=#0w@-aH#=flb z4cG;nsZ|t|(dj19={a;NOq8#BaJ1PeWHKl>3z?i_r{`$DcpN$?IyJ0@u!1J{J_l?d z=A1Yd8jxGPy!ZDBlhf{N=XjOJBgC6bELS^#?wLF`uG-85@lSpxkkd~q4JtLM#UKr#x zs*a~r=PtEshg!Wo`0Sg)zlmAp^qYYe-2275*{SsY40j^0QJn3@F0qjl3jwE}IYt*T zbo;1iA{N@lID2d4VQ+Q+9_$R_m{a?OdFW(ZOn7nV^h$8DPITy5A&85^N;)i#O5fdL zcyCohn;EW~dH11raiL%L``{HAlo%e{P_U!Jzzj!iDA;}-%rs(h>%1iW<^x8h)(&#a z3z_*a9GF_-NQtM0Fh}A%{AlJ2I3{--Hm*fr2#G^g4yn#Z%nOmvn!~~kNU~Vldo{-+ z^!X#V9tSc1ICJ$|562@hE_YsI@HcOWF=H7SdfyRn9E{#^1e`r`Yt=!mx}WzAC#-Vo zoa<(NDEoQu3rp1lJrMUJ$#ScGJcmcC9&tzx(0K{1vg(t|X54h(J_Q#myufGr7>FIT{2P+JqLig~)}7 z-xb;6;F7MNG$c4Iht4Ql1xZ6THVO1WQySz}o9{xB?5`9ABD=`qyU-*1-I08f?*gp# z3X#Xe=Zr!AGx$aS=6wa^;XJC(K}VxnLm?1UPKEP^h^RNE!@Y0YgF+@t&vb#bqntwS%np+ zCGQb6egMONl%zm1nelh(J3O7rlA5@{ACbJ(cz)HD! zOwH+U6MqA2vQCwv5LZDmRnc{{c;rWrXK^z`YB?DB+ zbaCr8(4`2|0tZeVw)s?QWxv=bDYcPpCkFoG*UV+s^oJw+wFjqycHz13YITOTakJQK z+GF;bK^0p?XJ7bL81njuuOhBzC*oJX&*#l-Eg8Tq>Y&+-S0>&JySks-P29SQ3)}#~ zczcSy?SQeo0t)SdTrc%4Reck;ZSnidHKsrCYA$h%;16imYCq&r8FrEA5|`hal8TiB zs{$4&4NC~$C{PZoc|GbrP3ch`2UKUbTGgRew}pGSz++=9D2*=g!}idJRmYy#L7Arz zcp<=a7!I?(4_>3(D*4VoDf{_$lgQ4qh`g>)1D(?SDD9kQVT9Gh7fPb1>^r|&_Gjx& zM5!fGIx(gcM?AJHvmuUnY*|qcPHcbQ0Vgn8EkH%bMAe)FS{3}YIk{pJkd`Yq2g*6Y zW6Cr42hwt}VaCG7RSo+~-x1jaNX>0OYOOg+Z+px^y)a)St)VVn?vIXepK@tf>1TARpCcFN6LZA&PR#Py3U z!vQRUIs?Jtq~QRW{|oYy<>sbrK~RKEVi-|24exI#L8FEPToOTCNaW@jBhsVSUxYyh zz{MFI4fP*W)JnU$!m1{B-C~2(upr>1 z2}U&bSOLq3X+K+h9czs9gu}tYKgHY6h&@`E1yq0A9>Eg99>Eg99`(=?(H`~a_NZ6Q zJ3xDMKy`Gh&JMMzO|6EB`H1$Y7w?Yz4SUop>`|O`I4i6J6$%b?!1+3iq!t*7@o94{ zFbs1e014){K2r<~V}{S9|CMGApGuaY7GQXP20gm%SPbPztgV-3DljwSb!{j?BQwY_ z#v{;kahtPvRJ^gdH1e%+mM&r<;BD$AJaw*a8ZHfg(n$CtOGN72ORy|*bEDArhTNWf}R%vW&N|xGXb@U6!*FF3Tv5UzS&!4Y@2M^HD8Q zZvuSF$F8es>G1oG2 zlmosDcMagB8s&y-0QU_AQP)5Rh;t2C80Q+`6+gBc?i!dChHDVPXSfD>b?nj&*MNm_ zt^wS3;7{Nh=m^Z!8}26u6m<=TC9JQ$Mf4?xxN$0dN0mRk&EPi&M;joVMuw9rqskPDE@XQp9Ga zPdE&R=`chN8kGSxua}NPf57oa)!Cy~9Z;*g;W)gEDXu<9LC0=qxIarZ_Gcyz^$Z-2 za1T^k{b#ZEw<;6F0jV&Bc>}@87>2m5s8c3jb_Hr^fblY12FhdZ1c#j0-?_>hY$gu1 zJGZcjWKIlt2Eu8BaCGO*oRC;Cg>_fYz}0w^ZHyVL`|w6>bc1j@pl@DG?;T5Wiy-bo zPJ9&>f1@hXs4}sAX!RX~pD$|L-?G-c#l44mdd!75)L(HRzt&C!$Py#blb^LRe3e$mp)hV0xq8d?T11N0r&+Z*s=K5M{f` zTQRN%V;etoe4oPjB0eNq3R0oIB90q)BZZkj-0_sZpL50>x!&X>QjYD(rA>v2knt91R86<+@HCa!mQ|G~#{|8mK)*=D)cZnXx`!z7gPzhly2~2P~1k3EP2CfJ0yYpYJf(*-==IhdLR+f&F^K5!fWR z=r|okDZtT-`X9yCD-UACN#7$7VWt6QC9WnO7!I?MFru(ia8 z`xgEmZ-gcTHhIw%5n%GK5wHQgwD5Q$ypOVXU3R^IOTl{>{9of?I5$}%I7zD&i-h-d zIL!Zx9tL~=P}pq1_Tmjx{tx#s*k49@O}uLWyBRM!^Z&Pp!Tvf5%W(w&n~t~B-$FVb zHtEm$xCqw>xFF!NV{zVM%*jmR)aO|*;0E6dhkIl38E{Dlqxg7_@f7~M;bL%{H^yY|UZh5vSojoevn}Tr>l_j6Kk+Wr*!Kq~DBqGve)t(=g}T z5N}7^kGKT$HU+-Kf#c!u9K@UP|6K)$?SpU#5pO>WT!>5F#XFRU=bR6R`2x~p@N*90 zHQ-kP;yK{QR>Wzbp$V}d{PNFb4qWEIWe!~Cz-10x=D=kRT;{-K4qWEIWe)s5aDd+? z>BE~SI}otVlA7}MZ>nrTn%|YN;yrzyWAK=QVPFiuhoyhx1Z-`}*p{ye4PuYR z7h6&g@ZzAEHOAOl@xDaDmaNPRI z$A91W;y?ek`n|7zb?`q9J^u6UyDHkA|Lebee#TeM9hmmyo2S3ooAXI)*Jt-l_}-|0 zz2XyFj-L3!FRI4)CQrP!boGwqvtNBK^NlIBD-KF0(?59j?r-dGopsxiyI$&f`|0;@ zaZL3q7m^-WHs?oA-SNb{?|k>MoBpz=`M<7D37>iSclN6X^1pxUKXm-$pT1m>_o>RY zHD5b?!xtL@3s1GAzIM-5|J|2+^OcK7XRLYQm1ovHysiJfx4LI;sQ<&#pO&mTd)#yX z&uqWi^tr6GA2)Rd|Lnc)_PttN`P|)wi;~|R=bC=!FCT3G^uHZB|LFMQKRxuw4?pwm z(C?j-Uf;S?9s8fh78K3@!Hsg`%3oh&e!wq%()3x`+1b-)rLS{UdJ59ZO4BQ*&X_)9 zYK}WI-Ocl~^o^d1N__AseO6X>)=lY?ioD+P%A2Q5F+aStzN~D0iKnuxs>1Eba+htG z;w>vHaTmFYOQ)2SY}{~Tc}3YbJZ^7#ZuZQAnXYy299OPuUEx$u;Y|h8re^2NoI0am zhHIv0ojW&onk#o!c4qpd2q{aJta9l6R&FfKr0g*b#kYtU^IL!G%SsB;bFy;qwv!}f zRTkmXQC`oE@uvx*BmrCy_KeQ8zJx~k%mf*Xqqq^yGbN-OW%pvT?{DT}p5 zuF4`kWsH1CCLgT`Wz^-PQH7_3i1b8x33|d;>F`@oCca;leT zXk1YyW#QX&#rdv^3fFyt8rOzmH##Z<8vJAltU5M)3`-)PHw+yU8F8aYFq!eu9;ia( zJ5D_NW8nFu`QWHYJlEluM|jL101QKhsL_8Y4?dIwaT1QUh@l68^@v1F+l05(g}oyj zZ4?7-l=%>r&jJJ->68(Uwu_++X@HA|O&As;(B2V_wvC|;>3BH4_e1+bINB%%lNJ<- z_N@Cl0__&lv|$Xicd_F@R(zp}c8zefZ4Bv1$HRRKWvCMPX~P*NARkK~ZRi#R!Yx3c z?Pp*a;drh_yo9SoAdhJC8vw(QVloY7MIo^K2F_fEwKpFewvlD^vgp2(iDYD`*;eL)B;fO+f7jV95Nph z?sXKHaMD_2mKgH_G9MEknrpM z-RtN6aXI-+*52!}*V=onz4l`sKh*N)CRi+rd=ix#m1s>-@&uvxPRT*ITqOzruTid6 zh5>EGD^HN)VT))?!X&{*XqzYx3T_ry3DbC;^azH{`eoyZZ!`{Uf*rFB(@zc~MnGX^}Dt<*Lbc{QvJi)9m&s)27Y%Z#O{WF%mCw z=PkDvD9=Ch;JFvC>OQypmHq=sZ@hi-iMJPxxK!iRpQ{F8m^1`_5flx^-#G;SZ$sc) zSo^6;-ZZW}LyY$Yz^jy0rT$wS{}czxcLaaNSdMs2;BOT8#km|YMzr%j^rk5vh84G9 z6rfM=SALTt9ufG@1pmA^{wBen_chKqp9Tz12_V^-A>2P&Ow#qj{xmWSk1$u+$HpO5 z>HaFmzr}%4F7SB*FYP%#g#A5`BfU-6@dipnJNtz_y;pF=cU2C5FWS$T$?G}7{z<}4 zWdg@vDeSLCmD=CYbR~8nz%iVV_C@hW)PGQVY6&4kCmX?;Plr=q+lzj#G)+2^E4^zZX+{qyfeb#aYWUg9qI6c-^(L^%In_X@N`XFxSI zUszaOg9t11lsr(l)LmMpcuI;r4jqKOM~3_fn5-V9(p% zUzk33(&XFz`0h_0KJd!lbF7}yDK8xVh7S z)A6Ex04?-Lqe=>1Bro?oD8@WwyI3Y-_OLV_GzK&t^ibdB9*f41#*+FU|A?iAjT4Q{ z)r=tl{QS=XE&uu-?Xmcu`i*;7o75cHOb=1WF4;FvDvd-!q(5?>D}5{Lqs2Z};x~!` z$cV$&3w(VcY2&d&{g#j4gqKSc(V9$nbNs9~;ib*QztMyz|HaKTw^9CbXEOY}6xj2-@>J3z<=nE;V{s`4+YK8hPgu{B{?7;0Pe}b|) zCQsS3G)o<`22@2+$2dWFA3{-FlkN-GB!o}ykxY8v0-87hCcSagP1MpK(9+T-NiWa? z@9C>gXJ7z}bi+DsJQ~&mTE8Bs>(c|Zy?UUaC*V4eAJ97U1Fja`0NMcBDCh~+qa|;@ zqWY*edWRMyt3vzH7ZY1cu$0*94uJ0!xUIvs2_2-TL)$@-YiK(Ht$N@XG;PrXdv)(_ zRrel)@)LUIAwBSk9&kMm9&gJ4v6<*6^~}S1;5_IX+lOsxpKIAfY{B9Fxe4ua6D{q- zElxu_;PlV6I{mj;I3Z^&9@v@-v-H5uYyd;sFjHHvHqIf6VM~L7y2rJlVPuj~ zyTRLT(>?9F(MSURkrswZU??W+A2}TI-WE$h+YtI42AW%;8;q(p_XSt}6C)nbo>aHF zo@^aRT75K3-7eVSJ!REBXY&mowe0Yx9%dPA!h{$96|!qV*0h|3#k?t$|XUT-V`OT_W@Lpomf&YnvK z!{y_-%QFB}-<80qel(+@1Y;z(={D z!*?J4gI7VIt#Jl?3(07PoXN^+<4O>9gK_JgMq)=$=|;|PF%#8YXM>GUZR{kxw*z6e zPdAv6e(Mzy3%~D!bI4|g-wN5(RgjfbCEv4ej^CQhwNel=^`RAL(f)eW9kiYcZ+Gg( zI1(lg>ii(jA?jz7_TE98OinL zNJhmJ$*7qkxgL@Hgo{V=T~Ik#B-isu_UTX%?OrsPw-Ui{)nmxW9O@+JWg+e35!V)) zfFyvZ-j9B(zGqlkx&oT%>F_xrM+x3wB^j)_q;c?Ir9{t}FBPxj!6oCBwLE0VI*mrM z!Ql-J*VJZ&+t$(Oi!*R2IB|e^;(AckZCeSnUPxMff`ZU#tm8tbtn)m3;bfA@^G_Y& zRJW}oP6v00(|DTmy`MPG^Jk}jZ&K+AuJ zZzMQSP(%Wvo0Mos#3dlcY_R{7hJ3X48tlLHZxYjIT3@2ch!$qfd@29-qZ1MTQu{;t z*SnLM4!@>B28&Pd~nz5YgGp5QvvO^Z11J!h%62 zG-DHUx)=JQ4m8baA{dQi0%C;>WU<27d8}~XwS@|h<}j^4#z4wxJstY#>F^zaAfMJ$ zl5X!td5CG<36jCYF6H(Xa7ElsEf48-OlzW>rnQ19P3yZqW$xL9DyB67^R(tda$1v& zoYuq{oz|SsJgo)BG_3_DI;{x-H>K-rT2te}o=*sM@w6sZF|D^SsX?YS5qLM@Dr$|n zim`K7@$qg8y?`w_T=fZDBVD!j7Un6qYBL16tEePhwGrhZT(uq~gNa?rRZZZExQbf7 zl&gqta#cUJR^+PRe9T<+D5!810kf;PkaQKvNLLYO)K#3%>?(mVxk_N7t|A0n_5Hcb zRn&NJBCHwARm3V>RnMdbaTO7aM&g94s5Ry)#?D>E$Ga^Qro8KW7>wkfe<|A%v%y4I zwq41p^k4e266GO$SrTEslrI;9E8cGg~<7VwA1-PV39j< zs$j;@5rQ?xHgF^qdK&Jy#0HKOk-MZ@<2Gdg4SR6Luf;LDAcz?q!~yO_NQnv2&rdxeP#eF2GRCnNN9!Z(6lD7~M5yM+ zT+xoOBlMBbU*H7Yuo_GG(u zLRs3O9Y@P3smdt`c3_s4d4p_0z*3LNWolBh%AqwPMj}qDi^y@&o&LIBtDE`;f zU@*M1pGE~EPxmL@*-fZmW=td$S{g@5r?ofHtRtcIs4cmZF!t7^Xf8z8H6~`8nc3QU zG~rUrmuz{dp`Ah3k2h#1tQNm^BJ>942$09)X91XwsXn@|0`-`>tuxRGw`5=ze0Vw> zZj$kTkv{^p#}Ruyh`k;}6I`o=sKf2rVZ09Ebr4}hw+`6+caPvFX_OMxMsd;5gUIPt zca2O^n`;kS4#B^NLwTG%X;7v^jOkE_uG0}!X8D7RbT9-8uHo<)S~m;F?$8eqjt$yj zzxHW^cF3=tY0wV(wa+@VF3#3vxQ=^6Hj1H{Os?yxR})eAY#>n3se5WW)#m)1PiX=f z1zq0VxY9Wbn{Tx5^^d&K(7KqCuFxw`!t_Rm$#5aZbgDk=XtCtdL=JAmT_25Sp1%$g z4s+LA*C)pgdjgEv2N*MU3x^qvF&j&=v_^PbK`~Mvu%3Q^bjDN%LvKPgX2J*RE?3yz z>UV|JU0Qfixi;Fm!D!9AoE#h|VBvkgI1UK~#i>M4jWv|-IoO6uOZ3rLQX+J zxAOW}0jqHrSqfOa7CvK*kORdL~j zv>Ci3B;O-DnmUYQcQWH0;b)!s7fuI~HLoIoMj);+q>^ zN0UyYuEnTDbEArY41NRlgzk^Q=M!E9{)}xtmzxnocM^RJ=+UNT5Gp+el|`tpQ0ow; z&b6q!^aPs8r-ski&kc+AA4!Z&X?9Uf_u1PA-{HEpbZDD-gDy1aNC;@pV+<hg5XRd-oc=ZtpMcP)%SHux3h zV+-pu3}N$eMz^|#-W-)(@6a}4{Zv8&$b38kl5l5AJ295@2J}Ej;1JtDtmlXTeBP>i zTXEBW6k8D7)_GG+@9Wh zD%J?+oqZ-3(0s%ELoJVJ&=XOfM&(;AF!i>0@%N82Q>QXImG|zda2$ zdg|67HfJyvTxIN$Qg4lgReJpV^O7i&5Lh z)(6-mj|NHb8`2m*8Z?f25}%yV8&jVFV4S^C&a^0JA5s9;H?3z2WL-VTPm$w9?0L!Y z9mm~{0>@nobnodB^D2ofR);>LJ?4= zca%5-ovjcx7(ga0&am6@RwJ{&38YSSSGM=UCe@e0#)0ZIJ%FI7Cx&+AAqMg+3>vNt z-Vma3zq%_W%{y?9>YF7P83pI`DCIgcg=E^TX<5`*gq08-S{wKf=4~^z4Qk^R#GZIFnl?$)5r_+omZ%s?B*wkX#)kQqnX_tCQ1xf{uh2p^r?{?7Q(kM?|mC(rD5@YectIGn}*?-{R|jPv~oqcO+ks)`>yNWbNh#`s2qjGK|9+ z$4bk^ERi8Ro=sg`nQ$>n?C@dVmz3wv*$H;cJC@qpLJys%)s?aZh9baIbZwJSumQX2 zPJ1{|w-!4tr{P+Q4U{vm*J;o`%2n?S?1xl6%iK-KV^hU#R$aF~;{tB8XzQ)|z66(G z1*QrTV#&RZ`y7iL_d5!4Vi@x`o~`5Vlm6f5$GFV&Z+suh;tw}X{({F4F;$aTP$dNV zur!Rr1{<*@(nuXesWsPO>2vz6xik+ruZ4wVgQT%a#Tj)~>NNk7+_d5jI5Z3pMdh-IS8F%tO-Oi5^C z+;iaKW|%2ZQYVy%j2TOfB&M-QOy`l9j+?=h1;J8+63Z52hth(To=*H@|phXF$jg??EZLAmub8wK26(jMDQ$8BRjA9!r zDPi7NO%QZijV0Z@v648_64_WuPU0J@?o6KRXy!0H5>Rww^*ceONhcdLZ>%IP zW@9ChgKVrgiEpg#=54c$l@y8DSZQD|={0SvxGfDSY5vpSO~~XLOCr z!rt39-n^W4ALRGB|GV+Alf?%a;Ob(_+aJ~DoS)(Llw0aTsF-$2RUlw9MVXLEP$(oh z?6lO0*dhT_vXERU$c{&m?~hV0bSA$c8xZO4YP5@p(S=`JU1)e@l4jqFrH``LS-jsv zbm3J-PfyY^@sXqSh+@c)ngJwXb_!s+;r=9S#Q8qlk^Ht)jCGe9eijX5WfYOf+MS9H z(OO63M>v@>qwEPbpcY!mo1g<)tY_@jT61*B+rO#hd|ik+nXQQ8{V(k-*g7>AuLU}L?wdL_OdI$qiqf(%C#9Cmom z;x1wY+#M`}^3WA1(R&}Z8^IBD1BEX3^JB8<{Y}T+3)*d0g9WYI5&@C5u%aZRg!ef{ zSpY#eHI4|n1+n@8iWZy^b51Z^>N^1ZAc(Wfn^cKxz6boNtw2Ej1;)EF0i$hu5oL$H z-|4sgiW3_-F%iVn$BCFZ;Pj{dm|df61Km_PYUL9zxzlfZ4G7%YZ2?f5N1)9YQDOtQ ziJ?-T0f-FX<5V#ZU_B5J|32e=$b!DvmZQuE(8I8^?*oX8QR?kPHcx(>+h@-J63yHI zfF^DwM~oVWik68fKk6Ekc;@m)SMGkiEMv9^rs#K z0^`@tcq^Nvy*X#6H9=cPptW2|9 zlQKN133;FJ>39YAg~KVtARfZwvPJ0y9&C|^@cDT40B?(6c{@d@cLSdkhkqFLPT=Vz zC?7acc>*uuXWub(T#@#pgqu@`C4O6lX^xa(X^fR@+kscoJK^vngpqs+bztMR9|3wL z=x@c)-(Ymoa~`kU-f)_(f z_O2RcW+Z#*vmE`W1|L6cww3e*d_x591+(w&%644d;cJIA+8(t&mY8_f8flXF^TEHc zFB~3C0WcW9#TLW=F!*(RB9XonGAMs?LJa?A@a29M4zurI57vHCl%M){1pMRiLFT7W zjQD$!K8ZSrmJV(FlFp@ zBu0`a3;8~D;zEZt_*Mu;KP6$0M`P(0=NON3vdVEalrH=n9ukC z(PqF2fNOEpk`I`Uc~S#dhWW4o@Ce`zz=sj{M*znqo@ZZwFxs*P|iigfK z^zc)*qI{KCBfn*W?K&F|X$Ovbte!0f0!Iv1FB5ef8DjWxBw%&FpkwPFLl^2kHz0p! zE?&WpQaR>H0iP4FS-^Gy4+(fez%v3469fAt0k0Qunt*c!yj#Gf0N`Ol2=FW>vUKku4xYyQH0 z-5mST6 zTJ)9b#jC%4B}1r-u~}p zcYkuK_@Nh*{;+afR{C?VvCPMnmO|TbJsIXRdJPeCO34wO;$o(f;*UmcISy z6F>Xvk3(-1jDKhCvw_stPRuEBJT+0>a@QZfB!BcSV|>nx?Ck8E85v95)x|{_73CRK zQ>Nuin_~B5W_alSDq}@)RW*J%C}T!ec2;i2_>!8M%Ia@Tnk0X~XIVwXva;gpirOkq zah9iI`J|ePiZV}$yR>{#S=ox^6DzAKzE|w2$(Woyy=c07iO24q>|U~TO7YU%qN!7| z?bD}BE1Kq>UcAIJdGb{E@8d12C@ada zXW8+|6-CLaF2PR_)wq`^S>+Wq#qxqKtF)-Nyhh-bmDgr1sVyxlnuuTg%PLw`UcG8L zhc#777Ew#w)g`*LordB zOvCYi@=&^<94_;Hq#zLM;~J0f3H+EidHNkadL$gntC9aAT}JBUPqIO_EAzjE+XaE- zC^yP=MXn3>DKFO#30nlCT&JXdDL)qlT9Tx^ zTyG?75sdNjavbPxmvXg~m-${o>K{E)Uh+vupJJx9K-T5@Afa4$Lb?ASdHVgKc=;azM?RJN zhf1+-NXYK~K$nkPeKffhY8-qtC9aQ{v@P3 zR4U8yTPfrv+$;x9v>^L08~kOQ{7}EcD*5C6|FV#mYUKV<{?2N=zWDks$g6lsdAZ*i z?cy5a$4kmfxEE~XJ1H;s5%PCz^TfbNyQQ3Lm)?V*@ssj$|61~GAP0G*yd?FYa4Grt z{1-2OG)`VwELxr~AT@4!q}>vA5(R2g+8_Dd(>plFJjp0vy#CX`lZxy(K1IlHjl)ZG nB>WU~xraBiZWr=0e@L42gRE0K5!)pa@PLp{k%|N@uB!YmQ*kw& literal 0 HcmV?d00001 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt index 34f7c64def..7896cbc234 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import com.cozmo.danar.util.BleCommandUtil +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker @@ -31,6 +31,6 @@ class DanaRSMessageHashTableTest : DanaRSTestBase() { val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, danaRSPlugin, activePlugin, constraintChecker, detailedBolusInfoStorage) val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, 0, 0, 0) val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command) - Assert.assertEquals(BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong()) + Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong()) } } \ No newline at end of file From b872b82cd9f6b5c181f4cab46eaa025c131fce45 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 24 Mar 2020 18:17:28 +0100 Subject: [PATCH 005/400] kt, share some MDT code --- .../plugins/pump/common/ble/BlePreCheck.kt | 88 +++++++ .../dialog/RileyLinkBLEScanActivity.java | 59 +---- .../pump/common/utils/LocationHelper.java | 70 ------ .../plugins/pump/danaRS/DanaRSPlugin.java | 24 +- .../danaRS/activities/BLEScanActivity.java | 217 ------------------ .../pump/danaRS/activities/BLEScanActivity.kt | 172 ++++++++++++++ .../activities/PairingHelperActivity.kt | 2 + .../plugins/pump/danaRS/services/BLEComm.kt | 84 +++---- .../service/RileyLinkMedtronicService.java | 9 +- 9 files changed, 326 insertions(+), 399 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/common/ble/BlePreCheck.kt delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/LocationHelper.java delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/ble/BlePreCheck.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/ble/BlePreCheck.kt new file mode 100644 index 0000000000..2d623902bb --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/ble/BlePreCheck.kt @@ -0,0 +1,88 @@ +package info.nightscout.androidaps.plugins.pump.common.ble + +import android.Manifest +import android.bluetooth.BluetoothAdapter +import android.content.Context +import android.content.Intent +import android.content.pm.PackageManager +import android.location.LocationManager +import android.provider.Settings +import androidx.appcompat.app.AppCompatActivity +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat +import info.nightscout.androidaps.R +import info.nightscout.androidaps.utils.OKDialog +import info.nightscout.androidaps.utils.OKDialog.showConfirmation +import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class BlePreCheck @Inject constructor( + val resourceHelper: ResourceHelper +) { + + companion object { + private const val PERMISSION_REQUEST_COARSE_LOCATION = 30241 // arbitrary. + } + + fun prerequisitesCheck(activity: AppCompatActivity): Boolean { + if (!activity.packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { + OKDialog.show(activity, resourceHelper.gs(R.string.app_name), resourceHelper.gs(R.string.rileylink_scanner_ble_not_supported)) + return false + } else { + // Use this check to determine whether BLE is supported on the device. Then + // you can selectively disable BLE-related features. + if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + // your code that requires permission + ActivityCompat.requestPermissions(activity, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION), PERMISSION_REQUEST_COARSE_LOCATION) + } + + val bluetoothAdapter = BluetoothAdapter.getDefaultAdapter() + // Ensures Bluetooth is available on the device and it is enabled. If not, + // displays a dialog requesting user permission to enable Bluetooth. + if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled) { + OKDialog.show(activity, resourceHelper.gs(R.string.app_name), resourceHelper.gs(R.string.rileylink_scanner_ble_not_enabled)) + return false + } else { + // Will request that GPS be enabled for devices running Marshmallow or newer. + if (!isLocationEnabled(activity)) { + requestLocation(activity) + return false + } + } + } + return true + } + + /** + * Determine if GPS is currently enabled. + * + * + * On Android 6 (Marshmallow), location needs to be enabled for Bluetooth discovery to work. + * + * @param context The current app context. + * @return true if location is enabled, false otherwise. + */ + private fun isLocationEnabled(context: Context): Boolean { + val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager + return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || + locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) + } + + /** + * Prompt the user to enable GPS location if it isn't already on. + * + * @param activity The currently visible activity. + */ + private fun requestLocation(activity: AppCompatActivity) { + if (isLocationEnabled(activity)) { + return + } + + // Shamelessly borrowed from http://stackoverflow.com/a/10311877/868533 + showConfirmation(activity, resourceHelper.gs(R.string.location_not_found_title), resourceHelper.gs(R.string.location_not_found_message), Runnable { + activity.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)) + }) + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEScanActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEScanActivity.java index e292808ded..7695344183 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEScanActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEScanActivity.java @@ -1,6 +1,5 @@ package info.nightscout.androidaps.plugins.pump.common.dialog; -import android.Manifest; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.le.BluetoothLeScanner; @@ -10,7 +9,6 @@ import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanSettings; import android.content.Context; import android.content.Intent; -import android.content.pm.PackageManager; import android.os.Bundle; import android.os.Handler; import android.os.ParcelUuid; @@ -26,13 +24,12 @@ import android.widget.TextView; import android.widget.Toast; import androidx.appcompat.widget.Toolbar; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,10 +40,10 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.activities.NoSplashAppCompatActivity; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; +import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.GattAttributes; -import info.nightscout.androidaps.plugins.pump.common.utils.LocationHelper; import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus; import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; @@ -60,9 +57,7 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity { @Inject SP sp; @Inject RxBusWrapper rxBus; @Inject ResourceHelper resourceHelper; - - private static final int PERMISSION_REQUEST_COARSE_LOCATION = 30241; // arbitrary. - private static final int REQUEST_ENABLE_BT = 30242; // arbitrary + @Inject BlePreCheck blePrecheck; private static String TAG = "RileyLinkBLEScanActivity"; @@ -156,36 +151,13 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity { public void prepareForScanning() { - // https://developer.android.com/training/permissions/requesting.html - // http://developer.radiusnetworks.com/2015/09/29/is-your-beacon-app-ready-for-android-6.html - if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { - Toast.makeText(this, R.string.rileylink_scanner_ble_not_supported, Toast.LENGTH_SHORT).show(); - } else { - // Use this check to determine whether BLE is supported on the device. Then - // you can selectively disable BLE-related features. - if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - // your code that requires permission - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, - PERMISSION_REQUEST_COARSE_LOCATION); - } + boolean checkOK = blePrecheck.prerequisitesCheck(this); - // Ensures Bluetooth is available on the device and it is enabled. If not, - // displays a dialog requesting user permission to enable Bluetooth. - if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) { - Toast.makeText(this, R.string.rileylink_scanner_ble_not_enabled, Toast.LENGTH_SHORT).show(); - } else { - - // Will request that GPS be enabled for devices running Marshmallow or newer. - if (!LocationHelper.isLocationEnabled(this)) { - LocationHelper.requestLocationForBluetooth(this); - } - - mLEScanner = mBluetoothAdapter.getBluetoothLeScanner(); - settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build(); - filters = Arrays.asList(new ScanFilter.Builder().setServiceUuid( - ParcelUuid.fromString(GattAttributes.SERVICE_RADIO)).build()); - - } + if (checkOK) { + mLEScanner = mBluetoothAdapter.getBluetoothLeScanner(); + settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build(); + filters = Collections.singletonList(new ScanFilter.Builder().setServiceUuid( + ParcelUuid.fromString(GattAttributes.SERVICE_RADIO)).build()); } // disable currently selected RL, so that we can discover it @@ -193,19 +165,6 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity { } - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (requestCode == REQUEST_ENABLE_BT) { - if (resultCode == RESULT_OK) { - // User allowed Bluetooth to turn on - } else if (resultCode == RESULT_CANCELED) { - // Error, or user said "NO" - finish(); - } - } - } - private ScanCallback mScanCallback2 = new ScanCallback() { @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/LocationHelper.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/LocationHelper.java deleted file mode 100644 index 065f0ec4d6..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/LocationHelper.java +++ /dev/null @@ -1,70 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.common.utils; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.location.LocationManager; - -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.utils.OKDialog; - -/** - * Helper for checking if location services are enabled on the device. - */ -public class LocationHelper { - - /** - * Determine if GPS is currently enabled. - *

- * On Android 6 (Marshmallow), location needs to be enabled for Bluetooth discovery to work. - * - * @param context The current app context. - * @return true if location is enabled, false otherwise. - */ - public static boolean isLocationEnabled(Context context) { - LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - - return (locationManager != null && // - (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || // - locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))); - - // return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); - } - - - /** - * Prompt the user to enable GPS location if it isn't already on. - * - * @param parent The currently visible activity. - */ - public static void requestLocation(final Activity parent) { - if (LocationHelper.isLocationEnabled(parent)) { - return; - } - - // Shamelessly borrowed from http://stackoverflow.com/a/10311877/868533 - OKDialog.showConfirmation(parent, MainApp.gs(R.string.location_not_found_title), MainApp.gs(R.string.location_not_found_message), () -> { - parent.startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); - }); - } - - - /** - * Prompt the user to enable GPS location on devices that need it for Bluetooth discovery. - *

- * Android 6 (Marshmallow) needs GPS enabled for Bluetooth discovery to work. - * - * @param activity The currently visible activity. - */ - public static void requestLocationForBluetooth(Activity activity) { - // Location needs to be enabled for Bluetooth discovery on Marshmallow. - LocationHelper.requestLocation(activity); - } - - // public static Boolean locationPermission(ActivityWithMenu act) { - // return ActivityCompat.checkSelfPermission(act, Manifest.permission.ACCESS_FINE_LOCATION) == - // PackageManager.PERMISSION_GRANTED; - // } - -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java index b9d4af7497..3e865cb0e4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java @@ -61,6 +61,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.Round; import info.nightscout.androidaps.utils.T; +import info.nightscout.androidaps.utils.ToastUtils; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; import io.reactivex.disposables.CompositeDisposable; @@ -77,16 +78,16 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR private final TreatmentsPlugin treatmentsPlugin; private final SP sp; private final RxBusWrapper rxBus; - private final CommandQueueProvider commandQueue; private final DanaRPump danaRPump; private final DetailedBolusInfoStorage detailedBolusInfoStorage; + private final FabricPrivacy fabricPrivacy; - private static DanaRSService danaRSService; + private DanaRSService danaRSService; - private static String mDeviceAddress = ""; - public static String mDeviceName = ""; + private String mDeviceAddress = ""; + public String mDeviceName = ""; - public static PumpDescription pumpDescription = new PumpDescription(); + public PumpDescription pumpDescription = new PumpDescription(); // Bolus & history handling public int bolusStartErrorCode; // from start message @@ -112,7 +113,8 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR SP sp, CommandQueueProvider commandQueue, DanaRPump danaRPump, - DetailedBolusInfoStorage detailedBolusInfoStorage + DetailedBolusInfoStorage detailedBolusInfoStorage, + FabricPrivacy fabricPrivacy ) { super(new PluginDescription() .mainType(PluginType.PUMP) @@ -130,9 +132,9 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR this.profileFunction = profileFunction; this.treatmentsPlugin = treatmentsPlugin; this.sp = sp; - this.commandQueue = commandQueue; this.danaRPump = danaRPump; this.detailedBolusInfoStorage = detailedBolusInfoStorage; + this.fabricPrivacy = fabricPrivacy; pumpDescription.setPumpDescription(PumpType.DanaRS); } @@ -153,12 +155,12 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR disposable.add(rxBus .toObservable(EventAppExit.class) .observeOn(Schedulers.io()) - .subscribe(event -> context.unbindService(mConnection), exception -> FabricPrivacy.getInstance().logException(exception)) + .subscribe(event -> context.unbindService(mConnection), fabricPrivacy::logException) ); disposable.add(rxBus .toObservable(EventDanaRSDeviceChange.class) .observeOn(Schedulers.io()) - .subscribe(event -> loadAddress(), exception -> FabricPrivacy.getInstance().logException(exception)) + .subscribe(event -> loadAddress(), fabricPrivacy::logException) ); loadAddress(); // load device name super.onStart(); @@ -195,7 +197,9 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR public void connect(String from) { getAapsLogger().debug(LTag.PUMP, "RS connect from: " + from); if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) { - danaRSService.connect(from, mDeviceAddress); + boolean success = danaRSService.connect(from, mDeviceAddress); + if (!success) + ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.rileylink_scanner_ble_not_supported)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.java deleted file mode 100644 index 89f794259e..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.java +++ /dev/null @@ -1,217 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.danaRS.activities; - -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; -import android.bluetooth.le.BluetoothLeScanner; -import android.bluetooth.le.ScanCallback; -import android.bluetooth.le.ScanResult; -import android.content.pm.ActivityInfo; -import android.os.Bundle; -import android.os.Handler; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ListView; -import android.widget.TextView; - -import java.util.ArrayList; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.activities.NoSplashAppCompatActivity; -import info.nightscout.androidaps.plugins.bus.RxBus; -import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSDeviceChange; -import info.nightscout.androidaps.utils.SP; - -public class BLEScanActivity extends NoSplashAppCompatActivity { - private ListAdapter mListAdapter = null; - private ArrayList mDevices = new ArrayList<>(); - - private BluetoothLeScanner mBluetoothLeScanner = null; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.danars_blescanner_activity); - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - - mListAdapter = new ListAdapter(); - - ListView listView = findViewById(R.id.danars_blescanner_listview); - listView.setEmptyView(findViewById(R.id.danars_blescanner_nodevice)); - listView.setAdapter(mListAdapter); - - mListAdapter.notifyDataSetChanged(); - } - - @Override - protected void onResume() { - super.onResume(); - - BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - if (mBluetoothAdapter != null) { - if (!mBluetoothAdapter.isEnabled()) mBluetoothAdapter.enable(); - mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner(); - - if (mBluetoothLeScanner == null) { - mBluetoothAdapter.enable(); - mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner(); - } - startScan(); - } - } - - @Override - protected void onPause() { - super.onPause(); - - stopScan(); - } - - private void startScan() { - if (mBluetoothLeScanner != null) - mBluetoothLeScanner.startScan(mBleScanCallback); - } - - private void stopScan() { - if (mBluetoothLeScanner != null) - mBluetoothLeScanner.stopScan(mBleScanCallback); - } - - private void addBleDevice(BluetoothDevice device) { - if (device == null || device.getName() == null || device.getName().equals("")) { - return; - } - BluetoothDeviceItem item = new BluetoothDeviceItem(device); - if (!isSNCheck(device.getName()) || mDevices.contains(item)) { - return; - } - - mDevices.add(item); - new Handler().post(() -> mListAdapter.notifyDataSetChanged()); - } - - private ScanCallback mBleScanCallback = new ScanCallback() { - @Override - public void onScanResult(int callbackType, ScanResult result) { - addBleDevice(result.getDevice()); - } - }; - - class ListAdapter extends BaseAdapter { - - @Override - public int getCount() { - return mDevices.size(); - } - - @Override - public BluetoothDeviceItem getItem(int i) { - return mDevices.get(i); - } - - @Override - public long getItemId(int i) { - return 0; - } - - @Override - public View getView(int i, View convertView, ViewGroup parent) { - View v = convertView; - ViewHolder holder; - - if (v == null) { - v = View.inflate(getApplicationContext(), R.layout.danars_blescanner_item, null); - holder = new ViewHolder(v); - v.setTag(holder); - } else { - holder = (ViewHolder) v.getTag(); - } - - BluetoothDeviceItem item = getItem(i); - holder.setData(item); - return v; - } - - private class ViewHolder implements View.OnClickListener { - private BluetoothDeviceItem item = null; - - private TextView mName; - private TextView mAddress; - - ViewHolder(View v) { - mName = v.findViewById(R.id.ble_name); - mAddress = v.findViewById(R.id.ble_address); - - v.setOnClickListener(ViewHolder.this); - } - - @Override - public void onClick(View v) { - SP.putString(R.string.key_danars_address, item.device.getAddress()); - SP.putString(R.string.key_danars_name, mName.getText().toString()); - item.device.createBond(); - RxBus.Companion.getINSTANCE().send(new EventDanaRSDeviceChange()); - finish(); - } - - public void setData(BluetoothDeviceItem data) { - if (data != null) { - try { - String tTitle = data.device.getName(); - if (tTitle == null || tTitle.equals("")) { - tTitle = "(unknown)"; - } else if (tTitle.length() > 10) { - tTitle = tTitle.substring(0, 10); - } - mName.setText(tTitle); - - mAddress.setText(data.device.getAddress()); - - item = data; - } catch (Exception ignored) { - } - } - } - } - } - - // - private class BluetoothDeviceItem { - private BluetoothDevice device; - - BluetoothDeviceItem(BluetoothDevice device) { - super(); - this.device = device; - } - - @Override - public boolean equals(Object o) { - if (device == null || !(o instanceof BluetoothDeviceItem)) { - return false; - } - BluetoothDeviceItem checkItem = (BluetoothDeviceItem) o; - if (checkItem.device == null) { - return false; - } - return stringEquals(device.getAddress(), checkItem.device.getAddress()); - } - - boolean stringEquals(String arg1, String arg2) { - try { - return arg1.equals(arg2); - } catch (Exception e) { - return false; - } - } - } - - public static boolean isSNCheck(String sn) { - String regex = "^([a-zA-Z]{3})([0-9]{5})([a-zA-Z]{2})$"; - Pattern p = Pattern.compile(regex); - Matcher m = p.matcher(sn); - - return m.matches(); - } -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt new file mode 100644 index 0000000000..d51dc5ab05 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt @@ -0,0 +1,172 @@ +package info.nightscout.androidaps.plugins.pump.danaRS.activities + +import android.annotation.SuppressLint +import android.bluetooth.BluetoothAdapter +import android.bluetooth.BluetoothDevice +import android.bluetooth.le.BluetoothLeScanner +import android.bluetooth.le.ScanCallback +import android.bluetooth.le.ScanResult +import android.content.pm.ActivityInfo +import android.os.Bundle +import android.os.Handler +import android.view.View +import android.view.ViewGroup +import android.widget.BaseAdapter +import android.widget.TextView +import info.nightscout.androidaps.R +import info.nightscout.androidaps.activities.NoSplashAppCompatActivity +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck +import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSDeviceChange +import info.nightscout.androidaps.utils.sharedPreferences.SP +import kotlinx.android.synthetic.main.danars_blescanner_activity.* +import java.util.* +import java.util.regex.Pattern +import javax.inject.Inject + +class BLEScanActivity : NoSplashAppCompatActivity() { + + @Inject lateinit var sp: SP + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var blePreCheck: BlePreCheck + + private var listAdapter: ListAdapter? = null + private val devices = ArrayList() + private var bluetoothLeScanner: BluetoothLeScanner? = null + + @SuppressLint("SourceLockedOrientationActivity") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.danars_blescanner_activity) + requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + + blePreCheck.prerequisitesCheck(this) + + listAdapter = ListAdapter() + danars_blescanner_listview.emptyView = findViewById(R.id.danars_blescanner_nodevice) + danars_blescanner_listview.adapter = listAdapter + listAdapter?.notifyDataSetChanged() + } + + override fun onResume() { + super.onResume() + + BluetoothAdapter.getDefaultAdapter()?.let { bluetoothAdapter -> + if (!bluetoothAdapter.isEnabled) bluetoothAdapter.enable() + bluetoothLeScanner = bluetoothAdapter.bluetoothLeScanner + startScan() + } + } + + override fun onPause() { + super.onPause() + stopScan() + } + + private fun startScan() { + if (bluetoothLeScanner != null) bluetoothLeScanner!!.startScan(mBleScanCallback) + } + + private fun stopScan() { + if (bluetoothLeScanner != null) bluetoothLeScanner!!.stopScan(mBleScanCallback) + } + + private fun addBleDevice(device: BluetoothDevice?) { + if (device == null || device.name == null || device.name == "") { + return + } + val item = BluetoothDeviceItem(device) + if (!isSNCheck(device.name) || devices.contains(item)) { + return + } + devices.add(item) + Handler().post { listAdapter!!.notifyDataSetChanged() } + } + + private val mBleScanCallback: ScanCallback = object : ScanCallback() { + override fun onScanResult(callbackType: Int, result: ScanResult) { + addBleDevice(result.device) + } + } + + internal inner class ListAdapter : BaseAdapter() { + override fun getCount(): Int = devices.size + override fun getItem(i: Int): BluetoothDeviceItem = devices[i] + override fun getItemId(i: Int): Long = 0 + + override fun getView(i: Int, convertView: View?, parent: ViewGroup?): View { + var v = convertView + val holder: ViewHolder + if (v == null) { + v = View.inflate(applicationContext, R.layout.danars_blescanner_item, null) + holder = ViewHolder(v) + v.tag = holder + } else { + // reuse view if already exists + holder = v.tag as ViewHolder + } + val item = getItem(i) + holder.setData(item) + return v!! + } + + private inner class ViewHolder internal constructor(v: View) : View.OnClickListener { + private lateinit var item: BluetoothDeviceItem + private val name: TextView = v.findViewById(R.id.ble_name) + private val address: TextView = v.findViewById(R.id.ble_address) + + init { + v.setOnClickListener(this@ViewHolder) + } + + override fun onClick(v: View) { + sp.putString(R.string.key_danars_address, item.device.address) + sp.putString(R.string.key_danars_name, name.text.toString()) + item.device.createBond() + rxBus.send(EventDanaRSDeviceChange()) + finish() + } + + fun setData(data: BluetoothDeviceItem) { + var tTitle = data.device.name + if (tTitle == null || tTitle == "") { + tTitle = "(unknown)" + } else if (tTitle.length > 10) { + tTitle = tTitle.substring(0, 10) + } + name.text = tTitle + address.text = data.device.address + item = data + } + + } + } + + // + inner class BluetoothDeviceItem internal constructor(val device: BluetoothDevice) { + + override fun equals(other: Any?): Boolean { + if (other !is BluetoothDeviceItem) { + return false + } + return stringEquals(device.address, other.device.address) + } + + private fun stringEquals(arg1: String, arg2: String): Boolean { + return try { + arg1 == arg2 + } catch (e: Exception) { + false + } + } + + override fun hashCode(): Int = device.hashCode() + } + + private fun isSNCheck(sn: String?): Boolean { + val regex = "^([a-zA-Z]{3})([0-9]{5})([a-zA-Z]{2})$" + val p = Pattern.compile(regex) + val m = p.matcher(sn) + return m.matches() + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt index ba73e1b368..03d31c10a2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt @@ -1,11 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.activities +import android.annotation.SuppressLint import android.content.pm.ActivityInfo import android.os.Bundle import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.plugins.pump.danaRS.dialogs.PairingProgressDialog class PairingHelperActivity : NoSplashAppCompatActivity() { + @SuppressLint("SourceLockedOrientationActivity") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) PairingProgressDialog() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt index b079d5c241..1260573c34 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -37,6 +37,7 @@ class BLEComm @Inject internal constructor( private val sp: SP, private val danaRSMessageHashTable: DanaRSMessageHashTable, private val danaRPump: DanaRPump, + private val danaRSPlugin: DanaRSPlugin, private val bleEncryption: BleEncryption ) { @@ -52,66 +53,51 @@ class BLEComm @Inject internal constructor( private var scheduledDisconnection: ScheduledFuture<*>? = null private var processedMessage: DanaRS_Packet? = null private val mSendQueue = ArrayList() - private var mBluetoothManager: BluetoothManager? = null - private var mBluetoothAdapter: BluetoothAdapter? = null + private var bluetoothManager: BluetoothManager? = null + private var bluetoothAdapter: BluetoothAdapter? = null private var connectDeviceName: String? = null - private var mBluetoothGatt: BluetoothGatt? = null + private var bluetoothGatt: BluetoothGatt? = null var isConnected = false var isConnecting = false private var uartRead: BluetoothGattCharacteristic? = null private var uartWrite: BluetoothGattCharacteristic? = null - init { - initialize() - } - - private fun initialize(): Boolean { + @Synchronized + fun connect(from: String, address: String?): Boolean { aapsLogger.debug(LTag.PUMPBTCOMM, "Initializing BLEComm.") - if (mBluetoothManager == null) { - mBluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager - if (mBluetoothManager == null) { + if (bluetoothManager == null) { + bluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager + if (bluetoothManager == null) { aapsLogger.error("Unable to initialize BluetoothManager.") return false } } - mBluetoothAdapter = mBluetoothManager?.adapter - if (mBluetoothAdapter == null) { + bluetoothAdapter = bluetoothManager?.adapter + if (bluetoothAdapter == null) { aapsLogger.error("Unable to obtain a BluetoothAdapter.") return false } - return true - } - - fun connect(from: String, address: String?): Boolean { - // test existing BT device - val tBluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager? - ?: return false - tBluetoothManager.adapter ?: return false if (address == null) { aapsLogger.error("unspecified address.") return false } - if (mBluetoothAdapter == null) { - if (!initialize()) { - return false - } - } isConnecting = true - val device = mBluetoothAdapter?.getRemoteDevice(address) + val device = bluetoothAdapter?.getRemoteDevice(address) if (device == null) { aapsLogger.error("Device not found. Unable to connect from: $from") return false } aapsLogger.debug(LTag.PUMPBTCOMM, "Trying to create a new connection from: $from") connectDeviceName = device.name - mBluetoothGatt = device.connectGatt(context, false, mGattCallback) + bluetoothGatt = device.connectGatt(context, false, mGattCallback) setCharacteristicNotification(uartReadBTGattChar, true) return true } + @Synchronized fun stopConnecting() { isConnecting = false } @@ -124,21 +110,21 @@ class BLEComm @Inject internal constructor( scheduledDisconnection?.cancel(false) scheduledDisconnection = null - if (mBluetoothAdapter == null || mBluetoothGatt == null) { - aapsLogger.error("disconnect not possible: (mBluetoothAdapter == null) " + (mBluetoothAdapter == null)) - aapsLogger.error("disconnect not possible: (mBluetoothGatt == null) " + (mBluetoothGatt == null)) + if (bluetoothAdapter == null || bluetoothGatt == null) { + aapsLogger.error("disconnect not possible: (mBluetoothAdapter == null) " + (bluetoothAdapter == null)) + aapsLogger.error("disconnect not possible: (mBluetoothGatt == null) " + (bluetoothGatt == null)) return } setCharacteristicNotification(uartReadBTGattChar, false) - mBluetoothGatt?.disconnect() + bluetoothGatt?.disconnect() isConnected = false SystemClock.sleep(2000) } @Synchronized fun close() { aapsLogger.debug(LTag.PUMPBTCOMM, "BluetoothAdapter close") - mBluetoothGatt?.close() - mBluetoothGatt = null + bluetoothGatt?.close() + bluetoothGatt = null } private val mGattCallback: BluetoothGattCallback = object : BluetoothGattCallback() { @@ -185,20 +171,20 @@ class BLEComm @Inject internal constructor( @Synchronized private fun setCharacteristicNotification(characteristic: BluetoothGattCharacteristic?, enabled: Boolean) { aapsLogger.debug(LTag.PUMPBTCOMM, "setCharacteristicNotification") - if (mBluetoothAdapter == null || mBluetoothGatt == null) { + if (bluetoothAdapter == null || bluetoothGatt == null) { aapsLogger.error("BluetoothAdapter not initialized_ERROR") isConnecting = false isConnected = false return } - mBluetoothGatt!!.setCharacteristicNotification(characteristic, enabled) + bluetoothGatt!!.setCharacteristicNotification(characteristic, enabled) } @Synchronized private fun writeCharacteristicNoResponse(characteristic: BluetoothGattCharacteristic, data: ByteArray) { Thread(Runnable { SystemClock.sleep(WRITE_DELAY_MILLIS) - if (mBluetoothAdapter == null || mBluetoothGatt == null) { + if (bluetoothAdapter == null || bluetoothGatt == null) { aapsLogger.error("BluetoothAdapter not initialized_ERROR") isConnecting = false isConnected = false @@ -207,7 +193,7 @@ class BLEComm @Inject internal constructor( characteristic.value = data characteristic.writeType = BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE aapsLogger.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data)) - mBluetoothGatt!!.writeCharacteristic(characteristic) + bluetoothGatt!!.writeCharacteristic(characteristic) }).start() } @@ -220,15 +206,15 @@ class BLEComm @Inject internal constructor( ?: BluetoothGattCharacteristic(UUID.fromString(UART_WRITE_UUID), BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE, 0).also { uartWrite = it } private fun getSupportedGattServices(): List? { - aapsLogger.debug(LTag.PUMPBTCOMM, "getSupportedGattServices") - if (mBluetoothAdapter == null || mBluetoothGatt == null) { - aapsLogger.error("BluetoothAdapter not initialized_ERROR") - isConnecting = false - isConnected = false - return null - } - return mBluetoothGatt?.services + aapsLogger.debug(LTag.PUMPBTCOMM, "getSupportedGattServices") + if (bluetoothAdapter == null || bluetoothGatt == null) { + aapsLogger.error("BluetoothAdapter not initialized_ERROR") + isConnecting = false + isConnected = false + return null } + return bluetoothGatt?.services + } private fun findCharacteristic() { val gattServices = getSupportedGattServices() ?: return @@ -339,7 +325,7 @@ class BLEComm @Inject internal constructor( BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK.toByte() -> if (decryptedBuffer.size == 4 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) { aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) // Grab pairing key from preferences if exists - val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, "") + val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, "") aapsLogger.debug(LTag.PUMPBTCOMM, "Using stored pairing key: $pairingKey") if (pairingKey.isNotEmpty()) { val encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey) @@ -366,7 +352,7 @@ class BLEComm @Inject internal constructor( aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) mSendQueue.clear() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.connectionerror))) - sp.remove(resourceHelper.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName) + sp.remove(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName) val n = Notification(Notification.WRONGSERIALNUMBER, resourceHelper.gs(R.string.wrongpassword), Notification.URGENT) rxBus.send(EventNewNotification(n)) } @@ -396,7 +382,7 @@ class BLEComm @Inject internal constructor( sendTimeInfo() val pairingKey = byteArrayOf(decryptedBuffer[2], decryptedBuffer[3]) // store pairing key to preferences - sp.putString(resourceHelper.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)) + sp.putString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)) aapsLogger.debug(LTag.PUMPBTCOMM, "Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java index 84beb5871d..17f7b03a17 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java @@ -53,9 +53,6 @@ public class RileyLinkMedtronicService extends RileyLinkService { public RileyLinkMedtronicService() { super(); instance = this; - aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly constructed"); - MedtronicUtil.setMedtronicService(this); - pumpStatus = (MedtronicPumpStatus) medtronicPumpPlugin.getPumpStatusData(); } @@ -68,6 +65,12 @@ public class RileyLinkMedtronicService extends RileyLinkService { return instance.medtronicCommunicationManager; } + @Override public void onCreate() { + super.onCreate(); + aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly created"); + MedtronicUtil.setMedtronicService(this); + pumpStatus = (MedtronicPumpStatus) medtronicPumpPlugin.getPumpStatusData(); + } @Override public void onConfigurationChanged(Configuration newConfig) { From d1d49a8db23c5ccf80f710ca27f0b9a63b84d9f9 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 24 Mar 2020 21:00:43 +0100 Subject: [PATCH 006/400] improve PairingProgressDialog --- app/src/main/AndroidManifest.xml | 4 +- .../dependencyInjection/FragmentsModule.kt | 2 + .../activities/PairingHelperActivity.kt | 18 +++- .../danaRS/dialogs/PairingProgressDialog.java | 91 +++++++++++-------- 4 files changed, 76 insertions(+), 39 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index caf37d462d..01df007470 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -81,7 +81,9 @@ - + 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 dbd9cdf424..361521ca10 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt @@ -33,6 +33,7 @@ import info.nightscout.androidaps.plugins.profile.local.LocalProfileFragment import info.nightscout.androidaps.plugins.profile.ns.NSProfileFragment import info.nightscout.androidaps.plugins.pump.combo.ComboFragment import info.nightscout.androidaps.plugins.pump.danaR.DanaRFragment +import info.nightscout.androidaps.plugins.pump.danaRS.dialogs.PairingProgressDialog import info.nightscout.androidaps.plugins.pump.insight.LocalInsightFragment import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpFragment @@ -83,6 +84,7 @@ abstract class FragmentsModule { @ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment + @ContributesAndroidInjector abstract fun contributesPairingProgressDialog(): PairingProgressDialog @ContributesAndroidInjector abstract fun contributesBolusProgressDialog(): BolusProgressDialog @ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog @ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt index 03d31c10a2..5a2ab565ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt @@ -1,18 +1,32 @@ package info.nightscout.androidaps.plugins.pump.danaRS.activities import android.annotation.SuppressLint +import android.content.Intent import android.content.pm.ActivityInfo import android.os.Bundle import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.plugins.pump.danaRS.dialogs.PairingProgressDialog class PairingHelperActivity : NoSplashAppCompatActivity() { + var dialog: PairingProgressDialog? = null + @SuppressLint("SourceLockedOrientationActivity") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - PairingProgressDialog() + dialog = PairingProgressDialog() .setHelperActivity(this) - .show(supportFragmentManager, "PairingProgress") + dialog?.show(supportFragmentManager, "PairingProgress") requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } + + override fun onDestroy() { + super.onDestroy() + dialog = null + } + + override fun onNewIntent(intent: Intent?) { + super.onNewIntent(intent) + dialog?.resetToNewPairing() + } + } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java index 9518dac337..dcf17dc355 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java @@ -14,19 +14,25 @@ import android.widget.Button; import android.widget.ProgressBar; import android.widget.TextView; -import androidx.fragment.app.DialogFragment; +import javax.inject.Inject; -import info.nightscout.androidaps.MainApp; +import dagger.android.support.DaggerDialogFragment; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity; import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess; import info.nightscout.androidaps.utils.FabricPrivacy; +import info.nightscout.androidaps.utils.resources.ResourceHelper; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.schedulers.Schedulers; -public class PairingProgressDialog extends DialogFragment { +public class PairingProgressDialog extends DaggerDialogFragment { + + @Inject ResourceHelper resourceHelper; + @Inject RxBusWrapper rxBus; + @Inject FabricPrivacy fabricPrivacy; + private CompositeDisposable disposable = new CompositeDisposable(); private TextView statusView; @@ -36,41 +42,21 @@ public class PairingProgressDialog extends DialogFragment { private static boolean pairingEnded = false; - private static Handler sHandler; - private static HandlerThread sHandlerThread; + private static Handler handler; + private static HandlerThread handlerThread; + + private static Runnable runnable; public PairingProgressDialog() { super(); // Required empty public constructor - if (sHandlerThread == null) { - sHandlerThread = new HandlerThread(PairingProgressDialog.class.getSimpleName()); - sHandlerThread.start(); - sHandler = new Handler(sHandlerThread.getLooper()); + if (handlerThread == null) { + handlerThread = new HandlerThread(PairingProgressDialog.class.getSimpleName()); + handlerThread.start(); + handler = new Handler(handlerThread.getLooper()); } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.danars_pairingprogressdialog, container, false); - - getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); - getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); - setCancelable(false); - getDialog().setCanceledOnTouchOutside(false); - - statusView = view.findViewById(R.id.danars_pairingprogress_status); - progressBar = view.findViewById(R.id.danars_pairingprogress_progressbar); - button = view.findViewById(R.id.ok); - - progressBar.setMax(100); - progressBar.setProgress(0); - statusView.setText(MainApp.gs(R.string.waitingforpairing)); - button.setVisibility(View.GONE); - button.setOnClickListener(v -> dismiss()); - - sHandler.post(() -> { + runnable = () -> { for (int i = 0; i < 20; i++) { if (pairingEnded) { Activity activity = getActivity(); @@ -102,17 +88,36 @@ public class PairingProgressDialog extends DialogFragment { button.setVisibility(View.VISIBLE); }); } - }); + }; + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.danars_pairingprogressdialog, container, false); + + getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); + getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); + setCancelable(false); + getDialog().setCanceledOnTouchOutside(false); + + statusView = view.findViewById(R.id.danars_pairingprogress_status); + progressBar = view.findViewById(R.id.danars_pairingprogress_progressbar); + button = view.findViewById(R.id.ok); + + setViews(); + return view; } @Override public void onResume() { super.onResume(); - disposable.add(RxBus.Companion.getINSTANCE() + disposable.add(rxBus .toObservable(EventDanaRSPairingSuccess.class) .observeOn(Schedulers.io()) - .subscribe(event -> pairingEnded = true, exception -> FabricPrivacy.getInstance().logException(exception)) + .subscribe(event -> pairingEnded = true, fabricPrivacy::logException) ); if (pairingEnded) dismiss(); getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); @@ -132,6 +137,20 @@ public class PairingProgressDialog extends DialogFragment { disposable.clear(); } + private void setViews() { + progressBar.setMax(100); + progressBar.setProgress(0); + statusView.setText(resourceHelper.gs(R.string.waitingforpairing)); + button.setVisibility(View.GONE); + button.setOnClickListener(v -> dismiss()); + handler.post(runnable); + } + + public void resetToNewPairing() { + handler.removeCallbacks(runnable); + setViews(); + } + public PairingProgressDialog setHelperActivity(PairingHelperActivity activity) { this.helperActivity = activity; return this; From 5ce8b998d9f2530cbcb74abe92df6a16264295f8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 26 Mar 2020 20:25:20 +0100 Subject: [PATCH 007/400] RS v3 encryption --- app/src/main/AndroidManifest.xml | 2 + .../dependencyInjection/ActivitiesModule.kt | 2 + .../pump/danaR/AbstractDanaRPlugin.java | 30 +- .../plugins/pump/danaR/DanaRFragment.kt | 22 ++ .../plugins/pump/danaRS/DanaRSPlugin.java | 7 + .../danaRS/activities/EnterPinActivity.kt | 99 ++++++ .../danaRS/comm/DanaRSMessageHashTable.kt | 2 +- ...cket_General_Initial_Screen_Information.kt | 1 - .../danaRS/comm/DanaRS_Packet_Notify_Alarm.kt | 14 +- .../pump/danaRS/encryption/BleEncryption.java | 2 +- .../plugins/pump/danaRS/services/BLEComm.kt | 310 +++++++++++++----- .../extensions/HexByteArrayConversion.kt | 32 ++ .../textValidator/DefaultEditTextValidator.kt | 23 +- .../ValidatingEditTextPreference.kt | 3 +- .../res/layout/danars_enter_pin_activity.xml | 90 +++++ app/src/main/res/values/strings.xml | 12 + app/src/main/res/values/validator.xml | 4 + .../comm/DanaRS_Packet_Notify_AlarmTest.kt | 2 +- 18 files changed, 549 insertions(+), 108 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt create mode 100644 app/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt create mode 100644 app/src/main/res/layout/danars_enter_pin_activity.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 01df007470..c89a41390a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -84,6 +84,8 @@ + diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt index e7411ad56b..57c8aea06e 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt @@ -13,6 +13,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyL import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActivity import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRUserOptionsActivity import info.nightscout.androidaps.plugins.pump.danaRS.activities.BLEScanActivity +import info.nightscout.androidaps.plugins.pump.danaRS.activities.EnterPinActivity import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity import info.nightscout.androidaps.plugins.pump.insight.activities.InsightAlertActivity import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity @@ -28,6 +29,7 @@ abstract class ActivitiesModule { @ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity @ContributesAndroidInjector abstract fun contributeDanaRHistoryActivity(): DanaRHistoryActivity @ContributesAndroidInjector abstract fun contributeDanaRUserOptionsActivity(): DanaRUserOptionsActivity + @ContributesAndroidInjector abstract fun contributeEnterPinActivity(): EnterPinActivity @ContributesAndroidInjector abstract fun contributeErrorHelperActivity(): ErrorHelperActivity @ContributesAndroidInjector abstract fun contributesHistoryBrowseActivity(): HistoryBrowseActivity @ContributesAndroidInjector abstract fun contributesInsightAlertActivity(): InsightAlertActivity diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java index b448990575..6de5376b89 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java @@ -15,6 +15,8 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.events.EventConfigBuilderChange; +import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.ConstraintsInterface; @@ -42,6 +44,8 @@ import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.Round; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; +import io.reactivex.disposables.CompositeDisposable; +import io.reactivex.schedulers.Schedulers; /** * Created by mike on 28.01.2018. @@ -50,6 +54,8 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; public abstract class AbstractDanaRPlugin extends PumpPluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface { protected AbstractDanaRExecutionService sExecutionService; + protected CompositeDisposable disposable = new CompositeDisposable(); + protected boolean useExtendedBoluses = false; protected PumpDescription pumpDescription = new PumpDescription(); @@ -86,6 +92,28 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump this.sp = sp; } + @Override protected void onStart() { + super.onStart(); + disposable.add(rxBus + .toObservable(EventConfigBuilderChange.class) + .observeOn(Schedulers.io()) + .subscribe(event -> danaRPump.setLastConnection(0)) + ); + disposable.add(rxBus + .toObservable(EventPreferenceChange.class) + .observeOn(Schedulers.io()) + .subscribe(event -> { + if (event.isChanged(getResourceHelper(), R.string.key_danar_bt_name)) + danaRPump.setLastConnection(0); + }) + ); + } + + @Override protected void onStop() { + super.onStop(); + disposable.clear(); + } + @Override public boolean isSuspended() { return danaRPump.getPumpSuspended(); @@ -488,6 +516,4 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump public void timeDateOrTimeZoneChanged() { } - - } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt index 2e7104c9e1..e9e001ced0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt @@ -11,6 +11,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.TDDStatsActivity import info.nightscout.androidaps.dialogs.ProfileViewerDialog import info.nightscout.androidaps.events.EventExtendedBolusChange +import info.nightscout.androidaps.events.EventInitializationChanged import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.events.EventTempBasalChange import info.nightscout.androidaps.interfaces.ActivePluginProvider @@ -24,13 +25,16 @@ import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActi import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRUserOptionsActivity import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRNewStatus import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin +import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.queue.events.EventQueueChanged import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.OKDialog import info.nightscout.androidaps.utils.SetWarnColor import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.extensions.plusAssign import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.androidaps.utils.sharedPreferences.SP import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import kotlinx.android.synthetic.main.danar_fragment.* @@ -43,8 +47,10 @@ class DanaRFragment : DaggerFragment() { @Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin + @Inject lateinit var danaRSPlugin: DanaRSPlugin @Inject lateinit var danaRPump: DanaRPump @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var sp: SP private var disposable: CompositeDisposable = CompositeDisposable() @@ -93,12 +99,28 @@ class DanaRFragment : DaggerFragment() { danaRPump.lastConnection = 0 commandQueue.readStatus("Clicked connect to pump", null) } + if (danaRSPlugin.isEnabled()) + danar_btconnection.setOnLongClickListener { + activity?.let { + OKDialog.showConfirmation(it, resourceHelper.gs(R.string.resetpairing), Runnable { + sp.remove(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName) + sp.remove(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName) + sp.remove(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName) + sp.remove(resourceHelper.gs(R.string.key_danars_v3_randomsynckey) + danaRSPlugin.mDeviceName) + }) + } + true + } } @Synchronized override fun onResume() { super.onResume() loopHandler.postDelayed(refreshLoop, T.mins(1).msecs()) + disposable += rxBus + .toObservable(EventInitializationChanged::class.java) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe({ updateGUI() }, { fabricPrivacy.logException(it) }) disposable += rxBus .toObservable(EventDanaRNewStatus::class.java) .observeOn(AndroidSchedulers.mainThread()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java index 3e865cb0e4..759b473d75 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java @@ -27,6 +27,7 @@ import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.events.EventAppExit; +import info.nightscout.androidaps.events.EventConfigBuilderChange; import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.ConstraintsInterface; @@ -157,6 +158,11 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR .observeOn(Schedulers.io()) .subscribe(event -> context.unbindService(mConnection), fabricPrivacy::logException) ); + disposable.add(rxBus + .toObservable(EventConfigBuilderChange.class) + .observeOn(Schedulers.io()) + .subscribe(event -> danaRPump.setLastConnection(0)) + ); disposable.add(rxBus .toObservable(EventDanaRSDeviceChange.class) .observeOn(Schedulers.io()) @@ -191,6 +197,7 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR private void loadAddress() { mDeviceAddress = sp.getString(R.string.key_danars_address, ""); mDeviceName = sp.getString(R.string.key_danars_name, ""); + danaRPump.setLastConnection(0); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt new file mode 100644 index 0000000000..524dfc9976 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt @@ -0,0 +1,99 @@ +package info.nightscout.androidaps.plugins.pump.danaRS.activities + +import android.os.Bundle +import android.util.Base64 +import info.nightscout.androidaps.R +import info.nightscout.androidaps.activities.NoSplashAppCompatActivity +import info.nightscout.androidaps.events.EventPumpStatusChanged +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.plugins.pump.danaRS.services.BLEComm +import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.OKDialog +import info.nightscout.androidaps.utils.extensions.hexStringToByteArray +import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.androidaps.utils.sharedPreferences.SP +import info.nightscout.androidaps.utils.textValidator.DefaultEditTextValidator +import info.nightscout.androidaps.utils.textValidator.EditTextValidator +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.CompositeDisposable +import kotlinx.android.synthetic.main.danars_enter_pin_activity.* +import kotlinx.android.synthetic.main.okcancel.* +import javax.inject.Inject +import kotlin.experimental.xor + +class EnterPinActivity : NoSplashAppCompatActivity() { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var fabricPrivacy: FabricPrivacy + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRSPlugin: DanaRSPlugin + @Inject lateinit var sp: SP + @Inject lateinit var bleComm: BLEComm + + private val disposable = CompositeDisposable() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.danars_enter_pin_activity) + + val p1 = DefaultEditTextValidator(rs_v3_pin1, this) + .setTestErrorString(resourceHelper.gs(R.string.error_mustbe12hexadidits), this) + .setCustomRegexp(resourceHelper.gs(R.string.twelvehexanumber), this) + .setTestType(EditTextValidator.TEST_REGEXP, this) + val p2 = DefaultEditTextValidator(rs_v3_pin2, this) + .setTestErrorString(resourceHelper.gs(R.string.error_mustbe8hexadidits), this) + .setCustomRegexp(resourceHelper.gs(R.string.eighthexanumber), this) + .setTestType(EditTextValidator.TEST_REGEXP, this) + + ok.setOnClickListener { + if (p1.testValidity(false) && p2.testValidity(false)) { + val result = checkPairingCheckSum( + rs_v3_pin1.text.toString().hexStringToByteArray(), + rs_v3_pin2.text.toString().substring(0..5).hexStringToByteArray(), + rs_v3_pin2.text.toString().substring(6..7).hexStringToByteArray()) + if (result) { + bleComm.finishV3Pairing() + finish() + } + else OKDialog.show(this, resourceHelper.gs(R.string.error), resourceHelper.gs(R.string.danar_invalidinput)) + } + } + cancel.setOnClickListener { finish() } + } + + override fun onResume() { + super.onResume() + disposable.add(rxBus + .toObservable(EventPumpStatusChanged::class.java) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe({ if (it.status == EventPumpStatusChanged.Status.DISCONNECTED) finish() }) { fabricPrivacy.logException(it) } + ) + } + + override fun onPause() { + super.onPause() + disposable.clear() + } + + private fun checkPairingCheckSum(pairingKey: ByteArray, randomPairingKey: ByteArray, checksum: ByteArray): Boolean { + + // pairingKey ByteArray(6) + // randomPairingKey ByteArray(3) + // checksum ByteArray(1) + + var pairingKeyCheckSum: Byte = 0 + for (i in pairingKey.indices) + pairingKeyCheckSum = pairingKeyCheckSum xor pairingKey[i] + + sp.putString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, Base64.encodeToString(pairingKey, Base64.DEFAULT)) + + for (i in randomPairingKey.indices) + pairingKeyCheckSum = pairingKeyCheckSum xor randomPairingKey[i] + + sp.putString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, Base64.encodeToString(randomPairingKey, Base64.DEFAULT)) + + return checksum[0] == pairingKeyCheckSum + } + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt index c589bbe633..224ecd9ae5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt @@ -69,7 +69,7 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_General_Delivery_Status(aapsLogger)) put(DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump)) put(DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_Notify_Alarm(aapsLogger, resourceHelper)) + put(DanaRS_Packet_Notify_Alarm(aapsLogger, resourceHelper, rxBus)) put(DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRSPlugin)) put(DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRSPlugin)) put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(aapsLogger)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt index 574791a005..03471e7408 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt @@ -11,7 +11,6 @@ class DanaRS_Packet_General_Initial_Screen_Information( ) : DanaRS_Packet() { init { - type = BleEncryption.DANAR_PACKET__TYPE_RESPONSE opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION aapsLogger.debug(LTag.PUMPCOMM, "New message") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt index 7650ff3704..f461c65f3c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt @@ -4,12 +4,16 @@ import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload +import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification +import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.utils.resources.ResourceHelper class DanaRS_Packet_Notify_Alarm( private val aapsLogger: AAPSLogger, - private val resourceHelper: ResourceHelper + private val resourceHelper: ResourceHelper, + private val rxBus: RxBusWrapper ) : DanaRS_Packet() { init { @@ -29,11 +33,11 @@ class DanaRS_Packet_Notify_Alarm( 0x03 -> // Occlusion errorString = resourceHelper.gs(R.string.occlusion) 0x04 -> // LOW BATTERY - errorString = resourceHelper.gs(R.string.lowbattery) + errorString = resourceHelper.gs(R.string.pumpshutdown) 0x05 -> // Shutdown errorString = resourceHelper.gs(R.string.lowbattery) 0x06 -> // Basal Compare - errorString = "BasalCompare ????" + errorString = resourceHelper.gs(R.string.basalcompare) 0x09 -> // Empty Reservoir errorString = resourceHelper.gs(R.string.emptyreservoir) 0x07, 0xFF -> // Blood sugar measurement alert @@ -41,7 +45,7 @@ class DanaRS_Packet_Notify_Alarm( 0x08, 0xFE -> // Remaining insulin level errorString = resourceHelper.gs(R.string.remaininsulinalert) 0xFD -> // Blood sugar check miss alarm - errorString = "Blood sugar check miss alarm ???" + errorString = resourceHelper.gs(R.string.missedbolus) } // No error no need to upload anything if (errorString == "") { @@ -49,6 +53,8 @@ class DanaRS_Packet_Notify_Alarm( aapsLogger.debug(LTag.PUMPCOMM, "Error detected: $errorString") return } + val notification = Notification(Notification.USERMESSAGE, errorString, Notification.URGENT) + rxBus.send(EventNewNotification(notification)) NSUpload.uploadError(errorString) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java index edd36f583e..b4fea5d8be 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java @@ -140,7 +140,7 @@ public class BleEncryption { return encryptSecondLevelPacketJni(context, bytes); } - public byte[] ecryptSecondLevelPacket(byte[] bytes) { + public byte[] decryptSecondLevelPacket(byte[] bytes) { return decryptSecondLevelPacketJni(context, bytes); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt index 1260573c34..1e6a5f1642 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -4,6 +4,7 @@ import android.bluetooth.* import android.content.Context import android.content.Intent import android.os.SystemClock +import android.util.Base64 import info.nightscout.androidaps.R import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.logging.AAPSLogger @@ -14,11 +15,13 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.plugins.pump.danaRS.activities.EnterPinActivity import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSMessageHashTable import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess +import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import okhttp3.internal.notify @@ -58,8 +61,17 @@ class BLEComm @Inject internal constructor( private var connectDeviceName: String? = null private var bluetoothGatt: BluetoothGatt? = null + private var v3Encryption: Boolean = false + set(newValue) { + bleEncryption.setEnhancedEncryption(newValue) + field = newValue + } + private var isEasyMode: Boolean = false + private var isUnitUD: Boolean = false + var isConnected = false var isConnecting = false + private var encryptedDataRead = false private var uartRead: BluetoothGattCharacteristic? = null private var uartWrite: BluetoothGattCharacteristic? = null @@ -106,6 +118,14 @@ class BLEComm @Inject internal constructor( fun disconnect(from: String) { aapsLogger.debug(LTag.PUMPBTCOMM, "disconnect from: $from") + if (!encryptedDataRead) { + // there was no response from pump after started encryption + // assume pairing keys are invalid + sp.remove(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName) + sp.remove(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName) + sp.remove(resourceHelper.gs(R.string.key_danars_v3_randomsynckey) + danaRSPlugin.mDeviceName) + ToastUtils.showToastInUiThread(context, R.string.invalidpairing) + } // cancel previous scheduled disconnection to prevent closing upcoming connection scheduledDisconnection?.cancel(false) scheduledDisconnection = null @@ -118,6 +138,7 @@ class BLEComm @Inject internal constructor( setCharacteristicNotification(uartReadBTGattChar, false) bluetoothGatt?.disconnect() isConnected = false + encryptedDataRead = false SystemClock.sleep(2000) } @@ -142,19 +163,20 @@ class BLEComm @Inject internal constructor( } override fun onCharacteristicRead(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, status: Int) { - aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicRead: " + DanaRS_Packet.toHexString(characteristic.value)) - addToReadBuffer(characteristic.value) - readDataParsing() + // for v3 after initial handshake it's encrypted - useless + // aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicRead: " + DanaRS_Packet.toHexString(characteristic.value)) + readDataParsing(characteristic.value) } override fun onCharacteristicChanged(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic) { - aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicChanged: " + DanaRS_Packet.toHexString(characteristic.value)) - addToReadBuffer(characteristic.value) - Thread(Runnable { readDataParsing() }).start() + // for v3 after initial handshake it's encrypted - useless + // aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicChanged: " + DanaRS_Packet.toHexString(characteristic.value)) + readDataParsing(characteristic.value) } override fun onCharacteristicWrite(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, status: Int) { - aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicWrite: " + DanaRS_Packet.toHexString(characteristic.value)) + // for v3 after initial handshake it's encrypted - useless + // aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicWrite: " + DanaRS_Packet.toHexString(characteristic.value)) Thread(Runnable { synchronized(mSendQueue) { // after message sent, check if there is the rest of the message waiting and send it @@ -175,9 +197,10 @@ class BLEComm @Inject internal constructor( aapsLogger.error("BluetoothAdapter not initialized_ERROR") isConnecting = false isConnected = false + encryptedDataRead = false return } - bluetoothGatt!!.setCharacteristicNotification(characteristic, enabled) + bluetoothGatt?.setCharacteristicNotification(characteristic, enabled) } @Synchronized @@ -188,13 +211,15 @@ class BLEComm @Inject internal constructor( aapsLogger.error("BluetoothAdapter not initialized_ERROR") isConnecting = false isConnected = false + encryptedDataRead = false return@Runnable } characteristic.value = data characteristic.writeType = BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE - aapsLogger.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data)) - bluetoothGatt!!.writeCharacteristic(characteristic) + //aapsLogger.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data)) + bluetoothGatt?.writeCharacteristic(characteristic) }).start() + waitMillis(50) } private val uartReadBTGattChar: BluetoothGattCharacteristic @@ -211,6 +236,7 @@ class BLEComm @Inject internal constructor( aapsLogger.error("BluetoothAdapter not initialized_ERROR") isConnecting = false isConnected = false + encryptedDataRead = false return null } return bluetoothGatt?.services @@ -243,6 +269,8 @@ class BLEComm @Inject internal constructor( close() isConnected = false isConnecting = false + v3Encryption = false + encryptedDataRead = false rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED)) aapsLogger.debug(LTag.PUMPBTCOMM, "Device was disconnected " + gatt.device.name) //Device was disconnected } @@ -263,13 +291,20 @@ class BLEComm @Inject internal constructor( } } - private fun readDataParsing() { + private fun readDataParsing(receviedData: ByteArray) { + //aapsLogger.debug(LTag.PUMPBTCOMM, "readDataParsing") var startSignatureFound = false var packetIsValid = false var isProcessing: Boolean isProcessing = true var inputBuffer: ByteArray? = null + // decrypt 2nd level after successful connection + val incomingBuffer = if (v3Encryption && isConnected) + bleEncryption.decryptSecondLevelPacket(receviedData).also { encryptedDataRead = true } + else receviedData + addToReadBuffer(incomingBuffer) + while (isProcessing) { var length = 0 synchronized(readBuffer) { @@ -321,85 +356,163 @@ class BLEComm @Inject internal constructor( // decrypt the packet bleEncryption.getDecryptedPacket(inputBuffer)?.let { decryptedBuffer -> when (decryptedBuffer[0]) { - BleEncryption.DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE.toByte() -> when (decryptedBuffer[1]) { - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK.toByte() -> if (decryptedBuffer.size == 4 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - // Grab pairing key from preferences if exists - val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, "") - aapsLogger.debug(LTag.PUMPBTCOMM, "Using stored pairing key: $pairingKey") - if (pairingKey.isNotEmpty()) { - val encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey) - val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)) - writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) - } else { - // Stored pairing key does not exists, request pairing - sendPairingRequest() - } - } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'P'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'M'.toByte() && decryptedBuffer[5] == 'P'.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - mSendQueue.clear() - rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumperror))) - NSUpload.uploadError(resourceHelper.gs(R.string.pumperror)) - val n = Notification(Notification.PUMPERROR, resourceHelper.gs(R.string.pumperror), Notification.URGENT) - rxBus.send(EventNewNotification(n)) - } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'S'.toByte() && decryptedBuffer[5] == 'Y'.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - mSendQueue.clear() - rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumpbusy))) - } else { - // ERROR in response, wrong serial number - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - mSendQueue.clear() - rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.connectionerror))) - sp.remove(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName) - val n = Notification(Notification.WRONGSERIALNUMBER, resourceHelper.gs(R.string.wrongpassword), Notification.URGENT) - rxBus.send(EventNewNotification(n)) - } + BleEncryption.DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE.toByte() -> + when (decryptedBuffer[1]) { + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK.toByte() -> + if (decryptedBuffer.size == 4 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + v3Encryption = false + // Grab pairing key from preferences if exists + val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, "") + aapsLogger.debug(LTag.PUMPBTCOMM, "Using stored pairing key: $pairingKey") + if (pairingKey.isNotEmpty()) { + val encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey) + val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } else { + // Stored pairing key does not exists, request pairing + sendPairingRequest() + } + } else if (decryptedBuffer.size == 9 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) { + // v3 2nd layer encryption + v3Encryption = true + val model = decryptedBuffer[5] + // val protocol = decryptedBuffer[7] + if (model == 0x05.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK V3 (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + // Dana RS Pump + val randomPairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, "") + val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, "") + if (randomPairingKey.isNotEmpty() && pairingKey.isNotEmpty()) { + val randomSyncKey = String.format("%02x", decryptedBuffer[decryptedBuffer.size - 1]) + sp.putString(resourceHelper.gs(R.string.key_danars_v3_randomsynckey) + danaRSPlugin.mDeviceName, randomSyncKey) + val tPairingKey = Base64.decode(pairingKey, Base64.DEFAULT) + val tRandomPairingKey = Base64.decode(randomPairingKey, Base64.DEFAULT) + var tRandomSyncKey: Byte = 0 + if (randomSyncKey.isNotEmpty()) { + tRandomSyncKey = randomSyncKey.toInt(16).toByte() + } + bleEncryption.setPairingKeys(tPairingKey, tRandomPairingKey, tRandomSyncKey) + sendV3PairingInformation(0) + } else { + sendV3PairingInformation(1) + } + } else if (model == 0x06.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK V3 EASY (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + // Dana RS Easy + val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK, null, null) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'P'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'M'.toByte() && decryptedBuffer[5] == 'P'.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + mSendQueue.clear() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumperror))) + NSUpload.uploadError(resourceHelper.gs(R.string.pumperror)) + val n = Notification(Notification.PUMPERROR, resourceHelper.gs(R.string.pumperror), Notification.URGENT) + rxBus.send(EventNewNotification(n)) + } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'S'.toByte() && decryptedBuffer[5] == 'Y'.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + mSendQueue.clear() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumpbusy))) + } else { + // ERROR in response, wrong serial number + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + mSendQueue.clear() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.connectionerror))) + sp.remove(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName) + val n = Notification(Notification.WRONGSERIALNUMBER, resourceHelper.gs(R.string.wrongpassword), Notification.URGENT) + rxBus.send(EventNewNotification(n)) + } - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY.toByte() -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - if (decryptedBuffer[2] == 0x00.toByte()) { - // Paring is not requested, sending time info + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION.toByte() -> { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */DanaRS_Packet.toHexString(decryptedBuffer)) + if (v3Encryption) { + // decryptedBuffer[2] : 0x00 OK 0x01 Error, No pairing + if (decryptedBuffer[2] == 0x00.toByte()) { + val randomPairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, "") + val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, "") + if (randomPairingKey.isNotEmpty() && pairingKey.isNotEmpty()) { + // expecting successful connect + isConnected = true + isConnecting = false + aapsLogger.debug(LTag.PUMPBTCOMM, "Connect !!") + } else { + context.startActivity(Intent(context, EnterPinActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) + aapsLogger.debug(LTag.PUMPBTCOMM, "Request pairing keys !!") + } + } else { + sendV3PairingInformation(1) + } + + } else { + val size = decryptedBuffer.size + var pass: Int = (decryptedBuffer[size - 1].toInt() and 0x000000FF shl 8) + (decryptedBuffer[size - 2].toInt() and 0x000000FF) + pass = pass xor 3463 + danaRPump.rsPassword = Integer.toHexString(pass) + aapsLogger.debug(LTag.PUMPBTCOMM, "Pump user password: " + Integer.toHexString(pass)) + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)) + isConnected = true + isConnecting = false + aapsLogger.debug(LTag.PUMPBTCOMM, "RS connected and status read") + } + } + + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY.toByte() -> { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + if (decryptedBuffer[2] == 0x00.toByte()) { + // Paring is not requested, sending time info + sendTimeInfo() + } else { + // Pairing on pump is requested + sendPairingRequest() + } + } + + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST.toByte() -> { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(decryptedBuffer)) + if (decryptedBuffer[2] != 0x00.toByte()) { + disconnect("passkey request failed") + } + } + + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN.toByte() -> { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(decryptedBuffer)) + // Paring is successful, sending time info + rxBus.send(EventDanaRSPairingSuccess()) sendTimeInfo() - } else { - // Pairing on pump is requested - sendPairingRequest() + val pairingKey = byteArrayOf(decryptedBuffer[2], decryptedBuffer[3]) + // store pairing key to preferences + sp.putString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)) + aapsLogger.debug(LTag.PUMPBTCOMM, "Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)) + } + + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_PUMP_CHECK.toByte() -> { + if (decryptedBuffer[2] == 0x05.toByte()) { + // not easy mode, request time info + val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } else { + // easy mode + val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK, null, null) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + } + + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK.toByte() -> { + isEasyMode = decryptedBuffer[2] == 0x01.toByte() + isUnitUD = decryptedBuffer[3] == 0x01.toByte() + + // request time information + if (v3Encryption) { + sendV3PairingInformation(1) + } else { + val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } } } - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST.toByte() -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(decryptedBuffer)) - if (decryptedBuffer[2] != 0x00.toByte()) { - disconnect("passkey request failed") - } - } - - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN.toByte() -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(decryptedBuffer)) - // Paring is successful, sending time info - rxBus.send(EventDanaRSPairingSuccess()) - sendTimeInfo() - val pairingKey = byteArrayOf(decryptedBuffer[2], decryptedBuffer[3]) - // store pairing key to preferences - sp.putString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)) - aapsLogger.debug(LTag.PUMPBTCOMM, "Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)) - } - - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION.toByte() -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */DanaRS_Packet.toHexString(decryptedBuffer)) - val size = decryptedBuffer.size - var pass: Int = (decryptedBuffer[size - 1].toInt() and 0x000000FF shl 8) + (decryptedBuffer[size - 2].toInt() and 0x000000FF) - pass = pass xor 3463 - danaRPump.rsPassword = Integer.toHexString(pass) - aapsLogger.debug(LTag.PUMPBTCOMM, "Pump user password: " + Integer.toHexString(pass)) - rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)) - isConnected = true - isConnecting = false - aapsLogger.debug(LTag.PUMPBTCOMM, "RS connected and status read") - } - } - else -> { // Retrieve message code from received buffer and last message sent val originalCommand = processedMessage?.command ?: 0xFFFF @@ -449,6 +562,8 @@ class BLEComm @Inject internal constructor( val params = message.requestParams aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + message.friendlyName + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params)) var bytes = bleEncryption.getEncryptedPacket(message.opCode, params, null) + if (v3Encryption) + bytes = bleEncryption.encryptSecondLevelPacket(bytes) // If there is another message not completely sent, add to queue only if (mSendQueue.size > 0) { // Split to parts per 20 bytes max @@ -509,13 +624,30 @@ class BLEComm @Inject internal constructor( } } + fun finishV3Pairing() { + val randomPairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, "") + val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, "") + if (randomPairingKey.isNotEmpty() && pairingKey.isNotEmpty()) { + val tPairingKey = Base64.decode(pairingKey, Base64.DEFAULT) + val tRandomPairingKey = Base64.decode(randomPairingKey, Base64.DEFAULT) + val tRandomSyncKey: Byte = 0 + bleEncryption.setPairingKeys(tPairingKey, tRandomPairingKey, tRandomSyncKey) + sendV3PairingInformation(0) + } + } + + // 0x00 Start encryption, 0x01 Request pairing + private fun sendV3PairingInformation(requestNewPairing: Int) { + val params = byteArrayOf(requestNewPairing.toByte()) + val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, params, null) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + private fun sendPairingRequest() { // Start activity which is waiting 20sec // On pump pairing request is displayed and is waiting for conformation - val i = Intent() - i.setClass(context, PairingHelperActivity::class.java) - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - context.startActivity(i) + context.startActivity(Intent(context, PairingHelperActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null) aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes)) writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt b/app/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt new file mode 100644 index 0000000000..9852ecbbf4 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt @@ -0,0 +1,32 @@ +package info.nightscout.androidaps.utils.extensions + +private val HEX_CHARS = "0123456789ABCDEF".toCharArray() + +fun ByteArray.toHex() : String{ + val result = StringBuffer() + + forEach { + val octet = it.toInt() + val firstIndex = (octet and 0xF0).ushr(4) + val secondIndex = octet and 0x0F + result.append(HEX_CHARS[firstIndex]) + result.append(HEX_CHARS[secondIndex]) + } + + return result.toString() +} + +fun String.hexStringToByteArray() : ByteArray { + + val result = ByteArray(length / 2) + + for (i in 0 until length step 2) { + val firstIndex = HEX_CHARS.indexOf(this[i]); + val secondIndex = HEX_CHARS.indexOf(this[i + 1]); + + val octet = firstIndex.shl(4).or(secondIndex) + result.set(i.shr(1), octet.toByte()) + } + + return result +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt b/app/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt index 4c15100edd..21146a9a72 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt @@ -15,6 +15,9 @@ class DefaultEditTextValidator : EditTextValidator { protected var testErrorString: String? = null protected var emptyAllowed = false protected lateinit var editTextView: EditText + private var tw: TextWatcher? = null + private var defaultEmptyErrorString: String? = null + protected var testType: Int protected var classType: String? = null protected var customRegexp: String? = null @@ -26,8 +29,6 @@ class DefaultEditTextValidator : EditTextValidator { protected var maxNumber = 0 protected var floatminNumber = 0f protected var floatmaxNumber = 0f - private var tw: TextWatcher? = null - private var defaultEmptyErrorString: String? = null @Suppress("unused") constructor(editTextView: EditText, context: Context) { @@ -167,44 +168,50 @@ class DefaultEditTextValidator : EditTextValidator { } @Suppress("unused") - fun setClassType(classType: String?, testErrorString: String?, context: Context) { + fun setClassType(classType: String?, testErrorString: String?, context: Context) : DefaultEditTextValidator{ testType = EditTextValidator.TEST_CUSTOM this.classType = classType this.testErrorString = testErrorString resetValidators(context) + return this } @Suppress("unused") - fun setCustomRegexp(customRegexp: String?, context: Context) { + fun setCustomRegexp(customRegexp: String?, context: Context) : DefaultEditTextValidator { testType = EditTextValidator.TEST_REGEXP this.customRegexp = customRegexp resetValidators(context) + return this } @Suppress("unused") - fun setEmptyAllowed(emptyAllowed: Boolean, context: Context) { + fun setEmptyAllowed(emptyAllowed: Boolean, context: Context) : DefaultEditTextValidator { this.emptyAllowed = emptyAllowed resetValidators(context) + return this } - fun setEmptyErrorString(emptyErrorString: String?) { + fun setEmptyErrorString(emptyErrorString: String?) : DefaultEditTextValidator { emptyErrorStringActual = if (!TextUtils.isEmpty(emptyErrorString)) { emptyErrorString } else { defaultEmptyErrorString } + return this } @Suppress("unused") - fun setTestErrorString(testErrorString: String?, context: Context) { + fun setTestErrorString(testErrorString: String?, context: Context) : DefaultEditTextValidator { this.testErrorString = testErrorString resetValidators(context) + return this } @Suppress("unused") - fun setTestType(testType: Int, context: Context) { + fun setTestType(testType: Int, context: Context) : DefaultEditTextValidator { this.testType = testType resetValidators(context) + return this } override fun testValidity(): Boolean { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt b/app/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt index 190a3bea73..0d605c17e8 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.utils.textValidator +import android.annotation.SuppressLint import android.content.Context import android.util.AttributeSet import androidx.core.content.res.TypedArrayUtils @@ -22,7 +23,7 @@ class ValidatingEditTextPreference(ctx: Context, attrs: AttributeSet, defStyleAt constructor(ctx: Context, attrs: AttributeSet, defStyle: Int) : this(ctx, attrs, defStyle, 0) - constructor(ctx: Context, attrs: AttributeSet) + @SuppressLint("RestrictedApi") constructor(ctx: Context, attrs: AttributeSet) : this(ctx, attrs, TypedArrayUtils.getAttr(ctx, R.attr.editTextPreferenceStyle, R.attr.editTextPreferenceStyle)) diff --git a/app/src/main/res/layout/danars_enter_pin_activity.xml b/app/src/main/res/layout/danars_enter_pin_activity.xml new file mode 100644 index 0000000000..0a232b6cc1 --- /dev/null +++ b/app/src/main/res/layout/danars_enter_pin_activity.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 0c6bcfbe4d..3ac901f44f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -417,6 +417,7 @@ Open Settings on Wear Pump Error Low Battery + Delivering less than preset basal rate Pump Shutdown Pump Battery Discharged DanaR Korean @@ -731,12 +732,16 @@ Pairing timed out Pairing danars_pairing_key_ + danars_v3_randompairing_key_ + danars_v3_pairing_key_ + danars_v3_randomsync_key_ danars_address danars_name No device found so far Empty reservoir Blood sugar measurement alert Remaining insulin level + Missed bolus DanaRS Dana Selected pump @@ -1736,4 +1741,11 @@ On each follower phone install Authenticator app that support RFC 6238 TOTP tokens. Popular free apps are:\n • Authy\n • Google Authenticator\n • LastPass Authenticator\n • FreeOTP Authenticator DO NOT SHARE this code online!\nUse it only to setup Authenticator App on follower phones. By reseting authenticator you make all already provisioned authenticators invalid. You will need to set up them again! + PIN1 + PIN2 + Press OK on the pump\nand enter 2 displayed numbers\nKeep display on pump ON by pressing minus button until you finish entering code. + 1: (12 digits) + 2: (8 digits) + Reset pairing information? + Invalid pairing information. Requesting new pairing diff --git a/app/src/main/res/values/validator.xml b/app/src/main/res/values/validator.xml index 15c40b743c..aef7116a48 100644 --- a/app/src/main/res/values/validator.xml +++ b/app/src/main/res/values/validator.xml @@ -16,9 +16,13 @@ Format not valid Must be 4 digit number Must be 6 digit number + Must be 12 characters of ABCDEF0123456789 + Must be 8 characters of ABCDEF0123456789 Not a minimum length Pin should be 3 to 6 digits, not same or in series ^\\d{4} + ^[A-F0-9]{12}$ + ^[A-F0-9]{8}$ \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt index 8aba3da2ba..58e0b738db 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt @@ -14,7 +14,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_Notify_AlarmTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_Notify_Alarm(aapsLogger, resourceHelper) + val packet = DanaRS_Packet_Notify_Alarm(aapsLogger, resourceHelper, rxBus) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding From 75cd9bccdcef9aa5bcb5c1f66a8817f5c29886e3 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 27 Mar 2020 21:48:42 +0100 Subject: [PATCH 008/400] switch pumps properly --- .../plugins/pump/danaR/AbstractDanaRPlugin.java | 4 +++- .../androidaps/plugins/pump/danaR/DanaRFragment.kt | 2 +- .../androidaps/plugins/pump/danaRS/DanaRSPlugin.java | 8 +++++--- .../androidaps/plugins/pump/danaRS/services/BLEComm.kt | 6 +++++- .../java/info/nightscout/androidaps/queue/CommandQueue.kt | 2 ++ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java index 6de5376b89..1982a0e7be 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java @@ -103,8 +103,10 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump .toObservable(EventPreferenceChange.class) .observeOn(Schedulers.io()) .subscribe(event -> { - if (event.isChanged(getResourceHelper(), R.string.key_danar_bt_name)) + if (event.isChanged(getResourceHelper(), R.string.key_danar_bt_name)) { danaRPump.setLastConnection(0); + danaRPump.setLastSettingsRead(0); + getCommandQueue().readStatus("DeviceChanged", null); } }) ); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt index e9e001ced0..7f9eb34c7f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt @@ -171,7 +171,7 @@ class DanaRFragment : DaggerFragment() { // GUI functions @Synchronized - internal fun updateGUI() { + fun updateGUI() { if (danar_dailyunits == null) return val pump = danaRPump val plugin: PumpInterface = activePlugin.activePump diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java index 759b473d75..7dcc0c29ff 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java @@ -166,9 +166,9 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR disposable.add(rxBus .toObservable(EventDanaRSDeviceChange.class) .observeOn(Schedulers.io()) - .subscribe(event -> loadAddress(), fabricPrivacy::logException) + .subscribe(event -> changePump(), fabricPrivacy::logException) ); - loadAddress(); // load device name + changePump(); // load device name super.onStart(); } @@ -194,10 +194,12 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR } }; - private void loadAddress() { + public void changePump() { mDeviceAddress = sp.getString(R.string.key_danars_address, ""); mDeviceName = sp.getString(R.string.key_danars_name, ""); danaRPump.setLastConnection(0); + danaRPump.setLastSettingsRead(0); + getCommandQueue().readStatus("DeviceChanged", null); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt index 1e6a5f1642..2f537e7d87 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -96,6 +96,9 @@ class BLEComm @Inject internal constructor( return false } + isConnected = false + v3Encryption = false + encryptedDataRead = false isConnecting = true val device = bluetoothAdapter?.getRemoteDevice(address) if (device == null) { @@ -118,13 +121,14 @@ class BLEComm @Inject internal constructor( fun disconnect(from: String) { aapsLogger.debug(LTag.PUMPBTCOMM, "disconnect from: $from") - if (!encryptedDataRead) { + if (!encryptedDataRead && v3Encryption) { // there was no response from pump after started encryption // assume pairing keys are invalid sp.remove(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName) sp.remove(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName) sp.remove(resourceHelper.gs(R.string.key_danars_v3_randomsynckey) + danaRSPlugin.mDeviceName) ToastUtils.showToastInUiThread(context, R.string.invalidpairing) + danaRSPlugin.changePump() } // cancel previous scheduled disconnection to prevent closing upcoming connection scheduledDisconnection?.cancel(false) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt index fd93f772aa..20a11124d4 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt @@ -374,12 +374,14 @@ class CommandQueue @Inject constructor( callback?.result(PumpEnactResult(injector).success(true).enacted(false))?.run() return false } + /* this is breaking setting of profile at all if not engineering mode if (!buildHelper.isEngineeringModeOrRelease()) { val notification = Notification(Notification.NOT_ENG_MODE_OR_RELEASE, resourceHelper.gs(R.string.not_eng_mode_or_release), Notification.URGENT) rxBus.send(EventNewNotification(notification)) callback?.result(PumpEnactResult(injector).success(false).enacted(false).comment(resourceHelper.gs(R.string.not_eng_mode_or_release)))?.run() return false } + */ // Compare with pump limits val basalValues = profile.basalValues for (basalValue in basalValues) { From 5e50ca8793d45c986201315297c37b19f54449d1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 28 Mar 2020 20:55:28 +0100 Subject: [PATCH 009/400] Improved switching between Dana pumps, code cleanup --- .../pump/danaR/AbstractDanaRPlugin.java | 8 +- .../plugins/pump/danaR/DanaRFragment.kt | 6 +- .../plugins/pump/danaR/DanaRPump.kt | 26 +- .../plugins/pump/danaR/comm/MsgCheckValue.kt | 6 +- .../danaR/services/DanaRExecutionService.java | 3 +- .../pump/danaRKorean/comm/MsgCheckValue_k.kt | 6 +- .../services/DanaRKoreanExecutionService.java | 3 +- .../plugins/pump/danaRS/DanaRSPlugin.java | 5 +- .../danaRS/comm/DanaRSMessageHashTable.kt | 3 + .../DanaRS_Packet_General_Get_Pump_Check.kt | 6 +- ...aRS_Packet_General_Get_Shipping_Version.kt | 28 + ...cket_General_Initial_Screen_Information.kt | 10 +- ...DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt | 27 + .../pump/danaRS/encryption/BleEncryption.java | 4 + .../plugins/pump/danaRS/services/BLEComm.kt | 494 ++++++++++-------- .../pump/danaRS/services/DanaRSService.java | 4 +- .../pump/danaRv2/comm/MsgCheckValue_v2.kt | 10 +- .../services/DanaRv2ExecutionService.java | 5 +- .../interfaces/ConstraintsCheckerTest.kt | 2 +- .../pump/danaR/comm/MsgCheckValueTest.kt | 2 +- .../plugins/pump/danaRS/DanaRSPluginTest.kt | 3 +- ...S_Packet_Bolus_Set_Step_Bolus_StartTest.kt | 3 +- ...Packet_General_Get_Shipping_VerisonTest.kt | 20 + ...Packet_Notify_Delivery_Rate_DisplayTest.kt | 3 +- ...RS_Packet_Review_Get_Pump_Dec_RatioTest.kt | 22 + .../pump/danaRv2/comm/MsgCheckValue_v2Test.kt | 2 +- 26 files changed, 434 insertions(+), 277 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java index 1982a0e7be..cb8740bbcf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java @@ -97,16 +97,16 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump disposable.add(rxBus .toObservable(EventConfigBuilderChange.class) .observeOn(Schedulers.io()) - .subscribe(event -> danaRPump.setLastConnection(0)) + .subscribe(event -> danaRPump.reset()) ); disposable.add(rxBus .toObservable(EventPreferenceChange.class) .observeOn(Schedulers.io()) .subscribe(event -> { if (event.isChanged(getResourceHelper(), R.string.key_danar_bt_name)) { - danaRPump.setLastConnection(0); - danaRPump.setLastSettingsRead(0); - getCommandQueue().readStatus("DeviceChanged", null); } + danaRPump.reset(); + getCommandQueue().readStatus("DeviceChanged", null); + } }) ); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt index 7f9eb34c7f..6cace72c5f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt @@ -210,8 +210,8 @@ class DanaRFragment : DaggerFragment() { danar_battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}" SetWarnColor.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0) danar_iob.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob) - if (pump.model != 0 || pump.protocol != 0 || pump.productCode != 0) { - danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.model, pump.protocol, pump.productCode) + if (pump.btModel != 0 || pump.protocol != 0 || pump.productCode != 0) { + danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.btModel, pump.protocol, pump.productCode) } else { @Suppress("SetTextI18n") danar_firmware.text = "OLD" @@ -229,7 +229,7 @@ class DanaRFragment : DaggerFragment() { //hide user options button if not an RS pump or old firmware // also excludes pump with model 03 because of untested error val isKorean = danaRKoreanPlugin.isEnabled(PluginType.PUMP) - if (isKorean || danar_firmware.text === "OLD" || pump.model == 3) { + if (isKorean || danar_firmware.text === "OLD" || pump.btModel == 3) { danar_user_options.visibility = View.GONE } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt index 0621fd80ad..eb5bb627fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt @@ -26,6 +26,20 @@ class DanaRPump @Inject constructor( private val injector: HasAndroidInjector ) { + enum class ErrorState(val code: Int) { + NONE(0x00), + SUSPENDED(0x01), + DAILYMAX(0x02), + BOLUSBLOCK(0x04), + ORDERDELIVERING(0x08), + NOPRIME(0x10); + + companion object { + private val map = values().associateBy(ErrorState::code) + operator fun get(value: Int) = map[value] + } + } + var lastConnection: Long = 0 var lastSettingsRead: Long = 0 @@ -33,12 +47,14 @@ class DanaRPump @Inject constructor( var serialNumber = "" var shippingDate: Long = 0 var shippingCountry = "" - var isNewPump = true - var password = -1 + var bleModel = "" // RS v3: like BPN-1.0.1 + var isNewPump = true // R only , providing model info + var password = -1 // R, RSv1 var pumpTime: Long = 0 - var model = 0 + var btModel = 0 var protocol = 0 var productCode = 0 + var errorState: ErrorState = ErrorState.NONE var isConfigUD = false var isExtendedBolusEnabled = false var isEasyModeEnabled = false @@ -49,6 +65,7 @@ class DanaRPump @Inject constructor( var dailyTotalUnits = 0.0 var dailyTotalBolusUnits = 0.0 // RS only var dailyTotalBasalUnits = 0.0 // RS only + var decRatio = 0 // RS v3: [%] for pump IOB calculation var maxDailyTotalUnits = 0 var bolusStep = 0.1 var basalStep = 0.1 @@ -207,6 +224,7 @@ class DanaRPump @Inject constructor( fun reset() { aapsLogger.debug(LTag.PUMP, "DanaRPump reset") lastConnection = 0 + lastSettingsRead = 0 } companion object { @@ -234,6 +252,8 @@ class DanaRPump @Inject constructor( const val PROFILECHANGE = 13 const val CARBS = 14 const val PRIMECANNULA = 15 + + // Dana R btModel const val DOMESTIC_MODEL = 0x01 const val EXPORT_MODEL = 0x03 } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt index abb6c34d8d..3cc8701a38 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt @@ -19,14 +19,14 @@ class MsgCheckValue( override fun handleMessage(bytes: ByteArray) { danaRPump.isNewPump = true aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed") - danaRPump.model = intFromBuff(bytes, 0, 1) + danaRPump.btModel = intFromBuff(bytes, 0, 1) danaRPump.protocol = intFromBuff(bytes, 1, 1) danaRPump.productCode = intFromBuff(bytes, 2, 1) - if (danaRPump.model != DanaRPump.EXPORT_MODEL) { + if (danaRPump.btModel != DanaRPump.EXPORT_MODEL) { danaRPlugin.disconnect("Wrong Model") aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected") } - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.model)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java index b71ed5abea..4178bd3d57 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java @@ -225,8 +225,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { if (danaRPump.getPumpTime() == 0) { // initial handshake was not successfull // deinitialize pump - danaRPump.setLastConnection(0); - danaRPump.setLastSettingsRead(0); + danaRPump.reset(); rxBus.send(new EventDanaRNewStatus()); rxBus.send(new EventInitializationChanged()); return; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt index 16ae6967a2..412d13cf3d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt @@ -21,14 +21,14 @@ class MsgCheckValue_k( override fun handleMessage(bytes: ByteArray) { danaRPump.isNewPump = true aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed") - danaRPump.model = intFromBuff(bytes, 0, 1) + danaRPump.btModel = intFromBuff(bytes, 0, 1) danaRPump.protocol = intFromBuff(bytes, 1, 1) danaRPump.productCode = intFromBuff(bytes, 2, 1) - if (danaRPump.model != DanaRPump.DOMESTIC_MODEL) { + if (danaRPump.btModel != DanaRPump.DOMESTIC_MODEL) { danaRKoreanPlugin.disconnect("Wrong Model") aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected") } - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.model)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java index f695448820..d40583e9db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java @@ -212,8 +212,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { if (danaRPump.getPumpTime() == 0) { // initial handshake was not successfull // deinitialize pump - danaRPump.setLastConnection(0); - danaRPump.setLastSettingsRead(0); + danaRPump.reset(); rxBus.send(new EventDanaRNewStatus()); rxBus.send(new EventInitializationChanged()); return; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java index 7dcc0c29ff..35f1e81a21 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java @@ -161,7 +161,7 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR disposable.add(rxBus .toObservable(EventConfigBuilderChange.class) .observeOn(Schedulers.io()) - .subscribe(event -> danaRPump.setLastConnection(0)) + .subscribe(event -> danaRPump.reset()) ); disposable.add(rxBus .toObservable(EventDanaRSDeviceChange.class) @@ -197,8 +197,7 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR public void changePump() { mDeviceAddress = sp.getString(R.string.key_danars_address, ""); mDeviceName = sp.getString(R.string.key_danars_name, ""); - danaRPump.setLastConnection(0); - danaRPump.setLastSettingsRead(0); + danaRPump.reset(); getCommandQueue().readStatus("DeviceChanged", null); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt index 224ecd9ae5..2f3b8b170a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt @@ -101,5 +101,8 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0)) put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, 0)) put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, 0, 0, 0, 0)) + // v3 + put(DanaRS_Packet_General_Get_Shipping_Version(aapsLogger, danaRPump)) + put(DanaRS_Packet_Review_Get_Pump_Dec_Ratio(aapsLogger, danaRPump)) } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt index bf3338b52f..5646c6f370 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt @@ -1,6 +1,5 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -8,6 +7,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper class DanaRS_Packet_General_Get_Pump_Check( @@ -30,14 +30,14 @@ class DanaRS_Packet_General_Get_Pump_Check( failed = false var dataIndex = DATA_START var dataSize = 1 - danaRPump.model = byteArrayToInt(getBytes(data, dataIndex, dataSize)) + danaRPump.btModel = byteArrayToInt(getBytes(data, dataIndex, dataSize)) dataIndex += dataSize dataSize = 1 danaRPump.protocol = byteArrayToInt(getBytes(data, dataIndex, dataSize)) dataIndex += dataSize dataSize = 1 danaRPump.productCode = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.model)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) if (danaRPump.productCode < 2) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt new file mode 100644 index 0000000000..9d3d83fbf4 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt @@ -0,0 +1,28 @@ +package info.nightscout.androidaps.plugins.pump.danaRS.comm + +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import java.nio.charset.Charset + +class DanaRS_Packet_General_Get_Shipping_Version( + private val aapsLogger: AAPSLogger, + private val danaRPump: DanaRPump +) : DanaRS_Packet() { + + init { + opCode = BleEncryption.DANAR_PACKET__OPCODE_GENERAL__GET_SHIPPING_VERSION + aapsLogger.debug(LTag.PUMPCOMM, "New message") + } + + override fun handleMessage(data: ByteArray) { + danaRPump.bleModel = data.copyOfRange(DATA_START, data.size).toString(Charset.forName("US-ASCII")) + failed = false + aapsLogger.debug(LTag.PUMPCOMM, "BLE Model: " + danaRPump.bleModel) + } + + override fun getFriendlyName(): String { + return "GENERAL__GET_SHIPPING_VERSION" + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt index 03471e7408..0510c28271 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_General_Initial_Screen_Information( private val aapsLogger: AAPSLogger, @@ -51,6 +51,14 @@ class DanaRS_Packet_General_Initial_Screen_Information( dataIndex += dataSize dataSize = 2 danaRPump.iob = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 + if (data.size >= 18) { + //protocol 10+ + dataIndex += dataSize + dataSize = 1 + danaRPump.errorState = DanaRPump.ErrorState[byteArrayToInt(getBytes(data, dataIndex, dataSize))] + ?: DanaRPump.ErrorState.NONE + aapsLogger.debug(LTag.PUMPCOMM, "ErrorState: " + danaRPump.errorState.name) + } aapsLogger.debug(LTag.PUMPCOMM, "Pump suspended: " + danaRPump.pumpSuspended) aapsLogger.debug(LTag.PUMPCOMM, "Temp basal in progress: " + danaRPump.isTempBasalInProgress) aapsLogger.debug(LTag.PUMPCOMM, "Extended in progress: " + danaRPump.isExtendedInProgress) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt new file mode 100644 index 0000000000..23d903de0b --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt @@ -0,0 +1,27 @@ +package info.nightscout.androidaps.plugins.pump.danaRS.comm + +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption + +class DanaRS_Packet_Review_Get_Pump_Dec_Ratio( + private val aapsLogger: AAPSLogger, + private val danaRPump: DanaRPump +) : DanaRS_Packet() { + + init { + opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_DEC_RATIO + aapsLogger.debug(LTag.PUMPCOMM, "New message") + } + + override fun handleMessage(data: ByteArray) { + danaRPump.decRatio = intFromBuff(data, 0, 1) * 5 + failed = false + aapsLogger.debug(LTag.PUMPCOMM, "Dec ratio: ${danaRPump.decRatio}%") + } + + override fun getFriendlyName(): String { + return "REVIEW__GET_PUMP_DEC_RATIO" + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java index b4fea5d8be..425a5a87a2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java @@ -97,6 +97,10 @@ public class BleEncryption { public static final int DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS = 0xC2; public static final int DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY = 0xC3; + // v3 specific + public static final int DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_DEC_RATIO = 0x80; + public static final int DANAR_PACKET__OPCODE_GENERAL__GET_SHIPPING_VERSION = 0x81; + // Easy Mode public static final int DANAR_PACKET__OPCODE_OPTION__GET_EASY_MENU_OPTION = 0x74; public static final int DANAR_PACKET__OPCODE_OPTION__SET_EASY_MENU_OPTION = 0x75; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt index 2f537e7d87..9145cb6559 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -162,7 +162,7 @@ class BLEComm @Inject internal constructor( if (status == BluetoothGatt.GATT_SUCCESS) { findCharacteristic() } - sendPumpCheck() + sendConnect() // 1st message sent to pump after connect } @@ -295,7 +295,7 @@ class BLEComm @Inject internal constructor( } } - private fun readDataParsing(receviedData: ByteArray) { + private fun readDataParsing(receivedData: ByteArray) { //aapsLogger.debug(LTag.PUMPBTCOMM, "readDataParsing") var startSignatureFound = false var packetIsValid = false @@ -305,8 +305,8 @@ class BLEComm @Inject internal constructor( // decrypt 2nd level after successful connection val incomingBuffer = if (v3Encryption && isConnected) - bleEncryption.decryptSecondLevelPacket(receviedData).also { encryptedDataRead = true } - else receviedData + bleEncryption.decryptSecondLevelPacket(receivedData).also { encryptedDataRead = true } + else receivedData addToReadBuffer(incomingBuffer) while (isProcessing) { @@ -356,196 +356,42 @@ class BLEComm @Inject internal constructor( } } if (packetIsValid) { - try { - // decrypt the packet - bleEncryption.getDecryptedPacket(inputBuffer)?.let { decryptedBuffer -> - when (decryptedBuffer[0]) { - BleEncryption.DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE.toByte() -> - when (decryptedBuffer[1]) { - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK.toByte() -> - if (decryptedBuffer.size == 4 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - v3Encryption = false - // Grab pairing key from preferences if exists - val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, "") - aapsLogger.debug(LTag.PUMPBTCOMM, "Using stored pairing key: $pairingKey") - if (pairingKey.isNotEmpty()) { - val encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey) - val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)) - writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) - } else { - // Stored pairing key does not exists, request pairing - sendPairingRequest() - } - } else if (decryptedBuffer.size == 9 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) { - // v3 2nd layer encryption - v3Encryption = true - val model = decryptedBuffer[5] - // val protocol = decryptedBuffer[7] - if (model == 0x05.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK V3 (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - // Dana RS Pump - val randomPairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, "") - val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, "") - if (randomPairingKey.isNotEmpty() && pairingKey.isNotEmpty()) { - val randomSyncKey = String.format("%02x", decryptedBuffer[decryptedBuffer.size - 1]) - sp.putString(resourceHelper.gs(R.string.key_danars_v3_randomsynckey) + danaRSPlugin.mDeviceName, randomSyncKey) - val tPairingKey = Base64.decode(pairingKey, Base64.DEFAULT) - val tRandomPairingKey = Base64.decode(randomPairingKey, Base64.DEFAULT) - var tRandomSyncKey: Byte = 0 - if (randomSyncKey.isNotEmpty()) { - tRandomSyncKey = randomSyncKey.toInt(16).toByte() - } - bleEncryption.setPairingKeys(tPairingKey, tRandomPairingKey, tRandomSyncKey) - sendV3PairingInformation(0) - } else { - sendV3PairingInformation(1) - } - } else if (model == 0x06.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK V3 EASY (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - // Dana RS Easy - val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK, null, null) - writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) - } - } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'P'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'M'.toByte() && decryptedBuffer[5] == 'P'.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - mSendQueue.clear() - rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumperror))) - NSUpload.uploadError(resourceHelper.gs(R.string.pumperror)) - val n = Notification(Notification.PUMPERROR, resourceHelper.gs(R.string.pumperror), Notification.URGENT) - rxBus.send(EventNewNotification(n)) - } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'S'.toByte() && decryptedBuffer[5] == 'Y'.toByte()) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - mSendQueue.clear() - rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumpbusy))) - } else { - // ERROR in response, wrong serial number - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - mSendQueue.clear() - rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.connectionerror))) - sp.remove(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName) - val n = Notification(Notification.WRONGSERIALNUMBER, resourceHelper.gs(R.string.wrongpassword), Notification.URGENT) - rxBus.send(EventNewNotification(n)) - } + // decrypt the packet + bleEncryption.getDecryptedPacket(inputBuffer)?.let { decryptedBuffer -> + if (decryptedBuffer[0] == BleEncryption.DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE.toByte()) { + when (decryptedBuffer[1]) { + // 1st packet exchange + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK.toByte() -> + processConnectResponse(decryptedBuffer) - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION.toByte() -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */DanaRS_Packet.toHexString(decryptedBuffer)) - if (v3Encryption) { - // decryptedBuffer[2] : 0x00 OK 0x01 Error, No pairing - if (decryptedBuffer[2] == 0x00.toByte()) { - val randomPairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, "") - val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, "") - if (randomPairingKey.isNotEmpty() && pairingKey.isNotEmpty()) { - // expecting successful connect - isConnected = true - isConnecting = false - aapsLogger.debug(LTag.PUMPBTCOMM, "Connect !!") - } else { - context.startActivity(Intent(context, EnterPinActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) - aapsLogger.debug(LTag.PUMPBTCOMM, "Request pairing keys !!") - } - } else { - sendV3PairingInformation(1) - } + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION.toByte() -> + processEncryptionResponse(decryptedBuffer) - } else { - val size = decryptedBuffer.size - var pass: Int = (decryptedBuffer[size - 1].toInt() and 0x000000FF shl 8) + (decryptedBuffer[size - 2].toInt() and 0x000000FF) - pass = pass xor 3463 - danaRPump.rsPassword = Integer.toHexString(pass) - aapsLogger.debug(LTag.PUMPBTCOMM, "Pump user password: " + Integer.toHexString(pass)) - rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)) - isConnected = true - isConnecting = false - aapsLogger.debug(LTag.PUMPBTCOMM, "RS connected and status read") - } - } + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY.toByte() -> + processPasskeyCheck(decryptedBuffer) - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY.toByte() -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - if (decryptedBuffer[2] == 0x00.toByte()) { - // Paring is not requested, sending time info - sendTimeInfo() - } else { - // Pairing on pump is requested - sendPairingRequest() - } - } + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST.toByte() -> + processPairingRequest(decryptedBuffer) - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST.toByte() -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(decryptedBuffer)) - if (decryptedBuffer[2] != 0x00.toByte()) { - disconnect("passkey request failed") - } - } + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN.toByte() -> + processPairingRequest2(decryptedBuffer) - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN.toByte() -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(decryptedBuffer)) - // Paring is successful, sending time info - rxBus.send(EventDanaRSPairingSuccess()) - sendTimeInfo() - val pairingKey = byteArrayOf(decryptedBuffer[2], decryptedBuffer[3]) - // store pairing key to preferences - sp.putString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)) - aapsLogger.debug(LTag.PUMPBTCOMM, "Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)) - } - - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_PUMP_CHECK.toByte() -> { - if (decryptedBuffer[2] == 0x05.toByte()) { - // not easy mode, request time info - val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null) - writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) - } else { - // easy mode - val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK, null, null) - writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) - } - } - - BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK.toByte() -> { - isEasyMode = decryptedBuffer[2] == 0x01.toByte() - isUnitUD = decryptedBuffer[3] == 0x01.toByte() - - // request time information - if (v3Encryption) { - sendV3PairingInformation(1) - } else { - val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null) - writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) - } - } - } - - else -> { - // Retrieve message code from received buffer and last message sent - val originalCommand = processedMessage?.command ?: 0xFFFF - val receivedCommand = DanaRS_Packet.getCommand(decryptedBuffer) - val message: DanaRS_Packet? = if (originalCommand == receivedCommand) { - // it's response to last message - processedMessage - } else { - // it's not response to last message, create new instance - danaRSMessageHashTable.findMessage(receivedCommand) - } - if (message != null) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + message.friendlyName + " " + DanaRS_Packet.toHexString(decryptedBuffer)) - // process received data - message.handleMessage(decryptedBuffer) - message.setReceived() - synchronized(message) { - // notify to sendMessage - message.notify() - } - } else { - aapsLogger.error("Unknown message received " + DanaRS_Packet.toHexString(decryptedBuffer)) - } + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_PUMP_CHECK.toByte() -> { + // not easy mode, request time info + if (decryptedBuffer[2] == 0x05.toByte()) sendTimeInfo() + // easy mode + else sendEasyMenuCheck() } + + BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK.toByte() -> + processEasyMenuCheck(decryptedBuffer) } - } ?: throw IllegalStateException("Null decryptedInputBuffer") - } catch (e: Exception) { - aapsLogger.error("Unhandled exception", e) - } + + } else { + // Retrieve message code from received buffer and last message sent + processMessage(decryptedBuffer) + } + } ?: throw IllegalStateException("Null decryptedInputBuffer") startSignatureFound = false packetIsValid = false if (bufferLength < 6) { @@ -559,6 +405,216 @@ class BLEComm @Inject internal constructor( } } + // 1st packet v1 v3 message sent to pump after connect + private fun sendConnect() { + val deviceName = connectDeviceName + if (deviceName == null || deviceName == "") { + val n = Notification(Notification.DEVICENOTPAIRED, resourceHelper.gs(R.string.pairfirst), Notification.URGENT) + rxBus.send(EventNewNotification(n)) + return + } + val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, deviceName) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + + // 1st packet response + private fun processConnectResponse(decryptedBuffer: ByteArray) { + // response OK v1 + if (decryptedBuffer.size == 4 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + v3Encryption = false + // Grab pairing key from preferences if exists + val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, "") + aapsLogger.debug(LTag.PUMPBTCOMM, "Using stored pairing key: $pairingKey") + if (pairingKey.isNotEmpty()) { + sendPasskeyCheck(pairingKey) + } else { + // Stored pairing key does not exists, request pairing + sendPairingRequest() + } + // response OK v3 + } else if (decryptedBuffer.size == 9 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) { + // v3 2nd layer encryption + v3Encryption = true + val model = decryptedBuffer[5] + // val protocol = decryptedBuffer[7] + if (model == 0x05.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK V3 (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + // Dana RS Pump + val randomPairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, "") + val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, "") + if (randomPairingKey.isNotEmpty() && pairingKey.isNotEmpty()) { + val randomSyncKey = String.format("%02x", decryptedBuffer[decryptedBuffer.size - 1]) + sp.putString(resourceHelper.gs(R.string.key_danars_v3_randomsynckey) + danaRSPlugin.mDeviceName, randomSyncKey) + val tPairingKey = Base64.decode(pairingKey, Base64.DEFAULT) + val tRandomPairingKey = Base64.decode(randomPairingKey, Base64.DEFAULT) + var tRandomSyncKey: Byte = 0 + if (randomSyncKey.isNotEmpty()) { + tRandomSyncKey = randomSyncKey.toInt(16).toByte() + } + bleEncryption.setPairingKeys(tPairingKey, tRandomPairingKey, tRandomSyncKey) + sendV3PairingInformation(0) + } else { + sendV3PairingInformation(1) + } + } else if (model == 0x06.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK V3 EASY (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + // Dana RS Easy + val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK, null, null) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + // response PUMP : error status + } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'P'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'M'.toByte() && decryptedBuffer[5] == 'P'.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + mSendQueue.clear() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumperror))) + NSUpload.uploadError(resourceHelper.gs(R.string.pumperror)) + val n = Notification(Notification.PUMPERROR, resourceHelper.gs(R.string.pumperror), Notification.URGENT) + rxBus.send(EventNewNotification(n)) + // response BUSY: error status + } else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'S'.toByte() && decryptedBuffer[5] == 'Y'.toByte()) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + mSendQueue.clear() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumpbusy))) + } else { + // ERROR in response, wrong serial number + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + mSendQueue.clear() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.connectionerror))) + sp.remove(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName) + val n = Notification(Notification.WRONGSERIALNUMBER, resourceHelper.gs(R.string.wrongpassword), Notification.URGENT) + rxBus.send(EventNewNotification(n)) + } + } + + // 2nd packet v1 check passkey + private fun sendPasskeyCheck(pairingKey: String) { + val encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey) + val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + + // 2nd packet v1 response + private fun processPasskeyCheck(decryptedBuffer: ByteArray) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + // Paring is not requested, sending time info + if (decryptedBuffer[2] == 0x00.toByte()) sendTimeInfo() + // Pairing on pump is requested + else sendPairingRequest() + } + + // 2nd packet v3 + // 0x00 Start encryption, 0x01 Request pairing + private fun sendV3PairingInformation(requestNewPairing: Int) { + val params = byteArrayOf(requestNewPairing.toByte()) + val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, params, null) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + + // 2nd packet response + private fun processEncryptionResponse(decryptedBuffer: ByteArray) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */DanaRS_Packet.toHexString(decryptedBuffer)) + if (v3Encryption) { + // decryptedBuffer[2] : 0x00 OK 0x01 Error, No pairing + if (decryptedBuffer[2] == 0x00.toByte()) { + val randomPairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, "") + val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, "") + if (randomPairingKey.isNotEmpty() && pairingKey.isNotEmpty()) { + // expecting successful connect + isConnected = true + isConnecting = false + aapsLogger.debug(LTag.PUMPBTCOMM, "Connect !!") + } else { + context.startActivity(Intent(context, EnterPinActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) + aapsLogger.debug(LTag.PUMPBTCOMM, "Request pairing keys !!") + } + } else { + sendV3PairingInformation(1) + } + + } else { + val size = decryptedBuffer.size + var pass: Int = (decryptedBuffer[size - 1].toInt() and 0x000000FF shl 8) + (decryptedBuffer[size - 2].toInt() and 0x000000FF) + pass = pass xor 3463 + danaRPump.rsPassword = Integer.toHexString(pass) + aapsLogger.debug(LTag.PUMPBTCOMM, "Pump user password: " + Integer.toHexString(pass)) + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)) + isConnected = true + isConnecting = false + aapsLogger.debug(LTag.PUMPBTCOMM, "RS connected and status read") + } + } + + // 3rd packet v1 existing pairing + private fun sendTimeInfo() { + val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + + //2nd or 3rd packet v1 pairing doesn't exist + private fun sendPairingRequest() { + // Start activity which is waiting 20sec + // On pump pairing request is displayed and is waiting for conformation + context.startActivity(Intent(context, PairingHelperActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) + val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null) + aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes)) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + + // 3rd packet v3 : only after entering PIN codes + fun finishV3Pairing() { + val randomPairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, "") + val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, "") + if (randomPairingKey.isNotEmpty() && pairingKey.isNotEmpty()) { + val tPairingKey = Base64.decode(pairingKey, Base64.DEFAULT) + val tRandomPairingKey = Base64.decode(randomPairingKey, Base64.DEFAULT) + val tRandomSyncKey: Byte = 0 + bleEncryption.setPairingKeys(tPairingKey, tRandomPairingKey, tRandomSyncKey) + sendV3PairingInformation(0) + } else throw java.lang.IllegalStateException("This should not be reached") + } + + // 2nd or 3rd packet v1 response + private fun processPairingRequest(decryptedBuffer: ByteArray) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(decryptedBuffer)) + if (decryptedBuffer[2] != 0x00.toByte()) { + disconnect("passkey request failed") + } + } + + // 2nd or 3rd packet v1 response + private fun processPairingRequest2(decryptedBuffer: ByteArray) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(decryptedBuffer)) + // Paring is successful, sending time info + rxBus.send(EventDanaRSPairingSuccess()) + sendTimeInfo() + val pairingKey = byteArrayOf(decryptedBuffer[2], decryptedBuffer[3]) + // store pairing key to preferences + sp.putString(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)) + aapsLogger.debug(LTag.PUMPBTCOMM, "Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)) + } + + // 3rd packet Easy menu pump + private fun sendEasyMenuCheck() { + val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK, null, null) + writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) + } + + // 3rd packet Easy menu response + private fun processEasyMenuCheck(decryptedBuffer: ByteArray) { + isEasyMode = decryptedBuffer[2] == 0x01.toByte() + isUnitUD = decryptedBuffer[3] == 0x01.toByte() + + // request time information + if (v3Encryption) sendV3PairingInformation(1) + else sendTimeInfo() + } + + // the rest of packets fun sendMessage(message: DanaRS_Packet?) { processedMessage = message if (message == null) return @@ -628,51 +684,27 @@ class BLEComm @Inject internal constructor( } } - fun finishV3Pairing() { - val randomPairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, "") - val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, "") - if (randomPairingKey.isNotEmpty() && pairingKey.isNotEmpty()) { - val tPairingKey = Base64.decode(pairingKey, Base64.DEFAULT) - val tRandomPairingKey = Base64.decode(randomPairingKey, Base64.DEFAULT) - val tRandomSyncKey: Byte = 0 - bleEncryption.setPairingKeys(tPairingKey, tRandomPairingKey, tRandomSyncKey) - sendV3PairingInformation(0) + // process common packet response + private fun processMessage(decryptedBuffer: ByteArray) { + val originalCommand = processedMessage?.command ?: 0xFFFF + val receivedCommand = DanaRS_Packet.getCommand(decryptedBuffer) + val message: DanaRS_Packet? = if (originalCommand == receivedCommand) { + // it's response to last message + processedMessage + } else { + // it's not response to last message, create new instance + danaRSMessageHashTable.findMessage(receivedCommand) } + if (message != null) { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + message.friendlyName + " " + DanaRS_Packet.toHexString(decryptedBuffer)) + // process received data + message.handleMessage(decryptedBuffer) + message.setReceived() + synchronized(message) { + // notify to sendMessage + message.notify() + } + } else aapsLogger.error("Unknown message received " + DanaRS_Packet.toHexString(decryptedBuffer)) } - // 0x00 Start encryption, 0x01 Request pairing - private fun sendV3PairingInformation(requestNewPairing: Int) { - val params = byteArrayOf(requestNewPairing.toByte()) - val bytes: ByteArray = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, params, null) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)) - writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) - } - - private fun sendPairingRequest() { - // Start activity which is waiting 20sec - // On pump pairing request is displayed and is waiting for conformation - context.startActivity(Intent(context, PairingHelperActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) - val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes)) - writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) - } - - private fun sendPumpCheck() { - // 1st message sent to pump after connect - val deviceName = connectDeviceName - if (deviceName == null || deviceName == "") { - val n = Notification(Notification.DEVICENOTPAIRED, resourceHelper.gs(R.string.pairfirst), Notification.URGENT) - rxBus.send(EventNewNotification(n)) - return - } - val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, deviceName) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes)) - writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) - } - - private fun sendTimeInfo() { - val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null) - aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)) - writeCharacteristicNoResponse(uartWriteBTGattChar, bytes) - } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java index cb6484bafd..4affd0d7c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java @@ -189,7 +189,7 @@ public class DanaRSService extends DaggerService { if (danaRPump.getPumpTime() == 0) { // initial handshake was not successfull // deinitialize pump - danaRPump.setLastConnection(0); + danaRPump.reset(); rxBus.send(new EventDanaRNewStatus()); rxBus.send(new EventInitializationChanged()); return; @@ -221,7 +221,7 @@ public class DanaRSService extends DaggerService { context.startActivity(i); //deinitialize pump - danaRPump.setLastConnection(0); + danaRPump.reset(); rxBus.send(new EventDanaRNewStatus()); rxBus.send(new EventInitializationChanged()); return; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt index d680490a15..87628c0d1a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt @@ -38,11 +38,11 @@ class MsgCheckValue_v2( override fun handleMessage(bytes: ByteArray) { danaRPump.isNewPump = true aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed") - danaRPump.model = intFromBuff(bytes, 0, 1) + danaRPump.btModel = intFromBuff(bytes, 0, 1) danaRPump.protocol = intFromBuff(bytes, 1, 1) danaRPump.productCode = intFromBuff(bytes, 2, 1) - if (danaRPump.model != DanaRPump.EXPORT_MODEL) { - danaRPump.lastConnection = 0 + if (danaRPump.btModel != DanaRPump.EXPORT_MODEL) { + danaRPump.reset() val notification = Notification(Notification.WRONG_DRIVER, resourceHelper.gs(R.string.pumpdrivercorrected), Notification.NORMAL) rxBus.send(EventNewNotification(notification)) danaRPlugin.disconnect("Wrong Model") @@ -59,7 +59,7 @@ class MsgCheckValue_v2( return } if (danaRPump.protocol != 2) { - danaRPump.lastConnection = 0 + danaRPump.reset() val notification = Notification(Notification.WRONG_DRIVER, resourceHelper.gs(R.string.pumpdrivercorrected), Notification.NORMAL) rxBus.send(EventNewNotification(notification)) danaRKoreanPlugin.disconnect("Wrong Model") @@ -74,7 +74,7 @@ class MsgCheckValue_v2( commandQueue.readStatus("PumpDriverChange", null) // force new connection return } - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.model)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java index 76f3083385..cb45d18bbd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java @@ -230,8 +230,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { if (danaRPump.getPumpTime() == 0) { // initial handshake was not successfull // deinitialize pump - danaRPump.setLastConnection(0); - danaRPump.setLastSettingsRead(0); + danaRPump.reset(); rxBus.send(new EventDanaRNewStatus()); rxBus.send(new EventInitializationChanged()); return; @@ -250,7 +249,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { context.startActivity(i); //deinitialize pump - danaRPump.setLastConnection(0); + danaRPump.reset(); rxBus.send(new EventDanaRNewStatus()); rxBus.send(new EventInitializationChanged()); return; diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index 763cd748cc..545b8fc119 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -115,7 +115,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp) comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context) danaRPlugin = DanaRPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, danaRPump) - danaRSPlugin = DanaRSPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage) + danaRSPlugin = DanaRSPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy) insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsPlugin, sp, commandQueue, profileFunction, context) openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits) openAPSAMAPlugin = OpenAPSAMAPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt index ec3588fbe7..b9d959c631 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt @@ -20,6 +20,6 @@ class MsgCheckValueTest : DanaRTestBase() { val array = ByteArray(100) putByteToArray(array, 0, DanaRPump.EXPORT_MODEL.toByte()) packet.handleMessage(array) - Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.model) + Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.btModel) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt index a9a13dbc90..89e4bd5fad 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt @@ -13,7 +13,6 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSTestBase -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import org.junit.Assert import org.junit.Before import org.junit.Test @@ -66,6 +65,6 @@ class DanaRSPluginTest : DanaRSTestBase() { Mockito.`when`(resourceHelper.gs(eq(R.string.limitingbasalratio), anyObject(), anyObject())).thenReturn("limitingbasalratio") Mockito.`when`(resourceHelper.gs(eq(R.string.limitingpercentrate), anyObject(), anyObject())).thenReturn("limitingpercentrate") - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage) + danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt index 420b0a73d8..7b5b94522f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt @@ -9,7 +9,6 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import org.junit.Assert import org.junit.Before import org.junit.Test @@ -47,7 +46,7 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest : DanaRSTestBase() { @Before fun mock() { - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage) + danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy) Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt new file mode 100644 index 0000000000..f962560115 --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt @@ -0,0 +1,20 @@ +package info.nightscout.androidaps.plugins.pump.danaRS.comm + +import org.junit.Assert +import org.junit.Test +import org.junit.runner.RunWith +import org.powermock.modules.junit4.PowerMockRunner + +@RunWith(PowerMockRunner::class) +class DanaRS_Packet_General_Get_Shipping_VerisonTest : DanaRSTestBase() { + + @Test fun runTest() { + val packet = DanaRS_Packet_General_Get_Shipping_Version(aapsLogger, danaRPump) + // test message decoding + val ver = byteArrayOf((-78).toByte(), (-127).toByte(), (66).toByte(), (80).toByte(), (78).toByte(), (45).toByte(), (51).toByte(), (46).toByte(), (48).toByte(), (46).toByte(), (48).toByte()) + packet.handleMessage(ver) + Assert.assertFalse(packet.failed) + Assert.assertEquals("BPN-3.0.0", danaRPump.bleModel) + Assert.assertEquals("GENERAL__GET_SHIPPING_VERSION", packet.friendlyName) + } +} \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt index 06f69cadbd..3d46558207 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt @@ -11,7 +11,6 @@ import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DefaultValueHelper import org.junit.Assert import org.junit.Before @@ -66,7 +65,7 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { @Before fun mock() { - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage) + danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy) danaRSPlugin.bolusingTreatment = Treatment(treatmentInjector) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt new file mode 100644 index 0000000000..4bd5bbbd1a --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt @@ -0,0 +1,22 @@ +package info.nightscout.androidaps.plugins.pump.danaRS.comm + +import org.junit.Assert +import org.junit.Test +import org.junit.runner.RunWith +import org.powermock.core.classloader.annotations.PrepareForTest +import org.powermock.modules.junit4.PowerMockRunner + +@RunWith(PowerMockRunner::class) +@PrepareForTest() +class DanaRS_Packet_Review_Get_Pump_Dec_RatioTest : DanaRSTestBase() { + + @Test fun runTest() { + val packet = DanaRS_Packet_Review_Get_Pump_Dec_Ratio(aapsLogger, danaRPump) + + val array = ByteArray(100) + putByteToArray(array, 0, 4.toByte()) + packet.handleMessage(array) + Assert.assertEquals(20, danaRPump.decRatio) + Assert.assertEquals("REVIEW__GET_PUMP_DEC_RATIO", packet.friendlyName) + } +} \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt index 71a361e8c5..77bf756890 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt @@ -33,6 +33,6 @@ class MsgCheckValue_v2Test : DanaRTestBase() { val packet = MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue) // test message decoding packet.handleMessage(createArray(34, 3.toByte())) - Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.model) + Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.btModel) } } \ No newline at end of file From a85ec262d32a7b491b92ce20b86c60a1f64a752c Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 28 Mar 2020 22:40:56 +0100 Subject: [PATCH 010/400] Display Dana model --- .../plugins/pump/danaR/DanaRFragment.kt | 9 ++------- .../androidaps/plugins/pump/danaR/DanaRPump.kt | 17 ++++++++++++++++- .../plugins/pump/danaR/comm/MsgCheckValue.kt | 6 +++--- .../pump/danaRKorean/comm/MsgCheckValue_k.kt | 6 +++--- .../DanaRS_Packet_General_Get_Pump_Check.kt | 4 ++-- .../pump/danaRv2/comm/MsgCheckValue_v2.kt | 6 +++--- app/src/main/res/values/strings.xml | 2 +- .../pump/danaR/comm/MsgCheckValueTest.kt | 2 +- .../pump/danaRv2/comm/MsgCheckValue_v2Test.kt | 2 +- 9 files changed, 32 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt index 6cace72c5f..fcc84f1314 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt @@ -210,12 +210,7 @@ class DanaRFragment : DaggerFragment() { danar_battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}" SetWarnColor.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0) danar_iob.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob) - if (pump.btModel != 0 || pump.protocol != 0 || pump.productCode != 0) { - danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.btModel, pump.protocol, pump.productCode) - } else { - @Suppress("SetTextI18n") - danar_firmware.text = "OLD" - } + danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.modelFriendlyName(), pump.hwModel, pump.protocol, pump.productCode) danar_basalstep.text = pump.basalStep.toString() danar_bolusstep.text = pump.bolusStep.toString() danar_serialnumber.text = pump.serialNumber @@ -229,7 +224,7 @@ class DanaRFragment : DaggerFragment() { //hide user options button if not an RS pump or old firmware // also excludes pump with model 03 because of untested error val isKorean = danaRKoreanPlugin.isEnabled(PluginType.PUMP) - if (isKorean || danar_firmware.text === "OLD" || pump.btModel == 3) { + if (isKorean || pump.hwModel == 0 || pump.hwModel == 3) { danar_user_options.visibility = View.GONE } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt index eb5bb627fc..213efac04d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt @@ -51,7 +51,7 @@ class DanaRPump @Inject constructor( var isNewPump = true // R only , providing model info var password = -1 // R, RSv1 var pumpTime: Long = 0 - var btModel = 0 + var hwModel = 0 var protocol = 0 var productCode = 0 var errorState: ErrorState = ErrorState.NONE @@ -227,6 +227,21 @@ class DanaRPump @Inject constructor( lastSettingsRead = 0 } + fun modelFriendlyName(): String = + when (hwModel) { + 0x01 -> "DanaR Korean" + 0x03 -> + if (protocol == 0x00) "DanaR old" + else if (protocol == 0x02) "DanaR v2" + else "DanaR" // 0x01 and 0x03 known + 0x05 -> + if (protocol < 10) "DanaRS" + else "DanaRS v3" + 0x06 -> "DanaRS Korean" + 0x07 -> "Dana-i" + else -> "Unknown Dana pump" + } + companion object { const val UNITS_MGDL = 0 const val UNITS_MMOL = 1 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt index 3cc8701a38..f573ef0475 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt @@ -19,14 +19,14 @@ class MsgCheckValue( override fun handleMessage(bytes: ByteArray) { danaRPump.isNewPump = true aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed") - danaRPump.btModel = intFromBuff(bytes, 0, 1) + danaRPump.hwModel = intFromBuff(bytes, 0, 1) danaRPump.protocol = intFromBuff(bytes, 1, 1) danaRPump.productCode = intFromBuff(bytes, 2, 1) - if (danaRPump.btModel != DanaRPump.EXPORT_MODEL) { + if (danaRPump.hwModel != DanaRPump.EXPORT_MODEL) { danaRPlugin.disconnect("Wrong Model") aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected") } - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt index 412d13cf3d..1742c4b1dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt @@ -21,14 +21,14 @@ class MsgCheckValue_k( override fun handleMessage(bytes: ByteArray) { danaRPump.isNewPump = true aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed") - danaRPump.btModel = intFromBuff(bytes, 0, 1) + danaRPump.hwModel = intFromBuff(bytes, 0, 1) danaRPump.protocol = intFromBuff(bytes, 1, 1) danaRPump.productCode = intFromBuff(bytes, 2, 1) - if (danaRPump.btModel != DanaRPump.DOMESTIC_MODEL) { + if (danaRPump.hwModel != DanaRPump.DOMESTIC_MODEL) { danaRKoreanPlugin.disconnect("Wrong Model") aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected") } - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt index 5646c6f370..be57043e89 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt @@ -30,14 +30,14 @@ class DanaRS_Packet_General_Get_Pump_Check( failed = false var dataIndex = DATA_START var dataSize = 1 - danaRPump.btModel = byteArrayToInt(getBytes(data, dataIndex, dataSize)) + danaRPump.hwModel = byteArrayToInt(getBytes(data, dataIndex, dataSize)) dataIndex += dataSize dataSize = 1 danaRPump.protocol = byteArrayToInt(getBytes(data, dataIndex, dataSize)) dataIndex += dataSize dataSize = 1 danaRPump.productCode = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) if (danaRPump.productCode < 2) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt index 87628c0d1a..7d0b2b5e53 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt @@ -38,10 +38,10 @@ class MsgCheckValue_v2( override fun handleMessage(bytes: ByteArray) { danaRPump.isNewPump = true aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed") - danaRPump.btModel = intFromBuff(bytes, 0, 1) + danaRPump.hwModel = intFromBuff(bytes, 0, 1) danaRPump.protocol = intFromBuff(bytes, 1, 1) danaRPump.productCode = intFromBuff(bytes, 2, 1) - if (danaRPump.btModel != DanaRPump.EXPORT_MODEL) { + if (danaRPump.hwModel != DanaRPump.EXPORT_MODEL) { danaRPump.reset() val notification = Notification(Notification.WRONG_DRIVER, resourceHelper.gs(R.string.pumpdrivercorrected), Notification.NORMAL) rxBus.send(EventNewNotification(notification)) @@ -74,7 +74,7 @@ class MsgCheckValue_v2( commandQueue.readStatus("PumpDriverChange", null) // force new connection return } - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3ac901f44f..86b7c02cbc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -485,7 +485,7 @@ Useful when data from unfiltered sources like xDrip gets noisy. Advanced Settings key_advancedsettings - Model: %1$02X Protocol: %2$02X Code: %3$02X + %1$s\nModel: %2$02X\nProtocol: %3$02X\nCode: %4$02X Profile Default value: 3 This is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware that’s what is discussed about “3x max daily; 4x current” for safety caps. Default value: 4 This is the other half of the key OpenAPS safety caps, and the other half of “3x max daily; 4x current” of the safety caps. This means your basal, regardless of max basal set on your pump, cannot be any higher than this number times the current level of your basal. This is to prevent people from getting into dangerous territory by setting excessively high max basals before understanding how the algorithm works. Again, the default is 4x; most people will never need to adjust this and are instead more likely to need to adjust other settings if they feel like they are “running into” this safety cap. diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt index b9d959c631..2b5058241d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt @@ -20,6 +20,6 @@ class MsgCheckValueTest : DanaRTestBase() { val array = ByteArray(100) putByteToArray(array, 0, DanaRPump.EXPORT_MODEL.toByte()) packet.handleMessage(array) - Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.btModel) + Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.hwModel) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt index 77bf756890..4bd8ad6e57 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt @@ -33,6 +33,6 @@ class MsgCheckValue_v2Test : DanaRTestBase() { val packet = MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue) // test message decoding packet.handleMessage(createArray(34, 3.toByte())) - Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.btModel) + Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.hwModel) } } \ No newline at end of file From df03a8a2c014b025d0d1236780bc627f2b5ec064 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 29 Mar 2020 11:40:57 +0200 Subject: [PATCH 011/400] DanaRSPlugin, DanaRSService -> kt, allign with R code --- .../interfaces/PumpDescription.java | 5 + .../smsCommunicator/SmsCommunicatorPlugin.kt | 2 +- .../plugins/pump/danaR/DanaRPlugin.java | 2 +- .../plugins/pump/danaR/DanaRPump.kt | 8 +- .../plugins/pump/danaR/comm/MsgBolusStart.kt | 3 +- .../pump/danaR/comm/MsgBolusStartWithSpeed.kt | 3 +- .../pump/danaRKorean/DanaRKoreanPlugin.java | 2 +- .../plugins/pump/danaRS/DanaRSPlugin.java | 843 ------------------ .../plugins/pump/danaRS/DanaRSPlugin.kt | 658 ++++++++++++++ .../danaRS/comm/DanaRSMessageHashTable.kt | 11 +- .../comm/DanaRS_Packet_APS_History_Events.kt | 11 +- ...anaRS_Packet_Bolus_Set_Step_Bolus_Start.kt | 12 +- ...DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt | 12 +- .../DanaRS_Packet_Notify_Delivery_Complete.kt | 14 +- ...aRS_Packet_Notify_Delivery_Rate_Display.kt | 14 +- .../plugins/pump/danaRS/services/BLEComm.kt | 3 +- .../pump/danaRS/services/DanaRSService.java | 565 ------------ .../pump/danaRS/services/DanaRSService.kt | 462 ++++++++++ .../plugins/pump/danaRv2/DanaRv2Plugin.java | 2 +- .../danaRS/comm/DanaRSMessageHashTableTest.kt | 7 +- .../DanaRS_Packet_APS_History_EventsTest.kt | 5 +- ...S_Packet_Bolus_Set_Step_Bolus_StartTest.kt | 2 +- ...RS_Packet_Bolus_Set_Step_Bolus_StopTest.kt | 7 +- ...aRS_Packet_Notify_Delivery_CompleteTest.kt | 9 +- ...Packet_Notify_Delivery_Rate_DisplayTest.kt | 4 +- 25 files changed, 1187 insertions(+), 1479 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java index e4a02883e8..65e735e53a 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java @@ -15,6 +15,11 @@ public class PumpDescription { resetSettings(); } + public PumpDescription (PumpType pumpType) { + this(); + setPumpDescription(pumpType); + } + public static final int NONE = 0; public static final int PERCENT = 0x01; public static final int ABSOLUTE = 0x02; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 78a0bf0ffc..7019a2a65d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -709,7 +709,7 @@ class SmsCommunicatorPlugin @Inject constructor( sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) return } - time = midnight + T.secs(seconds.toLong()).msecs() + time = midnight + T.secs(seconds.toLong()).msecs() // TODO: this is wrong during leap day } grams = constraintChecker.applyCarbsConstraints(Constraint(grams)).value() if (grams == 0) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java index 3c6ce84c42..91fa4207b4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java @@ -165,7 +165,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.bolusDelivered = t.insulin; result.carbsDelivered = detailedBolusInfo.carbs; if (!result.success) - result.comment = String.format(resourceHelper.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, danaRPump.getMessageStartErrorCode()); + result.comment = String.format(resourceHelper.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, danaRPump.getBolusStartErrorCode()); else result.comment = resourceHelper.gs(R.string.virtualpump_resultok); aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt index 213efac04d..b9a5509b54 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt @@ -141,15 +141,15 @@ class DanaRPump @Inject constructor( return if (units == UNITS_MGDL) Constants.MGDL else Constants.MMOL } - // DanaR,Rv2,RK specific flags - // last start bolus erroCode - var messageStartErrorCode: Int = 0 - var historyDoneReceived: Boolean = false + var bolusStartErrorCode: Int = 0 // last start bolus erroCode + var historyDoneReceived: Boolean = false // true when last history message is received var bolusingTreatment: Treatment? = null // actually delivered treatment var bolusAmountToBeDelivered = 0.0 // amount to be delivered var bolusProgressLastTimeStamp: Long = 0 // timestamp of last bolus progress message var bolusStopped = false // bolus finished var bolusStopForced = false // bolus forced to stop by user + var bolusDone = false // success end + var lastEventTimeLoaded: Long = 0 // timestamp of last received event fun createConvertedProfile(): ProfileStore? { pumpProfiles?.let { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStart.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStart.kt index 695c3f1ec0..320d8b85d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStart.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStart.kt @@ -4,7 +4,6 @@ import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump class MsgBolusStart( @@ -31,6 +30,6 @@ class MsgBolusStart( failed = false aapsLogger.debug(LTag.PUMPBTCOMM, "Messsage response: $errorCode OK") } - danaRPump.messageStartErrorCode = errorCode + danaRPump.bolusStartErrorCode = errorCode } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeed.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeed.kt index 3ea3eed8f1..2925172735 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeed.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeed.kt @@ -4,7 +4,6 @@ import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump class MsgBolusStartWithSpeed( @@ -33,6 +32,6 @@ class MsgBolusStartWithSpeed( failed = false aapsLogger.debug(LTag.PUMPBTCOMM, "Messsage response: $errorCode OK") } - danaRPump.messageStartErrorCode = errorCode + danaRPump.bolusStartErrorCode = errorCode } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java index 809cf77e6f..4ae99b25e8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java @@ -168,7 +168,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.bolusDelivered = t.insulin; result.carbsDelivered = detailedBolusInfo.carbs; if (!result.success) - result.comment = resourceHelper.gs(R.string.boluserrorcode, detailedBolusInfo.insulin, t.insulin, danaRPump.getMessageStartErrorCode()); + result.comment = resourceHelper.gs(R.string.boluserrorcode, detailedBolusInfo.insulin, t.insulin, danaRPump.getBolusStartErrorCode()); else result.comment = resourceHelper.gs(R.string.virtualpump_resultok); aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java deleted file mode 100644 index 35f1e81a21..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java +++ /dev/null @@ -1,843 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.danaRS; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.IBinder; - -import androidx.annotation.NonNull; -import androidx.preference.Preference; - -import org.jetbrains.annotations.NotNull; -import org.json.JSONException; -import org.json.JSONObject; - -import java.util.List; - -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.data.DetailedBolusInfo; -import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.data.PumpEnactResult; -import info.nightscout.androidaps.db.ExtendedBolus; -import info.nightscout.androidaps.db.TemporaryBasal; -import info.nightscout.androidaps.events.EventAppExit; -import info.nightscout.androidaps.events.EventConfigBuilderChange; -import info.nightscout.androidaps.interfaces.CommandQueueProvider; -import info.nightscout.androidaps.interfaces.Constraint; -import info.nightscout.androidaps.interfaces.ConstraintsInterface; -import info.nightscout.androidaps.interfaces.DanaRInterface; -import info.nightscout.androidaps.interfaces.PluginDescription; -import info.nightscout.androidaps.interfaces.PluginType; -import info.nightscout.androidaps.interfaces.PumpDescription; -import info.nightscout.androidaps.interfaces.PumpInterface; -import info.nightscout.androidaps.interfaces.PumpPluginBase; -import info.nightscout.androidaps.logging.AAPSLogger; -import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.common.ManufacturerType; -import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; -import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction; -import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType; -import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; -import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; -import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; -import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage; -import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; -import info.nightscout.androidaps.plugins.pump.danaR.DanaRFragment; -import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump; -import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes; -import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSDeviceChange; -import info.nightscout.androidaps.plugins.pump.danaRS.services.DanaRSService; -import info.nightscout.androidaps.plugins.treatments.Treatment; -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; -import info.nightscout.androidaps.utils.DateUtil; -import info.nightscout.androidaps.utils.DecimalFormatter; -import info.nightscout.androidaps.utils.FabricPrivacy; -import info.nightscout.androidaps.utils.Round; -import info.nightscout.androidaps.utils.T; -import info.nightscout.androidaps.utils.ToastUtils; -import info.nightscout.androidaps.utils.resources.ResourceHelper; -import info.nightscout.androidaps.utils.sharedPreferences.SP; -import io.reactivex.disposables.CompositeDisposable; -import io.reactivex.schedulers.Schedulers; - -@Singleton -public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface { - private CompositeDisposable disposable = new CompositeDisposable(); - - private final Context context; - private final ResourceHelper resourceHelper; - private final ConstraintChecker constraintChecker; - private final ProfileFunction profileFunction; - private final TreatmentsPlugin treatmentsPlugin; - private final SP sp; - private final RxBusWrapper rxBus; - private final DanaRPump danaRPump; - private final DetailedBolusInfoStorage detailedBolusInfoStorage; - private final FabricPrivacy fabricPrivacy; - - private DanaRSService danaRSService; - - private String mDeviceAddress = ""; - public String mDeviceName = ""; - - public PumpDescription pumpDescription = new PumpDescription(); - - // Bolus & history handling - public int bolusStartErrorCode; // from start message - public Treatment bolusingTreatment; // actually delivered treatment - public double bolusAmountToBeDelivered = 0.0; // amount to be delivered - public boolean bolusStopped = false; // bolus finished - public boolean bolusStopForced = false; // bolus forced to stop by user - public boolean bolusDone = false; // success end - public long bolusProgressLastTimeStamp = 0; // timestamp of last bolus progress message - public boolean apsHistoryDone = false; // true when last history message is received - public long lastEventTimeLoaded = 0; // timestamp of last received event - - @Inject - public DanaRSPlugin( - HasAndroidInjector injector, - AAPSLogger aapsLogger, - RxBusWrapper rxBus, - Context context, - ResourceHelper resourceHelper, - ConstraintChecker constraintChecker, - ProfileFunction profileFunction, - TreatmentsPlugin treatmentsPlugin, - SP sp, - CommandQueueProvider commandQueue, - DanaRPump danaRPump, - DetailedBolusInfoStorage detailedBolusInfoStorage, - FabricPrivacy fabricPrivacy - ) { - super(new PluginDescription() - .mainType(PluginType.PUMP) - .fragmentClass(DanaRFragment.class.getName()) - .pluginName(R.string.danarspump) - .shortName(R.string.danarspump_shortname) - .preferencesId(R.xml.pref_danars) - .description(R.string.description_pump_dana_rs), - injector, aapsLogger, resourceHelper, commandQueue - ); - this.context = context; - this.rxBus = rxBus; - this.resourceHelper = resourceHelper; - this.constraintChecker = constraintChecker; - this.profileFunction = profileFunction; - this.treatmentsPlugin = treatmentsPlugin; - this.sp = sp; - this.danaRPump = danaRPump; - this.detailedBolusInfoStorage = detailedBolusInfoStorage; - this.fabricPrivacy = fabricPrivacy; - - pumpDescription.setPumpDescription(PumpType.DanaRS); - } - - @Override - public void updatePreferenceSummary(@NotNull Preference pref) { - super.updatePreferenceSummary(pref); - - if (pref.getKey().equals(resourceHelper.gs(R.string.key_danars_name))) - pref.setSummary(sp.getString(R.string.key_danars_name, "")); - } - - @Override - protected void onStart() { - Intent intent = new Intent(context, DanaRSService.class); - context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); - - disposable.add(rxBus - .toObservable(EventAppExit.class) - .observeOn(Schedulers.io()) - .subscribe(event -> context.unbindService(mConnection), fabricPrivacy::logException) - ); - disposable.add(rxBus - .toObservable(EventConfigBuilderChange.class) - .observeOn(Schedulers.io()) - .subscribe(event -> danaRPump.reset()) - ); - disposable.add(rxBus - .toObservable(EventDanaRSDeviceChange.class) - .observeOn(Schedulers.io()) - .subscribe(event -> changePump(), fabricPrivacy::logException) - ); - changePump(); // load device name - super.onStart(); - } - - @Override - protected void onStop() { - context.unbindService(mConnection); - - disposable.clear(); - super.onStop(); - } - - private ServiceConnection mConnection = new ServiceConnection() { - - public void onServiceDisconnected(ComponentName name) { - getAapsLogger().debug(LTag.PUMP, "Service is disconnected"); - danaRSService = null; - } - - public void onServiceConnected(ComponentName name, IBinder service) { - getAapsLogger().debug(LTag.PUMP, "Service is connected"); - DanaRSService.LocalBinder mLocalBinder = (DanaRSService.LocalBinder) service; - danaRSService = mLocalBinder.getServiceInstance(); - } - }; - - public void changePump() { - mDeviceAddress = sp.getString(R.string.key_danars_address, ""); - mDeviceName = sp.getString(R.string.key_danars_name, ""); - danaRPump.reset(); - getCommandQueue().readStatus("DeviceChanged", null); - } - - @Override - public void connect(String from) { - getAapsLogger().debug(LTag.PUMP, "RS connect from: " + from); - if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) { - boolean success = danaRSService.connect(from, mDeviceAddress); - if (!success) - ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.rileylink_scanner_ble_not_supported)); - } - } - - @Override - public boolean isConnected() { - return danaRSService != null && danaRSService.isConnected(); - } - - @Override - public boolean isConnecting() { - return danaRSService != null && danaRSService.isConnecting(); - } - - @Override - public boolean isHandshakeInProgress() { - return false; - } - - @Override - public void finishHandshaking() { - } - - @Override - public void disconnect(String from) { - getAapsLogger().debug(LTag.PUMP, "RS disconnect from: " + from); - if (danaRSService != null) danaRSService.disconnect(from); - } - - @Override - public void stopConnecting() { - if (danaRSService != null) danaRSService.stopConnecting(); - } - - @Override - public void getPumpStatus() { - if (danaRSService != null) { - danaRSService.getPumpStatus(); - pumpDescription.basalStep = danaRPump.getBasalStep(); - pumpDescription.bolusStep = danaRPump.getBolusStep(); - } - } - - // DanaR interface - - @Override - public PumpEnactResult loadHistory(byte type) { - return danaRSService.loadHistory(type); - } - - @Override - public PumpEnactResult loadEvents() { - return danaRSService.loadEvents(); - } - - @Override - public PumpEnactResult setUserOptions() { - return danaRSService.setUserSettings(); - } - - // Constraints interface - - @NonNull - @Override - public Constraint applyBasalConstraints(Constraint absoluteRate, @NonNull Profile profile) { - absoluteRate.setIfSmaller(getAapsLogger(), danaRPump.getMaxBasal(), resourceHelper.gs(R.string.limitingbasalratio, danaRPump.getMaxBasal(), resourceHelper.gs(R.string.pumplimit)), this); - return absoluteRate; - } - - @NonNull - @Override - public Constraint applyBasalPercentConstraints(Constraint percentRate, @NonNull Profile profile) { - percentRate.setIfGreater(getAapsLogger(), 0, resourceHelper.gs(R.string.limitingpercentrate, 0, resourceHelper.gs(R.string.itmustbepositivevalue)), this); - percentRate.setIfSmaller(getAapsLogger(), getPumpDescription().maxTempPercent, resourceHelper.gs(R.string.limitingpercentrate, getPumpDescription().maxTempPercent, resourceHelper.gs(R.string.pumplimit)), this); - - return percentRate; - } - - - @NonNull - @Override - public Constraint applyBolusConstraints(Constraint insulin) { - insulin.setIfSmaller(getAapsLogger(), danaRPump.getMaxBolus(), resourceHelper.gs(R.string.limitingbolus, danaRPump.getMaxBolus(), resourceHelper.gs(R.string.pumplimit)), this); - return insulin; - } - - @NonNull - @Override - public Constraint applyExtendedBolusConstraints(@NonNull Constraint insulin) { - return applyBolusConstraints(insulin); - } - - // Pump interface - - @Override - public boolean isInitialized() { - return danaRPump.getLastConnection() > 0 && danaRPump.getMaxBasal() > 0; - } - - @Override - public boolean isSuspended() { - return danaRPump.getPumpSuspended(); - } - - @Override - public boolean isBusy() { - if (danaRSService == null) return false; - return danaRSService.isConnected() || danaRSService.isConnecting(); - } - - @NonNull @Override - public PumpEnactResult setNewBasalProfile(Profile profile) { - PumpEnactResult result = new PumpEnactResult(getInjector()); - - if (danaRSService == null) { - getAapsLogger().error("setNewBasalProfile sExecutionService is null"); - result.comment = "setNewBasalProfile sExecutionService is null"; - return result; - } - if (!isInitialized()) { - getAapsLogger().error("setNewBasalProfile not initialized"); - Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, resourceHelper.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT); - rxBus.send(new EventNewNotification(notification)); - result.comment = resourceHelper.gs(R.string.pumpNotInitializedProfileNotSet); - return result; - } else { - rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); - } - if (!danaRSService.updateBasalsInPump(profile)) { - Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT); - rxBus.send(new EventNewNotification(notification)); - result.comment = resourceHelper.gs(R.string.failedupdatebasalprofile); - return result; - } else { - rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); - rxBus.send(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); - Notification notification = new Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60); - rxBus.send(new EventNewNotification(notification)); - result.success = true; - result.enacted = true; - result.comment = "OK"; - return result; - } - } - - @Override - public boolean isThisProfileSet(Profile profile) { - if (!isInitialized()) - return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS - if (danaRPump.getPumpProfiles() == null) - return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS - int basalValues = danaRPump.getBasal48Enable() ? 48 : 24; - int basalIncrement = danaRPump.getBasal48Enable() ? 30 * 60 : 60 * 60; - for (int h = 0; h < basalValues; h++) { - Double pumpValue = danaRPump.getPumpProfiles()[danaRPump.getActiveProfile()][h]; - Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement); - if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) { - getAapsLogger().debug(LTag.PUMP, "Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); - return false; - } - } - return true; - } - - @Override - public long lastDataTime() { - return danaRPump.getLastConnection(); - } - - @Override - public double getBaseBasalRate() { - return danaRPump.getCurrentBasal(); - } - - @Override - public double getReservoirLevel() { - return danaRPump.getReservoirRemainingUnits(); - } - - @Override - public int getBatteryLevel() { - return danaRPump.getBatteryRemaining(); - } - - @NonNull @Override - public synchronized PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { - detailedBolusInfo.insulin = constraintChecker.applyBolusConstraints(new Constraint<>(detailedBolusInfo.insulin)).value(); - if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { - int preferencesSpeed = sp.getInt(R.string.key_danars_bolusspeed, 0); - int speed = 12; - switch (preferencesSpeed) { - case 0: - speed = 12; - break; - case 1: - speed = 30; - break; - case 2: - speed = 60; - break; - } - // RS stores end time for bolus, we need to adjust time - // default delivery speed is 12 sec/U - detailedBolusInfo.date = DateUtil.now() + (long) (speed * detailedBolusInfo.insulin * 1000); - // clean carbs to prevent counting them as twice because they will picked up as another record - // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records - double carbs = detailedBolusInfo.carbs; - detailedBolusInfo.carbs = 0; - int carbTime = detailedBolusInfo.carbTime; - if (carbTime == 0) carbTime--; // better set 1 min back to prevents clash with insulin - detailedBolusInfo.carbTime = 0; - - detailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history - - Treatment t = new Treatment(); - t.isSMB = detailedBolusInfo.isSMB; - boolean connectionOK = false; - if (detailedBolusInfo.insulin > 0 || carbs > 0) - connectionOK = danaRSService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + T.mins(carbTime).msecs(), t); - PumpEnactResult result = new PumpEnactResult(getInjector()); - result.success = connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep; - result.bolusDelivered = t.insulin; - result.carbsDelivered = detailedBolusInfo.carbs; - if (!result.success) { - String error = "" + bolusStartErrorCode; - switch (bolusStartErrorCode) { - // 4 reported as max bolus violation. Check later - case 0x10: - error = resourceHelper.gs(R.string.maxbolusviolation); - break; - case 0x20: - error = resourceHelper.gs(R.string.commanderror); - break; - case 0x40: - error = resourceHelper.gs(R.string.speederror); - break; - case 0x80: - error = resourceHelper.gs(R.string.insulinlimitviolation); - break; - } - result.comment = String.format(resourceHelper.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, error); - } else - result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - getAapsLogger().debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); - return result; - } else { - PumpEnactResult result = new PumpEnactResult(getInjector()); - result.success = false; - result.bolusDelivered = 0d; - result.carbsDelivered = 0d; - result.comment = resourceHelper.gs(R.string.danar_invalidinput); - getAapsLogger().error("deliverTreatment: Invalid input"); - return result; - } - } - - @Override - public void stopBolusDelivering() { - if (danaRSService == null) { - getAapsLogger().error("stopBolusDelivering sExecutionService is null"); - return; - } - danaRSService.bolusStop(); - } - - // This is called from APS - @NonNull @Override - public synchronized PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) { - // Recheck pump status if older than 30 min - - //This should not be needed while using queue because connection should be done before calling this - //if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) { - // connect("setTempBasalAbsolute old data"); - //} - - PumpEnactResult result = new PumpEnactResult(getInjector()); - - absoluteRate = constraintChecker.applyBasalConstraints(new Constraint<>(absoluteRate), profile).value(); - - final boolean doTempOff = getBaseBasalRate() - absoluteRate == 0d; - final boolean doLowTemp = absoluteRate < getBaseBasalRate(); - final boolean doHighTemp = absoluteRate > getBaseBasalRate(); - - if (doTempOff) { - // If temp in progress - if (treatmentsPlugin.isTempBasalInProgress()) { - getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: Stopping temp basal (doTempOff)"); - return cancelTempBasal(false); - } - result.success = true; - result.enacted = false; - result.percent = 100; - result.isPercent = true; - result.isTempCancel = true; - getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK"); - return result; - } - - if (doLowTemp || doHighTemp) { - Integer percentRate = Double.valueOf(absoluteRate / getBaseBasalRate() * 100).intValue(); - if (percentRate < 100) percentRate = Round.ceilTo((double) percentRate, 10d).intValue(); - else percentRate = Round.floorTo((double) percentRate, 10d).intValue(); - if (percentRate > 500) // Special high temp 500/15min - percentRate = 500; - // Check if some temp is already in progress - TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis()); - if (activeTemp != null) { - getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: currently running: " + activeTemp.toString()); - // Correct basal already set ? - if (activeTemp.percentRate == percentRate && activeTemp.getPlannedRemainingMinutes() > 4) { - if (!enforceNew) { - result.success = true; - result.percent = percentRate; - result.enacted = false; - result.duration = activeTemp.getPlannedRemainingMinutes(); - result.isPercent = true; - result.isTempCancel = false; - getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); - return result; - } - } - } - // Convert duration from minutes to hours - getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); - if (percentRate == 0 && durationInMinutes > 30) { - result = setTempBasalPercent(percentRate, durationInMinutes, profile, enforceNew); - } else { - // use special APS temp basal call ... 100+/15min .... 100-/30min - result = setHighTempBasalPercent(percentRate); - } - if (!result.success) { - getAapsLogger().error("setTempBasalAbsolute: Failed to set hightemp basal"); - return result; - } - getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: hightemp basal set ok"); - return result; - } - // We should never end here - getAapsLogger().error("setTempBasalAbsolute: Internal error"); - result.success = false; - result.comment = "Internal error"; - return result; - } - - @NonNull @Override - public synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) { - DanaRPump pump = danaRPump; - PumpEnactResult result = new PumpEnactResult(getInjector()); - percent = constraintChecker.applyBasalPercentConstraints(new Constraint<>(percent), profile).value(); - if (percent < 0) { - result.isTempCancel = false; - result.enacted = false; - result.success = false; - result.comment = resourceHelper.gs(R.string.danar_invalidinput); - getAapsLogger().error("setTempBasalPercent: Invalid input"); - return result; - } - if (percent > getPumpDescription().maxTempPercent) - percent = getPumpDescription().maxTempPercent; - long now = System.currentTimeMillis(); - TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(now); - if (activeTemp != null && activeTemp.percentRate == percent && activeTemp.getPlannedRemainingMinutes() > 4 && !enforceNew) { - result.enacted = false; - result.success = true; - result.isTempCancel = false; - result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - result.duration = pump.getTempBasalRemainingMin(); - result.percent = pump.getTempBasalPercent(); - result.isPercent = true; - getAapsLogger().debug(LTag.PUMP, "setTempBasalPercent: Correct value already set"); - return result; - } - boolean connectionOK; - if (durationInMinutes == 15 || durationInMinutes == 30) { - connectionOK = danaRSService.tempBasalShortDuration(percent, durationInMinutes); - } else { - int durationInHours = Math.max(durationInMinutes / 60, 1); - connectionOK = danaRSService.tempBasal(percent, durationInHours); - } - if (connectionOK && pump.isTempBasalInProgress() && pump.getTempBasalPercent() == percent) { - result.enacted = true; - result.success = true; - result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - result.isTempCancel = false; - result.duration = pump.getTempBasalRemainingMin(); - result.percent = pump.getTempBasalPercent(); - result.isPercent = true; - getAapsLogger().debug(LTag.PUMP, "setTempBasalPercent: OK"); - return result; - } - result.enacted = false; - result.success = false; - result.comment = resourceHelper.gs(R.string.tempbasaldeliveryerror); - getAapsLogger().error("setTempBasalPercent: Failed to set temp basal"); - return result; - } - - private synchronized PumpEnactResult setHighTempBasalPercent(Integer percent) { - DanaRPump pump = danaRPump; - PumpEnactResult result = new PumpEnactResult(getInjector()); - boolean connectionOK = danaRSService.highTempBasal(percent); - if (connectionOK && pump.isTempBasalInProgress() && pump.getTempBasalPercent() == percent) { - result.enacted = true; - result.success = true; - result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - result.isTempCancel = false; - result.duration = pump.getTempBasalRemainingMin(); - result.percent = pump.getTempBasalPercent(); - result.isPercent = true; - getAapsLogger().debug(LTag.PUMP, "setHighTempBasalPercent: OK"); - return result; - } - result.enacted = false; - result.success = false; - result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly); - getAapsLogger().error("setHighTempBasalPercent: Failed to set temp basal"); - return result; - } - - @NonNull @Override - public synchronized PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { - DanaRPump pump = danaRPump; - insulin = constraintChecker.applyExtendedBolusConstraints(new Constraint<>(insulin)).value(); - // needs to be rounded - int durationInHalfHours = Math.max(durationInMinutes / 30, 1); - insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep); - PumpEnactResult result = new PumpEnactResult(getInjector()); - ExtendedBolus runningEB = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()); - if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) { - result.enacted = false; - result.success = true; - result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - result.duration = pump.getExtendedBolusRemainingMinutes(); - result.absolute = pump.getExtendedBolusAbsoluteRate(); - result.isPercent = false; - result.isTempCancel = false; - getAapsLogger().debug(LTag.PUMP, "setExtendedBolus: Correct extended bolus already set. Current: " + pump.getExtendedBolusAmount() + " Asked: " + insulin); - return result; - } - boolean connectionOK = danaRSService.extendedBolus(insulin, durationInHalfHours); - if (connectionOK && pump.isExtendedInProgress() && Math.abs(pump.getExtendedBolusAbsoluteRate() - insulin) < getPumpDescription().extendedBolusStep) { - result.enacted = true; - result.success = true; - result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - result.isTempCancel = false; - result.duration = pump.getExtendedBolusRemainingMinutes(); - result.absolute = pump.getExtendedBolusAbsoluteRate(); - result.bolusDelivered = pump.getExtendedBolusAmount(); - result.isPercent = false; - getAapsLogger().debug(LTag.PUMP, "setExtendedBolus: OK"); - return result; - } - result.enacted = false; - result.success = false; - result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly); - getAapsLogger().error("setExtendedBolus: Failed to extended bolus"); - return result; - } - - @NonNull @Override - public synchronized PumpEnactResult cancelTempBasal(boolean force) { - PumpEnactResult result = new PumpEnactResult(getInjector()); - TemporaryBasal runningTB = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis()); - if (runningTB != null) { - danaRSService.tempBasalStop(); - result.enacted = true; - result.isTempCancel = true; - } - if (!danaRPump.isTempBasalInProgress()) { - result.success = true; - result.isTempCancel = true; - result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - getAapsLogger().debug(LTag.PUMP, "cancelRealTempBasal: OK"); - return result; - } else { - result.success = false; - result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly); - result.isTempCancel = true; - getAapsLogger().error("cancelRealTempBasal: Failed to cancel temp basal"); - return result; - } - } - - @NonNull @Override - public synchronized PumpEnactResult cancelExtendedBolus() { - PumpEnactResult result = new PumpEnactResult(getInjector()); - ExtendedBolus runningEB = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()); - if (runningEB != null) { - danaRSService.extendedBolusStop(); - result.enacted = true; - result.isTempCancel = true; - } - if (!danaRPump.isExtendedInProgress()) { - result.success = true; - result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - getAapsLogger().debug(LTag.PUMP, "cancelExtendedBolus: OK"); - return result; - } else { - result.success = false; - result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly); - getAapsLogger().error("cancelExtendedBolus: Failed to cancel extended bolus"); - return result; - } - } - - @NonNull @Override - public JSONObject getJSONStatus(Profile profile, String profileName) { - DanaRPump pump = danaRPump; - long now = System.currentTimeMillis(); - if (pump.getLastConnection() + 5 * 60 * 1000L < System.currentTimeMillis()) { - return new JSONObject(); - } - JSONObject pumpjson = new JSONObject(); - JSONObject battery = new JSONObject(); - JSONObject status = new JSONObject(); - JSONObject extended = new JSONObject(); - try { - battery.put("percent", pump.getBatteryRemaining()); - status.put("status", pump.getPumpSuspended() ? "suspended" : "normal"); - status.put("timestamp", DateUtil.toISOString(pump.getLastConnection())); - extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); - if (pump.getLastBolusTime() != 0) { - extended.put("LastBolus", DateUtil.dateAndTimeString(pump.getLastBolusTime())); - extended.put("LastBolusAmount", pump.getLastBolusAmount()); - } - TemporaryBasal tb = treatmentsPlugin.getTempBasalFromHistory(now); - if (tb != null) { - extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)); - extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); - extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); - } - ExtendedBolus eb = treatmentsPlugin.getExtendedBolusFromHistory(now); - if (eb != null) { - extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); - extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); - extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes()); - } - extended.put("BaseBasalRate", getBaseBasalRate()); - try { - extended.put("ActiveProfile", profileFunction.getProfileName()); - } catch (Exception e) { - getAapsLogger().error("Unhandled exception", e); - } - - pumpjson.put("battery", battery); - pumpjson.put("status", status); - pumpjson.put("extended", extended); - pumpjson.put("reservoir", (int) pump.getReservoirRemainingUnits()); - pumpjson.put("clock", DateUtil.toISOString(now)); - } catch (JSONException e) { - getAapsLogger().error("Unhandled exception", e); - } - return pumpjson; - } - - @NonNull @Override - public ManufacturerType manufacturer() { - return ManufacturerType.Sooil; - } - - @NonNull @Override - public PumpType model() { - return PumpType.DanaRS; - } - - @NonNull @Override - public String serialNumber() { - return danaRPump.getSerialNumber(); - } - - @NonNull @Override - public PumpDescription getPumpDescription() { - return pumpDescription; - } - - @NonNull @Override - public String shortStatus(boolean veryShort) { - DanaRPump pump = danaRPump; - String ret = ""; - if (pump.getLastConnection() != 0) { - long agoMsec = System.currentTimeMillis() - pump.getLastConnection(); - int agoMin = (int) (agoMsec / 60d / 1000d); - ret += "LastConn: " + agoMin + " minago\n"; - } - if (pump.getLastBolusTime() != 0) { - ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.getLastBolusAmount()) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.getLastBolusTime()) + "\n"; - } - TemporaryBasal activeTemp = treatmentsPlugin.getRealTempBasalFromHistory(System.currentTimeMillis()); - if (activeTemp != null) { - ret += "Temp: " + activeTemp.toStringFull() + "\n"; - } - ExtendedBolus activeExtendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()); - if (activeExtendedBolus != null) { - ret += "Extended: " + activeExtendedBolus.toString() + "\n"; - } - if (!veryShort) { - ret += "TDD: " + DecimalFormatter.to0Decimal(pump.getDailyTotalUnits()) + " / " + pump.getMaxDailyTotalUnits() + " U\n"; - } - ret += "Reserv: " + DecimalFormatter.to0Decimal(pump.getReservoirRemainingUnits()) + "U\n"; - ret += "Batt: " + pump.getBatteryRemaining() + "\n"; - return ret; - } - - @Override - public boolean isFakingTempsByExtendedBoluses() { - return false; - } - - @NonNull @Override - public PumpEnactResult loadTDDs() { - return loadHistory(RecordTypes.RECORD_TYPE_DAILY); - } - - @Override - public List getCustomActions() { - return null; - } - - @Override - public void executeCustomAction(CustomActionType customActionType) { - - } - - @Override - public boolean canHandleDST() { - return false; - } - - @Override - public void timeDateOrTimeZoneChanged() { - - } - -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt new file mode 100644 index 0000000000..fdfb55ca5a --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt @@ -0,0 +1,658 @@ +package info.nightscout.androidaps.plugins.pump.danaRS + +import android.content.ComponentName +import android.content.Context +import android.content.Intent +import android.content.ServiceConnection +import android.os.IBinder +import android.text.format.DateFormat +import androidx.preference.Preference +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.BuildConfig +import info.nightscout.androidaps.R +import info.nightscout.androidaps.data.DetailedBolusInfo +import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.data.PumpEnactResult +import info.nightscout.androidaps.events.EventAppExit +import info.nightscout.androidaps.events.EventConfigBuilderChange +import info.nightscout.androidaps.interfaces.* +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.common.ManufacturerType +import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker +import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction +import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType +import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification +import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification +import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage +import info.nightscout.androidaps.plugins.pump.common.defs.PumpType +import info.nightscout.androidaps.plugins.pump.danaR.DanaRFragment +import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes +import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSDeviceChange +import info.nightscout.androidaps.plugins.pump.danaRS.services.DanaRSService +import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin +import info.nightscout.androidaps.utils.* +import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.androidaps.utils.sharedPreferences.SP +import io.reactivex.disposables.CompositeDisposable +import io.reactivex.schedulers.Schedulers +import org.json.JSONException +import org.json.JSONObject +import javax.inject.Inject +import javax.inject.Singleton +import kotlin.math.abs +import kotlin.math.max + +@Singleton +class DanaRSPlugin @Inject constructor( + injector: HasAndroidInjector, + aapsLogger: AAPSLogger, + private val rxBus: RxBusWrapper, + private val context: Context, + resourceHelper: ResourceHelper, + private val constraintChecker: ConstraintChecker, + private val profileFunction: ProfileFunction, + private val treatmentsPlugin: TreatmentsPlugin, + private val sp: SP, + commandQueue: CommandQueueProvider, + private val danaRPump: DanaRPump, + private val detailedBolusInfoStorage: DetailedBolusInfoStorage, + private val fabricPrivacy: FabricPrivacy +) : PumpPluginBase(PluginDescription() + .mainType(PluginType.PUMP) + .fragmentClass(DanaRFragment::class.java.name) + .pluginName(R.string.danarspump) + .shortName(R.string.danarspump_shortname) + .preferencesId(R.xml.pref_danars) + .description(R.string.description_pump_dana_rs), + injector, aapsLogger, resourceHelper, commandQueue +), PumpInterface, DanaRInterface, ConstraintsInterface { + + private val disposable = CompositeDisposable() + private var danaRSService: DanaRSService? = null + private var mDeviceAddress = "" + var mDeviceName = "" + private var pumpDesc = PumpDescription(PumpType.DanaRS) + + override fun updatePreferenceSummary(pref: Preference) { + super.updatePreferenceSummary(pref) + if (pref.key == resourceHelper.gs(R.string.key_danars_name)) pref.summary = sp.getString(R.string.key_danars_name, "") + } + + override fun onStart() { + super.onStart() + val intent = Intent(context, DanaRSService::class.java) + context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE) + disposable.add(rxBus + .toObservable(EventAppExit::class.java) + .observeOn(Schedulers.io()) + .subscribe({ context.unbindService(mConnection) }) { fabricPrivacy.logException(it) } + ) + disposable.add(rxBus + .toObservable(EventConfigBuilderChange::class.java) + .observeOn(Schedulers.io()) + .subscribe { danaRPump.reset() } + ) + disposable.add(rxBus + .toObservable(EventDanaRSDeviceChange::class.java) + .observeOn(Schedulers.io()) + .subscribe({ changePump() }) { fabricPrivacy.logException(it) } + ) + changePump() // load device name + } + + override fun onStop() { + context.unbindService(mConnection) + disposable.clear() + super.onStop() + } + + private val mConnection: ServiceConnection = object : ServiceConnection { + override fun onServiceDisconnected(name: ComponentName) { + aapsLogger.debug(LTag.PUMP, "Service is disconnected") + danaRSService = null + } + + override fun onServiceConnected(name: ComponentName, service: IBinder) { + aapsLogger.debug(LTag.PUMP, "Service is connected") + val mLocalBinder = service as DanaRSService.LocalBinder + danaRSService = mLocalBinder.serviceInstance + } + } + + fun changePump() { + mDeviceAddress = sp.getString(R.string.key_danars_address, "") + mDeviceName = sp.getString(R.string.key_danars_name, "") + danaRPump.reset() + commandQueue.readStatus("DeviceChanged", null) + } + + override fun connect(from: String) { + aapsLogger.debug(LTag.PUMP, "RS connect from: $from") + if (danaRSService != null && mDeviceAddress != "" && mDeviceName != "") { + val success = danaRSService?.connect(from, mDeviceAddress) ?: false + if (!success) ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.rileylink_scanner_ble_not_supported)) + } + } + + override fun isConnected(): Boolean { + return danaRSService?.isConnected ?: false + } + + override fun isConnecting(): Boolean { + return danaRSService?.isConnecting ?: false + } + + override fun isHandshakeInProgress(): Boolean { + return false + } + + override fun finishHandshaking() {} + override fun disconnect(from: String) { + aapsLogger.debug(LTag.PUMP, "RS disconnect from: $from") + danaRSService?.disconnect(from) + } + + override fun stopConnecting() { + danaRSService?.stopConnecting() + } + + override fun getPumpStatus() { + danaRSService?.readPumpStatus() + pumpDesc.basalStep = danaRPump.basalStep + pumpDesc.bolusStep = danaRPump.bolusStep + } + + // DanaR interface + override fun loadHistory(type: Byte): PumpEnactResult { + return danaRSService?.loadHistory(type) ?: PumpEnactResult(injector).success(false) + } + + override fun loadEvents(): PumpEnactResult { + return danaRSService?.loadEvents() ?: PumpEnactResult(injector).success(false) + } + + override fun setUserOptions(): PumpEnactResult { + return danaRSService?.setUserSettings() ?: PumpEnactResult(injector).success(false) + } + + // Constraints interface + override fun applyBasalConstraints(absoluteRate: Constraint, profile: Profile): Constraint { + absoluteRate.setIfSmaller(aapsLogger, danaRPump.maxBasal, resourceHelper.gs(R.string.limitingbasalratio, danaRPump.maxBasal, resourceHelper.gs(R.string.pumplimit)), this) + return absoluteRate + } + + override fun applyBasalPercentConstraints(percentRate: Constraint, profile: Profile): Constraint { + percentRate.setIfGreater(aapsLogger, 0, resourceHelper.gs(R.string.limitingpercentrate, 0, resourceHelper.gs(R.string.itmustbepositivevalue)), this) + percentRate.setIfSmaller(aapsLogger, pumpDescription.maxTempPercent, resourceHelper.gs(R.string.limitingpercentrate, pumpDescription.maxTempPercent, resourceHelper.gs(R.string.pumplimit)), this) + return percentRate + } + + override fun applyBolusConstraints(insulin: Constraint): Constraint { + insulin.setIfSmaller(aapsLogger, danaRPump.maxBolus, resourceHelper.gs(R.string.limitingbolus, danaRPump.maxBolus, resourceHelper.gs(R.string.pumplimit)), this) + return insulin + } + + override fun applyExtendedBolusConstraints(insulin: Constraint): Constraint { + return applyBolusConstraints(insulin) + } + + // Pump interface + override fun isInitialized(): Boolean { + return danaRPump.lastConnection > 0 && danaRPump.maxBasal > 0 + } + + override fun isSuspended(): Boolean { + return danaRPump.pumpSuspended + } + + override fun isBusy(): Boolean { + return danaRSService?.isConnected ?: false || danaRSService?.isConnecting ?: false + } + + override fun setNewBasalProfile(profile: Profile): PumpEnactResult { + val result = PumpEnactResult(injector) + if (!isInitialized) { + aapsLogger.error("setNewBasalProfile not initialized") + val notification = Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, resourceHelper.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT) + rxBus.send(EventNewNotification(notification)) + result.comment = resourceHelper.gs(R.string.pumpNotInitializedProfileNotSet) + return result + } else { + rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)) + } + return if (danaRSService?.updateBasalsInPump(profile) != true) { + val notification = Notification(Notification.FAILED_UDPATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT) + rxBus.send(EventNewNotification(notification)) + result.comment = resourceHelper.gs(R.string.failedupdatebasalprofile) + result + } else { + rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)) + rxBus.send(EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)) + val notification = Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60) + rxBus.send(EventNewNotification(notification)) + result.success = true + result.enacted = true + result.comment = "OK" + result + } + } + + override fun isThisProfileSet(profile: Profile): Boolean { + if (!isInitialized) return true // TODO: not sure what's better. so far TRUE to prevent too many SMS + if (danaRPump.pumpProfiles == null) return true // TODO: not sure what's better. so far TRUE to prevent too many SMS + val basalValues = if (danaRPump.basal48Enable) 48 else 24 + val basalIncrement = if (danaRPump.basal48Enable) 30 * 60 else 60 * 60 + for (h in 0 until basalValues) { + val pumpValue = danaRPump.pumpProfiles!![danaRPump.activeProfile][h] + val profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement) + if (abs(pumpValue - profileValue) > pumpDescription.basalStep) { + aapsLogger.debug(LTag.PUMP, "Diff found. Hour: $h Pump: $pumpValue Profile: $profileValue") + return false + } + } + return true + } + + override fun lastDataTime(): Long { + return danaRPump.lastConnection + } + + override fun getBaseBasalRate(): Double { + return danaRPump.currentBasal + } + + override fun getReservoirLevel(): Double { + return danaRPump.reservoirRemainingUnits + } + + override fun getBatteryLevel(): Int { + return danaRPump.batteryRemaining + } + + @Synchronized + override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult { + detailedBolusInfo.insulin = constraintChecker.applyBolusConstraints(Constraint(detailedBolusInfo.insulin)).value() + return if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { + val preferencesSpeed = sp.getInt(R.string.key_danars_bolusspeed, 0) + var speed = 12 + when (preferencesSpeed) { + 0 -> speed = 12 + 1 -> speed = 30 + 2 -> speed = 60 + } + // RS stores end time for bolus, we need to adjust time + // default delivery speed is 12 sec/U + detailedBolusInfo.date = DateUtil.now() + (speed * detailedBolusInfo.insulin * 1000).toLong() + // clean carbs to prevent counting them as twice because they will picked up as another record + // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records + val carbs = detailedBolusInfo.carbs + detailedBolusInfo.carbs = 0.0 + var carbTime = detailedBolusInfo.carbTime + if (carbTime == 0) carbTime-- // better set 1 min back to prevents clash with insulin + detailedBolusInfo.carbTime = 0 + detailedBolusInfoStorage.add(detailedBolusInfo) // will be picked up on reading history + val t = Treatment() + t.isSMB = detailedBolusInfo.isSMB + var connectionOK = false + if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = danaRSService?.bolus(detailedBolusInfo.insulin, carbs.toInt(), DateUtil.now() + T.mins(carbTime.toLong()).msecs(), t) ?: false + val result = PumpEnactResult(injector) + result.success = connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDesc.bolusStep + result.bolusDelivered = t.insulin + result.carbsDelivered = detailedBolusInfo.carbs + if (!result.success) { + var error = "" + danaRPump.bolusStartErrorCode + when (danaRPump.bolusStartErrorCode) { + 0x10 -> error = resourceHelper.gs(R.string.maxbolusviolation) + 0x20 -> error = resourceHelper.gs(R.string.commanderror) + 0x40 -> error = resourceHelper.gs(R.string.speederror) + 0x80 -> error = resourceHelper.gs(R.string.insulinlimitviolation) + } + result.comment = String.format(resourceHelper.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, error) + } else result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered) + result + } else { + val result = PumpEnactResult(injector) + result.success = false + result.bolusDelivered = 0.0 + result.carbsDelivered = 0.0 + result.comment = resourceHelper.gs(R.string.danar_invalidinput) + aapsLogger.error("deliverTreatment: Invalid input") + result + } + } + + override fun stopBolusDelivering() { + danaRSService?.bolusStop() + } + + // This is called from APS + @Synchronized + override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult { + var result = PumpEnactResult(injector) + val absoluteAfterConstrain = constraintChecker.applyBasalConstraints(Constraint(absoluteRate), profile).value() + val doTempOff = baseBasalRate - absoluteAfterConstrain == 0.0 + val doLowTemp = absoluteAfterConstrain < baseBasalRate + val doHighTemp = absoluteAfterConstrain > baseBasalRate + if (doTempOff) { + // If temp in progress + if (treatmentsPlugin.isTempBasalInProgress) { + aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Stopping temp basal (doTempOff)") + return cancelTempBasal(false) + } + result.success = true + result.enacted = false + result.percent = 100 + result.isPercent = true + result.isTempCancel = true + aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK") + return result + } + if (doLowTemp || doHighTemp) { + var percentRate = java.lang.Double.valueOf(absoluteAfterConstrain / baseBasalRate * 100).toInt() + percentRate = if (percentRate < 100) Round.ceilTo(percentRate.toDouble(), 10.0).toInt() else Round.floorTo(percentRate.toDouble(), 10.0).toInt() + if (percentRate > 500) // Special high temp 500/15min + percentRate = 500 + // Check if some temp is already in progress + val activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis()) + if (activeTemp != null) { + aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: currently running: $activeTemp") + // Correct basal already set ? + if (activeTemp.percentRate == percentRate && activeTemp.plannedRemainingMinutes > 4) { + if (!enforceNew) { + result.success = true + result.percent = percentRate + result.enacted = false + result.duration = activeTemp.plannedRemainingMinutes + result.isPercent = true + result.isTempCancel = false + aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)") + return result + } + } + } + // Convert duration from minutes to hours + aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal $percentRate% for $durationInMinutes mins (doLowTemp || doHighTemp)") + result = if (percentRate == 0 && durationInMinutes > 30) { + setTempBasalPercent(percentRate, durationInMinutes, profile, enforceNew) + } else { + // use special APS temp basal call ... 100+/15min .... 100-/30min + setHighTempBasalPercent(percentRate) + } + if (!result.success) { + aapsLogger.error("setTempBasalAbsolute: Failed to set hightemp basal") + return result + } + aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: hightemp basal set ok") + return result + } + // We should never end here + aapsLogger.error("setTempBasalAbsolute: Internal error") + result.success = false + result.comment = "Internal error" + return result + } + + @Synchronized + override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult { + val pump = danaRPump + val result = PumpEnactResult(injector) + var percentAfterConstraint = constraintChecker.applyBasalPercentConstraints(Constraint(percent), profile).value() + if (percentAfterConstraint < 0) { + result.isTempCancel = false + result.enacted = false + result.success = false + result.comment = resourceHelper.gs(R.string.danar_invalidinput) + aapsLogger.error("setTempBasalPercent: Invalid input") + return result + } + if (percentAfterConstraint > pumpDescription.maxTempPercent) percentAfterConstraint = pumpDescription.maxTempPercent + val now = System.currentTimeMillis() + val activeTemp = treatmentsPlugin.getTempBasalFromHistory(now) + if (activeTemp != null && activeTemp.percentRate == percentAfterConstraint && activeTemp.plannedRemainingMinutes > 4 && !enforceNew) { + result.enacted = false + result.success = true + result.isTempCancel = false + result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.duration = pump.tempBasalRemainingMin + result.percent = pump.tempBasalPercent + result.isPercent = true + aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: Correct value already set") + return result + } + val connectionOK: Boolean + connectionOK = if (durationInMinutes == 15 || durationInMinutes == 30) { + danaRSService?.tempBasalShortDuration(percentAfterConstraint, durationInMinutes) ?: false + } else { + val durationInHours = max(durationInMinutes / 60, 1) + danaRSService?.tempBasal(percentAfterConstraint, durationInHours) ?: false + } + if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percentAfterConstraint) { + result.enacted = true + result.success = true + result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.isTempCancel = false + result.duration = pump.tempBasalRemainingMin + result.percent = pump.tempBasalPercent + result.isPercent = true + aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: OK") + return result + } + result.enacted = false + result.success = false + result.comment = resourceHelper.gs(R.string.tempbasaldeliveryerror) + aapsLogger.error("setTempBasalPercent: Failed to set temp basal") + return result + } + + @Synchronized private fun setHighTempBasalPercent(percent: Int): PumpEnactResult { + val pump = danaRPump + val result = PumpEnactResult(injector) + val connectionOK = danaRSService?.highTempBasal(percent) ?: false + if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) { + result.enacted = true + result.success = true + result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.isTempCancel = false + result.duration = pump.tempBasalRemainingMin + result.percent = pump.tempBasalPercent + result.isPercent = true + aapsLogger.debug(LTag.PUMP, "setHighTempBasalPercent: OK") + return result + } + result.enacted = false + result.success = false + result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly) + aapsLogger.error("setHighTempBasalPercent: Failed to set temp basal") + return result + } + + @Synchronized + override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult { + val pump = danaRPump + var insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value() + // needs to be rounded + val durationInHalfHours = max(durationInMinutes / 30, 1) + insulinAfterConstraint = Round.roundTo(insulinAfterConstraint, pumpDescription.extendedBolusStep) + val result = PumpEnactResult(injector) + val runningEB = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) + if (runningEB != null && abs(runningEB.insulin - insulinAfterConstraint) < pumpDescription.extendedBolusStep) { + result.enacted = false + result.success = true + result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.duration = pump.extendedBolusRemainingMinutes + result.absolute = pump.extendedBolusAbsoluteRate + result.isPercent = false + result.isTempCancel = false + aapsLogger.debug(LTag.PUMP, "setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulinAfterConstraint) + return result + } + val connectionOK = danaRSService?.extendedBolus(insulinAfterConstraint, durationInHalfHours) ?: false + if (connectionOK && pump.isExtendedInProgress && abs(pump.extendedBolusAbsoluteRate - insulinAfterConstraint) < pumpDescription.extendedBolusStep) { + result.enacted = true + result.success = true + result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.isTempCancel = false + result.duration = pump.extendedBolusRemainingMinutes + result.absolute = pump.extendedBolusAbsoluteRate + result.bolusDelivered = pump.extendedBolusAmount + result.isPercent = false + aapsLogger.debug(LTag.PUMP, "setExtendedBolus: OK") + return result + } + result.enacted = false + result.success = false + result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly) + aapsLogger.error("setExtendedBolus: Failed to extended bolus") + return result + } + + @Synchronized + override fun cancelTempBasal(force: Boolean): PumpEnactResult { + val result = PumpEnactResult(injector) + val runningTB = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis()) + if (runningTB != null) { + danaRSService?.tempBasalStop() + result.enacted = true + result.isTempCancel = true + } + return if (!danaRPump.isTempBasalInProgress) { + result.success = true + result.isTempCancel = true + result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + aapsLogger.debug(LTag.PUMP, "cancelRealTempBasal: OK") + result + } else { + result.success = false + result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly) + result.isTempCancel = true + aapsLogger.error("cancelRealTempBasal: Failed to cancel temp basal") + result + } + } + + @Synchronized override fun cancelExtendedBolus(): PumpEnactResult { + val result = PumpEnactResult(injector) + val runningEB = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) + if (runningEB != null) { + danaRSService?.extendedBolusStop() + result.enacted = true + result.isTempCancel = true + } + return if (!danaRPump.isExtendedInProgress) { + result.success = true + result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + aapsLogger.debug(LTag.PUMP, "cancelExtendedBolus: OK") + result + } else { + result.success = false + result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly) + aapsLogger.error("cancelExtendedBolus: Failed to cancel extended bolus") + result + } + } + + override fun getJSONStatus(profile: Profile, profileName: String): JSONObject { + val pump = danaRPump + val now = System.currentTimeMillis() + if (pump.lastConnection + 5 * 60 * 1000L < System.currentTimeMillis()) { + return JSONObject() + } + val pumpJson = JSONObject() + val battery = JSONObject() + val status = JSONObject() + val extended = JSONObject() + try { + battery.put("percent", pump.batteryRemaining) + status.put("status", if (pump.pumpSuspended) "suspended" else "normal") + status.put("timestamp", DateUtil.toISOString(pump.lastConnection)) + extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION) + if (pump.lastBolusTime != 0L) { + extended.put("LastBolus", DateUtil.dateAndTimeString(pump.lastBolusTime)) + extended.put("LastBolusAmount", pump.lastBolusAmount) + } + val tb = treatmentsPlugin.getTempBasalFromHistory(now) + if (tb != null) { + extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)) + extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)) + extended.put("TempBasalRemaining", tb.plannedRemainingMinutes) + } + val eb = treatmentsPlugin.getExtendedBolusFromHistory(now) + if (eb != null) { + extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()) + extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)) + extended.put("ExtendedBolusRemaining", eb.plannedRemainingMinutes) + } + extended.put("BaseBasalRate", baseBasalRate) + try { + extended.put("ActiveProfile", profileFunction.getProfileName()) + } catch (e: Exception) { + aapsLogger.error("Unhandled exception", e) + } + pumpJson.put("battery", battery) + pumpJson.put("status", status) + pumpJson.put("extended", extended) + pumpJson.put("reservoir", pump.reservoirRemainingUnits.toInt()) + pumpJson.put("clock", DateUtil.toISOString(now)) + } catch (e: JSONException) { + aapsLogger.error("Unhandled exception", e) + } + return pumpJson + } + + override fun manufacturer(): ManufacturerType { + return ManufacturerType.Sooil + } + + override fun model(): PumpType { + return PumpType.DanaRS + } + + override fun serialNumber(): String { + return danaRPump.serialNumber + } + + override fun getPumpDescription(): PumpDescription { + return pumpDesc + } + + override fun shortStatus(veryShort: Boolean): String { + val pump = danaRPump + var ret = "" + if (pump.lastConnection != 0L) { + val agoMillis = System.currentTimeMillis() - pump.lastConnection + val agoMin = (agoMillis / 60.0 / 1000.0).toInt() + ret += "LastConn: $agoMin minago\n" + } + if (pump.lastBolusTime != 0L) + ret += "LastBolus: ${DecimalFormatter.to2Decimal(pump.lastBolusAmount)}U @${DateFormat.format("HH:mm", pump.lastBolusTime)}" + + val activeTemp = treatmentsPlugin.getRealTempBasalFromHistory(System.currentTimeMillis()) + if (activeTemp != null) + ret += "Temp: ${activeTemp.toStringFull()}" + + val activeExtendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) + if (activeExtendedBolus != null) + ret += "Extended: $activeExtendedBolus\n" + + if (!veryShort) { + ret += "TDD: ${DecimalFormatter.to0Decimal(pump.dailyTotalUnits)} / ${pump.maxDailyTotalUnits} U" + } + ret += "Reserv: ${DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits)} U" + ret += "Batt: ${pump.batteryRemaining}" + return ret + } + + override fun isFakingTempsByExtendedBoluses(): Boolean = false + override fun loadTDDs(): PumpEnactResult = loadHistory(RecordTypes.RECORD_TYPE_DAILY) + override fun getCustomActions(): List? = null + override fun executeCustomAction(customActionType: CustomActionType) {} + override fun canHandleDST(): Boolean = false + override fun timeDateOrTimeZoneChanged() {} +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt index 2f3b8b170a..4f3d86c51d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt @@ -18,7 +18,6 @@ class DanaRSMessageHashTable @Inject constructor( rxBus: RxBusWrapper, resourceHelper: ResourceHelper, danaRPump: DanaRPump, - danaRSPlugin: DanaRSPlugin, activePlugin: ActivePluginProvider, constraintChecker: ConstraintChecker, detailedBolusInfoStorage: DetailedBolusInfoStorage @@ -62,16 +61,16 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_Bolus_Set_Dual_Bolus(aapsLogger)) put(DanaRS_Packet_Bolus_Set_Extended_Bolus(aapsLogger)) put(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRSPlugin, constraintChecker)) - put(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRSPlugin)) + put(DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRPump, constraintChecker)) + put(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRPump)) put(DanaRS_Packet_Etc_Keep_Connection(aapsLogger)) put(DanaRS_Packet_Etc_Set_History_Save(aapsLogger)) put(DanaRS_Packet_General_Delivery_Status(aapsLogger)) put(DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump)) put(DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)) put(DanaRS_Packet_Notify_Alarm(aapsLogger, resourceHelper, rxBus)) - put(DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRSPlugin)) - put(DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRSPlugin)) + put(DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRPump)) + put(DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRPump)) put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(aapsLogger)) put(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) put(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) @@ -99,7 +98,7 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus)) // APS put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0)) - put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, 0)) + put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, 0)) put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, 0, 0, 0, 0)) // v3 put(DanaRS_Packet_General_Get_Shipping_Version(aapsLogger, danaRPump)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt index 27b88c1380..97700ba30e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt @@ -1,6 +1,5 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.db.ExtendedBolus @@ -13,7 +12,7 @@ import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* @@ -23,7 +22,7 @@ open class DanaRS_Packet_APS_History_Events( private val rxBus: RxBusWrapper, private val resourceHelper: ResourceHelper, private val activePlugin: ActivePluginProvider, - private val danaRSPlugin: DanaRSPlugin, + private val danaRPump: DanaRPump, private val detailedBolusInfoStorage: DetailedBolusInfoStorage, private var from: Long ) : DanaRS_Packet() { @@ -50,7 +49,7 @@ open class DanaRS_Packet_APS_History_Events( min = cal[Calendar.MINUTE] sec = cal[Calendar.SECOND] aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(cal.timeInMillis)) - danaRSPlugin.apsHistoryDone = false + danaRPump.historyDoneReceived = false } override fun getRequestParams(): ByteArray { @@ -68,7 +67,7 @@ open class DanaRS_Packet_APS_History_Events( val recordCode = intFromBuff(data, 0, 1).toByte() // Last record if (recordCode == 0xFF.toByte()) { - danaRSPlugin.apsHistoryDone = true + danaRPump.historyDoneReceived = true aapsLogger.debug(LTag.PUMPCOMM, "Last record received") return } @@ -191,7 +190,7 @@ open class DanaRS_Packet_APS_History_Events( status = "UNKNOWN " + DateUtil.timeString(datetime) } } - if (datetime > danaRSPlugin.lastEventTimeLoaded) danaRSPlugin.lastEventTimeLoaded = datetime + if (datetime > danaRPump.lastEventTimeLoaded) danaRPump.lastEventTimeLoaded = datetime rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.processinghistory) + ": " + status)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt index ef14999e22..d9dc8f0d95 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt @@ -1,15 +1,15 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Step_Bolus_Start( private val aapsLogger: AAPSLogger, - private val danaRSPlugin: DanaRSPlugin, + private val danaRPump: DanaRPump, constraintChecker: ConstraintChecker, private var amount: Double = 0.0, private var speed: Int = 0 @@ -34,12 +34,12 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_Start( } override fun handleMessage(data: ByteArray) { - danaRSPlugin.bolusStartErrorCode = intFromBuff(data, 0, 1) - if (danaRSPlugin.bolusStartErrorCode == 0) { + danaRPump.bolusStartErrorCode = intFromBuff(data, 0, 1) + if (danaRPump.bolusStartErrorCode == 0) { failed = false aapsLogger.debug(LTag.PUMPCOMM, "Result OK") } else { - aapsLogger.error("Result Error: ${danaRSPlugin.bolusStartErrorCode}") + aapsLogger.error("Result Error: ${danaRPump.bolusStartErrorCode}") failed = true } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt index 462d639a0c..c5c1ace3b4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt @@ -1,19 +1,19 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper open class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop( private val aapsLogger: AAPSLogger, private val rxBus: RxBusWrapper, private val resourceHelper: ResourceHelper, - private val danaRSPlugin: DanaRSPlugin + private val danaRPump: DanaRPump ) : DanaRS_Packet() { @@ -31,10 +31,10 @@ open class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop( failed = true } val bolusingEvent = EventOverviewBolusProgress - danaRSPlugin.bolusStopped = true - if (!danaRSPlugin.bolusStopForced) { + danaRPump.bolusStopped = true + if (!danaRPump.bolusStopForced) { // delivery ended without user intervention - danaRSPlugin.bolusingTreatment.insulin = danaRSPlugin.bolusAmountToBeDelivered + danaRPump.bolusingTreatment?.insulin = danaRPump.bolusAmountToBeDelivered bolusingEvent.status = resourceHelper.gs(R.string.overview_bolusprogress_delivered) bolusingEvent.percent = 100 } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt index 03d884933b..c4e5d5a06d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper import kotlin.math.min @@ -14,7 +14,7 @@ class DanaRS_Packet_Notify_Delivery_Complete( private val aapsLogger: AAPSLogger, private val rxBus: RxBusWrapper, private val resourceHelper: ResourceHelper, - private val danaRSPlugin: DanaRSPlugin + private val danaRPump: DanaRPump ) : DanaRS_Packet() { init { @@ -25,12 +25,12 @@ class DanaRS_Packet_Notify_Delivery_Complete( override fun handleMessage(data: ByteArray) { val deliveredInsulin = byteArrayToInt(getBytes(data, DATA_START, 2)) / 100.0 - danaRSPlugin.bolusingTreatment.insulin = deliveredInsulin + danaRPump.bolusingTreatment?.insulin = deliveredInsulin val bolusingEvent = EventOverviewBolusProgress bolusingEvent.status = resourceHelper.gs(R.string.bolusdelivering, deliveredInsulin) - bolusingEvent.t = danaRSPlugin.bolusingTreatment - bolusingEvent.percent = min((deliveredInsulin / danaRSPlugin.bolusAmountToBeDelivered * 100).toInt(), 100) - danaRSPlugin.bolusDone = true + bolusingEvent.t = danaRPump.bolusingTreatment + bolusingEvent.percent = min((deliveredInsulin / danaRPump.bolusAmountToBeDelivered * 100).toInt(), 100) + danaRPump.bolusDone = true rxBus.send(bolusingEvent) aapsLogger.debug(LTag.PUMPCOMM, "Delivered insulin: $deliveredInsulin") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt index a63bad6f23..0a256ed088 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper import kotlin.math.min @@ -14,7 +14,7 @@ class DanaRS_Packet_Notify_Delivery_Rate_Display( private val aapsLogger: AAPSLogger, private val rxBus: RxBusWrapper, private val resourceHelper: ResourceHelper, - private val danaRSPlugin: DanaRSPlugin + private val danaRPump: DanaRPump ) : DanaRS_Packet() { @@ -25,12 +25,12 @@ class DanaRS_Packet_Notify_Delivery_Rate_Display( override fun handleMessage(data: ByteArray) { val deliveredInsulin = byteArrayToInt(getBytes(data, DATA_START, 2)) / 100.0 - danaRSPlugin.bolusProgressLastTimeStamp = System.currentTimeMillis() - danaRSPlugin.bolusingTreatment.insulin = deliveredInsulin + danaRPump.bolusProgressLastTimeStamp = System.currentTimeMillis() + danaRPump.bolusingTreatment?.insulin = deliveredInsulin val bolusingEvent = EventOverviewBolusProgress bolusingEvent.status = resourceHelper.gs(R.string.bolusdelivering, deliveredInsulin) - bolusingEvent.t = danaRSPlugin.bolusingTreatment - bolusingEvent.percent = min((deliveredInsulin / danaRSPlugin.bolusAmountToBeDelivered * 100).toInt(), 100) + bolusingEvent.t = danaRPump.bolusingTreatment + bolusingEvent.percent = min((deliveredInsulin / danaRPump.bolusAmountToBeDelivered * 100).toInt(), 100) failed = bolusingEvent.percent < 100 rxBus.send(bolusingEvent) aapsLogger.debug(LTag.PUMPCOMM, "Delivered insulin so far: $deliveredInsulin") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt index 9145cb6559..e691156d0d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -615,9 +615,8 @@ class BLEComm @Inject internal constructor( } // the rest of packets - fun sendMessage(message: DanaRS_Packet?) { + fun sendMessage(message: DanaRS_Packet) { processedMessage = message - if (message == null) return val command = byteArrayOf(message.type.toByte(), message.opCode.toByte()) val params = message.requestParams aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + message.friendlyName + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java deleted file mode 100644 index 4affd0d7c1..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java +++ /dev/null @@ -1,565 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.danaRS.services; - -import android.content.Context; -import android.content.Intent; -import android.os.Binder; -import android.os.IBinder; -import android.os.SystemClock; - -import javax.inject.Inject; - -import dagger.android.DaggerService; -import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.activities.ErrorHelperActivity; -import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.data.PumpEnactResult; -import info.nightscout.androidaps.dialogs.BolusProgressDialog; -import info.nightscout.androidaps.events.EventAppExit; -import info.nightscout.androidaps.events.EventInitializationChanged; -import info.nightscout.androidaps.events.EventProfileNeedsUpdate; -import info.nightscout.androidaps.events.EventPumpStatusChanged; -import info.nightscout.androidaps.interfaces.ActivePluginProvider; -import info.nightscout.androidaps.interfaces.CommandQueueProvider; -import info.nightscout.androidaps.interfaces.PumpInterface; -import info.nightscout.androidaps.logging.AAPSLogger; -import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; -import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; -import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; -import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress; -import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; -import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage; -import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump; -import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes; -import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRNewStatus; -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSMessageHashTable; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_APS_Basal_Set_Temporary_Basal; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_APS_History_Events; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_APS_Set_Event_History; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Basal_Get_Basal_Rate; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Basal_Get_Profile_Number; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Basal_Get_Temporary_Basal_State; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Basal_Set_Profile_Basal_Rate; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Basal_Set_Profile_Number; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Basal_Set_Temporary_Basal; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Bolus_Get_Bolus_Option; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Bolus_Get_CIR_CF_Array; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Bolus_Get_Calculation_Information; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Bolus_Get_Extended_Bolus_State; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Bolus_Get_Step_Bolus_Information; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Bolus_Set_Extended_Bolus; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Bolus_Set_Step_Bolus_Start; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Bolus_Set_Step_Bolus_Stop; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_General_Get_Pump_Check; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_General_Get_Shipping_Information; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_General_Initial_Screen_Information; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_General_Set_History_Upload_Mode; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History_; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History_Alarm; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History_Basal; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History_Blood_Glucose; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History_Bolus; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History_Carbohydrate; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History_Daily; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History_Prime; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History_Refill; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History_Suspend; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Option_Get_Pump_Time; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Option_Get_User_Option; -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Option_Set_Pump_Time; -import info.nightscout.androidaps.plugins.treatments.Treatment; -import info.nightscout.androidaps.queue.Callback; -import info.nightscout.androidaps.queue.commands.Command; -import info.nightscout.androidaps.utils.DateUtil; -import info.nightscout.androidaps.utils.FabricPrivacy; -import info.nightscout.androidaps.utils.T; -import info.nightscout.androidaps.utils.resources.ResourceHelper; -import info.nightscout.androidaps.utils.sharedPreferences.SP; -import io.reactivex.disposables.CompositeDisposable; -import io.reactivex.schedulers.Schedulers; - -public class DanaRSService extends DaggerService { - @Inject HasAndroidInjector injector; - @Inject AAPSLogger aapsLogger; - @Inject RxBusWrapper rxBus; - @Inject SP sp; - @Inject ResourceHelper resourceHelper; - @Inject ProfileFunction profileFunction; - @Inject CommandQueueProvider commandQueue; - @Inject Context context; - @Inject DanaRSPlugin danaRSPlugin; - @Inject DanaRPump danaRPump; - @Inject DanaRSMessageHashTable danaRSMessageHashTable; - @Inject ActivePluginProvider activePlugin; - @Inject ConstraintChecker constraintChecker; - @Inject DetailedBolusInfoStorage detailedBolusInfoStorage; - @Inject BLEComm bleComm; - @Inject FabricPrivacy fabricPrivacy; - - private CompositeDisposable disposable = new CompositeDisposable(); - - - private IBinder mBinder = new LocalBinder(); - - private Treatment bolusingTreatment = null; - - private long lastHistoryFetched = 0; - private long lastApproachingDailyLimit = 0; - - @Override - public void onCreate() { - super.onCreate(); - disposable.add(rxBus - .toObservable(EventAppExit.class) - .observeOn(Schedulers.io()) - .subscribe(event -> { - aapsLogger.debug(LTag.PUMPCOMM, "EventAppExit received"); - stopSelf(); - }, fabricPrivacy::logException) - ); - } - - @Override - public void onDestroy() { - disposable.clear(); - super.onDestroy(); - } - - public boolean isConnected() { - return bleComm.isConnected(); - } - - public boolean isConnecting() { - return bleComm.isConnecting(); - } - - public boolean connect(String from, String address) { - return bleComm.connect(from, address); - } - - public void stopConnecting() { - bleComm.stopConnecting(); - } - - public void disconnect(String from) { - bleComm.disconnect(from); - } - - @SuppressWarnings("unused") - public void sendMessage(DanaRS_Packet message) { - bleComm.sendMessage(message); - } - - public void getPumpStatus() { - try { - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus))); - - bleComm.sendMessage(new DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)); - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingextendedbolusstatus))); - bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)); - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))); - bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)); // last bolus, bolusStep, maxBolus - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingtempbasalstatus))); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); - - danaRPump.setLastConnection(System.currentTimeMillis()); - - Profile profile = profileFunction.getProfile(); - PumpInterface pump = activePlugin.getActivePump(); - if (profile != null && Math.abs(danaRPump.getCurrentBasal() - profile.getBasal()) >= pump.getPumpDescription().basalStep) { - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump)); // basal profile, basalStep, maxBasal - if (!pump.isThisProfileSet(profile) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE)) { - rxBus.send(new EventProfileNeedsUpdate()); - } - } - - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))); - bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)); - - long timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; - if (danaRPump.getPumpTime() == 0) { - // initial handshake was not successfull - // deinitialize pump - danaRPump.reset(); - rxBus.send(new EventDanaRNewStatus()); - rxBus.send(new EventInitializationChanged()); - return; - } - long now = System.currentTimeMillis(); - if (danaRPump.getLastSettingsRead() + 60 * 60 * 1000L < now || !pump.isInitialized()) { - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))); - bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)); // serial no - bleComm.sendMessage(new DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)); // firmware - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump)); - bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)); // isExtendedEnabled - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump)); // basal profile, basalStep, maxBasal - bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump)); // target - bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_CIR_CF_Array(aapsLogger, danaRPump)); - bleComm.sendMessage(new DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)); // Getting user options - danaRPump.setLastSettingsRead(now); - } - - aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: " + timeDiff + " seconds"); - if (Math.abs(timeDiff) > 3) { - if (Math.abs(timeDiff) > 60 * 60 * 1.5) { - aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: " + timeDiff + " seconds - large difference"); - //If time-diff is very large, warn user until we can synchronize history readings properly - Intent i = new Intent(context, ErrorHelperActivity.class); - i.putExtra("soundid", R.raw.error); - i.putExtra("status", resourceHelper.gs(R.string.largetimediff)); - i.putExtra("title", resourceHelper.gs(R.string.largetimedifftitle)); - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(i); - - //deinitialize pump - danaRPump.reset(); - rxBus.send(new EventDanaRNewStatus()); - rxBus.send(new EventInitializationChanged()); - return; - } else { - if (danaRPump.getProtocol() >= 6) { - bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now())); - } else { - waitForWholeMinute(); // Dana can set only whole minute - // add 10sec to be sure we are over minute (will be cutted off anyway) - bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now() + T.secs(10).msecs())); - } - bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)); - timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; - aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: " + timeDiff + " seconds"); - } - } - - loadEvents(); - - rxBus.send(new EventDanaRNewStatus()); - rxBus.send(new EventInitializationChanged()); - //NSUpload.uploadDeviceStatus(); - if (danaRPump.getDailyTotalUnits() > danaRPump.getMaxDailyTotalUnits() * Constants.dailyLimitWarning) { - aapsLogger.debug(LTag.PUMPCOMM, "Approaching daily limit: " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits()); - if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { - Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, resourceHelper.gs(R.string.approachingdailylimit), Notification.URGENT); - rxBus.send(new EventNewNotification(reportFail)); - NSUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U"); - lastApproachingDailyLimit = System.currentTimeMillis(); - } - } - } catch (Exception e) { - aapsLogger.error(LTag.PUMPCOMM, "Unhandled exception", e); - } - aapsLogger.debug(LTag.PUMPCOMM, "Pump status loaded"); - } - - public PumpEnactResult loadEvents() { - - if (!danaRSPlugin.isInitialized()) { - PumpEnactResult result = new PumpEnactResult(injector).success(false); - result.comment = "pump not initialized"; - return result; - } - - SystemClock.sleep(1000); - - DanaRS_Packet_APS_History_Events msg; - if (lastHistoryFetched == 0) { - msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, 0); - aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history"); - } else { - msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, lastHistoryFetched); - aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)); - } - bleComm.sendMessage(msg); - while (!danaRSPlugin.apsHistoryDone && bleComm.isConnected()) { - SystemClock.sleep(100); - } - if (danaRSPlugin.lastEventTimeLoaded != 0) - lastHistoryFetched = danaRSPlugin.lastEventTimeLoaded - T.mins(1).msecs(); - else - lastHistoryFetched = 0; - aapsLogger.debug(LTag.PUMPCOMM, "Events loaded"); - danaRPump.setLastConnection(System.currentTimeMillis()); - return new PumpEnactResult(injector).success(true); - } - - - public PumpEnactResult setUserSettings() { - bleComm.sendMessage(new DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)); - return new PumpEnactResult(injector).success(true); - } - - - public boolean bolus(final double insulin, int carbs, long carbtime, Treatment t) { - if (!isConnected()) return false; - if (BolusProgressDialog.stopPressed) return false; - - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.startingbolus))); - bolusingTreatment = t; - final int preferencesSpeed = sp.getInt(R.string.key_danars_bolusspeed, 0); - danaRSPlugin.bolusingTreatment = t; - danaRSPlugin.bolusAmountToBeDelivered = insulin; - danaRSPlugin.bolusStopped = false; - danaRSPlugin.bolusStopForced = false; - danaRSPlugin.bolusProgressLastTimeStamp = DateUtil.now(); - - DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRSPlugin, constraintChecker, insulin, preferencesSpeed); - if (carbs > 0) { -// MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs); #### -// bleComm.sendMessage(msg); - DanaRS_Packet_APS_Set_Event_History msgSetHistoryEntry_v2 = new DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, carbtime, carbs, 0); - bleComm.sendMessage(msgSetHistoryEntry_v2); - lastHistoryFetched = Math.min(lastHistoryFetched, carbtime - T.mins(1).msecs()); - } - - final long bolusStart = System.currentTimeMillis(); - if (insulin > 0) { - if (!danaRSPlugin.bolusStopped) { - bleComm.sendMessage(start); - } else { - t.insulin = 0d; - return false; - } - - while (!danaRSPlugin.bolusStopped && !start.failed && !danaRSPlugin.bolusDone) { - SystemClock.sleep(100); - if ((System.currentTimeMillis() - danaRSPlugin.bolusProgressLastTimeStamp) > 15 * 1000L) { // if i didn't receive status for more than 20 sec expecting broken comm - danaRSPlugin.bolusStopped = true; - danaRSPlugin.bolusStopForced = true; - aapsLogger.debug(LTag.PUMPCOMM, "Communication stopped"); - } - } - } - - final EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE; - bolusingEvent.setT(t); - bolusingEvent.setPercent(99); - - bolusingTreatment = null; - int speed = 12; - switch (preferencesSpeed) { - case 0: - speed = 12; - break; - case 1: - speed = 30; - break; - case 2: - speed = 60; - break; - } - long bolusDurationInMSec = (long) (insulin * speed * 1000); - long expectedEnd = bolusStart + bolusDurationInMSec + 2000; - while (System.currentTimeMillis() < expectedEnd) { - long waitTime = expectedEnd - System.currentTimeMillis(); - bolusingEvent.setStatus(String.format(resourceHelper.gs(R.string.waitingforestimatedbolusend), waitTime / 1000)); - rxBus.send(bolusingEvent); - SystemClock.sleep(1000); - } - // do not call loadEvents() directly, reconnection may be needed - commandQueue.loadEvents(new Callback() { - @Override - public void run() { - // reread bolus status - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))); - bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)); // last bolus - bolusingEvent.setPercent(100); - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.disconnecting))); - } - }); - return !start.failed; - } - - public void bolusStop() { - aapsLogger.debug(LTag.PUMPCOMM, "bolusStop >>>>> @ " + (bolusingTreatment == null ? "" : bolusingTreatment.insulin)); - DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRSPlugin); - danaRSPlugin.bolusStopForced = true; - if (isConnected()) { - bleComm.sendMessage(stop); - while (!danaRSPlugin.bolusStopped) { - bleComm.sendMessage(stop); - SystemClock.sleep(200); - } - } else { - danaRSPlugin.bolusStopped = true; - } - } - - public boolean tempBasal(Integer percent, int durationInHours) { - if (!isConnected()) return false; - if (danaRPump.isTempBasalInProgress()) { - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))); - bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)); - SystemClock.sleep(500); - } - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); - bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger, percent, durationInHours)); - SystemClock.sleep(200); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); - loadEvents(); - rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); - return true; - } - - public boolean highTempBasal(Integer percent) { - if (danaRPump.isTempBasalInProgress()) { - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))); - bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)); - SystemClock.sleep(500); - } - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); - bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); - loadEvents(); - rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); - return true; - } - - public boolean tempBasalShortDuration(Integer percent, int durationInMinutes) { - if (durationInMinutes != 15 && durationInMinutes != 30) { - aapsLogger.error(LTag.PUMPCOMM, "Wrong duration param"); - return false; - } - - if (danaRPump.isTempBasalInProgress()) { - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))); - bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)); - SystemClock.sleep(500); - } - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); - bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); - loadEvents(); - rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); - return true; - } - - public boolean tempBasalStop() { - if (!isConnected()) return false; - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))); - bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); - loadEvents(); - rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); - return true; - } - - public boolean extendedBolus(Double insulin, int durationInHalfHours) { - if (!isConnected()) return false; - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus))); - bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus(aapsLogger, insulin, durationInHalfHours)); - SystemClock.sleep(200); - bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)); - loadEvents(); - rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); - return true; - } - - public boolean extendedBolusStop() { - if (!isConnected()) return false; - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus))); - bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger)); - bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)); - loadEvents(); - rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); - return true; - } - - public boolean updateBasalsInPump(Profile profile) { - if (!isConnected()) return false; - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates))); - Double[] basal = danaRPump.buildDanaRProfileRecord(profile); - DanaRS_Packet_Basal_Set_Profile_Basal_Rate msgSet = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate(aapsLogger, 0, basal); - bleComm.sendMessage(msgSet); - DanaRS_Packet_Basal_Set_Profile_Number msgActivate = new DanaRS_Packet_Basal_Set_Profile_Number(aapsLogger, 0); - bleComm.sendMessage(msgActivate); - danaRPump.setLastSettingsRead(0); // force read full settings - getPumpStatus(); - rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); - return true; - } - - public PumpEnactResult loadHistory(byte type) { - PumpEnactResult result = new PumpEnactResult(injector); - if (!isConnected()) return result; - DanaRS_Packet_History_ msg = null; - switch (type) { - case RecordTypes.RECORD_TYPE_ALARM: - msg = new DanaRS_Packet_History_Alarm(aapsLogger, rxBus); - break; - case RecordTypes.RECORD_TYPE_PRIME: - msg = new DanaRS_Packet_History_Prime(aapsLogger, rxBus); - break; - case RecordTypes.RECORD_TYPE_BASALHOUR: - msg = new DanaRS_Packet_History_Basal(aapsLogger, rxBus); - break; - case RecordTypes.RECORD_TYPE_BOLUS: - msg = new DanaRS_Packet_History_Bolus(aapsLogger, rxBus); - break; - case RecordTypes.RECORD_TYPE_CARBO: - msg = new DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus); - break; - case RecordTypes.RECORD_TYPE_DAILY: - msg = new DanaRS_Packet_History_Daily(aapsLogger, rxBus); - break; - case RecordTypes.RECORD_TYPE_GLUCOSE: - msg = new DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus); - break; - case RecordTypes.RECORD_TYPE_REFILL: - msg = new DanaRS_Packet_History_Refill(aapsLogger, rxBus); - break; - case RecordTypes.RECORD_TYPE_SUSPEND: - msg = new DanaRS_Packet_History_Suspend(aapsLogger, rxBus); - break; - } - if (msg != null) { - bleComm.sendMessage(new DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 1)); - SystemClock.sleep(200); - bleComm.sendMessage(msg); - while (!msg.getDone() && isConnected()) { - SystemClock.sleep(100); - } - SystemClock.sleep(200); - bleComm.sendMessage(new DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 0)); - } - result.success = true; - result.comment = "OK"; - return result; - } - - - public class LocalBinder extends Binder { - public DanaRSService getServiceInstance() { - return DanaRSService.this; - } - - } - - @Override - public IBinder onBind(Intent intent) { - return mBinder; - } - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - return START_STICKY; - } - - void waitForWholeMinute() { - while (true) { - long time = DateUtil.now(); - long timeToWholeMinute = (60000 - time % 60000); - if (timeToWholeMinute > 59800 || timeToWholeMinute < 300) - break; - rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000)))); - SystemClock.sleep(Math.min(timeToWholeMinute, 100)); - } - } -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt new file mode 100644 index 0000000000..1497904916 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt @@ -0,0 +1,462 @@ +package info.nightscout.androidaps.plugins.pump.danaRS.services + +import android.app.Service +import android.content.Context +import android.content.Intent +import android.os.Binder +import android.os.IBinder +import android.os.SystemClock +import dagger.android.DaggerService +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.Constants +import info.nightscout.androidaps.R +import info.nightscout.androidaps.activities.ErrorHelperActivity +import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.data.PumpEnactResult +import info.nightscout.androidaps.dialogs.BolusProgressDialog +import info.nightscout.androidaps.events.EventAppExit +import info.nightscout.androidaps.events.EventInitializationChanged +import info.nightscout.androidaps.events.EventProfileNeedsUpdate +import info.nightscout.androidaps.events.EventPumpStatusChanged +import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.CommandQueueProvider +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker +import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.plugins.general.nsclient.NSUpload +import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification +import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress +import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage +import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes +import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRNewStatus +import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.plugins.pump.danaRS.comm.* +import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.queue.Callback +import info.nightscout.androidaps.queue.commands.Command +import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.T +import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.androidaps.utils.sharedPreferences.SP +import io.reactivex.disposables.CompositeDisposable +import io.reactivex.schedulers.Schedulers +import javax.inject.Inject +import kotlin.math.abs +import kotlin.math.min + +class DanaRSService : DaggerService() { + @Inject lateinit var injector: HasAndroidInjector + @Inject lateinit var aapsLogger: AAPSLogger + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var sp: SP + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var commandQueue: CommandQueueProvider + @Inject lateinit var context: Context + @Inject lateinit var danaRSPlugin: DanaRSPlugin + @Inject lateinit var danaRPump: DanaRPump + @Inject lateinit var danaRSMessageHashTable: DanaRSMessageHashTable + @Inject lateinit var activePlugin: ActivePluginProvider + @Inject lateinit var constraintChecker: ConstraintChecker + @Inject lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage + @Inject lateinit var bleComm: BLEComm + @Inject lateinit var fabricPrivacy: FabricPrivacy + + private val disposable = CompositeDisposable() + private val mBinder: IBinder = LocalBinder() + private var bolusingTreatment: Treatment? = null + private var lastHistoryFetched: Long = 0 + private var lastApproachingDailyLimit: Long = 0 + + override fun onCreate() { + super.onCreate() + disposable.add(rxBus + .toObservable(EventAppExit::class.java) + .observeOn(Schedulers.io()) + .subscribe({ stopSelf() }) { fabricPrivacy.logException(it) } + ) + } + + override fun onDestroy() { + disposable.clear() + super.onDestroy() + } + + val isConnected: Boolean + get() = bleComm.isConnected + + val isConnecting: Boolean + get() = bleComm.isConnecting + + fun connect(from: String, address: String): Boolean { + return bleComm.connect(from, address) + } + + fun stopConnecting() { + bleComm.stopConnecting() + } + + fun disconnect(from: String) { + bleComm.disconnect(from) + } + + fun sendMessage(message: DanaRS_Packet) { + bleComm.sendMessage(message) + } + + fun readPumpStatus() { + try { + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus))) + sendMessage(DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)) + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingextendedbolusstatus))) + sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))) + sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)) // last bolus, bolusStep, maxBolus + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingtempbasalstatus))) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + danaRPump.lastConnection = System.currentTimeMillis() + val profile = profileFunction.getProfile() + val pump = activePlugin.activePump + if (profile != null && abs(danaRPump.currentBasal - profile.basal) >= pump.pumpDescription.basalStep) { + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))) + sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump)) // basal profile, basalStep, maxBasal + if (!pump.isThisProfileSet(profile) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE)) { + rxBus.send(EventProfileNeedsUpdate()) + } + } + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))) + sendMessage(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) + var timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L + if (danaRPump.pumpTime == 0L) { + // initial handshake was not successful + // de-initialize pump + danaRPump.reset() + rxBus.send(EventDanaRNewStatus()) + rxBus.send(EventInitializationChanged()) + return + } + val now = System.currentTimeMillis() + if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized) { + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))) + sendMessage(DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)) // serial no + sendMessage(DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)) // firmware + sendMessage(DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)) // isExtendedEnabled + sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump)) // basal profile, basalStep, maxBasal + sendMessage(DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump)) // target + sendMessage(DanaRS_Packet_Bolus_Get_CIR_CF_Array(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) // Getting user options + danaRPump.lastSettingsRead = now + } + aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds") + if (abs(timeDiff) > 3) { + if (abs(timeDiff) > 60 * 60 * 1.5) { + aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds - large difference") + //If time-diff is very large, warn user until we can synchronize history readings properly + val i = Intent(context, ErrorHelperActivity::class.java) + i.putExtra("soundid", R.raw.error) + i.putExtra("status", resourceHelper.gs(R.string.largetimediff)) + i.putExtra("title", resourceHelper.gs(R.string.largetimedifftitle)) + i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + context.startActivity(i) + + //de-initialize pump + danaRPump.reset() + rxBus.send(EventDanaRNewStatus()) + rxBus.send(EventInitializationChanged()) + return + } else { + if (danaRPump.protocol >= 6) { + sendMessage(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now())) + } else { + waitForWholeMinute() // Dana can set only whole minute + // add 10sec to be sure we are over minute (will be cut off anyway) + sendMessage(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now() + T.secs(10).msecs())) + } + sendMessage(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) + timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L + aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds") + } + } + loadEvents() + rxBus.send(EventDanaRNewStatus()) + rxBus.send(EventInitializationChanged()) + //NSUpload.uploadDeviceStatus(); + if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { + aapsLogger.debug(LTag.PUMPCOMM, "Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits) + if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { + val reportFail = Notification(Notification.APPROACHING_DAILY_LIMIT, resourceHelper.gs(R.string.approachingdailylimit), Notification.URGENT) + rxBus.send(EventNewNotification(reportFail)) + NSUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U") + lastApproachingDailyLimit = System.currentTimeMillis() + } + } + } catch (e: Exception) { + aapsLogger.error(LTag.PUMPCOMM, "Unhandled exception", e) + } + aapsLogger.debug(LTag.PUMPCOMM, "Pump status loaded") + } + + fun loadEvents(): PumpEnactResult { + if (!danaRSPlugin.isInitialized) { + val result = PumpEnactResult(injector).success(false) + result.comment = "pump not initialized" + return result + } + SystemClock.sleep(1000) + val msg: DanaRS_Packet_APS_History_Events + if (lastHistoryFetched == 0L) { + msg = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, 0) + aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history") + } else { + msg = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, lastHistoryFetched) + aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)) + } + sendMessage(msg) + while (!danaRPump.historyDoneReceived && bleComm.isConnected) { + SystemClock.sleep(100) + } + lastHistoryFetched = if (danaRPump.lastEventTimeLoaded != 0L) danaRPump.lastEventTimeLoaded - T.mins(1).msecs() else 0 + aapsLogger.debug(LTag.PUMPCOMM, "Events loaded") + danaRPump.lastConnection = System.currentTimeMillis() + return PumpEnactResult(injector).success(true) + } + + fun setUserSettings(): PumpEnactResult { + sendMessage(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) + return PumpEnactResult(injector).success(true) + } + + fun bolus(insulin: Double, carbs: Int, carbTime: Long, t: Treatment): Boolean { + if (!isConnected) return false + if (BolusProgressDialog.stopPressed) return false + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.startingbolus))) + bolusingTreatment = t + val preferencesSpeed = sp.getInt(R.string.key_danars_bolusspeed, 0) + danaRPump.bolusingTreatment = t + danaRPump.bolusAmountToBeDelivered = insulin + danaRPump.bolusStopped = false + danaRPump.bolusStopForced = false + danaRPump.bolusProgressLastTimeStamp = DateUtil.now() + val start = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRPump, constraintChecker, insulin, preferencesSpeed) + if (carbs > 0) { +// MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbTime, carbs); #### +// sendMessage(msg); + val msgSetHistoryEntryV2 = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, carbTime, carbs, 0) + sendMessage(msgSetHistoryEntryV2) + lastHistoryFetched = min(lastHistoryFetched, carbTime - T.mins(1).msecs()) + } + val bolusStart = System.currentTimeMillis() + if (insulin > 0) { + if (!danaRPump.bolusStopped) { + sendMessage(start) + } else { + t.insulin = 0.0 + return false + } + while (!danaRPump.bolusStopped && !start.failed && !danaRPump.bolusDone) { + SystemClock.sleep(100) + if (System.currentTimeMillis() - danaRPump.bolusProgressLastTimeStamp > 15 * 1000L) { // if i didn't receive status for more than 20 sec expecting broken comm + danaRPump.bolusStopped = true + danaRPump.bolusStopForced = true + aapsLogger.debug(LTag.PUMPCOMM, "Communication stopped") + } + } + } + val bolusingEvent = EventOverviewBolusProgress + bolusingEvent.t = t + bolusingEvent.percent = 99 + bolusingTreatment = null + var speed = 12 + when (preferencesSpeed) { + 0 -> speed = 12 + 1 -> speed = 30 + 2 -> speed = 60 + } + val bolusDurationInMSec = (insulin * speed * 1000).toLong() + val expectedEnd = bolusStart + bolusDurationInMSec + 2000 + while (System.currentTimeMillis() < expectedEnd) { + val waitTime = expectedEnd - System.currentTimeMillis() + bolusingEvent.status = String.format(resourceHelper.gs(R.string.waitingforestimatedbolusend), waitTime / 1000) + rxBus.send(bolusingEvent) + SystemClock.sleep(1000) + } + // do not call loadEvents() directly, reconnection may be needed + commandQueue.loadEvents(object : Callback() { + override fun run() { + // reread bolus status + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))) + sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)) // last bolus + bolusingEvent.percent = 100 + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.disconnecting))) + } + }) + return !start.failed + } + + fun bolusStop() { + aapsLogger.debug(LTag.PUMPCOMM, "bolusStop >>>>> @ " + if (bolusingTreatment == null) "" else bolusingTreatment?.insulin) + val stop = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRPump) + danaRPump.bolusStopForced = true + if (isConnected) { + sendMessage(stop) + while (!danaRPump.bolusStopped) { + sendMessage(stop) + SystemClock.sleep(200) + } + } else { + danaRPump.bolusStopped = true + } + } + + fun tempBasal(percent: Int, durationInHours: Int): Boolean { + if (!isConnected) return false + if (danaRPump.isTempBasalInProgress) { + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) + SystemClock.sleep(500) + } + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) + sendMessage(DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger, percent, durationInHours)) + SystemClock.sleep(200) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + loadEvents() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) + return true + } + + fun highTempBasal(percent: Int): Boolean { + if (danaRPump.isTempBasalInProgress) { + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) + SystemClock.sleep(500) + } + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) + sendMessage(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + loadEvents() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) + return true + } + + fun tempBasalShortDuration(percent: Int, durationInMinutes: Int): Boolean { + if (durationInMinutes != 15 && durationInMinutes != 30) { + aapsLogger.error(LTag.PUMPCOMM, "Wrong duration param") + return false + } + if (danaRPump.isTempBasalInProgress) { + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) + SystemClock.sleep(500) + } + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) + sendMessage(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + loadEvents() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) + return true + } + + fun tempBasalStop(): Boolean { + if (!isConnected) return false + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + loadEvents() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) + return true + } + + fun extendedBolus(insulin: Double, durationInHalfHours: Int): Boolean { + if (!isConnected) return false + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus))) + sendMessage(DanaRS_Packet_Bolus_Set_Extended_Bolus(aapsLogger, insulin, durationInHalfHours)) + SystemClock.sleep(200) + sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) + loadEvents() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) + return true + } + + fun extendedBolusStop(): Boolean { + if (!isConnected) return false + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus))) + sendMessage(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger)) + sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) + loadEvents() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) + return true + } + + fun updateBasalsInPump(profile: Profile): Boolean { + if (!isConnected) return false + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates))) + val basal = danaRPump.buildDanaRProfileRecord(profile) + val msgSet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(aapsLogger, 0, basal) + sendMessage(msgSet) + val msgActivate = DanaRS_Packet_Basal_Set_Profile_Number(aapsLogger, 0) + sendMessage(msgActivate) + danaRPump.lastSettingsRead = 0 // force read full settings + readPumpStatus() + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) + return true + } + + fun loadHistory(type: Byte): PumpEnactResult { + val result = PumpEnactResult(injector) + if (!isConnected) return result + var msg: DanaRS_Packet_History_? = null + when (type) { + RecordTypes.RECORD_TYPE_ALARM -> msg = DanaRS_Packet_History_Alarm(aapsLogger, rxBus) + RecordTypes.RECORD_TYPE_PRIME -> msg = DanaRS_Packet_History_Prime(aapsLogger, rxBus) + RecordTypes.RECORD_TYPE_BASALHOUR -> msg = DanaRS_Packet_History_Basal(aapsLogger, rxBus) + RecordTypes.RECORD_TYPE_BOLUS -> msg = DanaRS_Packet_History_Bolus(aapsLogger, rxBus) + RecordTypes.RECORD_TYPE_CARBO -> msg = DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus) + RecordTypes.RECORD_TYPE_DAILY -> msg = DanaRS_Packet_History_Daily(aapsLogger, rxBus) + RecordTypes.RECORD_TYPE_GLUCOSE -> msg = DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus) + RecordTypes.RECORD_TYPE_REFILL -> msg = DanaRS_Packet_History_Refill(aapsLogger, rxBus) + RecordTypes.RECORD_TYPE_SUSPEND -> msg = DanaRS_Packet_History_Suspend(aapsLogger, rxBus) + } + if (msg != null) { + sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 1)) + SystemClock.sleep(200) + sendMessage(msg) + while (!msg.done && isConnected) { + SystemClock.sleep(100) + } + SystemClock.sleep(200) + sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 0)) + } + result.success = true + result.comment = "OK" + return result + } + + inner class LocalBinder : Binder() { + val serviceInstance: DanaRSService + get() = this@DanaRSService + } + + override fun onBind(intent: Intent): IBinder { + return mBinder + } + + override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { + return Service.START_STICKY + } + + private fun waitForWholeMinute() { + while (true) { + val time = DateUtil.now() + val timeToWholeMinute = 60000 - time % 60000 + if (timeToWholeMinute > 59800 || timeToWholeMinute < 300) break + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.waitingfortimesynchronization, (timeToWholeMinute / 1000).toInt()))) + SystemClock.sleep(min(timeToWholeMinute, 100)) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java index e783d13d78..46785fb900 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java @@ -188,7 +188,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.bolusDelivered = t.insulin; result.carbsDelivered = detailedBolusInfo.carbs; if (!result.success) - result.comment = String.format(resourceHelper.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, danaRPump.getMessageStartErrorCode()); + result.comment = String.format(resourceHelper.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, danaRPump.getBolusStartErrorCode()); else result.comment = resourceHelper.gs(R.string.virtualpump_resultok); aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt index 7896cbc234..0ebefe9403 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -16,10 +16,9 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class) +@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, DanaRSPlugin::class) class DanaRSMessageHashTableTest : DanaRSTestBase() { - @Mock lateinit var danaRSPlugin: DanaRSPlugin @Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var constraintChecker: ConstraintChecker @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage @@ -28,7 +27,7 @@ class DanaRSMessageHashTableTest : DanaRSTestBase() { fun runTest() { `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) - val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, danaRSPlugin, activePlugin, constraintChecker, detailedBolusInfoStorage) + val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin, constraintChecker, detailedBolusInfoStorage) val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, 0, 0, 0) val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command) Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong()) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt index 1072c72e09..2b88f1c450 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt @@ -14,17 +14,16 @@ import org.powermock.modules.junit4.PowerMockRunner import java.util.* @RunWith(PowerMockRunner::class) -@PrepareForTest(RxBusWrapper::class, DetailedBolusInfoStorage::class) +@PrepareForTest(RxBusWrapper::class, DetailedBolusInfoStorage::class, DanaRSPlugin::class) class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() { @Mock lateinit var activePlugin: ActivePluginProvider - @Mock lateinit var danaRSPlugin: DanaRSPlugin @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage @Test fun runTest() { val now = DateUtil.now() - val testPacket = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, now) + val testPacket = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, now) // test getRequestedParams val returnedValues = testPacket.requestParams val expectedValues = getCalender(now) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt index 7b5b94522f..9420b1f7b6 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt @@ -31,7 +31,7 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest : DanaRSTestBase() { private lateinit var danaRSPlugin: DanaRSPlugin @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRSPlugin, constraintChecker) + val packet = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRPump, constraintChecker) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt index d4854c12cd..70276dc23b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt @@ -18,13 +18,12 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(RxBusWrapper::class) +@PrepareForTest(RxBusWrapper::class, DanaRSPlugin::class) class DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest : DanaRSTestBase() { @Mock lateinit var defaultValueHelper: DefaultValueHelper @Mock lateinit var profileFunction: ProfileFunction @Mock lateinit var activePlugin: ActivePluginProvider - @Mock lateinit var danaRSPlugin: DanaRSPlugin private var treatmentInjector: HasAndroidInjector = HasAndroidInjector { AndroidInjector { @@ -40,8 +39,8 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest : DanaRSTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(Mockito.anyInt())).thenReturn("SomeString") - danaRSPlugin.bolusingTreatment = Treatment(treatmentInjector) - val testPacket = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRSPlugin) + danaRPump.bolusingTreatment = Treatment(treatmentInjector) + val testPacket = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRPump) // test message decoding testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, testPacket.failed) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt index a7246493e6..b3c3317e4d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt @@ -19,11 +19,10 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(RxBusWrapper::class) +@PrepareForTest(RxBusWrapper::class, DanaRSPlugin::class) class DanaRS_Packet_Notify_Delivery_CompleteTest : DanaRSTestBase() { @Mock lateinit var defaultValueHelper: DefaultValueHelper - @Mock lateinit var danaRSPlugin: DanaRSPlugin @Mock lateinit var profileFunction: ProfileFunction @Mock lateinit var activePlugin: ActivePluginProvider @@ -41,13 +40,13 @@ class DanaRS_Packet_Notify_Delivery_CompleteTest : DanaRSTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(anyInt(), anyDouble())).thenReturn("SomeString") - danaRSPlugin.bolusingTreatment = Treatment(treatmentInjector) - val packet = DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRSPlugin) + danaRPump.bolusingTreatment = Treatment(treatmentInjector) + val packet = DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRPump) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(17, 0.toByte())) - Assert.assertEquals(true, danaRSPlugin.bolusDone) + Assert.assertEquals(true, danaRPump.bolusDone) Assert.assertEquals("NOTIFY__DELIVERY_COMPLETE", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt index 3d46558207..4bacb5673d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt @@ -50,7 +50,7 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(ArgumentMatchers.anyInt(), anyObject())).thenReturn("SomeString") // val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(1.0, Treatment(treatmentInjector)) - val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRSPlugin) + val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRPump) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding @@ -66,6 +66,6 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { @Before fun mock() { danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy) - danaRSPlugin.bolusingTreatment = Treatment(treatmentInjector) + danaRPump.bolusingTreatment = Treatment(treatmentInjector) } } \ No newline at end of file From 0fa627372550b869c734c32a0d522ca7c3bdc47c Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 29 Mar 2020 21:21:01 +0200 Subject: [PATCH 012/400] replace deprecated calls --- .../plugins/pump/danaR/comm/MsgHistoryAll.kt | 4 +- .../pump/danaR/comm/MsgSettingPumpTime.kt | 9 ++-- ...Packet_Bolus_Get_Step_Bolus_Information.kt | 36 +++++----------- ...aRS_Packet_General_Get_More_Information.kt | 40 ++++++------------ .../danaRS/comm/DanaRS_Packet_History_.kt | 31 +++++++------- .../DanaRS_Packet_Option_Get_Pump_Time.kt | 11 +++-- .../DanaRS_Packet_Option_Set_Pump_Time.kt | 18 ++++---- .../comm/MsgSetAPSTempBasalStart_v2.kt | 1 + ...et_Bolus_Get_Step_Bolus_InformationTest.kt | 29 +++++++++---- ...Packet_General_Get_More_InformationTest.kt | 36 +++++++++++----- .../comm/DanaRS_Packet_History_AlarmTest.kt | 41 +++++++++++++++++-- .../DanaRS_Packet_Option_Get_Pump_TimeTest.kt | 21 +++++----- .../DanaRS_Packet_Option_Set_Pump_TimeTest.kt | 13 +++--- 13 files changed, 163 insertions(+), 127 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt index 8c50099756..6d1d4a2bc4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt @@ -25,8 +25,8 @@ open class MsgHistoryAll( val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes val dailyBasal = intFromBuff(bytes, 4, 2) * 0.01 val dailyBolus = intFromBuff(bytes, 6, 2) * 0.01 - val paramByte5 = intFromBuff(bytes, 4, 1).toByte() - val paramByte6 = intFromBuff(bytes, 5, 1).toByte() + //val paramByte5 = intFromBuff(bytes, 4, 1).toByte() + //val paramByte6 = intFromBuff(bytes, 5, 1).toByte() val paramByte7 = intFromBuff(bytes, 6, 1).toByte() val paramByte8 = intFromBuff(bytes, 7, 1).toByte() val value = intFromBuff(bytes, 8, 2).toDouble() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTime.kt index df356ca744..07b3825b84 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTime.kt @@ -4,6 +4,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.utils.DateUtil +import org.joda.time.DateTime import java.util.* class MsgSettingPumpTime( @@ -17,14 +18,14 @@ class MsgSettingPumpTime( } override fun handleMessage(bytes: ByteArray) { - val time = Date( - 100 + intFromBuff(bytes, 5, 1), - intFromBuff(bytes, 4, 1) - 1, + val time = DateTime( + 2000 + intFromBuff(bytes, 5, 1), + intFromBuff(bytes, 4, 1), intFromBuff(bytes, 3, 1), intFromBuff(bytes, 2, 1), intFromBuff(bytes, 1, 1), intFromBuff(bytes, 0, 1) - ).time + ).millis aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + DateUtil.dateAndTimeString(time) + " Phone time: " + Date()) danaRPump.pumpTime = time } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt index 395d90b6ae..dca14ce099 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt @@ -5,6 +5,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.utils.DateUtil +import org.joda.time.DateTime import java.util.* class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( @@ -18,32 +19,15 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( } override fun handleMessage(data: ByteArray) { - var dataIndex = DATA_START - var dataSize = 1 - val error = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 1 - val bolusType = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 2 - danaRPump.initialBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - val lbt = Date() // it doesn't provide day only hour+min, workaround: expecting today - dataIndex += dataSize - dataSize = 1 - lbt.hours = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 1 - lbt.minutes = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - danaRPump.lastBolusTime = lbt.time - dataIndex += dataSize - dataSize = 2 - danaRPump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 2 - danaRPump.maxBolus = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 1 - danaRPump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 + val error = intFromBuff(data, 0, 1) + val bolusType = intFromBuff(data, 1, 1) + danaRPump.initialBolusAmount = intFromBuff(data, 2, 2) / 100.0 + val hours = intFromBuff(data, 4, 1) + val minutes = intFromBuff(data, 5, 1) + danaRPump.lastBolusTime = DateTime.now().withHourOfDay(hours).withMinuteOfHour(minutes).millis + danaRPump.lastBolusAmount = intFromBuff(data, 6, 2) / 100.0 + danaRPump.maxBolus = intFromBuff(data, 8, 2) / 100.0 + danaRPump.bolusStep = intFromBuff(data, 10, 1) / 100.0 failed = error != 0 aapsLogger.debug(LTag.PUMPCOMM, "Result: $error") aapsLogger.debug(LTag.PUMPCOMM, "BolusType: $bolusType") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt index 875b91f397..eb7d617d3b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt @@ -1,11 +1,11 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil -import java.util.* +import org.joda.time.DateTime class DanaRS_Packet_General_Get_More_Information( private val aapsLogger: AAPSLogger, @@ -22,37 +22,21 @@ class DanaRS_Packet_General_Get_More_Information( failed = true return } - var dataIndex = DATA_START - var dataSize = 2 - danaRPump.iob = byteArrayToInt(getBytes(data, dataIndex, dataSize)).toDouble() - dataIndex += dataSize - dataSize = 2 - danaRPump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - dataIndex += dataSize - dataSize = 1 - danaRPump.isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01 - dataIndex += dataSize - dataSize = 2 - danaRPump.extendedBolusRemainingMinutes = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 2 - //val remainRate = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - val lastBolusTime = Date() // it doesn't provide day only hour+min, workaround: expecting today - dataIndex += dataSize - dataSize = 1 - lastBolusTime.hours = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 1 - lastBolusTime.minutes = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 2 - danaRPump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)).toDouble() + danaRPump.iob = intFromBuff(data, 0, 2) / 100.0 + danaRPump.dailyTotalUnits = intFromBuff(data, 2, 2) / 100.0 + danaRPump.isExtendedInProgress = intFromBuff(data, 4, 1) == 0x01 + danaRPump.extendedBolusRemainingMinutes = intFromBuff(data, 5, 2) + // val remainRate = intFromBuff(data, 7, 2) / 100.0 + val hours = intFromBuff(data, 9, 1) + val minutes = intFromBuff(data, 10, 1) + danaRPump.lastBolusTime = DateTime.now().withHourOfDay(hours).withMinuteOfHour(minutes).millis + danaRPump.lastBolusAmount = intFromBuff(data, 11, 2) / 100.0 // On DanaRS DailyUnits can't be more than 160 if (danaRPump.dailyTotalUnits > 160) failed = true aapsLogger.debug(LTag.PUMPCOMM, "Daily total units: " + danaRPump.dailyTotalUnits.toString() + " U") aapsLogger.debug(LTag.PUMPCOMM, "Is extended in progress: " + danaRPump.isExtendedInProgress) aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: " + danaRPump.extendedBolusRemainingMinutes) - aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + DateUtil.dateAndTimeAndSecondsString(lastBolusTime.time)) + aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + DateUtil.dateAndTimeAndSecondsString(danaRPump.lastBolusTime)) aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt index e8da961028..4273f6ca0d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt @@ -8,6 +8,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus import info.nightscout.androidaps.utils.DateUtil +import org.joda.time.DateTime import java.util.* abstract class DanaRS_Packet_History_( @@ -25,6 +26,7 @@ abstract class DanaRS_Packet_History_( var done = false var totalCount = 0 + val danaRHistoryRecord = DanaRHistoryRecord() init { val cal = GregorianCalendar() @@ -79,14 +81,13 @@ abstract class DanaRS_Packet_History_( val historySecond = byteArrayToInt(getBytes(data, DATA_START + 6, 1)) val paramByte7 = historySecond.toByte() val dailyBolus: Double = ((data[DATA_START + 6].toInt() and 0xFF shl 8) + (data[DATA_START + 7].toInt() and 0xFF)) * 0.01 - val date = Date(100 + historyYear, historyMonth - 1, historyDay) - val datetime = Date(100 + historyYear, historyMonth - 1, historyDay, historyHour, historyMinute) - val datetimewihtsec = Date(100 + historyYear, historyMonth - 1, historyDay, historyHour, historyMinute, historySecond) + val date = DateTime(2000 + historyYear, historyMonth, historyDay, 0, 0) + val datetime = DateTime(2000 + historyYear, historyMonth, historyDay, historyHour, historyMinute) + val datetimewihtsec = DateTime(2000 + historyYear, historyMonth, historyDay, historyHour, historyMinute, historySecond) val historyCode = byteArrayToInt(getBytes(data, DATA_START + 7, 1)) val paramByte8 = historyCode.toByte() val value: Int = (data[DATA_START + 8].toInt() and 0xFF shl 8) + (data[DATA_START + 9].toInt() and 0xFF) - aapsLogger.debug(LTag.PUMPCOMM, "History packet: " + recordCode + " Date: " + DateUtil.dateAndTimeString(datetimewihtsec) + " Code: " + historyCode + " Value: " + value) - val danaRHistoryRecord = DanaRHistoryRecord() + aapsLogger.debug(LTag.PUMPCOMM, "History packet: " + recordCode + " Date: " + DateUtil.dateAndTimeString(datetimewihtsec.millis) + " Code: " + historyCode + " Value: " + value) danaRHistoryRecord.setBytes(data) // danaRHistoryRecord.recordCode is different from DanaR codes // set in switch for every type @@ -94,7 +95,7 @@ abstract class DanaRS_Packet_History_( when (recordCode) { 0x02 -> { danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_BOLUS - danaRHistoryRecord.recordDate = datetime.time + danaRHistoryRecord.recordDate = datetime.millis when (0xF0 and paramByte8.toInt()) { 0xA0 -> { danaRHistoryRecord.bolusType = "DS" @@ -125,7 +126,7 @@ abstract class DanaRS_Packet_History_( 0x03 -> { danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_DAILY messageType += "dailyinsulin" - danaRHistoryRecord.recordDate = date.time + danaRHistoryRecord.recordDate = date.millis danaRHistoryRecord.recordDailyBasal = dailyBasal danaRHistoryRecord.recordDailyBolus = dailyBolus } @@ -133,49 +134,49 @@ abstract class DanaRS_Packet_History_( 0x04 -> { danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_PRIME messageType += "prime" - danaRHistoryRecord.recordDate = datetimewihtsec.time + danaRHistoryRecord.recordDate = datetimewihtsec.millis danaRHistoryRecord.recordValue = value * 0.01 } 0x05 -> { danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_REFILL messageType += "refill" - danaRHistoryRecord.recordDate = datetimewihtsec.time + danaRHistoryRecord.recordDate = datetimewihtsec.millis danaRHistoryRecord.recordValue = value * 0.01 } 0x0b -> { danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_BASALHOUR messageType += "basal hour" - danaRHistoryRecord.recordDate = datetimewihtsec.time + danaRHistoryRecord.recordDate = datetimewihtsec.millis danaRHistoryRecord.recordValue = value * 0.01 } 0x99 -> { danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_TEMP_BASAL messageType += "tb" - danaRHistoryRecord.recordDate = datetimewihtsec.time + danaRHistoryRecord.recordDate = datetimewihtsec.millis danaRHistoryRecord.recordValue = value * 0.01 } 0x06 -> { danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_GLUCOSE messageType += "glucose" - danaRHistoryRecord.recordDate = datetimewihtsec.time + danaRHistoryRecord.recordDate = datetimewihtsec.millis danaRHistoryRecord.recordValue = value.toDouble() } 0x07 -> { danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_CARBO messageType += "carbo" - danaRHistoryRecord.recordDate = datetimewihtsec.time + danaRHistoryRecord.recordDate = datetimewihtsec.millis danaRHistoryRecord.recordValue = value.toDouble() } 0x0a -> { danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_ALARM messageType += "alarm" - danaRHistoryRecord.recordDate = datetimewihtsec.time + danaRHistoryRecord.recordDate = datetimewihtsec.millis var strAlarm = "None" when (paramByte8.toInt()) { 67 -> strAlarm = "Check" @@ -190,7 +191,7 @@ abstract class DanaRS_Packet_History_( 0x09 -> { danaRHistoryRecord.recordCode = RecordTypes.RECORD_TYPE_SUSPEND messageType += "suspend" - danaRHistoryRecord.recordDate = datetimewihtsec.time + danaRHistoryRecord.recordDate = datetimewihtsec.millis var strRecordValue = "Off" if (paramByte8.toInt() == 79) strRecordValue = "On" danaRHistoryRecord.stringRecordValue = strRecordValue diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt index b582a0b492..4db309afe0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt @@ -1,11 +1,11 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil -import java.util.* +import org.joda.time.DateTime class DanaRS_Packet_Option_Get_Pump_Time( private val aapsLogger: AAPSLogger, @@ -36,10 +36,9 @@ class DanaRS_Packet_Option_Get_Pump_Time( dataIndex += dataSize dataSize = 1 val sec = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - val time = Date(100 + year, month - 1, day, hour, min, sec) - danaRPump.pumpTime = time.time - failed = year == month && month == day && day == hour && hour == min && min == sec && sec == 1 - aapsLogger.debug(LTag.PUMPCOMM, "Pump time " + DateUtil.dateAndTimeString(time)) + val time = DateTime(2000 + year, month, day, hour, min, sec) + danaRPump.pumpTime = time.millis + aapsLogger.debug(LTag.PUMPCOMM, "Pump time " + DateUtil.dateAndTimeString(time.millis)) } override fun handleMessageNotReceived() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt index 54a38af3de..73cf49c6df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt @@ -1,10 +1,10 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil -import java.util.* +import org.joda.time.DateTime class DanaRS_Packet_Option_Set_Pump_Time( private val aapsLogger: AAPSLogger, @@ -19,14 +19,14 @@ class DanaRS_Packet_Option_Set_Pump_Time( } override fun getRequestParams(): ByteArray { - val date = Date(time) + val date = DateTime(time) val request = ByteArray(6) - request[0] = (date.year - 100 and 0xff).toByte() - request[1] = (date.month + 1 and 0xff).toByte() - request[2] = (date.date and 0xff).toByte() - request[3] = (date.hours and 0xff).toByte() - request[4] = (date.minutes and 0xff).toByte() - request[5] = (date.seconds and 0xff).toByte() + request[0] = (date.year - 2000 and 0xff).toByte() + request[1] = (date.monthOfYear and 0xff).toByte() + request[2] = (date.dayOfMonth and 0xff).toByte() + request[3] = (date.hourOfDay and 0xff).toByte() + request[4] = (date.minuteOfHour and 0xff).toByte() + request[5] = (date.secondOfMinute and 0xff).toByte() return request } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStart_v2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStart_v2.kt index 95d2b56b77..2ff8c669ef 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStart_v2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStart_v2.kt @@ -4,6 +4,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase +@Suppress("UNUSED_PARAMETER") class MsgSetAPSTempBasalStart_v2( private val aapsLogger: AAPSLogger, private var percent: Int, diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt index 86239a8ea1..c3ac9a12d6 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt @@ -5,6 +5,7 @@ import org.junit.Test import org.junit.runner.RunWith import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner +import java.util.* @RunWith(PowerMockRunner::class) @PrepareForTest() @@ -12,14 +13,26 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest : DanaRSTestBase() { @Test fun runTest() { val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump) - Assert.assertEquals(null, packet.requestParams) - // test message decoding - packet.handleMessage(createArray(34, 0.toByte())) - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(34, 1.toByte())) - val valueRequested: Int = (1 and 0x000000FF shl 8) + (1 and 0x000000FF) - Assert.assertEquals(valueRequested / 100.0, danaRPump.lastBolusAmount, 0.0) - Assert.assertEquals(true, packet.failed) + + val array = createArray(13, 0.toByte()) // 11 + 2 + putByteToArray(array, 0, 2) // error 2 + putByteToArray(array, 1, 3) // bolus type 3 + putIntToArray(array, 2, 600) // initial bolus amount 6 + putByteToArray(array, 4, 13) // 13h + putByteToArray(array, 5, 20) // 20min + putIntToArray(array, 6, 1250) // last bolus amount 12.5 + putIntToArray(array, 8, 2500) // max bolus 25 + putByteToArray(array, 10, 100) // bolus step 1 + + packet.handleMessage(array) + Assert.assertTrue(packet.failed) + Assert.assertEquals(6.0, danaRPump.initialBolusAmount, 0.01) + val lastBolus = Date(danaRPump.lastBolusTime) + Assert.assertEquals(13, lastBolus.hours) + Assert.assertEquals(20, lastBolus.minutes) + Assert.assertEquals(12.5, danaRPump.lastBolusAmount, 0.01) + Assert.assertEquals(25.0, danaRPump.maxBolus, 0.01) + Assert.assertEquals(1.0, danaRPump.bolusStep, 0.01) Assert.assertEquals("BOLUS__GET_STEP_BOLUS_INFORMATION", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt index 327aa1c8a6..12ff721a2b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt @@ -3,25 +3,39 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner +import java.util.* @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() { @Test fun runTest() { var packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump) - Assert.assertEquals(null, packet.requestParams) - // test message decoding - // test for the length message - packet.handleMessage(createArray(13, 0.toByte())) - Assert.assertEquals(true, packet.failed) + + packet.handleMessage(createArray(14, 0.toByte())) + Assert.assertTrue(packet.failed) + packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump) - packet.handleMessage(createArray(15, 0.toByte())) - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(15, 161.toByte())) - Assert.assertEquals(true, packet.failed) + val array = createArray(15, 0.toByte()) // 13 + 2 + putIntToArray(array, 0, 600) // iob 6 + putIntToArray(array, 2, 1250) // daily units 12.5 + putByteToArray(array, 4, 1) // is extended in progress + putIntToArray(array, 5, 150) // extended remaining minutes 150 + putByteToArray(array, 9, 15) // hours 15 + putByteToArray(array, 10, 25) // minutes 25 + putIntToArray(array, 11, 170) // last bolus manout 1.70 + + packet.handleMessage(array) + Assert.assertFalse(packet.failed) + Assert.assertEquals(6.0, danaRPump.iob, 0.01) + Assert.assertEquals(12.5, danaRPump.dailyTotalUnits, 0.01) + Assert.assertTrue(danaRPump.isExtendedInProgress) + Assert.assertEquals(150, danaRPump.extendedBolusRemainingMinutes) + val lastBolus = Date(danaRPump.lastBolusTime) + Assert.assertEquals(15, lastBolus.hours) + Assert.assertEquals(25, lastBolus.minutes) + Assert.assertEquals(1.7, danaRPump.lastBolusAmount, 0.01) + Assert.assertEquals("REVIEW__GET_MORE_INFORMATION", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt index 743d3f66e7..bc10832af9 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt @@ -1,17 +1,52 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.db.DatabaseHelper +import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes import org.junit.Assert +import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import org.mockito.Mock +import org.mockito.Mockito.`when` +import org.powermock.api.mockito.PowerMockito import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner +import java.util.* @RunWith(PowerMockRunner::class) -@PrepareForTest() +@PrepareForTest(MainApp::class) class DanaRS_Packet_History_AlarmTest : DanaRSTestBase() { - @Test fun runTest() { - val packet = DanaRS_Packet_History_Alarm(aapsLogger, rxBus, System.currentTimeMillis()) + @Mock lateinit var databaseHelper: DatabaseHelper + + @Before + fun mock() { + PowerMockito.mockStatic(MainApp::class.java) + `when`(MainApp.getDbHelper()).thenReturn(databaseHelper) + } + + @Test + fun runTest() { + val packet = DanaRS_Packet_History_Alarm(aapsLogger, rxBus, 0) + + val array = createArray(12, 0.toByte()) // 10 + 2 + putByteToArray(array, 0, 0x0A) // record code alarm + putByteToArray(array, 1, 19) // year 2019 + putByteToArray(array, 2, 2) // month february + putByteToArray(array, 3, 4) // day 4 + putByteToArray(array, 4, 20) // hour 20 + putByteToArray(array, 5, 11) // min 11 + putByteToArray(array, 6, 35) // second 35 + putByteToArray(array, 7, 79) // occlusion + putByteToArray(array, 8, 1) // value + putByteToArray(array, 9, 100) // value + + packet.handleMessage(array) + Assert.assertEquals(RecordTypes.RECORD_TYPE_ALARM, packet.danaRHistoryRecord.recordCode) + Assert.assertEquals(Date(119, 1, 4, 20, 11, 35).time, packet.danaRHistoryRecord.recordDate) + Assert.assertEquals("Occlusion", packet.danaRHistoryRecord.recordAlarm) + Assert.assertEquals(3.56, packet.danaRHistoryRecord.recordValue, 0.01) Assert.assertEquals("REVIEW__ALARM", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt index 8f74812e9e..2ac915644f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt @@ -1,25 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import org.joda.time.DateTime import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Option_Get_Pump_TimeTest : DanaRSTestBase() { @Test fun runTest() { val packet = DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump) - // test params - Assert.assertEquals(null, packet.requestParams) - // test message decoding - packet.handleMessage(createArray(8, 0.toByte())) - Assert.assertEquals(false, packet.failed) - // this should fail - packet.handleMessage(createArray(8, 1.toByte())) - Assert.assertEquals(true, packet.failed) + val array = createArray(8, 0.toByte()) // 6 + 2 + putByteToArray(array, 0, 19) // year 2019 + putByteToArray(array, 1, 2) // month february + putByteToArray(array, 2, 4) // day 4 + putByteToArray(array, 3, 20) // hour 20 + putByteToArray(array, 4, 11) // min 11 + putByteToArray(array, 5, 35) // second 35 + + packet.handleMessage(array) + Assert.assertEquals(DateTime(2019, 2, 4, 20, 11, 35).millis, danaRPump.pumpTime) Assert.assertEquals("OPTION__GET_PUMP_TIME", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt index 5fd034e5b6..bf34d76510 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt @@ -1,22 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.utils.DateUtil import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner import java.util.* @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Option_Set_Pump_TimeTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now()) + val date = Date() + val packet = DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, date.time) // test params val params = packet.requestParams - Assert.assertEquals((Date().date and 0xff).toByte(), params[2]) + Assert.assertEquals((date.year - 100 and 0xff).toByte(), params[0]) // 2019 -> 19 + Assert.assertEquals((date.month + 1 and 0xff).toByte(), params[1]) + Assert.assertEquals((date.date and 0xff).toByte(), params[2]) + Assert.assertEquals((date.hours and 0xff).toByte(), params[3]) + Assert.assertEquals((date.minutes and 0xff).toByte(), params[4]) + Assert.assertEquals((date.seconds and 0xff).toByte(), params[5]) // test message decoding packet.handleMessage(createArray(3, 0.toByte())) Assert.assertEquals(false, packet.failed) From 8d3ad42ff762e0112d69dd9a6dd7062402507090 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 30 Mar 2020 21:14:56 +0200 Subject: [PATCH 013/400] Better detect failed encryption --- .../plugins/pump/danaRS/services/BLEComm.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt index e691156d0d..8e5937238d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -19,6 +19,8 @@ import info.nightscout.androidaps.plugins.pump.danaRS.activities.EnterPinActivit import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSMessageHashTable import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet +import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Etc_Keep_Connection +import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_General_Get_Pump_Check import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess import info.nightscout.androidaps.utils.ToastUtils @@ -72,6 +74,7 @@ class BLEComm @Inject internal constructor( var isConnected = false var isConnecting = false private var encryptedDataRead = false + private var encryptedCommandSent = false private var uartRead: BluetoothGattCharacteristic? = null private var uartWrite: BluetoothGattCharacteristic? = null @@ -99,6 +102,7 @@ class BLEComm @Inject internal constructor( isConnected = false v3Encryption = false encryptedDataRead = false + encryptedCommandSent = false isConnecting = true val device = bluetoothAdapter?.getRemoteDevice(address) if (device == null) { @@ -121,7 +125,7 @@ class BLEComm @Inject internal constructor( fun disconnect(from: String) { aapsLogger.debug(LTag.PUMPBTCOMM, "disconnect from: $from") - if (!encryptedDataRead && v3Encryption) { + if (!encryptedDataRead && encryptedCommandSent && v3Encryption) { // there was no response from pump after started encryption // assume pairing keys are invalid sp.remove(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName) @@ -143,6 +147,7 @@ class BLEComm @Inject internal constructor( bluetoothGatt?.disconnect() isConnected = false encryptedDataRead = false + encryptedCommandSent = false SystemClock.sleep(2000) } @@ -202,6 +207,7 @@ class BLEComm @Inject internal constructor( isConnecting = false isConnected = false encryptedDataRead = false + encryptedCommandSent = false return } bluetoothGatt?.setCharacteristicNotification(characteristic, enabled) @@ -216,6 +222,7 @@ class BLEComm @Inject internal constructor( isConnecting = false isConnected = false encryptedDataRead = false + encryptedCommandSent = false return@Runnable } characteristic.value = data @@ -241,6 +248,7 @@ class BLEComm @Inject internal constructor( isConnecting = false isConnected = false encryptedDataRead = false + encryptedCommandSent = false return null } return bluetoothGatt?.services @@ -275,6 +283,7 @@ class BLEComm @Inject internal constructor( isConnecting = false v3Encryption = false encryptedDataRead = false + encryptedCommandSent = false rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED)) aapsLogger.debug(LTag.PUMPBTCOMM, "Device was disconnected " + gatt.device.name) //Device was disconnected } @@ -527,6 +536,7 @@ class BLEComm @Inject internal constructor( isConnected = true isConnecting = false aapsLogger.debug(LTag.PUMPBTCOMM, "Connect !!") + // Send one message to confirm communication } else { context.startActivity(Intent(context, EnterPinActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) aapsLogger.debug(LTag.PUMPBTCOMM, "Request pairing keys !!") @@ -616,6 +626,7 @@ class BLEComm @Inject internal constructor( // the rest of packets fun sendMessage(message: DanaRS_Packet) { + encryptedCommandSent = true processedMessage = message val command = byteArrayOf(message.type.toByte(), message.opCode.toByte()) val params = message.requestParams From 58fe62c45afca477eb3c7f0faaf1ad4b16de53fe Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 2 Apr 2020 21:46:30 +0200 Subject: [PATCH 014/400] concurrency extension --- .../plugins/pump/danaRS/services/BLEComm.kt | 8 ++--- .../nightscout/androidaps/utils/CryptoUtil.kt | 33 +------------------ .../utils/extensions/Concurrency.kt | 22 +++++++++++++ 3 files changed, 26 insertions(+), 37 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/utils/extensions/Concurrency.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt index 8e5937238d..e46aff33d7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -19,15 +19,13 @@ import info.nightscout.androidaps.plugins.pump.danaRS.activities.EnterPinActivit import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSMessageHashTable import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Etc_Keep_Connection -import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_General_Get_Pump_Check import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess import info.nightscout.androidaps.utils.ToastUtils +import info.nightscout.androidaps.utils.extensions.notify +import info.nightscout.androidaps.utils.extensions.waitMillis import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP -import okhttp3.internal.notify -import okhttp3.internal.waitMillis import java.util.* import java.util.concurrent.ScheduledFuture import javax.inject.Inject @@ -230,7 +228,7 @@ class BLEComm @Inject internal constructor( //aapsLogger.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data)) bluetoothGatt?.writeCharacteristic(characteristic) }).start() - waitMillis(50) + SystemClock.sleep(50) } private val uartReadBTGattChar: BluetoothGattCharacteristic diff --git a/app/src/main/java/info/nightscout/androidaps/utils/CryptoUtil.kt b/app/src/main/java/info/nightscout/androidaps/utils/CryptoUtil.kt index 745f4449ee..ad271e7344 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/CryptoUtil.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/CryptoUtil.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.utils +import info.nightscout.androidaps.utils.extensions.toHex import org.spongycastle.util.encoders.Base64 import java.nio.ByteBuffer import java.security.MessageDigest @@ -13,38 +14,6 @@ import javax.crypto.spec.GCMParameterSpec import javax.crypto.spec.PBEKeySpec import javax.crypto.spec.SecretKeySpec -private val HEX_CHARS = "0123456789abcdef" -private val HEX_CHARS_ARRAY = "0123456789abcdef".toCharArray() - -fun String.hexStringToByteArray() : ByteArray { - - val upperCased = this.toLowerCase() - val result = ByteArray(length / 2) - for (i in 0 until length step 2) { - val firstIndex = HEX_CHARS.indexOf(upperCased[i]); - val secondIndex = HEX_CHARS.indexOf(upperCased[i + 1]); - - val octet = firstIndex.shl(4).or(secondIndex) - result.set(i.shr(1), octet.toByte()) - } - - return result -} - -fun ByteArray.toHex() : String{ - val result = StringBuffer() - - forEach { - val octet = it.toInt() - val firstIndex = (octet and 0xF0).ushr(4) - val secondIndex = octet and 0x0F - result.append(HEX_CHARS_ARRAY[firstIndex]) - result.append(HEX_CHARS_ARRAY[secondIndex]) - } - - return result.toString() -} - object CryptoUtil { private const val IV_LENGTH_BYTE = 12 diff --git a/app/src/main/java/info/nightscout/androidaps/utils/extensions/Concurrency.kt b/app/src/main/java/info/nightscout/androidaps/utils/extensions/Concurrency.kt new file mode 100644 index 0000000000..b958a0ea24 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/utils/extensions/Concurrency.kt @@ -0,0 +1,22 @@ +package info.nightscout.androidaps.utils.extensions + + +@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "NOTHING_TO_INLINE") +inline fun Any.wait() = (this as Object).wait() + +/** + * Lock and wait a duration in milliseconds and nanos. + * Unlike [java.lang.Object.wait] this interprets 0 as "don't wait" instead of "wait forever". + */ +@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") +fun Any.waitMillis(timeout: Long, nanos: Int = 0) { + if (timeout > 0L || nanos > 0) { + (this as Object).wait(timeout, nanos) + } +} + +@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "NOTHING_TO_INLINE") +inline fun Any.notify() = (this as Object).notify() + +@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "NOTHING_TO_INLINE") +inline fun Any.notifyAll() = (this as Object).notifyAll() From 0d89262dfabf49716d4607aff9d58550bcb9ef10 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 6 Apr 2020 10:35:00 +0200 Subject: [PATCH 015/400] fix SmsPluginCommunicatorTest --- .../general/smsCommunicator/SmsCommunicatorPluginTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index d5b7ddd5f5..2ce83f0164 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -13,6 +13,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.interfaces.PumpDescription import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction @@ -156,6 +157,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { `when`(virtualPumpPlugin.shortStatus(ArgumentMatchers.anyBoolean())).thenReturn("Virtual Pump") `when`(virtualPumpPlugin.isSuspended).thenReturn(false) + `when`(virtualPumpPlugin.pumpDescription).thenReturn(PumpDescription()) `when`(treatmentsPlugin.lastCalculationTreatments).thenReturn(IobTotal(0)) `when`(treatmentsPlugin.lastCalculationTempBasals).thenReturn(IobTotal(0)) From f595560baadeafacc93f25b15882ebbfc6e99996 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 19 Apr 2020 12:57:08 +0200 Subject: [PATCH 016/400] RS insulin and canula change logging --- .../androidaps/dialogs/FillDialog.kt | 48 ++++++++++--------- .../danaRS/comm/DanaRSMessageHashTable.kt | 7 +-- .../comm/DanaRS_Packet_APS_History_Events.kt | 8 ++++ .../pump/danaRS/services/DanaRSService.kt | 4 +- .../plugins/treatments/TreatmentsPlugin.java | 2 +- app/src/main/res/values/strings.xml | 6 +++ app/src/main/res/xml/pref_danars.xml | 12 +++++ .../danaRS/comm/DanaRSMessageHashTableTest.kt | 2 +- .../DanaRS_Packet_APS_History_EventsTest.kt | 2 +- 9 files changed, 60 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt index df1664b68a..3fbdc7112c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -25,6 +25,7 @@ import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.SafeParse import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.androidaps.utils.sharedPreferences.SP import kotlinx.android.synthetic.main.dialog_fill.* import kotlinx.android.synthetic.main.notes.* import kotlinx.android.synthetic.main.okcancel.* @@ -121,12 +122,12 @@ class FillDialog : DialogFragmentWithDate() { } if (siteChange) { aapsLogger.debug("USER ENTRY: SITE CHANGE") - generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes) + generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes, resourceHelper, sp) } if (insulinChange) { // add a second for case of both checked aapsLogger.debug("USER ENTRY: INSULIN CHANGE") - generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes) + generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes, resourceHelper, sp) } }, null) } @@ -160,27 +161,28 @@ class FillDialog : DialogFragmentWithDate() { }) } - private fun generateCareportalEvent(eventType: String, time: Long, notes: String) { - val careportalEvent = CareportalEvent() - careportalEvent.source = Source.USER - careportalEvent.date = time - careportalEvent.json = generateJson(eventType, time, notes).toString() - careportalEvent.eventType = eventType - MainApp.getDbHelper().createOrUpdate(careportalEvent) - NSUpload.uploadEvent(eventType, time, notes) - } - - private fun generateJson(careportalEvent: String, time: Long, notes: String): JSONObject { - val data = JSONObject() - try { - data.put("eventType", careportalEvent) - data.put("created_at", DateUtil.toISOString(time)) - data.put("mills", time) - data.put("enteredBy", sp.getString("careportal_enteredby", resourceHelper.gs(R.string.app_name))) - if (notes.isNotEmpty()) data.put("notes", notes) - } catch (ignored: JSONException) { + companion object { + fun generateCareportalEvent(eventType: String, time: Long, notes: String, resourceHelper: ResourceHelper, sp: SP) { + val careportalEvent = CareportalEvent() + careportalEvent.source = Source.USER + careportalEvent.date = time + careportalEvent.json = generateJson(eventType, time, notes, resourceHelper, sp).toString() + careportalEvent.eventType = eventType + MainApp.getDbHelper().createOrUpdate(careportalEvent) + NSUpload.uploadEvent(eventType, time, notes) } - return data - } + private fun generateJson(careportalEvent: String, time: Long, notes: String, resourceHelper: ResourceHelper, sp: SP): JSONObject { + val data = JSONObject() + try { + data.put("eventType", careportalEvent) + data.put("created_at", DateUtil.toISOString(time)) + data.put("mills", time) + data.put("enteredBy", sp.getString("careportal_enteredby", resourceHelper.gs(R.string.app_name))) + if (notes.isNotEmpty()) data.put("notes", notes) + } catch (ignored: JSONException) { + } + return data + } + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt index 4f3d86c51d..c158cce9a5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt @@ -6,8 +6,8 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.androidaps.utils.sharedPreferences.SP import java.util.* import javax.inject.Inject import javax.inject.Singleton @@ -20,7 +20,8 @@ class DanaRSMessageHashTable @Inject constructor( danaRPump: DanaRPump, activePlugin: ActivePluginProvider, constraintChecker: ConstraintChecker, - detailedBolusInfoStorage: DetailedBolusInfoStorage + detailedBolusInfoStorage: DetailedBolusInfoStorage, + sp: SP ) { var messages: HashMap = HashMap() @@ -98,7 +99,7 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus)) // APS put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0)) - put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, 0)) + put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, 0)) put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, 0, 0, 0, 0)) // v3 put(DanaRS_Packet_General_Get_Shipping_Version(aapsLogger, danaRPump)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt index 97700ba30e..1ee7086bd8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt @@ -2,9 +2,11 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm import info.nightscout.androidaps.R import info.nightscout.androidaps.data.DetailedBolusInfo +import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.ExtendedBolus import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TemporaryBasal +import info.nightscout.androidaps.dialogs.FillDialog import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.AAPSLogger @@ -15,6 +17,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.androidaps.utils.sharedPreferences.SP import java.util.* open class DanaRS_Packet_APS_History_Events( @@ -24,6 +27,7 @@ open class DanaRS_Packet_APS_History_Events( private val activePlugin: ActivePluginProvider, private val danaRPump: DanaRPump, private val detailedBolusInfoStorage: DetailedBolusInfoStorage, + private val sp: SP, private var from: Long ) : DanaRS_Packet() { @@ -156,11 +160,15 @@ open class DanaRS_Packet_APS_History_Events( DanaRPump.REFILL -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT REFILL (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") + if (sp.getBoolean(R.string.key_rs_loginsulinchange, true)) + FillDialog.generateCareportalEvent(CareportalEvent.INSULINCHANGE, datetime, resourceHelper.gs(R.string.danarspump), resourceHelper, sp) status = "REFILL " + DateUtil.timeString(datetime) } DanaRPump.PRIME -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIME (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") + if (sp.getBoolean(R.string.key_rs_logcanulachange, true)) + FillDialog.generateCareportalEvent(CareportalEvent.SITECHANGE, datetime, resourceHelper.gs(R.string.danarspump), resourceHelper, sp) status = "PRIME " + DateUtil.timeString(datetime) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt index 1497904916..3cdb8f3857 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt @@ -211,10 +211,10 @@ class DanaRSService : DaggerService() { SystemClock.sleep(1000) val msg: DanaRS_Packet_APS_History_Events if (lastHistoryFetched == 0L) { - msg = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, 0) + msg = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, 0) aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history") } else { - msg = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, lastHistoryFetched) + msg = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, lastHistoryFetched) aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)) } sendMessage(msg) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java index 9704d82f43..910c4d1cfb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java @@ -288,7 +288,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface /** * Returns all Treatments after specified timestamp. Also returns invalid entries (required to - * map "Fill Canulla" entries to history (and not to add double bolus for it) + * map "Fill Canula" entries to history (and not to add double bolus for it) * * @param fromTimestamp * @return diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 019338b92c..6f0d1e46e3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1815,4 +1815,10 @@ Predictions Deviation slope graphconfig + rs_loginsulinchange + Log reservoir change + Add \"Insulin Change\" event to careportal when detected in history + rs_logcanulachange + Log canula change + Add \"Site Change\" event to careportal when detected in history diff --git a/app/src/main/res/xml/pref_danars.xml b/app/src/main/res/xml/pref_danars.xml index 2bd7446a61..baf7bc4405 100644 --- a/app/src/main/res/xml/pref_danars.xml +++ b/app/src/main/res/xml/pref_danars.xml @@ -35,6 +35,18 @@ android:key="@string/key_danars_bolusspeed" android:title="@string/bolusspeed" /> + + + + diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt index 0ebefe9403..1db5d5ffc1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt @@ -27,7 +27,7 @@ class DanaRSMessageHashTableTest : DanaRSTestBase() { fun runTest() { `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) - val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin, constraintChecker, detailedBolusInfoStorage) + val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin, constraintChecker, detailedBolusInfoStorage, sp) val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, 0, 0, 0) val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command) Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong()) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt index 2b88f1c450..51d31a907d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt @@ -23,7 +23,7 @@ class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() { @Test fun runTest() { val now = DateUtil.now() - val testPacket = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, now) + val testPacket = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, now) // test getRequestedParams val returnedValues = testPacket.requestParams val expectedValues = getCalender(now) From e526ad4617bf50a08f957f44d22b996e27a593d5 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 20 Apr 2020 21:28:29 +0200 Subject: [PATCH 017/400] model string --- .../plugins/pump/danaR/DanaRFragment.kt | 38 +++++++++---------- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt index d747301ec0..83c7077825 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt @@ -178,7 +178,7 @@ class DanaRFragment : DaggerFragment() { if (pump.lastConnection != 0L) { val agoMsec = System.currentTimeMillis() - pump.lastConnection val agoMin = (agoMsec.toDouble() / 60.0 / 1000.0).toInt() - danar_lastconnection.text = DateUtil.timeString(pump.lastConnection) + " (" + resourceHelper.gs(R.string.minago, agoMin) + ")" + danar_lastconnection?.text = DateUtil.timeString(pump.lastConnection) + " (" + resourceHelper.gs(R.string.minago, agoMin) + ")" SetWarnColor.setColor(danar_lastconnection, agoMin.toDouble(), 16.0, 31.0) } if (pump.lastBolusTime != 0L) { @@ -186,46 +186,46 @@ class DanaRFragment : DaggerFragment() { val agoHours = agoMsec.toDouble() / 60.0 / 60.0 / 1000.0 if (agoHours < 6) // max 6h back - danar_lastbolus.text = DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime, resourceHelper) + " " + resourceHelper.gs(R.string.formatinsulinunits, pump.lastBolusAmount) + danar_lastbolus?.text = DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime, resourceHelper) + " " + resourceHelper.gs(R.string.formatinsulinunits, pump.lastBolusAmount) else - danar_lastbolus.text = "" + danar_lastbolus?.text = "" } - danar_dailyunits.text = resourceHelper.gs(R.string.reservoirvalue, pump.dailyTotalUnits, pump.maxDailyTotalUnits) + danar_dailyunits?.text = resourceHelper.gs(R.string.reservoirvalue, pump.dailyTotalUnits, pump.maxDailyTotalUnits) SetWarnColor.setColor(danar_dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9) - danar_basabasalrate.text = "( " + (pump.activeProfile + 1) + " ) " + resourceHelper.gs(R.string.pump_basebasalrate, plugin.baseBasalRate) + danar_basabasalrate?.text = "( " + (pump.activeProfile + 1) + " ) " + resourceHelper.gs(R.string.pump_basebasalrate, plugin.baseBasalRate) // DanaRPlugin, DanaRKoreanPlugin if (activePlugin.activePump.isFakingTempsByExtendedBoluses == true) { - danar_tempbasal.text = activePlugin.activeTreatments.getRealTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() + danar_tempbasal?.text = activePlugin.activeTreatments.getRealTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: "" } else { // v2 plugin - danar_tempbasal.text = activePlugin.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() + danar_tempbasal?.text = activePlugin.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: "" } - danar_extendedbolus.text = activePlugin.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis())?.toString() + danar_extendedbolus?.text = activePlugin.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis())?.toString() ?: "" - danar_reservoir.text = resourceHelper.gs(R.string.reservoirvalue, pump.reservoirRemainingUnits, 300) + danar_reservoir?.text = resourceHelper.gs(R.string.reservoirvalue, pump.reservoirRemainingUnits, 300) SetWarnColor.setColorInverse(danar_reservoir, pump.reservoirRemainingUnits, 50.0, 20.0) - danar_battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}" + danar_battery?.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}" SetWarnColor.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0) - danar_iob.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob) - danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.modelFriendlyName(), pump.hwModel, pump.protocol, pump.productCode) - danar_basalstep.text = pump.basalStep.toString() - danar_bolusstep.text = pump.bolusStep.toString() - danar_serialnumber.text = pump.serialNumber + danar_iob?.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob) + danar_firmware?.text = resourceHelper.gs(R.string.dana_model, pump.modelFriendlyName(), pump.hwModel, pump.protocol, pump.productCode) + danar_basalstep?.text = pump.basalStep.toString() + danar_bolusstep?.text = pump.bolusStep.toString() + danar_serialnumber?.text = pump.serialNumber val status = commandQueue.spannedStatus() if (status.toString() == "") { - danar_queue.visibility = View.GONE + danar_queue?.visibility = View.GONE } else { - danar_queue.visibility = View.VISIBLE - danar_queue.text = status + danar_queue?.visibility = View.VISIBLE + danar_queue?.text = status } //hide user options button if not an RS pump or old firmware // also excludes pump with model 03 because of untested error val isKorean = danaRKoreanPlugin.isEnabled(PluginType.PUMP) if (isKorean || pump.hwModel == 0 || pump.hwModel == 3) { - danar_user_options.visibility = View.GONE + danar_user_options?.visibility = View.GONE } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9f65f79867..9b3e148dc9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -529,7 +529,7 @@ Useful when data from unfiltered sources like xDrip gets noisy. Advanced Settings key_advancedsettings - %1$s\nModel: %2$02X\nProtocol: %3$02X\nCode: %4$02X + %1$s\nModel: %2$02X\nProtocol: %3$02X\nCode: %4$02X Profile Default value: 3 This is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware that’s what is discussed about “3x max daily; 4x current” for safety caps. Default value: 4 This is the other half of the key OpenAPS safety caps, and the other half of “3x max daily; 4x current” of the safety caps. This means your basal, regardless of max basal set on your pump, cannot be any higher than this number times the current level of your basal. This is to prevent people from getting into dangerous territory by setting excessively high max basals before understanding how the algorithm works. Again, the default is 4x; most people will never need to adjust this and are instead more likely to need to adjust other settings if they feel like they are “running into” this safety cap. From c84e7ec326b18de8bdff4f870206e1ccc114896e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 24 Apr 2020 23:23:39 +0200 Subject: [PATCH 018/400] fix tests --- .../utils/extensions/HexByteArrayConversion.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt b/app/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt index 9852ecbbf4..7492135983 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt @@ -1,6 +1,8 @@ package info.nightscout.androidaps.utils.extensions -private val HEX_CHARS = "0123456789ABCDEF".toCharArray() +import java.util.* + +private val HEX_CHARS = "0123456789abcdef".toCharArray() fun ByteArray.toHex() : String{ val result = StringBuffer() @@ -20,9 +22,10 @@ fun String.hexStringToByteArray() : ByteArray { val result = ByteArray(length / 2) + val lowerCased = this.toLowerCase(Locale.getDefault()) for (i in 0 until length step 2) { - val firstIndex = HEX_CHARS.indexOf(this[i]); - val secondIndex = HEX_CHARS.indexOf(this[i + 1]); + val firstIndex = HEX_CHARS.indexOf(lowerCased[i]); + val secondIndex = HEX_CHARS.indexOf(lowerCased[i + 1]); val octet = firstIndex.shl(4).or(secondIndex) result.set(i.shr(1), octet.toByte()) From b42304d836f8ad5ca57b1dbeb344f1c5fd271e3e Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Mon, 27 Apr 2020 20:09:46 +1200 Subject: [PATCH 019/400] Add skip Neutral Temps preference --- .../plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java | 2 +- app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/pref_openapssmb.xml | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java index 4d3a0db704..796eb9ef4e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java @@ -265,7 +265,7 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("exercise_mode", SMBDefaults.exercise_mode); mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target); mProfile.put("maxCOB", SMBDefaults.maxCOB); - mProfile.put("skip_neutral_temps", SMBDefaults.skip_neutral_temps); + mProfile.put("skip_neutral_temps", sp.getBoolean(R.string.key_skip_neutral_temps,SMBDefaults.skip_neutral_temps)); // min_5m_carbimpact is not used within SMB determinebasal //if (mealData.usedMinCarbsImpact > 0) { // mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b0f6821b69..3560471abf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -956,6 +956,9 @@ enableSMB_with_temptarget enableSMB_after_carbs enableSMB_with_high_temptarget + skip_neutral_temps + Skip neutral temp basals + If enabled, sets basal to neutral before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. Enable SMB always Enable SMB always independently to boluses. Possible only with BG source with nice filtering of data like G5 Enable SMB after carbs diff --git a/app/src/main/res/xml/pref_openapssmb.xml b/app/src/main/res/xml/pref_openapssmb.xml index 859a75a82b..09c6ff1221 100644 --- a/app/src/main/res/xml/pref_openapssmb.xml +++ b/app/src/main/res/xml/pref_openapssmb.xml @@ -73,6 +73,12 @@ android:summary="@string/enablesmbaftercarbs_summary" android:title="@string/enablesmbaftercarbs" /> + + Date: Mon, 27 Apr 2020 20:33:41 +1200 Subject: [PATCH 020/400] clarify definition --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3560471abf..c4c96fb42a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -958,7 +958,7 @@ enableSMB_with_high_temptarget skip_neutral_temps Skip neutral temp basals - If enabled, sets basal to neutral before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. + If enabled, it skips setting basal to neutral before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. Enable SMB always Enable SMB always independently to boluses. Possible only with BG source with nice filtering of data like G5 Enable SMB after carbs From a5108ca4c4cce2913eb4a57c0d75ccc401217c24 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 29 Apr 2020 23:27:48 +0200 Subject: [PATCH 021/400] RS injection refactor --- .../dependencyInjection/AppModule.kt | 2 +- .../dependencyInjection/DanaRSCommModule.kt | 79 +++++++++ .../danaRS/comm/DanaRSMessageHashTable.kt | 154 ++++++++---------- .../pump/danaRS/comm/DanaRS_Packet.java | 26 ++- ...RS_Packet_APS_Basal_Set_Temporary_Basal.kt | 8 +- .../comm/DanaRS_Packet_APS_History_Events.kt | 20 +-- .../DanaRS_Packet_APS_Set_Event_History.kt | 8 +- .../DanaRS_Packet_Basal_Get_Basal_Rate.kt | 18 +- ...aRS_Packet_Basal_Get_Profile_Basal_Rate.kt | 14 +- .../DanaRS_Packet_Basal_Get_Profile_Number.kt | 12 +- ..._Packet_Basal_Get_Temporary_Basal_State.kt | 12 +- .../DanaRS_Packet_Basal_Set_Basal_Rate.kt | 8 +- ...Packet_Basal_Set_Cancel_Temporary_Basal.kt | 8 +- ...aRS_Packet_Basal_Set_Profile_Basal_Rate.kt | 8 +- .../DanaRS_Packet_Basal_Set_Profile_Number.kt | 8 +- .../DanaRS_Packet_Basal_Set_Suspend_Off.kt | 8 +- .../DanaRS_Packet_Basal_Set_Suspend_On.kt | 8 +- ...DanaRS_Packet_Basal_Set_Temporary_Basal.kt | 8 +- .../DanaRS_Packet_Bolus_Get_Bolus_Option.kt | 15 +- .../DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt | 12 +- ...acket_Bolus_Get_Calculation_Information.kt | 11 +- ...et_Carbohydrate_Calculation_Information.kt | 12 +- .../DanaRS_Packet_Bolus_Get_Dual_Bolus.kt | 12 +- .../DanaRS_Packet_Bolus_Get_Extended_Bolus.kt | 12 +- ...S_Packet_Bolus_Get_Extended_Bolus_State.kt | 12 +- ...et_Bolus_Get_Extended_Menu_Option_State.kt | 12 +- .../DanaRS_Packet_Bolus_Get_Initial_Bolus.kt | 8 +- ...Packet_Bolus_Get_Step_Bolus_Information.kt | 13 +- .../DanaRS_Packet_Bolus_Set_Bolus_Option.kt | 8 +- .../DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt | 8 +- .../DanaRS_Packet_Bolus_Set_Dual_Bolus.kt | 9 +- .../DanaRS_Packet_Bolus_Set_Extended_Bolus.kt | 9 +- ..._Packet_Bolus_Set_Extended_Bolus_Cancel.kt | 8 +- .../DanaRS_Packet_Bolus_Set_Initial_Bolus.kt | 8 +- ...anaRS_Packet_Bolus_Set_Step_Bolus_Start.kt | 11 +- ...DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt | 13 +- .../comm/DanaRS_Packet_Etc_Keep_Connection.kt | 8 +- .../DanaRS_Packet_Etc_Set_History_Save.kt | 9 +- .../DanaRS_Packet_General_Delivery_Status.kt | 8 +- ...aRS_Packet_General_Get_More_Information.kt | 10 +- .../DanaRS_Packet_General_Get_Password.kt | 12 +- .../DanaRS_Packet_General_Get_Pump_Check.kt | 14 +- ...Packet_General_Get_Shipping_Information.kt | 12 +- ...aRS_Packet_General_Get_Shipping_Version.kt | 10 +- ...Packet_General_Get_Today_Delivery_Total.kt | 12 +- ...acket_General_Get_User_Time_Change_Flag.kt | 8 +- ...cket_General_Initial_Screen_Information.kt | 10 +- ..._Packet_General_Set_History_Upload_Mode.kt | 8 +- ...General_Set_User_Time_Change_Flag_Clear.kt | 9 +- .../danaRS/comm/DanaRS_Packet_History_.kt | 10 +- .../comm/DanaRS_Packet_History_Alarm.kt | 10 +- .../comm/DanaRS_Packet_History_All_History.kt | 10 +- .../comm/DanaRS_Packet_History_Basal.kt | 10 +- .../DanaRS_Packet_History_Blood_Glucose.kt | 10 +- .../comm/DanaRS_Packet_History_Bolus.kt | 10 +- .../DanaRS_Packet_History_Carbohydrate.kt | 10 +- .../comm/DanaRS_Packet_History_Daily.kt | 10 +- .../comm/DanaRS_Packet_History_Prime.kt | 10 +- .../comm/DanaRS_Packet_History_Refill.kt | 10 +- .../comm/DanaRS_Packet_History_Suspend.kt | 6 +- .../comm/DanaRS_Packet_History_Temporary.kt | 10 +- .../danaRS/comm/DanaRS_Packet_Notify_Alarm.kt | 14 +- .../DanaRS_Packet_Notify_Delivery_Complete.kt | 14 +- ...aRS_Packet_Notify_Delivery_Rate_Display.kt | 13 +- ...DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt | 8 +- .../DanaRS_Packet_Option_Get_Pump_Time.kt | 10 +- .../DanaRS_Packet_Option_Get_User_Option.kt | 12 +- .../DanaRS_Packet_Option_Set_Pump_Time.kt | 6 +- .../DanaRS_Packet_Option_Set_User_Option.kt | 11 +- .../comm/DanaRS_Packet_Review_Bolus_Avg.kt | 8 +- ...DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt | 10 +- .../plugins/pump/danaRS/services/BLEComm.kt | 4 +- .../pump/danaRS/services/DanaRSService.kt | 104 ++++++------ .../danaRS/comm/DanaRSMessageHashTableTest.kt | 26 ++- ...acket_APS_Basal_Set_Temporary_BasalTest.kt | 22 ++- .../DanaRS_Packet_APS_History_EventsTest.kt | 20 ++- ...DanaRS_Packet_APS_Set_Event_HistoryTest.kt | 18 +- .../DanaRS_Packet_Basal_Get_Basal_RateTest.kt | 14 +- ...Packet_Basal_Get_Profile_Basal_RateTest.kt | 23 ++- ...aRS_Packet_Basal_Get_Profile_NumberTest.kt | 13 +- ...ket_Basal_Get_Temporary_Basal_StateTest.kt | 13 +- .../DanaRS_Packet_Basal_Set_Basal_RateTest.kt | 12 +- ...et_Basal_Set_Cancel_Temporary_BasalTest.kt | 12 +- ...Packet_Basal_Set_Profile_Basal_RateTest.kt | 12 +- ...aRS_Packet_Basal_Set_Profile_NumberTest.kt | 12 +- ...DanaRS_Packet_Basal_Set_Suspend_OffTest.kt | 12 +- .../DanaRS_Packet_Basal_Set_Suspend_OnTest.kt | 12 +- ...RS_Packet_Basal_Set_Temporary_BasalTest.kt | 13 +- ...anaRS_Packet_Bolus_Get_Bolus_OptionTest.kt | 15 +- ...anaRS_Packet_Bolus_Get_CIR_CF_ArrayTest.kt | 15 +- ...t_Bolus_Get_Calculation_InformationTest.kt | 13 +- ...arbohydrate_Calculation_InformationTest.kt | 13 +- .../DanaRS_Packet_Bolus_Get_Dual_BolusTest.kt | 15 +- ...aRS_Packet_Bolus_Get_Extended_BolusTest.kt | 13 +- ...cket_Bolus_Get_Extended_Bolus_StateTest.kt | 13 +- ...olus_Get_Extended_Menu_Option_StateTest.kt | 15 +- ...naRS_Packet_Bolus_Get_Initial_BolusTest.kt | 14 +- ...et_Bolus_Get_Step_Bolus_InformationTest.kt | 13 +- ...anaRS_Packet_Bolus_Set_Bolus_OptionTest.kt | 14 +- ...anaRS_Packet_Bolus_Set_CIR_CF_ArrayTest.kt | 14 +- .../DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt | 14 +- ...aRS_Packet_Bolus_Set_Extended_BolusTest.kt | 14 +- ...ket_Bolus_Set_Extended_Bolus_CancelTest.kt | 14 +- ...naRS_Packet_Bolus_Set_Initial_BolusTest.kt | 14 +- ...S_Packet_Bolus_Set_Step_Bolus_StartTest.kt | 13 +- ...RS_Packet_Bolus_Set_Step_Bolus_StopTest.kt | 14 +- .../DanaRS_Packet_Etc_Keep_ConnectionTest.kt | 14 +- .../DanaRS_Packet_Etc_Set_History_SaveTest.kt | 12 +- ...naRS_Packet_General_Delivery_StatusTest.kt | 12 +- ...Packet_General_Get_More_InformationTest.kt | 15 +- .../DanaRS_Packet_General_Get_PasswordTest.kt | 17 +- ...anaRS_Packet_General_Get_Pump_CheckTest.kt | 17 +- ...et_General_Get_Shipping_InformationTest.kt | 15 +- ...Packet_General_Get_Shipping_VerisonTest.kt | 13 +- ...et_General_Get_Today_Delivery_TotalTest.kt | 17 +- ...t_General_Get_User_Time_Change_FlagTest.kt | 16 +- ..._General_Initial_Screen_InformationTest.kt | 17 +- ...ket_General_Set_History_Upload_ModeTest.kt | 14 +- ...ral_Set_User_Time_Change_Flag_ClearTest.kt | 14 +- .../comm/DanaRS_Packet_History_AlarmTest.kt | 13 +- .../DanaRS_Packet_History_All_HistoryTest.kt | 15 +- .../comm/DanaRS_Packet_History_BasalTest.kt | 15 +- ...DanaRS_Packet_History_Blood_GlucoseTest.kt | 15 +- .../comm/DanaRS_Packet_History_BolusTest.kt | 15 +- .../DanaRS_Packet_History_CarbohydrateTest.kt | 15 +- .../comm/DanaRS_Packet_History_DailyTest.kt | 15 +- .../comm/DanaRS_Packet_History_PrimeTest.kt | 15 +- .../comm/DanaRS_Packet_History_RefillTest.kt | 15 +- .../comm/DanaRS_Packet_History_SuspendTest.kt | 15 +- .../DanaRS_Packet_History_TemporaryTest.kt | 15 +- .../comm/DanaRS_Packet_Notify_AlarmTest.kt | 14 +- ...aRS_Packet_Notify_Delivery_CompleteTest.kt | 14 +- ...Packet_Notify_Delivery_Rate_DisplayTest.kt | 14 +- ...RS_Packet_Notify_Missed_Bolus_AlarmTest.kt | 14 +- .../DanaRS_Packet_Option_Get_Pump_TimeTest.kt | 13 +- ...anaRS_Packet_Option_Get_User_OptionTest.kt | 15 +- .../DanaRS_Packet_Option_Set_Pump_TimeTest.kt | 14 +- ...anaRS_Packet_Option_Set_User_OptionTest.kt | 15 +- .../DanaRS_Packet_Review_Bolus_AvgTest.kt | 12 +- ...RS_Packet_Review_Get_Pump_Dec_RatioTest.kt | 15 +- 140 files changed, 1396 insertions(+), 646 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/dependencyInjection/DanaRSCommModule.kt diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index 6d334aa3d4..44fdc075f7 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -74,7 +74,7 @@ import info.nightscout.androidaps.utils.wizard.BolusWizard import info.nightscout.androidaps.utils.wizard.QuickWizardEntry import javax.inject.Singleton -@Module(includes = [AppModule.AppBindings::class, PluginsModule::class]) +@Module(includes = [AppModule.AppBindings::class, PluginsModule::class, DanaRSCommModule::class]) open class AppModule { @Provides diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DanaRSCommModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DanaRSCommModule.kt new file mode 100644 index 0000000000..fa915f8246 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DanaRSCommModule.kt @@ -0,0 +1,79 @@ +package info.nightscout.androidaps.dependencyInjection + +import dagger.Module +import dagger.android.ContributesAndroidInjector +import info.nightscout.androidaps.plugins.pump.danaRS.comm.* + +@Module +@Suppress("unused") +abstract class DanaRSCommModule { + + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet(): DanaRS_Packet + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(): DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Basal_Rate(): DanaRS_Packet_Basal_Get_Basal_Rate + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Profile_Basal_Rate(): DanaRS_Packet_Basal_Get_Profile_Basal_Rate + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Profile_Number(): DanaRS_Packet_Basal_Get_Profile_Number + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Basal_Rate(): DanaRS_Packet_Basal_Set_Basal_Rate + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Profile_Basal_Rate(): DanaRS_Packet_Basal_Set_Profile_Basal_Rate + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Profile_Number(): DanaRS_Packet_Basal_Set_Profile_Number + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Suspend_Off(): DanaRS_Packet_Basal_Set_Suspend_Off + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Suspend_On(): DanaRS_Packet_Basal_Set_Suspend_On + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Set_Temporary_Basal(): DanaRS_Packet_Basal_Set_Temporary_Basal + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Basal_Get_Temporary_Basal_State(): DanaRS_Packet_Basal_Get_Temporary_Basal_State + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Bolus_Option(): DanaRS_Packet_Bolus_Get_Bolus_Option + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Initial_Bolus(): DanaRS_Packet_Bolus_Get_Initial_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Calculation_Information(): DanaRS_Packet_Bolus_Get_Calculation_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(): DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_CIR_CF_Array(): DanaRS_Packet_Bolus_Get_CIR_CF_Array + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Dual_Bolus(): DanaRS_Packet_Bolus_Get_Dual_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Bolus(): DanaRS_Packet_Bolus_Get_Extended_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Bolus_State(): DanaRS_Packet_Bolus_Get_Extended_Bolus_State + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(): DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Step_Bolus_Information(): DanaRS_Packet_Bolus_Get_Step_Bolus_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Bolus_Option(): DanaRS_Packet_Bolus_Set_Bolus_Option + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Initial_Bolus(): DanaRS_Packet_Bolus_Set_Initial_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_CIR_CF_Array(): DanaRS_Packet_Bolus_Set_CIR_CF_Array + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Dual_Bolus(): DanaRS_Packet_Bolus_Set_Dual_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Extended_Bolus(): DanaRS_Packet_Bolus_Set_Extended_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(): DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Step_Bolus_Start(): DanaRS_Packet_Bolus_Set_Step_Bolus_Start + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Step_Bolus_Stop(): DanaRS_Packet_Bolus_Set_Step_Bolus_Stop + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Etc_Keep_Connection(): DanaRS_Packet_Etc_Keep_Connection + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Etc_Set_History_Save(): DanaRS_Packet_Etc_Set_History_Save + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Delivery_Status(): DanaRS_Packet_General_Delivery_Status + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Password(): DanaRS_Packet_General_Get_Password + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Initial_Screen_Information(): DanaRS_Packet_General_Initial_Screen_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Alarm(): DanaRS_Packet_Notify_Alarm + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Delivery_Complete(): DanaRS_Packet_Notify_Delivery_Complete + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Delivery_Rate_Display(): DanaRS_Packet_Notify_Delivery_Rate_Display + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Notify_Missed_Bolus_Alarm(): DanaRS_Packet_Notify_Missed_Bolus_Alarm + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Get_Pump_Time(): DanaRS_Packet_Option_Get_Pump_Time + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Get_User_Option(): DanaRS_Packet_Option_Get_User_Option + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Set_Pump_Time(): DanaRS_Packet_Option_Set_Pump_Time + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Set_User_Option(): DanaRS_Packet_Option_Set_User_Option + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_(): DanaRS_Packet_History_ + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Alarm(): DanaRS_Packet_History_Alarm + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_All_History(): DanaRS_Packet_History_All_History + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Basal(): DanaRS_Packet_History_Basal + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Blood_Glucose(): DanaRS_Packet_History_Blood_Glucose + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Bolus(): DanaRS_Packet_History_Bolus + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Review_Bolus_Avg(): DanaRS_Packet_Review_Bolus_Avg + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Carbohydrate(): DanaRS_Packet_History_Carbohydrate + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Daily(): DanaRS_Packet_History_Daily + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_More_Information(): DanaRS_Packet_General_Get_More_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Pump_Check(): DanaRS_Packet_General_Get_Pump_Check + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Shipping_Information(): DanaRS_Packet_General_Get_Shipping_Information + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Today_Delivery_Total(): DanaRS_Packet_General_Get_Today_Delivery_Total + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_User_Time_Change_Flag(): DanaRS_Packet_General_Get_User_Time_Change_Flag + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Prime(): DanaRS_Packet_History_Prime + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Refill(): DanaRS_Packet_History_Refill + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Set_History_Upload_Mode(): DanaRS_Packet_General_Set_History_Upload_Mode + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(): DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Suspend(): DanaRS_Packet_History_Suspend + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_History_Temporary(): DanaRS_Packet_History_Temporary + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_APS_Basal_Set_Temporary_Basal(): DanaRS_Packet_APS_Basal_Set_Temporary_Basal + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_APS_History_Events(): DanaRS_Packet_APS_History_Events + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_APS_Set_Event_History(): DanaRS_Packet_APS_Set_Event_History + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Shipping_Version(): DanaRS_Packet_General_Get_Shipping_Version + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Review_Get_Pump_Dec_Ratio(): DanaRS_Packet_Review_Get_Pump_Dec_Ratio +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt index cb6cbcee17..fea80dc506 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt @@ -1,29 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.logging.AAPSLogger -import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage -import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump -import info.nightscout.androidaps.utils.resources.ResourceHelper -import info.nightscout.androidaps.utils.sharedPreferences.SP import java.util.* import javax.inject.Inject import javax.inject.Singleton @Singleton class DanaRSMessageHashTable @Inject constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, - resourceHelper: ResourceHelper, - danaRPump: DanaRPump, - activePlugin: ActivePluginProvider, - constraintChecker: ConstraintChecker, - detailedBolusInfoStorage: DetailedBolusInfoStorage, - sp: SP, - injector: HasAndroidInjector + val injector: HasAndroidInjector ) { var messages: HashMap = HashMap() @@ -33,78 +17,78 @@ class DanaRSMessageHashTable @Inject constructor( } fun findMessage(command: Int): DanaRS_Packet { - return messages[command] ?: DanaRS_Packet() + return messages[command] ?: DanaRS_Packet(injector) } init { - put(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) - put(DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump)) - put(DanaRS_Packet_Basal_Get_Profile_Basal_Rate(aapsLogger, danaRPump)) - put(DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump)) - put(DanaRS_Packet_Basal_Set_Basal_Rate(aapsLogger, arrayOf())) - put(DanaRS_Packet_Basal_Set_Profile_Basal_Rate(aapsLogger, 0, arrayOf())) - put(DanaRS_Packet_Basal_Set_Profile_Number(aapsLogger)) - put(DanaRS_Packet_Basal_Set_Suspend_Off(aapsLogger)) - put(DanaRS_Packet_Basal_Set_Suspend_On(aapsLogger)) - put(DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger)) - put(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Initial_Bolus(aapsLogger)) - put(DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_CIR_CF_Array(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Dual_Bolus(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Extended_Bolus(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Set_Bolus_Option(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Initial_Bolus(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_CIR_CF_Array(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Dual_Bolus(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Extended_Bolus(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger)) - put(DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRPump, constraintChecker)) - put(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRPump)) - put(DanaRS_Packet_Etc_Keep_Connection(aapsLogger)) - put(DanaRS_Packet_Etc_Set_History_Save(aapsLogger)) - put(DanaRS_Packet_General_Delivery_Status(aapsLogger)) - put(DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump)) - put(DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_Notify_Alarm(aapsLogger, resourceHelper, rxBus)) - put(DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRPump)) - put(DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRPump)) - put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(aapsLogger)) - put(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) - put(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) - put(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger)) - put(DanaRS_Packet_Option_Set_User_Option(aapsLogger, danaRPump)) - //put(new DanaRS_Packet_History_()); - put(DanaRS_Packet_History_Alarm(aapsLogger, rxBus)) - put(DanaRS_Packet_History_All_History(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Basal(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Bolus(aapsLogger, rxBus)) - put(DanaRS_Packet_Review_Bolus_Avg(aapsLogger)) - put(DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Daily(aapsLogger, rxBus)) - put(DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)) - put(DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)) - put(DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump)) - put(DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger)) - put(DanaRS_Packet_History_Prime(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Refill(aapsLogger, rxBus)) - put(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger)) - put(DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(aapsLogger)) - put(DanaRS_Packet_History_Suspend(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus)) + put(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) + put(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) + put(DanaRS_Packet_Basal_Get_Profile_Basal_Rate(injector)) + put(DanaRS_Packet_Basal_Get_Profile_Number(injector)) + put(DanaRS_Packet_Basal_Set_Basal_Rate(injector, arrayOf())) + put(DanaRS_Packet_Basal_Set_Profile_Basal_Rate(injector, 0, arrayOf())) + put(DanaRS_Packet_Basal_Set_Profile_Number(injector)) + put(DanaRS_Packet_Basal_Set_Suspend_Off(injector)) + put(DanaRS_Packet_Basal_Set_Suspend_On(injector)) + put(DanaRS_Packet_Basal_Set_Temporary_Basal(injector)) + put(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) + put(DanaRS_Packet_Bolus_Get_Bolus_Option(injector)) + put(DanaRS_Packet_Bolus_Get_Initial_Bolus(injector)) + put(DanaRS_Packet_Bolus_Get_Calculation_Information(injector)) + put(DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(injector)) + put(DanaRS_Packet_Bolus_Get_CIR_CF_Array(injector)) + put(DanaRS_Packet_Bolus_Get_Dual_Bolus(injector)) + put(DanaRS_Packet_Bolus_Get_Extended_Bolus(injector)) + put(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(injector)) + put(DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(injector)) + put(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(injector)) + put(DanaRS_Packet_Bolus_Set_Bolus_Option(injector)) + put(DanaRS_Packet_Bolus_Set_Initial_Bolus(injector)) + put(DanaRS_Packet_Bolus_Set_CIR_CF_Array(injector)) + put(DanaRS_Packet_Bolus_Set_Dual_Bolus(injector)) + put(DanaRS_Packet_Bolus_Set_Extended_Bolus(injector)) + put(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(injector)) + put(DanaRS_Packet_Bolus_Set_Step_Bolus_Start(injector)) + put(DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(injector)) + put(DanaRS_Packet_Etc_Keep_Connection(injector)) + put(DanaRS_Packet_Etc_Set_History_Save(injector)) + put(DanaRS_Packet_General_Delivery_Status(injector)) + put(DanaRS_Packet_General_Get_Password(injector)) + put(DanaRS_Packet_General_Initial_Screen_Information(injector)) + put(DanaRS_Packet_Notify_Alarm(injector)) + put(DanaRS_Packet_Notify_Delivery_Complete(injector)) + put(DanaRS_Packet_Notify_Delivery_Rate_Display(injector)) + put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(injector)) + put(DanaRS_Packet_Option_Get_Pump_Time(injector)) + put(DanaRS_Packet_Option_Get_User_Option(injector)) + put(DanaRS_Packet_Option_Set_Pump_Time(injector)) + put(DanaRS_Packet_Option_Set_User_Option(injector)) + //put(new DanaRS_Packet_History_(injector)); + put(DanaRS_Packet_History_Alarm(injector)) + put(DanaRS_Packet_History_All_History(injector)) + put(DanaRS_Packet_History_Basal(injector)) + put(DanaRS_Packet_History_Blood_Glucose(injector)) + put(DanaRS_Packet_History_Bolus(injector)) + put(DanaRS_Packet_Review_Bolus_Avg(injector)) + put(DanaRS_Packet_History_Carbohydrate(injector)) + put(DanaRS_Packet_History_Daily(injector)) + put(DanaRS_Packet_General_Get_More_Information(injector)) + put(DanaRS_Packet_General_Get_Pump_Check(injector)) + put(DanaRS_Packet_General_Get_Shipping_Information(injector)) + put(DanaRS_Packet_General_Get_Today_Delivery_Total(injector)) + put(DanaRS_Packet_General_Get_User_Time_Change_Flag(injector)) + put(DanaRS_Packet_History_Prime(injector)) + put(DanaRS_Packet_History_Refill(injector)) + put(DanaRS_Packet_General_Set_History_Upload_Mode(injector)) + put(DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(injector)) + put(DanaRS_Packet_History_Suspend(injector)) + put(DanaRS_Packet_History_Temporary(injector)) // APS - put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0)) - put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, injector, 0)) - put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, 0, 0, 0, 0)) + put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(injector, 0)) + put(DanaRS_Packet_APS_History_Events(injector, 0)) + put(DanaRS_Packet_APS_Set_Event_History(injector, 0, 0, 0, 0)) // v3 - put(DanaRS_Packet_General_Get_Shipping_Version(aapsLogger, danaRPump)) - put(DanaRS_Packet_Review_Get_Pump_Dec_Ratio(aapsLogger, danaRPump)) + put(DanaRS_Packet_General_Get_Shipping_Version(injector)) + put(DanaRS_Packet_Review_Get_Pump_Dec_Ratio(injector)) } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java index 9bb70720fb..275ba6f145 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java @@ -3,16 +3,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm; import android.annotation.TargetApi; import android.os.Build; +import dagger.android.HasAndroidInjector; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.logging.AAPSLogger; +import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption; + import org.slf4j.Logger; import java.nio.charset.StandardCharsets; import java.util.Date; +import javax.inject.Inject; + import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; public class DanaRS_Packet { - private static final Logger log = StacktraceLoggerWrapper.getLogger(DanaRS_Packet.class); + + @Inject AAPSLogger aapsLogger; + + protected HasAndroidInjector injector; protected static final int TYPE_START = 0; protected static final int OPCODE_START = 1; @@ -23,9 +33,11 @@ public class DanaRS_Packet { protected int type = BleEncryption.DANAR_PACKET__TYPE_RESPONSE; // most of the messages, should be changed for others protected int opCode; - public DanaRS_Packet() { + public DanaRS_Packet(HasAndroidInjector injector) { received = false; failed = false; + this.injector = injector; + injector.androidInjector().inject(this); } public void setReceived() { @@ -54,7 +66,7 @@ public class DanaRS_Packet { // STATIC FUNCTIONS - public static int getCommand(byte[] data) { + public int getCommand(byte[] data) { int type = byteArrayToInt(getBytes(data, TYPE_START, 1)); int opCode = byteArrayToInt(getBytes(data, OPCODE_START, 1)); return ((type & 0xFF) << 8) + (opCode & 0xFF); @@ -70,7 +82,7 @@ public class DanaRS_Packet { return "UNKNOWN_PACKET"; } - protected static byte[] getBytes(byte[] data, int srcStart, int srcLength) { + protected byte[] getBytes(byte[] data, int srcStart, int srcLength) { try { byte[] ret = new byte[srcLength]; @@ -78,7 +90,7 @@ public class DanaRS_Packet { return ret; } catch (Exception e) { - log.error("Unhandled exception", e); + aapsLogger.error(LTag.PUMPBTCOMM, "Unhandled exception", e); } return null; } @@ -148,7 +160,7 @@ public class DanaRS_Packet { return new String(strbuff, StandardCharsets.UTF_8); } - public static long dateFromBuff(byte[] buff, int offset) { + public long dateFromBuff(byte[] buff, int offset) { return new Date( 100 + byteArrayToInt(getBytes(buff, offset, 1)), @@ -159,7 +171,7 @@ public class DanaRS_Packet { @TargetApi(Build.VERSION_CODES.KITKAT) - public static String asciiStringFromBuff(byte[] buff, int offset, int length) { + public String asciiStringFromBuff(byte[] buff, int offset, int length) { byte[] strbuff = new byte[length]; System.arraycopy(buff, offset, strbuff, 0, length); for (int pos = 0; pos < length; pos++) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt index 89a2c3fac3..bfcfeac676 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_APS_Basal_Set_Temporary_Basal( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var percent: Int -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { var temporaryBasalRatio = 0 var temporaryBasalDuration = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt index 5ca6eac5a2..14da2a9b8e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt @@ -10,7 +10,6 @@ import info.nightscout.androidaps.db.TemporaryBasal import info.nightscout.androidaps.dialogs.FillDialog import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.interfaces.ActivePluginProvider -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.common.bolusInfo.DetailedBolusInfoStorage @@ -20,18 +19,19 @@ import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import java.util.* +import javax.inject.Inject open class DanaRS_Packet_APS_History_Events( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val activePlugin: ActivePluginProvider, - private val danaRPump: DanaRPump, - private val detailedBolusInfoStorage: DetailedBolusInfoStorage, - private val sp: SP, - private val injector: HasAndroidInjector, + injector: HasAndroidInjector, private var from: Long -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var activePlugin: ActivePluginProvider + @Inject lateinit var danaRPump: DanaRPump + @Inject lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage + @Inject lateinit var sp: SP private var year = 0 private var month = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt index 861854d77b..7f6c1e342f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt @@ -1,19 +1,19 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import java.util.* class DanaRS_Packet_APS_Set_Event_History( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var packetType: Int, private var time: Long, private var param1: Int, private var param2: Int -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt index 8cdbbe2d65..b25bc2c587 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt @@ -1,23 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* +import javax.inject.Inject class DanaRS_Packet_Basal_Get_Basal_Rate( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE @@ -31,7 +33,7 @@ class DanaRS_Packet_Basal_Get_Basal_Rate( dataIndex += dataSize dataSize = 1 danaRPump.basalStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100.0 - danaRPump.pumpProfiles = Array(4) {Array(48) {0.0} } + danaRPump.pumpProfiles = Array(4) { Array(48) { 0.0 } } var i = 0 val size = 24 while (i < size) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt index 9b0de5603c..bbac168239 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt @@ -1,16 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import java.util.* +import javax.inject.Inject open class DanaRS_Packet_Basal_Get_Profile_Basal_Rate( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump, + injector: HasAndroidInjector, private val profileNumber: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_BASAL_RATE @@ -26,7 +28,7 @@ open class DanaRS_Packet_Basal_Get_Profile_Basal_Rate( override fun handleMessage(data: ByteArray) { var dataIndex = DATA_START var dataSize = 2 - danaRPump.pumpProfiles = Array(4) {Array(48) {0.0} } + danaRPump.pumpProfiles = Array(4) { Array(48) { 0.0 } } var i = 0 val size = 24 while (i < size) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt index bdd586e948..c973a5aa11 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Basal_Get_Profile_Number( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt index bb5f0d8d98..709438d8df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt @@ -1,16 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil +import javax.inject.Inject import kotlin.math.ceil class DanaRS_Packet_Basal_Get_Temporary_Basal_State( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt index 28d7b6b693..f16bc7c0cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Basal_Rate( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var profileBasalRate: Array -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt index c30b938002..c7fa4c3536 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt index 189a704e0c..ddf0adba78 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt @@ -1,14 +1,14 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Profile_Basal_Rate( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var profileNumber: Int, private var profileBasalRate: Array -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_BASAL_RATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt index 2056889532..7c0994196b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Profile_Number( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var profileNumber: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt index eff81eb0bb..3608ee30ca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Suspend_Off( - private val aapsLogger: AAPSLogger - ) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt index e3a3f9d228..df5bee1aac 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Basal_Set_Suspend_On( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt index f4318fb0b3..cbd91aa051 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt @@ -1,14 +1,14 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption open class DanaRS_Packet_Basal_Set_Temporary_Basal( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var temporaryBasalRatio: Int = 0, private var temporaryBasalDuration: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_TEMPORARY_BASAL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt index 8918094938..432f0792dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt @@ -1,23 +1,24 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Bolus_Option( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { -) : DanaRS_Packet() { + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt index d981da5033..4af5c48fac 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_CIR_CF_Array( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CIR_CF_ARRAY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt index 6c19045a2f..8f618bce4f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt @@ -1,15 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Calculation_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CALCULATION_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt index c1bd0aeb40..ad7a5de3b7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt index 97d40dd0af..8334d04028 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Dual_Bolus( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt index 9d96debe56..4795b08482 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Extended_Bolus( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt index ef24b5cec1..ecf337987e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Extended_Bolus_State( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt index cd16a68bb7..001107cfa2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt index 50f5864e81..c301490a9f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Get_Initial_Bolus( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt index dca14ce099..6a90788340 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt @@ -1,17 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime -import java.util.* +import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_STEP_BOLUS_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt index 21d9b39d56..ebf19f1459 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt @@ -1,11 +1,11 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Bolus_Option( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var extendedBolusOptionOnOff: Int = 0, private var bolusCalculationOption: Int = 0, private var missedBolusConfig: Int = 0, @@ -26,7 +26,7 @@ class DanaRS_Packet_Bolus_Set_Bolus_Option( private var missedBolus04EndHour: Int = 0, private var missedBolus04EndMin: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_OPTION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt index 137c1633b6..cf2bfa44d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt @@ -1,11 +1,11 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_CIR_CF_Array( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var cir01: Int = 0, private var cir02: Int = 0, private var cir03: Int = 0, @@ -20,7 +20,7 @@ class DanaRS_Packet_Bolus_Set_CIR_CF_Array( private var cf05: Int = 0, private var cf06: Int = 0, private var cf07: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_CIR_CF_ARRAY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt index 919039319b..d9c18cb839 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt @@ -1,16 +1,15 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Dual_Bolus( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var amount: Double = 0.0, private var extendedAmount: Double = 0.0, private var extendedBolusDurationInHalfHours: Int = 0 -) : DanaRS_Packet() { - +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_DUAL_BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt index 222152c2a8..095f9f5080 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt @@ -1,15 +1,14 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Extended_Bolus( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var extendedAmount: Double = 0.0, private var extendedBolusDurationInHalfHours: Int = 0 -) : DanaRS_Packet() { - +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt index 868dd5f7b6..4b36940aaf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt index eecd43c6ca..0229c9434c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt @@ -1,16 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Bolus_Set_Initial_Bolus( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var bolusRate01: Int = 0, private var bolusRate02: Int = 0, private var bolusRate03: Int = 0, private var bolusRate04: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_RATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt index d9dc8f0d95..9dfc6016c7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt @@ -1,20 +1,21 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.Constraint -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Bolus_Set_Step_Bolus_Start( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump, - constraintChecker: ConstraintChecker, + injector: HasAndroidInjector, private var amount: Double = 0.0, private var speed: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { + @Inject lateinit var danaRPump: DanaRPump + @Inject lateinit var constraintChecker: ConstraintChecker init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_START diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt index c5c1ace3b4..cf42e445ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt @@ -1,21 +1,22 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject open class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_STOP diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt index 1038881c2e..89ae76b68e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Etc_Keep_Connection( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt index ae1fac6bff..2859aa8496 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt @@ -1,11 +1,11 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Etc_Set_History_Save( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var historyType: Int = 0, private var historyYear: Int = 0, private var historyMonth: Int = 0, @@ -15,8 +15,7 @@ class DanaRS_Packet_Etc_Set_History_Save( private var historySecond: Int = 0, private var historyCode: Int = 0, private var historyValue: Int = 0 -) : DanaRS_Packet() { - +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt index 21937923fc..eb71b50be1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_General_Delivery_Status( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt index eb7d617d3b..2d0dee2c53 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt @@ -1,16 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime +import javax.inject.Inject class DanaRS_Packet_General_Get_More_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt index 58cdf77ae9..dcbbb54136 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_General_Get_Password( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt index be57043e89..dc942cdfe9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification @@ -9,13 +9,15 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject class DanaRS_Packet_General_Get_Pump_Check( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_CHECK diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt index 6bf3296af1..99eed59d76 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt @@ -1,15 +1,17 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil +import javax.inject.Inject class DanaRS_Packet_General_Get_Shipping_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt index 9d3d83fbf4..e13912f666 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt @@ -1,15 +1,17 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import java.nio.charset.Charset +import javax.inject.Inject class DanaRS_Packet_General_Get_Shipping_Version( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_GENERAL__GET_SHIPPING_VERSION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt index fe9c676ca9..2075528d8a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_General_Get_Today_Delivery_Total( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt index 45e68600d7..6ff8fa6231 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_General_Get_User_Time_Change_Flag( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt index 0510c28271..586577be09 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_General_Initial_Screen_Information( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt index e26e13e6f0..969dd36c87 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_General_Set_History_Upload_Mode( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var mode: Int = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SET_HISTORY_UPLOAD_MODE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt index 969f226fb0..4190545f99 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt @@ -1,17 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR aapsLogger.debug(LTag.PUMPCOMM, "New message") } + override fun handleMessage(data: ByteArray) { val result = intFromBuff(data, 0, 1) if (result == 0) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt index 4273f6ca0d..00b00a0fc0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt @@ -1,8 +1,8 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.db.DanaRHistoryRecord -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.danaR.comm.RecordTypes @@ -10,12 +10,14 @@ import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime import java.util.* +import javax.inject.Inject abstract class DanaRS_Packet_History_( - protected val aapsLogger: AAPSLogger, - protected val rxBus: RxBusWrapper, + injector: HasAndroidInjector, protected val from: Long -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper protected var year = 0 protected var month = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt index bcf3ffc1df..eef5b0bac1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Alarm @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__ALARM diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt index 2b42507888..298d0005c9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_All_History( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt index 09173ed5c1..afd2469f64 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Basal @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BASAL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt index 7f07e71680..eda50d6749 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Blood_Glucose @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt index d6f8b51707..6970681afb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Bolus @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt index ed3b49a8d7..2ddeae6a9a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Carbohydrate @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt index 645cab8272..4ce5d88af5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Daily @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__DAILY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt index da209b0a8a..93dd90576f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Prime @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__PRIME diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt index 8b470a0170..adeff980df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Refill @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__REFILL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt index 2e5ad23dd9..614b728971 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt @@ -1,15 +1,15 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper class DanaRS_Packet_History_Suspend @JvmOverloads constructor( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SUSPEND diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt index 5689ca82c5..045457a699 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_History_Temporary( - aapsLogger: AAPSLogger, - rxBus: RxBusWrapper, + injector: HasAndroidInjector, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(injector, from) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt index f461c65f3c..de92b18367 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt @@ -1,20 +1,22 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject class DanaRS_Packet_Notify_Alarm( - private val aapsLogger: AAPSLogger, - private val resourceHelper: ResourceHelper, - private val rxBus: RxBusWrapper -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper init { type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt index c4e5d5a06d..fd059dfe57 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt @@ -1,21 +1,23 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject import kotlin.math.min class DanaRS_Packet_Notify_Delivery_Complete( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt index 0a256ed088..27d6c011a8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt @@ -1,22 +1,23 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject import kotlin.math.min class DanaRS_Packet_Notify_Delivery_Rate_Display( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, - private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var danaRPump: DanaRPump init { type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt index f15582f3d0..afe2599866 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Notify_Missed_Bolus_Alarm( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt index 4db309afe0..e6bca23320 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt @@ -1,16 +1,18 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime +import javax.inject.Inject class DanaRS_Packet_Option_Get_Pump_Time( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt index a012b1302b..6e44cdace8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Option_Get_User_Option( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt index 73cf49c6df..d6bb703beb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt @@ -1,15 +1,15 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime class DanaRS_Packet_Option_Set_Pump_Time( - private val aapsLogger: AAPSLogger, + injector: HasAndroidInjector, private var time: Long = 0 -) : DanaRS_Packet() { +) : DanaRS_Packet(injector) { var error = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt index d266bf765b..01ca99c2e5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt @@ -1,15 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Option_Set_User_Option( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__SET_USER_OPTION diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt index ee953d8581..04751087eb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption class DanaRS_Packet_Review_Bolus_Avg( - private val aapsLogger: AAPSLogger -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt index 23d903de0b..182f58c3fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt @@ -1,14 +1,16 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -import info.nightscout.androidaps.logging.AAPSLogger +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption +import javax.inject.Inject class DanaRS_Packet_Review_Get_Pump_Dec_Ratio( - private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump -) : DanaRS_Packet() { + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaRPump: DanaRPump init { opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_DEC_RATIO diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt index e46aff33d7..255a86d1f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -5,6 +5,7 @@ import android.content.Context import android.content.Intent import android.os.SystemClock import android.util.Base64 +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.logging.AAPSLogger @@ -33,6 +34,7 @@ import javax.inject.Singleton @Singleton class BLEComm @Inject internal constructor( + private val injector: HasAndroidInjector, private val aapsLogger: AAPSLogger, private val resourceHelper: ResourceHelper, private val context: Context, @@ -695,7 +697,7 @@ class BLEComm @Inject internal constructor( // process common packet response private fun processMessage(decryptedBuffer: ByteArray) { val originalCommand = processedMessage?.command ?: 0xFFFF - val receivedCommand = DanaRS_Packet.getCommand(decryptedBuffer) + val receivedCommand = DanaRS_Packet(injector).getCommand(decryptedBuffer) val message: DanaRS_Packet? = if (originalCommand == receivedCommand) { // it's response to last message processedMessage diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt index 3d8a5c6a40..9c2e37214e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt @@ -112,25 +112,25 @@ class DanaRSService : DaggerService() { fun readPumpStatus() { try { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus))) - sendMessage(DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_General_Initial_Screen_Information(injector)) rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingextendedbolusstatus))) - sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(injector)) rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))) - sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)) // last bolus, bolusStep, maxBolus + sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(injector)) // last bolus, bolusStep, maxBolus rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingtempbasalstatus))) - sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) danaRPump.lastConnection = System.currentTimeMillis() val profile = profileFunction.getProfile() val pump = activePlugin.activePump if (profile != null && abs(danaRPump.currentBasal - profile.basal) >= pump.pumpDescription.basalStep) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))) - sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump)) // basal profile, basalStep, maxBasal + sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) // basal profile, basalStep, maxBasal if (!pump.isThisProfileSet(profile) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE)) { rxBus.send(EventProfileNeedsUpdate()) } } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))) - sendMessage(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Option_Get_Pump_Time(injector)) var timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L if (danaRPump.pumpTime == 0L) { // initial handshake was not successful @@ -143,14 +143,14 @@ class DanaRSService : DaggerService() { val now = System.currentTimeMillis() if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))) - sendMessage(DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)) // serial no - sendMessage(DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)) // firmware - sendMessage(DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump)) - sendMessage(DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)) // isExtendedEnabled - sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump)) // basal profile, basalStep, maxBasal - sendMessage(DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump)) // target - sendMessage(DanaRS_Packet_Bolus_Get_CIR_CF_Array(aapsLogger, danaRPump)) - sendMessage(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) // Getting user options + sendMessage(DanaRS_Packet_General_Get_Shipping_Information(injector)) // serial no + sendMessage(DanaRS_Packet_General_Get_Pump_Check(injector)) // firmware + sendMessage(DanaRS_Packet_Basal_Get_Profile_Number(injector)) + sendMessage(DanaRS_Packet_Bolus_Get_Bolus_Option(injector)) // isExtendedEnabled + sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) // basal profile, basalStep, maxBasal + sendMessage(DanaRS_Packet_Bolus_Get_Calculation_Information(injector)) // target + sendMessage(DanaRS_Packet_Bolus_Get_CIR_CF_Array(injector)) + sendMessage(DanaRS_Packet_Option_Get_User_Option(injector)) // Getting user options danaRPump.lastSettingsRead = now } aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds") @@ -172,13 +172,13 @@ class DanaRSService : DaggerService() { return } else { if (danaRPump.protocol >= 6) { - sendMessage(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now())) + sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, DateUtil.now())) } else { waitForWholeMinute() // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cut off anyway) - sendMessage(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now() + T.secs(10).msecs())) + sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, DateUtil.now() + T.secs(10).msecs())) } - sendMessage(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Option_Get_Pump_Time(injector)) timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds") } @@ -211,10 +211,10 @@ class DanaRSService : DaggerService() { SystemClock.sleep(1000) val msg: DanaRS_Packet_APS_History_Events if (lastHistoryFetched == 0L) { - msg = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, injector, 0) + msg = DanaRS_Packet_APS_History_Events(injector, 0) aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history") } else { - msg = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, injector, lastHistoryFetched) + msg = DanaRS_Packet_APS_History_Events(injector, lastHistoryFetched) aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)) } sendMessage(msg) @@ -228,7 +228,7 @@ class DanaRSService : DaggerService() { } fun setUserSettings(): PumpEnactResult { - sendMessage(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Option_Get_User_Option(injector)) return PumpEnactResult(injector).success(true) } @@ -243,11 +243,11 @@ class DanaRSService : DaggerService() { danaRPump.bolusStopped = false danaRPump.bolusStopForced = false danaRPump.bolusProgressLastTimeStamp = DateUtil.now() - val start = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRPump, constraintChecker, insulin, preferencesSpeed) + val start = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(injector, insulin, preferencesSpeed) if (carbs > 0) { // MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbTime, carbs); #### // sendMessage(msg); - val msgSetHistoryEntryV2 = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, carbTime, carbs, 0) + val msgSetHistoryEntryV2 = DanaRS_Packet_APS_Set_Event_History(injector, DanaRPump.CARBS, carbTime, carbs, 0) sendMessage(msgSetHistoryEntryV2) lastHistoryFetched = min(lastHistoryFetched, carbTime - T.mins(1).msecs()) } @@ -291,7 +291,7 @@ class DanaRSService : DaggerService() { override fun run() { // reread bolus status rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))) - sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)) // last bolus + sendMessage(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(injector)) // last bolus bolusingEvent.percent = 100 rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.disconnecting))) } @@ -301,7 +301,7 @@ class DanaRSService : DaggerService() { fun bolusStop() { aapsLogger.debug(LTag.PUMPCOMM, "bolusStop >>>>> @ " + if (bolusingTreatment == null) "" else bolusingTreatment?.insulin) - val stop = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRPump) + val stop = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(injector) danaRPump.bolusStopForced = true if (isConnected) { sendMessage(stop) @@ -318,13 +318,13 @@ class DanaRSService : DaggerService() { if (!isConnected) return false if (danaRPump.isTempBasalInProgress) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) SystemClock.sleep(500) } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger, percent, durationInHours)) + sendMessage(DanaRS_Packet_Basal_Set_Temporary_Basal(injector, percent, durationInHours)) SystemClock.sleep(200) - sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -333,12 +333,12 @@ class DanaRSService : DaggerService() { fun highTempBasal(percent: Int): Boolean { if (danaRPump.isTempBasalInProgress) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) SystemClock.sleep(500) } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) - sendMessage(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)) - sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(injector, percent)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -351,12 +351,12 @@ class DanaRSService : DaggerService() { } if (danaRPump.isTempBasalInProgress) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) SystemClock.sleep(500) } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))) - sendMessage(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)) - sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(injector, percent)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -365,8 +365,8 @@ class DanaRSService : DaggerService() { fun tempBasalStop(): Boolean { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))) - sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)) - sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(injector)) + sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -375,9 +375,9 @@ class DanaRSService : DaggerService() { fun extendedBolus(insulin: Double, durationInHalfHours: Int): Boolean { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus))) - sendMessage(DanaRS_Packet_Bolus_Set_Extended_Bolus(aapsLogger, insulin, durationInHalfHours)) + sendMessage(DanaRS_Packet_Bolus_Set_Extended_Bolus(injector, insulin, durationInHalfHours)) SystemClock.sleep(200) - sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -386,8 +386,8 @@ class DanaRSService : DaggerService() { fun extendedBolusStop(): Boolean { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus))) - sendMessage(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger)) - sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) + sendMessage(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(injector)) + sendMessage(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(injector)) loadEvents() rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)) return true @@ -397,9 +397,9 @@ class DanaRSService : DaggerService() { if (!isConnected) return false rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates))) val basal = danaRPump.buildDanaRProfileRecord(profile) - val msgSet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(aapsLogger, 0, basal) + val msgSet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(injector, 0, basal) sendMessage(msgSet) - val msgActivate = DanaRS_Packet_Basal_Set_Profile_Number(aapsLogger, 0) + val msgActivate = DanaRS_Packet_Basal_Set_Profile_Number(injector, 0) sendMessage(msgActivate) danaRPump.lastSettingsRead = 0 // force read full settings readPumpStatus() @@ -412,25 +412,25 @@ class DanaRSService : DaggerService() { if (!isConnected) return result var msg: DanaRS_Packet_History_? = null when (type) { - RecordTypes.RECORD_TYPE_ALARM -> msg = DanaRS_Packet_History_Alarm(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_PRIME -> msg = DanaRS_Packet_History_Prime(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_BASALHOUR -> msg = DanaRS_Packet_History_Basal(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_BOLUS -> msg = DanaRS_Packet_History_Bolus(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_CARBO -> msg = DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_DAILY -> msg = DanaRS_Packet_History_Daily(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_GLUCOSE -> msg = DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_REFILL -> msg = DanaRS_Packet_History_Refill(aapsLogger, rxBus) - RecordTypes.RECORD_TYPE_SUSPEND -> msg = DanaRS_Packet_History_Suspend(aapsLogger, rxBus) + RecordTypes.RECORD_TYPE_ALARM -> msg = DanaRS_Packet_History_Alarm(injector) + RecordTypes.RECORD_TYPE_PRIME -> msg = DanaRS_Packet_History_Prime(injector) + RecordTypes.RECORD_TYPE_BASALHOUR -> msg = DanaRS_Packet_History_Basal(injector) + RecordTypes.RECORD_TYPE_BOLUS -> msg = DanaRS_Packet_History_Bolus(injector) + RecordTypes.RECORD_TYPE_CARBO -> msg = DanaRS_Packet_History_Carbohydrate(injector) + RecordTypes.RECORD_TYPE_DAILY -> msg = DanaRS_Packet_History_Daily(injector) + RecordTypes.RECORD_TYPE_GLUCOSE -> msg = DanaRS_Packet_History_Blood_Glucose(injector) + RecordTypes.RECORD_TYPE_REFILL -> msg = DanaRS_Packet_History_Refill(injector) + RecordTypes.RECORD_TYPE_SUSPEND -> msg = DanaRS_Packet_History_Suspend(injector) } if (msg != null) { - sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 1)) + sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(injector, 1)) SystemClock.sleep(200) sendMessage(msg) while (!msg.done && isConnected) { SystemClock.sleep(100) } SystemClock.sleep(200) - sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 0)) + sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(injector, 0)) } result.success = true result.comment = "OK" diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt index c5ed222313..d50ee1ba25 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt @@ -1,11 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import org.junit.Assert import org.junit.Test @@ -16,19 +17,36 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, DanaRSPlugin::class) +@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class) class DanaRSMessageHashTableTest : DanaRSTestBase() { @Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var constraintChecker: ConstraintChecker @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet) { + it.aapsLogger = aapsLogger + } + if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Start) { + it.constraintChecker = constraintChecker + } + if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Start) { + it.danaRPump = danaRPump + } + if (it is DanaRS_Packet_APS_History_Events) { + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) - val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin, constraintChecker, detailedBolusInfoStorage, sp, injector) - val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, 0, 0, 0) + val danaRSMessageHashTable = DanaRSMessageHashTable(packetInjector) + val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, 0, 0, 0) val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command) Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong()) } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.kt index 835a56be84..8672867161 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,30 +12,38 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_APS_Basal_Set_Temporary_Basal) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { // under 100% should last 30 min - var packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0) + var packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 0) Assert.assertEquals(0, packet.temporaryBasalRatio) Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM30MIN, packet.temporaryBasalDuration) //constructor with param - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 10) + packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 10) Assert.assertEquals(10, packet.temporaryBasalRatio) Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM30MIN, packet.temporaryBasalDuration) // over 100% should last 15 min - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 150) + packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 150) Assert.assertEquals(150, packet.temporaryBasalRatio) Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM15MIN, packet.temporaryBasalDuration) // test low hard limit - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, -1) + packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, -1) Assert.assertEquals(0, packet.temporaryBasalRatio) Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM30MIN, packet.temporaryBasalDuration) // test high hard limit - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 550) + packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 550) Assert.assertEquals(500, packet.temporaryBasalRatio) Assert.assertEquals(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.PARAM15MIN, packet.temporaryBasalDuration) // test message generation - packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 260) + packet = DanaRS_Packet_APS_Basal_Set_Temporary_Basal(packetInjector, 260) val generatedCode = packet.requestParams Assert.assertEquals(3, generatedCode.size.toLong()) Assert.assertEquals(4.toByte(), generatedCode[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt index 49871ade89..97c7fbe1a5 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage @@ -20,10 +22,24 @@ class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() { @Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_APS_History_Events) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.activePlugin = activePlugin + it.danaRPump = danaRPump + it.detailedBolusInfoStorage = detailedBolusInfoStorage + it.sp = sp + } + } + } + @Test fun runTest() { val now = DateUtil.now() - val testPacket = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRPump, detailedBolusInfoStorage, sp, injector, now) + val testPacket = DanaRS_Packet_APS_History_Events(packetInjector, now) // test getRequestedParams val returnedValues = testPacket.requestParams val expectedValues = getCalender(now) @@ -45,7 +61,7 @@ class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() { Assert.assertEquals("APS_HISTORY_EVENTS", testPacket.friendlyName) } - fun getCalender(from: Long): ByteArray { + private fun getCalender(from: Long): ByteArray { val cal = GregorianCalendar() if (from != 0L) cal.timeInMillis = from else cal[2000, 0, 1, 0, 0] = 0 val ret = ByteArray(6) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt index 33e343ee08..b252c07830 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.utils.DateUtil import org.junit.Assert @@ -12,21 +14,29 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_APS_Set_Event_HistoryTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_APS_Set_Event_History) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { // test for negative carbs val now = DateUtil.now() - var historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, -1, 0) + var historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, now, -1, 0) var testparams = historyTest.requestParams Assert.assertEquals(0.toByte(), testparams[8]) // 5g carbs - historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, 5, 0) + historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, now, 5, 0) testparams = historyTest.requestParams Assert.assertEquals(5.toByte(), testparams[8]) // 150g carbs - historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, 150, 0) + historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, now, 150, 0) testparams = historyTest.requestParams Assert.assertEquals(150.toByte(), testparams[8]) // test message generation - historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, 5, 0) + historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, now, 5, 0) testparams = historyTest.requestParams Assert.assertEquals(5.toByte(), testparams[8]) Assert.assertEquals(11, testparams.size) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_RateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_RateTest.kt index 2c5b7ffec1..aa79c64b03 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_RateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_RateTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.bus.RxBusWrapper import org.junit.Assert import org.junit.Test @@ -11,9 +13,19 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(RxBusWrapper::class) class DanaRS_Packet_Basal_Get_Basal_RateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Get_Basal_Rate) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } + } + } @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Get_Basal_Rate(aapsLogger, rxBus, resourceHelper, danaRPump) + val packet = DanaRS_Packet_Basal_Get_Basal_Rate(packetInjector) // test message decoding // rate is 0.01 val array = ByteArray(100) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_RateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_RateTest.kt index 59e6356f16..7cc2d5cb5c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_RateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_RateTest.kt @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Basal_Get_Profile_Basal_RateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Get_Profile_Basal_Rate) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val testPacket = DanaRS_Packet_Basal_Get_Profile_Basal_Rate(aapsLogger, danaRPump, 1) + val testPacket = DanaRS_Packet_Basal_Get_Profile_Basal_Rate(packetInjector, 1) // test if pumpProfile array is set right - val basal01 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet.getBytes(createArray(50, 1.toByte()), 2, 2)) / 100.0 - val basal05 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet.getBytes(createArray(50, 5.toByte()), 2, 2)) / 100.0 - val basal12 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet.getBytes(createArray(50, 12.toByte()), 2, 2)) / 100.0 + val basal01 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 1.toByte()), 2, 2)) / 100.0 + val basal05 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 5.toByte()), 2, 2)) / 100.0 + val basal12 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 12.toByte()), 2, 2)) / 100.0 // basal rate > 1U/hr - val basal120 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet.getBytes(createArray(50, 120.toByte()), 2, 2)) / 100.0 + val basal120 = DanaRS_Packet.byteArrayToInt(DanaRS_Packet(packetInjector).getBytes(createArray(50, 120.toByte()), 2, 2)) / 100.0 val params = testPacket.requestParams assertEquals(1.toByte(), params[0]) testPacket.handleMessage(createArray(50, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_NumberTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_NumberTest.kt index f8468573cd..458370fdc5 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_NumberTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_NumberTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Get_Profile_NumberTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Get_Profile_Number) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Basal_Get_Profile_Number(packetInjector) val array = ByteArray(100) putByteToArray(array, 0, 1.toByte()) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt index f8e3472c8e..115dba03b0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Get_Temporary_Basal_State) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Basal_Get_Temporary_Basal_State(packetInjector) // test message decoding val array = ByteArray(100) putByteToArray(array, 0, 1.toByte()) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_RateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_RateTest.kt index d4e2b2de06..58d89e6220 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_RateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_RateTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,9 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Basal_RateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Basal_Rate) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { // test message decoding - val packet = DanaRS_Packet_Basal_Set_Basal_Rate(aapsLogger, createArray(24, 5.0)) + val packet = DanaRS_Packet_Basal_Set_Basal_Rate(packetInjector, createArray(24, 5.0)) val requested = packet.requestParams var lookingFor = (5 * 100 and 0xff).toByte() Assert.assertEquals(lookingFor, requested[24]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest.kt index 4c127cf437..a48dc769eb 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger) + val packet = DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(packetInjector) // test message decoding packet.handleMessage(createArray(3, 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_RateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_RateTest.kt index d2d918726f..035387ac85 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_RateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_RateTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Profile_Basal_RateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Profile_Basal_Rate) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(aapsLogger, 1, createArray(24, 1.0)) + val packet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(packetInjector, 1, createArray(24, 1.0)) // test params val testparams = packet.requestParams // is profile 1 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_NumberTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_NumberTest.kt index 8b15bf2863..a39c2efde9 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_NumberTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_NumberTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Profile_NumberTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Profile_Number) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Profile_Number(aapsLogger, 1) + val packet = DanaRS_Packet_Basal_Set_Profile_Number(packetInjector, 1) // test params val testparams = packet.requestParams // is profile 1 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OffTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OffTest.kt index aa6d5832ad..50ce4c0c35 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OffTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OffTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Suspend_OffTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Suspend_Off) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Suspend_Off(aapsLogger) + val packet = DanaRS_Packet_Basal_Set_Suspend_Off(packetInjector) // test message decoding packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OnTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OnTest.kt index cb12a85d1d..3665cd96b1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OnTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_OnTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Basal_Set_Suspend_OnTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Suspend_On) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Set_Suspend_On(aapsLogger) + val packet = DanaRS_Packet_Basal_Set_Suspend_On(packetInjector) // test message decoding packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, packet.failed) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_BasalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_BasalTest.kt index d15dff5c39..6fccfdcb81 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_BasalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_BasalTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -7,11 +9,18 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Basal_Set_Temporary_BasalTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Basal_Set_Temporary_Basal) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val testPacket = DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger, 50, 20) + val testPacket = DanaRS_Packet_Basal_Set_Temporary_Basal(packetInjector, 50, 20) // params val params = testPacket.requestParams // is ratio 50 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_OptionTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_OptionTest.kt index 1b83b1df86..ac17776c70 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_OptionTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_OptionTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.bus.RxBusWrapper import org.junit.Assert import org.junit.Test @@ -11,8 +13,19 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(RxBusWrapper::class) class DanaRS_Packet_Bolus_Get_Bolus_OptionTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Bolus_Option) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Bolus_Option(packetInjector) // test message decoding //if dataArray is 1 pump.isExtendedBolusEnabled should be true packet.handleMessage(createArray(21, 1.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest.kt index 19f9fc5fbd..997014a92b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest.kt @@ -1,18 +1,27 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_CIR_CF_Array) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_CIR_CF_Array(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_CIR_CF_Array(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_InformationTest.kt index 4a805821b1..f09c01657f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_InformationTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Bolus_Get_Calculation_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Calculation_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Calculation_Information(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(24, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest.kt index b344cf3ade..effd2fa235 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(24, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_BolusTest.kt index 315ac6f045..19ade4619b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_BolusTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Get_Dual_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Dual_Bolus) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Dual_Bolus(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Dual_Bolus(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_BolusTest.kt index a62d960cdc..3d54ad98bc 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_BolusTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Bolus_Get_Extended_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Extended_Bolus) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Extended_Bolus(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Extended_Bolus(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest.kt index c950a2b8e7..1e2af1ae1e 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,17 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Extended_Bolus_State) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Extended_Bolus_State(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest.kt index 4dab05c2cf..c489cc6677 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(34, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_BolusTest.kt index c9f2529bb7..6976effbdb 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_BolusTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Get_Initial_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Initial_Bolus) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Initial_Bolus(aapsLogger) + val packet = DanaRS_Packet_Bolus_Get_Initial_Bolus(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(34, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt index c3ac9a12d6..254862a8db 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -11,8 +13,17 @@ import java.util.* @PrepareForTest() class DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Get_Step_Bolus_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(packetInjector) val array = createArray(13, 0.toByte()) // 11 + 2 putByteToArray(array, 0, 2) // error 2 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_OptionTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_OptionTest.kt index b79f14552b..b4bfc7018a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_OptionTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_OptionTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_Bolus_OptionTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Bolus_Option) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Bolus_Option(aapsLogger, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + val packet = DanaRS_Packet_Bolus_Set_Bolus_Option(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest.kt index df29bd2439..b749f9fb99 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_CIR_CF_Array) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_CIR_CF_Array(aapsLogger, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + val packet = DanaRS_Packet_Bolus_Set_CIR_CF_Array(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt index 0e60b237d7..2aeba32298 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_Dual_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Dual_Bolus) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Dual_Bolus(aapsLogger, 0.0, 0.0, 1) + val packet = DanaRS_Packet_Bolus_Set_Dual_Bolus(packetInjector, 0.0, 0.0, 1) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_BolusTest.kt index 173a87b423..55f3620850 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_BolusTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_Extended_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Extended_Bolus) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus(aapsLogger, 1.0, 1) + val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus(packetInjector, 1.0, 1) // test params val testparams = packet.requestParams Assert.assertEquals(100.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest.kt index adf2ec11f2..2f0615f9c2 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger) + val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(34, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_BolusTest.kt index 29513ced1a..1fb3c6928d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_BolusTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Bolus_Set_Initial_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Initial_Bolus) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Initial_Bolus(aapsLogger, 0, 0, 0, 100) + val packet = DanaRS_Packet_Bolus_Set_Initial_Bolus(packetInjector, 0, 0, 0, 100) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt index 7b740531a0..d4b53cffcd 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt @@ -6,7 +6,6 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import org.junit.Assert @@ -29,8 +28,18 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest : DanaRSTestBase() { private lateinit var danaRSPlugin: DanaRSPlugin + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Start) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + it.constraintChecker = constraintChecker + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(aapsLogger, danaRPump, constraintChecker) + val packet = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(packetInjector) // test params val testparams = packet.requestParams Assert.assertEquals(0.toByte(), testparams[0]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt index 8b0f24ff32..2605b0ba72 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt @@ -4,10 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.utils.DefaultValueHelper import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -23,8 +21,14 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest : DanaRSTestBase() { @Mock lateinit var activePlugin: ActivePluginProvider - private var treatmentInjector: HasAndroidInjector = HasAndroidInjector { + private val packetInjector = HasAndroidInjector { AndroidInjector { + if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Stop) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } if (it is Treatment) { it.defaultValueHelper = defaultValueHelper it.resourceHelper = resourceHelper @@ -37,8 +41,8 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest : DanaRSTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(Mockito.anyInt())).thenReturn("SomeString") - danaRPump.bolusingTreatment = Treatment(treatmentInjector) - val testPacket = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(aapsLogger, rxBus, resourceHelper, danaRPump) + danaRPump.bolusingTreatment = Treatment(packetInjector) + val testPacket = DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(packetInjector) // test message decoding testPacket.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) Assert.assertEquals(false, testPacket.failed) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_ConnectionTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_ConnectionTest.kt index e1b90f30da..1a8b2e6fbc 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_ConnectionTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_ConnectionTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Etc_Keep_ConnectionTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Etc_Keep_Connection) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Etc_Keep_Connection(aapsLogger) + val packet = DanaRS_Packet_Etc_Keep_Connection(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_SaveTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_SaveTest.kt index a089eafd9a..cb82f0b277 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_SaveTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_SaveTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Etc_Set_History_SaveTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Etc_Set_History_Save) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Etc_Set_History_Save(aapsLogger, 0, 0, 0, 0, 0, 0, 0, 0, 2) + val packet = DanaRS_Packet_Etc_Set_History_Save(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 2) // test params val testparams = packet.requestParams Assert.assertEquals(2.toByte(), testparams[8]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_StatusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_StatusTest.kt index fd32e3ca30..6515062bb0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_StatusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_StatusTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_General_Delivery_StatusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Delivery_Status) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_General_Delivery_Status(aapsLogger) + val packet = DanaRS_Packet_General_Delivery_Status(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(15, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt index 12ff721a2b..d3f96c2e11 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -9,13 +11,22 @@ import java.util.* @RunWith(PowerMockRunner::class) class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_More_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Get_More_Information(packetInjector) packet.handleMessage(createArray(14, 0.toByte())) Assert.assertTrue(packet.failed) - packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Get_More_Information(packetInjector) val array = createArray(15, 0.toByte()) // 13 + 2 putIntToArray(array, 0, 600) // iob 6 putIntToArray(array, 2, 1250) // daily units 12.5 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_PasswordTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_PasswordTest.kt index 88f3ac3496..eac2fc9127 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_PasswordTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_PasswordTest.kt @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Get_PasswordTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_Password) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Get_Password(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Get_Password(packetInjector) packet.handleMessage(createArray(15, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_PASSWORD", packet.friendlyName) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_CheckTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_CheckTest.kt index 5248c2b699..ed6a23541f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_CheckTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_CheckTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.bus.RxBusWrapper import org.junit.Assert import org.junit.Test @@ -11,14 +13,25 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(RxBusWrapper::class) class DanaRS_Packet_General_Get_Pump_CheckTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_Pump_Check) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper) + var packet = DanaRS_Packet_General_Get_Pump_Check(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper) + packet = DanaRS_Packet_General_Get_Pump_Check(packetInjector) packet.handleMessage(createArray(15, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_PUMP_CHECK", packet.friendlyName) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt index 3de89db27b..d8c4e0fe66 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -8,15 +10,24 @@ import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) class DanaRS_Packet_General_Get_Shipping_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_Shipping_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Get_Shipping_Information(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) // everything ok :) - packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Get_Shipping_Information(packetInjector) packet.handleMessage(createArray(18, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.friendlyName) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt index f962560115..7aef230f52 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_VerisonTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -8,8 +10,17 @@ import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) class DanaRS_Packet_General_Get_Shipping_VerisonTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_Shipping_Version) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_General_Get_Shipping_Version(aapsLogger, danaRPump) + val packet = DanaRS_Packet_General_Get_Shipping_Version(packetInjector) // test message decoding val ver = byteArrayOf((-78).toByte(), (-127).toByte(), (66).toByte(), (80).toByte(), (78).toByte(), (45).toByte(), (51).toByte(), (46).toByte(), (48).toByte(), (46).toByte(), (48).toByte()) packet.handleMessage(ver) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_TotalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_TotalTest.kt index 1e89db2771..8c2092a425 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_TotalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_TotalTest.kt @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Get_Today_Delivery_TotalTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_Today_Delivery_Total) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Get_Today_Delivery_Total(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Get_Today_Delivery_Total(packetInjector) packet.handleMessage(createArray(18, 0.toByte())) Assert.assertEquals(false, packet.failed) packet.handleMessage(createArray(15, 1.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_FlagTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_FlagTest.kt index 18f89e1096..2dc51fb3af 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_FlagTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_FlagTest.kt @@ -1,23 +1,31 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Get_User_Time_Change_FlagTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Get_User_Time_Change_Flag) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger) + var packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger) + packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(packetInjector) packet.handleMessage(createArray(18, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_USER_TIME_CHANGE_FLAG", packet.friendlyName) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_InformationTest.kt index 15e9f8e99b..9f878e0be1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_InformationTest.kt @@ -1,23 +1,32 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Initial_Screen_InformationTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Initial_Screen_Information) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - var packet = DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Initial_Screen_Information(packetInjector) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Initial_Screen_Information(packetInjector) packet.handleMessage(createArray(17, 1.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals(true, danaRPump.pumpSuspended) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_ModeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_ModeTest.kt index d918e9d682..b0e0867b4c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_ModeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_ModeTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Set_History_Upload_ModeTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Set_History_Upload_Mode) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 1) + val packet = DanaRS_Packet_General_Set_History_Upload_Mode(packetInjector, 1) // test params Assert.assertEquals(1.toByte(), packet.requestParams[0]) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest.kt index 45e472af3c..2ee55972da 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(aapsLogger) + val packet = DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt index bc10832af9..4ebf521537 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.db.DatabaseHelper import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes @@ -26,9 +28,18 @@ class DanaRS_Packet_History_AlarmTest : DanaRSTestBase() { `when`(MainApp.getDbHelper()).thenReturn(databaseHelper) } + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Alarm) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Alarm(aapsLogger, rxBus, 0) + val packet = DanaRS_Packet_History_Alarm(packetInjector, 0) val array = createArray(12, 0.toByte()) // 10 + 2 putByteToArray(array, 0, 0x0A) // record code alarm diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt index 1f7dd00783..8730eaddec 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_All_HistoryTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_All_History) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_All_History(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_All_History(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__ALL_HISTORY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt index 8451e90b0f..08910af3b0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_BasalTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Basal) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Basal(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Basal(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BASAL", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt index 0442ea98b9..c6ad86d977 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_Blood_GlucoseTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Blood_Glucose) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Blood_Glucose(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BLOOD_GLUCOSE", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt index badaa0aa10..0417bc22ae 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_BolusTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Bolus) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Bolus(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Bolus(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BOLUS", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt index 22a99fcc53..8efec691e0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_CarbohydrateTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Carbohydrate) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Carbohydrate(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__CARBOHYDRATE", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt index 91d4bea862..2a4bc6b533 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_DailyTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Daily) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Daily(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Daily(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__DAILY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt index 19c8d2ef4e..f56216ce4c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_PrimeTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Prime) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Prime(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Prime(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__PRIME", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt index 8b75ec344f..d83499bce4 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_RefillTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Refill) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Refill(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Refill(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__REFILL", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt index 66b06f4ed7..f02425c546 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_SuspendTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Suspend) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Suspend(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Suspend(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__SUSPEND", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt index a4e436a373..76dc831eed 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_History_TemporaryTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_History_Temporary) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_History_Temporary(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Temporary(packetInjector, System.currentTimeMillis()) Assert.assertEquals("REVIEW__TEMPORARY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt index 58e0b738db..f10bb50efd 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_AlarmTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import org.junit.Assert import org.junit.Before @@ -13,8 +15,18 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(NSUpload::class) class DanaRS_Packet_Notify_AlarmTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Notify_Alarm) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Notify_Alarm(aapsLogger, resourceHelper, rxBus) + val packet = DanaRS_Packet_Notify_Alarm(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt index 83d9d06182..31c9bbe726 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt @@ -4,10 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.utils.DefaultValueHelper import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -25,8 +23,14 @@ class DanaRS_Packet_Notify_Delivery_CompleteTest : DanaRSTestBase() { @Mock lateinit var danaRSPlugin: DanaRSPlugin @Mock lateinit var activePlugin: ActivePluginProvider - private var treatmentInjector: HasAndroidInjector = HasAndroidInjector { + private val packetInjector = HasAndroidInjector { AndroidInjector { + if (it is DanaRS_Packet_Notify_Delivery_Complete) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } if (it is Treatment) { it.defaultValueHelper = defaultValueHelper it.resourceHelper = resourceHelper @@ -39,8 +43,8 @@ class DanaRS_Packet_Notify_Delivery_CompleteTest : DanaRSTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(anyInt(), anyDouble())).thenReturn("SomeString") - danaRPump.bolusingTreatment = Treatment(treatmentInjector) - val packet = DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRPump) + danaRPump.bolusingTreatment = Treatment(packetInjector) + val packet = DanaRS_Packet_Notify_Delivery_Complete(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt index 69bf3789b1..03712fa1c0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt @@ -7,11 +7,9 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.utils.DefaultValueHelper import org.junit.Assert import org.junit.Before import org.junit.Test @@ -34,8 +32,14 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { private lateinit var danaRSPlugin: DanaRSPlugin - private var treatmentInjector: HasAndroidInjector = HasAndroidInjector { + private val packetInjector = HasAndroidInjector { AndroidInjector { + if (it is DanaRS_Packet_Notify_Delivery_Rate_Display) { + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.danaRPump = danaRPump + } if (it is Treatment) { it.defaultValueHelper = defaultValueHelper it.resourceHelper = resourceHelper @@ -48,7 +52,7 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(ArgumentMatchers.anyInt(), anyObject())).thenReturn("SomeString") // val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(1.0, Treatment(treatmentInjector)) - val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRPump) + val packet = DanaRS_Packet_Notify_Delivery_Rate_Display(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding @@ -64,6 +68,6 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { @Before fun mock() { danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy) - danaRPump.bolusingTreatment = Treatment(treatmentInjector) + danaRPump.bolusingTreatment = Treatment(packetInjector) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_AlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_AlarmTest.kt index 9583c89d4e..9eae04dbec 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_AlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_AlarmTest.kt @@ -1,17 +1,25 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Notify_Missed_Bolus_AlarmTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Notify_Missed_Bolus_Alarm) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Notify_Missed_Bolus_Alarm(aapsLogger) + val packet = DanaRS_Packet_Notify_Missed_Bolus_Alarm(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt index 2ac915644f..4d63163c4b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.joda.time.DateTime import org.junit.Assert import org.junit.Test @@ -9,8 +11,17 @@ import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) class DanaRS_Packet_Option_Get_Pump_TimeTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Option_Get_Pump_Time) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Option_Get_Pump_Time(packetInjector) val array = createArray(8, 0.toByte()) // 6 + 2 putByteToArray(array, 0, 19) // year 2019 putByteToArray(array, 1, 2) // month february diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_OptionTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_OptionTest.kt index 32e3b051c6..4412f5b1fb 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_OptionTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_OptionTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Option_Get_User_OptionTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Option_Get_User_Option) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Option_Get_User_Option(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt index bf34d76510..f2fd2ad61c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -9,12 +11,20 @@ import java.util.* @RunWith(PowerMockRunner::class) class DanaRS_Packet_Option_Set_Pump_TimeTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Option_Set_Pump_Time) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { val date = Date() - val packet = DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, date.time) + val packet = DanaRS_Packet_Option_Set_Pump_Time(packetInjector, date.time) // test params val params = packet.requestParams - Assert.assertEquals((date.year - 100 and 0xff).toByte(), params[0]) // 2019 -> 19 + Assert.assertEquals((date.year - 100 and 0xff).toByte(), params[0]) // 2019 -> 19 Assert.assertEquals((date.month + 1 and 0xff).toByte(), params[1]) Assert.assertEquals((date.date and 0xff).toByte(), params[2]) Assert.assertEquals((date.hours and 0xff).toByte(), params[3]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_OptionTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_OptionTest.kt index 30d076e037..6f53976045 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_OptionTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_OptionTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Option_Set_User_OptionTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Option_Set_User_Option) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Option_Set_User_Option(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Option_Set_User_Option(packetInjector) // test params val params = packet.requestParams Assert.assertEquals((danaRPump.lcdOnTimeSec and 0xff).toByte(), params[3]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_AvgTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_AvgTest.kt index ff5dc4ce80..2842e99c74 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_AvgTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_AvgTest.kt @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -10,8 +12,16 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest() class DanaRS_Packet_Review_Bolus_AvgTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Review_Bolus_Avg) { + it.aapsLogger = aapsLogger + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Review_Bolus_Avg(aapsLogger) + val packet = DanaRS_Packet_Review_Bolus_Avg(packetInjector) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt index 4bd5bbbd1a..9c5a6f824c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_RatioTest.kt @@ -1,17 +1,26 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest() class DanaRS_Packet_Review_Get_Pump_Dec_RatioTest : DanaRSTestBase() { + private val packetInjector = HasAndroidInjector { + AndroidInjector { + if (it is DanaRS_Packet_Review_Get_Pump_Dec_Ratio) { + it.aapsLogger = aapsLogger + it.danaRPump = danaRPump + } + } + } + @Test fun runTest() { - val packet = DanaRS_Packet_Review_Get_Pump_Dec_Ratio(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Review_Get_Pump_Dec_Ratio(packetInjector) val array = ByteArray(100) putByteToArray(array, 0, 4.toByte()) From bce3d3b6b9a1f7b628163d2b07dadddc3f116e74 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 2 May 2020 00:17:39 +0200 Subject: [PATCH 022/400] Verify RSv1 password --- .../dependencyInjection/AppComponent.kt | 3 +- .../dependencyInjection/AppModule.kt | 2 +- .../plugins/pump/danaR/DanaRPump.kt | 6 +- .../plugins/pump/danaRS/DanaRSPlugin.kt | 77 ++++++++++--------- .../plugins/pump/danaRS/services/BLEComm.kt | 21 +++-- app/src/main/res/values/strings.xml | 3 +- app/src/main/res/values/validator.xml | 2 + app/src/main/res/xml/pref_danars.xml | 21 ++--- 8 files changed, 76 insertions(+), 59 deletions(-) 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 91153bd867..0bb89f83c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt @@ -67,7 +67,8 @@ import javax.inject.Singleton PreferencesModule::class, OverviewModule::class, DataClassesModule::class, - SMSModule::class + SMSModule::class, + DanaRSCommModule::class ] ) interface AppComponent : AndroidInjector { diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index 48b599c488..871f88a503 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -74,7 +74,7 @@ import info.nightscout.androidaps.utils.wizard.BolusWizard import info.nightscout.androidaps.utils.wizard.QuickWizardEntry import javax.inject.Singleton -@Module(includes = [AppModule.AppBindings::class, PluginsModule::class, DanaRSCommModule::class]) +@Module(includes = [AppModule.AppBindings::class, PluginsModule::class]) open class AppModule { @Provides diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt index b9a5509b54..8b50a1670a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt @@ -119,6 +119,7 @@ class DanaRPump @Inject constructor( // DanaRS specific var rsPassword = "" + var v3RSPump = false; // User settings var timeDisplayType = 0 @@ -219,7 +220,10 @@ class DanaRPump @Inject constructor( } val isPasswordOK: Boolean - get() = !(password != -1 && password != sp.getInt(R.string.key_danar_password, -1)) + get() = password == sp.getInt(R.string.key_danar_password, -2) + + val isRSPasswordOK: Boolean + get() = rsPassword.equals(sp.getString(R.string.key_danars_password, ""), ignoreCase = true) fun reset() { aapsLogger.debug(LTag.PUMP, "DanaRPump reset") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt index 53062a3c93..7bed59fdfa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt @@ -81,7 +81,15 @@ class DanaRSPlugin @Inject constructor( override fun updatePreferenceSummary(pref: Preference) { super.updatePreferenceSummary(pref) - if (pref.key == resourceHelper.gs(R.string.key_danars_name)) pref.summary = sp.getString(R.string.key_danars_name, "") + + if (pref.key == resourceHelper.gs(R.string.key_danars_name)) { + val value = sp.getStringOrNull(R.string.key_danars_name, null) + pref.summary = value + ?: resourceHelper.gs(R.string.rileylink_error_address_not_set_short) + } + if (pref.key == resourceHelper.gs(R.string.key_danars_password)) { + if (danaRPump.v3RSPump) pref + } } override fun onStart() { @@ -204,7 +212,7 @@ class DanaRSPlugin @Inject constructor( // Pump interface override fun isInitialized(): Boolean { - return danaRPump.lastConnection > 0 && danaRPump.maxBasal > 0 + return danaRPump.lastConnection > 0 && danaRPump.maxBasal > 0 && danaRPump.isRSPasswordOK } override fun isSuspended(): Boolean { @@ -402,7 +410,6 @@ class DanaRSPlugin @Inject constructor( @Synchronized override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult { - val pump = danaRPump val result = PumpEnactResult(injector) var percentAfterConstraint = constraintChecker.applyBasalPercentConstraints(Constraint(percent), profile).value() if (percentAfterConstraint < 0) { @@ -421,8 +428,8 @@ class DanaRSPlugin @Inject constructor( result.success = true result.isTempCancel = false result.comment = resourceHelper.gs(R.string.virtualpump_resultok) - result.duration = pump.tempBasalRemainingMin - result.percent = pump.tempBasalPercent + result.duration = danaRPump.tempBasalRemainingMin + result.percent = danaRPump.tempBasalPercent result.isPercent = true aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: Correct value already set") return result @@ -435,13 +442,13 @@ class DanaRSPlugin @Inject constructor( val durationInHours = max(durationInMinutes / 60, 1) danaRSService?.tempBasal(percentAfterConstraint, durationInHours) ?: false } - if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percentAfterConstraint) { + if (connectionOK && danaRPump.isTempBasalInProgress && danaRPump.tempBasalPercent == percentAfterConstraint) { result.enacted = true result.success = true result.comment = resourceHelper.gs(R.string.virtualpump_resultok) result.isTempCancel = false - result.duration = pump.tempBasalRemainingMin - result.percent = pump.tempBasalPercent + result.duration = danaRPump.tempBasalRemainingMin + result.percent = danaRPump.tempBasalPercent result.isPercent = true aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: OK") return result @@ -454,16 +461,15 @@ class DanaRSPlugin @Inject constructor( } @Synchronized private fun setHighTempBasalPercent(percent: Int): PumpEnactResult { - val pump = danaRPump val result = PumpEnactResult(injector) val connectionOK = danaRSService?.highTempBasal(percent) ?: false - if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) { + if (connectionOK && danaRPump.isTempBasalInProgress && danaRPump.tempBasalPercent == percent) { result.enacted = true result.success = true result.comment = resourceHelper.gs(R.string.virtualpump_resultok) result.isTempCancel = false - result.duration = pump.tempBasalRemainingMin - result.percent = pump.tempBasalPercent + result.duration = danaRPump.tempBasalRemainingMin + result.percent = danaRPump.tempBasalPercent result.isPercent = true aapsLogger.debug(LTag.PUMP, "setHighTempBasalPercent: OK") return result @@ -477,7 +483,6 @@ class DanaRSPlugin @Inject constructor( @Synchronized override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult { - val pump = danaRPump var insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value() // needs to be rounded val durationInHalfHours = max(durationInMinutes / 30, 1) @@ -488,23 +493,23 @@ class DanaRSPlugin @Inject constructor( result.enacted = false result.success = true result.comment = resourceHelper.gs(R.string.virtualpump_resultok) - result.duration = pump.extendedBolusRemainingMinutes - result.absolute = pump.extendedBolusAbsoluteRate + result.duration = danaRPump.extendedBolusRemainingMinutes + result.absolute = danaRPump.extendedBolusAbsoluteRate result.isPercent = false result.isTempCancel = false - aapsLogger.debug(LTag.PUMP, "setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulinAfterConstraint) + aapsLogger.debug(LTag.PUMP, "setExtendedBolus: Correct extended bolus already set. Current: " + danaRPump.extendedBolusAmount + " Asked: " + insulinAfterConstraint) return result } val connectionOK = danaRSService?.extendedBolus(insulinAfterConstraint, durationInHalfHours) ?: false - if (connectionOK && pump.isExtendedInProgress && abs(pump.extendedBolusAbsoluteRate - insulinAfterConstraint) < pumpDescription.extendedBolusStep) { + if (connectionOK && danaRPump.isExtendedInProgress && abs(danaRPump.extendedBolusAbsoluteRate - insulinAfterConstraint) < pumpDescription.extendedBolusStep) { result.enacted = true result.success = true result.comment = resourceHelper.gs(R.string.virtualpump_resultok) result.isTempCancel = false - result.duration = pump.extendedBolusRemainingMinutes - result.absolute = pump.extendedBolusAbsoluteRate - result.bolusDelivered = pump.extendedBolusAmount + result.duration = danaRPump.extendedBolusRemainingMinutes + result.absolute = danaRPump.extendedBolusAbsoluteRate + result.bolusDelivered = danaRPump.extendedBolusAmount result.isPercent = false aapsLogger.debug(LTag.PUMP, "setExtendedBolus: OK") return result @@ -562,9 +567,8 @@ class DanaRSPlugin @Inject constructor( } override fun getJSONStatus(profile: Profile, profileName: String): JSONObject { - val pump = danaRPump val now = System.currentTimeMillis() - if (pump.lastConnection + 5 * 60 * 1000L < System.currentTimeMillis()) { + if (danaRPump.lastConnection + 5 * 60 * 1000L < System.currentTimeMillis()) { return JSONObject() } val pumpJson = JSONObject() @@ -572,13 +576,13 @@ class DanaRSPlugin @Inject constructor( val status = JSONObject() val extended = JSONObject() try { - battery.put("percent", pump.batteryRemaining) - status.put("status", if (pump.pumpSuspended) "suspended" else "normal") - status.put("timestamp", DateUtil.toISOString(pump.lastConnection)) + battery.put("percent", danaRPump.batteryRemaining) + status.put("status", if (danaRPump.pumpSuspended) "suspended" else "normal") + status.put("timestamp", DateUtil.toISOString(danaRPump.lastConnection)) extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION) - if (pump.lastBolusTime != 0L) { - extended.put("LastBolus", DateUtil.dateAndTimeString(pump.lastBolusTime)) - extended.put("LastBolusAmount", pump.lastBolusAmount) + if (danaRPump.lastBolusTime != 0L) { + extended.put("LastBolus", DateUtil.dateAndTimeString(danaRPump.lastBolusTime)) + extended.put("LastBolusAmount", danaRPump.lastBolusAmount) } val tb = treatmentsPlugin.getTempBasalFromHistory(now) if (tb != null) { @@ -601,7 +605,7 @@ class DanaRSPlugin @Inject constructor( pumpJson.put("battery", battery) pumpJson.put("status", status) pumpJson.put("extended", extended) - pumpJson.put("reservoir", pump.reservoirRemainingUnits.toInt()) + pumpJson.put("reservoir", danaRPump.reservoirRemainingUnits.toInt()) pumpJson.put("clock", DateUtil.toISOString(now)) } catch (e: JSONException) { aapsLogger.error("Unhandled exception", e) @@ -626,15 +630,14 @@ class DanaRSPlugin @Inject constructor( } override fun shortStatus(veryShort: Boolean): String { - val pump = danaRPump var ret = "" - if (pump.lastConnection != 0L) { - val agoMillis = System.currentTimeMillis() - pump.lastConnection + if (danaRPump.lastConnection != 0L) { + val agoMillis = System.currentTimeMillis() - danaRPump.lastConnection val agoMin = (agoMillis / 60.0 / 1000.0).toInt() ret += "LastConn: $agoMin minago\n" } - if (pump.lastBolusTime != 0L) - ret += "LastBolus: ${DecimalFormatter.to2Decimal(pump.lastBolusAmount)}U @${DateFormat.format("HH:mm", pump.lastBolusTime)}" + if (danaRPump.lastBolusTime != 0L) + ret += "LastBolus: ${DecimalFormatter.to2Decimal(danaRPump.lastBolusAmount)}U @${DateFormat.format("HH:mm", danaRPump.lastBolusTime)}" val activeTemp = treatmentsPlugin.getRealTempBasalFromHistory(System.currentTimeMillis()) if (activeTemp != null) @@ -645,10 +648,10 @@ class DanaRSPlugin @Inject constructor( ret += "Extended: $activeExtendedBolus\n" if (!veryShort) { - ret += "TDD: ${DecimalFormatter.to0Decimal(pump.dailyTotalUnits)} / ${pump.maxDailyTotalUnits} U" + ret += "TDD: ${DecimalFormatter.to0Decimal(danaRPump.dailyTotalUnits)} / ${danaRPump.maxDailyTotalUnits} U" } - ret += "Reserv: ${DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits)} U" - ret += "Batt: ${pump.batteryRemaining}" + ret += "Reserv: ${DecimalFormatter.to0Decimal(danaRPump.reservoirRemainingUnits)} U" + ret += "Batt: ${danaRPump.batteryRemaining}" return ret } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt index 255a86d1f3..c3a60805d2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt @@ -12,6 +12,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload +import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -22,6 +23,7 @@ import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSMessageHashTabl import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess +import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.extensions.notify import info.nightscout.androidaps.utils.extensions.waitMillis @@ -67,6 +69,7 @@ class BLEComm @Inject internal constructor( set(newValue) { bleEncryption.setEnhancedEncryption(newValue) field = newValue + danaRPump.v3RSPump = newValue } private var isEasyMode: Boolean = false private var isUnitUD: Boolean = false @@ -550,11 +553,19 @@ class BLEComm @Inject internal constructor( var pass: Int = (decryptedBuffer[size - 1].toInt() and 0x000000FF shl 8) + (decryptedBuffer[size - 2].toInt() and 0x000000FF) pass = pass xor 3463 danaRPump.rsPassword = Integer.toHexString(pass) - aapsLogger.debug(LTag.PUMPBTCOMM, "Pump user password: " + Integer.toHexString(pass)) - rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)) - isConnected = true - isConnecting = false - aapsLogger.debug(LTag.PUMPBTCOMM, "RS connected and status read") + aapsLogger.debug(LTag.PUMPBTCOMM, "Pump user password: " + danaRPump.rsPassword) + if (!danaRPump.isRSPasswordOK) { + aapsLogger.error(LTag.PUMPBTCOMM, "Wrong pump password") + rxBus.send(EventNewNotification(Notification(Notification.WRONG_PUMP_PASSWORD, resourceHelper.gs(R.string.wrongpumppassword), Notification.URGENT))) + disconnect("WrongPassword") + SystemClock.sleep(T.mins(1).msecs()) + } else { + rxBus.send(EventDismissNotification(Notification.WRONG_PUMP_PASSWORD)) + rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)) + isConnected = true + isConnecting = false + aapsLogger.debug(LTag.PUMPBTCOMM, "RS connected and status read") + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2fbd5522ea..315b0e66a7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -379,6 +379,7 @@ Refill Suspend Connecting for %1$d s + Pump password (v1 only) Pump password Wrong pump password! Pump is busy @@ -805,7 +806,6 @@ DanaRS Dana Selected pump - Pair new pump Bolus speed danars_bolusspeed Set basal step to 0.01 U/h @@ -1844,4 +1844,5 @@ statuslights_copy_ns Copy NS settings (if exists)? statuslights_overview_advanced + danars_password diff --git a/app/src/main/res/values/validator.xml b/app/src/main/res/values/validator.xml index aef7116a48..4de9c5fab1 100644 --- a/app/src/main/res/values/validator.xml +++ b/app/src/main/res/values/validator.xml @@ -18,11 +18,13 @@ Must be 6 digit number Must be 12 characters of ABCDEF0123456789 Must be 8 characters of ABCDEF0123456789 + Must be 4 characters of ABCDEF0123456789 Not a minimum length Pin should be 3 to 6 digits, not same or in series ^\\d{4} ^[A-F0-9]{12}$ ^[A-F0-9]{8}$ + ^[A-F0-9]{4}$ \ No newline at end of file diff --git a/app/src/main/res/xml/pref_danars.xml b/app/src/main/res/xml/pref_danars.xml index baf7bc4405..1e35b65ee9 100644 --- a/app/src/main/res/xml/pref_danars.xml +++ b/app/src/main/res/xml/pref_danars.xml @@ -8,24 +8,19 @@ app:initialExpandedChildrenCount="0"> + android:key="@string/key_danars_name" + android:summary="" + android:title="@string/selectedpump"> - - Date: Sun, 3 May 2020 17:06:10 +1200 Subject: [PATCH 023/400] Convert to Kotlin --- .../aps/loop/CarbSuggestionReceiver.java | 20 ------------------- .../aps/loop/CarbSuggestionReceiver.kt | 15 ++++++++++++++ 2 files changed, 15 insertions(+), 20 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/CarbSuggestionReceiver.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/CarbSuggestionReceiver.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/CarbSuggestionReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/CarbSuggestionReceiver.java deleted file mode 100644 index fe0b9b3ef4..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/CarbSuggestionReceiver.java +++ /dev/null @@ -1,20 +0,0 @@ -package info.nightscout.androidaps.plugins.aps.loop; - -import android.content.Context; -import android.content.Intent; - -import javax.inject.Inject; - -import dagger.android.DaggerBroadcastReceiver; - -public class CarbSuggestionReceiver extends DaggerBroadcastReceiver { - - @Inject LoopPlugin loopPlugin; - - @Override - public void onReceive(Context context, Intent intent) { - super.onReceive(context, intent); - int duartion = intent.getIntExtra("ignoreDuration", 5); - loopPlugin.disableCarbSuggestions(duartion); - } -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/CarbSuggestionReceiver.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/CarbSuggestionReceiver.kt new file mode 100644 index 0000000000..5382184d15 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/CarbSuggestionReceiver.kt @@ -0,0 +1,15 @@ +package info.nightscout.androidaps.plugins.aps.loop + +import android.content.Context +import android.content.Intent +import dagger.android.DaggerBroadcastReceiver +import javax.inject.Inject + +class CarbSuggestionReceiver : DaggerBroadcastReceiver() { + @Inject lateinit var loopPlugin: LoopPlugin + override fun onReceive(context: Context, intent: Intent) { + super.onReceive(context, intent) + val duration = intent.getIntExtra("ignoreDuration", 5) + loopPlugin.disableCarbSuggestions(duration) + } +} \ No newline at end of file From ad39aabeb3d40dad23ea700aaf51112cdfa885ed Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Sun, 3 May 2020 17:23:51 +1200 Subject: [PATCH 024/400] Refactor messages used for carbs required --- app/src/main/res/values/strings.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8aba55479d..08df1c35b6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -782,8 +782,6 @@ Enable UAM Enable SMB Enable Carbs Suggestions - Minimum Carbs Required For Suggestion - Minimum grams of carbs to display a carbs suggestion alert. Carbs suggestions below this number will not trigger a notification. Use Super Micro Boluses instead of temp basal for faster action Detection of Unannounced meals Enable carbs suggestions when BG is predicted to go below threshold @@ -891,8 +889,8 @@ UAM SMB max minutes Max minutes of basal to limit SMB to for UAM carbsReqThreshold - Carb suggestion threshold - When Carbs are suggested, how many carbs will prompt a notification + Minimum Carbs Required For Suggestion + Minimum grams of carbs to display a carbs suggestion alert. Carbs suggestions below this number will not trigger a notification. Unsupported pump firmware Send BG data to xDrip+ dexcomg5_xdripupload From e1e81ed3e43d724010bfd51eb6d79a90f1c53b0b Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Sun, 3 May 2020 17:24:25 +1200 Subject: [PATCH 025/400] Use Summary text --- app/src/main/res/xml/pref_openapssmb.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/xml/pref_openapssmb.xml b/app/src/main/res/xml/pref_openapssmb.xml index bee0d054d9..12846b91ec 100644 --- a/app/src/main/res/xml/pref_openapssmb.xml +++ b/app/src/main/res/xml/pref_openapssmb.xml @@ -152,6 +152,7 @@ Date: Sun, 3 May 2020 18:04:51 +1200 Subject: [PATCH 026/400] Further refractor and use shared preferences --- .../plugins/aps/openAPSSMB/DetermineBasalResultSMB.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java index 0c0c5e17ed..f84f312329 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java @@ -3,14 +3,17 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMB; import org.json.JSONException; import org.json.JSONObject; +import javax.inject.Inject; + import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.aps.loop.APSResult; import info.nightscout.androidaps.utils.DateUtil; -import info.nightscout.androidaps.utils.SP; +import info.nightscout.androidaps.utils.sharedPreferences.SP; public class DetermineBasalResultSMB extends APSResult { + @Inject SP sp; private double eventualBG; private double snoozeBG; @@ -35,7 +38,7 @@ public class DetermineBasalResultSMB extends APSResult { if (result.has("snoozeBG")) snoozeBG = result.getDouble("snoozeBG"); //if (result.has("insulinReq")) insulinReq = result.getDouble("insulinReq"); - if (SP.getBoolean(R.string.key_smb_enable_carbs_suggestions, false)) { + if (sp.getBoolean(R.string.key_smb_enable_carbs_suggestions, false)) { if (result.has("carbsReq")) carbsReq = result.getInt("carbsReq"); if (result.has("carbsReqWithin")) carbsReqWithin = result.getInt("carbsReqWithin"); } From 017b6187b5ec92d5e46e4d5ff6153040bf6f029f Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Sun, 3 May 2020 23:09:48 +1200 Subject: [PATCH 027/400] Patch determine basal --- app/src/main/assets/OpenAPSSMB/determine-basal.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/OpenAPSSMB/determine-basal.js b/app/src/main/assets/OpenAPSSMB/determine-basal.js index 00a9c1d0a2..18181d25de 100644 --- a/app/src/main/assets/OpenAPSSMB/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMB/determine-basal.js @@ -897,7 +897,8 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // if not in LGS mode, cancel temps before the top of the hour to reduce beeping/vibration // console.error(profile.skip_neutral_temps, rT.deliverAt.getMinutes()); - if ( profile.skip_neutral_temps && rT.deliverAt.getMinutes() >= 55 ) { + //patch determine basal so skip_neutral_temps works as expected + if ( !profile.skip_neutral_temps && rT.deliverAt.getMinutes() >= 55 ) { rT.reason += "; Canceling temp at " + rT.deliverAt.getMinutes() + "m past the hour. "; return tempBasalFunctions.setTempBasal(0, 0, profile, rT, currenttemp); } From 39d011a4ccdf099286772c1b9b9864efdd88f4f3 Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Sun, 3 May 2020 23:10:46 +1200 Subject: [PATCH 028/400] Move to Medtronic driver --- app/src/main/res/xml/pref_medtronic.xml | 6 ++++++ app/src/main/res/xml/pref_openapssmb.xml | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/xml/pref_medtronic.xml b/app/src/main/res/xml/pref_medtronic.xml index fd9a84ab64..c5f4562e1d 100644 --- a/app/src/main/res/xml/pref_medtronic.xml +++ b/app/src/main/res/xml/pref_medtronic.xml @@ -98,6 +98,12 @@ + + \ No newline at end of file diff --git a/app/src/main/res/xml/pref_openapssmb.xml b/app/src/main/res/xml/pref_openapssmb.xml index 09c6ff1221..859a75a82b 100644 --- a/app/src/main/res/xml/pref_openapssmb.xml +++ b/app/src/main/res/xml/pref_openapssmb.xml @@ -73,12 +73,6 @@ android:summary="@string/enablesmbaftercarbs_summary" android:title="@string/enablesmbaftercarbs" /> - - Date: Sun, 3 May 2020 23:11:29 +1200 Subject: [PATCH 029/400] Use different defaults if using Medtronic Pump --- .../aps/openAPSSMB/DetermineBasalAdapterSMBJS.java | 12 ++++++++++-- .../plugins/aps/openAPSSMB/SMBDefaults.java | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java index 796eb9ef4e..16949fcb4c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java @@ -26,10 +26,12 @@ import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.aps.loop.ScriptReader; import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback; +import info.nightscout.androidaps.plugins.common.ManufacturerType; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; @@ -237,7 +239,9 @@ public class DetermineBasalAdapterSMBJS { ) throws JSONException { String units = profile.getUnits(); - Double pumpbolusstep = activePluginProvider.getActivePump().getPumpDescription().bolusStep; + PumpInterface pump = activePluginProvider.getActivePump(); + ManufacturerType manufacturer = pump.manufacturer(); + Double pumpbolusstep = pump.getPumpDescription().bolusStep; mProfile = new JSONObject(); mProfile.put("max_iob", maxIob); @@ -265,7 +269,11 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("exercise_mode", SMBDefaults.exercise_mode); mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target); mProfile.put("maxCOB", SMBDefaults.maxCOB); - mProfile.put("skip_neutral_temps", sp.getBoolean(R.string.key_skip_neutral_temps,SMBDefaults.skip_neutral_temps)); + if (!manufacturer.name().equals("Medtronic")) { + mProfile.put("skip_neutral_temps",SMBDefaults.skip_neutral_temps); + } else { + mProfile.put("skip_neutral_temps", sp.getBoolean(R.string.key_skip_neutral_temps, SMBDefaults.skip_neutral_temps_medtronic)); + } // min_5m_carbimpact is not used within SMB determinebasal //if (mealData.usedMinCarbsImpact > 0) { // mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java index 5f2216b5ae..42eacdbce6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java @@ -38,6 +38,7 @@ public class SMBDefaults { // Essentially, this just limits AMA/SMB as a safety cap against excessive COB entry) public final static int maxCOB = 120; public final static boolean skip_neutral_temps = true; // ***** default false in oref1 ***** if true, don't set neutral temps + public final static boolean skip_neutral_temps_medtronic = false;//if using a medtronic pump default to false so the pump doesnt beep on the hour // unsuspend_if_no_temp:false // if true, pump will un-suspend after a zero temp finishes // bolussnooze_dia_divisor:2 // bolus snooze decays after 1/2 of DIA public final static double min_5m_carbimpact = 8d; // mg/dL per 5m (8 mg/dL/5m corresponds to 24g/hr at a CSF of 4 mg/dL/g (x/5*60/4)) From 3c60b0ff73d090c43650801d84125a69db3d0b62 Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Mon, 4 May 2020 01:41:09 +1200 Subject: [PATCH 030/400] Remove not needed entry and fix keys --- app/src/main/res/values/strings.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 08df1c35b6..82dd0ab796 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -195,7 +195,6 @@ LGS New suggestion available Carbs Suggestion - Unsupported version of NSClient Unsupported version of Nightscout LOOP DISABLED BY CONSTRAINTS Basal IOB @@ -777,8 +776,8 @@ SMB use_smb use_uam - key_smb_enable_carbs_suggestions - key_smb_enable_carbs_suggestions_threshold + smb_enable_carbs_suggestions + smb_enable_carbs_suggestions_threshold Enable UAM Enable SMB Enable Carbs Suggestions From a5f384f07fee1a80a31cb649180f2a3a17ea4d42 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 3 May 2020 16:10:48 +0200 Subject: [PATCH 031/400] forgotten code --- .../nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt index 7bed59fdfa..2960bebf8c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt @@ -87,9 +87,6 @@ class DanaRSPlugin @Inject constructor( pref.summary = value ?: resourceHelper.gs(R.string.rileylink_error_address_not_set_short) } - if (pref.key == resourceHelper.gs(R.string.key_danars_password)) { - if (danaRPump.v3RSPump) pref - } } override fun onStart() { From abb950512289038b9b97bbc05f2db60ccee21881 Mon Sep 17 00:00:00 2001 From: TebbeUbben Date: Sun, 3 May 2020 18:52:26 +0200 Subject: [PATCH 032/400] Insight: Disable vibration on bolus for firmware version 3 --- .../insight/app_layer/remote_control/DeliverBolusMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java index f1b4c3f6de..e15c01cfae 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java @@ -22,7 +22,7 @@ public class DeliverBolusMessage extends AppLayerMessage { @Override protected ByteBuf getData() { ByteBuf byteBuf = new ByteBuf(22); - byteBuf.putUInt16LE(805); + byteBuf.putUInt16LE(31); byteBuf.putUInt16LE(BolusTypeIDs.IDS.getID(bolusType)); byteBuf.putUInt16LE(31); byteBuf.putUInt16LE(0); From 591cef11e522e215ca2a745ec1e0e60cf6d5780e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 3 May 2020 19:48:48 +0200 Subject: [PATCH 033/400] 2.6.1.3 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 38457916a4..cce6b64992 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,7 +109,7 @@ android { targetSdkVersion 28 multiDexEnabled true versionCode 1500 - version "2.6.1.2" + version "2.6.1.3" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' From 1c075c526eac2a38e8f764e00e8049526eabffe4 Mon Sep 17 00:00:00 2001 From: TebbeUbben Date: Mon, 4 May 2020 17:36:37 +0200 Subject: [PATCH 034/400] 2.6.1.4 --- app/build.gradle | 2 +- .../insight/app_layer/remote_control/DeliverBolusMessage.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index cce6b64992..893f13632c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,7 +109,7 @@ android { targetSdkVersion 28 multiDexEnabled true versionCode 1500 - version "2.6.1.3" + version "2.6.1.4" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java index e15c01cfae..e0d0f2461a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java @@ -22,7 +22,7 @@ public class DeliverBolusMessage extends AppLayerMessage { @Override protected ByteBuf getData() { ByteBuf byteBuf = new ByteBuf(22); - byteBuf.putUInt16LE(31); + byteBuf.putUInt16LE(252); byteBuf.putUInt16LE(BolusTypeIDs.IDS.getID(bolusType)); byteBuf.putUInt16LE(31); byteBuf.putUInt16LE(0); From ad472beb4abbde281ab0222d2ee2d077bedcfe8b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 6 May 2020 01:27:38 +0200 Subject: [PATCH 035/400] danars di start --- app/build.gradle | 1 + .../dependencyInjection/ActivitiesModule.kt | 4 -- .../dependencyInjection/AppComponent.kt | 4 +- .../general/maintenance/ImportExportPrefs.kt | 4 +- .../res/layout/danars_blescanner_item.xml | 33 --------- app/src/main/res/values/strings.xml | 6 -- danars/.gitignore | 1 + danars/build.gradle | 71 +++++++++++++++++++ danars/consumer-rules.pro | 0 danars/proguard-rules.pro | 21 ++++++ danars/src/main/AndroidManifest.xml | 6 ++ .../DanaRSActivitiesModule.kt | 14 ++++ .../pump/danaRS/activities/BLEScanActivity.kt | 2 +- .../activities/PairingHelperActivity.kt | 0 .../danaRS/dialogs/PairingProgressDialog.java | 8 +-- .../danaRS/events/EventDanaRSDeviceChange.kt | 0 .../events/EventDanaRSPairingSuccess.kt | 0 .../res/layout/danars_blescanner_activity.xml | 6 +- .../res/layout/danars_blescanner_item.xml | 27 +++++++ .../layout/danars_pairingprogressdialog.xml | 0 danars/src/main/res/values/strings.xml | 14 ++++ settings.gradle | 2 +- 22 files changed, 169 insertions(+), 55 deletions(-) delete mode 100644 app/src/main/res/layout/danars_blescanner_item.xml create mode 100644 danars/.gitignore create mode 100644 danars/build.gradle create mode 100644 danars/consumer-rules.pro create mode 100644 danars/proguard-rules.pro create mode 100644 danars/src/main/AndroidManifest.xml create mode 100644 danars/src/main/java/info/nightscout/androidaps/danars/dependencyInjection/DanaRSActivitiesModule.kt rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt (99%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java (94%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/events/EventDanaRSDeviceChange.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/events/EventDanaRSPairingSuccess.kt (100%) rename {app => danars}/src/main/res/layout/danars_blescanner_activity.xml (88%) create mode 100644 danars/src/main/res/layout/danars_blescanner_item.xml rename {app => danars}/src/main/res/layout/danars_pairingprogressdialog.xml (100%) create mode 100644 danars/src/main/res/values/strings.xml diff --git a/app/build.gradle b/app/build.gradle index 8a404945f3..e3a302680b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -243,6 +243,7 @@ dependencies { wearApp project(':wear') implementation project(':core') + implementation project(':danars') implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.google.android.gms:play-services-wearable:17.0.0' diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt index 1afa263919..f4b6e9a27a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt @@ -13,9 +13,7 @@ import info.nightscout.androidaps.plugins.pump.common.dialog.RileyLinkBLEScanAct import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActivity import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRUserOptionsActivity -import info.nightscout.androidaps.plugins.pump.danaRS.activities.BLEScanActivity import info.nightscout.androidaps.plugins.pump.danaRS.activities.EnterPinActivity -import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity import info.nightscout.androidaps.plugins.pump.insight.activities.InsightAlertActivity import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity @@ -26,7 +24,6 @@ import info.nightscout.androidaps.setupwizard.SetupWizardActivity @Suppress("unused") abstract class ActivitiesModule { - @ContributesAndroidInjector abstract fun contributesBLEScanActivity(): BLEScanActivity @ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity @ContributesAndroidInjector abstract fun contributeDanaRHistoryActivity(): DanaRHistoryActivity @ContributesAndroidInjector abstract fun contributeDanaRUserOptionsActivity(): DanaRUserOptionsActivity @@ -39,7 +36,6 @@ abstract class ActivitiesModule { @ContributesAndroidInjector abstract fun contributesLogSettingActivity(): LogSettingActivity @ContributesAndroidInjector abstract fun contributeMainActivity(): MainActivity @ContributesAndroidInjector abstract fun contributesMedtronicHistoryActivity(): MedtronicHistoryActivity - @ContributesAndroidInjector abstract fun contributesPairingHelperActivity(): PairingHelperActivity @ContributesAndroidInjector abstract fun contributesPreferencesActivity(): PreferencesActivity @ContributesAndroidInjector abstract fun contributesQuickWizardListActivity(): QuickWizardListActivity @ContributesAndroidInjector abstract fun contributesRequestDexcomPermissionActivity(): RequestDexcomPermissionActivity 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 f5b4139053..67feb4b4bf 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt @@ -6,6 +6,7 @@ import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjector import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.core.dependencyInjection.CoreModule +import info.nightscout.androidaps.danars.dependencyInjection.DanaRSActivitiesModule import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.ProfileStore import info.nightscout.androidaps.data.PumpEnactResult @@ -71,7 +72,8 @@ import javax.inject.Singleton DataClassesModule::class, SMSModule::class, UIModule::class, - DanaRSCommModule::class + DanaRSCommModule::class, + DanaRSActivitiesModule::class ] ) interface AppComponent : AndroidInjector { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt index b859a1dee5..4d9021bb71 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt @@ -217,7 +217,7 @@ class ImportExportPrefs @Inject constructor( fun importSharedPreferences(fragment: Fragment) { fragment.activity?.let { fragmentAct -> - val callForPrefFile = fragmentAct.prepareCall(PrefsFileContract()) { + val callForPrefFile = fragmentAct.registerForActivityResult(PrefsFileContract()) { it?.let { importSharedPreferences(fragmentAct, it) } @@ -227,7 +227,7 @@ class ImportExportPrefs @Inject constructor( } fun importSharedPreferences(activity: FragmentActivity) { - val callForPrefFile = activity.prepareCall(PrefsFileContract()) { + val callForPrefFile = activity.registerForActivityResult(PrefsFileContract()) { it?.let { importSharedPreferences(activity, it) } diff --git a/app/src/main/res/layout/danars_blescanner_item.xml b/app/src/main/res/layout/danars_blescanner_item.xml deleted file mode 100644 index 2c620b532f..0000000000 --- a/app/src/main/res/layout/danars_blescanner_item.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - \ 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 cc4f698551..a27829b954 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -798,17 +798,11 @@ Activate profile Date INVALID - Waiting for pairing on pump - Pairing OK - Pairing timed out Pairing danars_pairing_key_ danars_v3_randompairing_key_ danars_v3_pairing_key_ danars_v3_randomsync_key_ - danars_address - danars_name - No device found so far Empty reservoir Blood sugar measurement alert Remaining insulin level diff --git a/danars/.gitignore b/danars/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/danars/.gitignore @@ -0,0 +1 @@ +/build diff --git a/danars/build.gradle b/danars/build.gradle new file mode 100644 index 0000000000..96753367b4 --- /dev/null +++ b/danars/build.gradle @@ -0,0 +1,71 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-kapt' + +android { + compileSdkVersion 28 + + defaultConfig { + minSdkVersion 23 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles 'consumer-rules.pro' + } + + kotlinOptions { + jvmTarget = '1.8' + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + debug { + testCoverageEnabled(project.hasProperty('coverage')) + } + firebaseDisable { + System.setProperty("disableFirebase", "true") + ext.enableCrashlytics = false + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation project(':core') + + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion" + + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.core:core-ktx:1.2.0' + implementation "androidx.activity:activity:${activityVersion}" + implementation "androidx.activity:activity-ktx:${activityVersion}" + + + implementation "com.google.dagger:dagger-android:$dagger_version" + implementation "com.google.dagger:dagger-android-support:$dagger_version" + annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version" + annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version" + kapt "com.google.dagger:dagger-android-processor:$dagger_version" + kapt "com.google.dagger:dagger-compiler:$dagger_version" + + //RxBus + implementation "io.reactivex.rxjava2:rxandroid:2.1.1" + + testImplementation 'junit:junit:4.13' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' +} + diff --git a/danars/consumer-rules.pro b/danars/consumer-rules.pro new file mode 100644 index 0000000000..e69de29bb2 diff --git a/danars/proguard-rules.pro b/danars/proguard-rules.pro new file mode 100644 index 0000000000..f1b424510d --- /dev/null +++ b/danars/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/danars/src/main/AndroidManifest.xml b/danars/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..128d47771d --- /dev/null +++ b/danars/src/main/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/dependencyInjection/DanaRSActivitiesModule.kt b/danars/src/main/java/info/nightscout/androidaps/danars/dependencyInjection/DanaRSActivitiesModule.kt new file mode 100644 index 0000000000..269fa7a131 --- /dev/null +++ b/danars/src/main/java/info/nightscout/androidaps/danars/dependencyInjection/DanaRSActivitiesModule.kt @@ -0,0 +1,14 @@ +package info.nightscout.androidaps.danars.dependencyInjection + +import dagger.Module +import dagger.android.ContributesAndroidInjector +import info.nightscout.androidaps.plugins.pump.danaRS.activities.BLEScanActivity +import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity + +@Module +@Suppress("unused") +abstract class DanaRSActivitiesModule { + + @ContributesAndroidInjector abstract fun contributesBLEScanActivity(): BLEScanActivity + @ContributesAndroidInjector abstract fun contributesPairingHelperActivity(): PairingHelperActivity +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt index d51dc5ab05..79024ca402 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt +++ b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/BLEScanActivity.kt @@ -13,8 +13,8 @@ import android.view.View import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.TextView -import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.NoSplashAppCompatActivity +import info.nightscout.androidaps.danars.R import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSDeviceChange diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/PairingHelperActivity.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java similarity index 94% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java index dcf17dc355..48a567c840 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java +++ b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/dialogs/PairingProgressDialog.java @@ -17,7 +17,7 @@ import android.widget.TextView; import javax.inject.Inject; import dagger.android.support.DaggerDialogFragment; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.danars.R; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity; import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess; @@ -63,7 +63,7 @@ public class PairingProgressDialog extends DaggerDialogFragment { if (activity != null) { activity.runOnUiThread(() -> { progressBar.setProgress(100); - statusView.setText(R.string.pairingok); + statusView.setText(R.string.danars_pairingok); try { Thread.sleep(1000); } catch (InterruptedException ignored) { @@ -84,7 +84,7 @@ public class PairingProgressDialog extends DaggerDialogFragment { if (activity != null) { activity.runOnUiThread(() -> { progressBar.setProgress(100); - statusView.setText(R.string.pairingtimedout); + statusView.setText(R.string.danars_pairingtimedout); button.setVisibility(View.VISIBLE); }); } @@ -140,7 +140,7 @@ public class PairingProgressDialog extends DaggerDialogFragment { private void setViews() { progressBar.setMax(100); progressBar.setProgress(0); - statusView.setText(resourceHelper.gs(R.string.waitingforpairing)); + statusView.setText(resourceHelper.gs(R.string.danars_waitingforpairing)); button.setVisibility(View.GONE); button.setOnClickListener(v -> dismiss()); handler.post(runnable); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/events/EventDanaRSDeviceChange.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/events/EventDanaRSDeviceChange.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/events/EventDanaRSDeviceChange.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/events/EventDanaRSDeviceChange.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/events/EventDanaRSPairingSuccess.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/events/EventDanaRSPairingSuccess.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/events/EventDanaRSPairingSuccess.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/events/EventDanaRSPairingSuccess.kt diff --git a/app/src/main/res/layout/danars_blescanner_activity.xml b/danars/src/main/res/layout/danars_blescanner_activity.xml similarity index 88% rename from app/src/main/res/layout/danars_blescanner_activity.xml rename to danars/src/main/res/layout/danars_blescanner_activity.xml index 654f8c1fb6..fe9e25879c 100644 --- a/app/src/main/res/layout/danars_blescanner_activity.xml +++ b/danars/src/main/res/layout/danars_blescanner_activity.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - tools:context=".plugins.pump.danaRS.activities.BLEScanActivity"> + tools:context="info.nightscout.androidaps.plugins.pump.danaRS.activities.BLEScanActivity"> diff --git a/danars/src/main/res/layout/danars_blescanner_item.xml b/danars/src/main/res/layout/danars_blescanner_item.xml new file mode 100644 index 0000000000..9a39302163 --- /dev/null +++ b/danars/src/main/res/layout/danars_blescanner_item.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/danars_pairingprogressdialog.xml b/danars/src/main/res/layout/danars_pairingprogressdialog.xml similarity index 100% rename from app/src/main/res/layout/danars_pairingprogressdialog.xml rename to danars/src/main/res/layout/danars_pairingprogressdialog.xml diff --git a/danars/src/main/res/values/strings.xml b/danars/src/main/res/values/strings.xml new file mode 100644 index 0000000000..f3f951e035 --- /dev/null +++ b/danars/src/main/res/values/strings.xml @@ -0,0 +1,14 @@ + + + danars_address + danars_name + + Pairing + No device found so far + Pairing OK + Pairing timed out + Waiting for pairing on pump + OK + Cancel + + diff --git a/settings.gradle b/settings.gradle index f7c8a5fc0a..cd2caae7bd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':wear', ':core' \ No newline at end of file +include ':app', ':wear', ':core', ':danars' From 5527c3d70d069c49d1d8452a805e723d0fe983fb Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Thu, 7 May 2020 01:04:29 +0100 Subject: [PATCH 036/400] - remove omnipod as option from config builder --- .../androidaps/activities/MyPreferenceFragment.kt | 2 -- .../androidaps/dependencyInjection/ActivitiesModule.kt | 2 -- .../androidaps/dependencyInjection/AppComponent.kt | 3 +-- .../androidaps/dependencyInjection/PluginsModule.kt | 6 ------ 4 files changed, 1 insertion(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt index 91af0ca115..d2057f3c19 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -79,7 +79,6 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang @Inject lateinit var loopPlugin: LoopPlugin @Inject lateinit var localInsightPlugin: LocalInsightPlugin @Inject lateinit var medtronicPumpPlugin: MedtronicPumpPlugin - @Inject lateinit var omnipodPumpPlugin: OmnipodPumpPlugin @Inject lateinit var nsClientPlugin: NSClientPlugin @Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin @Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin @@ -175,7 +174,6 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang addPreferencesFromResourceIfEnabled(localInsightPlugin, rootKey, Config.PUMPDRIVERS) addPreferencesFromResourceIfEnabled(comboPlugin, rootKey, Config.PUMPDRIVERS) addPreferencesFromResourceIfEnabled(medtronicPumpPlugin, rootKey, Config.PUMPDRIVERS) - addPreferencesFromResourceIfEnabled(omnipodPumpPlugin, rootKey, Config.PUMPDRIVERS) addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey, !Config.NSCLIENT) addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey) addPreferencesFromResourceIfEnabled(nsClientPlugin, rootKey) diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt index 3c4add198a..93cac53038 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt @@ -50,7 +50,5 @@ abstract class ActivitiesModule { @ContributesAndroidInjector abstract fun contributesStatsActivity(): StatsActivity @ContributesAndroidInjector abstract fun contributesSurveyActivity(): SurveyActivity @ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity - @ContributesAndroidInjector abstract fun contributesPodManagementActivity(): PodManagementActivity - @ContributesAndroidInjector abstract fun contributesPodHistoryActivity(): PodHistoryActivity } \ No newline at end of file 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 bba9b15298..1bb1595863 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt @@ -69,8 +69,7 @@ import javax.inject.Singleton PreferencesModule::class, OverviewModule::class, DataClassesModule::class, - SMSModule::class, - OmnipodModule::class + SMSModule::class ] ) interface AppComponent : AndroidInjector { 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 c790f58c32..6b726528f7 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt @@ -352,12 +352,6 @@ abstract class PluginsModule { @IntKey(480) abstract fun bindConfigBuilderPlugin(plugin: ConfigBuilderPlugin): PluginBase - @Binds - @PumpDriver - @IntoMap - @IntKey(490) - abstract fun bindOmnipodPumpPlugin(plugin: OmnipodPumpPlugin): PluginBase - @Qualifier annotation class AllConfigs From 24112eb43749b274c90bfb077a7ae5a8864b8745 Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 7 May 2020 08:29:03 +0200 Subject: [PATCH 037/400] Temp Basal icon switched --- .../androidaps/plugins/general/overview/OverviewFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 4a6455e41c..021c3729e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -667,7 +667,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } overview_basebasal?.setTextColor(activeTemp?.let { resourceHelper.gc(R.color.basal) } ?: resourceHelper.gc(R.color.defaulttextcolor)) - overview_basebasal_icon.setImageResource(if (activeTemp != null) R.drawable.icon_cp_basal_start else R.drawable.icon_cp_basal_end) + overview_basebasal_icon.setImageResource(if (activeTemp == null) R.drawable.icon_cp_basal_start else R.drawable.icon_cp_basal_end) // Extended bolus val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) From 120c526b802652be601c03f3db634ed75843562c Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 7 May 2020 09:54:36 +0200 Subject: [PATCH 038/400] move to core --- app/build.gradle | 3 +- .../nightscout/androidaps/RealPumpTest.kt | 4 +- .../info/nightscout/androidaps/Config.java | 15 --- .../java/info/nightscout/androidaps/Config.kt | 15 +++ .../nightscout/androidaps/MainActivity.kt | 5 +- .../info/nightscout/androidaps/MainApp.java | 13 ++- .../activities/MyPreferenceFragment.kt | 26 +++-- .../androidaps/activities/StatsActivity.kt | 4 +- .../androidaps/activities/SurveyActivity.kt | 5 +- .../activities/TDDStatsActivity.java | 2 +- .../androidaps/db/DatabaseHelper.java | 54 ++++++++- .../dependencyInjection/APSModule.kt | 2 +- .../dependencyInjection/AppComponent.kt | 42 ------- .../dependencyInjection/AppModule.kt | 20 ++-- .../dependencyInjection/DataClassesModule.kt | 5 +- .../dependencyInjection/OverviewModule.kt | 8 -- .../dependencyInjection/PluginsModule.kt | 4 - .../dependencyInjection/UIModule.kt | 10 -- .../androidaps/dialogs/CalibrationDialog.kt | 2 +- .../androidaps/dialogs/CarbsDialog.kt | 2 +- .../androidaps/dialogs/CareDialog.kt | 2 +- .../dialogs/DialogFragmentWithDate.kt | 5 +- .../androidaps/dialogs/InsulinDialog.kt | 2 +- .../androidaps/dialogs/ProfileSwitchDialog.kt | 2 +- .../androidaps/dialogs/TempBasalDialog.kt | 2 +- .../androidaps/dialogs/TempTargetDialog.kt | 2 +- .../androidaps/dialogs/WizardDialog.kt | 2 +- .../androidaps/dialogs/WizardInfoDialog.kt | 2 +- .../androidaps/events/EventTreatmentChange.kt | 2 +- .../historyBrowser/HistoryBrowseActivity.kt | 2 +- .../IobCobStaticCalculatorPlugin.kt | 2 +- .../plugins/aps/loop/LoopPlugin.java | 2 +- .../DetermineBasalAdapterAMAJS.java | 2 +- .../aps/openAPSAMA/OpenAPSAMAPlugin.java | 4 +- .../DetermineBasalAdapterSMBJS.java | 2 +- .../aps/openAPSSMB/OpenAPSSMBPlugin.java | 4 +- .../plugins/configBuilder/PluginStore.kt | 5 +- .../objectives/ObjectivesPlugin.kt | 7 +- .../activities/ObjectivesExamDialog.kt | 3 +- .../constraints/safety/SafetyPlugin.java | 7 +- .../general/actions/ActionsFragment.kt | 7 +- .../plugins/general/actions/ActionsPlugin.kt | 7 +- .../general/automation/AutomationPlugin.kt | 6 +- .../automation/actions/ActionNotification.kt | 1 - .../automation/actions/ActionProfileSwitch.kt | 2 +- .../general/automation/elements/InputBg.kt | 2 +- .../automation/elements/InputDateTime.kt | 5 +- .../general/automation/elements/InputTime.kt | 6 +- .../automation/elements/InputTimeRange.kt | 10 +- .../general/automation/triggers/Trigger.kt | 2 +- .../triggers/TriggerRecurringTime.kt | 10 +- .../automation/triggers/TriggerTempTarget.kt | 1 - .../automation/triggers/TriggerTimeRange.kt | 8 +- .../automation/triggers/TriggerWifiSsid.kt | 1 - .../general/careportal/CareportalPlugin.kt | 7 +- .../Dialogs/NewNSTreatmentDialog.java | 11 +- .../dataBroadcaster/DataBroadcastPlugin.kt | 17 ++- .../general/maintenance/MaintenancePlugin.kt | 6 +- .../general/nsclient/NSClientPlugin.java | 10 +- .../plugins/general/nsclient/NSUpload.java | 4 +- .../general/nsclient/data/NSSettingsStatus.kt | 5 +- .../nsclient/services/NSClientService.java | 7 +- .../general/overview/OverviewFragment.kt | 18 +-- .../plugins/general/overview/OverviewMenus.kt | 11 +- .../general/overview/StatusLightHandler.kt | 7 +- .../activities/QuickWizardListActivity.kt | 5 +- .../overview/dialogs/EditQuickWizardDialog.kt | 5 +- .../events/EventOverviewBolusProgress.kt | 2 +- .../general/overview/graphData/GraphData.kt | 2 +- .../notifications/NotificationStore.kt | 5 +- .../PersistentNotificationPlugin.kt | 12 +- .../SmsCommunicatorFragment.kt | 7 +- .../smsCommunicator/SmsCommunicatorPlugin.kt | 10 +- .../general/tidepool/comm/UploadChunk.kt | 2 +- .../general/tidepool/elements/BasalElement.kt | 2 +- .../general/tidepool/elements/BolusElement.kt | 2 +- .../tidepool/elements/WizardElement.kt | 2 +- .../general/wear/ActionStringHandler.kt | 18 +-- .../wearintegration/WatchUpdaterService.java | 7 +- .../xdripStatusline/StatusLinePlugin.kt | 2 +- .../plugins/insulin/ActivityGraph.java | 2 +- .../plugins/insulin/InsulinOrefBasePlugin.kt | 4 +- .../insulin/InsulinOrefFreePeakPlugin.kt | 2 +- .../insulin/InsulinOrefRapidActingPlugin.kt | 2 +- .../InsulinOrefUltraRapidActingPlugin.kt | 2 +- .../IobCobCalculatorPlugin.java | 9 +- .../iobCobCalculator/IobCobOref1Thread.java | 11 +- .../iob/iobCobCalculator/IobCobThread.java | 11 +- .../profile/local/LocalProfilePlugin.kt | 57 +++++---- .../plugins/profile/ns/NSProfileFragment.kt | 2 +- .../plugins/profile/ns/NSProfilePlugin.kt | 11 +- .../plugins/pump/combo/ComboPlugin.java | 4 +- .../pump/common/PumpPluginAbstract.java | 3 +- .../plugins/pump/common/data/PumpStatus.java | 2 +- .../common/defs/PumpHistoryEntryGroup.java | 1 + .../plugins/pump/danaR/DanaRFragment.kt | 5 +- .../plugins/pump/danaR/DanaRPlugin.java | 2 +- .../plugins/pump/danaR/DanaRPump.kt | 4 +- .../danaR/activities/DanaRHistoryActivity.kt | 2 +- .../plugins/pump/danaR/comm/MsgBolusStart.kt | 1 - .../pump/danaR/comm/MsgBolusStartWithSpeed.kt | 1 - .../AbstractDanaRExecutionService.java | 3 +- .../danaR/services/DanaRExecutionService.java | 11 +- .../pump/danaRKorean/DanaRKoreanPlugin.java | 2 +- .../services/DanaRKoreanExecutionService.java | 11 +- .../plugins/pump/danaRS/DanaRSPlugin.java | 4 +- .../danaRS/comm/DanaRSMessageHashTable.kt | 6 +- .../comm/DanaRS_Packet_APS_History_Events.kt | 33 +++--- .../pump/danaRS/services/DanaRSService.java | 9 +- .../plugins/pump/danaRv2/DanaRv2Plugin.java | 2 +- .../pump/danaRv2/comm/MessageHashTableRv2.kt | 6 +- .../pump/danaRv2/comm/MsgHistoryEvents_v2.kt | 31 ++--- .../services/DanaRv2ExecutionService.java | 14 +-- .../pump/insight/LocalInsightFragment.java | 3 +- .../pump/insight/LocalInsightPlugin.java | 9 +- .../medtronic/data/MedtronicHistoryData.java | 3 +- .../omnipod/dialogs/PodManagementActivity.kt | 2 +- .../wizard/initpod/InitActionFragment.java | 3 - .../dialogs/wizard/initpod/InitPodTask.java | 3 +- .../pump/virtual/VirtualPumpFragment.kt | 2 +- .../plugins/pump/virtual/VirtualPumpPlugin.kt | 9 +- .../sensitivity/AbstractSensitivityPlugin.kt | 4 +- .../sensitivity/SensitivityAAPSPlugin.java | 7 +- .../sensitivity/SensitivityOref1Plugin.java | 74 ++++++------ .../SensitivityWeightedAveragePlugin.java | 8 +- .../plugins/source/BGSourceFragment.kt | 7 +- .../plugins/treatments/TreatmentService.java | 1 + .../plugins/treatments/TreatmentsPlugin.java | 5 +- .../fragments/TreatmentsBolusFragment.kt | 4 +- .../TreatmentsExtendedBolusesFragment.kt | 3 +- .../TreatmentsTempTargetFragment.java | 5 +- .../TreatmentsTemporaryBasalsFragment.kt | 2 +- .../androidaps/queue/CommandQueue.kt | 3 +- .../androidaps/receivers/KeepAliveReceiver.kt | 8 +- .../androidaps/setupwizard/SWDefinition.kt | 13 ++- .../elements/SWEditNumberWithUnits.kt | 2 +- .../androidaps/skins/SkinButtonsOn.kt | 6 +- .../androidaps/skins/SkinClassic.kt | 6 +- .../androidaps/utils/LocalAlertUtils.kt | 7 +- .../androidaps/utils/XdripCalibrations.kt | 2 +- .../utils/buildHelper/BuildHelper.kt | 6 +- .../utils/resources/IconsProvider.kt | 10 +- .../nightscout/androidaps/utils/stats/TIR.kt | 2 +- .../androidaps/utils/stats/TddCalculator.kt | 10 +- .../androidaps/utils/stats/TirCalculator.kt | 7 +- .../androidaps/utils/wizard/BolusWizard.kt | 2 +- .../utils/wizard/QuickWizardEntry.kt | 2 +- app/src/main/res/values-nl-rNL/strings.xml | 1 - app/src/main/res/values/colors.xml | 11 -- app/src/main/res/values/strings.xml | 83 -------------- .../info/nightscout/androidaps/TestBase.kt | 5 - .../androidaps/TestBaseWithProfile.kt | 8 +- .../androidaps/data/QuickWizardTest.kt | 3 +- .../nightscout/androidaps/db/BgReadingTest.kt | 3 +- .../interfaces/ConstraintsCheckerTest.kt | 2 - .../plugins/aps/loop/LoopPluginTest.kt | 2 +- .../automation/actions/ActionsTestBase.kt | 5 - .../triggers/TriggerAutosensValueTest.kt | 2 +- .../automation/triggers/TriggerBgTest.kt | 2 +- .../automation/triggers/TriggerDeltaTest.kt | 2 +- .../automation/triggers/TriggerTestBase.kt | 1 - .../SmsCommunicatorPluginTest.kt | 2 - .../insulin/InsulinOrefBasePluginTest.kt | 4 +- .../insulin/InsulinOrefFreePeakPluginTest.kt | 3 +- .../InsulinOrefRapidActingPluginTest.kt | 2 +- .../InsulinOrefUltraRapidActingPluginTest.kt | 2 +- .../IobCobCalculatorPluginTest.kt | 3 +- .../plugins/pump/combo/ComboPluginTest.kt | 3 +- .../plugins/pump/danaR/DanaRPluginTest.kt | 1 - .../plugins/pump/danaR/comm/DanaRTestBase.kt | 2 +- .../pump/danaR/comm/MsgBolusProgressTest.kt | 2 +- .../pump/danaR/comm/MsgBolusStopTest.kt | 4 +- .../pump/danaRKorean/DanaRKoreanPluginTest.kt | 1 - .../comm/MessageHashTableRKoreanTest.kt | 1 - .../plugins/pump/danaRS/DanaRSPluginTest.kt | 2 - ...S_Packet_Bolus_Set_Step_Bolus_StartTest.kt | 2 - ...RS_Packet_Bolus_Set_Step_Bolus_StopTest.kt | 4 +- ...aRS_Packet_Notify_Delivery_CompleteTest.kt | 4 +- ...Packet_Notify_Delivery_Rate_DisplayTest.kt | 5 +- .../plugins/pump/danaRv2/DanaRv2PluginTest.kt | 1 - .../pump/virtual/VirtualPumpPluginUTest.kt | 3 +- .../androidaps/queue/CommandQueueTest.kt | 4 - .../utils/wizard/BolusWizardTest.kt | 3 +- build.gradle | 1 + core/build.gradle | 10 ++ .../info/nightscout/androidaps/Constants.java | 3 + .../androidaps/data/DetailedBolusInfo.java | 0 .../nightscout/androidaps/data/Intervals.java | 0 .../info/nightscout/androidaps/data/Iob.java | 0 .../nightscout/androidaps/data/IobTotal.java | 0 .../nightscout/androidaps/data/MealData.java | 0 .../data/NonOverlappingIntervals.java | 0 .../androidaps/data/OverlappingIntervals.java | 0 .../nightscout/androidaps/data/Profile.java | 16 +-- .../androidaps/data/ProfileIntervals.java | 0 .../androidaps/data/PumpEnactResult.java | 2 +- .../data/defaultProfile/DefaultProfile.kt | 0 .../nightscout/androidaps/db/BgReading.java | 20 ++-- .../androidaps/db/CareportalEvent.java | 13 +-- .../androidaps/db/DanaRHistoryRecord.java | 4 +- .../androidaps/db/DbObjectBase.java | 0 .../nightscout/androidaps/db/DbRequest.java | 2 +- .../androidaps/db/ExtendedBolus.java | 10 +- .../nightscout/androidaps/db/ICallback.java | 0 .../androidaps/db/ProfileSwitch.java | 16 ++- .../info/nightscout/androidaps/db/Source.java | 0 .../androidaps/db/StaticInjector.kt | 28 +++++ .../info/nightscout/androidaps/db/TDD.java | 11 +- .../nightscout/androidaps/db/TempTarget.java | 7 +- .../androidaps/db/TemporaryBasal.java | 19 ++- .../nightscout/androidaps/db}/Treatment.java | 11 +- .../androidaps/interfaces/APSInterface.java | 1 + .../interfaces/ActivePluginProvider.java | 0 .../interfaces/BgSourceInterface.java | 0 .../interfaces/CommandQueueProvider.kt | 0 .../androidaps/interfaces/ConfigInterface.kt | 9 ++ .../androidaps/interfaces/Constraint.java | 0 .../interfaces/ConstraintsInterface.kt | 0 .../interfaces/DatabaseHelperInterface.kt | 8 ++ .../interfaces/InsulinInterface.java | 2 +- .../androidaps/interfaces/Interval.java | 0 .../interfaces/IobCobCalculatorInterface.java | 11 ++ .../androidaps/interfaces/PluginBase.kt | 0 .../interfaces/PluginDescription.java | 0 .../androidaps/interfaces/PluginType.java | 0 .../androidaps/interfaces}/ProfileFunction.kt | 4 +- .../interfaces/ProfileInterface.java | 2 - .../androidaps/interfaces}/ProfileStore.kt | 3 +- .../interfaces/PumpDescription.java | 0 .../androidaps/interfaces/PumpInterface.java | 3 - .../androidaps/interfaces/PumpPluginBase.kt | 0 .../interfaces/SensitivityInterface.java | 3 +- .../interfaces/TreatmentsInterface.java | 23 +++- .../plugins/aps/loop/APSResult.java | 8 +- .../plugins/aps/openAPSSMB/SMBDefaults.java | 0 .../plugins/common/ManufacturerType.java | 0 .../configBuilder/ConstraintChecker.kt | 0 .../ProfileFunctionImplementation.kt | 7 +- .../general/actions/defs/CustomAction.kt | 2 +- .../general/actions/defs/CustomActionType.kt | 0 .../plugins/general/nsclient/data/NSMbg.java | 0 .../plugins/general/nsclient/data/NSSgv.java | 0 .../DataPointWithLabelInterface.java | 0 .../PointsWithLabelGraphSeries.java | 21 ++-- .../overview/graphExtensions/Scale.java | 0 .../iob/iobCobCalculator/AutosensResult.java | 0 .../iobCobCalculator/data}/AutosensData.java | 31 +++-- .../pump/common/data/DoseSettings.java | 0 .../pump/common/defs/DoseStepSize.java | 0 .../pump/common/defs/PumpCapability.java | 0 .../pump/common/defs/PumpDriverState.java | 0 .../pump/common/defs/PumpStatusType.java | 0 .../pump/common/defs/PumpTempBasalType.java | 0 .../plugins/pump/common/defs/PumpType.java | 8 +- .../nightscout/androidaps/queue/Callback.java | 0 .../androidaps/queue/commands/Command.kt | 2 +- .../nightscout/androidaps/utils/DateUtil.java | 53 ++++++--- .../androidaps/utils/DecimalFormatter.java | 0 .../androidaps/utils/DefaultValueHelper.kt | 4 +- .../nightscout/androidaps/utils/JsonHelper.kt | 0 .../nightscout/androidaps/utils/Round.java | 0 .../androidaps/utils/TimeChangeType.java | 0 .../nightscout/androidaps/utils/Translator.kt | 2 +- .../drawable/icon_actions_profileswitch.png | Bin core/src/main/res/values/colors.xml | 21 +++- core/src/main/res/values/strings.xml | 108 ++++++++++++++++++ 266 files changed, 924 insertions(+), 839 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/Config.java create mode 100644 app/src/main/java/info/nightscout/androidaps/Config.kt rename {app => core}/src/main/java/info/nightscout/androidaps/Constants.java (97%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/Intervals.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/Iob.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/IobTotal.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/MealData.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/NonOverlappingIntervals.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/OverlappingIntervals.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/Profile.java (98%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/ProfileIntervals.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java (99%) rename {app => core}/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfile.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/BgReading.java (93%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java (96%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/DanaRHistoryRecord.java (95%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/DbObjectBase.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/DbRequest.java (97%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java (97%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/ICallback.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java (94%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/Source.java (100%) create mode 100644 core/src/main/java/info/nightscout/androidaps/db/StaticInjector.kt rename {app => core}/src/main/java/info/nightscout/androidaps/db/TDD.java (78%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/TempTarget.java (95%) rename {app => core}/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java (97%) rename {app/src/main/java/info/nightscout/androidaps/plugins/treatments => core/src/main/java/info/nightscout/androidaps/db}/Treatment.java (95%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/APSInterface.java (99%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/ActivePluginProvider.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/CommandQueueProvider.kt (100%) create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/ConfigInterface.kt rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/Constraint.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.kt (100%) create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java (90%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/Interval.java (100%) create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/PluginType.java (100%) rename {app/src/main/java/info/nightscout/androidaps/plugins/configBuilder => core/src/main/java/info/nightscout/androidaps/interfaces}/ProfileFunction.kt (85%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/ProfileInterface.java (81%) rename {app/src/main/java/info/nightscout/androidaps/data => core/src/main/java/info/nightscout/androidaps/interfaces}/ProfileStore.kt (96%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java (98%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/PumpPluginBase.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/SensitivityInterface.java (60%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java (94%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java (98%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/common/ManufacturerType.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt (95%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomAction.kt (91%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomActionType.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSMbg.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSgv.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/DataPointWithLabelInterface.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java (96%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/Scale.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/AutosensResult.java (100%) rename {app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator => core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data}/AutosensData.java (87%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/DoseSettings.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/DoseStepSize.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpCapability.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDriverState.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpStatusType.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpTempBasalType.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java (98%) rename {app => core}/src/main/java/info/nightscout/androidaps/queue/Callback.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/queue/commands/Command.kt (97%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/DateUtil.java (90%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/DecimalFormatter.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/DefaultValueHelper.kt (97%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/JsonHelper.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/Round.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/TimeChangeType.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/Translator.kt (98%) rename {app => core}/src/main/res/drawable/icon_actions_profileswitch.png (100%) diff --git a/app/build.gradle b/app/build.gradle index fa13e0eea0..20c70ab9b6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,7 +25,6 @@ jacoco { } ext { - ormLiteVersion = "4.46" powermockVersion = "1.7.3" dexmakerVersion = "1.2" retrofit2Version = '2.8.1' @@ -265,6 +264,7 @@ dependencies { implementation "androidx.preference:preference-ktx:1.1.1" implementation "androidx.activity:activity:${activityVersion}" implementation "androidx.activity:activity-ktx:${activityVersion}" + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.material:material:1.1.0' implementation 'com.wdullaer:materialdatetimepicker:4.2.3' @@ -280,7 +280,6 @@ dependencies { // Graphview cannot be upgraded implementation "com.jjoe64:graphview:4.0.1" implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2" - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.madgag.spongycastle:core:1.58.0.0' implementation(name: "com.atech-software.android.library.wizardpager-1.1.1", ext: "aar") diff --git a/app/src/androidTest/java/info/nightscout/androidaps/RealPumpTest.kt b/app/src/androidTest/java/info/nightscout/androidaps/RealPumpTest.kt index a327989975..9158c5f119 100644 --- a/app/src/androidTest/java/info/nightscout/androidaps/RealPumpTest.kt +++ b/app/src/androidTest/java/info/nightscout/androidaps/RealPumpTest.kt @@ -8,11 +8,10 @@ import androidx.test.rule.GrantPermissionRule import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginType -import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin import info.nightscout.androidaps.plugins.insulin.InsulinOrefUltraRapidActingPlugin @@ -30,7 +29,6 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith -import org.slf4j.LoggerFactory import javax.inject.Inject @LargeTest diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java deleted file mode 100644 index bb967cdeb6..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ /dev/null @@ -1,15 +0,0 @@ -package info.nightscout.androidaps; - -/** - * Created by mike on 07.06.2016. - */ -public class Config { - public static int SUPPORTEDNSVERSION = 1002; // 0.10.00 - - public static final boolean APS = BuildConfig.FLAVOR.equals("full"); - - public static final boolean NSCLIENT = BuildConfig.FLAVOR.equals("nsclient") || BuildConfig.FLAVOR.equals("nsclient2"); - public static final boolean PUMPCONTROL = BuildConfig.FLAVOR.equals("pumpcontrol"); - - public static final boolean PUMPDRIVERS = BuildConfig.FLAVOR.equals("full") || BuildConfig.FLAVOR.equals("pumpcontrol"); -} diff --git a/app/src/main/java/info/nightscout/androidaps/Config.kt b/app/src/main/java/info/nightscout/androidaps/Config.kt new file mode 100644 index 0000000000..c5edf0c438 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/Config.kt @@ -0,0 +1,15 @@ +package info.nightscout.androidaps + +import info.nightscout.androidaps.interfaces.ConfigInterface +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class Config @Inject constructor(): ConfigInterface{ + + override val SUPPORTEDNSVERSION = 1002 // 0.10.00 + override val APS = BuildConfig.FLAVOR == "full" + override val NSCLIENT = BuildConfig.FLAVOR == "nsclient" || BuildConfig.FLAVOR == "nsclient2" + override val PUMPCONTROL = BuildConfig.FLAVOR == "pumpcontrol" + override val PUMPDRIVERS = BuildConfig.FLAVOR == "full" || BuildConfig.FLAVOR == "pumpcontrol" +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index 4e58a1f21f..c78aaedaf5 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -85,6 +85,7 @@ class MainActivity : NoSplashAppCompatActivity() { @Inject lateinit var iconsProvider: IconsProvider @Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var signatureVerifierPlugin: SignatureVerifierPlugin + @Inject lateinit var config: Config private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle private var pluginPreferencesMenuItem: MenuItem? = null @@ -137,7 +138,7 @@ class MainActivity : NoSplashAppCompatActivity() { } androidPermission.notifyForStoragePermission(this) androidPermission.notifyForBatteryOptimizationPermission(this) - if (Config.PUMPDRIVERS) { + if (config.PUMPDRIVERS) { androidPermission.notifyForLocationPermissions(this) androidPermission.notifyForSMSPermissions(this, smsCommunicatorPlugin) androidPermission.notifyForSystemWindowPermissions(this) @@ -352,7 +353,7 @@ class MainActivity : NoSplashAppCompatActivity() { val hashes: List = signatureVerifierPlugin.shortHashes() if (hashes.isNotEmpty()) fabricPrivacy.firebaseAnalytics.setUserProperty("Hash", hashes[0]) activePlugin.activePump.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Pump", it::class.java.simpleName) } - if (!Config.NSCLIENT && !Config.PUMPCONTROL) + if (!config.NSCLIENT && !config.PUMPCONTROL) activePlugin.activeAPS.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Aps", it::class.java.simpleName) } activePlugin.activeBgSource.let { fabricPrivacy.firebaseAnalytics.setUserProperty("BgSource", it::class.java.simpleName) } fabricPrivacy.firebaseAnalytics.setUserProperty("Profile", activePlugin.activeProfileInterface.javaClass.simpleName) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 66acee4016..85d8f83ed7 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -14,14 +14,19 @@ import com.j256.ormlite.android.apptools.OpenHelperManager; import net.danlew.android.joda.JodaTimeAndroid; +import org.jetbrains.annotations.NotNull; + import java.util.List; import javax.inject.Inject; import dagger.android.AndroidInjector; import dagger.android.DaggerApplication; +import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.DatabaseHelper; +import info.nightscout.androidaps.db.StaticInjector; import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent; +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; @@ -40,7 +45,7 @@ import info.nightscout.androidaps.utils.ActivityMonitor; import info.nightscout.androidaps.utils.LocaleHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; -public class MainApp extends DaggerApplication { +public class MainApp extends DaggerApplication implements DatabaseHelperInterface { static MainApp sInstance; private static Resources sResources; @@ -57,6 +62,8 @@ public class MainApp extends DaggerApplication { @Inject KeepAliveReceiver.KeepAliveManager keepAliveManager; @Inject List plugins; + @Inject StaticInjector staticInjector; // TODO remove , fake only to initialize + @Override public void onCreate() { super.onCreate(); @@ -166,4 +173,8 @@ public class MainApp extends DaggerApplication { keepAliveManager.cancelAlarm(this); super.onTerminate(); } + + @NotNull @Override public List getAllBgreadingsDataFromTime(long mills, boolean ascending) { + return getDbHelper().getAllBgreadingsDataFromTime(mills, ascending); + } } diff --git a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt index 78147d4108..f7872853f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -22,7 +22,7 @@ import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.PluginStore -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin @@ -66,6 +66,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang @Inject lateinit var sp: SP @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var pluginStore: PluginStore + @Inject lateinit var config: Config @Inject lateinit var automationPlugin: AutomationPlugin @Inject lateinit var danaRPlugin: DanaRPlugin @@ -100,6 +101,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang @Inject lateinit var passwordCheck: PasswordCheck @Inject lateinit var nsSettingStatus: NSSettingsStatus + // TODO why? @Inject lateinit var androidInjector: DispatchingAndroidInjector override fun androidInjector(): AndroidInjector = androidInjector @@ -160,20 +162,20 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang addPreferencesFromResourceIfEnabled(poctechPlugin, rootKey) addPreferencesFromResourceIfEnabled(glimpPlugin, rootKey) addPreferencesFromResourceIfEnabled(careportalPlugin, rootKey) - addPreferencesFromResourceIfEnabled(loopPlugin, rootKey, Config.APS) - addPreferencesFromResourceIfEnabled(openAPSAMAPlugin, rootKey, Config.APS) - addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, Config.APS) + addPreferencesFromResourceIfEnabled(loopPlugin, rootKey, config.APS) + addPreferencesFromResourceIfEnabled(openAPSAMAPlugin, rootKey, config.APS) + addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, config.APS) addPreferencesFromResourceIfEnabled(sensitivityAAPSPlugin, rootKey) addPreferencesFromResourceIfEnabled(sensitivityWeightedAveragePlugin, rootKey) addPreferencesFromResourceIfEnabled(sensitivityOref1Plugin, rootKey) - addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey, Config.PUMPDRIVERS) - addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey, Config.PUMPDRIVERS) - addPreferencesFromResourceIfEnabled(danaRv2Plugin, rootKey, Config.PUMPDRIVERS) - addPreferencesFromResourceIfEnabled(danaRSPlugin, rootKey, Config.PUMPDRIVERS) - addPreferencesFromResourceIfEnabled(localInsightPlugin, rootKey, Config.PUMPDRIVERS) - addPreferencesFromResourceIfEnabled(comboPlugin, rootKey, Config.PUMPDRIVERS) - addPreferencesFromResourceIfEnabled(medtronicPumpPlugin, rootKey, Config.PUMPDRIVERS) - addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey, !Config.NSCLIENT) + addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey, config.PUMPDRIVERS) + addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey, config.PUMPDRIVERS) + addPreferencesFromResourceIfEnabled(danaRv2Plugin, rootKey, config.PUMPDRIVERS) + addPreferencesFromResourceIfEnabled(danaRSPlugin, rootKey, config.PUMPDRIVERS) + addPreferencesFromResourceIfEnabled(localInsightPlugin, rootKey, config.PUMPDRIVERS) + addPreferencesFromResourceIfEnabled(comboPlugin, rootKey, config.PUMPDRIVERS) + addPreferencesFromResourceIfEnabled(medtronicPumpPlugin, rootKey, config.PUMPDRIVERS) + addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey, !config.NSCLIENT) addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey) addPreferencesFromResourceIfEnabled(nsClientPlugin, rootKey) addPreferencesFromResourceIfEnabled(tidepoolPlugin, rootKey) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt index 6ea91d443a..d53f06e67c 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.activities import android.os.Bundle import info.nightscout.androidaps.R import info.nightscout.androidaps.utils.ActivityMonitor +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.stats.TddCalculator import info.nightscout.androidaps.utils.stats.TirCalculator @@ -15,12 +16,13 @@ class StatsActivity : NoSplashAppCompatActivity() { @Inject lateinit var tirCalculator: TirCalculator @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var activityMonitor: ActivityMonitor + @Inject lateinit var dateUtil: DateUtil override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_stats) - stats_tdds.text = tddCalculator.stats() + stats_tdds.text = tddCalculator.stats(dateUtil) stats_tir.text = tirCalculator.stats() stats_activity.text = activityMonitor.stats() diff --git a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt index 2a5e8bcecd..8797bcfe70 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt @@ -10,7 +10,7 @@ import info.nightscout.androidaps.dialogs.ProfileViewerDialog import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.ActivityMonitor import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.InstanceId @@ -31,6 +31,7 @@ class SurveyActivity : NoSplashAppCompatActivity() { @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var activityMonitor: ActivityMonitor @Inject lateinit var defaultProfile: DefaultProfile + @Inject lateinit var dateUtil: DateUtil override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -42,7 +43,7 @@ class SurveyActivity : NoSplashAppCompatActivity() { val profileList = profileStore?.getProfileList() ?: return survey_spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, profileList) - survey_tdds.text = tddCalculator.stats() + survey_tdds.text = tddCalculator.stats(dateUtil) survey_tir.text = tirCalculator.stats() survey_activity.text = activityMonitor.stats() diff --git a/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java b/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java index ae337b8e59..1cf80ed1ca 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java @@ -39,7 +39,7 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin; import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus; import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin; 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 5759429d69..abc6df92c9 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -33,7 +33,7 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.NonOverlappingIntervals; import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.data.ProfileStore; +import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.events.EventCareportalEventChange; import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventNewBG; @@ -50,8 +50,6 @@ import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.plugins.bus.RxBus; -import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.plugins.configBuilder.PluginStore; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes; @@ -62,6 +60,7 @@ 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; +import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.ToastUtils; /** @@ -83,7 +82,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public static final String DATABASE_DANARHISTORY = "DanaRHistory"; public static final String DATABASE_DBREQUESTS = "DBRequests"; public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents"; - public static final String DATABASE_PROFILESWITCHES = "ProfileSwitches"; public static final String DATABASE_TDDS = "TDDs"; public static final String DATABASE_INSIGHT_HISTORY_OFFSETS = "InsightHistoryOffsets"; public static final String DATABASE_INSIGHT_BOLUS_IDS = "InsightBolusIDs"; @@ -1903,4 +1901,52 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { return new ArrayList<>(); } + + // Copied from xDrip+ + String calculateDirection(BgReading bgReading) { + // Rework to get bgreaings from internal DB and calculate on that base + + List bgReadingsList = MainApp.getDbHelper().getAllBgreadingsDataFromTime(bgReading.date - T.mins(10).msecs(), false); + if (bgReadingsList == null || bgReadingsList.size() < 2) + return "NONE"; + BgReading current = bgReadingsList.get(1); + BgReading previous = bgReadingsList.get(0); + + if (bgReadingsList.get(1).date < bgReadingsList.get(0).date) { + current = bgReadingsList.get(0); + previous = bgReadingsList.get(1); + } + + double slope; + + // Avoid division by 0 + if (current.date == previous.date) + slope = 0; + else + slope = (previous.value - current.value) / (previous.date - current.date); + +// aapsLogger.error(LTag.GLUCOSE, "Slope is :" + slope + " delta " + (previous.value - current.value) + " date difference " + (current.date - previous.date)); + + double slope_by_minute = slope * 60000; + String arrow = "NONE"; + + if (slope_by_minute <= (-3.5)) { + arrow = "DoubleDown"; + } else if (slope_by_minute <= (-2)) { + arrow = "SingleDown"; + } else if (slope_by_minute <= (-1)) { + arrow = "FortyFiveDown"; + } else if (slope_by_minute <= (1)) { + arrow = "Flat"; + } else if (slope_by_minute <= (2)) { + arrow = "FortyFiveUp"; + } else if (slope_by_minute <= (3.5)) { + arrow = "SingleUp"; + } else if (slope_by_minute <= (40)) { + arrow = "DoubleUp"; + } +// aapsLogger.error(LTag.GLUCOSE, "Direction set to: " + arrow); + return arrow; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/APSModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/APSModule.kt index d3fef14166..7315329ab2 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/APSModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/APSModule.kt @@ -8,7 +8,7 @@ import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalAdapterAM import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread 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 a836da500e..1dec3bf9bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt @@ -6,48 +6,6 @@ import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjector import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.core.dependencyInjection.CoreModule -import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.data.ProfileStore -import info.nightscout.androidaps.data.PumpEnactResult -import info.nightscout.androidaps.db.BgReading -import info.nightscout.androidaps.db.CareportalEvent -import info.nightscout.androidaps.db.ProfileSwitch -import info.nightscout.androidaps.db.TemporaryBasal -import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback -import info.nightscout.androidaps.plugins.aps.loop.APSResult -import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA -import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS -import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.* -import info.nightscout.androidaps.plugins.general.automation.AutomationEvent -import info.nightscout.androidaps.plugins.general.automation.actions.* -import info.nightscout.androidaps.plugins.general.automation.elements.* -import info.nightscout.androidaps.plugins.general.automation.triggers.* -import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData -import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction -import info.nightscout.androidaps.plugins.general.smsCommunicator.AuthRequest -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread -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 -import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.queue.CommandQueue -import info.nightscout.androidaps.queue.commands.* -import info.nightscout.androidaps.setupwizard.SWEventListener -import info.nightscout.androidaps.setupwizard.SWScreen -import info.nightscout.androidaps.setupwizard.elements.* -import info.nightscout.androidaps.utils.wizard.BolusWizard -import info.nightscout.androidaps.utils.wizard.QuickWizardEntry import javax.inject.Singleton @Singleton diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index 944fe3615f..e405ab91fd 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -8,13 +8,11 @@ import dagger.Provides import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.MainApp -import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.interfaces.CommandQueueProvider -import info.nightscout.androidaps.interfaces.PluginBase +import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.configBuilder.PluginStore -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation +import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.CommandQueue import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -37,17 +35,18 @@ open class AppModule { } @Provides - fun providesPlugins(@PluginsModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>, + fun providesPlugins(configInterface: ConfigInterface, + @PluginsModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>, @PluginsModule.PumpDriver pumpDrivers: Lazy>, @PluginsModule.NotNSClient notNsClient: Lazy>, @PluginsModule.NSClient nsClient: Lazy>, @PluginsModule.APS aps: Lazy>) : List<@JvmSuppressWildcards PluginBase> { val plugins = allConfigs.toMutableMap() - if (Config.PUMPDRIVERS) plugins += pumpDrivers.get() - if (Config.APS) plugins += aps.get() - if (!Config.NSCLIENT) plugins += notNsClient.get() - if (Config.NSCLIENT) plugins += nsClient.get() + if (configInterface.PUMPDRIVERS) plugins += pumpDrivers.get() + if (configInterface.APS) plugins += aps.get() + if (!configInterface.NSCLIENT) plugins += notNsClient.get() + if (configInterface.NSCLIENT) plugins += nsClient.get() return plugins.toList().sortedBy { it.first }.map { it.second } } @@ -62,8 +61,11 @@ open class AppModule { @Binds fun bindContext(mainApp: MainApp): Context @Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector + @Binds fun bindDatabaseHelperInterface(mainApp: MainApp): DatabaseHelperInterface @Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider @Binds fun commandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider + @Binds fun configInterfaceProvider(config: Config): ConfigInterface + @Binds fun treatmentInterfaceProvider(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface } } diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DataClassesModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DataClassesModule.kt index 99ffb12f25..536454413c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DataClassesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/DataClassesModule.kt @@ -3,14 +3,14 @@ package info.nightscout.androidaps.dependencyInjection import dagger.Module import dagger.android.ContributesAndroidInjector import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.data.ProfileStore +import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.ExtendedBolus import info.nightscout.androidaps.db.ProfileSwitch import info.nightscout.androidaps.db.TemporaryBasal import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.plugins.treatments.TreatmentService import info.nightscout.androidaps.utils.wizard.BolusWizard import info.nightscout.androidaps.utils.wizard.QuickWizardEntry @@ -23,6 +23,7 @@ abstract class DataClassesModule { @ContributesAndroidInjector abstract fun glucoseStatusInjector(): GlucoseStatus @ContributesAndroidInjector abstract fun profileStoreInjector(): ProfileStore + // TODO move to Core @ContributesAndroidInjector abstract fun bgReadingInjector(): BgReading @ContributesAndroidInjector abstract fun treatmentInjector(): Treatment @ContributesAndroidInjector abstract fun profileSwitchInjector(): ProfileSwitch diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OverviewModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OverviewModule.kt index d022d3a726..196e5b1203 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OverviewModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OverviewModule.kt @@ -2,16 +2,8 @@ package info.nightscout.androidaps.dependencyInjection import dagger.Module import dagger.android.ContributesAndroidInjector -import info.nightscout.androidaps.plugins.aps.loop.APSResult -import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA -import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS -import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.* import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread @Module @Suppress("unused") 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 2861829d7f..e7b1903389 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt @@ -1,13 +1,9 @@ package info.nightscout.androidaps.dependencyInjection import dagger.Binds -import dagger.Lazy import dagger.Module -import dagger.Provides import dagger.multibindings.IntKey import dagger.multibindings.IntoMap -import dagger.multibindings.IntoSet -import info.nightscout.androidaps.Config import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/UIModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/UIModule.kt index 50abc0b69a..193b46957a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/UIModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/UIModule.kt @@ -2,16 +2,6 @@ package info.nightscout.androidaps.dependencyInjection import dagger.Module import dagger.android.ContributesAndroidInjector -import info.nightscout.androidaps.plugins.aps.loop.APSResult -import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA -import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS -import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.* -import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData -import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread import info.nightscout.androidaps.skins.SkinListPreference @Module diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt index ff1b401b0d..10c10b27f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt @@ -9,7 +9,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.alertDialogs.OKDialog diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt index caba26346f..73effb19d8 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -16,7 +16,7 @@ import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TempTarget import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.treatments.CarbsGenerator diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index e561cb0890..8a07e111b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -15,7 +15,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.utils.DateUtil diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt index 081589f526..73921c0067 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt @@ -24,6 +24,7 @@ import javax.inject.Inject abstract class DialogFragmentWithDate : DaggerDialogFragment() { @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var sp: SP + @Inject lateinit var dateUtil: DateUtil var eventTime = DateUtil.now() var eventTimeChanged = false @@ -57,7 +58,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() { eventTime = savedInstanceState?.getLong("eventTime") ?: DateUtil.now() eventTimeChanged = savedInstanceState?.getBoolean("eventTimeChanged") ?: false overview_eventdate?.text = DateUtil.dateString(eventTime) - overview_eventtime?.text = DateUtil.timeString(eventTime) + overview_eventtime?.text = dateUtil.timeString(eventTime) // create an OnDateSetListener val dateSetListener = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth -> @@ -92,7 +93,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() { cal.set(Calendar.SECOND, seconds++) // randomize seconds to prevent creating record of the same time, if user choose time manually eventTime = cal.timeInMillis eventTimeChanged = true - overview_eventtime?.text = DateUtil.timeString(eventTime) + overview_eventtime?.text = dateUtil.timeString(eventTime) } overview_eventtime?.setOnClickListener { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt index 333de055ca..e4fa54e2f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -21,7 +21,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.* import info.nightscout.androidaps.utils.alertDialogs.OKDialog diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 45491761d7..10be190380 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -9,7 +9,7 @@ import com.google.common.base.Joiner import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.HtmlHelper diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt index bcba2ae87b..3e6a2c374e 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt @@ -14,7 +14,7 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PumpDescription import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.alertDialogs.OKDialog diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt index ba114c9b21..95ca3c0723 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -14,7 +14,7 @@ import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TempTarget import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DefaultValueHelper diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt index cc3c6c7a98..23ddfcabd1 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt @@ -24,7 +24,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardInfoDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardInfoDialog.kt index 2c25836f8d..2bac82dbc6 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardInfoDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardInfoDialog.kt @@ -9,7 +9,7 @@ import android.view.WindowManager import dagger.android.support.DaggerDialogFragment import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.resources.ResourceHelper diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.kt b/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.kt index 9cbc9d1563..679b62ee30 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.kt +++ b/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.kt @@ -1,5 +1,5 @@ package info.nightscout.androidaps.events -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment class EventTreatmentChange(val treatment: Treatment?) : EventLoop() diff --git a/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt b/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt index 0b260e9470..ab8cae8666 100644 --- a/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt @@ -18,7 +18,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.overview.OverviewMenus import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished diff --git a/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt index 87276a50a9..8334ce9567 100644 --- a/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt @@ -4,7 +4,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java index 93fcef0f0b..c5c723731c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java @@ -53,7 +53,7 @@ import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui; import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java index 50a6c6e018..c6b5afbdeb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java @@ -32,7 +32,7 @@ import info.nightscout.androidaps.plugins.aps.loop.ScriptReader; import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback; import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java index 42003d1b13..0cb082f368 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java @@ -27,8 +27,8 @@ import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData; +import info.nightscout.androidaps.interfaces.ProfileFunction; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java index 4d3a0db704..6b5f5363b0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java @@ -31,7 +31,7 @@ import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.aps.loop.ScriptReader; import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.interfaces.ActivePluginProvider; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java index 878d260bca..6da05d9075 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java @@ -30,8 +30,8 @@ import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData; +import info.nightscout.androidaps.interfaces.ProfileFunction; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt index 35ba1db642..5166248e7d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt @@ -9,7 +9,8 @@ import javax.inject.Singleton @Singleton class PluginStore @Inject constructor( - val aapsLogger: AAPSLogger + private val aapsLogger: AAPSLogger, + private val config: Config ) : ActivePluginProvider { lateinit var plugins: List<@JvmSuppressWildcards PluginBase> @@ -68,7 +69,7 @@ class PluginStore @Inject constructor( var pluginsInCategory: ArrayList? // PluginType.APS - if (!Config.NSCLIENT && !Config.PUMPCONTROL) { + if (!config.NSCLIENT && !config.PUMPCONTROL) { pluginsInCategory = getSpecificPluginsList(PluginType.APS) activeAPS = getTheOneEnabledInArray(pluginsInCategory, PluginType.APS) as APSInterface? if (activeAPS == null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt index 209a74f44a..cc57908438 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -24,13 +24,14 @@ class ObjectivesPlugin @Inject constructor( aapsLogger: AAPSLogger, resourceHelper: ResourceHelper, private val activePlugin: ActivePluginProvider, - private val sp: SP + private val sp: SP, + private val config: Config ) : PluginBase(PluginDescription() .mainType(PluginType.CONSTRAINTS) .fragmentClass(ObjectivesFragment::class.qualifiedName) - .alwaysEnabled(Config.APS) - .showInList(Config.APS) + .alwaysEnabled(config.APS) + .showInList(config.APS) .pluginName(R.string.objectives) .shortName(R.string.objectives_shortname) .description(R.string.description_objectives), diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt index 2ea9743cee..e44135eb45 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt @@ -21,6 +21,7 @@ import javax.inject.Inject class ObjectivesExamDialog : DaggerDialogFragment() { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper + @Inject lateinit var dateUtil: DateUtil companion object { var objective: Objective? = null @@ -76,7 +77,7 @@ class ObjectivesExamDialog : DaggerDialogFragment() { objectives_exam_hints.addView(h.generate(context)) } // Disabled to - objectives_exam_disabledto.text = resourceHelper.gs(R.string.answerdisabledto, DateUtil.timeString(task.disabledTo)) + objectives_exam_disabledto.text = resourceHelper.gs(R.string.answerdisabledto, dateUtil.timeString(task.disabledTo)) objectives_exam_disabledto.visibility = if (task.isEnabledAnswer) View.GONE else View.VISIBLE // Buttons objectives_exam_verify.isEnabled = !task.answered && task.isEnabledAnswer diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java index ab325f1f0c..b6f25325f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java @@ -47,6 +47,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { private HardLimits hardLimits; private BuildHelper buildHelper; private TreatmentsPlugin treatmentsPlugin; + private Config config; @Inject public SafetyPlugin( @@ -62,7 +63,8 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { ActivePluginProvider activePlugin, HardLimits hardLimits, BuildHelper buildHelper, - TreatmentsPlugin treatmentsPlugin + TreatmentsPlugin treatmentsPlugin, + Config config ) { super(new PluginDescription() .mainType(PluginType.CONSTRAINTS) @@ -83,6 +85,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { this.hardLimits = hardLimits; this.buildHelper = buildHelper; this.treatmentsPlugin = treatmentsPlugin; + this.config = config; } /** @@ -159,7 +162,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { absoluteRate.setIfGreater(getAapsLogger(), 0d, String.format(getResourceHelper().gs(R.string.limitingbasalratio), 0d, getResourceHelper().gs(R.string.itmustbepositivevalue)), this); - if (Config.APS) { + if (config.getAPS()) { double maxBasal = sp.getDouble(R.string.key_openapsma_max_basal, 1d); if (maxBasal < profile.getMaxDailyBasal()) { maxBasal = profile.getMaxDailyBasal(); 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 6a324d74cc..e6077e6e26 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 @@ -20,7 +20,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler import info.nightscout.androidaps.queue.Callback @@ -54,6 +54,7 @@ class ActionsFragment : DaggerFragment() { @Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var buildHelper: BuildHelper @Inject lateinit var protectionCheck: ProtectionCheck + @Inject lateinit var config: Config private var disposable: CompositeDisposable = CompositeDisposable() @@ -239,7 +240,7 @@ class ActionsFragment : DaggerFragment() { if (!pump.pumpDescription.isRefillingCapable || !pump.isInitialized || pump.isSuspended) View.GONE else View.VISIBLE - actions_temptarget?.visibility = Config.APS.toVisibility() + actions_temptarget?.visibility = config.APS.toVisibility() actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility() statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null) checkPumpCustomActions() @@ -247,7 +248,7 @@ class ActionsFragment : DaggerFragment() { private fun checkPumpCustomActions() { val activePump = activePlugin.activePump - val customActions = activePump.customActions ?: return + val customActions = activePump.customActions removePumpCustomActions() for (customAction in customActions) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt index 91125a9e1e..ff3927da71 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt @@ -15,12 +15,13 @@ import javax.inject.Singleton class ActionsPlugin @Inject constructor( injector: HasAndroidInjector, aapsLogger: AAPSLogger, - resourceHelper: ResourceHelper + resourceHelper: ResourceHelper, + config: Config ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(ActionsFragment::class.qualifiedName) - .enableByDefault(Config.APS || Config.PUMPCONTROL) - .visibleByDefault(Config.APS || Config.PUMPCONTROL) + .enableByDefault(config.APS || config.PUMPCONTROL) + .visibleByDefault(config.APS || config.PUMPCONTROL) .pluginName(R.string.actions) .shortName(R.string.actions_shortname) .description(R.string.description_actions), diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt index 9a1c4d5c3a..b4f9ec425e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt @@ -37,7 +37,6 @@ import io.reactivex.schedulers.Schedulers import org.json.JSONArray import org.json.JSONException import org.json.JSONObject -import java.util.* import javax.inject.Inject import javax.inject.Singleton import kotlin.collections.ArrayList @@ -52,7 +51,8 @@ class AutomationPlugin @Inject constructor( private val loopPlugin: LoopPlugin, private val rxBus: RxBusWrapper, private val constraintChecker: ConstraintChecker, - aapsLogger: AAPSLogger + aapsLogger: AAPSLogger, + private val dateUtil: DateUtil ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(AutomationFragment::class.qualifiedName) @@ -197,7 +197,7 @@ class AutomationPlugin @Inject constructor( action.doAction(object : Callback() { override fun run() { val sb = StringBuilder() - sb.append(DateUtil.timeString(DateUtil.now())) + sb.append(dateUtil.timeString(DateUtil.now())) sb.append(" ") sb.append(if (result.success) "☺" else "▼") sb.append(" ") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt index 76152b8861..7a730585c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt @@ -12,7 +12,6 @@ import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithE import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification -import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationUserMessage import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.JsonHelper diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt index 3e6406fac0..a46796b59d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt @@ -7,7 +7,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.automation.elements.InputProfileName import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt index c7ee4a5d6a..f81ef07bb8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt @@ -4,7 +4,7 @@ import android.widget.LinearLayout import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.NumberPicker import java.text.DecimalFormat import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt index f61d1d5719..2c92fcb75f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt @@ -18,6 +18,7 @@ import javax.inject.Inject class InputDateTime(injector: HasAndroidInjector) : Element(injector) { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var context: Context + @Inject lateinit var dateUtil: DateUtil var value: Long = DateUtil.now() @@ -30,7 +31,7 @@ class InputDateTime(injector: HasAndroidInjector) : Element(injector) { val dateButton = TextView(root.context) val timeButton = TextView(root.context) dateButton.text = DateUtil.dateString(value) - timeButton.text = DateUtil.timeString(value) + timeButton.text = dateUtil.timeString(value) // create an OnDateSetListener val dateSetListener = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth -> @@ -63,7 +64,7 @@ class InputDateTime(injector: HasAndroidInjector) : Element(injector) { cal.set(Calendar.MINUTE, minute) cal.set(Calendar.SECOND, 0) // randomize seconds to prevent creating record of the same time, if user choose time manually value = cal.timeInMillis - timeButton.text = DateUtil.timeString(value) + timeButton.text = dateUtil.timeString(value) } timeButton.setOnClickListener { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt index 01a7854e35..bd0622b29b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt @@ -12,7 +12,6 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.MidnightTime -import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject @@ -20,17 +19,18 @@ import javax.inject.Inject class InputTime(injector: HasAndroidInjector) : Element(injector) { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var context: Context + @Inject lateinit var dateUtil: DateUtil var value: Int = getMinSinceMidnight(DateUtil.now()) override fun addToLayout(root: LinearLayout) { val label = TextView(root.context) val startButton = TextView(root.context) - startButton.text = DateUtil.timeString(toMills(value)) + startButton.text = dateUtil.timeString(toMills(value)) val startTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute -> value = 60 * hour + minute - startButton.text = DateUtil.timeString(toMills(value)) + startButton.text = dateUtil.timeString(toMills(value)) } startButton.setOnClickListener { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt index 4775990d16..f8d0a369dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt @@ -12,7 +12,6 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.MidnightTime -import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject @@ -20,6 +19,7 @@ import javax.inject.Inject class InputTimeRange(injector: HasAndroidInjector) : Element(injector) { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var context: Context + @Inject lateinit var dateUtil: DateUtil var start: Int = getMinSinceMidnight(DateUtil.now()) var end: Int = getMinSinceMidnight(DateUtil.now()) @@ -28,13 +28,13 @@ class InputTimeRange(injector: HasAndroidInjector) : Element(injector) { val label = TextView(root.context) val startButton = TextView(root.context) val endButton = TextView(root.context) - startButton.text = DateUtil.timeString(toMills(start)) + startButton.text = dateUtil.timeString(toMills(start)) @Suppress("SetTextI18n") - endButton.text = resourceHelper.gs(R.string.and) + " " + DateUtil.timeString(toMills(end)) + endButton.text = resourceHelper.gs(R.string.and) + " " + dateUtil.timeString(toMills(end)) val startTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute -> start = 60 * hour + minute - startButton.text = DateUtil.timeString(toMills(start)) + startButton.text = dateUtil.timeString(toMills(start)) } startButton.setOnClickListener { @@ -51,7 +51,7 @@ class InputTimeRange(injector: HasAndroidInjector) : Element(injector) { val endTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute -> end = 60 * hour + minute - endButton.text = DateUtil.timeString(toMills(end)) + endButton.text = dateUtil.timeString(toMills(end)) } endButton.setOnClickListener { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt index 3890deb60d..357e4b462d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt @@ -13,7 +13,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseTriggerDialog import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerChanged import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerClone diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt index 8982a12669..08343a3c94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt @@ -13,11 +13,13 @@ import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabe import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.MidnightTime -import info.nightscout.androidaps.utils.T import org.json.JSONObject import java.util.* +import javax.inject.Inject class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) { + @Inject lateinit var dateUtil: DateUtil + val days = InputWeekDay(injector) val time = InputTime(injector) @@ -27,9 +29,9 @@ class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) { System.arraycopy(triggerRecurringTime.days.weekdays, 0, days.weekdays, 0, triggerRecurringTime.days.weekdays.size) } - fun time(minutes:Int): TriggerRecurringTime { + fun time(minutes: Int): TriggerRecurringTime { time.value = minutes - return this + return this } override fun shouldRun(): Boolean { @@ -85,7 +87,7 @@ class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) { sb.append(resourceHelper.gs(Objects.requireNonNull(InputWeekDay.DayOfWeek.fromCalendarInt(i)).shortName)) } sb.append(" ") - sb.append(DateUtil.timeString(toMills(time.value))) + sb.append(dateUtil.timeString(toMills(time.value))) return if (counter == 0) resourceHelper.gs(R.string.never) else sb.toString() } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt index 015cfce079..26aa0c81b7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt @@ -5,7 +5,6 @@ import com.google.common.base.Optional import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt index 2c565fa733..08f54025bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt @@ -12,12 +12,14 @@ import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabe import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.JsonHelper.safeGetInt import info.nightscout.androidaps.utils.MidnightTime -import info.nightscout.androidaps.utils.T import org.json.JSONObject +import javax.inject.Inject // Trigger for time range ( from 10:00AM till 13:00PM ) class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) { + @Inject lateinit var dateUtil: DateUtil + // in minutes since midnight 60 means 1AM var range = InputTimeRange(injector) @@ -31,7 +33,7 @@ class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) { range.end = triggerTimeRange.range.end } - fun period(start: Int, end:Int) : TriggerTimeRange { + fun period(start: Int, end: Int): TriggerTimeRange { this.range.start = start this.range.end = end return this @@ -70,7 +72,7 @@ class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) { override fun friendlyName(): Int = R.string.time_range override fun friendlyDescription(): String = - resourceHelper.gs(R.string.timerange_value, DateUtil.timeString(toMills(range.start)), DateUtil.timeString(toMills(range.end))) + resourceHelper.gs(R.string.timerange_value, dateUtil.timeString(toMills(range.start)), dateUtil.timeString(toMills(range.end))) override fun icon(): Optional = Optional.of(R.drawable.ic_access_alarm_24dp) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt index cef73c1339..49aeec14ed 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt @@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.general.automation.elements.InputStrin import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel -import info.nightscout.androidaps.receivers.NetworkChangeReceiver import info.nightscout.androidaps.receivers.ReceiverStatusStore import info.nightscout.androidaps.utils.JsonHelper import org.json.JSONObject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalPlugin.kt index e3328aefc9..897f28b0ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalPlugin.kt @@ -15,14 +15,15 @@ import javax.inject.Singleton class CareportalPlugin @Inject constructor( injector: HasAndroidInjector, aapsLogger: AAPSLogger, - resourceHelper: ResourceHelper + resourceHelper: ResourceHelper, + config: Config ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(CareportalFragment::class.java.name) .pluginName(R.string.careportal) .shortName(R.string.careportal_shortname) - .visibleByDefault(Config.NSCLIENT) - .enableByDefault(Config.NSCLIENT) + .visibleByDefault(config.NSCLIENT) + .enableByDefault(config.NSCLIENT) .description(R.string.description_careportal), aapsLogger, resourceHelper, injector ) \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java index 0c7dd11e83..8cbb16a8dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java @@ -44,14 +44,14 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.interfaces.ActivePluginProvider; +import info.nightscout.androidaps.interfaces.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; @@ -61,9 +61,9 @@ import info.nightscout.androidaps.utils.DefaultValueHelper; import info.nightscout.androidaps.utils.HardLimits; import info.nightscout.androidaps.utils.JsonHelper; import info.nightscout.androidaps.utils.NumberPicker; -import info.nightscout.androidaps.utils.alertDialogs.OKDialog; import info.nightscout.androidaps.utils.SafeParse; import info.nightscout.androidaps.utils.Translator; +import info.nightscout.androidaps.utils.alertDialogs.OKDialog; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -79,6 +79,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O @Inject TreatmentsPlugin treatmentsPlugin; @Inject HardLimits hardLimits; @Inject Translator translator; + @Inject DateUtil dateUtil; private static OptionsToShow options; private static @StringRes int event; @@ -168,7 +169,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O dateButton = view.findViewById(R.id.careportal_newnstreatment_eventdate); timeButton = view.findViewById(R.id.careportal_newnstreatment_eventtime); dateButton.setText(DateUtil.dateString(eventTime)); - timeButton.setText(DateUtil.timeString(eventTime)); + timeButton.setText(dateUtil.timeString(eventTime)); dateButton.setOnClickListener(this); timeButton.setOnClickListener(this); @@ -484,7 +485,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O eventTime.setHours(hourOfDay); eventTime.setMinutes(minute); eventTime.setSeconds(this.seconds++); // randomize seconds to prevent creating record of the same time, if user choose time manually - timeButton.setText(DateUtil.timeString(eventTime)); + timeButton.setText(dateUtil.timeString(eventTime)); updateBGforDateTime(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/dataBroadcaster/DataBroadcastPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/dataBroadcaster/DataBroadcastPlugin.kt index 63a32edc41..28d2b378b5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/dataBroadcaster/DataBroadcastPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/dataBroadcaster/DataBroadcastPlugin.kt @@ -14,16 +14,12 @@ import info.nightscout.androidaps.events.EventExtendedBolusChange import info.nightscout.androidaps.events.EventNewBasalProfile import info.nightscout.androidaps.events.EventTempBasalChange import info.nightscout.androidaps.events.EventTreatmentChange -import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.interfaces.PluginBase -import info.nightscout.androidaps.interfaces.PluginDescription -import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui +import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus @@ -53,8 +49,9 @@ class DataBroadcastPlugin @Inject constructor( private val nsDeviceStatus: NSDeviceStatus, private val loopPlugin: LoopPlugin, private val activePlugin: ActivePluginProvider, - private var receiverStatusStore: ReceiverStatusStore - + private var receiverStatusStore: ReceiverStatusStore, + private val config: Config, + private val databaseHelper: DatabaseHelperInterface ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) @@ -131,7 +128,7 @@ class DataBroadcastPlugin @Inject constructor( bundle.putDouble("glucoseMgdl", lastBG.value) // last BG in mgdl bundle.putLong("glucoseTimeStamp", lastBG.date) // timestamp bundle.putString("units", profileFunction.getUnits()) // units used in AAPS "mg/dl" or "mmol" - bundle.putString("slopeArrow", lastBG.directionToSymbol()) // direction arrow as string + bundle.putString("slopeArrow", lastBG.directionToSymbol(databaseHelper)) // direction arrow as string bundle.putDouble("deltaMgdl", glucoseStatus.delta) // bg delta in mgdl bundle.putDouble("avgDeltaMgdl", glucoseStatus.avgdelta) // average bg delta bundle.putDouble("high", defaultValueHelper.determineHighLine()) // predefined top value of in range (green area) @@ -158,7 +155,7 @@ class DataBroadcastPlugin @Inject constructor( bundle.putInt("phoneBattery", receiverStatusStore.batteryLevel) bundle.putInt("rigBattery", nsDeviceStatus.uploaderStatus.replace("%", "").trim { it <= ' ' }.toInt()) - if (Config.APS && loopPlugin.lastRun?.lastTBREnact != 0L) { //we are AndroidAPS + if (config.APS && loopPlugin.lastRun?.lastTBREnact != 0L) { //we are AndroidAPS bundle.putLong("suggestedTimeStamp", loopPlugin.lastRun?.lastAPSRun ?: -1L) bundle.putString("suggested", loopPlugin.lastRun?.request?.json().toString()) if (loopPlugin.lastRun?.tbrSetByPump != null && loopPlugin.lastRun?.tbrSetByPump?.enacted == true) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt index 4a3e5e83ab..9377b58992 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt @@ -18,7 +18,6 @@ import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP -import info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference import java.io.* import java.util.* import java.util.zip.ZipEntry @@ -34,7 +33,8 @@ class MaintenancePlugin @Inject constructor( private val sp: SP, private val nsSettingsStatus: NSSettingsStatus, aapsLogger: AAPSLogger, - private val buildHelper: BuildHelper + private val buildHelper: BuildHelper, + private val config: Config ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(MaintenanceFragment::class.java.name) @@ -171,7 +171,7 @@ class MaintenancePlugin @Inject constructor( builder.append("you have to do it manually)" + System.lineSeparator()) builder.append("-------------------------------------------------------" + System.lineSeparator()) builder.append(resourceHelper.gs(R.string.app_name) + " " + BuildConfig.VERSION + System.lineSeparator()) - if (Config.NSCLIENT) builder.append("NSCLIENT" + System.lineSeparator()) + if (config.NSCLIENT) builder.append("NSCLIENT" + System.lineSeparator()) builder.append("Build: " + BuildConfig.BUILDVERSION + System.lineSeparator()) builder.append("Remote: " + BuildConfig.REMOTE + System.lineSeparator()) builder.append("Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + System.lineSeparator()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java index 51f394860a..da77936384 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java @@ -11,7 +11,6 @@ import android.text.Html; import android.text.Spanned; import androidx.preference.PreferenceFragmentCompat; -import androidx.preference.PreferenceScreen; import org.jetbrains.annotations.NotNull; @@ -58,6 +57,7 @@ public class NSClientPlugin extends PluginBase { private final ResourceHelper resourceHelper; private final Context context; private final SP sp; + private final Config config; public Handler handler; @@ -81,7 +81,8 @@ public class NSClientPlugin extends PluginBase { ResourceHelper resourceHelper, Context context, SP sp, - NsClientReceiverDelegate nsClientReceiverDelegate + NsClientReceiverDelegate nsClientReceiverDelegate, + Config config ) { super(new PluginDescription() .mainType(PluginType.GENERAL) @@ -99,8 +100,9 @@ public class NSClientPlugin extends PluginBase { this.context = context; this.sp = sp; this.nsClientReceiverDelegate = nsClientReceiverDelegate; + this.config = config; - if (Config.NSCLIENT) { + if (config.getNSCLIENT()) { getPluginDescription().alwaysEnabled(true).visibleByDefault(true); } if (handler == null) { @@ -184,7 +186,7 @@ public class NSClientPlugin extends PluginBase { public void preprocessPreferences(@NotNull PreferenceFragmentCompat preferenceFragment) { super.preprocessPreferences(preferenceFragment); - if (Config.NSCLIENT) { + if (config.getNSCLIENT()) { preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_overview_advanced)); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java index 75f1c9b30c..48a2b31b35 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java @@ -25,7 +25,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.data.ProfileStore; +import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.DbRequest; @@ -40,7 +40,7 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.plugins.aps.loop.APSResult; import info.nightscout.androidaps.plugins.aps.loop.DeviceStatus; import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.receivers.ReceiverStatusStore; import info.nightscout.androidaps.utils.DateUtil; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt index 8319c143b1..d0441cccfa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt @@ -115,7 +115,8 @@ class NSSettingsStatus @Inject constructor( private val resourceHelper: ResourceHelper, private val rxBus: RxBusWrapper, private val defaultValueHelper: DefaultValueHelper, - private val sp: SP + private val sp: SP, + private val config: Config ) { var nightscoutVersionName = "" @@ -126,7 +127,7 @@ class NSSettingsStatus @Inject constructor( fun handleNewData(nightscoutVersionName: String, nightscoutVersionCode: Int, status: JSONObject) { this.nightscoutVersionName = nightscoutVersionName aapsLogger.debug(LTag.NSCLIENT, "Got versions: Nightscout: $nightscoutVersionName") - if (nightscoutVersionCode < Config.SUPPORTEDNSVERSION) { + if (nightscoutVersionCode < config.SUPPORTEDNSVERSION) { val notification = Notification(Notification.OLD_NS, resourceHelper.gs(R.string.unsupportednsversion), Notification.NORMAL) rxBus.send(EventNewNotification(notification)) } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java index 9c76a6e16b..54de04db85 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java @@ -20,7 +20,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.net.URISyntaxException; import java.sql.SQLException; @@ -31,11 +30,10 @@ import javax.inject.Inject; import dagger.android.DaggerService; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.ProfileStore; +import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.db.DbRequest; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventConfigBuilderChange; @@ -91,6 +89,7 @@ public class NSClientService extends DaggerService { @Inject SP sp; @Inject NSClientPlugin nsClientPlugin; @Inject BuildHelper buildHelper; + @Inject Config config; private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT); private CompositeDisposable disposable = new CompositeDisposable(); @@ -557,7 +556,7 @@ public class NSClientService extends DaggerService { nsSettingsStatus.setData(status); if (!status.has("versionNum")) { - if (status.getInt("versionNum") < Config.SUPPORTEDNSVERSION) { + if (status.getInt("versionNum") < config.getSUPPORTEDNSVERSION()) { rxBus.send(new EventNSClientNewLog("ERROR", "Unsupported Nightscout version !!!!")); } } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 4a6455e41c..2a462fb44a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -36,14 +36,15 @@ import info.nightscout.androidaps.dialogs.WizardDialog import info.nightscout.androidaps.events.* import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.Constraint +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData @@ -134,6 +135,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var overviewMenus: OverviewMenus @Inject lateinit var skinProvider: SkinProvider + @Inject lateinit var config: Config + @Inject lateinit var dateUtil: DateUtil + @Inject lateinit var databaseHelper: DatabaseHelperInterface private val disposable = CompositeDisposable() @@ -510,7 +514,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList fun updateGUI(from: String) { aapsLogger.debug("UpdateGUI from $from") - overview_time?.text = DateUtil.timeString(Date()) + overview_time?.text = dateUtil.timeString(Date()) if (!profileFunction.isProfileValid("Overview")) { overview_pumpstatus?.setText(R.string.noprofileset) @@ -541,7 +545,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList overview_bg?.text = lastBG.valueToUnitsToString(units) overview_bg?.setTextColor(color) - overview_arrow?.text = lastBG.directionToSymbol() + overview_arrow?.text = lastBG.directionToSymbol(databaseHelper) overview_arrow?.setTextColor(color) val glucoseStatus = GlucoseStatus(injector).glucoseStatusData @@ -570,7 +574,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList val closedLoopEnabled = constraintChecker.isClosedLoopAllowed() // open loop mode - if (Config.APS && pump.pumpDescription.isTempBasalCapable) { + if (config.APS && pump.pumpDescription.isTempBasalCapable) { overview_apsmode?.visibility = View.VISIBLE when { loopPlugin.isEnabled() && loopPlugin.isSuperBolus -> { @@ -719,7 +723,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } // Status lights - overview_statuslights?.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || Config.NSCLIENT).toVisibility() + overview_statuslights?.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility() statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_pbage, careportal_batterylevel) // cob @@ -732,7 +736,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList overview_cob?.text = cobText val lastRun = loopPlugin.lastRun - val predictionsAvailable = if (Config.APS) lastRun?.request?.hasPredictions == true else Config.NSCLIENT + val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT // pump status from ns overview_pump?.text = nsDeviceStatus.pumpStatus @@ -771,7 +775,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList val toTime: Long val fromTime: Long val endTime: Long - val apsResult = if (Config.APS) lastRun?.constraintsProcessed else NSDeviceStatus.getAPSResult(injector) + val apsResult = if (config.APS) lastRun?.constraintsProcessed else NSDeviceStatus.getAPSResult(injector) if (predictionsAvailable && apsResult != null && overviewMenus.setting[0][OverviewMenus.CharType.PRE.ordinal]) { var predHours = (ceil(apsResult.latestPredictionsTime - System.currentTimeMillis().toDouble()) / (60 * 60 * 1000)).toInt() predHours = min(2, predHours) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt index a6ad002aa9..69c6f84cb2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewMenus.kt @@ -15,7 +15,6 @@ import androidx.annotation.StringRes import androidx.appcompat.widget.PopupMenu import androidx.fragment.app.FragmentManager import com.google.gson.Gson -import com.google.gson.reflect.TypeToken import info.nightscout.androidaps.Config import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity @@ -34,7 +33,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DefaultValueHelper @@ -42,7 +41,6 @@ import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP -import java.lang.reflect.Type import javax.inject.Inject import javax.inject.Singleton @@ -59,7 +57,8 @@ class OverviewMenus @Inject constructor( private val profileFunction: ProfileFunction, private val commandQueue: CommandQueueProvider, private val configBuilderPlugin: ConfigBuilderPlugin, - private val loopPlugin: LoopPlugin + private val loopPlugin: LoopPlugin, + private val config: Config ) { enum class CharType(@StringRes val nameId: Int, @ColorRes val colorId: Int, val primary: Boolean, val secondary: Boolean) { @@ -117,8 +116,8 @@ class OverviewMenus @Inject constructor( chartButton.setOnClickListener { v: View -> val predictionsAvailable: Boolean = when { - Config.APS -> loopPlugin.lastRun?.request?.hasPredictions ?: false - Config.NSCLIENT -> true + config.APS -> loopPlugin.lastRun?.request?.hasPredictions ?: false + config.NSCLIENT -> true else -> false } val popup = PopupMenu(v.context, v) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt index b05e1cb015..8a95e34e1e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt @@ -20,7 +20,8 @@ class StatusLightHandler @Inject constructor( private val resourceHelper: ResourceHelper, private val sp: SP, private val activePlugin: ActivePluginProvider, - private val warnColors: WarnColors + private val warnColors: WarnColors, + private val config: Config ) { /** @@ -32,9 +33,9 @@ class StatusLightHandler @Inject constructor( handleAge(careportal_insulinage, CareportalEvent.INSULINCHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0) handleAge(careportal_sensorage, CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0) handleAge(careportal_pbage, CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0) - if (!Config.NSCLIENT) + if (!config.NSCLIENT) handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U") - if (!Config.NSCLIENT && pump.model() != PumpType.AccuChekCombo) + if (!config.NSCLIENT && pump.model() != PumpType.AccuChekCombo) handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt index 505ec3e943..6510b7505f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt @@ -29,6 +29,7 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var quickWizard: QuickWizard + @Inject lateinit var dateUtil: DateUtil private var disposable: CompositeDisposable = CompositeDisposable() @@ -39,8 +40,8 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() { } override fun onBindViewHolder(holder: QuickWizardEntryViewHolder, position: Int) { - holder.from.text = DateUtil.timeString(quickWizard[position].validFromDate()) - holder.to.text = DateUtil.timeString(quickWizard[position].validToDate()) + holder.from.text = dateUtil.timeString(quickWizard[position].validFromDate()) + holder.to.text = dateUtil.timeString(quickWizard[position].validToDate()) holder.buttonText.text = quickWizard[position].buttonText() holder.carbs.text = resourceHelper.gs(R.string.format_carbs, quickWizard[position].carbs()) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/EditQuickWizardDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/EditQuickWizardDialog.kt index d2531c77c5..188ce707db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/EditQuickWizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/EditQuickWizardDialog.kt @@ -27,6 +27,7 @@ class EditQuickWizardDialog : DaggerDialogFragment() { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var quickWizard: QuickWizard + @Inject lateinit var dateUtil: DateUtil var position = -1 @@ -77,13 +78,13 @@ class EditQuickWizardDialog : DaggerDialogFragment() { var pos = 0 var t = 0 while (t < 24 * 60 * 60) { - timeList.add(DateUtil.timeString(DateUtil.toDate(t))) + timeList.add(dateUtil.timeString(DateUtil.toDate(t))) if (entry.validFrom() == t) posFrom = pos if (entry.validTo() == t) posTo = pos pos++ t += 15 * 60 } - timeList.add(DateUtil.timeString(DateUtil.toDate(24 * 60 * 60 - 60))) + timeList.add(dateUtil.timeString(DateUtil.toDate(24 * 60 * 60 - 60))) val adapter = context?.let { context -> ArrayAdapter(context, R.layout.spinner_centered, timeList) } overview_editquickwizard_from_spinner.adapter = adapter diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventOverviewBolusProgress.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventOverviewBolusProgress.kt index 52b62790da..fe43913333 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventOverviewBolusProgress.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventOverviewBolusProgress.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.general.overview.events -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.events.Event object EventOverviewBolusProgress : Event() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt index 54d34533f3..02ccf1480f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt @@ -21,7 +21,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin.LastRun import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.overview.graphExtensions.* import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt index b07e9756e9..f467cc1fce 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt @@ -38,7 +38,8 @@ class NotificationStore @Inject constructor( private val rxBus: RxBusWrapper, private val resourceHelper: ResourceHelper, private val context: Context, - private val iconsProvider: IconsProvider + private val iconsProvider: IconsProvider, + private val dateUtil: DateUtil ) { var store: MutableList = ArrayList() @@ -192,7 +193,7 @@ class NotificationStore @Inject constructor( if (notification.buttonText != 0) holder.dismiss.setText(notification.buttonText) else holder.dismiss.setText(R.string.snooze) @Suppress("SetTextI18n") - holder.text.text = DateUtil.timeString(notification.date) + " " + notification.text + holder.text.text = dateUtil.timeString(notification.date) + " " + notification.text when (notification.level) { Notification.URGENT -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationUrgent)) Notification.NORMAL -> holder.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationNormal)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt index c1a203a343..e8d32ed386 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt @@ -14,14 +14,11 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainActivity import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.db.DatabaseHelper import info.nightscout.androidaps.events.* -import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.interfaces.PluginBase -import info.nightscout.androidaps.interfaces.PluginDescription -import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished @@ -47,7 +44,8 @@ class PersistentNotificationPlugin @Inject constructor( private var rxBus: RxBusWrapper, private var context: Context, private var notificationHolder: NotificationHolder, - private val iconsProvider: IconsProvider + private val iconsProvider: IconsProvider, + private val databaseHelper: DatabaseHelperInterface ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .neverVisible(true) @@ -147,7 +145,7 @@ class PersistentNotificationPlugin @Inject constructor( if (glucoseStatus != null) { line1 += (" Δ" + Profile.toSignedUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " avgΔ" + Profile.toSignedUnitsString(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units)) - line1_aa += " " + lastBG.directionToSymbol() + line1_aa += " " + lastBG.directionToSymbol(databaseHelper) } else { line1 += " " + resourceHelper.gs(R.string.old_data) + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorFragment.kt index 94dd9965f8..49a1778a7e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorFragment.kt @@ -23,6 +23,7 @@ class SmsCommunicatorFragment : DaggerFragment() { @Inject lateinit var fabricPrivacy : FabricPrivacy @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin + @Inject lateinit var dateUtil: DateUtil private val disposable = CompositeDisposable() @@ -61,15 +62,15 @@ class SmsCommunicatorFragment : DaggerFragment() { val sms = smsCommunicatorPlugin.messages[x] when { sms.ignored -> { - logText += DateUtil.timeString(sms.date) + " <<< " + "░ " + sms.phoneNumber + " " + sms.text + "
" + logText += dateUtil.timeString(sms.date) + " <<< " + "░ " + sms.phoneNumber + " " + sms.text + "
" } sms.received -> { - logText += DateUtil.timeString(sms.date) + " <<< " + (if (sms.processed) "● " else "○ ") + sms.phoneNumber + " " + sms.text + "
" + logText += dateUtil.timeString(sms.date) + " <<< " + (if (sms.processed) "● " else "○ ") + sms.phoneNumber + " " + sms.text + "
" } sms.sent -> { - logText += DateUtil.timeString(sms.date) + " >>> " + (if (sms.processed) "● " else "○ ") + sms.phoneNumber + " " + sms.text + "
" + logText += dateUtil.timeString(sms.date) + " >>> " + (if (sms.processed) "● " else "○ ") + sms.phoneNumber + " " + sms.text + "
" } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index c8a6bc8601..7aa94f1dcc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -23,7 +23,7 @@ import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification @@ -61,7 +61,9 @@ class SmsCommunicatorPlugin @Inject constructor( private val loopPlugin: LoopPlugin, private val iobCobCalculatorPlugin: IobCobCalculatorPlugin, private val xdripCalibrations: XdripCalibrations, - private var otp: OneTimePassword + private var otp: OneTimePassword, + private val config: Config, + private val dateUtil: DateUtil ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(SmsCommunicatorFragment::class.java.name) @@ -612,7 +614,7 @@ class SmsCommunicatorPlugin @Inject constructor( override fun run() { if (result.success) { var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_extendedset), aDouble, duration) - if (Config.APS) replyText += "\n" + resourceHelper.gs(R.string.loopsuspended) + if (config.APS) replyText += "\n" + resourceHelper.gs(R.string.loopsuspended) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) } else { @@ -713,7 +715,7 @@ class SmsCommunicatorPlugin @Inject constructor( if (grams == 0) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) else { val passCode = generatePasscode() - val reply = String.format(resourceHelper.gs(R.string.smscommunicator_carbsreplywithcode), grams, DateUtil.timeString(time), passCode) + val reply = String.format(resourceHelper.gs(R.string.smscommunicator_carbsreplywithcode), grams, dateUtil.timeString(time), passCode) receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(grams, time) { override fun run() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt index 9c5bfb9aad..8ad1bdd0bc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt @@ -9,7 +9,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.tidepool.elements.* import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolStatus import info.nightscout.androidaps.plugins.general.tidepool.utils.GsonInstance diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/BasalElement.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/BasalElement.kt index 4297e24420..50e07a4096 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/BasalElement.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/BasalElement.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.tidepool.elements import com.google.gson.annotations.Expose import info.nightscout.androidaps.db.TemporaryBasal -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import java.util.* class BasalElement(tbr: TemporaryBasal, private val profileFunction: ProfileFunction) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/BolusElement.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/BolusElement.kt index 3d8dcbe964..f437018994 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/BolusElement.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/BolusElement.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.general.tidepool.elements import com.google.gson.annotations.Expose -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment import java.util.* class BolusElement(treatment: Treatment) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/WizardElement.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/WizardElement.kt index d7641862fe..87aba24d1c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/WizardElement.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/elements/WizardElement.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.general.tidepool.elements import com.google.gson.annotations.Expose -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment import java.util.* class WizardElement(treatment: Treatment) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt index f1c58029d1..8aed0f5288 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt @@ -20,7 +20,7 @@ import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin @@ -67,7 +67,9 @@ class ActionStringHandler @Inject constructor( private val danaRSPlugin: DanaRSPlugin, private val danaRPump: DanaRPump, private val hardLimits: HardLimits, - private val carbsGenerator: CarbsGenerator + private val carbsGenerator: CarbsGenerator, + private val dateUtil: DateUtil, + private val config: Config ) { private val TIMEOUT = 65 * 1000 @@ -278,7 +280,7 @@ class ActionStringHandler @Inject constructor( val starttimestamp = System.currentTimeMillis() + starttime * 60 * 1000 val carbsAfterConstraints = constraintChecker.applyCarbsConstraints(Constraint(carbs)).value() rMessage += resourceHelper.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g" - rMessage += "\n" + resourceHelper.gs(R.string.time) + ": " + DateUtil.timeString(starttimestamp) + rMessage += "\n" + resourceHelper.gs(R.string.time) + ": " + dateUtil.timeString(starttimestamp) rMessage += "\n" + resourceHelper.gs(R.string.duration) + ": " + duration + "h" if (carbsAfterConstraints - carbs != 0) { rMessage += "\n" + resourceHelper.gs(R.string.constraintapllied) @@ -409,8 +411,8 @@ class ActionStringHandler @Inject constructor( ret += "APS: " + (aps as PluginBase).name val lastRun = loopPlugin.lastRun if (lastRun != null) { - ret += "\nLast Run: " + DateUtil.timeString(lastRun.lastAPSRun) - if (lastRun.lastTBREnact != 0L) ret += "\nLast Enact: " + DateUtil.timeString(lastRun.lastTBREnact) + ret += "\nLast Run: " + dateUtil.timeString(lastRun.lastAPSRun) + if (lastRun.lastTBREnact != 0L) ret += "\nLast Enact: " + dateUtil.timeString(lastRun.lastTBREnact) } } else { ret += "LOOP DISABLED\n" @@ -422,7 +424,7 @@ class ActionStringHandler @Inject constructor( private val targetsStatus: String get() { var ret = "" - if (!Config.APS) { + if (!config.APS) { return "Targets only apply in APS mode!" } val profile = profileFunction.getProfile() ?: return "No profile set :(" @@ -430,7 +432,7 @@ class ActionStringHandler @Inject constructor( val tempTarget = activePlugin.activeTreatments.tempTargetFromHistory if (tempTarget != null) { ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, Constants.MGDL, profileFunction.getUnits()) - ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd()) + ret += "\nuntil: " + dateUtil.timeString(tempTarget.originalEnd()) ret += "\n\n" } ret += "DEFAULT RANGE: " @@ -442,7 +444,7 @@ class ActionStringHandler @Inject constructor( private val oAPSResultStatus: String get() { var ret = "" - if (!Config.APS) + if (!config.APS) return "Only apply in APS mode!" val usedAPS = activePlugin.activeAPS val result = usedAPS.lastAPSResult ?: return "Last result not available!" diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java index b60dd1f1fd..e0a0657826 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java @@ -42,13 +42,13 @@ import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus; import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler; import info.nightscout.androidaps.plugins.general.wear.WearPlugin; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.receivers.ReceiverStatusStore; import info.nightscout.androidaps.utils.DecimalFormatter; @@ -72,6 +72,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog @Inject public TreatmentsPlugin treatmentsPlugin; @Inject public ActionStringHandler actionStringHandler; @Inject ReceiverStatusStore receiverStatusStore; + @Inject Config config; public static final String ACTION_RESEND = WatchUpdaterService.class.getName().concat(".Resend"); public static final String ACTION_OPEN_SETTINGS = WatchUpdaterService.class.getName().concat(".OpenSettings"); @@ -712,7 +713,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog long openApsStatus; //OpenAPS status - if (Config.APS) { + if (config.getAPS()) { //we are AndroidAPS openApsStatus = loopPlugin.lastRun != null && loopPlugin.lastRun.lastTBREnact != 0 ? loopPlugin.lastRun.lastTBREnact : -1; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt index 79a8dd486b..067c444eaa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt @@ -14,7 +14,7 @@ import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished import info.nightscout.androidaps.utils.DecimalFormatter diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/ActivityGraph.java b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/ActivityGraph.java index fd8564cf73..cb8dabdde5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/ActivityGraph.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/ActivityGraph.java @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.List; import info.nightscout.androidaps.data.Iob; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.interfaces.InsulinInterface; /** diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt index e5a92588c3..935fad3ccb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt @@ -9,10 +9,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.utils.resources.ResourceHelper /** diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt index 1ae2869b6e..f1804cbd43 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt @@ -5,7 +5,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.InsulinInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt index 634ad2df5d..770e7f1f91 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt @@ -5,7 +5,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.InsulinInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject import javax.inject.Singleton diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt index e2048d7a65..60f07c3203 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt @@ -5,7 +5,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.InsulinInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject import javax.inject.Singleton diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java index c35e3797dc..fe5ac90449 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java @@ -30,18 +30,20 @@ import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBasalProfile; import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.interfaces.ActivePluginProvider; +import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin; import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin; import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; @@ -55,7 +57,7 @@ import io.reactivex.schedulers.Schedulers; import static info.nightscout.androidaps.utils.DateUtil.now; @Singleton -public class IobCobCalculatorPlugin extends PluginBase { +public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculatorInterface { private final HasAndroidInjector injector; private final SP sp; private final RxBusWrapper rxBus; @@ -681,6 +683,7 @@ public class IobCobCalculatorPlugin extends PluginBase { } } + @Override public String lastDataTime() { if (autosensDataTable.size() > 0) return DateUtil.dateAndTimeString(autosensDataTable.valueAt(autosensDataTable.size() - 1).time); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java index 9478b9ed73..b1762e3722 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java @@ -26,14 +26,15 @@ import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress; import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin; import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.FabricPrivacy; @@ -240,7 +241,8 @@ public class IobCobOref1Thread extends Thread { List recentCarbTreatments = activePluginProvider.getActiveTreatments().getCarbTreatments5MinBackFromHistory(bgTime); for (Treatment recentCarbTreatment : recentCarbTreatments) { autosensData.carbsFromBolus += recentCarbTreatment.carbs; - autosensData.activeCarbsList.add(autosensData.new CarbsInPast(recentCarbTreatment)); + boolean isAAPSOrWeighted = sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled(); + autosensData.activeCarbsList.add(autosensData.new CarbsInPast(recentCarbTreatment, isAAPSOrWeighted)); autosensData.pastSensitivity += "[" + DecimalFormatter.to0Decimal(recentCarbTreatment.carbs) + "g]"; } @@ -277,7 +279,8 @@ public class IobCobOref1Thread extends Thread { autosensData.uam = previous.uam; } - autosensData.removeOldCarbs(bgTime); + boolean isAAPSOrWeighted = sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled(); + autosensData.removeOldCarbs(bgTime, isAAPSOrWeighted); autosensData.cob += autosensData.carbsFromBolus; autosensData.mealCarbs += autosensData.carbsFromBolus; autosensData.deviation = deviation; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java index 48b9c2eb0a..d9ceb47dfc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java @@ -24,14 +24,15 @@ import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress; import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin; import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.FabricPrivacy; @@ -237,7 +238,8 @@ public class IobCobThread extends Thread { List recentCarbTreatments = activePluginProvider.getActiveTreatments().getCarbTreatments5MinBackFromHistory(bgTime); for (Treatment recentCarbTreatment : recentCarbTreatments) { autosensData.carbsFromBolus += recentCarbTreatment.carbs; - autosensData.activeCarbsList.add(autosensData.new CarbsInPast(recentCarbTreatment)); + boolean isAAPSOrWeighted = sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled(); + autosensData.activeCarbsList.add(autosensData.new CarbsInPast(recentCarbTreatment, isAAPSOrWeighted)); autosensData.pastSensitivity += "[" + DecimalFormatter.to0Decimal(recentCarbTreatment.carbs) + "g]"; } @@ -268,7 +270,8 @@ public class IobCobThread extends Thread { autosensData.substractAbosorbedCarbs(); autosensData.usedMinCarbsImpact = totalMinCarbsImpact; } - autosensData.removeOldCarbs(bgTime); + boolean isAAPSOrWeighted = sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled(); + autosensData.removeOldCarbs(bgTime, isAAPSOrWeighted); autosensData.cob += autosensData.carbsFromBolus; autosensData.deviation = deviation; autosensData.bgi = bgi; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index 456c46a5da..8d2761cfa3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -5,7 +5,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.data.ProfileStore +import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.events.EventProfileStoreChanged import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription @@ -14,7 +14,7 @@ import info.nightscout.androidaps.interfaces.ProfileInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DecimalFormatter @@ -53,11 +53,6 @@ class LocalProfilePlugin @Inject constructor( private val defaultArray = "[{\"time\":\"00:00\",\"timeAsSeconds\":0,\"value\":0}]" - companion object { - @JvmStatic - val LOCAL_PROFILE = "LocalProfile" - } - override fun onStart() { super.onStart() loadSettings() @@ -122,7 +117,7 @@ class LocalProfilePlugin @Inject constructor( fun storeSettings(activity: Activity? = null) { for (i in 0 until numOfProfiles) { profiles[i].run { - val LOCAL_PROFILE_NUMBERED = LOCAL_PROFILE + "_" + i + "_" + val LOCAL_PROFILE_NUMBERED = Constants.LOCAL_PROFILE + "_" + i + "_" sp.putString(LOCAL_PROFILE_NUMBERED + "name", name!!) sp.putBoolean(LOCAL_PROFILE_NUMBERED + "mgdl", mgdl) sp.putDouble(LOCAL_PROFILE_NUMBERED + "dia", dia) @@ -133,7 +128,7 @@ class LocalProfilePlugin @Inject constructor( sp.putString(LOCAL_PROFILE_NUMBERED + "targethigh", targetHigh.toString()) } } - sp.putInt(LOCAL_PROFILE + "_profiles", numOfProfiles) + sp.putInt(Constants.LOCAL_PROFILE + "_profiles", numOfProfiles) createAndStoreConvertedProfile() isEdited = false @@ -154,20 +149,20 @@ class LocalProfilePlugin @Inject constructor( @Synchronized fun loadSettings() { - if (sp.contains(LOCAL_PROFILE + "mgdl")) { + if (sp.contains(Constants.LOCAL_PROFILE + "mgdl")) { doConversion() return } - numOfProfiles = sp.getInt(LOCAL_PROFILE + "_profiles", 0) + numOfProfiles = sp.getInt(Constants.LOCAL_PROFILE + "_profiles", 0) profiles.clear() numOfProfiles = max(numOfProfiles, 1) // create at least one default profile if none exists for (i in 0 until numOfProfiles) { val p = SingleProfile() - val LOCAL_PROFILE_NUMBERED = LOCAL_PROFILE + "_" + i + "_" + val LOCAL_PROFILE_NUMBERED = Constants.LOCAL_PROFILE + "_" + i + "_" - p.name = sp.getString(LOCAL_PROFILE_NUMBERED + "name", LOCAL_PROFILE + i) + p.name = sp.getString(LOCAL_PROFILE_NUMBERED + "name", Constants.LOCAL_PROFILE + i) if (isExistingName(p.name)) continue p.mgdl = sp.getBoolean(LOCAL_PROFILE_NUMBERED + "mgdl", false) p.dia = sp.getDouble(LOCAL_PROFILE_NUMBERED + "dia", Constants.defaultDIA) @@ -240,10 +235,10 @@ class LocalProfilePlugin @Inject constructor( aapsLogger.debug(LTag.PROFILE, "Loading stored settings") val p = SingleProfile() - p.mgdl = sp.getBoolean(LOCAL_PROFILE + "mgdl", profileFunction.getUnits() == Constants.MGDL) - p.dia = sp.getDouble(LOCAL_PROFILE + "dia", Constants.defaultDIA) + p.mgdl = sp.getBoolean(Constants.LOCAL_PROFILE + "mgdl", profileFunction.getUnits() == Constants.MGDL) + p.dia = sp.getDouble(Constants.LOCAL_PROFILE + "dia", Constants.defaultDIA) try { - p.ic = JSONArray(sp.getString(LOCAL_PROFILE + "ic", defaultArray)) + p.ic = JSONArray(sp.getString(Constants.LOCAL_PROFILE + "ic", defaultArray)) } catch (e1: JSONException) { try { p.ic = JSONArray(defaultArray) @@ -252,7 +247,7 @@ class LocalProfilePlugin @Inject constructor( } try { - p.isf = JSONArray(sp.getString(LOCAL_PROFILE + "isf", defaultArray)) + p.isf = JSONArray(sp.getString(Constants.LOCAL_PROFILE + "isf", defaultArray)) } catch (e1: JSONException) { try { p.isf = JSONArray(defaultArray) @@ -261,7 +256,7 @@ class LocalProfilePlugin @Inject constructor( } try { - p.basal = JSONArray(sp.getString(LOCAL_PROFILE + "basal", defaultArray)) + p.basal = JSONArray(sp.getString(Constants.LOCAL_PROFILE + "basal", defaultArray)) } catch (e1: JSONException) { try { p.basal = JSONArray(defaultArray) @@ -270,7 +265,7 @@ class LocalProfilePlugin @Inject constructor( } try { - p.targetLow = JSONArray(sp.getString(LOCAL_PROFILE + "targetlow", defaultArray)) + p.targetLow = JSONArray(sp.getString(Constants.LOCAL_PROFILE + "targetlow", defaultArray)) } catch (e1: JSONException) { try { p.targetLow = JSONArray(defaultArray) @@ -279,23 +274,23 @@ class LocalProfilePlugin @Inject constructor( } try { - p.targetHigh = JSONArray(sp.getString(LOCAL_PROFILE + "targethigh", defaultArray)) + p.targetHigh = JSONArray(sp.getString(Constants.LOCAL_PROFILE + "targethigh", defaultArray)) } catch (e1: JSONException) { try { p.targetHigh = JSONArray(defaultArray) } catch (ignored: JSONException) { } } - p.name = LOCAL_PROFILE + p.name = Constants.LOCAL_PROFILE - sp.remove(LOCAL_PROFILE + "mgdl") - sp.remove(LOCAL_PROFILE + "mmol") - sp.remove(LOCAL_PROFILE + "dia") - sp.remove(LOCAL_PROFILE + "ic") - sp.remove(LOCAL_PROFILE + "isf") - sp.remove(LOCAL_PROFILE + "basal") - sp.remove(LOCAL_PROFILE + "targetlow") - sp.remove(LOCAL_PROFILE + "targethigh") + sp.remove(Constants.LOCAL_PROFILE + "mgdl") + sp.remove(Constants.LOCAL_PROFILE + "mmol") + sp.remove(Constants.LOCAL_PROFILE + "dia") + sp.remove(Constants.LOCAL_PROFILE + "ic") + sp.remove(Constants.LOCAL_PROFILE + "isf") + sp.remove(Constants.LOCAL_PROFILE + "basal") + sp.remove(Constants.LOCAL_PROFILE + "targetlow") + sp.remove(Constants.LOCAL_PROFILE + "targethigh") currentProfileIndex = 0 numOfProfiles = 1 @@ -352,13 +347,13 @@ class LocalProfilePlugin @Inject constructor( fun addNewProfile() { var free = 0 for (i in 1..10000) { - if (rawProfile?.getSpecificProfile(LOCAL_PROFILE + i) == null) { + if (rawProfile?.getSpecificProfile(Constants.LOCAL_PROFILE + i) == null) { free = i break } } val p = SingleProfile() - p.name = LOCAL_PROFILE + free + p.name = Constants.LOCAL_PROFILE + free p.mgdl = profileFunction.getUnits() == Constants.MGDL p.dia = Constants.defaultDIA p.ic = JSONArray(defaultArray) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt index 87831d5352..119f2b41a0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt @@ -9,7 +9,7 @@ import android.widget.ArrayAdapter import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.profile.ns.events.EventNSProfileUpdateGUI import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DateUtil diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt index a93cbaad01..31aa4a2df1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt @@ -4,7 +4,7 @@ import android.content.Intent import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.R -import info.nightscout.androidaps.data.ProfileStore +import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.events.EventProfileStoreChanged import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription @@ -27,15 +27,16 @@ class NSProfilePlugin @Inject constructor( aapsLogger: AAPSLogger, private val rxBus: RxBusWrapper, resourceHelper: ResourceHelper, - private val sp: SP + private val sp: SP, + config: Config ) : PluginBase(PluginDescription() .mainType(PluginType.PROFILE) .fragmentClass(NSProfileFragment::class.java.name) .pluginName(R.string.nsprofile) .shortName(R.string.profileviewer_shortname) - .alwaysEnabled(Config.NSCLIENT) - .alwaysVisible(Config.NSCLIENT) - .showInList(!Config.NSCLIENT) + .alwaysEnabled(config.NSCLIENT) + .alwaysVisible(config.NSCLIENT) + .showInList(!config.NSCLIENT) .description(R.string.description_profile_nightscout), aapsLogger, resourceHelper, injector ), ProfileInterface { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index 0ec21a8014..ace9df0a97 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -44,7 +44,7 @@ import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.common.ManufacturerType; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType; import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; @@ -65,7 +65,7 @@ import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.PumpH import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.PumpHistoryRequest; import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Tdd; import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.InstanceId; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java index 126b017b5e..f4dd6a48df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java @@ -37,9 +37,8 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewB import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus; 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.service.RileyLinkService; import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.FabricPrivacy; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/PumpStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/PumpStatus.java index 34a3418902..3c51b484e8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/PumpStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/PumpStatus.java @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.common.data; import java.util.Date; -import info.nightscout.androidaps.data.ProfileStore; +import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType; import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.utils.DateUtil; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.java index 48d1df3b9d..bbe96c41c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.java @@ -6,6 +6,7 @@ import java.util.List; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; + /** * This file was taken from GGC - GNU Gluco Control (ggc.sourceforge.net), application for diabetes * management and modified/extended for AAPS. diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt index 9a8477ae2d..3b4f84a4d8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt @@ -46,6 +46,7 @@ class DanaRFragment : DaggerFragment() { @Inject lateinit var danaRPump: DanaRPump @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var warnColors: WarnColors + @Inject lateinit var dateUtil: DateUtil private var disposable: CompositeDisposable = CompositeDisposable() @@ -155,7 +156,7 @@ class DanaRFragment : DaggerFragment() { if (pump.lastConnection != 0L) { val agoMsec = System.currentTimeMillis() - pump.lastConnection val agoMin = (agoMsec.toDouble() / 60.0 / 1000.0).toInt() - danar_lastconnection.text = DateUtil.timeString(pump.lastConnection) + " (" + resourceHelper.gs(R.string.minago, agoMin) + ")" + danar_lastconnection.text = dateUtil.timeString(pump.lastConnection) + " (" + resourceHelper.gs(R.string.minago, agoMin) + ")" warnColors.setColor(danar_lastconnection, agoMin.toDouble(), 16.0, 31.0) } if (pump.lastBolusTime != 0L) { @@ -163,7 +164,7 @@ class DanaRFragment : DaggerFragment() { val agoHours = agoMsec.toDouble() / 60.0 / 60.0 / 1000.0 if (agoHours < 6) // max 6h back - danar_lastbolus.text = DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime, resourceHelper) + " " + resourceHelper.gs(R.string.formatinsulinunits, pump.lastBolusAmount) + danar_lastbolus.text = dateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime, resourceHelper) + " " + resourceHelper.gs(R.string.formatinsulinunits, pump.lastBolusAmount) else danar_lastbolus.text = "" } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java index 3c6ce84c42..95fdc80829 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java @@ -29,7 +29,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.plugins.pump.danaR.services.DanaRExecutionService; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.Round; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt index 0621fd80ad..2f18df687e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt @@ -4,10 +4,10 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.data.ProfileStore +import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.utils.sharedPreferences.SP import org.json.JSONArray import org.json.JSONException diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt index 0daed24ddb..288e10ef9d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt @@ -21,7 +21,7 @@ import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStart.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStart.kt index 695c3f1ec0..e0e2df7a90 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStart.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStart.kt @@ -4,7 +4,6 @@ import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump class MsgBolusStart( diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeed.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeed.kt index 3ea3eed8f1..8080166af1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeed.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStartWithSpeed.kt @@ -4,7 +4,6 @@ import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump class MsgBolusStartWithSpeed( diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/AbstractDanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/AbstractDanaRExecutionService.java index f93ce4a780..a72d813199 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/AbstractDanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/AbstractDanaRExecutionService.java @@ -21,7 +21,6 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventBTChange; -import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; @@ -41,7 +40,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistorySuspend; import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgPCCommStart; import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgPCCommStop; import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.ToastUtils; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java index 832826cf52..510ba70578 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java @@ -1,8 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaR.services; -import android.bluetooth.BluetoothDevice; import android.content.Context; -import android.content.IntentFilter; import android.os.Binder; import android.os.SystemClock; @@ -17,9 +15,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.dialogs.BolusProgressDialog; -import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventInitializationChanged; -import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.ActivePluginProvider; @@ -29,7 +25,7 @@ import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress; @@ -67,15 +63,12 @@ import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgStatusBolusExtended import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgStatusTempBasal; import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRNewStatus; import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.commands.Command; import info.nightscout.androidaps.utils.DateUtil; -import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; -import io.reactivex.disposables.CompositeDisposable; -import io.reactivex.schedulers.Schedulers; public class DanaRExecutionService extends AbstractDanaRExecutionService { @Inject AAPSLogger aapsLogger; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java index 809cf77e6f..57d14c36b4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java @@ -31,7 +31,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.plugins.pump.danaR.AbstractDanaRPlugin; import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump; import info.nightscout.androidaps.plugins.pump.danaRKorean.services.DanaRKoreanExecutionService; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.Round; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java index 0d18b1ecef..96de7ad78d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java @@ -1,8 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRKorean.services; -import android.bluetooth.BluetoothDevice; import android.content.Context; -import android.content.IntentFilter; import android.os.Binder; import android.os.SystemClock; @@ -16,9 +14,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.dialogs.BolusProgressDialog; -import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventInitializationChanged; -import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.ActivePluginProvider; @@ -28,7 +24,7 @@ import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; @@ -59,14 +55,11 @@ import info.nightscout.androidaps.plugins.pump.danaRKorean.comm.MessageHashTable import info.nightscout.androidaps.plugins.pump.danaRKorean.comm.MsgCheckValue_k; import info.nightscout.androidaps.plugins.pump.danaRKorean.comm.MsgSettingBasal_k; import info.nightscout.androidaps.plugins.pump.danaRKorean.comm.MsgStatusBasic_k; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.queue.commands.Command; import info.nightscout.androidaps.utils.DateUtil; -import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.resources.ResourceHelper; -import io.reactivex.disposables.CompositeDisposable; -import io.reactivex.schedulers.Schedulers; public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { @Inject AAPSLogger aapsLogger; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java index 2227c905a9..8d5b8093b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java @@ -41,7 +41,7 @@ import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.common.ManufacturerType; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType; import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; @@ -54,7 +54,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump; import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSDeviceChange; import info.nightscout.androidaps.plugins.pump.danaRS.services.DanaRSService; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt index 2edf5254b3..3e64372fc7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt @@ -8,6 +8,7 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject @@ -23,7 +24,8 @@ class DanaRSMessageHashTable @Inject constructor( activePlugin: ActivePluginProvider, constraintChecker: ConstraintChecker, detailedBolusInfoStorage: DetailedBolusInfoStorage, - injector: HasAndroidInjector + injector: HasAndroidInjector, + dateUtil: DateUtil ) { var messages: HashMap = HashMap() @@ -101,7 +103,7 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus)) // APS put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0)) - put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector,0)) + put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, dateUtil, 0)) put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, 0, 0, 0, 0)) } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt index 4681e68e92..a3b57d12ef 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt @@ -27,6 +27,7 @@ open class DanaRS_Packet_APS_History_Events( private val danaRSPlugin: DanaRSPlugin, private val detailedBolusInfoStorage: DetailedBolusInfoStorage, private val injector: HasAndroidInjector, + private val dateUtil: DateUtil, private var from: Long ) : DanaRS_Packet() { @@ -86,13 +87,13 @@ open class DanaRS_Packet_APS_History_Events( temporaryBasal.percentRate = param1 temporaryBasal.durationInMinutes = param2 activePlugin.activeTreatments.addToHistoryTempBasal(temporaryBasal) - status = "TEMPSTART " + DateUtil.timeString(datetime) + status = "TEMPSTART " + dateUtil.timeString(datetime) } DanaRPump.TEMPSTOP -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime)) activePlugin.activeTreatments.addToHistoryTempBasal(temporaryBasal) - status = "TEMPSTOP " + DateUtil.timeString(datetime) + status = "TEMPSTOP " + dateUtil.timeString(datetime) } DanaRPump.EXTENDEDSTART -> { @@ -100,13 +101,13 @@ open class DanaRS_Packet_APS_History_Events( extendedBolus.insulin = param1 / 100.0 extendedBolus.durationInMinutes = param2 activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) - status = "EXTENDEDSTART " + DateUtil.timeString(datetime) + status = "EXTENDEDSTART " + dateUtil.timeString(datetime) } DanaRPump.EXTENDEDSTOP -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) - status = "EXTENDEDSTOP " + DateUtil.timeString(datetime) + status = "EXTENDEDSTOP " + dateUtil.timeString(datetime) } DanaRPump.BOLUS -> { @@ -118,7 +119,7 @@ open class DanaRS_Packet_APS_History_Events( detailedBolusInfo.insulin = param1 / 100.0 val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") - status = "BOLUS " + DateUtil.timeString(datetime) + status = "BOLUS " + dateUtil.timeString(datetime) } DanaRPump.DUALBOLUS -> { @@ -130,7 +131,7 @@ open class DanaRS_Packet_APS_History_Events( detailedBolusInfo.insulin = param1 / 100.0 val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") - status = "DUALBOLUS " + DateUtil.timeString(datetime) + status = "DUALBOLUS " + dateUtil.timeString(datetime) } DanaRPump.DUALEXTENDEDSTART -> { @@ -138,38 +139,38 @@ open class DanaRS_Packet_APS_History_Events( extendedBolus.insulin = param1 / 100.0 extendedBolus.durationInMinutes = param2 activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) - status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime) + status = "DUALEXTENDEDSTART " + dateUtil.timeString(datetime) } DanaRPump.DUALEXTENDEDSTOP -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) - status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime) + status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime) } DanaRPump.SUSPENDON -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDON (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") - status = "SUSPENDON " + DateUtil.timeString(datetime) + status = "SUSPENDON " + dateUtil.timeString(datetime) } DanaRPump.SUSPENDOFF -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") - status = "SUSPENDOFF " + DateUtil.timeString(datetime) + status = "SUSPENDOFF " + dateUtil.timeString(datetime) } DanaRPump.REFILL -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT REFILL (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") - status = "REFILL " + DateUtil.timeString(datetime) + status = "REFILL " + dateUtil.timeString(datetime) } DanaRPump.PRIME -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIME (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") - status = "PRIME " + DateUtil.timeString(datetime) + status = "PRIME " + dateUtil.timeString(datetime) } DanaRPump.PROFILECHANGE -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h") - status = "PROFILECHANGE " + DateUtil.timeString(datetime) + status = "PROFILECHANGE " + dateUtil.timeString(datetime) } DanaRPump.CARBS -> { @@ -180,17 +181,17 @@ open class DanaRS_Packet_APS_History_Events( emptyCarbsInfo.pumpId = datetime val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(emptyCarbsInfo, false) aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g") - status = "CARBS " + DateUtil.timeString(datetime) + status = "CARBS " + dateUtil.timeString(datetime) } DanaRPump.PRIMECANNULA -> { aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIMECANNULA(" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") - status = "PRIMECANNULA " + DateUtil.timeString(datetime) + status = "PRIMECANNULA " + dateUtil.timeString(datetime) } else -> { aapsLogger.debug(LTag.PUMPCOMM, "Event: " + recordCode + " " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) - status = "UNKNOWN " + DateUtil.timeString(datetime) + status = "UNKNOWN " + dateUtil.timeString(datetime) } } if (datetime > danaRSPlugin.lastEventTimeLoaded) danaRSPlugin.lastEventTimeLoaded = datetime diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java index 3d7eb03e0a..5122f012f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java @@ -27,7 +27,7 @@ import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress; @@ -75,7 +75,7 @@ import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_History import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Option_Get_Pump_Time; import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Option_Get_User_Option; import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_Option_Set_Pump_Time; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.commands.Command; import info.nightscout.androidaps.utils.DateUtil; @@ -101,6 +101,7 @@ public class DanaRSService extends DaggerService { @Inject ActivePluginProvider activePlugin; @Inject ConstraintChecker constraintChecker; @Inject DetailedBolusInfoStorage detailedBolusInfoStorage; + @Inject DateUtil dateUtil; private CompositeDisposable disposable = new CompositeDisposable(); @@ -271,10 +272,10 @@ public class DanaRSService extends DaggerService { DanaRS_Packet_APS_History_Events msg; if (lastHistoryFetched == 0) { - msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, 0); + msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, dateUtil, 0); aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history"); } else { - msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, lastHistoryFetched); + msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, dateUtil, lastHistoryFetched); aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)); } bleComm.sendMessage(msg); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java index e783d13d78..9a88ce28f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java @@ -29,7 +29,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.plugins.pump.danaR.AbstractDanaRPlugin; import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump; import info.nightscout.androidaps.plugins.pump.danaRv2.services.DanaRv2ExecutionService; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt index 7fbb2f3258..f02062e05b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt @@ -14,6 +14,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.comm.* import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject @@ -34,7 +35,8 @@ class MessageHashTableRv2 @Inject constructor( activePlugin: ActivePluginProvider, detailedBolusInfoStorage: DetailedBolusInfoStorage, treatmentsPlugin: TreatmentsPlugin, - injector: HasAndroidInjector + injector: HasAndroidInjector, + dateUtil: DateUtil ) : MessageHashTableBase { var messages: HashMap = HashMap() @@ -93,7 +95,7 @@ class MessageHashTableRv2 @Inject constructor( put(MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue)) // 0xF0F1 CMD_PUMP_CHECK_VALUE put(MsgStatusAPS_v2(aapsLogger, danaRPump)) // 0xE001 CMD_PUMPSTATUS_APS put(MsgSetAPSTempBasalStart_v2(aapsLogger, 0, false, false)) // 0xE002 CMD_PUMPSET_APSTEMP - put(MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin, injector)) // 0xE003 CMD_GET_HISTORY + put(MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin, injector, dateUtil)) // 0xE003 CMD_GET_HISTORY put(MsgSetHistoryEntry_v2(aapsLogger, 0, 0, 0, 0)) // 0xE004 CMD_SET_HISTORY_ENTRY } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2.kt index 0280b0a3e6..4f07a49ff9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2.kt @@ -27,6 +27,7 @@ class MsgHistoryEvents_v2 constructor( val rxBus: RxBusWrapper, val treatmentsPlugin: TreatmentsPlugin, private val injector: HasAndroidInjector, + private val dateUtil: DateUtil, var from: Long = 0 ) : MessageBase() { @@ -78,13 +79,13 @@ class MsgHistoryEvents_v2 constructor( temporaryBasal.percentRate = param1 temporaryBasal.durationInMinutes = param2 treatmentsPlugin.addToHistoryTempBasal(temporaryBasal) - status = "TEMPSTART " + DateUtil.timeString(datetime) + status = "TEMPSTART " + dateUtil.timeString(datetime) } DanaRPump.TEMPSTOP -> { aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime)) treatmentsPlugin.addToHistoryTempBasal(temporaryBasal) - status = "TEMPSTOP " + DateUtil.timeString(datetime) + status = "TEMPSTOP " + dateUtil.timeString(datetime) } DanaRPump.EXTENDEDSTART -> { @@ -92,13 +93,13 @@ class MsgHistoryEvents_v2 constructor( extendedBolus.insulin = param1 / 100.0 extendedBolus.durationInMinutes = param2 treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) - status = "EXTENDEDSTART " + DateUtil.timeString(datetime) + status = "EXTENDEDSTART " + dateUtil.timeString(datetime) } DanaRPump.EXTENDEDSTOP -> { aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) - status = "EXTENDEDSTOP " + DateUtil.timeString(datetime) + status = "EXTENDEDSTOP " + dateUtil.timeString(datetime) } DanaRPump.BOLUS -> { @@ -110,7 +111,7 @@ class MsgHistoryEvents_v2 constructor( detailedBolusInfo.insulin = param1 / 100.0 val newRecord = treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false) aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") - status = "BOLUS " + DateUtil.timeString(datetime) + status = "BOLUS " + dateUtil.timeString(datetime) } DanaRPump.DUALBOLUS -> { @@ -122,7 +123,7 @@ class MsgHistoryEvents_v2 constructor( detailedBolusInfo.insulin = param1 / 100.0 val newRecord = treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false) aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") - status = "DUALBOLUS " + DateUtil.timeString(datetime) + status = "DUALBOLUS " + dateUtil.timeString(datetime) } DanaRPump.DUALEXTENDEDSTART -> { @@ -130,38 +131,38 @@ class MsgHistoryEvents_v2 constructor( extendedBolus.insulin = param1 / 100.0 extendedBolus.durationInMinutes = param2 treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) - status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime) + status = "DUALEXTENDEDSTART " + dateUtil.timeString(datetime) } DanaRPump.DUALEXTENDEDSTOP -> { aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) - status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime) + status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime) } DanaRPump.SUSPENDON -> { aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT SUSPENDON (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") - status = "SUSPENDON " + DateUtil.timeString(datetime) + status = "SUSPENDON " + dateUtil.timeString(datetime) } DanaRPump.SUSPENDOFF -> { aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") - status = "SUSPENDOFF " + DateUtil.timeString(datetime) + status = "SUSPENDOFF " + dateUtil.timeString(datetime) } DanaRPump.REFILL -> { aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT REFILL (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") - status = "REFILL " + DateUtil.timeString(datetime) + status = "REFILL " + dateUtil.timeString(datetime) } DanaRPump.PRIME -> { aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT PRIME (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") - status = "PRIME " + DateUtil.timeString(datetime) + status = "PRIME " + dateUtil.timeString(datetime) } DanaRPump.PROFILECHANGE -> { aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h") - status = "PROFILECHANGE " + DateUtil.timeString(datetime) + status = "PROFILECHANGE " + dateUtil.timeString(datetime) } DanaRPump.CARBS -> { @@ -172,12 +173,12 @@ class MsgHistoryEvents_v2 constructor( emptyCarbsInfo.pumpId = datetime val newRecord = treatmentsPlugin.addToHistoryTreatment(emptyCarbsInfo, false) aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g") - status = "CARBS " + DateUtil.timeString(datetime) + status = "CARBS " + dateUtil.timeString(datetime) } else -> { aapsLogger.debug(LTag.PUMPBTCOMM, "Event: " + recordCode + " " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) - status = "UNKNOWN " + DateUtil.timeString(datetime) + status = "UNKNOWN " + dateUtil.timeString(datetime) } } if (datetime > danaRv2Plugin.lastEventTimeLoaded) danaRv2Plugin.lastEventTimeLoaded = datetime diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java index 564b59e77f..ba2729c672 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java @@ -1,9 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRv2.services; -import android.bluetooth.BluetoothDevice; import android.content.Context; import android.content.Intent; -import android.content.IntentFilter; import android.os.Binder; import android.os.SystemClock; @@ -19,9 +17,7 @@ import info.nightscout.androidaps.activities.ErrorHelperActivity; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.dialogs.BolusProgressDialog; -import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventInitializationChanged; -import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.ActivePluginProvider; @@ -32,7 +28,7 @@ import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress; @@ -76,17 +72,14 @@ import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgSetAPSTempBasalSt import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgSetHistoryEntry_v2; import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgStatusBolusExtended_v2; import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgStatusTempBasal_v2; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.commands.Command; import info.nightscout.androidaps.utils.DateUtil; -import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; -import io.reactivex.disposables.CompositeDisposable; -import io.reactivex.schedulers.Schedulers; public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { @Inject HasAndroidInjector injector; @@ -107,6 +100,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { @Inject TreatmentsPlugin treatmentsPlugin; @Inject ProfileFunction profileFunction; @Inject SP sp; + @Inject DateUtil dateUtil; private long lastHistoryFetched = 0; @@ -455,7 +449,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { if (!isConnected()) return new PumpEnactResult(injector).success(false); SystemClock.sleep(300); - MsgHistoryEvents_v2 msg = new MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin, injector, lastHistoryFetched); + MsgHistoryEvents_v2 msg = new MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin, injector, dateUtil, lastHistoryFetched); aapsLogger.debug(LTag.PUMP, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)); mSerialIOThread.sendMessage(msg); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightFragment.java index 603e8aabb9..2c1c9b6e91 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightFragment.java @@ -44,6 +44,7 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick @Inject RxBusWrapper rxBus; @Inject ResourceHelper resourceHelper; @Inject FabricPrivacy fabricPrivacy; + @Inject DateUtil dateUtil; private CompositeDisposable disposable = new CompositeDisposable(); @@ -237,7 +238,7 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick long lastConnection = localInsightPlugin.getConnectionService().getLastConnected(); if (lastConnection == 0) return; int min = (int) ((System.currentTimeMillis() - lastConnection) / 60000); - statusItems.add(getStatusItem(resourceHelper.gs(R.string.last_connected), DateUtil.timeString(lastConnection))); + statusItems.add(getStatusItem(resourceHelper.gs(R.string.last_connected), dateUtil.timeString(lastConnection))); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index b91823a24a..b147d01b10 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -53,7 +53,7 @@ import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.common.ManufacturerType; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; @@ -132,7 +132,7 @@ import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_erro import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.NoActiveTBRToCanceLException; import info.nightscout.androidaps.plugins.pump.insight.utils.ExceptionTranslator; import info.nightscout.androidaps.plugins.pump.insight.utils.ParameterBlockUtil; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.TimeChangeType; @@ -208,7 +208,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, SP sp, CommandQueueProvider commandQueue, ProfileFunction profileFunction, - Context context + Context context, + Config config ) { super(new PluginDescription() .pluginName(R.string.insight_local) @@ -216,7 +217,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, .mainType(PluginType.PUMP) .description(R.string.description_pump_insight_local) .fragmentClass(LocalInsightFragment.class.getName()) - .preferencesId(Config.APS ? R.xml.pref_insight_local_full : R.xml.pref_insight_local_pumpcontrol), + .preferencesId(config.getAPS() ? R.xml.pref_insight_local_full : R.xml.pref_insight_local_pumpcontrol), injector, aapsLogger, resourceHelper, commandQueue ); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java index 496f2af06b..d8f5c47b4f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java @@ -35,7 +35,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.common.defs.PumpType; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil; import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder; @@ -52,7 +51,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalProce import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentService; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.DateUtil; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt index c3a7bfeccd..826d28b7ce 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodManagementActivity.kt @@ -13,7 +13,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.FullInitPodWizardModel diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java index 7cb106ca47..387daee11a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitActionFragment.java @@ -24,11 +24,8 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import javax.inject.Inject; - import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.PumpEnactResult; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java index 32f6eabac4..1ab711871c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/initpod/InitPodTask.java @@ -1,12 +1,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod; import android.os.AsyncTask; -import android.os.SystemClock; import android.view.View; import javax.inject.Inject; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt index d534e51e2f..3ca7e671ff 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt @@ -84,6 +84,6 @@ class VirtualPumpFragment : DaggerFragment() { val pumpType = virtualPumpPlugin.pumpType virtualpump_type?.text = pumpType?.description - virtualpump_type_def?.text = pumpType?.getFullDescription(resourceHelper.gs(R.string.virtualpump_pump_def), pumpType.hasExtendedBasals()) + virtualpump_type_def?.text = pumpType?.getFullDescription(resourceHelper.gs(R.string.virtualpump_pump_def), pumpType.hasExtendedBasals(), resourceHelper) } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt index 007d585408..9dbaea4025 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt @@ -17,7 +17,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.common.ManufacturerType -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification @@ -51,14 +51,15 @@ class VirtualPumpPlugin @Inject constructor( private val sp: SP, private val profileFunction: ProfileFunction, private val treatmentsPlugin: TreatmentsPlugin, - commandQueue: CommandQueueProvider + commandQueue: CommandQueueProvider, + private val config: Config ) : PumpPluginBase(PluginDescription() .mainType(PluginType.PUMP) .fragmentClass(VirtualPumpFragment::class.java.name) .pluginName(R.string.virtualpump) .shortName(R.string.virtualpump_shortname) .preferencesId(R.xml.pref_virtualpump) - .neverVisible(Config.NSCLIENT) + .neverVisible(config.NSCLIENT) .description(R.string.description_pump_virtual) .setDefault(), injector, aapsLogger, resourceHelper, commandQueue @@ -131,7 +132,7 @@ class VirtualPumpPlugin @Inject constructor( } override fun isFakingTempsByExtendedBoluses(): Boolean { - return Config.NSCLIENT && getFakingStatus() + return config.NSCLIENT && getFakingStatus() } override fun loadTDDs(): PumpEnactResult { //no result, could read DB in the future? diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPlugin.kt index 43e8b89a5d..ced1bcd888 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPlugin.kt @@ -2,13 +2,13 @@ package info.nightscout.androidaps.plugins.sensitivity import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.SensitivityInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.utils.Round import info.nightscout.androidaps.utils.SafeParse import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -25,7 +25,7 @@ abstract class AbstractSensitivityPlugin( val sp: SP ) : PluginBase(pluginDescription, aapsLogger, resourceHelper, injector), SensitivityInterface { - abstract override fun detectSensitivity(plugin: IobCobCalculatorPlugin, fromTime: Long, toTime: Long): AutosensResult + abstract override fun detectSensitivity(plugin: IobCobCalculatorInterface, fromTime: Long, toTime: Long): AutosensResult fun fillResult(ratio: Double, carbsAbsorbed: Double, pastSensitivity: String, ratioLimit: String, sensResult: String, deviationsArraySize: Int): AutosensResult { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java index 090e980d9f..317a25bdf9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java @@ -16,12 +16,13 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.ProfileSwitch; +import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData; +import info.nightscout.androidaps.interfaces.ProfileFunction; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.utils.DateUtil; @@ -60,7 +61,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { } @NonNull @Override - public AutosensResult detectSensitivity(IobCobCalculatorPlugin iobCobCalculatorPlugin, long fromTime, long toTime) { + public AutosensResult detectSensitivity(IobCobCalculatorInterface iobCobCalculatorPlugin, long fromTime, long toTime) { LongSparseArray autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); String age = sp.getString(R.string.key_age, ""); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java index 8424a65a93..97fb1a68bc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java @@ -15,14 +15,15 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.ProfileSwitch; +import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -58,7 +59,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { } @Override - public AutosensResult detectSensitivity(IobCobCalculatorPlugin iobCobCalculatorPlugin, long fromTime, long toTime) { + public AutosensResult detectSensitivity(IobCobCalculatorInterface iobCobCalculatorPlugin, long fromTime, long toTime) { // todo this method is called from the IobCobCalculatorPlugin, which leads to a circular // dependency, this should be avoided LongSparseArray autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); @@ -88,13 +89,13 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { //[0] = 8 hour //[1] = 24 hour //Deviationshour has DeviationsArray - List deviationsHour = Arrays.asList(new ArrayList(),new ArrayList()); - List pastSensitivityArray = Arrays.asList("",""); - List sensResultArray = Arrays.asList("",""); - List ratioArray = Arrays.asList(0d,0d); - List deviationCategory = Arrays.asList(96d,288d); - List ratioLimitArray = Arrays.asList("",""); - List hoursDetection = Arrays.asList(8d,24d); + List deviationsHour = Arrays.asList(new ArrayList(), new ArrayList()); + List pastSensitivityArray = Arrays.asList("", ""); + List sensResultArray = Arrays.asList("", ""); + List ratioArray = Arrays.asList(0d, 0d); + List deviationCategory = Arrays.asList(96d, 288d); + List ratioLimitArray = Arrays.asList("", ""); + List hoursDetection = Arrays.asList(8d, 24d); int index = 0; @@ -113,7 +114,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { int hoursegment = 0; //hoursegment = 0 = 8 hour //hoursegment = 1 = 24 hour - while (hoursegment < deviationsHour.size()){ + while (hoursegment < deviationsHour.size()) { ArrayList deviationsArray = deviationsHour.get(hoursegment); String pastSensitivity = pastSensitivityArray.get(hoursegment); @@ -124,7 +125,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { } // reset deviations after profile switch - if (ProfileSwitch.isEvent5minBack(getAapsLogger(),profileSwitches, autosensData.time, true)) { + if (ProfileSwitch.isEvent5minBack(getAapsLogger(), profileSwitches, autosensData.time, true)) { deviationsArray.clear(); pastSensitivity += "(PROFILESWITCH)"; } @@ -143,7 +144,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { for (int i = 0; i < autosensData.extraDeviation.size(); i++) deviationsArray.add(autosensData.extraDeviation.get(i)); - if (deviationsArray.size() > deviationCategory.get(hoursegment)){ + if (deviationsArray.size() > deviationCategory.get(hoursegment)) { deviationsArray.remove(0); } @@ -155,11 +156,11 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { } //Update the data back to the parent - deviationsHour.set(hoursegment,deviationsArray); - pastSensitivityArray.set(hoursegment,pastSensitivity); + deviationsHour.set(hoursegment, deviationsArray); + pastSensitivityArray.set(hoursegment, pastSensitivity); hoursegment++; - } - index++; + } + index++; } // when we have less than 8h/24 worth of deviation data, add up to 90m of zero deviations @@ -167,26 +168,27 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { for (int i = 0; i < deviationsHour.size(); i++) { ArrayList deviations = deviationsHour.get(i); - getAapsLogger().debug(LTag.AUTOSENS,"Using most recent " + deviations.size() + " deviations"); + getAapsLogger().debug(LTag.AUTOSENS, "Using most recent " + deviations.size() + " deviations"); if (deviations.size() < deviationCategory.get(i)) { int pad = (int) Math.round((1 - (double) deviations.size() / deviationCategory.get(i)) * 18); - getAapsLogger().debug(LTag.AUTOSENS,"Adding " + pad + " more zero deviations"); - for (int d = 0; d < pad; d++) { ; + getAapsLogger().debug(LTag.AUTOSENS, "Adding " + pad + " more zero deviations"); + for (int d = 0; d < pad; d++) { + ; deviations.add(0d); } } //Update the data back to the parent - deviationsHour.set(i,deviations); + deviationsHour.set(i, deviations); } int hourused = 0; - while (hourused < deviationsHour.size()){ + while (hourused < deviationsHour.size()) { ArrayList deviationsArray = deviationsHour.get(hourused); String pastSensitivity = pastSensitivityArray.get(hourused); String sensResult = "(8 hours) "; String senstime = sensResult; - if (hourused == 1){ + if (hourused == 1) { senstime = "(24 hours) "; sensResult = senstime; } @@ -198,7 +200,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { double sens = profile.getIsfMgdl(); - getAapsLogger().debug(LTag.AUTOSENS,"Records: " + index + " " + pastSensitivity); + getAapsLogger().debug(LTag.AUTOSENS, "Records: " + index + " " + pastSensitivity); Arrays.sort(deviations); double pSensitive = IobCobCalculatorPlugin.percentile(deviations, 0.50); @@ -208,35 +210,35 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { if (pSensitive < 0) { // sensitive basalOff = pSensitive * (60 / 5) / Profile.toMgdl(sens, profile.getUnits()); - sensResult+= "Excess insulin sensitivity detected"; + sensResult += "Excess insulin sensitivity detected"; } else if (pResistant > 0) { // resistant basalOff = pResistant * (60 / 5) / Profile.toMgdl(sens, profile.getUnits()); - sensResult+= "Excess insulin resistance detected"; + sensResult += "Excess insulin resistance detected"; } else { - sensResult+= "Sensitivity normal"; + sensResult += "Sensitivity normal"; } - getAapsLogger().debug(LTag.AUTOSENS,sensResult); + getAapsLogger().debug(LTag.AUTOSENS, sensResult); double ratio = 1 + (basalOff / profile.getMaxDailyBasal()); //Update the data back to the parent - sensResultArray.set(hourused,sensResult); - ratioArray.set(hourused,ratio); - ratioLimitArray.set(hourused,ratioLimit); + sensResultArray.set(hourused, sensResult); + ratioArray.set(hourused, ratio); + ratioLimitArray.set(hourused, ratioLimit); hourused++; } int key = 1; - String comparison = " 8 h ratio " +ratioArray.get(0)+" vs 24h ratio "+ratioArray.get(1); + String comparison = " 8 h ratio " + ratioArray.get(0) + " vs 24h ratio " + ratioArray.get(1); //use 24 hour ratio by default //if the 8 hour ratio is less than the 24 hour ratio, the 8 hour ratio is used - if(ratioArray.get(0) < ratioArray.get(1)){ - key = 0; + if (ratioArray.get(0) < ratioArray.get(1)) { + key = 0; } - String message = hoursDetection.get(key)+" of sensitivity used"; + String message = hoursDetection.get(key) + " of sensitivity used"; AutosensResult output = fillResult(ratioArray.get(key), current.cob, pastSensitivityArray.get(key), ratioLimitArray.get(key), - sensResultArray.get(key)+comparison, deviationsHour.get(key).size()); + sensResultArray.get(key) + comparison, deviationsHour.get(key).size()); getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: " + DateUtil.dateAndTimeString(toTime) + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java index 09a4a20838..d2128791d8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java @@ -13,14 +13,14 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.ProfileSwitch; +import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -57,7 +57,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin } @Override - public AutosensResult detectSensitivity(IobCobCalculatorPlugin iobCobCalculatorPlugin, long fromTime, long toTime) { + public AutosensResult detectSensitivity(IobCobCalculatorInterface iobCobCalculatorPlugin, long fromTime, long toTime) { LongSparseArray autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); String age = sp.getString(R.string.key_age, ""); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt index f95b8b1a05..97b28f9dab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt @@ -12,8 +12,10 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.db.BgReading +import info.nightscout.androidaps.db.DatabaseHelper +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.source.BGSourceFragment.RecyclerViewAdapter.BgReadingsViewHolder @@ -32,6 +34,7 @@ class BGSourceFragment : DaggerFragment() { @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var databaseHelper: DatabaseHelperInterface private val disposable = CompositeDisposable() private val MILLS_TO_THE_PAST = T.hours(12).msecs() @@ -83,7 +86,7 @@ class BGSourceFragment : DaggerFragment() { holder.invalid.visibility = if (!bgReading.isValid) View.VISIBLE else View.GONE holder.date.text = DateUtil.dateAndTimeString(bgReading.date) holder.value.text = bgReading.valueToUnitsToString(profileFunction.getUnits()) - holder.direction.text = bgReading.directionToSymbol() + holder.direction.text = bgReading.directionToSymbol(databaseHelper) holder.remove.tag = bgReading } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java index cd81621252..f43ece03d8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java @@ -33,6 +33,7 @@ import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.ICallback; import info.nightscout.androidaps.db.Source; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.EventNsTreatment; import info.nightscout.androidaps.events.EventReloadTreatmentData; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java index 51c602bfd2..698db2c81f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java @@ -31,7 +31,8 @@ import info.nightscout.androidaps.data.NonOverlappingIntervals; import info.nightscout.androidaps.data.OverlappingIntervals; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.ProfileIntervals; -import info.nightscout.androidaps.data.ProfileStore; +import info.nightscout.androidaps.db.Treatment; +import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.Source; @@ -50,7 +51,7 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt index 7e130ceab9..673f9bdc23 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt @@ -14,12 +14,12 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.events.EventTreatmentChange import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.dialogs.WizardInfoDialog import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsBolusFragment.RecyclerViewAdapter.TreatmentsViewHolder diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt index 8ce87e6b5e..175fb81c97 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt @@ -40,6 +40,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy + @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -73,7 +74,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { } else { @SuppressLint("SetTextI18n") if (extendedBolus.isInProgress) holder.date.text = DateUtil.dateAndTimeString(extendedBolus.date) - else holder.date.text = DateUtil.dateAndTimeString(extendedBolus.date) + " - " + DateUtil.timeString(extendedBolus.end()) + else holder.date.text = DateUtil.dateAndTimeString(extendedBolus.date) + " - " + dateUtil.timeString(extendedBolus.end()) holder.duration.text = resourceHelper.gs(R.string.format_mins, extendedBolus.durationInMinutes) holder.insulin.text = resourceHelper.gs(R.string.formatinsulinunits, extendedBolus.insulin) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java index 1d95d4306b..8e1e6fb663 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java @@ -23,7 +23,7 @@ import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.events.EventTempTargetChange; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue; import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart; @@ -48,6 +48,7 @@ public class TreatmentsTempTargetFragment extends DaggerFragment { @Inject ProfileFunction profileFunction; @Inject ResourceHelper resourceHelper; @Inject FabricPrivacy fabricPrivacy; + @Inject DateUtil dateUtil; private CompositeDisposable disposable = new CompositeDisposable(); @@ -77,7 +78,7 @@ public class TreatmentsTempTargetFragment extends DaggerFragment { holder.ph.setVisibility(tempTarget.source == Source.PUMP ? View.VISIBLE : View.GONE); holder.ns.setVisibility(NSUpload.isIdValid(tempTarget._id) ? View.VISIBLE : View.GONE); if (!tempTarget.isEndingEvent()) { - holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date) + " - " + DateUtil.timeString(tempTarget.originalEnd())); + holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date) + " - " + dateUtil.timeString(tempTarget.originalEnd())); holder.duration.setText(DecimalFormatter.to0Decimal(tempTarget.durationInMinutes) + " min"); holder.low.setText(tempTarget.lowValueToUnitsToString(units)); holder.high.setText(tempTarget.highValueToUnitsToString(units)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt index d863754d07..99764c73bf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt @@ -20,7 +20,7 @@ import info.nightscout.androidaps.db.TemporaryBasal import info.nightscout.androidaps.events.EventTempBasalChange import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt index fd93f772aa..15f1eaa9f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt @@ -24,11 +24,12 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.queue.commands.Command import info.nightscout.androidaps.queue.commands.* import info.nightscout.androidaps.queue.commands.Command.CommandType import info.nightscout.androidaps.utils.FabricPrivacy diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt index 2c99b1e4f1..4ca7055636 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt @@ -16,7 +16,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.queue.commands.Command @@ -38,7 +38,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { @Inject lateinit var localAlertUtils: LocalAlertUtils @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var receiverStatusStore: ReceiverStatusStore - + @Inject lateinit var config: Config companion object { private val KEEP_ALIVE_MILLISECONDS = T.mins(5).msecs() @@ -100,8 +100,8 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { // IOB displayed in NS private fun checkAPS() { var shouldUploadStatus = false - if (Config.NSCLIENT) return - if (Config.PUMPCONTROL) shouldUploadStatus = true + if (config.NSCLIENT) return + if (config.PUMPCONTROL) shouldUploadStatus = true else if (!loopPlugin.isEnabled() || iobCobCalculatorPlugin.actualBg() == null) shouldUploadStatus = true else if (DateUtil.isOlderThan(activePlugin.activeAPS.lastAPSRun, 5)) shouldUploadStatus = true diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt index 5fca6651da..c8e406881b 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt @@ -19,7 +19,7 @@ import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs @@ -62,7 +62,8 @@ class SWDefinition @Inject constructor( private val protectionCheck: ProtectionCheck, private val importExportPrefs: ImportExportPrefs, private val androidPermission: AndroidPermission, - private val cryptoUtil: CryptoUtil + private val cryptoUtil: CryptoUtil, + private val config: Config ) { lateinit var activity: AppCompatActivity @@ -339,7 +340,7 @@ class SWDefinition @Inject constructor( }, null) }) .visibility(SWValidator { (activePlugin.activeAPS as PluginBase).preferencesId > 0 })) - .visibility(SWValidator { Config.APS }) + .visibility(SWValidator { config.APS }) private val screenApsMode = SWScreen(injector, R.string.apsmode_title) .skippable(false) .add(SWRadioButton(injector) @@ -364,7 +365,7 @@ class SWDefinition @Inject constructor( }) .visibility(SWValidator { !loopPlugin.isEnabled(PluginType.LOOP) })) .validator(SWValidator { loopPlugin.isEnabled(PluginType.LOOP) }) - .visibility(SWValidator { !loopPlugin.isEnabled(PluginType.LOOP) && Config.APS }) + .visibility(SWValidator { !loopPlugin.isEnabled(PluginType.LOOP) && config.APS }) private val screenSensitivity = SWScreen(injector, R.string.configbuilder_sensitivity) .skippable(false) .add(SWInfotext(injector) @@ -395,7 +396,7 @@ class SWDefinition @Inject constructor( .add(SWFragment(injector, this) .add(ObjectivesFragment())) .validator(SWValidator { objectivesPlugin.objectives[ObjectivesPlugin.FIRST_OBJECTIVE].isStarted }) - .visibility(SWValidator { !objectivesPlugin.objectives[ObjectivesPlugin.FIRST_OBJECTIVE].isStarted && Config.APS }) + .visibility(SWValidator { !objectivesPlugin.objectives[ObjectivesPlugin.FIRST_OBJECTIVE].isStarted && config.APS }) private fun swDefinitionFull() { // List all the screens here add(screenSetupWizard) @@ -468,6 +469,6 @@ class SWDefinition @Inject constructor( } init { - if (Config.APS) swDefinitionFull() else if (Config.PUMPCONTROL) swDefinitionPumpControl() else if (Config.NSCLIENT) swDefinitionNSClient() + if (config.APS) swDefinitionFull() else if (config.PUMPCONTROL) swDefinitionPumpControl() else if (config.NSCLIENT) swDefinitionNSClient() } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditNumberWithUnits.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditNumberWithUnits.kt index 80ed784fff..978455a4ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditNumberWithUnits.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditNumberWithUnits.kt @@ -9,7 +9,7 @@ import android.widget.TextView import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.setupwizard.SWNumberValidator import info.nightscout.androidaps.utils.NumberPicker import info.nightscout.androidaps.utils.SafeParse diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt index 3bc092dfc2..b2243d3336 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt @@ -6,14 +6,14 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class SkinButtonsOn @Inject constructor() : SkinInterface { +class SkinButtonsOn @Inject constructor(private val config: Config) : SkinInterface { override val description: Int get() = R.string.buttonson_desrciption override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int = when { - Config.NSCLIENT && isTablet -> R.layout.overview_fragment_nsclient_tablet - Config.NSCLIENT -> R.layout.overview_fragment_nsclient + config.NSCLIENT && isTablet -> R.layout.overview_fragment_nsclient_tablet + config.NSCLIENT -> R.layout.overview_fragment_nsclient else -> R.layout.overview_fragment } diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt index 15e69e9ad9..deef2440f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt @@ -6,14 +6,14 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class SkinClassic @Inject constructor(): SkinInterface { +class SkinClassic @Inject constructor(private val config: Config): SkinInterface { override val description: Int get() = R.string.classic_desrciption override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int = when { - Config.NSCLIENT && isTablet -> R.layout.overview_fragment_nsclient_tablet - Config.NSCLIENT -> R.layout.overview_fragment_nsclient + config.NSCLIENT && isTablet -> R.layout.overview_fragment_nsclient_tablet + config.NSCLIENT -> R.layout.overview_fragment_nsclient isSmallHeight || isLandscape -> R.layout.overview_fragment_landscape else -> R.layout.overview_fragment } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt b/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt index 070c1b0c51..77a269712f 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt @@ -7,7 +7,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification @@ -29,7 +29,8 @@ class LocalAlertUtils @Inject constructor( private val resourceHelper: ResourceHelper, private val activePlugin: ActivePluginProvider, private val profileFunction: ProfileFunction, - private val iobCobCalculatorPlugin: IobCobCalculatorPlugin + private val iobCobCalculatorPlugin: IobCobCalculatorPlugin, + private val config: Config ) { fun missedReadingsThreshold(): Long { @@ -43,7 +44,7 @@ class LocalAlertUtils @Inject constructor( fun checkPumpUnreachableAlarm(lastConnection: Long, isStatusOutdated: Boolean, isDisconnected: Boolean) { val alarmTimeoutExpired = lastConnection + pumpUnreachableThreshold() < System.currentTimeMillis() val nextAlarmOccurrenceReached = sp.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis() - if (Config.APS && sp.getBoolean(resourceHelper.gs(R.string.key_enable_pump_unreachable_alert), true) + if (config.APS && sp.getBoolean(resourceHelper.gs(R.string.key_enable_pump_unreachable_alert), true) && isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !isDisconnected) { aapsLogger.debug(LTag.CORE, "Generating pump unreachable alarm. lastConnection: " + DateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated) val n = Notification(Notification.PUMP_UNREACHABLE, resourceHelper.gs(R.string.pump_unreachable), Notification.URGENT) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/XdripCalibrations.kt b/app/src/main/java/info/nightscout/androidaps/utils/XdripCalibrations.kt index 9c32ccadef..af13dadb1e 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/XdripCalibrations.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/XdripCalibrations.kt @@ -6,7 +6,7 @@ import android.os.Bundle import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.services.Intents import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelper.kt b/app/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelper.kt index f1cec2109f..a08f671512 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelper.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelper.kt @@ -8,7 +8,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class BuildHelper @Inject constructor() { +class BuildHelper @Inject constructor(private val config: Config) { private var devBranch = false private var engineeringMode = false @@ -22,10 +22,10 @@ class BuildHelper @Inject constructor() { } fun isEngineeringModeOrRelease(): Boolean = - if (!Config.APS) true else engineeringMode || !devBranch + if (!config.APS) true else engineeringMode || !devBranch fun isEngineeringMode(): Boolean = - if (!Config.APS) true else engineeringMode || !devBranch + if (!config.APS) true else engineeringMode || !devBranch fun isDev(): Boolean = devBranch } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/utils/resources/IconsProvider.kt b/app/src/main/java/info/nightscout/androidaps/utils/resources/IconsProvider.kt index d707caaaa1..6bdeaa73a8 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/resources/IconsProvider.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/resources/IconsProvider.kt @@ -6,19 +6,19 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class IconsProvider @Inject constructor() { +class IconsProvider @Inject constructor(private val config: Config) { fun getIcon(): Int = when { - Config.NSCLIENT -> R.mipmap.ic_yellowowl - Config.PUMPCONTROL -> R.mipmap.ic_pumpcontrol + config.NSCLIENT -> R.mipmap.ic_yellowowl + config.PUMPCONTROL -> R.mipmap.ic_pumpcontrol else -> R.mipmap.ic_launcher } fun getNotificationIcon(): Int = when { - Config.NSCLIENT -> R.drawable.ic_notif_nsclient - Config.PUMPCONTROL -> R.drawable.ic_notif_pumpcontrol + config.NSCLIENT -> R.drawable.ic_notif_nsclient + config.PUMPCONTROL -> R.drawable.ic_notif_pumpcontrol else -> R.drawable.ic_notif_aaps } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt index f6db77e09f..2b7806468e 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt @@ -21,7 +21,7 @@ class TIR(val date: Long, val lowThreshold: Double, val highThreshold: Double) { fun inRangePct() = if (count > 0) (inRange.toDouble() / count * 100.0).roundToInt() else 0 fun abovePct() = if (count > 0) (above.toDouble() / count * 100.0).roundToInt() else 0 - fun toText(resourceHelper: ResourceHelper): String = resourceHelper.gs(R.string.tirformat, DateUtil.dateStringShort(date), belowPct(), inRangePct(), abovePct()) + fun toText(resourceHelper: ResourceHelper, dateUtil: DateUtil): String = resourceHelper.gs(R.string.tirformat, dateUtil.dateStringShort(date), belowPct(), inRangePct(), abovePct()) fun toText(resourceHelper: ResourceHelper, days: Int): String = resourceHelper.gs(R.string.tirformat, "%02d".format(days) + " " + resourceHelper.gs(R.string.days), belowPct(), inRangePct(), abovePct()) } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt index 906516d5ea..6d4895f1f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt @@ -10,7 +10,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.treatments.TreatmentService import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DateUtil @@ -85,21 +85,21 @@ class TddCalculator @Inject constructor( return totalTdd } - fun stats(): Spanned { + fun stats(dateUtil: DateUtil): Spanned { val tdds = calculate(7) val averageTdd = averageTDD(tdds) return HtmlHelper.fromHtml( "" + resourceHelper.gs(R.string.tdd) + ":
" + - toText(tdds) + + toText(tdds, dateUtil) + "" + resourceHelper.gs(R.string.average) + ":
" + averageTdd.toText(resourceHelper, tdds.size()) ) } - private fun toText(tdds: LongSparseArray): String { + private fun toText(tdds: LongSparseArray, dateUtil: DateUtil): String { var t = "" for (i in 0 until tdds.size()) { - t += "${tdds.valueAt(i).toText(resourceHelper)}
" + t += "${tdds.valueAt(i).toText(resourceHelper, dateUtil)}
" } return t } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TirCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TirCalculator.kt index f1f13cbf0d..bbda132d80 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TirCalculator.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TirCalculator.kt @@ -6,7 +6,7 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.MidnightTime @@ -18,7 +18,8 @@ import javax.inject.Singleton @Singleton class TirCalculator @Inject constructor( private val resourceHelper: ResourceHelper, - private val profileFunction: ProfileFunction + private val profileFunction: ProfileFunction, + private val dateUtil: DateUtil ){ fun calculate(days: Long, lowMgdl: Double, highMgdl: Double): LongSparseArray { if (lowMgdl < 39) throw RuntimeException("Low below 39") @@ -89,7 +90,7 @@ class TirCalculator @Inject constructor( fun toText(resourceHelper: ResourceHelper, tirs: LongSparseArray): String { var t = "" for (i in 0 until tirs.size()) { - t += "${tirs.valueAt(i).toText(resourceHelper)}
" + t += "${tirs.valueAt(i).toText(resourceHelper, dateUtil)}
" } return t } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt index 8416eff715..fffa175e07 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt @@ -19,7 +19,7 @@ import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.queue.Callback diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt index f24f3d72f4..baf858dc14 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt @@ -6,7 +6,7 @@ import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin diff --git a/app/src/main/res/values-nl-rNL/strings.xml b/app/src/main/res/values-nl-rNL/strings.xml index 1d91d77a7f..1b2d56b27f 100644 --- a/app/src/main/res/values-nl-rNL/strings.xml +++ b/app/src/main/res/values-nl-rNL/strings.xml @@ -1153,7 +1153,6 @@ Herhaal tijd Elke Nooit - %1$dmin Voorwaarde: Actie: IOB [E]: diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index de49a0aee5..27adfdd924 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,21 +2,12 @@ #ff00ff #00ffff - #1e88e5 #00d2d2 #1ea3e5 - #1ea3e5 - #FFFB8C00 - #FFFB8C00 - #c9bd60 - #00d2d2 #FFFFFF #d3f166 #FFFFFF00 #FFFF00FF - #00FF00 - #FF0000 - #FFFF00 #FFFF00 #505050 #FF33B5E5 @@ -24,7 +15,6 @@ #7484E2 #2800FF00 #C83F51B5 - #C803A9F4 #757575 #d8d8d8 #ff1a1a @@ -61,7 +51,6 @@ #de7550 #25912e - #FF8C00 #ff0400 #ff5e55 #ff827c diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a3f9ff20a1..29a25862ef 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -100,7 +100,6 @@ TT Carbs Corr - U Bolus IOB Run now VIRTUAL PUMP @@ -120,11 +119,7 @@ Result Result: %1$s %2$s No glucose data available - No change requested Request - Rate - Duration - Reason Glucose Delta Delta: @@ -150,7 +145,6 @@ General These are some general plugins you might find useful. Which constraints are applied? - days Constraints Loop @@ -198,24 +192,6 @@ Basal IOB Bolus constraint applied Carbs constraint applied - BG Check - Announcement - Note - Question - Exercise - Pump Site Change - CGM Sensor Insert - CGM Sensor Start - Insulin Cartridge Change - Profile switch - Snack Bolus - Meal Bolus - Correction Bolus - Combo Bolus - Temp Basal Start - Temp Basal End - Carbs correction - OpenAPS Offline Event type Other @@ -321,19 +297,11 @@ Pump IOB Daily units Last bolus - %1$.1fh ago Invalid input data Value not set properly Reload profile View profile - Enacted - Comment - Success - Percent - Absolute - Cancel temp basal SMS Communicator - Waiting for result Allowed phone numbers +XXXXXXXXXX;+YYYYYYYYYY To deliver bolus %1$.2fU reply with code %2$s @@ -357,11 +325,6 @@ Temp Target canceled successfully Delivering %1$.2fU Allow remote commands via SMS - Finger - Sensor - Manual - Temporary target - Temporary target cancel DanaR profile settings DIA [h] Duration of Insulin Activity @@ -402,7 +365,6 @@ Waiting for pump Going to deliver %1$.2fU You reached allowed limit - No profile selected Loop has been disabled Loop has been enabled Loop is disabled @@ -486,7 +448,6 @@ MM640g Ongoing Notification OLD DATA - %1$dm ago %1$dmin ago Local Profile OpenAPS AMA @@ -595,8 +556,6 @@ nsclientinternal_api_secret danar_bt_name danar_password - danar_useextended - danar_visualizeextendedaspercentage" Clear log nsclientinternal_autoscroll nsclientinternal_paused @@ -652,7 +611,6 @@ ns_logappstartedevent Exiting application to apply settings. DanaRv2 - Insulin Which type of insulin are you using? Fast Acting Insulin Novorapid, Novolog, Humalog @@ -710,11 +668,9 @@ Sensor age Canula age Insulin age - hours Invalid profile !!! Do Profile Switch Pump battery age - Pump Battery Change Alarm options nsalarm_urgent_high nsalarm_high @@ -746,8 +702,6 @@ Sensitivity Oref1 Sensitivity AAPS Absorption settings - absorption_maxtime - absorption_cutoff Meal max absorption time [h] Time in hours where is expected all carbs from meal will be absorbed @@ -779,7 +733,6 @@ PUMP Duration [min] OpenAPS SMB - SMB use_smb use_uam Enable UAM @@ -826,12 +779,6 @@ activity target hypo duration hypo target - eatingsoon_duration - eatingsoon_target - activity_duration - activity_target - hypo_duration - hypo_target Prime Getting extended bolus status Getting bolus status @@ -841,12 +788,8 @@ reuse Controls from Watch Set Temp-Targets and enter Treatments from the watch. - Connection timed out Food g - m - h - d ]]> kJ En @@ -897,8 +840,6 @@ dexcomg5_xdripupload In xDrip+ select 640g/Eversense data source NSClient BG - Basal value replaced by minimal supported value: %1$s - Basal value replaced by maximum supported value: %1$s BG calculation Bolus IOB calculation Basal IOB calculation @@ -916,8 +857,6 @@ Closed mode enabled Maximal IOB set properly BG available from selected source - Basal values not aligned to hours: %1$s - Invalid profile: %1$s Programming pump for bolusing Refresh State @@ -976,7 +915,6 @@ Enable SMB when there is temp target active (eating soon, exercise) Enable SMB with high temp targets Enable SMB when there is high temp target active (exercise) - Let temp basal run Mute Insulin Carbs @@ -1108,7 +1046,6 @@ Setup Wizard FINISH Select your language - openapsama_min_5m_carbimpact Asked: %1$.2fU Delivered: %2$.2fU Error code: %3$s First insulin increment Second insulin increment @@ -1138,7 +1075,6 @@ 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 - * Only discrete values no ranges are supported as granularity for basal/bolus in virtual pump. Autobackfill BG Wizard Settings wearwizard_bg @@ -1255,7 +1191,6 @@ Command error Speed error Insulin limit violation - loop_openmode_min_change Minimal request change [%] Open Loop will popup new change request only if change is bigger than this value in %. Default value is 20% short_tabtitles @@ -1350,7 +1285,6 @@ is equal or greater than is greater than is not available - unknown Glucose is not available Glucose %1$s %2$.0f %3$s Glucose %1$s %2$.1f %3$s @@ -1369,25 +1303,12 @@ Automation == ∑ %1$s U - U/h - g/U - /U dexcom_lognssensorchange Log sensor change to NS Create event \"Sensor Change\" in NS automaticaly on sensor start Tomato (MiaoMiao) Tomato - second - minute - hour - day - week - seconds - minutes - hours - days - weeks tidepool_username tidepool_password tidepool_dev_servers @@ -1705,7 +1626,6 @@ Profile name: Selected: Units - units Do you want to switch profile and discard changes made to current profile? wizard_calculation_visible %1$dg @@ -1720,8 +1640,6 @@ Select units you want to display values in ns_uploadlocalprofile Upload local profile changes to NS - low_mark - high_mark wear_detailediob wear_showbgi DIA @@ -1746,7 +1664,6 @@ Survey Invalid age entry Invalid weight entry - %1$s:
∑: %2$.2f Bol: %3$.2f Bas: %4$.2f]]>
%1$s: Low: %2$02d%% In: %3$02d%% High: %4$02d%%]]> Average TDD diff --git a/app/src/test/java/info/nightscout/androidaps/TestBase.kt b/app/src/test/java/info/nightscout/androidaps/TestBase.kt index 278a74d081..60022c99dd 100644 --- a/app/src/test/java/info/nightscout/androidaps/TestBase.kt +++ b/app/src/test/java/info/nightscout/androidaps/TestBase.kt @@ -1,11 +1,6 @@ package info.nightscout.androidaps -import dagger.android.AndroidInjector -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.data.ProfileStore import info.nightscout.androidaps.logging.AAPSLoggerTest -import org.json.JSONObject import org.junit.Before import org.junit.Rule import org.mockito.Mockito diff --git a/app/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt b/app/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt index 6272726ff1..188266fbb3 100644 --- a/app/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt +++ b/app/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt @@ -3,14 +3,12 @@ package info.nightscout.androidaps import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.data.ProfileStore +import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.db.ProfileSwitch import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.logging.AAPSLogger -import info.nightscout.androidaps.logging.AAPSLoggerTest import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.FabricPrivacy diff --git a/app/src/test/java/info/nightscout/androidaps/data/QuickWizardTest.kt b/app/src/test/java/info/nightscout/androidaps/data/QuickWizardTest.kt index 69a166dc86..f79cfd7c43 100644 --- a/app/src/test/java/info/nightscout/androidaps/data/QuickWizardTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/data/QuickWizardTest.kt @@ -3,9 +3,8 @@ package info.nightscout.androidaps.data import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBase -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.sharedPreferences.SP diff --git a/app/src/test/java/info/nightscout/androidaps/db/BgReadingTest.kt b/app/src/test/java/info/nightscout/androidaps/db/BgReadingTest.kt index 61494f7d8c..7e37b24660 100644 --- a/app/src/test/java/info/nightscout/androidaps/db/BgReadingTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/db/BgReadingTest.kt @@ -5,9 +5,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainApp -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.L -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.resources.ResourceHelper diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index 7698cc6844..fda1b15ae5 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin @@ -26,7 +25,6 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin import info.nightscout.androidaps.plugins.source.GlimpPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentService import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin -import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.HardLimits import info.nightscout.androidaps.utils.Profiler import info.nightscout.androidaps.utils.buildHelper.BuildHelper diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt index 40495880a3..28fb3668da 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt @@ -12,7 +12,7 @@ import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PumpDescription import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt index 45e7f5c51d..5d56382e0b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt @@ -2,21 +2,16 @@ package info.nightscout.androidaps.plugins.general.automation.actions import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin -import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import org.mockito.Mock import org.powermock.core.classloader.annotations.PrepareForTest diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt index a91fcf6d06..27b042afa1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional import info.nightscout.androidaps.R import info.nightscout.androidaps.plugins.general.automation.elements.Comparator -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.utils.DateUtil import org.json.JSONObject diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt index 61c1f869ba..f172acb741 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt @@ -4,7 +4,7 @@ import com.google.common.base.Optional import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.db.BgReading -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt index 47422cd41f..ebf0a57fc1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt @@ -4,7 +4,7 @@ import com.google.common.base.Optional import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.db.BgReading -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.InputDelta.DeltaType import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt index a886ef27c6..3cbaa271f2 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt @@ -6,7 +6,6 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin import info.nightscout.androidaps.plugins.general.automation.elements.InputBg import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index aa3f522264..bf96b45765 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -16,7 +16,6 @@ import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PumpDescription import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus @@ -36,7 +35,6 @@ import org.mockito.ArgumentMatchers import org.mockito.Mock import org.mockito.Mockito import org.mockito.Mockito.`when` -import org.mockito.Mockito.anyDouble import org.mockito.invocation.InvocationOnMock import org.mockito.stubbing.Answer import org.powermock.api.mockito.PowerMockito diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePluginTest.kt index d3eb07a25d..646681c1dd 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePluginTest.kt @@ -6,9 +6,9 @@ import info.nightscout.androidaps.data.Iob import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPluginTest.kt index e34407fcfe..8c65f3339f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPluginTest.kt @@ -5,9 +5,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.InsulinInterface -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Assert.assertEquals diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPluginTest.kt index a7aea711c3..7f1ec85ae9 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPluginTest.kt @@ -6,7 +6,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.InsulinInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert.assertEquals import org.junit.Before diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPluginTest.kt index 7d02e4be21..16b5a6dbc3 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPluginTest.kt @@ -6,7 +6,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.InsulinInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert.assertEquals import org.junit.Before diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt index a21990f406..595c8215d7 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt @@ -5,9 +5,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/combo/ComboPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/combo/ComboPluginTest.kt index 6b349711f0..46951f8730 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/combo/ComboPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/combo/ComboPluginTest.kt @@ -10,11 +10,10 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PluginType -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Bolus import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.CommandQueue diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt index 44ee4019c3..d3f14725af 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt @@ -10,7 +10,6 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Assert import org.junit.Before diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt index 5a9107ccb0..8392d74120 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt @@ -5,7 +5,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.db.TemporaryBasal import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Before diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusProgressTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusProgressTest.kt index 7c10c200ce..b98ac3e378 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusProgressTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusProgressTest.kt @@ -4,7 +4,7 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert import org.junit.Test diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStopTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStopTest.kt index 3e813c1328..e64df1a055 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStopTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStopTest.kt @@ -4,7 +4,7 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.treatments.Treatment +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert import org.junit.Test @@ -21,7 +21,7 @@ class MsgBolusStopTest : DanaRTestBase() { @Test fun runTest() { `when`(resourceHelper.gs(R.string.overview_bolusprogress_delivered)).thenReturn("Delivered") - danaRPump.bolusingTreatment = Treatment(HasAndroidInjector { AndroidInjector { } }) + danaRPump.bolusingTreatment = Treatment(HasAndroidInjector { AndroidInjector { } }) val packet = MsgBolusStop(aapsLogger, rxBus, resourceHelper, danaRPump) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt index 5dd1c1a3b0..b4f61fd220 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt @@ -11,7 +11,6 @@ import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Assert import org.junit.Before diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt index d3edf9690c..f72d6cde94 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt @@ -9,7 +9,6 @@ import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInf import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSTestBase -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt index 6df25b94c7..3f5da64f27 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt @@ -10,10 +10,8 @@ import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSTestBase -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import org.junit.Assert import org.junit.Before import org.junit.Test diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt index 6c1f96cdc7..bcc56e2f92 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt @@ -6,10 +6,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import org.junit.Assert import org.junit.Before import org.junit.Test diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt index ac5b33158b..7c39d39cea 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt @@ -4,10 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin -import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.utils.DefaultValueHelper +import info.nightscout.androidaps.db.Treatment import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt index 790117afc2..c4b8d79ee3 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt @@ -4,10 +4,8 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin -import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.utils.DefaultValueHelper +import info.nightscout.androidaps.db.Treatment import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt index 37a1197b4f..0f90812ed0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt @@ -7,12 +7,9 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin -import info.nightscout.androidaps.plugins.treatments.Treatment -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin -import info.nightscout.androidaps.utils.DefaultValueHelper +import info.nightscout.androidaps.db.Treatment import org.junit.Assert import org.junit.Before import org.junit.Test diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt index dca4d1e3ad..23285e59e3 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt @@ -12,7 +12,6 @@ import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import org.junit.Before import org.junit.Test import org.junit.runner.RunWith diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPluginUTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPluginUTest.kt index 7a8c732c62..db6d30ef59 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPluginUTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPluginUTest.kt @@ -5,9 +5,8 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.interfaces.CommandQueueProvider -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.FabricPrivacy diff --git a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt index 5dd11ba4a0..f4ebe83fdd 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt @@ -9,17 +9,13 @@ import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PumpDescription -import info.nightscout.androidaps.logging.AAPSLogger -import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.commands.Command import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.buildHelper.BuildHelper -import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Assert import org.junit.Before diff --git a/app/src/test/java/info/nightscout/androidaps/utils/wizard/BolusWizardTest.kt b/app/src/test/java/info/nightscout/androidaps/utils/wizard/BolusWizardTest.kt index e44b95c950..4bbe3736b5 100644 --- a/app/src/test/java/info/nightscout/androidaps/utils/wizard/BolusWizardTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/utils/wizard/BolusWizardTest.kt @@ -11,11 +11,10 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PumpDescription -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin diff --git a/build.gradle b/build.gradle index b340946773..fe6a38714e 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,7 @@ buildscript { dagger_version = '2.27' coroutinesVersion = '1.3.5' activityVersion = '1.2.0-alpha04' + ormLiteVersion = "4.46" } repositories { google() diff --git a/core/build.gradle b/core/build.gradle index e81f23f7b6..bde94da837 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -65,6 +65,16 @@ dependencies { implementation "io.reactivex.rxjava2:rxandroid:2.1.1" implementation 'org.apache.commons:commons-lang3:3.10' + // Graphview cannot be upgraded + implementation "com.jjoe64:graphview:4.0.1" + + //DateUtil + implementation 'net.danlew:android.joda:2.10.6' + + //db + implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}" + implementation "com.j256.ormlite:ormlite-android:${ormLiteVersion}" + testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' diff --git a/app/src/main/java/info/nightscout/androidaps/Constants.java b/core/src/main/java/info/nightscout/androidaps/Constants.java similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/Constants.java rename to core/src/main/java/info/nightscout/androidaps/Constants.java index 38767ebfb9..f66342de7e 100644 --- a/app/src/main/java/info/nightscout/androidaps/Constants.java +++ b/core/src/main/java/info/nightscout/androidaps/Constants.java @@ -86,6 +86,9 @@ public class Constants { public static final double STATS_RANGE_LOW_MMOL = 3.9; public static final double STATS_RANGE_HIGH_MMOL = 10.0; + // Local profile + public static final String LOCAL_PROFILE = "LocalProfile"; + // One Time Password diff --git a/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java b/core/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java rename to core/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/Intervals.java b/core/src/main/java/info/nightscout/androidaps/data/Intervals.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/data/Intervals.java rename to core/src/main/java/info/nightscout/androidaps/data/Intervals.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/Iob.java b/core/src/main/java/info/nightscout/androidaps/data/Iob.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/data/Iob.java rename to core/src/main/java/info/nightscout/androidaps/data/Iob.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/IobTotal.java b/core/src/main/java/info/nightscout/androidaps/data/IobTotal.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/data/IobTotal.java rename to core/src/main/java/info/nightscout/androidaps/data/IobTotal.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/MealData.java b/core/src/main/java/info/nightscout/androidaps/data/MealData.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/data/MealData.java rename to core/src/main/java/info/nightscout/androidaps/data/MealData.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/NonOverlappingIntervals.java b/core/src/main/java/info/nightscout/androidaps/data/NonOverlappingIntervals.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/data/NonOverlappingIntervals.java rename to core/src/main/java/info/nightscout/androidaps/data/NonOverlappingIntervals.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/OverlappingIntervals.java b/core/src/main/java/info/nightscout/androidaps/data/OverlappingIntervals.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/data/OverlappingIntervals.java rename to core/src/main/java/info/nightscout/androidaps/data/OverlappingIntervals.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/Profile.java b/core/src/main/java/info/nightscout/androidaps/data/Profile.java similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/data/Profile.java rename to core/src/main/java/info/nightscout/androidaps/data/Profile.java index 0fcc0321c2..dc8e08b0df 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/core/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -13,22 +13,20 @@ import java.util.TimeZone; import javax.inject.Inject; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.interfaces.ActivePluginProvider; +import info.nightscout.androidaps.interfaces.ConfigInterface; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.FabricPrivacy; -import info.nightscout.androidaps.utils.MidnightTime; import info.nightscout.androidaps.utils.Round; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -38,6 +36,7 @@ public class Profile { @Inject public ResourceHelper resourceHelper; @Inject public RxBusWrapper rxBus; @Inject public FabricPrivacy fabricPrivacy; + @Inject public ConfigInterface configInterface; private HasAndroidInjector injector; @@ -62,11 +61,6 @@ public class Profile { protected boolean isValid; protected boolean isValidated; - // Default constructor for DB - public Profile() { - MainApp.instance().androidInjector().inject(this); - } - protected Profile(HasAndroidInjector injector) { injector.androidInjector().inject(this); this.injector = injector; @@ -253,7 +247,7 @@ public class Profile { for (int index = 0; index < basal_v.size(); index++) { long secondsFromMidnight = basal_v.keyAt(index); if (notify && secondsFromMidnight % 3600 != 0) { - if (Config.APS) { + if (configInterface.getAPS()) { Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, resourceHelper.gs(R.string.basalprofilenotaligned, from), Notification.NORMAL); rxBus.send(new EventNewNotification(notification)); } diff --git a/app/src/main/java/info/nightscout/androidaps/data/ProfileIntervals.java b/core/src/main/java/info/nightscout/androidaps/data/ProfileIntervals.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/data/ProfileIntervals.java rename to core/src/main/java/info/nightscout/androidaps/data/ProfileIntervals.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java b/core/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java rename to core/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java index 00cfb1e6bd..16c3707536 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java +++ b/core/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java @@ -6,7 +6,7 @@ import org.json.JSONObject; import javax.inject.Inject; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.Round; diff --git a/app/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfile.kt b/core/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfile.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfile.kt rename to core/src/main/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfile.kt diff --git a/app/src/main/java/info/nightscout/androidaps/db/BgReading.java b/core/src/main/java/info/nightscout/androidaps/db/BgReading.java similarity index 93% rename from app/src/main/java/info/nightscout/androidaps/db/BgReading.java rename to core/src/main/java/info/nightscout/androidaps/db/BgReading.java index b15d92a851..f2b53b8738 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/BgReading.java +++ b/core/src/main/java/info/nightscout/androidaps/db/BgReading.java @@ -13,11 +13,11 @@ import javax.inject.Inject; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.core.R; +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries; @@ -27,7 +27,7 @@ import info.nightscout.androidaps.utils.DefaultValueHelper; import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.resources.ResourceHelper; -@DatabaseTable(tableName = DatabaseHelper.DATABASE_BGREADINGS) +@DatabaseTable(tableName = "BgReadings") public class BgReading implements DataPointWithLabelInterface { @Inject public AAPSLogger aapsLogger; @Inject public DefaultValueHelper defaultValueHelper; @@ -59,7 +59,7 @@ public class BgReading implements DataPointWithLabelInterface { public boolean isZTPrediction = false; // true when drawing predictions as bg points (ZT) public BgReading() { - MainApp.instance().androidInjector().inject(this); + StaticInjector.Companion.getInstance().androidInjector().inject(this); } public BgReading(HasAndroidInjector injector) { @@ -86,10 +86,10 @@ public class BgReading implements DataPointWithLabelInterface { else return DecimalFormatter.to1Decimal(value * Constants.MGDL_TO_MMOLL); } - public String directionToSymbol() { + public String directionToSymbol(DatabaseHelperInterface databaseHelper) { String symbol = ""; if (direction == null) - direction = calculateDirection(); + direction = calculateDirection(databaseHelper); if (direction.compareTo("DoubleDown") == 0) { symbol = "\u21ca"; @@ -249,7 +249,7 @@ public class BgReading implements DataPointWithLabelInterface { return resourceHelper.gc(R.color.uam); if (isZTPrediction) return resourceHelper.gc(R.color.zt); - return R.color.mdtp_white; + return R.color.white; } private boolean isPrediction() { @@ -258,10 +258,10 @@ public class BgReading implements DataPointWithLabelInterface { // Copied from xDrip+ - String calculateDirection() { + String calculateDirection(DatabaseHelperInterface databasehelper) { // Rework to get bgreaings from internal DB and calculate on that base - List bgReadingsList = MainApp.getDbHelper().getAllBgreadingsDataFromTime(this.date - T.mins(10).msecs(), false); + List bgReadingsList = databasehelper.getAllBgreadingsDataFromTime(this.date - T.mins(10).msecs(), false); if (bgReadingsList == null || bgReadingsList.size() < 2) return "NONE"; BgReading current = bgReadingsList.get(1); diff --git a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java b/core/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java rename to core/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java index ea9e44e7fe..6f95917ace 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java +++ b/core/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java @@ -9,10 +9,6 @@ import org.apache.commons.lang3.StringUtils; import org.json.JSONException; import org.json.JSONObject; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -21,13 +17,12 @@ import javax.inject.Inject; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.interfaces.Interval; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries; @@ -36,7 +31,7 @@ import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.Translator; import info.nightscout.androidaps.utils.resources.ResourceHelper; -@DatabaseTable(tableName = DatabaseHelper.DATABASE_CAREPORTALEVENTS) +@DatabaseTable(tableName = "CareportalEvents") public class CareportalEvent implements DataPointWithLabelInterface, Interval { @Inject ProfileFunction profileFunction; @@ -84,7 +79,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval { @Deprecated public CareportalEvent() { - MainApp.instance().androidInjector().inject(this); + StaticInjector.Companion.getInstance().androidInjector().inject(this); } public CareportalEvent(HasAndroidInjector injector) { diff --git a/app/src/main/java/info/nightscout/androidaps/db/DanaRHistoryRecord.java b/core/src/main/java/info/nightscout/androidaps/db/DanaRHistoryRecord.java similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/db/DanaRHistoryRecord.java rename to core/src/main/java/info/nightscout/androidaps/db/DanaRHistoryRecord.java index 5c2e4f4985..2c161df1cc 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DanaRHistoryRecord.java +++ b/core/src/main/java/info/nightscout/androidaps/db/DanaRHistoryRecord.java @@ -3,9 +3,7 @@ package info.nightscout.androidaps.db; import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; -import java.util.Date; - -@DatabaseTable(tableName = DatabaseHelper.DATABASE_DANARHISTORY) +@DatabaseTable(tableName = "DanaRHistory") public class DanaRHistoryRecord { @DatabaseField diff --git a/app/src/main/java/info/nightscout/androidaps/db/DbObjectBase.java b/core/src/main/java/info/nightscout/androidaps/db/DbObjectBase.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/db/DbObjectBase.java rename to core/src/main/java/info/nightscout/androidaps/db/DbObjectBase.java diff --git a/app/src/main/java/info/nightscout/androidaps/db/DbRequest.java b/core/src/main/java/info/nightscout/androidaps/db/DbRequest.java similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/db/DbRequest.java rename to core/src/main/java/info/nightscout/androidaps/db/DbRequest.java index 60da1d2bca..e280c5efbb 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DbRequest.java +++ b/core/src/main/java/info/nightscout/androidaps/db/DbRequest.java @@ -16,7 +16,7 @@ import info.nightscout.androidaps.utils.DateUtil; *

* Allowed actions "dbAdd" || "dbUpdate" || "dbUpdateUnset" || "dbRemove" */ -@DatabaseTable(tableName = DatabaseHelper.DATABASE_DBREQUESTS) +@DatabaseTable(tableName = "DBRequests") public class DbRequest { private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATABASE); diff --git a/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java b/core/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java rename to core/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java index 15dd969e09..49b223d9b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java +++ b/core/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java @@ -17,18 +17,15 @@ import javax.inject.Inject; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.Iob; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.Interval; -import info.nightscout.androidaps.plugins.configBuilder.PluginStore; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; -import info.nightscout.androidaps.plugins.treatments.Treatment; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.JsonHelper; @@ -38,10 +35,11 @@ import info.nightscout.androidaps.utils.Round; * Created by mike on 21.05.2017. */ -@DatabaseTable(tableName = DatabaseHelper.DATABASE_EXTENDEDBOLUSES) +@DatabaseTable(tableName = "ExtendedBoluses") public class ExtendedBolus implements Interval, DataPointWithLabelInterface { @Inject ActivePluginProvider activePlugin; + @Inject DateUtil dateUtil; private HasAndroidInjector injector; @@ -71,7 +69,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface { @Deprecated public ExtendedBolus() { - injector = MainApp.instance(); + injector = StaticInjector.Companion.getInstance(); injector.androidInjector().inject(this); } @@ -330,7 +328,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface { public String toString() { return "E " + DecimalFormatter.to2Decimal(absoluteRate()) + "U/h @" + - DateUtil.timeString(date) + + dateUtil.timeString(date) + " " + getRealDuration() + "/" + durationInMinutes + "min"; } diff --git a/app/src/main/java/info/nightscout/androidaps/db/ICallback.java b/core/src/main/java/info/nightscout/androidaps/db/ICallback.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/db/ICallback.java rename to core/src/main/java/info/nightscout/androidaps/db/ICallback.java diff --git a/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java b/core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java similarity index 94% rename from app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java rename to core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java index 06174c9c66..09b7d047ba 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java +++ b/core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java @@ -16,26 +16,24 @@ import java.util.Objects; import javax.inject.Inject; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.interfaces.Interval; +import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.logging.AAPSLogger; -import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; -import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin; -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.resources.ResourceHelper; -@DatabaseTable(tableName = DatabaseHelper.DATABASE_PROFILESWITCHES) +@DatabaseTable(tableName = "ProfileSwitches") public class ProfileSwitch implements Interval, DataPointWithLabelInterface { @DatabaseField(id = true) @@ -71,13 +69,13 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface { private Profile profile = null; HasAndroidInjector injector; - @Inject public TreatmentsPlugin treatmentsPlugin; + @Inject public TreatmentsInterface treatmentsPlugin; @Inject public AAPSLogger aapsLogger; @Inject public RxBusWrapper rxBus; @Inject public ResourceHelper resourceHelper; public ProfileSwitch() { - this.injector = MainApp.instance(); + this.injector = StaticInjector.Companion.getInstance(); injector.androidInjector().inject(this); } @@ -130,7 +128,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface { */ public String getCustomizedName() { String name = profileName; - if (LocalProfilePlugin.Companion.getLOCAL_PROFILE().equals(name)) { + if (Constants.LOCAL_PROFILE.equals(name)) { name = DecimalFormatter.to2Decimal(getProfileObject().percentageBasalSum()) + "U "; } if (isCPP) { diff --git a/app/src/main/java/info/nightscout/androidaps/db/Source.java b/core/src/main/java/info/nightscout/androidaps/db/Source.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/db/Source.java rename to core/src/main/java/info/nightscout/androidaps/db/Source.java diff --git a/core/src/main/java/info/nightscout/androidaps/db/StaticInjector.kt b/core/src/main/java/info/nightscout/androidaps/db/StaticInjector.kt new file mode 100644 index 0000000000..65a31bd812 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/db/StaticInjector.kt @@ -0,0 +1,28 @@ +package info.nightscout.androidaps.db + +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector +import java.lang.IllegalStateException +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +@Deprecated("Only until DB is refactored") +class StaticInjector @Inject constructor( + private val injector: HasAndroidInjector +) : HasAndroidInjector { + companion object { + @Deprecated("Only until DB is refactored") + private var instance : StaticInjector? = null + + fun getInstance() : StaticInjector { + if (instance == null) throw IllegalStateException("StaticInjector not initialized") + return instance!! + } + } + + init { + instance = this + } + override fun androidInjector(): AndroidInjector = injector.androidInjector() +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/db/TDD.java b/core/src/main/java/info/nightscout/androidaps/db/TDD.java similarity index 78% rename from app/src/main/java/info/nightscout/androidaps/db/TDD.java rename to core/src/main/java/info/nightscout/androidaps/db/TDD.java index 8d6a2e2576..eba359f2ad 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/TDD.java +++ b/core/src/main/java/info/nightscout/androidaps/db/TDD.java @@ -5,8 +5,7 @@ import com.j256.ormlite.table.DatabaseTable; import java.util.Locale; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -15,7 +14,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper; */ -@DatabaseTable(tableName = DatabaseHelper.DATABASE_TDDS) +@DatabaseTable(tableName = "TDDs") public class TDD { @DatabaseField(id = true) @@ -51,15 +50,15 @@ public class TDD { public String toString() { return "TDD [" + "date=" + date + - "date(str)=" + DateTimeUtil.toStringFromTimeInMillis(date) + + "date(str)=" + DateUtil.dateAndTimeString(date) + ", bolus=" + bolus + ", basal=" + basal + ", total=" + total + ']'; } - public String toText(ResourceHelper resourceHelper) { - return resourceHelper.gs(R.string.tddformat, DateUtil.dateStringShort(date), total, bolus, basal); + public String toText(ResourceHelper resourceHelper, DateUtil dateUtil) { + return resourceHelper.gs(R.string.tddformat, dateUtil.dateStringShort(date), total, bolus, basal); } public String toText(ResourceHelper resourceHelper, int days) { diff --git a/app/src/main/java/info/nightscout/androidaps/db/TempTarget.java b/core/src/main/java/info/nightscout/androidaps/db/TempTarget.java similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/db/TempTarget.java rename to core/src/main/java/info/nightscout/androidaps/db/TempTarget.java index be7b76c554..cc9b7db990 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/TempTarget.java +++ b/core/src/main/java/info/nightscout/androidaps/db/TempTarget.java @@ -4,23 +4,20 @@ import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Objects; import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.interfaces.Interval; -import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.resources.ResourceHelper; -@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPTARGETS) +@DatabaseTable(tableName = "TempTargets") public class TempTarget implements Interval { private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATABASE); diff --git a/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java b/core/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java rename to core/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java index 937022196c..cf59c456d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java +++ b/core/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java @@ -8,8 +8,7 @@ import java.util.Objects; import javax.inject.Inject; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.data.Iob; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; @@ -17,9 +16,8 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.Interval; import info.nightscout.androidaps.logging.AAPSLogger; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; -import info.nightscout.androidaps.plugins.treatments.Treatment; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -28,13 +26,14 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; * Created by mike on 21.05.2017. */ -@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPORARYBASALS) +@DatabaseTable(tableName = "TemporaryBasals") public class TemporaryBasal implements Interval, DbObjectBase { @Inject public AAPSLogger aapsLogger; @Inject public ProfileFunction profileFunction; @Inject public ActivePluginProvider activePlugin; @Inject public SP sp; + @Inject DateUtil dateUtil; private HasAndroidInjector injector; @@ -68,7 +67,7 @@ public class TemporaryBasal implements Interval, DbObjectBase { @Deprecated public TemporaryBasal() { - injector = MainApp.instance(); + injector = StaticInjector.Companion.getInstance(); injector.androidInjector().inject(this); } @@ -110,7 +109,7 @@ public class TemporaryBasal implements Interval, DbObjectBase { } public TemporaryBasal(ExtendedBolus extendedBolus) { - injector = MainApp.instance(); + injector = StaticInjector.Companion.getInstance(); injector.androidInjector().inject(this); double basal = profileFunction.getProfile(extendedBolus.date).getBasal(extendedBolus.date); this.date = extendedBolus.date; @@ -427,15 +426,15 @@ public class TemporaryBasal implements Interval, DbObjectBase { Double currentBasalRate = profile.getBasal(); double rate = currentBasalRate + netExtendedRate; return getCalcuatedPercentageIfNeeded() + DecimalFormatter.to2Decimal(rate) + "U/h (" + DecimalFormatter.to2Decimal(netExtendedRate) + "E) @" + - DateUtil.timeString(date) + + dateUtil.timeString(date) + " " + getRealDuration() + "/" + durationInMinutes + "'"; } else if (isAbsolute) { return DecimalFormatter.to2Decimal(absoluteRate) + "U/h @" + - DateUtil.timeString(date) + + dateUtil.timeString(date) + " " + getRealDuration() + "/" + durationInMinutes + "'"; } else { // percent return percentRate + "% @" + - DateUtil.timeString(date) + + dateUtil.timeString(date) + " " + getRealDuration() + "/" + durationInMinutes + "'"; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/Treatment.java b/core/src/main/java/info/nightscout/androidaps/db/Treatment.java similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/plugins/treatments/Treatment.java rename to core/src/main/java/info/nightscout/androidaps/db/Treatment.java index ee99412f77..0df0dd0efa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/Treatment.java +++ b/core/src/main/java/info/nightscout/androidaps/db/Treatment.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.treatments; +package info.nightscout.androidaps.db; import android.graphics.Color; @@ -17,15 +17,12 @@ import javax.inject.Inject; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.data.Iob; import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.db.DbObjectBase; -import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.InsulinInterface; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries; import info.nightscout.androidaps.utils.DateUtil; @@ -74,7 +71,7 @@ public class Treatment implements DataPointWithLabelInterface, DbObjectBase { public String boluscalc; public Treatment() { - MainApp.instance().androidInjector().inject(this); // TODO it will be removed by new database + StaticInjector.Companion.getInstance().androidInjector().inject(this); // TODO it will be removed by new database } public Treatment(HasAndroidInjector injector) { diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/APSInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/APSInterface.java similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/interfaces/APSInterface.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/APSInterface.java index 7d32e37ff0..5cbdddac9f 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/APSInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/APSInterface.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.interfaces; + import info.nightscout.androidaps.plugins.aps.loop.APSResult; /** diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/ActivePluginProvider.java b/core/src/main/java/info/nightscout/androidaps/interfaces/ActivePluginProvider.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/ActivePluginProvider.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/ActivePluginProvider.java diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/CommandQueueProvider.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/CommandQueueProvider.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/CommandQueueProvider.kt rename to core/src/main/java/info/nightscout/androidaps/interfaces/CommandQueueProvider.kt diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/ConfigInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ConfigInterface.kt new file mode 100644 index 0000000000..b5071628b5 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ConfigInterface.kt @@ -0,0 +1,9 @@ +package info.nightscout.androidaps.interfaces + +interface ConfigInterface { + val SUPPORTEDNSVERSION: Int + val APS: Boolean + val NSCLIENT: Boolean + val PUMPCONTROL: Boolean + val PUMPDRIVERS: Boolean +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/Constraint.java b/core/src/main/java/info/nightscout/androidaps/interfaces/Constraint.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/Constraint.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/Constraint.java diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.kt rename to core/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.kt diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt new file mode 100644 index 0000000000..fb6c30a2c3 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt @@ -0,0 +1,8 @@ +package info.nightscout.androidaps.interfaces + +import info.nightscout.androidaps.db.BgReading + +@Deprecated("Remove with new DB") +interface DatabaseHelperInterface { + fun getAllBgreadingsDataFromTime(mills : Long, ascending: Boolean): List +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java similarity index 90% rename from app/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java index 2ad36fb747..d5e8ab399d 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java @@ -1,7 +1,7 @@ package info.nightscout.androidaps.interfaces; import info.nightscout.androidaps.data.Iob; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; /** * Created by mike on 17.04.2017. diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/Interval.java b/core/src/main/java/info/nightscout/androidaps/interfaces/Interval.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/Interval.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/Interval.java diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java new file mode 100644 index 0000000000..2d06449082 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java @@ -0,0 +1,11 @@ +package info.nightscout.androidaps.interfaces; + +import androidx.collection.LongSparseArray; + +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; + +public interface IobCobCalculatorInterface { + LongSparseArray getAutosensDataTable(); + String lastDataTime(); + AutosensData getAutosensData(long toTime); +} diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt rename to core/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginType.java b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginType.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/PluginType.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/PluginType.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunction.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt similarity index 85% rename from app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunction.kt rename to core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt index e6adc728f5..64582a62d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunction.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.configBuilder +package info.nightscout.androidaps.interfaces import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.data.ProfileStore +import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.db.ProfileSwitch interface ProfileFunction { diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/ProfileInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileInterface.java similarity index 81% rename from app/src/main/java/info/nightscout/androidaps/interfaces/ProfileInterface.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/ProfileInterface.java index 5fb3b459b6..5af03b863f 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/ProfileInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileInterface.java @@ -2,8 +2,6 @@ package info.nightscout.androidaps.interfaces; import androidx.annotation.Nullable; -import info.nightscout.androidaps.data.ProfileStore; - /** * Created by mike on 14.06.2016. */ diff --git a/app/src/main/java/info/nightscout/androidaps/data/ProfileStore.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/data/ProfileStore.kt rename to core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt index 751067a27a..5840dfabf0 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/ProfileStore.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt @@ -1,7 +1,8 @@ -package info.nightscout.androidaps.data +package info.nightscout.androidaps.interfaces import androidx.collection.ArrayMap import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.utils.JsonHelper import org.json.JSONException diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java index d85a383752..d5356af55d 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java @@ -5,8 +5,6 @@ import org.json.JSONObject; import java.util.List; -import javax.annotation.Nullable; - import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; @@ -107,7 +105,6 @@ public interface PumpInterface { boolean canHandleDST(); - @Nullable List getCustomActions(); void executeCustomAction(CustomActionType customActionType); diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpPluginBase.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpPluginBase.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/PumpPluginBase.kt rename to core/src/main/java/info/nightscout/androidaps/interfaces/PumpPluginBase.kt diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/SensitivityInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/SensitivityInterface.java similarity index 60% rename from app/src/main/java/info/nightscout/androidaps/interfaces/SensitivityInterface.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/SensitivityInterface.java index 9d75382542..04503c5690 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/SensitivityInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/SensitivityInterface.java @@ -1,7 +1,6 @@ package info.nightscout.androidaps.interfaces; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; /** * Created by mike on 24.06.2017. @@ -12,6 +11,6 @@ public interface SensitivityInterface { double MIN_HOURS = 1; double MIN_HOURS_FULL_AUTOSENS = 4; - AutosensResult detectSensitivity(IobCobCalculatorPlugin plugin, long fromTime, long toTime); + AutosensResult detectSensitivity(IobCobCalculatorInterface plugin, long fromTime, long toTime); } diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java similarity index 94% rename from app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java index 98441f8a7d..8856f8a74e 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java @@ -7,15 +7,13 @@ import java.util.List; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.Intervals; import info.nightscout.androidaps.data.IobTotal; -import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.NonOverlappingIntervals; import info.nightscout.androidaps.data.ProfileIntervals; -import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TemporaryBasal; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.db.Treatment; /** * Created by mike on 14.06.2016. @@ -23,31 +21,43 @@ import info.nightscout.androidaps.plugins.treatments.Treatment; public interface TreatmentsInterface { void updateTotalIOBTreatments(); + void updateTotalIOBTempBasals(); IobTotal getLastCalculationTreatments(); + IobTotal getCalculationToTimeTreatments(long time); + IobTotal getLastCalculationTempBasals(); + IobTotal getCalculationToTimeTempBasals(long time); List getTreatmentsFromHistory(); + List getCarbTreatments5MinBackFromHistory(long time); + List getTreatmentsFromHistoryAfterTimestamp(long timestamp); + long getLastBolusTime(); // real basals (not faked by extended bolus) boolean isInHistoryRealTempBasalInProgress(); + TemporaryBasal getRealTempBasalFromHistory(long time); boolean addToHistoryTempBasal(TemporaryBasal tempBasal); // basal that can be faked by extended boluses boolean isTempBasalInProgress(); + TemporaryBasal getTempBasalFromHistory(long time); + NonOverlappingIntervals getTemporaryBasalsFromHistory(); boolean isInHistoryExtendedBoluslInProgress(); + ExtendedBolus getExtendedBolusFromHistory(long time); + Intervals getExtendedBolusesFromHistory(); boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus); @@ -55,14 +65,21 @@ public interface TreatmentsInterface { boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate); TempTarget getTempTargetFromHistory(); + TempTarget getTempTargetFromHistory(long time); + Intervals getTempTargetsFromHistory(); + void addToHistoryTempTarget(TempTarget tempTarget); ProfileSwitch getProfileSwitchFromHistory(long time); + ProfileIntervals getProfileSwitchesFromHistory(); + void addToHistoryProfileSwitch(ProfileSwitch profileSwitch); + void doProfileSwitch(@NotNull final ProfileStore profileStore, @NotNull final String profileName, final int duration, final int percentage, final int timeShift, final long date); + void doProfileSwitch(final int duration, final int percentage, final int timeShift); long oldestDataAvailable(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java b/core/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java rename to core/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java index 5ca88bfac0..edec4da528 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java @@ -13,7 +13,7 @@ import java.util.List; import javax.inject.Inject; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.BgReading; @@ -22,11 +22,11 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -40,7 +40,7 @@ public class APSResult { @Inject ConstraintChecker constraintChecker; @Inject SP sp; @Inject ActivePluginProvider activePlugin; - @Inject TreatmentsPlugin treatmentsPlugin; + @Inject TreatmentsInterface treatmentsPlugin; @Inject ProfileFunction profileFunction; @Inject ResourceHelper resourceHelper; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java b/core/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java rename to core/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/common/ManufacturerType.java b/core/src/main/java/info/nightscout/androidaps/plugins/common/ManufacturerType.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/common/ManufacturerType.java rename to core/src/main/java/info/nightscout/androidaps/plugins/common/ManufacturerType.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt rename to core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt rename to core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt index 3128ac766d..ed084120f4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt @@ -3,14 +3,14 @@ package info.nightscout.androidaps.plugins.configBuilder import android.os.Bundle import com.google.firebase.analytics.FirebaseAnalytics import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.data.ProfileStore import info.nightscout.androidaps.db.ProfileSwitch import info.nightscout.androidaps.db.Source +import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy @@ -87,7 +87,6 @@ class ProfileFunctionImplementation @Inject constructor( if (activeTreatments.profileSwitchesFromHistory.size() > 0) { val bundle = Bundle() bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_ID, "CatchedError") - bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, BuildConfig.BUILDVERSION) bundle.putString(FirebaseAnalytics.Param.START_DATE, time.toString()) bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, activeTreatments.profileSwitchesFromHistory.toString()) fabricPrivacy.logCustom(bundle) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomAction.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomAction.kt similarity index 91% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomAction.kt rename to core/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomAction.kt index fe9af4a03e..b276bae9b1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomAction.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomAction.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.general.actions.defs -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R class CustomAction @JvmOverloads constructor(val name: Int, val customActionType: CustomActionType?, val iconResourceId: Int = R.drawable.icon_actions_profileswitch, var isEnabled: Boolean = true) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomActionType.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomActionType.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomActionType.kt rename to core/src/main/java/info/nightscout/androidaps/plugins/general/actions/defs/CustomActionType.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSMbg.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSMbg.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSMbg.java rename to core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSMbg.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSgv.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSgv.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSgv.java rename to core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSgv.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/DataPointWithLabelInterface.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/DataPointWithLabelInterface.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/DataPointWithLabelInterface.java rename to core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/DataPointWithLabelInterface.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java rename to core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java index eb981e9329..8058a6eef6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java @@ -39,10 +39,6 @@ import com.jjoe64.graphview.series.BaseSeries; import java.util.Iterator; -import info.nightscout.androidaps.MainApp; - -// Added by Rumen for scalable text - /** * Series that plots the data as points. * The points can be different shapes or a @@ -53,10 +49,6 @@ import info.nightscout.androidaps.MainApp; public class PointsWithLabelGraphSeries extends BaseSeries { // Default spSize int spSize = 14; - // Convert the sp to pixels - Context context = MainApp.instance().getApplicationContext(); - float scaledTextSize = spSize * context.getResources().getDisplayMetrics().scaledDensity; - float scaledPxSize = context.getResources().getDisplayMetrics().scaledDensity * 3f; /** * choose a predefined shape to render for @@ -123,6 +115,9 @@ public class PointsWithLabelGraphSeries e */ @Override public void draw(GraphView graphView, Canvas canvas, boolean isSecondScale) { + // Convert the sp to pixels + float scaledTextSize = spSize * graphView.getContext().getResources().getDisplayMetrics().scaledDensity; + float scaledPxSize = graphView.getContext().getResources().getDisplayMetrics().scaledDensity * 3f; resetDataPoints(); // get data @@ -238,7 +233,7 @@ public class PointsWithLabelGraphSeries e mPaint.setStyle(Paint.Style.FILL_AND_STROKE); drawArrows(points, canvas, mPaint); if (value.getLabel() != null) { - drawLabel45(endX, endY, value, canvas); + drawLabel45(endX, endY, value, canvas, scaledPxSize, scaledTextSize); } } else if (value.getShape() == Shape.SMB) { mPaint.setStrokeWidth(2); @@ -287,21 +282,21 @@ public class PointsWithLabelGraphSeries e mPaint.setStrokeWidth(0); canvas.drawCircle(endX, endY, scaledPxSize, mPaint); if (value.getLabel() != null) { - drawLabel45(endX, endY, value, canvas); + drawLabel45(endX, endY, value, canvas, scaledPxSize, scaledTextSize); } } else if (value.getShape() == Shape.ANNOUNCEMENT) { mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStrokeWidth(0); canvas.drawCircle(endX, endY, scaledPxSize, mPaint); if (value.getLabel() != null) { - drawLabel45(endX, endY, value, canvas); + drawLabel45(endX, endY, value, canvas, scaledPxSize, scaledTextSize); } } else if (value.getShape() == Shape.GENERAL) { mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStrokeWidth(0); canvas.drawCircle(endX, endY, scaledPxSize, mPaint); if (value.getLabel() != null) { - drawLabel45(endX, endY, value, canvas); + drawLabel45(endX, endY, value, canvas, scaledPxSize, scaledTextSize); } } else if (value.getShape() == Shape.EXERCISE) { mPaint.setStrokeWidth(0); @@ -385,7 +380,7 @@ public class PointsWithLabelGraphSeries e canvas.restore(); } - void drawLabel45(float endX, float endY, E value, Canvas canvas) { + void drawLabel45(float endX, float endY, E value, Canvas canvas, Float scaledPxSize, Float scaledTextSize) { if (value.getLabel().startsWith("~")) { float px = endX; float py = endY + scaledPxSize; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/Scale.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/Scale.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/Scale.java rename to core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/Scale.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/AutosensResult.java b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/AutosensResult.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/AutosensResult.java rename to core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/AutosensResult.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/AutosensData.java b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.java similarity index 87% rename from app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/AutosensData.java rename to core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.java index 6b3b4ef3de..9cd8c74f87 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/AutosensData.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.iob.iobCobCalculator; +package info.nightscout.androidaps.plugins.iob.iobCobCalculator.data; import java.util.ArrayList; import java.util.List; @@ -8,18 +8,18 @@ import javax.inject.Inject; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.data.Profile; +import info.nightscout.androidaps.db.Treatment; +import info.nightscout.androidaps.interfaces.ActivePluginProvider; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Scale; -import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin; -import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin; -import info.nightscout.androidaps.plugins.treatments.Treatment; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -29,8 +29,7 @@ public class AutosensData implements DataPointWithLabelInterface { @Inject AAPSLogger aapsLogger; @Inject SP sp; @Inject ResourceHelper resourceHelper; - @Inject SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin; - @Inject SensitivityAAPSPlugin sensitivityAAPSPlugin; + @Inject ActivePluginProvider activePlugin; @Inject ProfileFunction profileFunction; public AutosensData(HasAndroidInjector injector) { @@ -41,17 +40,17 @@ public class AutosensData implements DataPointWithLabelInterface { this.chartTime = chartTime; } - class CarbsInPast { + public class CarbsInPast { long time = 0L; double carbs = 0d; - double min5minCarbImpact = 0d; + public double min5minCarbImpact = 0d; double remaining = 0d; - CarbsInPast(Treatment t) { + public CarbsInPast(Treatment t, boolean isAAPSOrWeighted) { time = t.date; carbs = t.carbs; remaining = t.carbs; - if (sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled()) { + if (isAAPSOrWeighted) { double maxAbsorptionHours = sp.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME); Profile profile = profileFunction.getProfile(t.date); double sens = profile.getIsfMgdl(t.date); @@ -82,8 +81,8 @@ public class AutosensData implements DataPointWithLabelInterface { public String pastSensitivity = ""; public double deviation = 0d; public boolean validDeviation = false; - List activeCarbsList = new ArrayList<>(); - double absorbed = 0d; + public List activeCarbsList = new ArrayList<>(); + public double absorbed = 0d; public double carbsFromBolus = 0d; public double cob = 0; public double bgi = 0d; @@ -122,9 +121,9 @@ public class AutosensData implements DataPointWithLabelInterface { } // remove carbs older than timeframe - public void removeOldCarbs(long toTime) { + public void removeOldCarbs(long toTime, boolean isAAPSOrWeighted) { double maxAbsorptionHours = Constants.DEFAULT_MAX_ABSORPTION_TIME; - if (sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled()) { + if (isAAPSOrWeighted) { maxAbsorptionHours = sp.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME); } else { maxAbsorptionHours = sp.getDouble(R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/DoseSettings.java b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/DoseSettings.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/DoseSettings.java rename to core/src/main/java/info/nightscout/androidaps/plugins/pump/common/data/DoseSettings.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/DoseStepSize.java b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/DoseStepSize.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/DoseStepSize.java rename to core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/DoseStepSize.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpCapability.java b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpCapability.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpCapability.java rename to core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpCapability.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDriverState.java b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDriverState.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDriverState.java rename to core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpDriverState.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpStatusType.java b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpStatusType.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpStatusType.java rename to core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpStatusType.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpTempBasalType.java b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpTempBasalType.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpTempBasalType.java rename to core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpTempBasalType.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java rename to core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java index 3fff66fdf7..b52e1a1290 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.java @@ -4,11 +4,11 @@ package info.nightscout.androidaps.plugins.pump.common.defs; import java.util.HashMap; import java.util.Map; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.plugins.common.ManufacturerType; import info.nightscout.androidaps.plugins.pump.common.data.DoseSettings; import info.nightscout.androidaps.utils.Round; +import info.nightscout.androidaps.utils.resources.ResourceHelper; /** @@ -362,14 +362,14 @@ public enum PumpType { } - public String getFullDescription(String i18nTemplate, boolean hasExtendedBasals) { + public String getFullDescription(String i18nTemplate, boolean hasExtendedBasals, ResourceHelper resourceHelper) { String unit = getPumpTempBasalType() == PumpTempBasalType.Percent ? "%" : ""; DoseSettings eb = getExtendedBolusSettings(); DoseSettings tbr = getTbrSettings(); - String extendedNote = hasExtendedBasals ? MainApp.gs(R.string.virtualpump_pump_def_extended_note) : ""; + String extendedNote = hasExtendedBasals ? resourceHelper.gs(R.string.virtualpump_pump_def_extended_note) : ""; return String.format(i18nTemplate, // getStep("" + getBolusSize(), getSpecialBolusSize()), // diff --git a/app/src/main/java/info/nightscout/androidaps/queue/Callback.java b/core/src/main/java/info/nightscout/androidaps/queue/Callback.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/queue/Callback.java rename to core/src/main/java/info/nightscout/androidaps/queue/Callback.java diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.kt b/core/src/main/java/info/nightscout/androidaps/queue/commands/Command.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/queue/commands/Command.kt rename to core/src/main/java/info/nightscout/androidaps/queue/commands/Command.kt index eac1e6d103..ea6a8b9196 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.kt +++ b/core/src/main/java/info/nightscout/androidaps/queue/commands/Command.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag diff --git a/app/src/main/java/info/nightscout/androidaps/utils/DateUtil.java b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java similarity index 90% rename from app/src/main/java/info/nightscout/androidaps/utils/DateUtil.java rename to core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java index f058896f19..16fb3e2504 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/DateUtil.java +++ b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.utils; +import android.content.Context; + import androidx.collection.LongSparseArray; import org.joda.time.DateTime; @@ -26,15 +28,36 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import javax.inject.Inject; +import javax.inject.Singleton; + +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.utils.resources.ResourceHelper; /** * The Class DateUtil. A simple wrapper around SimpleDateFormat to ease the handling of iso date string <-> date obj * with TZ */ + +@Singleton public class DateUtil { + private final Context context; + private final ResourceHelper resourceHelper; + + @Deprecated + private static DateUtil instance; + + @Inject + public DateUtil(Context context, ResourceHelper resourceHelper) { + this.context = context; + this.resourceHelper = resourceHelper; + instance = this; + } + + @Deprecated + public static DateUtil getInstance() { + return instance; + } /** * The date format in iso. @@ -147,33 +170,33 @@ public class DateUtil { return df.format(mills); } - public static String dateStringShort(long mills) { + public String dateStringShort(long mills) { String format = "MM/dd"; - if (android.text.format.DateFormat.is24HourFormat(MainApp.instance())) { + if (android.text.format.DateFormat.is24HourFormat(context)) { format = "dd/MM"; } return new DateTime(mills).toString(DateTimeFormat.forPattern(format)); } - public static String timeString(Date date) { + public String timeString(Date date) { String format = "hh:mma"; - if (android.text.format.DateFormat.is24HourFormat(MainApp.instance())) { + if (android.text.format.DateFormat.is24HourFormat(context)) { format = "HH:mm"; } return new DateTime(date).toString(DateTimeFormat.forPattern(format)); } - public static String timeString(long mills) { + public String timeString(long mills) { String format = "hh:mma"; - if (android.text.format.DateFormat.is24HourFormat(MainApp.instance())) { + if (android.text.format.DateFormat.is24HourFormat(context)) { format = "HH:mm"; } return new DateTime(mills).toString(DateTimeFormat.forPattern(format)); } - public static String timeStringWithSeconds(long mills) { + public String timeStringWithSeconds(long mills) { String format = "hh:mm:ssa"; - if (android.text.format.DateFormat.is24HourFormat(MainApp.instance())) { + if (android.text.format.DateFormat.is24HourFormat(context)) { format = "HH:mm:ss"; } return new DateTime(mills).toString(DateTimeFormat.forPattern(format)); @@ -184,21 +207,21 @@ public class DateUtil { } public static String dateAndTimeString(Date date) { - return dateString(date) + " " + timeString(date); + return dateString(date) + " " + instance.timeString(date); } public static String dateAndTimeRangeString(long start, long end) { - return dateAndTimeString(start) + " - " + timeString(end); + return dateAndTimeString(start) + " - " + instance.timeString(end); } public static String dateAndTimeString(long mills) { if (mills == 0) return ""; - return dateString(mills) + " " + timeString(mills); + return dateString(mills) + " " + instance.timeString(mills); } public static String dateAndTimeAndSecondsString(long mills) { if (mills == 0) return ""; - return dateString(mills) + " " + timeStringWithSeconds(mills); + return dateString(mills) + " " + instance.timeStringWithSeconds(mills); } public static String dateAndTimeFullString(long mills) { @@ -226,7 +249,7 @@ public class DateUtil { String cached = timeStrings.get(seconds); if (cached != null) return cached; - String t = timeString(toDate(seconds)); + String t = instance.timeString(toDate(seconds)); timeStrings.put(seconds, t); return t; } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/DecimalFormatter.java b/core/src/main/java/info/nightscout/androidaps/utils/DecimalFormatter.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/DecimalFormatter.java rename to core/src/main/java/info/nightscout/androidaps/utils/DecimalFormatter.java diff --git a/app/src/main/java/info/nightscout/androidaps/utils/DefaultValueHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/DefaultValueHelper.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/utils/DefaultValueHelper.kt rename to core/src/main/java/info/nightscout/androidaps/utils/DefaultValueHelper.kt index 6f7e49c9bd..1f85996369 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/DefaultValueHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/DefaultValueHelper.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.utils import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.sharedPreferences.SP import javax.inject.Inject import javax.inject.Singleton diff --git a/app/src/main/java/info/nightscout/androidaps/utils/JsonHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/JsonHelper.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/JsonHelper.kt rename to core/src/main/java/info/nightscout/androidaps/utils/JsonHelper.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/Round.java b/core/src/main/java/info/nightscout/androidaps/utils/Round.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/Round.java rename to core/src/main/java/info/nightscout/androidaps/utils/Round.java diff --git a/app/src/main/java/info/nightscout/androidaps/utils/TimeChangeType.java b/core/src/main/java/info/nightscout/androidaps/utils/TimeChangeType.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/TimeChangeType.java rename to core/src/main/java/info/nightscout/androidaps/utils/TimeChangeType.java diff --git a/app/src/main/java/info/nightscout/androidaps/utils/Translator.kt b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/utils/Translator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/Translator.kt index b68fb74194..501c2e7d1a 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/Translator.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.utils -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject import javax.inject.Singleton diff --git a/app/src/main/res/drawable/icon_actions_profileswitch.png b/core/src/main/res/drawable/icon_actions_profileswitch.png similarity index 100% rename from app/src/main/res/drawable/icon_actions_profileswitch.png rename to core/src/main/res/drawable/icon_actions_profileswitch.png diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index ab83365d64..19da434c99 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -4,15 +4,32 @@ #000000 #40bbaa + #303030 #121212 #FFFFFF #FFFFFF - #FFFB8C00 #FF000000 - #FFFF5555 #FF000000 + + #C803A9F4 + + + #00FF00 + #FF0000 + #FFFF00 + #1e88e5 + #1ea3e5 + #FFFB8C00 + #FFFB8C00 + #c9bd60 + #00d2d2 + #ffffff + + + #FF8C00 + diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index be67629d42..b69a63c11c 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -2,16 +2,124 @@ enable_fabric language + units + loop_openmode_min_change + absorption_maxtime + openapsama_min_5m_carbimpact + absorption_cutoff + danar_visualizeextendedaspercentage" + danar_useextended + eatingsoon_duration + eatingsoon_target + activity_duration + activity_target + hypo_duration + hypo_target + low_mark + high_mark + Confirmation Message OK Cancel DISMISS + Bluetooth Low Energy not supported. Bluetooth not enabled. Location Is Not Enabled For Bluetooth discovery to work on newer devices, location must be enabled. AAPS does not track your location and it can be disabled after pairing is successful. + + %1$dm ago + %1$.1fh ago + h + days + hours + second + minute + hour + day + week + seconds + minutes + hours + days + weeks + m + d + + + Basal values not aligned to hours: %1$s + Basal value replaced by minimal supported value: %1$s + Basal value replaced by maximum supported value: %1$s + /U + U/h + g/U + + + No profile selected + + + * Only discrete values no ranges are supported as granularity for basal/bolus in virtual pump. + + + Cancel temp basal + Let temp basal run + Rate + Duration + Reason + No change requested + + + Invalid profile: %1$s + + + %1$dmin + + + %1$s: ∑: %2$.2f Bol: %3$.2f Bas: %4$.2f]]> + + + BG Check + Announcement + Note + Question + Exercise + Pump Site Change + CGM Sensor Insert + CGM Sensor Start + Insulin Cartridge Change + Profile switch + Snack Bolus + Meal Bolus + Correction Bolus + Combo Bolus + Temp Basal Start + Temp Basal End + Carbs correction + OpenAPS Offline + Pump Battery Change + Temporary target + Temporary target cancel + Finger + Sensor + Manual + unknown + + + Connection timed out + + + Enacted + Comment + Success + Percent + Absolute + Insulin + U + Waiting for result + SMB + \ No newline at end of file From eb6eebe853a43086904dd2e91f1e13907e519402 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Thu, 7 May 2020 21:17:32 +0200 Subject: [PATCH 039/400] Restore version for upstream merge from Omnipod repo --- app/build.gradle | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e3666c9961..fa13e0eea0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -129,7 +129,7 @@ android { targetSdkVersion 28 multiDexEnabled true versionCode 1500 - version "2.7-omnipod-0.4-dagger-SNAPSHOT" + version "2.6.5-dev" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' @@ -137,11 +137,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.5-dev"' - buildConfigField "String", "DEV_VERSION_COMMIT", '"b87155ead499167b3d42a73e3daf808494f10a2d"' - buildConfigField "String", "DEV_VERSION_COMMIT_DATE", '"24.4.2020"' // 24th April - ndk { moduleName "BleCommandUtil" } From 70e9d3e88ad02c498a8a4f31babed2ba4873da4f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 7 May 2020 23:40:59 +0200 Subject: [PATCH 040/400] fix tests --- .../androidaps/activities/StatsActivity.kt | 3 +- .../androidaps/activities/SurveyActivity.kt | 3 +- .../androidaps/dialogs/CarbsDialog.kt | 4 +- .../androidaps/dialogs/CareDialog.kt | 2 +- .../androidaps/dialogs/FillDialog.kt | 2 +- .../androidaps/dialogs/InsulinDialog.kt | 2 +- .../androidaps/dialogs/ProfileSwitchDialog.kt | 2 +- .../androidaps/dialogs/ProfileViewerDialog.kt | 3 +- .../androidaps/dialogs/TempTargetDialog.kt | 2 +- .../historyBrowser/HistoryBrowseActivity.kt | 7 ++- .../IobCobStaticCalculatorPlugin.kt | 6 +- .../plugins/aps/loop/LoopFragment.kt | 11 ++-- .../aps/openAPSAMA/OpenAPSAMAFragment.kt | 3 +- .../aps/openAPSSMB/OpenAPSSMBFragment.kt | 3 +- .../objectives/ObjectivesFragment.kt | 8 ++- .../general/actions/ActionsFragment.kt | 2 +- .../automation/triggers/TriggerTime.kt | 5 +- .../Dialogs/NewNSTreatmentDialog.java | 2 +- .../nsclient/services/NSClientService.java | 3 +- .../general/tidepool/comm/TidepoolUploader.kt | 5 +- .../general/tidepool/comm/UploadChunk.kt | 15 ++--- .../IobCobCalculatorPlugin.java | 27 ++++---- .../iobCobCalculator/IobCobOref1Thread.java | 5 +- .../iob/iobCobCalculator/IobCobThread.java | 5 +- .../profile/local/LocalProfileFragment.kt | 23 ++++--- .../pump/common/PumpPluginAbstract.java | 10 +-- .../RileyLinkStatusGeneralFragment.java | 6 +- .../RileyLinkStatusHistoryFragment.java | 3 +- .../plugins/pump/common/utils/StringUtil.java | 4 +- .../pump/danaR/AbstractDanaRPlugin.java | 11 ++-- .../plugins/pump/danaR/DanaRPlugin.java | 6 +- .../danaR/activities/DanaRHistoryActivity.kt | 3 +- .../pump/danaR/comm/MessageHashTableR.kt | 32 +++++----- .../pump/danaR/comm/MsgHistoryAlarm.kt | 6 +- .../plugins/pump/danaR/comm/MsgHistoryAll.kt | 5 +- .../pump/danaR/comm/MsgHistoryBasalHour.kt | 6 +- .../pump/danaR/comm/MsgHistoryBolus.kt | 6 +- .../pump/danaR/comm/MsgHistoryCarbo.kt | 6 +- .../pump/danaR/comm/MsgHistoryDailyInsulin.kt | 6 +- .../pump/danaR/comm/MsgHistoryError.kt | 6 +- .../pump/danaR/comm/MsgHistoryGlucose.kt | 6 +- .../plugins/pump/danaR/comm/MsgHistoryNew.kt | 6 +- .../pump/danaR/comm/MsgHistoryRefill.kt | 6 +- .../pump/danaR/comm/MsgHistorySuspend.kt | 6 +- .../pump/danaR/comm/MsgInitConnStatusTime.kt | 5 +- .../plugins/pump/danaR/comm/MsgSetTime.kt | 3 +- .../pump/danaR/comm/MsgSettingPumpTime.kt | 5 +- .../pump/danaR/comm/MsgStatusBolusExtended.kt | 5 +- .../AbstractDanaRExecutionService.java | 19 +++--- .../danaR/services/DanaRExecutionService.java | 19 +++--- .../pump/danaRKorean/DanaRKoreanPlugin.java | 7 ++- .../comm/MessageHashTableRKorean.kt | 22 ++++--- .../comm/MsgInitConnStatusTime_k.kt | 5 +- .../services/DanaRKoreanExecutionService.java | 13 ++-- .../plugins/pump/danaRS/DanaRSPlugin.java | 11 ++-- .../danaRS/comm/DanaRSMessageHashTable.kt | 36 +++++------ .../comm/DanaRS_Packet_APS_History_Events.kt | 34 +++++----- .../DanaRS_Packet_APS_Set_Event_History.kt | 3 +- ..._Packet_Basal_Get_Temporary_Basal_State.kt | 5 +- ...Packet_Bolus_Get_Step_Bolus_Information.kt | 5 +- ...aRS_Packet_General_Get_More_Information.kt | 5 +- ...Packet_General_Get_Shipping_Information.kt | 5 +- .../danaRS/comm/DanaRS_Packet_History_.kt | 7 ++- .../comm/DanaRS_Packet_History_Alarm.kt | 4 +- .../comm/DanaRS_Packet_History_All_History.kt | 4 +- .../comm/DanaRS_Packet_History_Basal.kt | 4 +- .../DanaRS_Packet_History_Blood_Glucose.kt | 4 +- .../comm/DanaRS_Packet_History_Bolus.kt | 4 +- .../DanaRS_Packet_History_Carbohydrate.kt | 4 +- .../comm/DanaRS_Packet_History_Daily.kt | 4 +- .../comm/DanaRS_Packet_History_Prime.kt | 4 +- .../comm/DanaRS_Packet_History_Refill.kt | 4 +- .../comm/DanaRS_Packet_History_Suspend.kt | 4 +- .../comm/DanaRS_Packet_History_Temporary.kt | 4 +- .../DanaRS_Packet_Option_Get_Pump_Time.kt | 5 +- .../DanaRS_Packet_Option_Set_Pump_Time.kt | 3 +- .../pump/danaRS/services/DanaRSService.java | 46 +++++++------- .../plugins/pump/danaRv2/DanaRv2Plugin.java | 5 +- .../pump/danaRv2/comm/MessageHashTableRv2.kt | 28 ++++----- .../pump/danaRv2/comm/MsgHistoryEvents_v2.kt | 30 ++++----- .../danaRv2/comm/MsgStatusTempBasal_v2.kt | 6 +- .../services/DanaRv2ExecutionService.java | 22 +++---- .../pump/insight/LocalInsightPlugin.java | 9 ++- .../pump/medtronic/MedtronicPumpPlugin.java | 6 +- .../RileyLinkStatusDeviceMedtronic.java | 4 +- .../pump/omnipod/OmnipodPumpPlugin.java | 13 ++-- .../omnipod/defs/state/PodSessionState.java | 3 +- .../plugins/pump/virtual/VirtualPumpPlugin.kt | 7 ++- .../sensitivity/SensitivityAAPSPlugin.java | 18 +++--- .../sensitivity/SensitivityOref1Plugin.java | 13 ++-- .../SensitivityWeightedAveragePlugin.java | 23 +++---- .../plugins/source/BGSourceFragment.kt | 10 +-- .../plugins/source/EversensePlugin.kt | 7 ++- .../plugins/source/NSClientSourcePlugin.kt | 2 +- .../plugins/treatments/TreatmentsPlugin.java | 11 ++-- .../fragments/TreatmentsBolusFragment.kt | 5 +- .../fragments/TreatmentsCareportalFragment.kt | 5 +- .../TreatmentsExtendedBolusesFragment.kt | 8 +-- .../TreatmentsProfileSwitchFragment.kt | 9 +-- .../TreatmentsTempTargetFragment.java | 6 +- .../TreatmentsTemporaryBasalsFragment.kt | 9 +-- .../queue/commands/CommandSMBBolus.kt | 3 +- .../androidaps/receivers/KeepAliveReceiver.kt | 3 +- .../androidaps/utils/LocalAlertUtils.kt | 5 +- .../androidaps/utils/SntpClient.java | 63 ++++++++++++------- .../androidaps/utils/TimeListEdit.java | 26 +++++--- .../androidaps/utils/stats/TddCalculator.kt | 11 ++-- .../androidaps/TestBaseWithProfile.kt | 4 ++ .../nightscout/androidaps/db/BgReadingTest.kt | 56 ++++++++--------- .../interfaces/ConstraintsCheckerTest.kt | 13 ++-- .../objectives/ObjectivesPluginTest.kt | 4 +- .../constraints/safety/SafetyPluginTest.kt | 3 +- .../automation/triggers/TriggerBgTest.kt | 2 +- .../automation/triggers/TriggerDeltaTest.kt | 16 ++--- .../automation/triggers/TriggerTestBase.kt | 13 ++++ .../maintenance/MaintenancePluginTest.kt | 4 +- .../SmsCommunicatorPluginTest.kt | 10 ++- .../GlucoseStatusTest.kt | 38 ++++++----- .../IobCobCalculatorPluginTest.kt | 4 +- .../plugins/pump/danaR/DanaRPluginTest.kt | 2 +- .../plugins/pump/danaR/comm/DanaRTestBase.kt | 2 + .../pump/danaR/comm/MessageHashTableRTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryAlarmTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryAllTest.kt | 2 +- .../danaR/comm/MsgHistoryBasalHourTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryBolusTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryCarboTest.kt | 2 +- .../danaR/comm/MsgHistoryDailyInsulinTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryErrorTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryGlucoseTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryNewTest.kt | 2 +- .../pump/danaR/comm/MsgHistoryRefillTest.kt | 2 +- .../pump/danaR/comm/MsgHistorySuspendTest.kt | 2 +- .../danaR/comm/MsgInitConnStatusTimeTest.kt | 2 +- .../plugins/pump/danaR/comm/MsgSetTimeTest.kt | 2 +- .../pump/danaR/comm/MsgSettingPumpTimeTest.kt | 2 +- .../danaR/comm/MsgStatusBolusExtendedTest.kt | 2 +- .../pump/danaRKorean/DanaRKoreanPluginTest.kt | 2 +- .../comm/MessageHashTableRKoreanTest.kt | 2 +- .../plugins/pump/danaRS/DanaRSPluginTest.kt | 2 +- .../danaRS/comm/DanaRSMessageHashTableTest.kt | 7 ++- .../DanaRS_Packet_APS_History_EventsTest.kt | 4 +- ...DanaRS_Packet_APS_Set_Event_HistoryTest.kt | 8 +-- ...ket_Basal_Get_Temporary_Basal_StateTest.kt | 2 +- ...et_Bolus_Get_Step_Bolus_InformationTest.kt | 2 +- ...S_Packet_Bolus_Set_Step_Bolus_StartTest.kt | 2 +- ...Packet_General_Get_More_InformationTest.kt | 4 +- ...et_General_Get_Shipping_InformationTest.kt | 4 +- .../comm/DanaRS_Packet_History_AlarmTest.kt | 2 +- .../DanaRS_Packet_History_All_HistoryTest.kt | 2 +- .../comm/DanaRS_Packet_History_BasalTest.kt | 2 +- ...DanaRS_Packet_History_Blood_GlucoseTest.kt | 2 +- .../comm/DanaRS_Packet_History_BolusTest.kt | 2 +- .../DanaRS_Packet_History_CarbohydrateTest.kt | 2 +- .../comm/DanaRS_Packet_History_DailyTest.kt | 2 +- .../comm/DanaRS_Packet_History_PrimeTest.kt | 2 +- .../comm/DanaRS_Packet_History_RefillTest.kt | 2 +- .../comm/DanaRS_Packet_History_SuspendTest.kt | 2 +- .../DanaRS_Packet_History_TemporaryTest.kt | 2 +- ...Packet_Notify_Delivery_Rate_DisplayTest.kt | 2 +- .../DanaRS_Packet_Option_Get_Pump_TimeTest.kt | 2 +- .../DanaRS_Packet_Option_Set_Pump_TimeTest.kt | 2 +- .../plugins/pump/danaRv2/DanaRv2PluginTest.kt | 2 +- .../danaRv2/comm/MessageHashTable_rv2Test.kt | 5 +- .../danaRv2/comm/MsgHistoryEvents_v2Test.kt | 5 +- .../danaRv2/comm/MsgStatusTempBasal_v2Test.kt | 2 +- .../pump/virtual/VirtualPumpPluginUTest.kt | 5 +- .../AbstractSensitivityPluginTest.kt | 3 +- .../treatments/TreatmentsPluginTest.kt | 2 +- .../androidaps/queue/CommandQueueTest.kt | 3 +- .../androidaps/utils/DateUtilTest.kt | 22 ++++--- .../androidaps/utils/SntpClientTest.java | 28 --------- .../androidaps/utils/SntpClientTest.kt | 29 +++++++++ .../nightscout/androidaps/db/BgReading.java | 6 +- .../androidaps/db/CareportalEvent.java | 5 +- .../androidaps/db/ExtendedBolus.java | 2 +- .../androidaps/db/ProfileSwitch.java | 13 ++-- .../info/nightscout/androidaps/db/TDD.java | 5 +- .../nightscout/androidaps/db/TempTarget.java | 4 +- .../androidaps/db/TemporaryBasal.java | 2 +- .../nightscout/androidaps/db/Treatment.java | 3 +- .../iobCobCalculator/data/AutosensData.java | 11 ++-- .../nightscout/androidaps/utils/DateUtil.java | 29 +++------ 183 files changed, 814 insertions(+), 617 deletions(-) delete mode 100644 app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.kt diff --git a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt index d53f06e67c..ca26266f8f 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt @@ -16,13 +16,12 @@ class StatsActivity : NoSplashAppCompatActivity() { @Inject lateinit var tirCalculator: TirCalculator @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var activityMonitor: ActivityMonitor - @Inject lateinit var dateUtil: DateUtil override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_stats) - stats_tdds.text = tddCalculator.stats(dateUtil) + stats_tdds.text = tddCalculator.stats() stats_tir.text = tirCalculator.stats() stats_activity.text = activityMonitor.stats() diff --git a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt index 8797bcfe70..ff3e361a9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt @@ -31,7 +31,6 @@ class SurveyActivity : NoSplashAppCompatActivity() { @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var activityMonitor: ActivityMonitor @Inject lateinit var defaultProfile: DefaultProfile - @Inject lateinit var dateUtil: DateUtil override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -43,7 +42,7 @@ class SurveyActivity : NoSplashAppCompatActivity() { val profileList = profileStore?.getProfileList() ?: return survey_spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, profileList) - survey_tdds.text = tddCalculator.stats(dateUtil) + survey_tdds.text = tddCalculator.stats() survey_tir.text = tirCalculator.stats() survey_activity.text = activityMonitor.stats() diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt index 73effb19d8..28abd8eb60 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -170,7 +170,7 @@ class CarbsDialog : DialogFragmentWithDate() { eventTime -= eventTime % 1000 val time = eventTime + timeOffset * 1000 * 60 if (timeOffset != 0) - actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time)) + actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(time)) val duration = overview_carbs_duration.value.toInt() if (duration > 0) actions.add(resourceHelper.gs(R.string.duration) + ": " + duration + resourceHelper.gs(R.string.shorthour)) @@ -184,7 +184,7 @@ class CarbsDialog : DialogFragmentWithDate() { actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes) if (eventTimeChanged) - actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime)) + actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) if (carbsAfterConstraints > 0 || activitySelected || eatingSoonSelected || hypoSelected) { activity?.let { activity -> diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index 8a07e111b9..1eda2e060e 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -167,7 +167,7 @@ class CareDialog : DialogFragmentWithDate() { eventTime -= eventTime % 1000 if (eventTimeChanged) - actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime)) + actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) json.put("created_at", DateUtil.toISOString(eventTime)) json.put("mills", eventTime) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt index 135eeb0e09..1300ee1612 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -112,7 +112,7 @@ class FillDialog : DialogFragmentWithDate() { eventTime -= eventTime % 1000 if (eventTimeChanged) - actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime)) + actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) if (insulinAfterConstraints > 0 || fill_catheter_change.isChecked || fill_cartridge_change.isChecked) { activity?.let { activity -> diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt index e4fa54e2f3..f06f563874 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -145,7 +145,7 @@ class InsulinDialog : DialogFragmentWithDate() { val timeOffset = overview_insulin_time.value.toInt() val time = DateUtil.now() + T.mins(timeOffset.toLong()).msecs() if (timeOffset != 0) - actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time)) + actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(time)) val notes = notes.text.toString() if (notes.isNotEmpty()) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 10be190380..72daeb1ad1 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -98,7 +98,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { if (notes.isNotEmpty()) actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes) if (eventTimeChanged) - actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime)) + actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), Runnable { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileViewerDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileViewerDialog.kt index 382e6359a5..9536da6928 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileViewerDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileViewerDialog.kt @@ -23,6 +23,7 @@ class ProfileViewerDialog : DaggerDialogFragment() { @Inject lateinit var injector: HasAndroidInjector @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var treatmentsPlugin: TreatmentsPlugin + @Inject lateinit var dateUtil: DateUtil private var time: Long = 0 @@ -67,7 +68,7 @@ class ProfileViewerDialog : DaggerDialogFragment() { Mode.RUNNING_PROFILE -> { profile = treatmentsPlugin.getProfileSwitchFromHistory(time)?.profileObject profileName = treatmentsPlugin.getProfileSwitchFromHistory(time)?.customizedName - date = DateUtil.dateAndTimeString(treatmentsPlugin.getProfileSwitchFromHistory(time)?.date + date = dateUtil.dateAndTimeString(treatmentsPlugin.getProfileSwitchFromHistory(time)?.date ?: 0) profileview_datelayout.visibility = View.VISIBLE } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt index 95ca3c0723..d2e9c0454f 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -129,7 +129,7 @@ class TempTargetDialog : DialogFragmentWithDate() { actions.add(resourceHelper.gs(R.string.stoptemptarget)) } if (eventTimeChanged) - actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime)) + actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), Runnable { diff --git a/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt b/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt index ab8cae8666..f59a38d770 100644 --- a/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt @@ -54,6 +54,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { @Inject lateinit var buildHelper: BuildHelper @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var overviewMenus: OverviewMenus + @Inject lateinit var dateUtil: DateUtil private val disposable = CompositeDisposable() @@ -117,7 +118,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { cal.set(Calendar.MONTH, monthOfYear) cal.set(Calendar.DAY_OF_MONTH, dayOfMonth) start = cal.timeInMillis - historybrowse_date?.text = DateUtil.dateAndTimeString(start) + historybrowse_date?.text = dateUtil.dateAndTimeString(start) updateGUI("onClickDate") runCalculation("onClickDate") } @@ -236,7 +237,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { val lowLine = defaultValueHelper.determineLowLine() val highLine = defaultValueHelper.determineHighLine() - historybrowse_date?.text = DateUtil.dateAndTimeString(start) + historybrowse_date?.text = dateUtil.dateAndTimeString(start) historybrowse_zoom?.text = rangeToDisplay.toString() GlobalScope.launch(Dispatchers.Main) { @@ -248,7 +249,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { withContext(Dispatchers.Default) { val fromTime: Long = start + T.secs(100).msecs() val toTime: Long = start + T.hours(rangeToDisplay.toLong()).msecs() - aapsLogger.debug(LTag.UI, "Period: " + DateUtil.dateAndTimeString(fromTime) + " - " + DateUtil.dateAndTimeString(toTime)) + aapsLogger.debug(LTag.UI, "Period: " + dateUtil.dateAndTimeString(fromTime) + " - " + dateUtil.dateAndTimeString(toTime)) val pointer = System.currentTimeMillis() // **** In range Area **** diff --git a/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt index 8334ce9567..4a81820fd7 100644 --- a/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/historyBrowser/IobCobStaticCalculatorPlugin.kt @@ -10,6 +10,7 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -27,9 +28,10 @@ class IobCobStaticCalculatorPlugin @Inject constructor( sensitivityOref1Plugin: SensitivityOref1Plugin, sensitivityAAPSPlugin: SensitivityAAPSPlugin, sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin, - fabricPrivacy: FabricPrivacy + fabricPrivacy: FabricPrivacy, + dateUtil: DateUtil ) : IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction, - activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy) { + activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil) { override fun onStart() { // do not attach to rxbus } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt index 8463e8f133..4092f1d602 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopFragment.kt @@ -29,6 +29,7 @@ class LoopFragment : DaggerFragment() { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var loopPlugin: LoopPlugin + @Inject lateinit var dateUtil: DateUtil private var disposable: CompositeDisposable = CompositeDisposable() @@ -81,12 +82,12 @@ class LoopFragment : DaggerFragment() { loop_request?.text = it.request?.toSpanned() ?: "" loop_constraintsprocessed?.text = it.constraintsProcessed?.toSpanned() ?: "" loop_source?.text = it.source ?: "" - loop_lastrun?.text = DateUtil.dateAndTimeString(it.lastAPSRun) + loop_lastrun?.text = dateUtil.dateAndTimeString(it.lastAPSRun) ?: "" - loop_smbrequest_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastSMBRequest) - loop_smbexecution_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastSMBEnact) - loop_tbrrequest_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastTBRRequest) - loop_tbrexecution_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastTBREnact) + loop_smbrequest_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastSMBRequest) + loop_smbexecution_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastSMBEnact) + loop_tbrrequest_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBRRequest) + loop_tbrexecution_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBREnact) loop_tbrsetbypump?.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) } ?: "" diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAFragment.kt index 342a1395f5..fcd78a9adc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAFragment.kt @@ -32,6 +32,7 @@ class OpenAPSAMAFragment : DaggerFragment() { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin + @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -96,7 +97,7 @@ class OpenAPSAMAFragment : DaggerFragment() { openapsma_scriptdebugdata.text = determineBasalAdapterAMAJS.scriptDebug } if (openAPSAMAPlugin.lastAPSRun != 0L) { - openapsma_lastrun.text = DateUtil.dateAndTimeString(openAPSAMAPlugin.lastAPSRun) + openapsma_lastrun.text = dateUtil.dateAndTimeString(openAPSAMAPlugin.lastAPSRun) } openAPSAMAPlugin.lastAutosensResult?.let { openapsma_autosensdata.text = JSONFormatter.format(it.json()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBFragment.kt index 95b0f7f7b8..c16a432370 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBFragment.kt @@ -33,6 +33,7 @@ class OpenAPSSMBFragment : DaggerFragment() { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin + @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -99,7 +100,7 @@ class OpenAPSSMBFragment : DaggerFragment() { } } if (openAPSSMBPlugin.lastAPSRun != 0L) { - openapsma_lastrun.text = DateUtil.dateAndTimeString(openAPSSMBPlugin.lastAPSRun) + openapsma_lastrun.text = dateUtil.dateAndTimeString(openAPSSMBPlugin.lastAPSRun) } openAPSSMBPlugin.lastAutosensResult?.let { openapsma_autosensdata.text = JSONFormatter.format(it.json()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index 5fe20f2968..1e01d814f6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -49,6 +49,8 @@ class ObjectivesFragment : DaggerFragment() { @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var objectivesPlugin: ObjectivesPlugin @Inject lateinit var receiverStatusStore: ReceiverStatusStore + @Inject lateinit var dateUtil: DateUtil + @Inject lateinit var sntpClient: SntpClient private val objectivesAdapter = ObjectivesAdapter() private val handler = Handler(Looper.getMainLooper()) @@ -221,7 +223,7 @@ class ObjectivesFragment : DaggerFragment() { holder.progress.addView(separator, LinearLayout.LayoutParams.MATCH_PARENT, 2) } } - holder.accomplished.text = resourceHelper.gs(R.string.accomplished, DateUtil.dateAndTimeString(objective.accomplishedOn)) + holder.accomplished.text = resourceHelper.gs(R.string.accomplished, dateUtil.dateAndTimeString(objective.accomplishedOn)) holder.accomplished.setTextColor(-0x3e3e3f) holder.verify.setOnClickListener { receiverStatusStore.updateNetworkStatus() @@ -236,7 +238,7 @@ class ObjectivesFragment : DaggerFragment() { Thread { NtpProgressDialog().show((context as AppCompatActivity).supportFragmentManager, "NtpCheck") rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0)) - SntpClient.ntpTime(object : SntpClient.Callback() { + sntpClient.ntpTime(object : SntpClient.Callback() { override fun run() { aapsLogger.debug("NTP time: $time System time: ${DateUtil.now()}") SystemClock.sleep(300) @@ -275,7 +277,7 @@ class ObjectivesFragment : DaggerFragment() { Thread { NtpProgressDialog().show((context as AppCompatActivity).supportFragmentManager, "NtpCheck") rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0)) - SntpClient.ntpTime(object : SntpClient.Callback() { + sntpClient.ntpTime(object : SntpClient.Callback() { override fun run() { aapsLogger.debug("NTP time: $time System time: ${DateUtil.now()}") SystemClock.sleep(300) 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 e6077e6e26..f14f7732dd 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 @@ -248,7 +248,7 @@ class ActionsFragment : DaggerFragment() { private fun checkPumpCustomActions() { val activePump = activePlugin.activePump - val customActions = activePump.customActions + val customActions = activePump.customActions ?: return removePumpCustomActions() for (customAction in customActions) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt index 4726eb5e95..6641286484 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt @@ -12,8 +12,11 @@ import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.T import org.json.JSONObject +import javax.inject.Inject class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) { + @Inject lateinit var dateUtil: DateUtil + var time = InputDateTime(injector) constructor(injector: HasAndroidInjector, runAt: Long) : this(injector) { @@ -57,7 +60,7 @@ class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) { override fun friendlyName(): Int = R.string.time override fun friendlyDescription(): String = - resourceHelper.gs(R.string.atspecifiedtime, DateUtil.dateAndTimeString(time.value)) + resourceHelper.gs(R.string.atspecifiedtime, dateUtil.dateAndTimeString(time.value)) override fun icon(): Optional = Optional.of(R.drawable.ic_access_alarm_24dp) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java index 8cbb16a8dc..8fe577ced3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java @@ -699,7 +699,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O if (data.has("created_at")) { ret += resourceHelper.gs(R.string.event_time_label); ret += ": "; - ret += DateUtil.dateAndTimeString(eventTime); + ret += dateUtil.dateAndTimeString(eventTime); ret += "\n"; } if (data.has("enteredBy")) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java index 54de04db85..3187ccc924 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java @@ -90,6 +90,7 @@ public class NSClientService extends DaggerService { @Inject NSClientPlugin nsClientPlugin; @Inject BuildHelper buildHelper; @Inject Config config; + @Inject DateUtil dateUtil; private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT); private CompositeDisposable disposable = new CompositeDisposable(); @@ -721,7 +722,7 @@ public class NSClientService extends DaggerService { } handleNewSgv(sgvs, isDelta); } - rxBus.send(new EventNSClientNewLog("LAST", DateUtil.dateAndTimeString(latestDateInReceivedData))); + rxBus.send(new EventNSClientNewLog("LAST", dateUtil.dateAndTimeString(latestDateInReceivedData))); } catch (JSONException e) { log.error("Unhandled exception", e); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt index 6c120fc576..faaa1b40d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt @@ -38,7 +38,8 @@ class TidepoolUploader @Inject constructor( private val resourceHelper: ResourceHelper, private val sp: SP, private val uploadChunk: UploadChunk, - private val activePlugin: ActivePluginProvider + private val activePlugin: ActivePluginProvider, + private val dateUtil: DateUtil ) { private var wl: PowerManager.WakeLock? = null @@ -233,7 +234,7 @@ class TidepoolUploader @Inject constructor( private fun uploadNext() { if (uploadChunk.getLastEnd() < DateUtil.now() - T.mins(1).msecs()) { SystemClock.sleep(3000) - aapsLogger.debug(LTag.TIDEPOOL, "Restarting doUpload. Last: " + DateUtil.dateAndTimeString(uploadChunk.getLastEnd())) + aapsLogger.debug(LTag.TIDEPOOL, "Restarting doUpload. Last: " + dateUtil.dateAndTimeString(uploadChunk.getLastEnd())) doUpload() } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt index 8ad1bdd0bc..4062f27bd0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt @@ -29,7 +29,8 @@ class UploadChunk @Inject constructor( private val aapsLogger: AAPSLogger, private val profileFunction: ProfileFunction, private val treatmentsPlugin: TreatmentsPlugin, - private val activePlugin: ActivePluginProvider + private val activePlugin: ActivePluginProvider, + private val dateUtil: DateUtil ) { private val MAX_UPLOAD_SIZE = T.days(7).msecs() // don't change this @@ -51,9 +52,9 @@ class UploadChunk @Inject constructor( operator fun get(start: Long, end: Long): String { - aapsLogger.debug(LTag.TIDEPOOL, "Syncing data between: " + DateUtil.dateAndTimeString(start) + " -> " + DateUtil.dateAndTimeString(end)) + aapsLogger.debug(LTag.TIDEPOOL, "Syncing data between: " + dateUtil.dateAndTimeString(start) + " -> " + dateUtil.dateAndTimeString(end)) if (end <= start) { - aapsLogger.debug(LTag.TIDEPOOL, "End is <= start: " + DateUtil.dateAndTimeString(start) + " " + DateUtil.dateAndTimeString(end)) + aapsLogger.debug(LTag.TIDEPOOL, "End is <= start: " + dateUtil.dateAndTimeString(start) + " " + dateUtil.dateAndTimeString(end)) return "" } if (end - start > MAX_UPLOAD_SIZE) { @@ -85,11 +86,11 @@ class UploadChunk @Inject constructor( fun setLastEnd(time: Long) { if (time > getLastEnd()) { sp.putLong(R.string.key_tidepool_last_end, time) - val friendlyEnd = DateUtil.dateAndTimeString(time) + val friendlyEnd = dateUtil.dateAndTimeString(time) rxBus.send(EventTidepoolStatus(("Marking uploaded data up to $friendlyEnd"))) - aapsLogger.debug(LTag.TIDEPOOL, "Updating last end to: " + DateUtil.dateAndTimeString(time)) + aapsLogger.debug(LTag.TIDEPOOL, "Updating last end to: " + dateUtil.dateAndTimeString(time)) } else { - aapsLogger.debug(LTag.TIDEPOOL, "Cannot set last end to: " + DateUtil.dateAndTimeString(time) + " vs " + DateUtil.dateAndTimeString(getLastEnd())) + aapsLogger.debug(LTag.TIDEPOOL, "Cannot set last end to: " + dateUtil.dateAndTimeString(time) + " vs " + dateUtil.dateAndTimeString(getLastEnd())) } } @@ -129,7 +130,7 @@ class UploadChunk @Inject constructor( } - internal fun getBgReadings(start: Long, end: Long): List { + private fun getBgReadings(start: Long, end: Long): List { val readings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, end, true) val selection = SensorGlucoseElement.fromBgReadings(readings) if (selection.isNotEmpty()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java index fe5ac90449..c38c286122 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java @@ -69,6 +69,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat private final SensitivityAAPSPlugin sensitivityAAPSPlugin; private final SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin; private final FabricPrivacy fabricPrivacy; + private final DateUtil dateUtil; private CompositeDisposable disposable = new CompositeDisposable(); @@ -98,7 +99,8 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat SensitivityOref1Plugin sensitivityOref1Plugin, SensitivityAAPSPlugin sensitivityAAPSPlugin, SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin, - FabricPrivacy fabricPrivacy + FabricPrivacy fabricPrivacy, + DateUtil dateUtil ) { super(new PluginDescription() .mainType(PluginType.GENERAL) @@ -119,6 +121,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat this.sensitivityAAPSPlugin = sensitivityAAPSPlugin; this.sensitivityWeightedAveragePlugin = sensitivityWeightedAveragePlugin; this.fabricPrivacy = fabricPrivacy; + this.dateUtil = dateUtil; } @Override @@ -247,10 +250,10 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat // if close to now expect there can be some readings with time in close future (caused by wrong time setting) // so read all records bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, false); - getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start)); + getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + dateUtil.dateAndTimeString(start)); } else { bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, to, false); - getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(to)); + getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + dateUtil.dateAndTimeString(start) + " End date: " + dateUtil.dateAndTimeString(to)); } } @@ -440,7 +443,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat if (limitDataToOldestAvailable) { getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia))); if (getBGDataFrom == oldestDataAvailable) - getAapsLogger().debug(LTag.AUTOSENS, "Limiting data to oldest available temps: " + DateUtil.dateAndTimeString(oldestDataAvailable)); + getAapsLogger().debug(LTag.AUTOSENS, "Limiting data to oldest available temps: " + dateUtil.dateAndTimeString(oldestDataAvailable)); } else getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia)); return getBGDataFrom; @@ -675,7 +678,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat return null; } if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) { - getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time)); + getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + dateUtil.dateAndTimeString(data.time)); return null; } else { getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA (" + reason + ") " + data.toString()); @@ -686,7 +689,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat @Override public String lastDataTime() { if (autosensDataTable.size() > 0) - return DateUtil.dateAndTimeString(autosensDataTable.valueAt(autosensDataTable.size() - 1).time); + return dateUtil.dateAndTimeString(autosensDataTable.valueAt(autosensDataTable.size() - 1).time); else return "autosensDataTable empty"; } @@ -808,7 +811,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat } public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { - getAapsLogger().debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end)); + getAapsLogger().debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + dateUtil.dateAndTimeString(end)); if (thread == null || thread.getState() == Thread.State.TERMINATED) { if (sensitivityOref1Plugin.isEnabled()) thread = new IobCobOref1Thread(injector, from, end, bgDataReload, limitDataToOldestAvailable, cause); @@ -825,10 +828,10 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat synchronized (dataLock) { // clear up 5 min back for proper COB calculation long time = ev.getTime() - 5 * 60 * 1000L; - getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data to: " + DateUtil.dateAndTimeString(time)); + getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data to: " + dateUtil.dateAndTimeString(time)); for (int index = iobTable.size() - 1; index >= 0; index--) { if (iobTable.keyAt(index) > time) { - getAapsLogger().debug(LTag.AUTOSENS, "Removing from iobTable: " + DateUtil.dateAndTimeString(iobTable.keyAt(index))); + getAapsLogger().debug(LTag.AUTOSENS, "Removing from iobTable: " + dateUtil.dateAndTimeString(iobTable.keyAt(index))); iobTable.removeAt(index); } else { break; @@ -836,7 +839,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat } for (int index = absIobTable.size() - 1; index >= 0; index--) { if (absIobTable.keyAt(index) > time) { - getAapsLogger().debug(LTag.AUTOSENS, "Removing from absIobTable: " + DateUtil.dateAndTimeString(absIobTable.keyAt(index))); + getAapsLogger().debug(LTag.AUTOSENS, "Removing from absIobTable: " + dateUtil.dateAndTimeString(absIobTable.keyAt(index))); absIobTable.removeAt(index); } else { break; @@ -844,7 +847,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat } for (int index = autosensDataTable.size() - 1; index >= 0; index--) { if (autosensDataTable.keyAt(index) > time) { - getAapsLogger().debug(LTag.AUTOSENS, "Removing from autosensDataTable: " + DateUtil.dateAndTimeString(autosensDataTable.keyAt(index))); + getAapsLogger().debug(LTag.AUTOSENS, "Removing from autosensDataTable: " + dateUtil.dateAndTimeString(autosensDataTable.keyAt(index))); autosensDataTable.removeAt(index); } else { break; @@ -852,7 +855,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat } for (int index = basalDataTable.size() - 1; index >= 0; index--) { if (basalDataTable.keyAt(index) > time) { - getAapsLogger().debug(LTag.AUTOSENS, "Removing from basalDataTable: " + DateUtil.dateAndTimeString(basalDataTable.keyAt(index))); + getAapsLogger().debug(LTag.AUTOSENS, "Removing from basalDataTable: " + dateUtil.dateAndTimeString(basalDataTable.keyAt(index))); basalDataTable.removeAt(index); } else { break; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java index b1762e3722..457b16716a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java @@ -68,6 +68,7 @@ public class IobCobOref1Thread extends Thread { @Inject BuildHelper buildHelper; @Inject Profiler profiler; @Inject FabricPrivacy fabricPrivacy; + @Inject DateUtil dateUtil; private final HasAndroidInjector injector; private boolean bgDataReload; @@ -122,7 +123,7 @@ public class IobCobOref1Thread extends Thread { } long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); - aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + DateUtil.dateAndTimeString(prevDataTime)); + aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + dateUtil.dateAndTimeString(prevDataTime)); AutosensData previous = autosensDataTable.get(prevDataTime); // start from oldest to be able sub cob for (int i = bucketed_data.size() - 4; i >= 0; i--) { @@ -378,7 +379,7 @@ public class IobCobOref1Thread extends Thread { previous = autosensData; if (bgTime < now()) autosensDataTable.put(bgTime, autosensData); - aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime()); + aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime()); AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime); aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: " + sensitivity.toString()); autosensData.autosensResult = sensitivity; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java index d9ceb47dfc..84a02005e1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java @@ -65,6 +65,7 @@ public class IobCobThread extends Thread { @Inject BuildHelper buildHelper; @Inject Profiler profiler; @Inject FabricPrivacy fabricPrivacy; + @Inject DateUtil dateUtil; private final HasAndroidInjector injector; private boolean bgDataReload; @@ -119,7 +120,7 @@ public class IobCobThread extends Thread { } long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); - aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + DateUtil.dateAndTimeString(prevDataTime)); + aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + dateUtil.dateAndTimeString(prevDataTime)); AutosensData previous = autosensDataTable.get(prevDataTime); // start from oldest to be able sub cob for (int i = bucketed_data.size() - 4; i >= 0; i--) { @@ -302,7 +303,7 @@ public class IobCobThread extends Thread { previous = autosensData; if (bgTime < now()) autosensDataTable.put(bgTime, autosensData); - aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime()); + aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime()); AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime); aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: " + sensitivity.toString()); autosensData.autosensResult = sensitivity; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index f26bacf8ec..ef64d4a690 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -14,6 +14,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged @@ -28,12 +29,14 @@ import java.text.DecimalFormat import javax.inject.Inject class LocalProfileFragment : DaggerFragment() { + @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var localProfilePlugin: LocalProfilePlugin @Inject lateinit var hardLimits: HardLimits + @Inject lateinit var dateUtil: DateUtil private var disposable: CompositeDisposable = CompositeDisposable() @@ -103,14 +106,14 @@ class LocalProfileFragment : DaggerFragment() { localprofile_name.addTextChangedListener(textWatch) localprofile_dia.setParams(localProfilePlugin.currentProfile().dia, hardLimits.MINDIA, hardLimits.MAXDIA, 0.1, DecimalFormat("0.0"), false, localprofile_save, textWatch) localprofile_dia.tag = "LP_DIA" - TimeListEdit(context, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.nsprofileview_ic_label), localProfilePlugin.currentProfile().ic, null, hardLimits.MINIC, hardLimits.MAXIC, 0.1, DecimalFormat("0.0"), save) - basalView = TimeListEdit(context, view, R.id.localprofile_basal, "BASAL", resourceHelper.gs(R.string.nsprofileview_basal_label) + ": " + sumLabel(), localProfilePlugin.currentProfile().basal, null, pumpDescription.basalMinimumRate, 10.0, 0.01, DecimalFormat("0.00"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.nsprofileview_ic_label), localProfilePlugin.currentProfile().ic, null, hardLimits.MINIC, hardLimits.MAXIC, 0.1, DecimalFormat("0.0"), save) + basalView = TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_basal, "BASAL", resourceHelper.gs(R.string.nsprofileview_basal_label) + ": " + sumLabel(), localProfilePlugin.currentProfile().basal, null, pumpDescription.basalMinimumRate, 10.0, 0.01, DecimalFormat("0.00"), save) if (units == Constants.MGDL) { - TimeListEdit(context, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label), localProfilePlugin.currentProfile().isf, null, hardLimits.MINISF, hardLimits.MAXISF, 1.0, DecimalFormat("0"), save) - TimeListEdit(context, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label), localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, hardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), hardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), 1.0, DecimalFormat("0"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label), localProfilePlugin.currentProfile().isf, null, hardLimits.MINISF, hardLimits.MAXISF, 1.0, DecimalFormat("0"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label), localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, hardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), hardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), 1.0, DecimalFormat("0"), save) } else { - TimeListEdit(context, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label), localProfilePlugin.currentProfile().isf, null, Profile.fromMgdlToUnits(hardLimits.MINISF, Constants.MMOL), Profile.fromMgdlToUnits(hardLimits.MAXISF, Constants.MMOL), 0.1, DecimalFormat("0.0"), save) - TimeListEdit(context, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label), localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, Profile.fromMgdlToUnits(hardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), Constants.MMOL), Profile.fromMgdlToUnits(hardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), Constants.MMOL), 0.1, DecimalFormat("0.0"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label), localProfilePlugin.currentProfile().isf, null, Profile.fromMgdlToUnits(hardLimits.MINISF, Constants.MMOL), Profile.fromMgdlToUnits(hardLimits.MAXISF, Constants.MMOL), 0.1, DecimalFormat("0.0"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label), localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, Profile.fromMgdlToUnits(hardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), Constants.MMOL), Profile.fromMgdlToUnits(hardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), Constants.MMOL), 0.1, DecimalFormat("0.0"), save) } // Spinner @@ -187,10 +190,10 @@ class LocalProfileFragment : DaggerFragment() { localprofile_units.text = resourceHelper.gs(R.string.units_colon) + " " + (if (localProfilePlugin.currentProfile().mgdl) resourceHelper.gs(R.string.mgdl) else resourceHelper.gs(R.string.mmol)) localprofile_dia.setParams(localProfilePlugin.currentProfile().dia, MIN_DIA, 12.0, 0.1, DecimalFormat("0.0"), false, localprofile_save, textWatch) localprofile_dia.tag = "LP_DIA" - TimeListEdit(context, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.nsprofileview_ic_label) + ":", localProfilePlugin.currentProfile().ic, null, 0.5, 50.0, 0.1, DecimalFormat("0.0"), save) - TimeListEdit(context, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label) + ":", localProfilePlugin.currentProfile().isf, null, 0.5, 500.0, 0.1, DecimalFormat("0.0"), save) - basalView = TimeListEdit(context, view, R.id.localprofile_basal, "BASAL", resourceHelper.gs(R.string.nsprofileview_basal_label) + ": " + sumLabel(), localProfilePlugin.currentProfile().basal, null, pumpDescription.basalMinimumRate, 10.0, 0.01, DecimalFormat("0.00"), save) - TimeListEdit(context, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label) + ":", localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, 3.0, 200.0, 0.1, DecimalFormat("0.0"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.nsprofileview_ic_label) + ":", localProfilePlugin.currentProfile().ic, null, 0.5, 50.0, 0.1, DecimalFormat("0.0"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label) + ":", localProfilePlugin.currentProfile().isf, null, 0.5, 500.0, 0.1, DecimalFormat("0.0"), save) + basalView = TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_basal, "BASAL", resourceHelper.gs(R.string.nsprofileview_basal_label) + ": " + sumLabel(), localProfilePlugin.currentProfile().basal, null, pumpDescription.basalMinimumRate, 10.0, 0.01, DecimalFormat("0.00"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label) + ":", localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, 3.0, 200.0, 0.1, DecimalFormat("0.0"), save) updateGUI() } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java index f4dd6a48df..0bb38acb76 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java @@ -65,6 +65,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI protected ResourceHelper resourceHelper; protected CommandQueueProvider commandQueue; protected SP sp; + protected DateUtil dateUtil; /* protected static final PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult().success(false) @@ -92,7 +93,8 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI ActivePluginProvider activePlugin, SP sp, Context context, - FabricPrivacy fabricPrivacy + FabricPrivacy fabricPrivacy, + DateUtil dateUtil ) { super(pluginDescription, injector, aapsLogger, resourceHelper, commandQueue); @@ -107,7 +109,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI pumpDescription.setPumpDescription(pumpType); this.pumpType = pumpType; - + this.dateUtil = dateUtil; } @@ -345,14 +347,14 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI if (tb != null) { extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(System.currentTimeMillis(), profile)); - extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); + extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); } ExtendedBolus eb = activePlugin.getActiveTreatments().getExtendedBolusFromHistory(System.currentTimeMillis()); if (eb != null) { extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); - extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); + extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes()); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java index 623ecae9ef..bec19c7d1f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java @@ -32,6 +32,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin; import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; +import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; /** @@ -45,6 +46,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re @Inject MedtronicUtil medtronicUtil; @Inject AAPSLogger aapsLogger; @Inject RileyLinkServiceData rileyLinkServiceData; + @Inject DateUtil dateUtil; TextView connectionStatus; TextView configuredAddress; @@ -148,7 +150,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re rileyLinkServiceData.lastGoodFrequency)); if (medtronicPumpStatus.lastConnection != 0) - this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime( + this.lastDeviceContact.setText(StringUtil.toDateTimeString(dateUtil, new LocalDateTime( medtronicPumpStatus.lastDataTime))); else this.lastDeviceContact.setText(resourceHelper.gs(R.string.common_never)); @@ -182,7 +184,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re rileyLinkServiceData.lastGoodFrequency)); if (omnipodPumpStatus.lastConnection != 0) - this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime( + this.lastDeviceContact.setText(StringUtil.toDateTimeString(dateUtil, new LocalDateTime( omnipodPumpStatus.lastDataTime))); else this.lastDeviceContact.setText(resourceHelper.gs(R.string.common_never)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusHistoryFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusHistoryFragment.java index f8f79c821a..8a3ff18207 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusHistoryFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusHistoryFragment.java @@ -34,6 +34,7 @@ public class RileyLinkStatusHistoryFragment extends DaggerFragment implements Re @Inject RileyLinkUtil rileyLinkUtil; @Inject ResourceHelper resourceHelper; + @Inject DateUtil dateUtil; RecyclerView recyclerView; RecyclerViewAdapter recyclerViewAdapter; @@ -136,7 +137,7 @@ public class RileyLinkStatusHistoryFragment extends DaggerFragment implements Re RLHistoryItem item = historyList.get(position); if (item != null) { - holder.timeView.setText(DateUtil.dateAndTimeAndSecondsString(item.getDateTime().toDateTime().getMillis())); + holder.timeView.setText(dateUtil.dateAndTimeAndSecondsString(item.getDateTime().toDateTime().getMillis())); holder.typeView.setText(item.getSource().getDesc()); holder.valueView.setText(item.getDescription(resourceHelper)); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/StringUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/StringUtil.java index f7d86e5774..cc9533e669 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/StringUtil.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/StringUtil.java @@ -84,8 +84,8 @@ public class StringUtil { } - public static String toDateTimeString(LocalDateTime localDateTime) { - return DateUtil.dateAndTimeAndSecondsString(localDateTime.toDateTime().getMillis()); + public static String toDateTimeString(DateUtil dateUtil, LocalDateTime localDateTime) { + return dateUtil.dateAndTimeAndSecondsString(localDateTime.toDateTime().getMillis()); //return localDateTime.toString("dd.MM.yyyy HH:mm:ss"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java index 4fe2815bdc..50a94b0ca9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java @@ -59,6 +59,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump protected RxBusWrapper rxBus; protected TreatmentsPlugin treatmentsPlugin; protected SP sp; + protected DateUtil dateUtil; protected AbstractDanaRPlugin( HasAndroidInjector injector, @@ -69,7 +70,8 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump CommandQueueProvider commandQueue, RxBusWrapper rxBus, TreatmentsPlugin treatmentsPlugin, - SP sp + SP sp, + DateUtil dateUtil ) { super(new PluginDescription() .mainType(PluginType.PUMP) @@ -85,6 +87,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump this.rxBus = rxBus; this.treatmentsPlugin = treatmentsPlugin; this.sp = sp; + this.dateUtil = dateUtil; } @Override @@ -349,19 +352,19 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump status.put("timestamp", DateUtil.toISOString(pump.getLastConnection())); extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); if (pump.getLastBolusTime() != 0) { - extended.put("LastBolus", DateUtil.dateAndTimeString(pump.getLastBolusTime())); + extended.put("LastBolus", dateUtil.dateAndTimeString(pump.getLastBolusTime())); extended.put("LastBolusAmount", pump.getLastBolusAmount()); } TemporaryBasal tb = treatmentsPlugin.getRealTempBasalFromHistory(now); if (tb != null) { extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)); - extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); + extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); } ExtendedBolus eb = treatmentsPlugin.getExtendedBolusFromHistory(now); if (eb != null) { extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); - extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); + extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes()); } extended.put("BaseBasalRate", getBaseBasalRate()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java index 95fdc80829..e1f06d4017 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java @@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.plugins.pump.danaR.services.DanaRExecutionService; import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; +import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.Round; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -58,9 +59,10 @@ public class DanaRPlugin extends AbstractDanaRPlugin { TreatmentsPlugin treatmentsPlugin, SP sp, CommandQueueProvider commandQueue, - DanaRPump danaRPump + DanaRPump danaRPump, + DateUtil dateUtil ) { - super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp); + super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp, dateUtil); this.aapsLogger = aapsLogger; this.context = context; this.resourceHelper = resourceHelper; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt index 288e10ef9d..18ffab8460 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt @@ -47,6 +47,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() { @Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin @Inject lateinit var danaRSPlugin: DanaRSPlugin @Inject lateinit var commandQueue: CommandQueueProvider + @Inject lateinit var dateUtil: DateUtil private val disposable = CompositeDisposable() @@ -143,7 +144,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() { override fun onBindViewHolder(holder: HistoryViewHolder, position: Int) { val record = historyList[position] - holder.time.text = DateUtil.dateAndTimeString(record.recordDate) + holder.time.text = dateUtil.dateAndTimeString(record.recordDate) holder.value.text = DecimalFormatter.to2Decimal(record.recordValue) holder.stringValue.text = record.stringRecordValue holder.bolusType.text = record.bolusType diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableR.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableR.kt index a81408b381..dd4c59cee4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableR.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableR.kt @@ -10,6 +10,7 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject @@ -27,7 +28,8 @@ class MessageHashTableR @Inject constructor( configBuilderPlugin: ConfigBuilderPlugin, commandQueue: CommandQueueProvider, activePlugin: ActivePluginProvider, - injector: HasAndroidInjector + injector: HasAndroidInjector, + dateUtil: DateUtil ) : MessageHashTableBase { var messages: HashMap = HashMap() @@ -39,11 +41,11 @@ class MessageHashTableR @Inject constructor( put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE - put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I + put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil)) // 0x0207 CMD_PUMP_EXPANS_INS_I put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS // 0x0301 CMD_PUMPINIT_TIME_INFO - put(MsgInitConnStatusTime(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) + put(MsgInitConnStatusTime(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, dateUtil)) put(MsgInitConnStatusBolus(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO put(MsgInitConnStatusBasic(aapsLogger, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO put(MsgInitConnStatusOption(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0304 CMD_PUMPINIT_OPTION @@ -55,15 +57,15 @@ class MessageHashTableR @Inject constructor( put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT - put(MsgHistoryBolus(aapsLogger, rxBus)) // 0x3101 CMD_HISTORY_MEAL_INS - put(MsgHistoryDailyInsulin(aapsLogger, rxBus)) // 0x3102 CMD_HISTORY_DAY_INS - put(MsgHistoryGlucose(aapsLogger, rxBus)) // 0x3104 CMD_HISTORY_GLUCOSE - put(MsgHistoryAlarm(aapsLogger, rxBus)) // 0x3105 CMD_HISTORY_ALARM - put(MsgHistoryError(aapsLogger, rxBus)) // 0x3106 CMD_HISTORY_ERROR - put(MsgHistoryCarbo(aapsLogger, rxBus)) // 0x3107 CMD_HISTORY_CARBOHY - put(MsgHistoryRefill(aapsLogger, rxBus)) // 0x3108 CMD_HISTORY_REFILL - put(MsgHistorySuspend(aapsLogger, rxBus)) // 0x3109 CMD_HISTORY_SUSPEND - put(MsgHistoryBasalHour(aapsLogger, rxBus)) // 0x310A CMD_HISTORY_BASAL_HOUR + put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS + put(MsgHistoryDailyInsulin(aapsLogger, rxBus, dateUtil)) // 0x3102 CMD_HISTORY_DAY_INS + put(MsgHistoryGlucose(aapsLogger, rxBus, dateUtil)) // 0x3104 CMD_HISTORY_GLUCOSE + put(MsgHistoryAlarm(aapsLogger, rxBus, dateUtil)) // 0x3105 CMD_HISTORY_ALARM + put(MsgHistoryError(aapsLogger, rxBus, dateUtil)) // 0x3106 CMD_HISTORY_ERROR + put(MsgHistoryCarbo(aapsLogger, rxBus, dateUtil)) // 0x3107 CMD_HISTORY_CARBOHY + put(MsgHistoryRefill(aapsLogger, rxBus, dateUtil)) // 0x3108 CMD_HISTORY_REFILL + put(MsgHistorySuspend(aapsLogger, rxBus, dateUtil)) // 0x3109 CMD_HISTORY_SUSPEND + put(MsgHistoryBasalHour(aapsLogger, rxBus, dateUtil)) // 0x310A CMD_HISTORY_BASAL_HOUR put(MsgHistoryDone(aapsLogger, danaRPump)) // 0x31F1 CMD_HISTORY_DONT_USED // 0x3202 CMD_SETTING_V_BASAL_INS_I put(MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin)) @@ -74,7 +76,7 @@ class MessageHashTableR @Inject constructor( put(MsgSettingBasalProfileAll(aapsLogger, danaRPump)) // 0x3206 CMD_SETTING_V_BASAL_PROFILE_ALL put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY - put(MsgSettingPumpTime(aapsLogger, danaRPump)) // 0x320A CMD_SETTING_V_TIME_I + put(MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)) // 0x320A CMD_SETTING_V_TIME_I put(MsgSettingUserOptions(aapsLogger, danaRPump)) // 0x320B CMD_SETTING_V_USER_OPTIONS put(MsgSettingActiveProfile(aapsLogger, danaRPump)) // 0x320C CMD_SETTING_V_PROFILE_NUMBER put(MsgSettingProfileRatiosAll(aapsLogger, danaRPump)) // 0x320D CMD_SETTING_V_CIR_CF_VALUE @@ -83,9 +85,9 @@ class MessageHashTableR @Inject constructor( put(MsgSetUserOptions(aapsLogger, danaRPump)) // 0x330B CMD_SETTING_USER_OPTIONS_S put(MsgSetActivateBasalProfile(aapsLogger, 0.toByte())) // 0x330C CMD_SETTING_PROFILE_NUMBER_S put(MsgHistoryAllDone(aapsLogger, danaRPump)) // 0x41F1 CMD_HISTORY_ALL_DONE - put(MsgHistoryAll(aapsLogger, rxBus)) // 0x41F2 CMD_HISTORY_ALL + put(MsgHistoryAll(aapsLogger, rxBus, dateUtil)) // 0x41F2 CMD_HISTORY_ALL put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE - put(MsgHistoryNew(aapsLogger, rxBus)) // 0x42F2 CMD_HISTORY_NEW + put(MsgHistoryNew(aapsLogger, rxBus, dateUtil)) // 0x42F2 CMD_HISTORY_NEW // 0xF0F1 CMD_PUMP_CHECK_VALUE put(MsgCheckValue(aapsLogger, danaRPump, danaRPlugin)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarm.kt index 142d0fea04..97c942fbf1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarm.kt @@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class MsgHistoryAlarm( aapsLogger: AAPSLogger, - rxBus: RxBusWrapper -) : MsgHistoryAll(aapsLogger, rxBus) { + rxBus: RxBusWrapper, + dateUtil: DateUtil +) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) { init { SetCommand(0x3105) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt index 8c50099756..8b953a15f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt @@ -10,7 +10,8 @@ import info.nightscout.androidaps.utils.DateUtil open class MsgHistoryAll( val aapsLogger: AAPSLogger, - val rxBus: RxBusWrapper + val rxBus: RxBusWrapper, + private val dateUtil: DateUtil ) : MessageBase() { init { @@ -138,6 +139,6 @@ open class MsgHistoryAll( 17.toByte() -> failed = true } MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord) - rxBus.send(EventDanaRSyncStatus(DateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType)) + rxBus.send(EventDanaRSyncStatus(dateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType)) } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHour.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHour.kt index 2f235f38d1..87bfbbc870 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHour.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHour.kt @@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class MsgHistoryBasalHour( aapsLogger: AAPSLogger, - rxBus: RxBusWrapper -) : MsgHistoryAll(aapsLogger, rxBus) { + rxBus: RxBusWrapper, + dateUtil: DateUtil +) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) { init { SetCommand(0x310A) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolus.kt index 26e1506eac..693d56d462 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolus.kt @@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class MsgHistoryBolus( aapsLogger: AAPSLogger, - rxBus: RxBusWrapper -) : MsgHistoryAll(aapsLogger, rxBus) { + rxBus: RxBusWrapper, + dateUtil: DateUtil +) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) { init { SetCommand(0x3101) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarbo.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarbo.kt index 8650e251a8..23e060d2a7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarbo.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarbo.kt @@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class MsgHistoryCarbo( aapsLogger: AAPSLogger, - rxBus: RxBusWrapper -) : MsgHistoryAll(aapsLogger, rxBus) { + rxBus: RxBusWrapper, + dateUtil: DateUtil +) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) { init { SetCommand(0x3107) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulin.kt index 60c1fffd14..5a978fc0ec 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulin.kt @@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class MsgHistoryDailyInsulin( aapsLogger: AAPSLogger, - rxBus: RxBusWrapper -) : MsgHistoryAll(aapsLogger, rxBus) { + rxBus: RxBusWrapper, + dateUtil: DateUtil +) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) { init { SetCommand(0x3102) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryError.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryError.kt index 50d6cb9051..8883a704a9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryError.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryError.kt @@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class MsgHistoryError( aapsLogger: AAPSLogger, - rxBus: RxBusWrapper -) : MsgHistoryAll(aapsLogger, rxBus) { + rxBus: RxBusWrapper, + dateUtil: DateUtil +) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) { init { SetCommand(0x3106) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucose.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucose.kt index 07e2354f18..4f717dded1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucose.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucose.kt @@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class MsgHistoryGlucose( aapsLogger: AAPSLogger, - rxBus: RxBusWrapper -) : MsgHistoryAll(aapsLogger, rxBus) { + rxBus: RxBusWrapper, + dateUtil: DateUtil +) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) { init { SetCommand(0x3104) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNew.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNew.kt index 0bf49cc612..b271f4f915 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNew.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNew.kt @@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class MsgHistoryNew( aapsLogger: AAPSLogger, - rxBus: RxBusWrapper -) : MsgHistoryAll(aapsLogger, rxBus) { + rxBus: RxBusWrapper, + dateUtil: DateUtil +) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) { init { SetCommand(0x42F2) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefill.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefill.kt index d77d0fbca7..24bb799db8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefill.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefill.kt @@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class MsgHistoryRefill( aapsLogger: AAPSLogger, - rxBus: RxBusWrapper -) : MsgHistoryAll(aapsLogger, rxBus) { + rxBus: RxBusWrapper, + dateUtil: DateUtil +) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) { init { SetCommand(0x3108) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspend.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspend.kt index d3f947f77d..bd116ed709 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspend.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspend.kt @@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class MsgHistorySuspend( aapsLogger: AAPSLogger, - rxBus: RxBusWrapper -) : MsgHistoryAll(aapsLogger, rxBus) { + rxBus: RxBusWrapper, + dateUtil: DateUtil +) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) { init { SetCommand(0x3109) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTime.kt index 1ff8eb0e9b..7d1ded9f8f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTime.kt @@ -24,7 +24,8 @@ class MsgInitConnStatusTime( private val danaRPlugin: DanaRPlugin, private val danaRKoreanPlugin: DanaRKoreanPlugin, private val configBuilderPlugin: ConfigBuilderPlugin, - private val commandQueue: CommandQueueProvider + private val commandQueue: CommandQueueProvider, + private val dateUtil: DateUtil ) : MessageBase() { init { @@ -54,7 +55,7 @@ class MsgInitConnStatusTime( } val time = dateTimeSecFromBuff(bytes, 0) val versionCode = intFromBuff(bytes, 6, 1) - aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + DateUtil.dateAndTimeString(time)) + aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + dateUtil.dateAndTimeString(time)) aapsLogger.debug(LTag.PUMPCOMM, "Version code: $versionCode") } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTime.kt index 70971c431e..0fcdcd5589 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTime.kt @@ -7,13 +7,14 @@ import java.util.* class MsgSetTime( private val aapsLogger: AAPSLogger, + private val dateUtil: DateUtil, time: Date ) : MessageBase() { init { SetCommand(0x330a) AddParamDateTime(time) - aapsLogger.debug(LTag.PUMPCOMM, "New message: time:" + DateUtil.dateAndTimeString(time)) + aapsLogger.debug(LTag.PUMPCOMM, "New message: time:" + dateUtil.dateAndTimeString(time)) } override fun handleMessage(bytes: ByteArray) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTime.kt index df356ca744..b8c9af91f4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTime.kt @@ -8,7 +8,8 @@ import java.util.* class MsgSettingPumpTime( private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump + private val danaRPump: DanaRPump, + private val dateUtil: DateUtil ) : MessageBase() { init { @@ -25,7 +26,7 @@ class MsgSettingPumpTime( intFromBuff(bytes, 1, 1), intFromBuff(bytes, 0, 1) ).time - aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + DateUtil.dateAndTimeString(time) + " Phone time: " + Date()) + aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + dateUtil.dateAndTimeString(time) + " Phone time: " + Date()) danaRPump.pumpTime = time } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtended.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtended.kt index 448b45346a..b7151d8add 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtended.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtended.kt @@ -14,7 +14,8 @@ class MsgStatusBolusExtended( private val injector: HasAndroidInjector, private val aapsLogger: AAPSLogger, private val danaRPump: DanaRPump, - private val activePlugin: ActivePluginProvider + private val activePlugin: ActivePluginProvider, + private val dateUtil: DateUtil ) : MessageBase() { init { @@ -48,7 +49,7 @@ class MsgStatusBolusExtended( aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus amount: $extendedBolusAmount") aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus so far in minutes: $extendedBolusSoFarInMinutes") aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus absolute rate: $extendedBolusAbsoluteRate") - aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus start: " + DateUtil.dateAndTimeString(extendedBolusStart)) + aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus start: " + dateUtil.dateAndTimeString(extendedBolusStart)) aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: $extendedBolusRemainingMinutes") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/AbstractDanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/AbstractDanaRExecutionService.java index a72d813199..b6b707381f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/AbstractDanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/AbstractDanaRExecutionService.java @@ -62,6 +62,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService { @Inject ResourceHelper resourceHelper; @Inject DanaRPump danaRPump; @Inject FabricPrivacy fabricPrivacy; + @Inject DateUtil dateUtil; private CompositeDisposable disposable = new CompositeDisposable(); @@ -228,31 +229,31 @@ public abstract class AbstractDanaRExecutionService extends DaggerService { MessageBase msg = null; switch (type) { case RecordTypes.RECORD_TYPE_ALARM: - msg = new MsgHistoryAlarm(aapsLogger, rxBus); + msg = new MsgHistoryAlarm(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_BASALHOUR: - msg = new MsgHistoryBasalHour(aapsLogger, rxBus); + msg = new MsgHistoryBasalHour(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_BOLUS: - msg = new MsgHistoryBolus(aapsLogger, rxBus); + msg = new MsgHistoryBolus(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_CARBO: - msg = new MsgHistoryCarbo(aapsLogger, rxBus); + msg = new MsgHistoryCarbo(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_DAILY: - msg = new MsgHistoryDailyInsulin(aapsLogger, rxBus); + msg = new MsgHistoryDailyInsulin(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_ERROR: - msg = new MsgHistoryError(aapsLogger, rxBus); + msg = new MsgHistoryError(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_GLUCOSE: - msg = new MsgHistoryGlucose(aapsLogger, rxBus); + msg = new MsgHistoryGlucose(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_REFILL: - msg = new MsgHistoryRefill(aapsLogger, rxBus); + msg = new MsgHistoryRefill(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_SUSPEND: - msg = new MsgHistorySuspend(aapsLogger, rxBus); + msg = new MsgHistorySuspend(aapsLogger, rxBus, dateUtil); break; } danaRPump.setHistoryDoneReceived(false); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java index 510ba70578..f027216839 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java @@ -14,18 +14,19 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.dialogs.BolusProgressDialog; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.CommandQueueProvider; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress; @@ -63,10 +64,8 @@ import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgStatusBolusExtended import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgStatusTempBasal; import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRNewStatus; import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin; -import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.commands.Command; -import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -143,7 +142,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump); MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump); MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector); - MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin); + MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil); MsgCheckValue checkValue = new MsgCheckValue(aapsLogger, danaRPump, danaRPlugin); if (danaRPump.isNewPump()) { @@ -187,7 +186,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingUserOptions(aapsLogger, danaRPump)); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))); - mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); + mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)); if (danaRPump.getPumpTime() == 0) { // initial handshake was not successfull // deinitialize pump @@ -200,8 +199,8 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { long timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 10) { - mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, new Date())); - mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); + mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, dateUtil, new Date())); + mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)); timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); } @@ -252,7 +251,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { if (!isConnected()) return false; rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus))); mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF))); - mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)); + mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; } @@ -261,7 +260,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { if (!isConnected()) return false; rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus))); mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger)); - mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)); + mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; } @@ -350,7 +349,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { t.insulin = danaRPump.getLastBolusAmount(); aapsLogger.debug(LTag.PUMP, "Used bolus amount from history: " + danaRPump.getLastBolusAmount()); } else { - aapsLogger.debug(LTag.PUMP, "Bolus amount in history too old: " + DateUtil.dateAndTimeString(danaRPump.getLastBolusTime())); + aapsLogger.debug(LTag.PUMP, "Bolus amount in history too old: " + dateUtil.dateAndTimeString(danaRPump.getLastBolusTime())); } synchronized (o) { o.notify(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java index 57d14c36b4..580e7c4ad3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java @@ -33,6 +33,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump; import info.nightscout.androidaps.plugins.pump.danaRKorean.services.DanaRKoreanExecutionService; import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; +import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.Round; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -60,10 +61,10 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { ConstraintChecker constraintChecker, TreatmentsPlugin treatmentsPlugin, SP sp, - CommandQueueProvider commandQueue - + CommandQueueProvider commandQueue, + DateUtil dateUtil ) { - super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp); + super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp, dateUtil); this.aapsLogger = aapsLogger; this.context = context; this.resourceHelper = resourceHelper; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKorean.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKorean.kt index 7c8f5ca33b..882ab11739 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKorean.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKorean.kt @@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaR.comm.* import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject @@ -28,6 +29,7 @@ class MessageHashTableRKorean @Inject constructor( configBuilderPlugin: ConfigBuilderPlugin, commandQueue: CommandQueueProvider, activePlugin: ActivePluginProvider, + dateUtil: DateUtil, injector: HasAndroidInjector ) : MessageHashTableBase { @@ -39,10 +41,10 @@ class MessageHashTableRKorean @Inject constructor( put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE - put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I + put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil)) // 0x0207 CMD_PUMP_EXPANS_INS_I put(MsgStatusBasic_k(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I put(MsgStatus_k(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS - put(MsgInitConnStatusTime_k(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) // 0x0301 CMD_PUMPINIT_TIME_INFO + put(MsgInitConnStatusTime_k(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, dateUtil)) // 0x0301 CMD_PUMPINIT_TIME_INFO put(MsgInitConnStatusBolus_k(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO put(MsgInitConnStatusBasic_k(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO put(MsgSetTempBasalStart(aapsLogger, 0, 0)) // 0x0401 CMD_PUMPSET_EXERCISE_S @@ -53,11 +55,11 @@ class MessageHashTableRKorean @Inject constructor( put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT - put(MsgHistoryBolus(aapsLogger, rxBus)) // 0x3101 CMD_HISTORY_MEAL_INS - put(MsgHistoryDailyInsulin(aapsLogger, rxBus)) // 0x3102 CMD_HISTORY_DAY_INS - put(MsgHistoryGlucose(aapsLogger, rxBus)) // 0x3104 CMD_HISTORY_GLUCOSE - put(MsgHistoryAlarm(aapsLogger, rxBus)) // 0x3105 CMD_HISTORY_ALARM - put(MsgHistoryCarbo(aapsLogger, rxBus)) // 0x3107 CMD_HISTORY_CARBOHY + put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS + put(MsgHistoryDailyInsulin(aapsLogger, rxBus, dateUtil)) // 0x3102 CMD_HISTORY_DAY_INS + put(MsgHistoryGlucose(aapsLogger, rxBus, dateUtil)) // 0x3104 CMD_HISTORY_GLUCOSE + put(MsgHistoryAlarm(aapsLogger, rxBus, dateUtil)) // 0x3105 CMD_HISTORY_ALARM + put(MsgHistoryCarbo(aapsLogger, rxBus, dateUtil)) // 0x3107 CMD_HISTORY_CARBOHY put(MsgSettingBasal_k(aapsLogger, danaRPump, danaRKoreanPlugin)) // 0x3202 CMD_SETTING_V_BASAL_INS_I put(MsgSettingMeal(aapsLogger, rxBus, resourceHelper, danaRPump, danaRKoreanPlugin)) // 0x3203 CMD_SETTING_V_MEAL_SETTING_I put(MsgSettingProfileRatios(aapsLogger, danaRPump)) // 0x3204 CMD_SETTING_V_CCC_I @@ -65,11 +67,11 @@ class MessageHashTableRKorean @Inject constructor( put(MsgSettingBasalProfileAll_k(aapsLogger, danaRPump)) // 0x3206 CMD_SETTING_V_BASAL_PROFILE_ALL put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY - put(MsgSettingPumpTime(aapsLogger, danaRPump)) // 0x320A CMD_SETTING_V_TIME_I + put(MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)) // 0x320A CMD_SETTING_V_TIME_I put(MsgSetSingleBasalProfile(aapsLogger, rxBus, resourceHelper, Array(24) { 0.0 })) // 0x3302 CMD_SETTING_BASAL_INS_S - put(MsgHistoryAll(aapsLogger, rxBus)) // 0x41F2 CMD_HISTORY_ALL + put(MsgHistoryAll(aapsLogger, rxBus, dateUtil)) // 0x41F2 CMD_HISTORY_ALL put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE - put(MsgHistoryNew(aapsLogger, rxBus)) // 0x42F2 CMD_HISTORY_NEW + put(MsgHistoryNew(aapsLogger, rxBus, dateUtil)) // 0x42F2 CMD_HISTORY_NEW put(MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin)) // 0xF0F1 CMD_PUMP_CHECK_VALUE } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgInitConnStatusTime_k.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgInitConnStatusTime_k.kt index 77402e0389..78575809a3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgInitConnStatusTime_k.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgInitConnStatusTime_k.kt @@ -25,7 +25,8 @@ class MsgInitConnStatusTime_k( private val danaRPlugin: DanaRPlugin, private val danaRKoreanPlugin: DanaRKoreanPlugin, private val configBuilderPlugin: ConfigBuilderPlugin, - private val commandQueue: CommandQueueProvider + private val commandQueue: CommandQueueProvider, + private val dateUtil: DateUtil ) : MessageBase() { init { @@ -55,7 +56,7 @@ class MsgInitConnStatusTime_k( val versionCode2 = intFromBuff(bytes, 7, 1) val versionCode3 = intFromBuff(bytes, 8, 1) val versionCode4 = intFromBuff(bytes, 9, 1) - aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + DateUtil.dateAndTimeString(time)) + aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + dateUtil.dateAndTimeString(time)) aapsLogger.debug(LTag.PUMPCOMM, "Version code1: $versionCode1") aapsLogger.debug(LTag.PUMPCOMM, "Version code2: $versionCode2") aapsLogger.debug(LTag.PUMPCOMM, "Version code3: $versionCode3") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java index 96de7ad78d..0a0b0ce4c7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java @@ -75,6 +75,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { @Inject MessageHashTableRKorean messageHashTableRKorean; @Inject ActivePluginProvider activePlugin; @Inject ProfileFunction profileFunction; + @Inject DateUtil dateUtil; public DanaRKoreanExecutionService() { } @@ -132,7 +133,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { //MsgStatus_k statusMsg = new MsgStatus_k(); MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k(aapsLogger, danaRPump); MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector); - MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin); + MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil); MsgCheckValue_k checkValue = new MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin); if (danaRPump.isNewPump()) { @@ -172,7 +173,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { mSerialIOThread.sendMessage(new MsgSettingGlucose(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingProfileRatios(aapsLogger, danaRPump)); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))); - mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); + mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)); if (danaRPump.getPumpTime() == 0) { // initial handshake was not successfull // deinitialize pump @@ -187,8 +188,8 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { if (Math.abs(timeDiff) > 10) { waitForWholeMinute(); // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cutted off anyway) - mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, new Date(DateUtil.now() + T.secs(10).msecs()))); - mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); + mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, dateUtil, new Date(DateUtil.now() + T.secs(10).msecs()))); + mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)); timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); } @@ -239,7 +240,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { if (!isConnected()) return false; rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus))); mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF))); - mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)); + mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; } @@ -248,7 +249,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { if (!isConnected()) return false; rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus))); mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger)); - mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)); + mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java index 8d5b8093b9..293faf8621 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java @@ -81,6 +81,7 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR private final CommandQueueProvider commandQueue; private final DanaRPump danaRPump; private final DetailedBolusInfoStorage detailedBolusInfoStorage; + private final DateUtil dateUtil; private static DanaRSService danaRSService; @@ -113,7 +114,8 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR SP sp, CommandQueueProvider commandQueue, DanaRPump danaRPump, - DetailedBolusInfoStorage detailedBolusInfoStorage + DetailedBolusInfoStorage detailedBolusInfoStorage, + DateUtil dateUtil ) { super(new PluginDescription() .mainType(PluginType.PUMP) @@ -134,6 +136,7 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR this.commandQueue = commandQueue; this.danaRPump = danaRPump; this.detailedBolusInfoStorage = detailedBolusInfoStorage; + this.dateUtil = dateUtil; pumpDescription.setPumpDescription(PumpType.DanaRS); } @@ -720,19 +723,19 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR status.put("timestamp", DateUtil.toISOString(pump.getLastConnection())); extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); if (pump.getLastBolusTime() != 0) { - extended.put("LastBolus", DateUtil.dateAndTimeString(pump.getLastBolusTime())); + extended.put("LastBolus", dateUtil.dateAndTimeString(pump.getLastBolusTime())); extended.put("LastBolusAmount", pump.getLastBolusAmount()); } TemporaryBasal tb = treatmentsPlugin.getTempBasalFromHistory(now); if (tb != null) { extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)); - extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); + extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); } ExtendedBolus eb = treatmentsPlugin.getExtendedBolusFromHistory(now); if (eb != null) { extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); - extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); + extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes()); } extended.put("BaseBasalRate", getBaseBasalRate()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt index 3e64372fc7..0a4c81314d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt @@ -49,7 +49,7 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_Basal_Set_Suspend_Off(aapsLogger)) put(DanaRS_Packet_Basal_Set_Suspend_On(aapsLogger)) put(DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger)) - put(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) + put(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil)) put(DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)) put(DanaRS_Packet_Bolus_Get_Initial_Bolus(aapsLogger)) put(DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump)) @@ -59,7 +59,7 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_Bolus_Get_Extended_Bolus(aapsLogger, danaRPump)) put(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) put(DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(aapsLogger, danaRPump)) - put(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)) + put(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump, dateUtil)) put(DanaRS_Packet_Bolus_Set_Bolus_Option(aapsLogger)) put(DanaRS_Packet_Bolus_Set_Initial_Bolus(aapsLogger)) put(DanaRS_Packet_Bolus_Set_CIR_CF_Array(aapsLogger)) @@ -77,33 +77,33 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRSPlugin)) put(DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRSPlugin)) put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(aapsLogger)) - put(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) + put(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump, dateUtil)) put(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) - put(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger)) + put(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, dateUtil)) put(DanaRS_Packet_Option_Set_User_Option(aapsLogger, danaRPump)) //put(new DanaRS_Packet_History_()); - put(DanaRS_Packet_History_Alarm(aapsLogger, rxBus)) - put(DanaRS_Packet_History_All_History(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Basal(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Bolus(aapsLogger, rxBus)) + put(DanaRS_Packet_History_Alarm(aapsLogger, rxBus, dateUtil)) + put(DanaRS_Packet_History_All_History(aapsLogger, rxBus, dateUtil)) + put(DanaRS_Packet_History_Basal(aapsLogger, rxBus, dateUtil)) + put(DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus, dateUtil)) + put(DanaRS_Packet_History_Bolus(aapsLogger, rxBus, dateUtil)) put(DanaRS_Packet_Review_Bolus_Avg(aapsLogger)) - put(DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Daily(aapsLogger, rxBus)) - put(DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump)) + put(DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus, dateUtil)) + put(DanaRS_Packet_History_Daily(aapsLogger, rxBus, dateUtil)) + put(DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump, dateUtil)) put(DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)) - put(DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)) + put(DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump, dateUtil)) put(DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump)) put(DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger)) - put(DanaRS_Packet_History_Prime(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Refill(aapsLogger, rxBus)) + put(DanaRS_Packet_History_Prime(aapsLogger, rxBus, dateUtil)) + put(DanaRS_Packet_History_Refill(aapsLogger, rxBus, dateUtil)) put(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger)) put(DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(aapsLogger)) - put(DanaRS_Packet_History_Suspend(aapsLogger, rxBus)) - put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus)) + put(DanaRS_Packet_History_Suspend(aapsLogger, rxBus, dateUtil)) + put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus, dateUtil)) // APS put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0)) put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, dateUtil, 0)) - put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, 0, 0, 0, 0)) + put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, dateUtil, 0, 0, 0, 0)) } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt index a3b57d12ef..cb26675222 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt @@ -52,7 +52,7 @@ open class DanaRS_Packet_APS_History_Events( hour = cal[Calendar.HOUR_OF_DAY] min = cal[Calendar.MINUTE] sec = cal[Calendar.SECOND] - aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(cal.timeInMillis)) + aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(cal.timeInMillis)) danaRSPlugin.apsHistoryDone = false } @@ -83,7 +83,7 @@ open class DanaRS_Packet_APS_History_Events( val status: String when (recordCode.toInt()) { DanaRPump.TEMPSTART -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min") temporaryBasal.percentRate = param1 temporaryBasal.durationInMinutes = param2 activePlugin.activeTreatments.addToHistoryTempBasal(temporaryBasal) @@ -91,13 +91,13 @@ open class DanaRS_Packet_APS_History_Events( } DanaRPump.TEMPSTOP -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime)) + aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime)) activePlugin.activeTreatments.addToHistoryTempBasal(temporaryBasal) status = "TEMPSTOP " + dateUtil.timeString(datetime) } DanaRPump.EXTENDEDSTART -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") extendedBolus.insulin = param1 / 100.0 extendedBolus.durationInMinutes = param2 activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) @@ -105,7 +105,7 @@ open class DanaRS_Packet_APS_History_Events( } DanaRPump.EXTENDEDSTOP -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) status = "EXTENDEDSTOP " + dateUtil.timeString(datetime) } @@ -118,7 +118,7 @@ open class DanaRS_Packet_APS_History_Events( detailedBolusInfo.pumpId = datetime detailedBolusInfo.insulin = param1 / 100.0 val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) - aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") status = "BOLUS " + dateUtil.timeString(datetime) } @@ -130,12 +130,12 @@ open class DanaRS_Packet_APS_History_Events( detailedBolusInfo.pumpId = datetime detailedBolusInfo.insulin = param1 / 100.0 val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) - aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") status = "DUALBOLUS " + dateUtil.timeString(datetime) } DanaRPump.DUALEXTENDEDSTART -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") extendedBolus.insulin = param1 / 100.0 extendedBolus.durationInMinutes = param2 activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) @@ -143,33 +143,33 @@ open class DanaRS_Packet_APS_History_Events( } DanaRPump.DUALEXTENDEDSTOP -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime) } DanaRPump.SUSPENDON -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDON (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDON (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") status = "SUSPENDON " + dateUtil.timeString(datetime) } DanaRPump.SUSPENDOFF -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") status = "SUSPENDOFF " + dateUtil.timeString(datetime) } DanaRPump.REFILL -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT REFILL (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT REFILL (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") status = "REFILL " + dateUtil.timeString(datetime) } DanaRPump.PRIME -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIME (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIME (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") status = "PRIME " + dateUtil.timeString(datetime) } DanaRPump.PROFILECHANGE -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h") status = "PROFILECHANGE " + dateUtil.timeString(datetime) } @@ -180,17 +180,17 @@ open class DanaRS_Packet_APS_History_Events( emptyCarbsInfo.source = Source.PUMP emptyCarbsInfo.pumpId = datetime val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(emptyCarbsInfo, false) - aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g") + aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g") status = "CARBS " + dateUtil.timeString(datetime) } DanaRPump.PRIMECANNULA -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIMECANNULA(" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") + aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIMECANNULA(" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") status = "PRIMECANNULA " + dateUtil.timeString(datetime) } else -> { - aapsLogger.debug(LTag.PUMPCOMM, "Event: " + recordCode + " " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) + aapsLogger.debug(LTag.PUMPCOMM, "Event: " + recordCode + " " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) status = "UNKNOWN " + dateUtil.timeString(datetime) } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt index 266554d3be..f513e6c7ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt @@ -9,6 +9,7 @@ import java.util.* class DanaRS_Packet_APS_Set_Event_History( private val aapsLogger: AAPSLogger, + private val dateUtil: DateUtil, private var packetType: Int, private var time: Long, private var param1: Int, @@ -18,7 +19,7 @@ class DanaRS_Packet_APS_Set_Event_History( init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY if ((packetType == DanaRPump.CARBS || packetType == DanaRPump.BOLUS) && param1 <= 0) this.param1 = 0 - aapsLogger.debug(LTag.PUMPCOMM, "Set history entry: " + DateUtil.dateAndTimeString(time) + " type: " + packetType + " param1: " + param1 + " param2: " + param2) + aapsLogger.debug(LTag.PUMPCOMM, "Set history entry: " + dateUtil.dateAndTimeString(time) + " type: " + packetType + " param1: " + param1 + " param2: " + param2) } override fun getRequestParams(): ByteArray { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt index fdc5c16480..7a2f523da8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt @@ -9,7 +9,8 @@ import kotlin.math.ceil class DanaRS_Packet_Basal_Get_Temporary_Basal_State( private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump + private val danaRPump: DanaRPump, + private val dateUtil: DateUtil ) : DanaRS_Packet() { init { @@ -35,7 +36,7 @@ class DanaRS_Packet_Basal_Get_Temporary_Basal_State( aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal percent: " + danaRPump.tempBasalPercent) aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal remaining min: $tempBasalRemainingMin") aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal total sec: " + danaRPump.tempBasalTotalSec) - aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal start: " + DateUtil.dateAndTimeString(tempBasalStart)) + aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal start: " + dateUtil.dateAndTimeString(tempBasalStart)) } override fun getFriendlyName(): String { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt index e6c8121506..a78bf0c525 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt @@ -9,7 +9,8 @@ import java.util.* class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump + private val danaRPump: DanaRPump, + private val dateUtil: DateUtil ) : DanaRS_Packet() { init { @@ -48,7 +49,7 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( aapsLogger.debug(LTag.PUMPCOMM, "Result: $error") aapsLogger.debug(LTag.PUMPCOMM, "BolusType: $bolusType") aapsLogger.debug(LTag.PUMPCOMM, "Initial bolus amount: " + danaRPump.initialBolusAmount + " U") - aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + DateUtil.dateAndTimeString(danaRPump.lastBolusTime)) + aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + dateUtil.dateAndTimeString(danaRPump.lastBolusTime)) aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount) aapsLogger.debug(LTag.PUMPCOMM, "Max bolus: " + danaRPump.maxBolus + " U") aapsLogger.debug(LTag.PUMPCOMM, "Bolus step: " + danaRPump.bolusStep + " U") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt index b8e7e6bb53..a9b1b2df62 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt @@ -9,7 +9,8 @@ import java.util.* class DanaRS_Packet_General_Get_More_Information( private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump + private val danaRPump: DanaRPump, + private val dateUtil: DateUtil ) : DanaRS_Packet() { init { @@ -52,7 +53,7 @@ class DanaRS_Packet_General_Get_More_Information( aapsLogger.debug(LTag.PUMPCOMM, "Daily total units: " + danaRPump.dailyTotalUnits.toString() + " U") aapsLogger.debug(LTag.PUMPCOMM, "Is extended in progress: " + danaRPump.isExtendedInProgress) aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: " + danaRPump.extendedBolusRemainingMinutes) - aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + DateUtil.dateAndTimeAndSecondsString(lastBolusTime.time)) + aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + dateUtil.dateAndTimeAndSecondsString(lastBolusTime.time)) aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt index 00ebd4118a..6a60ea523a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt @@ -8,7 +8,8 @@ import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_General_Get_Shipping_Information( private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump + private val danaRPump: DanaRPump, + private val dateUtil: DateUtil ) : DanaRS_Packet() { init { @@ -31,7 +32,7 @@ class DanaRS_Packet_General_Get_Shipping_Information( dataSize = 3 danaRPump.shippingCountry = asciiStringFromBuff(data, dataIndex, dataSize) aapsLogger.debug(LTag.PUMPCOMM, "Serial number: " + danaRPump.serialNumber) - aapsLogger.debug(LTag.PUMPCOMM, "Shipping date: " + DateUtil.dateAndTimeString(danaRPump.shippingDate)) + aapsLogger.debug(LTag.PUMPCOMM, "Shipping date: " + dateUtil.dateAndTimeString(danaRPump.shippingDate)) aapsLogger.debug(LTag.PUMPCOMM, "Shipping country: " + danaRPump.shippingCountry) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt index e8da961028..dd62bc2136 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt @@ -13,6 +13,7 @@ import java.util.* abstract class DanaRS_Packet_History_( protected val aapsLogger: AAPSLogger, protected val rxBus: RxBusWrapper, + protected val dateUtil: DateUtil, protected val from: Long ) : DanaRS_Packet() { @@ -36,7 +37,7 @@ abstract class DanaRS_Packet_History_( hour = cal[Calendar.HOUR_OF_DAY] min = cal[Calendar.MINUTE] sec = cal[Calendar.SECOND] - aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(cal.timeInMillis)) + aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(cal.timeInMillis)) } override fun getRequestParams(): ByteArray { @@ -85,7 +86,7 @@ abstract class DanaRS_Packet_History_( val historyCode = byteArrayToInt(getBytes(data, DATA_START + 7, 1)) val paramByte8 = historyCode.toByte() val value: Int = (data[DATA_START + 8].toInt() and 0xFF shl 8) + (data[DATA_START + 9].toInt() and 0xFF) - aapsLogger.debug(LTag.PUMPCOMM, "History packet: " + recordCode + " Date: " + DateUtil.dateAndTimeString(datetimewihtsec) + " Code: " + historyCode + " Value: " + value) + aapsLogger.debug(LTag.PUMPCOMM, "History packet: " + recordCode + " Date: " + dateUtil.dateAndTimeString(datetimewihtsec) + " Code: " + historyCode + " Value: " + value) val danaRHistoryRecord = DanaRHistoryRecord() danaRHistoryRecord.setBytes(data) // danaRHistoryRecord.recordCode is different from DanaR codes @@ -197,7 +198,7 @@ abstract class DanaRS_Packet_History_( } } MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord) - rxBus.send(EventDanaRSyncStatus(DateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType)) + rxBus.send(EventDanaRSyncStatus(dateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType)) } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt index 9b0c7ef4c6..360499cc21 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_Alarm @JvmOverloads constructor( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt index a8010b2127..8f6343604b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_All_History( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt index 0ac22574d5..e3268bcf1d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_Basal @JvmOverloads constructor( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt index 6ebbeaed53..7235137871 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_Blood_Glucose @JvmOverloads constructor( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt index 47996fc8c6..1d7950e8b3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_Bolus @JvmOverloads constructor( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt index 1084434962..03b84489cb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_Carbohydrate @JvmOverloads constructor( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt index 93e974728d..74f3894e79 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_Daily @JvmOverloads constructor( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt index 0306e6f129..9d283e905c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_Prime @JvmOverloads constructor( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt index 672c5e2cc4..637fb1be0d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_Refill @JvmOverloads constructor( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt index 9868cd10a4..3d35ec35dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_Suspend @JvmOverloads constructor( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt index b185748495..31258ea1b0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt @@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil class DanaRS_Packet_History_Temporary( aapsLogger: AAPSLogger, rxBus: RxBusWrapper, + dateUtil: DateUtil, from: Long = 0 -) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { +) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) { init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt index 2b18603d11..297804469c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt @@ -9,7 +9,8 @@ import java.util.* class DanaRS_Packet_Option_Get_Pump_Time( private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump + private val danaRPump: DanaRPump, + private val dateUtil: DateUtil ) : DanaRS_Packet() { init { @@ -39,7 +40,7 @@ class DanaRS_Packet_Option_Get_Pump_Time( val time = Date(100 + year, month - 1, day, hour, min, sec) danaRPump.pumpTime = time.time failed = year == month && month == day && day == hour && hour == min && min == sec && sec == 1 - aapsLogger.debug(LTag.PUMPCOMM, "Pump time " + DateUtil.dateAndTimeString(time)) + aapsLogger.debug(LTag.PUMPCOMM, "Pump time " + dateUtil.dateAndTimeString(time)) } override fun handleMessageNotReceived() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt index ec1a44c789..6739c50f57 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt @@ -8,6 +8,7 @@ import java.util.* class DanaRS_Packet_Option_Set_Pump_Time( private val aapsLogger: AAPSLogger, + private val dateUtil: DateUtil, private var time: Long = 0 ) : DanaRS_Packet() { @@ -15,7 +16,7 @@ class DanaRS_Packet_Option_Set_Pump_Time( init { opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_PUMP_TIME - aapsLogger.debug(LTag.PUMPCOMM, "Setting pump time " + DateUtil.dateAndTimeString(time)) + aapsLogger.debug(LTag.PUMPCOMM, "Setting pump time " + dateUtil.dateAndTimeString(time)) } override fun getRequestParams(): ByteArray { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java index 5122f012f8..359294ca00 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java @@ -167,9 +167,9 @@ public class DanaRSService extends DaggerService { rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingextendedbolusstatus))); bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))); - bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)); // last bolus, bolusStep, maxBolus + bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump, dateUtil)); // last bolus, bolusStep, maxBolus rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingtempbasalstatus))); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); + bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil)); danaRPump.setLastConnection(System.currentTimeMillis()); @@ -184,7 +184,7 @@ public class DanaRSService extends DaggerService { } rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))); - bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)); + bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump, dateUtil)); long timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; if (danaRPump.getPumpTime() == 0) { @@ -198,7 +198,7 @@ public class DanaRSService extends DaggerService { long now = System.currentTimeMillis(); if (danaRPump.getLastSettingsRead() + 60 * 60 * 1000L < now || !pump.isInitialized()) { rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))); - bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)); // serial no + bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump, dateUtil)); // serial no bleComm.sendMessage(new DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)); // firmware bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump)); bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)); // isExtendedEnabled @@ -228,13 +228,13 @@ public class DanaRSService extends DaggerService { return; } else { if (danaRPump.getProtocol() >= 6) { - bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now())); + bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, dateUtil, DateUtil.now())); } else { waitForWholeMinute(); // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cutted off anyway) - bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now() + T.secs(10).msecs())); + bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, dateUtil, DateUtil.now() + T.secs(10).msecs())); } - bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)); + bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump, dateUtil)); timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: " + timeDiff + " seconds"); } @@ -276,7 +276,7 @@ public class DanaRSService extends DaggerService { aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history"); } else { msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, dateUtil, lastHistoryFetched); - aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)); + aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(lastHistoryFetched)); } bleComm.sendMessage(msg); while (!danaRSPlugin.apsHistoryDone && bleComm.isConnected()) { @@ -315,7 +315,7 @@ public class DanaRSService extends DaggerService { if (carbs > 0) { // MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs); #### // bleComm.sendMessage(msg); - DanaRS_Packet_APS_Set_Event_History msgSetHistoryEntry_v2 = new DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, carbtime, carbs, 0); + DanaRS_Packet_APS_Set_Event_History msgSetHistoryEntry_v2 = new DanaRS_Packet_APS_Set_Event_History(aapsLogger, dateUtil, DanaRPump.CARBS, carbtime, carbs, 0); bleComm.sendMessage(msgSetHistoryEntry_v2); lastHistoryFetched = Math.min(lastHistoryFetched, carbtime - T.mins(1).msecs()); } @@ -370,7 +370,7 @@ public class DanaRSService extends DaggerService { public void run() { // reread bolus status rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))); - bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)); // last bolus + bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump, dateUtil)); // last bolus bolusingEvent.setPercent(100); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.disconnecting))); } @@ -403,7 +403,7 @@ public class DanaRSService extends DaggerService { rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger, percent, durationInHours)); SystemClock.sleep(200); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); + bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil)); loadEvents(); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; @@ -417,7 +417,7 @@ public class DanaRSService extends DaggerService { } rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); + bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil)); loadEvents(); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; @@ -436,7 +436,7 @@ public class DanaRSService extends DaggerService { } rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); + bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil)); loadEvents(); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; @@ -446,7 +446,7 @@ public class DanaRSService extends DaggerService { if (!isConnected()) return false; rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))); bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)); - bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); + bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil)); loadEvents(); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; @@ -493,31 +493,31 @@ public class DanaRSService extends DaggerService { DanaRS_Packet_History_ msg = null; switch (type) { case RecordTypes.RECORD_TYPE_ALARM: - msg = new DanaRS_Packet_History_Alarm(aapsLogger, rxBus); + msg = new DanaRS_Packet_History_Alarm(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_PRIME: - msg = new DanaRS_Packet_History_Prime(aapsLogger, rxBus); + msg = new DanaRS_Packet_History_Prime(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_BASALHOUR: - msg = new DanaRS_Packet_History_Basal(aapsLogger, rxBus); + msg = new DanaRS_Packet_History_Basal(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_BOLUS: - msg = new DanaRS_Packet_History_Bolus(aapsLogger, rxBus); + msg = new DanaRS_Packet_History_Bolus(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_CARBO: - msg = new DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus); + msg = new DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_DAILY: - msg = new DanaRS_Packet_History_Daily(aapsLogger, rxBus); + msg = new DanaRS_Packet_History_Daily(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_GLUCOSE: - msg = new DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus); + msg = new DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_REFILL: - msg = new DanaRS_Packet_History_Refill(aapsLogger, rxBus); + msg = new DanaRS_Packet_History_Refill(aapsLogger, rxBus, dateUtil); break; case RecordTypes.RECORD_TYPE_SUSPEND: - msg = new DanaRS_Packet_History_Suspend(aapsLogger, rxBus); + msg = new DanaRS_Packet_History_Suspend(aapsLogger, rxBus, dateUtil); break; } if (msg != null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java index 9a88ce28f3..72df8b9e68 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java @@ -66,9 +66,10 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { TreatmentsPlugin treatmentsPlugin, SP sp, CommandQueueProvider commandQueue, - DetailedBolusInfoStorage detailedBolusInfoStorage + DetailedBolusInfoStorage detailedBolusInfoStorage, + DateUtil dateUtil ) { - super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp); + super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp, dateUtil); this.aapsLogger = aapsLogger; this.context = context; this.resourceHelper = resourceHelper; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt index f02062e05b..8833ea6b3f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt @@ -47,11 +47,11 @@ class MessageHashTableRv2 @Inject constructor( put(MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, 0.0, 0)) // 0x0104 CMD_MEALINS_START_DATA_SPEED put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING - put(MsgStatusTempBasal_v2(aapsLogger, danaRPump)) // 0x0205 CMD_PUMP_EXERCISE_MODE + put(MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil)) // 0x0205 CMD_PUMP_EXERCISE_MODE put(MsgStatusBolusExtended_v2(aapsLogger, danaRPump)) // 0x0207 CMD_PUMP_EXPANS_INS_I put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS - put(MsgInitConnStatusTime(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) // 0x0301 CMD_PUMPINIT_TIME_INFO + put(MsgInitConnStatusTime(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, dateUtil)) // 0x0301 CMD_PUMPINIT_TIME_INFO put(MsgInitConnStatusBolus(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO put(MsgInitConnStatusBasic(aapsLogger, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO put(MsgInitConnStatusOption(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0304 CMD_PUMPINIT_OPTION @@ -63,15 +63,15 @@ class MessageHashTableRv2 @Inject constructor( put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT - put(MsgHistoryBolus(aapsLogger, rxBus)) // 0x3101 CMD_HISTORY_MEAL_INS - put(MsgHistoryDailyInsulin(aapsLogger, rxBus)) // 0x3102 CMD_HISTORY_DAY_INS - put(MsgHistoryGlucose(aapsLogger, rxBus)) // 0x3104 CMD_HISTORY_GLUCOSE - put(MsgHistoryAlarm(aapsLogger, rxBus)) // 0x3105 CMD_HISTORY_ALARM - put(MsgHistoryError(aapsLogger, rxBus)) // 0x3106 CMD_HISTORY_ERROR - put(MsgHistoryCarbo(aapsLogger, rxBus)) // 0x3107 CMD_HISTORY_CARBOHY - put(MsgHistoryRefill(aapsLogger, rxBus)) // 0x3108 CMD_HISTORY_REFILL - put(MsgHistorySuspend(aapsLogger, rxBus)) // 0x3109 CMD_HISTORY_SUSPEND - put(MsgHistoryBasalHour(aapsLogger, rxBus)) // 0x310A CMD_HISTORY_BASAL_HOUR + put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS + put(MsgHistoryDailyInsulin(aapsLogger, rxBus, dateUtil)) // 0x3102 CMD_HISTORY_DAY_INS + put(MsgHistoryGlucose(aapsLogger, rxBus, dateUtil)) // 0x3104 CMD_HISTORY_GLUCOSE + put(MsgHistoryAlarm(aapsLogger, rxBus, dateUtil)) // 0x3105 CMD_HISTORY_ALARM + put(MsgHistoryError(aapsLogger, rxBus, dateUtil)) // 0x3106 CMD_HISTORY_ERROR + put(MsgHistoryCarbo(aapsLogger, rxBus, dateUtil)) // 0x3107 CMD_HISTORY_CARBOHY + put(MsgHistoryRefill(aapsLogger, rxBus, dateUtil)) // 0x3108 CMD_HISTORY_REFILL + put(MsgHistorySuspend(aapsLogger, rxBus, dateUtil)) // 0x3109 CMD_HISTORY_SUSPEND + put(MsgHistoryBasalHour(aapsLogger, rxBus, dateUtil)) // 0x310A CMD_HISTORY_BASAL_HOUR put(MsgHistoryDone(aapsLogger, danaRPump)) // 0x31F1 CMD_HISTORY_DONT_USED put(MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin)) // 0x3202 CMD_SETTING_V_BASAL_INS_I put(MsgSettingMeal(aapsLogger, rxBus, resourceHelper, danaRPump, danaRKoreanPlugin)) // 0x3203 CMD_SETTING_V_MEAL_SETTING_I @@ -80,7 +80,7 @@ class MessageHashTableRv2 @Inject constructor( put(MsgSettingBasalProfileAll(aapsLogger, danaRPump)) // 0x3206 CMD_SETTING_V_BASAL_PROFILE_ALL put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY - put(MsgSettingPumpTime(aapsLogger, danaRPump)) // 0x320A CMD_SETTING_V_TIME_I + put(MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)) // 0x320A CMD_SETTING_V_TIME_I put(MsgSettingUserOptions(aapsLogger, danaRPump)) // 0x320B CMD_SETTING_V_USER_OPTIONS put(MsgSettingActiveProfile(aapsLogger, danaRPump)) // 0x320C CMD_SETTING_V_PROFILE_NUMBER put(MsgSettingProfileRatiosAll(aapsLogger, danaRPump)) // 0x320D CMD_SETTING_V_CIR_CF_VALUE @@ -89,9 +89,9 @@ class MessageHashTableRv2 @Inject constructor( put(MsgSetUserOptions(aapsLogger, danaRPump)) // 0x330B CMD_SETTING_USER_OPTIONS_S put(MsgSetActivateBasalProfile(aapsLogger, 0.toByte())) // 0x330C CMD_SETTING_PROFILE_NUMBER_S put(MsgHistoryAllDone(aapsLogger, danaRPump)) // 0x41F1 CMD_HISTORY_ALL_DONE - put(MsgHistoryAll(aapsLogger, rxBus)) // 0x41F2 CMD_HISTORY_ALL + put(MsgHistoryAll(aapsLogger, rxBus, dateUtil)) // 0x41F2 CMD_HISTORY_ALL put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE - put(MsgHistoryNew(aapsLogger, rxBus)) // 0x42F2 CMD_HISTORY_NEW + put(MsgHistoryNew(aapsLogger, rxBus, dateUtil)) // 0x42F2 CMD_HISTORY_NEW put(MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue)) // 0xF0F1 CMD_PUMP_CHECK_VALUE put(MsgStatusAPS_v2(aapsLogger, danaRPump)) // 0xE001 CMD_PUMPSTATUS_APS put(MsgSetAPSTempBasalStart_v2(aapsLogger, 0, false, false)) // 0xE002 CMD_PUMPSET_APSTEMP diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2.kt index 4f07a49ff9..7b11695910 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2.kt @@ -75,7 +75,7 @@ class MsgHistoryEvents_v2 constructor( val status: String when (recordCode.toInt()) { DanaRPump.TEMPSTART -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT TEMPSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT TEMPSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min") temporaryBasal.percentRate = param1 temporaryBasal.durationInMinutes = param2 treatmentsPlugin.addToHistoryTempBasal(temporaryBasal) @@ -83,13 +83,13 @@ class MsgHistoryEvents_v2 constructor( } DanaRPump.TEMPSTOP -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime)) + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime)) treatmentsPlugin.addToHistoryTempBasal(temporaryBasal) status = "TEMPSTOP " + dateUtil.timeString(datetime) } DanaRPump.EXTENDEDSTART -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT EXTENDEDSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT EXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") extendedBolus.insulin = param1 / 100.0 extendedBolus.durationInMinutes = param2 treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) @@ -97,7 +97,7 @@ class MsgHistoryEvents_v2 constructor( } DanaRPump.EXTENDEDSTOP -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) status = "EXTENDEDSTOP " + dateUtil.timeString(datetime) } @@ -110,7 +110,7 @@ class MsgHistoryEvents_v2 constructor( detailedBolusInfo.pumpId = datetime detailedBolusInfo.insulin = param1 / 100.0 val newRecord = treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false) - aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") status = "BOLUS " + dateUtil.timeString(datetime) } @@ -122,12 +122,12 @@ class MsgHistoryEvents_v2 constructor( detailedBolusInfo.pumpId = datetime detailedBolusInfo.insulin = param1 / 100.0 val newRecord = treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false) - aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") status = "DUALBOLUS " + dateUtil.timeString(datetime) } DanaRPump.DUALEXTENDEDSTART -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") extendedBolus.insulin = param1 / 100.0 extendedBolus.durationInMinutes = param2 treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) @@ -135,33 +135,33 @@ class MsgHistoryEvents_v2 constructor( } DanaRPump.DUALEXTENDEDSTOP -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime) } DanaRPump.SUSPENDON -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT SUSPENDON (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT SUSPENDON (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") status = "SUSPENDON " + dateUtil.timeString(datetime) } DanaRPump.SUSPENDOFF -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") status = "SUSPENDOFF " + dateUtil.timeString(datetime) } DanaRPump.REFILL -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT REFILL (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT REFILL (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") status = "REFILL " + dateUtil.timeString(datetime) } DanaRPump.PRIME -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT PRIME (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT PRIME (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") status = "PRIME " + dateUtil.timeString(datetime) } DanaRPump.PROFILECHANGE -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h") + aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h") status = "PROFILECHANGE " + dateUtil.timeString(datetime) } @@ -172,12 +172,12 @@ class MsgHistoryEvents_v2 constructor( emptyCarbsInfo.source = Source.PUMP emptyCarbsInfo.pumpId = datetime val newRecord = treatmentsPlugin.addToHistoryTreatment(emptyCarbsInfo, false) - aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g") + aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g") status = "CARBS " + dateUtil.timeString(datetime) } else -> { - aapsLogger.debug(LTag.PUMPBTCOMM, "Event: " + recordCode + " " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) + aapsLogger.debug(LTag.PUMPBTCOMM, "Event: " + recordCode + " " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) status = "UNKNOWN " + dateUtil.timeString(datetime) } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2.kt index ac21c3f533..e4668fcd2b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2.kt @@ -9,8 +9,8 @@ import kotlin.math.ceil class MsgStatusTempBasal_v2( private val aapsLogger: AAPSLogger, - private val danaRPump: DanaRPump - + private val danaRPump: DanaRPump, + private val dateUtil: DateUtil ) : MessageBase() { init { @@ -37,7 +37,7 @@ class MsgStatusTempBasal_v2( aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal percent: $tempBasalPercent") aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal remaining min: $tempBasalRemainingMin") aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal total sec: $tempBasalTotalSec") - aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal start: " + DateUtil.dateAndTimeString(tempBasalStart)) + aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal start: " + dateUtil.dateAndTimeString(tempBasalStart)) } private fun getDateFromTempBasalSecAgo(tempBasalAgoSecs: Int): Long { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java index ba2729c672..1433d3727f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java @@ -16,19 +16,20 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.activities.ErrorHelperActivity; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.dialogs.BolusProgressDialog; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.CommandQueueProvider; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress; @@ -72,7 +73,6 @@ import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgSetAPSTempBasalSt import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgSetHistoryEntry_v2; import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgStatusBolusExtended_v2; import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgStatusTempBasal_v2; -import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.commands.Command; @@ -159,7 +159,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus))); MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump); MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump); - MsgStatusTempBasal_v2 tempStatusMsg = new MsgStatusTempBasal_v2(aapsLogger, danaRPump); + MsgStatusTempBasal_v2 tempStatusMsg = new MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil); MsgStatusBolusExtended_v2 exStatusMsg = new MsgStatusBolusExtended_v2(aapsLogger, danaRPump); MsgCheckValue_v2 checkValue = new MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue); @@ -191,7 +191,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))); - mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); + mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)); if (danaRPump.getPumpTime() == 0) { // initial handshake was not successfull // deinitialize pump @@ -222,8 +222,8 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } else { waitForWholeMinute(); // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cutted off anyway) - mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, new Date(DateUtil.now() + T.secs(10).msecs()))); - mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); + mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, dateUtil, new Date(DateUtil.now() + T.secs(10).msecs()))); + mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)); timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); } @@ -274,7 +274,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); mSerialIOThread.sendMessage(new MsgSetTempBasalStart(aapsLogger, percent, durationInHours)); - mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump)); + mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil)); loadEvents(); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; @@ -289,7 +289,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(aapsLogger, percent, durationInMinutes == 15, durationInMinutes == 30)); - mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump)); + mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil)); loadEvents(); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; @@ -309,7 +309,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(aapsLogger, percent, durationInMinutes == 15, durationInMinutes == 30)); - mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump)); + mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil)); loadEvents(); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; @@ -319,7 +319,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { if (!isConnected()) return false; rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))); mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger)); - mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump)); + mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil)); loadEvents(); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); return true; @@ -450,7 +450,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { return new PumpEnactResult(injector).success(false); SystemClock.sleep(300); MsgHistoryEvents_v2 msg = new MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin, injector, dateUtil, lastHistoryFetched); - aapsLogger.debug(LTag.PUMP, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)); + aapsLogger.debug(LTag.PUMP, "Loading event history from: " + dateUtil.dateAndTimeString(lastHistoryFetched)); mSerialIOThread.sendMessage(msg); while (!danaRv2Plugin.eventsLoadingDone && mRfcommSocket.isConnected()) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index b147d01b10..d44470bad1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -150,6 +150,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, private final CommandQueueProvider commandQueue; private final ProfileFunction profileFunction; private final Context context; + private final DateUtil dateUtil; public static final String ALERT_CHANNEL_ID = "AndroidAPS-InsightAlert"; @@ -209,7 +210,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, CommandQueueProvider commandQueue, ProfileFunction profileFunction, Context context, - Config config + Config config, + DateUtil dateUtil ) { super(new PluginDescription() .pluginName(R.string.insight_local) @@ -229,6 +231,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, this.commandQueue = commandQueue; this.profileFunction = profileFunction; this.context = context; + this.dateUtil = dateUtil; pumpDescription = new PumpDescription(); pumpDescription.setPumpDescription(PumpType.AccuChekInsightBluetooth); @@ -996,13 +999,13 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, TemporaryBasal tb = treatmentsPlugin.getTempBasalFromHistory(now); if (tb != null) { extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)); - extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); + extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); } ExtendedBolus eb = treatmentsPlugin.getExtendedBolusFromHistory(now); if (eb != null) { extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); - extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); + extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes()); } extended.put("BaseBasalRate", getBaseBasalRate()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index 9d4b89675e..95a3f68c12 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -84,6 +84,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButt import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; +import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.TimeChangeType; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -136,7 +137,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter MedtronicPumpStatus medtronicPumpStatus, MedtronicHistoryData medtronicHistoryData, RileyLinkServiceData rileyLinkServiceData, - ServiceTaskExecutor serviceTaskExecutor + ServiceTaskExecutor serviceTaskExecutor, + DateUtil dateUtil ) { super(new PluginDescription() // @@ -147,7 +149,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter .preferencesId(R.xml.pref_medtronic) .description(R.string.description_pump_medtronic), // PumpType.Medtronic_522_722, // we default to most basic model, correct model from config is loaded later - injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy + injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy, dateUtil ); this.rileyLinkUtil = rileyLinkUtil; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/dialog/RileyLinkStatusDeviceMedtronic.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/dialog/RileyLinkStatusDeviceMedtronic.java index 2a7ffa2ce4..616f033799 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/dialog/RileyLinkStatusDeviceMedtronic.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/dialog/RileyLinkStatusDeviceMedtronic.java @@ -18,6 +18,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil; +import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; /** @@ -32,6 +33,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper; public class RileyLinkStatusDeviceMedtronic extends DaggerFragment implements RefreshableInterface { @Inject ResourceHelper resourceHelper; + @Inject DateUtil dateUtil; // @BindView(R.id.rileylink_history_list) ListView listView; @@ -153,7 +155,7 @@ public class RileyLinkStatusDeviceMedtronic extends DaggerFragment implements Re } RLHistoryItem item = historyItemList.get(i); - viewHolder.itemTime.setText(StringUtil.toDateTimeString(item.getDateTime())); + viewHolder.itemTime.setText(StringUtil.toDateTimeString(dateUtil, item.getDateTime())); viewHolder.itemSource.setText("Riley Link"); // for now viewHolder.itemDescription.setText(item.getDescription(resourceHelper)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 62adc49855..7f958a725c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -73,6 +73,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefres 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; import info.nightscout.androidaps.utils.TimeChangeType; @@ -136,7 +137,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump CommandQueueProvider commandQueue, FabricPrivacy fabricPrivacy, RileyLinkServiceData rileyLinkServiceData, - ServiceTaskExecutor serviceTaskExecutor) { + ServiceTaskExecutor serviceTaskExecutor, + DateUtil dateUtil + ) { super(new PluginDescription() // .mainType(PluginType.PUMP) // @@ -146,7 +149,7 @@ 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 + injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy, dateUtil ); this.rileyLinkServiceData = rileyLinkServiceData; this.serviceTaskExecutor = serviceTaskExecutor; @@ -232,8 +235,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump ActivePluginProvider activePlugin, info.nightscout.androidaps.utils.sharedPreferences.SP sp, CommandQueueProvider commandQueue, - FabricPrivacy fabricPrivacy) { - super(pluginDescription, pumpType, injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy); + FabricPrivacy fabricPrivacy, + DateUtil dateUtil + ) { + super(pluginDescription, pumpType, injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy, dateUtil); // this.rileyLinkUtil = rileyLinkUtil; // this.medtronicUtil = medtronicUtil; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java index 22bd4293fe..5664b1b539 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java @@ -36,6 +36,7 @@ public class PodSessionState extends PodState { @Inject AAPSLogger aapsLogger; @Inject SP sp; @Inject OmnipodUtil omnipodUtil; + @Inject DateUtil dateUtil; private final Map configuredAlerts; private transient PodStateChangedHandler stateChangedHandler; @@ -112,7 +113,7 @@ public class PodSessionState extends PodState { } public String getExpiryDateAsString() { - return expiresAt == null ? "???" : DateUtil.dateAndTimeString(expiresAt.toDate()); + return expiresAt == null ? "???" : dateUtil.dateAndTimeString(expiresAt.toDate()); } public FirmwareVersion getPiVersion() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt index 9dbaea4025..3db377a230 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt @@ -52,7 +52,8 @@ class VirtualPumpPlugin @Inject constructor( private val profileFunction: ProfileFunction, private val treatmentsPlugin: TreatmentsPlugin, commandQueue: CommandQueueProvider, - private val config: Config + private val config: Config, + private val dateUtil: DateUtil ) : PumpPluginBase(PluginDescription() .mainType(PluginType.PUMP) .fragmentClass(VirtualPumpFragment::class.java.name) @@ -356,13 +357,13 @@ class VirtualPumpPlugin @Inject constructor( val tb = treatmentsPlugin.getTempBasalFromHistory(now) if (tb != null) { extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)) - extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)) + extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date)) extended.put("TempBasalRemaining", tb.plannedRemainingMinutes) } val eb = treatmentsPlugin.getExtendedBolusFromHistory(now) if (eb != null) { extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()) - extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)) + extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date)) extended.put("ExtendedBolusRemaining", eb.plannedRemainingMinutes) } status.put("timestamp", DateUtil.toISOString(now)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java index 317a25bdf9..fc527bab94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java @@ -38,7 +38,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { private SP sp; private ProfileFunction profileFunction; - private ResourceHelper resourceHelper; + private DateUtil dateUtil; @Inject public SensitivityAAPSPlugin( @@ -46,7 +46,8 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { AAPSLogger aapsLogger, ResourceHelper resourceHelper, SP sp, - ProfileFunction profileFunction + ProfileFunction profileFunction, + DateUtil dateUtil ) { super(new PluginDescription() .mainType(PluginType.SENSITIVITY) @@ -58,6 +59,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { ); this.sp = sp; this.profileFunction = profileFunction; + this.dateUtil = dateUtil; } @NonNull @Override @@ -66,9 +68,9 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { String age = sp.getString(R.string.key_age, ""); int defaultHours = 24; - if (age.equals(resourceHelper.gs(R.string.key_adult))) defaultHours = 24; - if (age.equals(resourceHelper.gs(R.string.key_teenage))) defaultHours = 4; - if (age.equals(resourceHelper.gs(R.string.key_child))) defaultHours = 4; + if (age.equals(getResourceHelper().gs(R.string.key_adult))) defaultHours = 24; + if (age.equals(getResourceHelper().gs(R.string.key_teenage))) defaultHours = 4; + if (age.equals(getResourceHelper().gs(R.string.key_child))) defaultHours = 4; int hoursForDetection = sp.getInt(R.string.key_openapsama_autosens_period, defaultHours); Profile profile = profileFunction.getProfile(); @@ -85,7 +87,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already if (current == null) { - getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); + getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + dateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } @@ -116,7 +118,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { } // reset deviations after profile switch - if (ProfileSwitch.isEvent5minBack(getAapsLogger(), profileSwitches, autosensData.time, true)) { + if (new ProfileSwitch(getInjector()).isEvent5minBack(profileSwitches, autosensData.time, true)) { deviationsArray.clear(); pastSensitivity += "(PROFILESWITCH)"; } @@ -172,7 +174,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { sensResult, deviationsArray.size()); getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: " - + DateUtil.dateAndTimeString(toTime) + + + dateUtil.dateAndTimeString(toTime) + " ratio: " + output.ratio + " mealCOB: " + current.cob); getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: deviations " + Arrays.toString(deviations)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java index 97fb1a68bc..5740c7a5d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java @@ -35,7 +35,8 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; @Singleton public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { - private ProfileFunction profileFunction; + private final ProfileFunction profileFunction; + private final DateUtil dateUtil; @Inject public SensitivityOref1Plugin( @@ -43,7 +44,8 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { AAPSLogger aapsLogger, ResourceHelper resourceHelper, SP sp, - ProfileFunction profileFunction + ProfileFunction profileFunction, + DateUtil dateUtil ) { super(new PluginDescription() .mainType(PluginType.SENSITIVITY) @@ -56,6 +58,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { injector, aapsLogger, resourceHelper, sp ); this.profileFunction = profileFunction; + this.dateUtil = dateUtil; } @Override @@ -79,7 +82,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { // the current AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already if (current == null) { - getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); + getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + dateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } @@ -125,7 +128,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { } // reset deviations after profile switch - if (ProfileSwitch.isEvent5minBack(getAapsLogger(), profileSwitches, autosensData.time, true)) { + if (new ProfileSwitch(getInjector()).isEvent5minBack(profileSwitches, autosensData.time, true)) { deviationsArray.clear(); pastSensitivity += "(PROFILESWITCH)"; } @@ -241,7 +244,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { sensResultArray.get(key) + comparison, deviationsHour.get(key).size()); getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: " - + DateUtil.dateAndTimeString(toTime) + + + dateUtil.dateAndTimeString(toTime) + " ratio: " + output.ratio + " mealCOB: " + current.cob); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java index d2128791d8..27b1820735 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java @@ -32,7 +32,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin { private SP sp; - private ResourceHelper resourceHelper; + private DateUtil dateUtil; private ProfileFunction profileFunction; @Inject @@ -41,7 +41,8 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin AAPSLogger aapsLogger, ResourceHelper resourceHelper, SP sp, - ProfileFunction profileFunction + ProfileFunction profileFunction, + DateUtil dateUtil ) { super(new PluginDescription() .mainType(PluginType.SENSITIVITY) @@ -52,7 +53,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin injector, aapsLogger, resourceHelper, sp ); this.sp = sp; - this.resourceHelper = resourceHelper; + this.dateUtil = dateUtil; this.profileFunction = profileFunction; } @@ -62,9 +63,9 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin String age = sp.getString(R.string.key_age, ""); int defaultHours = 24; - if (age.equals(resourceHelper.gs(R.string.key_adult))) defaultHours = 24; - if (age.equals(resourceHelper.gs(R.string.key_teenage))) defaultHours = 4; - if (age.equals(resourceHelper.gs(R.string.key_child))) defaultHours = 4; + if (age.equals(getResourceHelper().gs(R.string.key_adult))) defaultHours = 24; + if (age.equals(getResourceHelper().gs(R.string.key_teenage))) defaultHours = 4; + if (age.equals(getResourceHelper().gs(R.string.key_child))) defaultHours = 4; int hoursForDetection = sp.getInt(R.string.key_openapsama_autosens_period, defaultHours); if (autosensDataTable == null || autosensDataTable.size() < 4) { @@ -74,7 +75,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already if (current == null) { - getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); + getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + dateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } @@ -117,7 +118,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin } // reset deviations after profile switch - if (ProfileSwitch.isEvent5minBack(getAapsLogger(), profileSwitches, autosensData.time, true)) { + if (new ProfileSwitch(getInjector()).isEvent5minBack(profileSwitches, autosensData.time, true)) { data.clear(); pastSensitivity += "(PROFILESWITCH)"; } @@ -145,10 +146,10 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin } if (data.size() == 0) { - getAapsLogger().debug(LTag.AUTOSENS, "Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime)); + getAapsLogger().debug(LTag.AUTOSENS, "Data size: " + data.size() + " fromTime: " + dateUtil.dateAndTimeString(fromTime) + " toTime: " + dateUtil.dateAndTimeString(toTime)); return new AutosensResult(); } else { - getAapsLogger().debug(LTag.AUTOSENS, "Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime)); + getAapsLogger().debug(LTag.AUTOSENS, "Data size: " + data.size() + " fromTime: " + dateUtil.dateAndTimeString(fromTime) + " toTime: " + dateUtil.dateAndTimeString(toTime)); } double weightedsum = 0; @@ -192,7 +193,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin sensResult, data.size()); getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: " - + DateUtil.dateAndTimeString(toTime) + + + dateUtil.dateAndTimeString(toTime) + " ratio: " + output.ratio + " mealCOB: " + current.cob); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt index 97b28f9dab..b01ba8d470 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt @@ -12,17 +12,16 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.db.BgReading -import info.nightscout.androidaps.db.DatabaseHelper import info.nightscout.androidaps.interfaces.DatabaseHelperInterface -import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.source.BGSourceFragment.RecyclerViewAdapter.BgReadingsViewHolder import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.T +import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.resources.ResourceHelper import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable @@ -34,6 +33,7 @@ class BGSourceFragment : DaggerFragment() { @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var dateUtil: DateUtil @Inject lateinit var databaseHelper: DatabaseHelperInterface private val disposable = CompositeDisposable() @@ -84,7 +84,7 @@ class BGSourceFragment : DaggerFragment() { val bgReading = bgReadings[position] holder.ns.visibility = if (NSUpload.isIdValid(bgReading._id)) View.VISIBLE else View.GONE holder.invalid.visibility = if (!bgReading.isValid) View.VISIBLE else View.GONE - holder.date.text = DateUtil.dateAndTimeString(bgReading.date) + holder.date.text = dateUtil.dateAndTimeString(bgReading.date) holder.value.text = bgReading.valueToUnitsToString(profileFunction.getUnits()) holder.direction.text = bgReading.directionToSymbol(databaseHelper) holder.remove.tag = bgReading @@ -106,7 +106,7 @@ class BGSourceFragment : DaggerFragment() { remove.setOnClickListener { v: View -> val bgReading = v.tag as BgReading activity?.let { activity -> - val text = DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profileFunction.getUnits()) + val text = dateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profileFunction.getUnits()) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { bgReading.isValid = false MainApp.getDbHelper().update(bgReading) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt index 91683b3f4f..6b0021fbcf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt @@ -28,7 +28,8 @@ class EversensePlugin @Inject constructor( injector: HasAndroidInjector, private val sp: SP, resourceHelper: ResourceHelper, - aapsLogger: AAPSLogger + aapsLogger: AAPSLogger, + private val dateUtil: DateUtil ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) @@ -50,7 +51,7 @@ class EversensePlugin @Inject constructor( if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress")) if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel")) if (bundle.containsKey("glucoseTrendDirection")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTrendDirection: " + bundle.getString("glucoseTrendDirection")) - if (bundle.containsKey("glucoseTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamp: " + DateUtil.dateAndTimeString(bundle.getLong("glucoseTimestamp"))) + if (bundle.containsKey("glucoseTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamp: " + dateUtil.dateAndTimeString(bundle.getLong("glucoseTimestamp"))) if (bundle.containsKey("batteryLevel")) aapsLogger.debug(LTag.BGSOURCE, "batteryLevel: " + bundle.getString("batteryLevel")) if (bundle.containsKey("signalStrength")) aapsLogger.debug(LTag.BGSOURCE, "signalStrength: " + bundle.getString("signalStrength")) if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber")) @@ -58,7 +59,7 @@ class EversensePlugin @Inject constructor( if (bundle.containsKey("transmitterModelNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterModelNumber: " + bundle.getString("transmitterModelNumber")) if (bundle.containsKey("transmitterSerialNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterSerialNumber: " + bundle.getString("transmitterSerialNumber")) if (bundle.containsKey("transmitterAddress")) aapsLogger.debug(LTag.BGSOURCE, "transmitterAddress: " + bundle.getString("transmitterAddress")) - if (bundle.containsKey("sensorInsertionTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "sensorInsertionTimestamp: " + DateUtil.dateAndTimeString(bundle.getLong("sensorInsertionTimestamp"))) + if (bundle.containsKey("sensorInsertionTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "sensorInsertionTimestamp: " + dateUtil.dateAndTimeString(bundle.getLong("sensorInsertionTimestamp"))) if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber")) if (bundle.containsKey("transmitterConnectionState")) aapsLogger.debug(LTag.BGSOURCE, "transmitterConnectionState: " + bundle.getString("transmitterConnectionState")) if (bundle.containsKey("glucoseLevels")) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt index aa498105a6..daf570edc2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt @@ -70,7 +70,7 @@ class NSClientSourcePlugin @Inject constructor( private fun storeSgv(sgvJson: JSONObject) { val nsSgv = NSSgv(sgvJson) - val bgReading = BgReading(nsSgv) + val bgReading = BgReading(injector, nsSgv) MainApp.getDbHelper().createIfNotExists(bgReading, "NS") detectSource(safeGetString(sgvJson, "device", "none"), safeGetLong(sgvJson, "mills")) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java index 698db2c81f..f83e522b30 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java @@ -76,6 +76,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface private final ProfileFunction profileFunction; private final ActivePluginProvider activePlugin; private final FabricPrivacy fabricPrivacy; + private final DateUtil dateUtil; private CompositeDisposable disposable = new CompositeDisposable(); @@ -100,7 +101,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface SP sp, ProfileFunction profileFunction, ActivePluginProvider activePlugin, - FabricPrivacy fabricPrivacy + FabricPrivacy fabricPrivacy, + DateUtil dateUtil ) { super(new PluginDescription() .mainType(PluginType.TREATMENT) @@ -119,6 +121,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface this.profileFunction = profileFunction; this.activePlugin = activePlugin; this.fabricPrivacy = fabricPrivacy; + this.dateUtil = dateUtil; } @Override @@ -339,7 +342,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface last = t.date; } } - getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: " + DateUtil.dateAndTimeString(last)); + getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: " + dateUtil.dateAndTimeString(last)); return last; } @@ -354,7 +357,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface last = t.date; } } - getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: " + DateUtil.dateAndTimeString(last)); + getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: " + dateUtil.dateAndTimeString(last)); return last; } @@ -643,7 +646,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface if (!allowUpdate && !creatOrUpdateResult.success) { getAapsLogger().error("Treatment could not be added to DB", new Exception()); - String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, DateUtil.dateAndTimeString(treatment.date)); + String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, dateUtil.dateAndTimeString(treatment.date)); Intent i = new Intent(context, ErrorHelperActivity.class); i.putExtra("soundid", R.raw.error); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt index 673f9bdc23..63574ea8d2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt @@ -42,6 +42,7 @@ class TreatmentsBolusFragment : DaggerFragment() { @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var treatmentsPlugin: TreatmentsPlugin @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -109,7 +110,7 @@ class TreatmentsBolusFragment : DaggerFragment() { override fun onBindViewHolder(holder: TreatmentsViewHolder, position: Int) { val profile = profileFunction.getProfile() ?: return val t = treatments[position] - holder.date.text = DateUtil.dateAndTimeString(t.date) + holder.date.text = dateUtil.dateAndTimeString(t.date) holder.insulin.text = resourceHelper.gs(R.string.formatinsulinunits, t.insulin) holder.carbs.text = resourceHelper.gs(R.string.format_carbs, t.carbs.toInt()) val iob = t.iobCalc(System.currentTimeMillis(), profile.dia) @@ -158,7 +159,7 @@ class TreatmentsBolusFragment : DaggerFragment() { val text = resourceHelper.gs(R.string.configbuilder_insulin) + ": " + resourceHelper.gs(R.string.formatinsulinunits, treatment.insulin) + "\n" + resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" + - resourceHelper.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(treatment.date) + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { if (treatment.source == Source.PUMP) { treatment.isValid = false diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt index d7a5e99496..9307238211 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt @@ -38,6 +38,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var translator: Translator + @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -106,7 +107,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { override fun onBindViewHolder(holder: CareportalEventsViewHolder, position: Int) { val careportalEvent = careportalEventList[position] holder.ns.visibility = if (NSUpload.isIdValid(careportalEvent._id)) View.VISIBLE else View.GONE - holder.date.text = DateUtil.dateAndTimeString(careportalEvent.date) + holder.date.text = dateUtil.dateAndTimeString(careportalEvent.date) holder.duration.text = if (careportalEvent.durationInMsec() == 0L) "" else DateUtil.niceTimeScalar(careportalEvent.durationInMsec(), resourceHelper) holder.note.text = careportalEvent.notes holder.type.text = translator.translate(careportalEvent.eventType) @@ -132,7 +133,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { activity?.let { activity -> val text = resourceHelper.gs(R.string.careportal_newnstreatment_eventtype) + ": " + translator.translate(careportalEvent.eventType) + "\n" + resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + careportalEvent.notes + "\n" + - resourceHelper.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(careportalEvent.date) + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(careportalEvent.date) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { if (NSUpload.isIdValid(careportalEvent._id)) NSUpload.removeCareportalEntryFromNS(careportalEvent._id) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt index 175fb81c97..d2dcd632ea 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt @@ -64,7 +64,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { holder.ph.visibility = if (extendedBolus.source == Source.PUMP) View.VISIBLE else View.GONE holder.ns.visibility = if (NSUpload.isIdValid(extendedBolus._id)) View.VISIBLE else View.GONE if (extendedBolus.isEndingEvent) { - holder.date.text = DateUtil.dateAndTimeString(extendedBolus.date) + holder.date.text = dateUtil.dateAndTimeString(extendedBolus.date) holder.duration.text = resourceHelper.gs(R.string.cancel) holder.insulin.text = "" holder.realDuration.text = "" @@ -73,8 +73,8 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { holder.ratio.text = "" } else { @SuppressLint("SetTextI18n") - if (extendedBolus.isInProgress) holder.date.text = DateUtil.dateAndTimeString(extendedBolus.date) - else holder.date.text = DateUtil.dateAndTimeString(extendedBolus.date) + " - " + dateUtil.timeString(extendedBolus.end()) + if (extendedBolus.isInProgress) holder.date.text = dateUtil.dateAndTimeString(extendedBolus.date) + else holder.date.text = dateUtil.dateAndTimeString(extendedBolus.date) + " - " + dateUtil.timeString(extendedBolus.end()) holder.duration.text = resourceHelper.gs(R.string.format_mins, extendedBolus.durationInMinutes) holder.insulin.text = resourceHelper.gs(R.string.formatinsulinunits, extendedBolus.insulin) @@ -113,7 +113,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { showConfirmation(it, resourceHelper.gs(R.string.removerecord), """ ${resourceHelper.gs(R.string.extended_bolus)} - ${resourceHelper.gs(R.string.date)}: ${DateUtil.dateAndTimeString(extendedBolus.date)} + ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)} """.trimIndent(), DialogInterface.OnClickListener { _: DialogInterface, _: Int -> val id = extendedBolus._id if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt index d45d547ef0..77934e304c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt @@ -43,6 +43,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { @Inject lateinit var localProfilePlugin: LocalProfilePlugin @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy + @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -95,7 +96,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { val profileSwitch = profileSwitchList[position] holder.ph.visibility = (profileSwitch.source == Source.PUMP).toVisibility() holder.ns.visibility = NSUpload.isIdValid(profileSwitch._id).toVisibility() - holder.date.text = DateUtil.dateAndTimeString(profileSwitch.date) + holder.date.text = dateUtil.dateAndTimeString(profileSwitch.date) if (!profileSwitch.isEndingEvent) { holder.duration.text = resourceHelper.gs(R.string.format_mins, profileSwitch.durationInMinutes) } else { @@ -132,7 +133,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName + - "\n" + resourceHelper.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(profileSwitch.date), Runnable { + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { val id = profileSwitch._id if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id) else UploadQueue.removeID("dbAdd", id) @@ -141,10 +142,10 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { } R.id.profileswitch_clone -> activity?.let { activity -> - OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + DateUtil.dateAndTimeString(profileSwitch.date), Runnable { + OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { profileSwitch.profileObject?.let { val nonCustomized = it.convertToNonCustomizedProfile() - localProfilePlugin.addProfile(LocalProfilePlugin.SingleProfile().copyFrom(localProfilePlugin.rawProfile, nonCustomized, profileSwitch.customizedName + " " + DateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_"))) + localProfilePlugin.addProfile(LocalProfilePlugin.SingleProfile().copyFrom(localProfilePlugin.rawProfile, nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_"))) rxBus.send(EventLocalProfileChanged()) } }) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java index 8e1e6fb663..7df7db72be 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java @@ -78,13 +78,13 @@ public class TreatmentsTempTargetFragment extends DaggerFragment { holder.ph.setVisibility(tempTarget.source == Source.PUMP ? View.VISIBLE : View.GONE); holder.ns.setVisibility(NSUpload.isIdValid(tempTarget._id) ? View.VISIBLE : View.GONE); if (!tempTarget.isEndingEvent()) { - holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date) + " - " + dateUtil.timeString(tempTarget.originalEnd())); + holder.date.setText(dateUtil.dateAndTimeString(tempTarget.date) + " - " + dateUtil.timeString(tempTarget.originalEnd())); holder.duration.setText(DecimalFormatter.to0Decimal(tempTarget.durationInMinutes) + " min"); holder.low.setText(tempTarget.lowValueToUnitsToString(units)); holder.high.setText(tempTarget.highValueToUnitsToString(units)); holder.reason.setText(tempTarget.reason); } else { - holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date)); + holder.date.setText(dateUtil.dateAndTimeString(tempTarget.date)); holder.duration.setText(R.string.cancel); holder.low.setText(""); holder.high.setText(""); @@ -142,7 +142,7 @@ public class TreatmentsTempTargetFragment extends DaggerFragment { final TempTarget tempTarget = (TempTarget) v.getTag(); OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.removerecord), resourceHelper.gs(R.string.careportal_temporarytarget) + ": " + tempTarget.friendlyDescription(profileFunction.getUnits(), resourceHelper) + - "\n" + DateUtil.dateAndTimeString(tempTarget.date), + "\n" + dateUtil.dateAndTimeString(tempTarget.date), (dialog, id) -> { final String _id = tempTarget._id; if (NSUpload.isIdValid(_id)) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt index 99764c73bf..4ff6b15950 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt @@ -44,6 +44,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -88,7 +89,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { holder.ph.visibility = if (tempBasal.source == Source.PUMP) View.VISIBLE else View.GONE holder.ns.visibility = if (NSUpload.isIdValid(tempBasal._id)) View.VISIBLE else View.GONE if (tempBasal.isEndingEvent) { - holder.date.text = DateUtil.dateAndTimeString(tempBasal.date) + holder.date.text = dateUtil.dateAndTimeString(tempBasal.date) holder.duration.text = resourceHelper.gs(R.string.cancel) holder.absolute.text = "" holder.percent.text = "" @@ -100,10 +101,10 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { holder.iob.setTextColor(holder.netRatio.currentTextColor) } else { if (tempBasal.isInProgress) { - holder.date.text = DateUtil.dateAndTimeString(tempBasal.date) + holder.date.text = dateUtil.dateAndTimeString(tempBasal.date) holder.date.setTextColor(resourceHelper.gc(R.color.colorActive)) } else { - holder.date.text = DateUtil.dateAndTimeRangeString(tempBasal.date, tempBasal.end()) + holder.date.text = dateUtil.dateAndTimeRangeString(tempBasal.date, tempBasal.end()) holder.date.setTextColor(holder.netRatio.currentTextColor) } holder.duration.text = resourceHelper.gs(R.string.format_mins, tempBasal.durationInMinutes) @@ -160,7 +161,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { showConfirmation(it, resourceHelper.gs(R.string.removerecord), """ ${resourceHelper.gs(R.string.pump_tempbasal_label)}: ${tempBasal.toStringFull()} - ${resourceHelper.gs(R.string.date)}: ${DateUtil.dateAndTimeString(tempBasal.date)} + ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)} """.trimIndent(), DialogInterface.OnClickListener { _: DialogInterface?, _: Int -> val id = tempBasal._id diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt index a52a23bd09..f18ae1db9f 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt @@ -17,6 +17,7 @@ class CommandSMBBolus( callback: Callback? ) : Command(injector, CommandType.SMB_BOLUS, callback) { + @Inject lateinit var dateUtil: DateUtil @Inject lateinit var activePlugin: ActivePluginProvider override fun execute() { @@ -29,7 +30,7 @@ class CommandSMBBolus( r = activePlugin.activePump.deliverTreatment(detailedBolusInfo) } else { r = PumpEnactResult(injector).enacted(false).success(false).comment("SMB request too old") - aapsLogger.debug(LTag.PUMPQUEUE, "SMB bolus canceled. deliverAt: " + DateUtil.dateAndTimeString(detailedBolusInfo.deliverAt)) + aapsLogger.debug(LTag.PUMPQUEUE, "SMB bolus canceled. deliverAt: " + dateUtil.dateAndTimeString(detailedBolusInfo.deliverAt)) } aapsLogger.debug(LTag.PUMPQUEUE, "Result success: ${r.success} enacted: ${r.enacted}") callback?.result(r)?.run() diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt index 4ca7055636..a3dda44325 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt @@ -39,6 +39,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var receiverStatusStore: ReceiverStatusStore @Inject lateinit var config: Config + @Inject lateinit var dateUtil: DateUtil companion object { private val KEEP_ALIVE_MILLISECONDS = T.mins(5).msecs() @@ -117,7 +118,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { val lastConnection = pump.lastDataTime() val isStatusOutdated = lastConnection + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis() val isBasalOutdated = abs(profile.basal - pump.baseBasalRate) > pump.pumpDescription.basalStep - aapsLogger.debug(LTag.CORE, "Last connection: " + DateUtil.dateAndTimeString(lastConnection)) + aapsLogger.debug(LTag.CORE, "Last connection: " + dateUtil.dateAndTimeString(lastConnection)) // sometimes keep alive broadcast stops // as as workaround test if readStatus was requested before an alarm is generated if (lastReadStatus != 0L && lastReadStatus > System.currentTimeMillis() - T.mins(5).msecs()) { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt b/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt index 77a269712f..eff444aa6e 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt @@ -30,7 +30,8 @@ class LocalAlertUtils @Inject constructor( private val activePlugin: ActivePluginProvider, private val profileFunction: ProfileFunction, private val iobCobCalculatorPlugin: IobCobCalculatorPlugin, - private val config: Config + private val config: Config, + private val dateUtil: DateUtil ) { fun missedReadingsThreshold(): Long { @@ -46,7 +47,7 @@ class LocalAlertUtils @Inject constructor( val nextAlarmOccurrenceReached = sp.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis() if (config.APS && sp.getBoolean(resourceHelper.gs(R.string.key_enable_pump_unreachable_alert), true) && isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !isDisconnected) { - aapsLogger.debug(LTag.CORE, "Generating pump unreachable alarm. lastConnection: " + DateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated) + aapsLogger.debug(LTag.CORE, "Generating pump unreachable alarm. lastConnection: " + dateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated) val n = Notification(Notification.PUMP_UNREACHABLE, resourceHelper.gs(R.string.pump_unreachable), Notification.URGENT) n.soundId = R.raw.alarm sp.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold()) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.java b/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.java index 38ef842f8d..0bfa1cbd0d 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.java @@ -23,6 +23,10 @@ import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; +import javax.inject.Inject; +import javax.inject.Singleton; + +import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; @@ -38,31 +42,42 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; * } * */ +@Singleton public class SntpClient { - private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.CORE); + private final AAPSLogger aapsLogger; + private final DateUtil dateUtil; + + //private final int REFERENCE_TIME_OFFSET = 16; + private final int ORIGINATE_TIME_OFFSET = 24; + private final int RECEIVE_TIME_OFFSET = 32; + private final int TRANSMIT_TIME_OFFSET = 40; + private final int NTP_PACKET_SIZE = 48; - //private static final int REFERENCE_TIME_OFFSET = 16; - private static final int ORIGINATE_TIME_OFFSET = 24; - private static final int RECEIVE_TIME_OFFSET = 32; - private static final int TRANSMIT_TIME_OFFSET = 40; - private static final int NTP_PACKET_SIZE = 48; + private final int NTP_PORT = 123; + private final int NTP_MODE_CLIENT = 3; + private final int NTP_VERSION = 3; - private static final int NTP_PORT = 123; - private static final int NTP_MODE_CLIENT = 3; - private static final int NTP_VERSION = 3; + @Inject + public SntpClient( + AAPSLogger aapsLogger, + DateUtil dateUtil + ) { + this.aapsLogger = aapsLogger; + this.dateUtil = dateUtil; + } // Number of seconds between Jan 1, 1900 and Jan 1, 1970 // 70 years plus 17 leap days - private static final long OFFSET_1900_TO_1970 = ((365L * 70L) + 17L) * 24L * 60L * 60L; + private final long OFFSET_1900_TO_1970 = ((365L * 70L) + 17L) * 24L * 60L * 60L; // system time computed from NTP server response - private static long mNtpTime; + private long mNtpTime; // value of SystemClock.elapsedRealtime() corresponding to mNtpTime - private static long mNtpTimeReference; + private long mNtpTimeReference; // round trip time in milliseconds - private static long mRoundTripTime; + private long mRoundTripTime; public static abstract class Callback implements Runnable { public boolean networkConnected = false; @@ -70,7 +85,7 @@ public class SntpClient { public long time = 0; } - public static synchronized void ntpTime(final Callback callback, boolean isConnected) { + public synchronized void ntpTime(final Callback callback, boolean isConnected) { callback.networkConnected = isConnected; if (callback.networkConnected) { new Thread(() -> doNtpTime(callback)).start(); @@ -79,11 +94,11 @@ public class SntpClient { } } - static void doNtpTime(final Callback callback) { - log.debug("Time detection started"); + void doNtpTime(final Callback callback) { + aapsLogger.debug("Time detection started"); callback.success = requestTime("time.google.com", 5000); callback.time = getNtpTime() + SystemClock.elapsedRealtime() - getNtpTimeReference(); - log.debug("Time detection ended: " + callback.success + " " + DateUtil.dateAndTimeString(getNtpTime())); + aapsLogger.debug("Time detection ended: " + callback.success + " " + dateUtil.dateAndTimeString(getNtpTime())); callback.run(); } @@ -94,7 +109,7 @@ public class SntpClient { * @param timeout network timeout in milliseconds. * @return true if the transaction was successful. */ - private static synchronized boolean requestTime(String host, int timeout) { + private synchronized boolean requestTime(String host, int timeout) { try { DatagramSocket socket = new DatagramSocket(); socket.setSoTimeout(timeout); @@ -144,7 +159,7 @@ public class SntpClient { mNtpTimeReference = responseTicks; mRoundTripTime = roundTripTime; } catch (Exception e) { - log.debug("request time failed: " + e); + aapsLogger.debug("request time failed: " + e); return false; } @@ -156,7 +171,7 @@ public class SntpClient { * * @return time value computed from NTP server response. */ - private static long getNtpTime() { + private long getNtpTime() { return mNtpTime; } @@ -166,7 +181,7 @@ public class SntpClient { * * @return reference clock corresponding to the NTP time. */ - private static long getNtpTimeReference() { + private long getNtpTimeReference() { return mNtpTimeReference; } @@ -182,7 +197,7 @@ public class SntpClient { /** * Reads an unsigned 32 bit big endian number from the given offset in the buffer. */ - private static long read32(byte[] buffer, int offset) { + private long read32(byte[] buffer, int offset) { byte b0 = buffer[offset]; byte b1 = buffer[offset + 1]; byte b2 = buffer[offset + 2]; @@ -201,7 +216,7 @@ public class SntpClient { * Reads the NTP time stamp at the given offset in the buffer and returns * it as a system time (milliseconds since January 1, 1970). */ - private static long readTimeStamp(byte[] buffer, int offset) { + private long readTimeStamp(byte[] buffer, int offset) { long seconds = read32(buffer, offset); long fraction = read32(buffer, offset + 4); return ((seconds - OFFSET_1900_TO_1970) * 1000) + ((fraction * 1000L) / 0x100000000L); @@ -211,7 +226,7 @@ public class SntpClient { * Writes system time (milliseconds since January 1, 1970) as an NTP time stamp * at the given offset in the buffer. */ - private static void writeTimeStamp(byte[] buffer, int offset, long time) { + private void writeTimeStamp(byte[] buffer, int offset, long time) { long seconds = time / 1000L; long milliseconds = time - seconds * 1000L; seconds += OFFSET_1900_TO_1970; diff --git a/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java b/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java index 892f9b2667..3386dd9235 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java @@ -29,6 +29,7 @@ import java.util.List; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; /** @@ -36,7 +37,8 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; */ public class TimeListEdit { - private static Logger log = StacktraceLoggerWrapper.getLogger(TimeListEdit.class); + private final AAPSLogger aapsLogger; + private final DateUtil dateUtil; private final int ONEHOURINSECONDS = 60 * 60; @@ -65,8 +67,14 @@ public class TimeListEdit { private int inflatedUntil = -1; - public TimeListEdit(Context context, View view, int resLayoutId, String tagPrefix, String label, JSONArray data1, JSONArray data2, double min, double max, double step, NumberFormat formatter, Runnable save) { + public TimeListEdit( + Context context, + AAPSLogger aapsLogger, + DateUtil dateUtil, + View view, int resLayoutId, String tagPrefix, String label, JSONArray data1, JSONArray data2, double min, double max, double step, NumberFormat formatter, Runnable save) { this.context = context; + this.aapsLogger = aapsLogger; + this.dateUtil = dateUtil; this.view = view; this.resLayoutId = resLayoutId; this.tagPrefix = tagPrefix; @@ -281,7 +289,7 @@ public class TimeListEdit { ArrayList timeListValues = new ArrayList<>(); int pos = 0; for (int t = previous + ONEHOURINSECONDS; t < next; t += ONEHOURINSECONDS) { - timeList.add(DateUtil.timeStringFromSeconds(t)); + timeList.add(dateUtil.timeStringFromSeconds(t)); timeListValues.add(t); if (secondsFromMidnight == t) posInList = pos; pos++; @@ -311,7 +319,7 @@ public class TimeListEdit { return time; } } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } return 0; } @@ -323,7 +331,7 @@ public class TimeListEdit { return item.getDouble("value"); } } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } return 0d; } @@ -336,7 +344,7 @@ public class TimeListEdit { return item.getDouble("value"); } } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } return 0d; @@ -362,7 +370,7 @@ public class TimeListEdit { data2.put(index, newObject2); } } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } @@ -383,7 +391,7 @@ public class TimeListEdit { // add new object editItem(index, timeAsSeconds, value1, value2); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } @@ -396,7 +404,7 @@ public class TimeListEdit { private void log() { for (int i = 0; i < data1.length(); i++) { - log.debug(i + ": @" + DateUtil.timeStringFromSeconds(secondFromMidnight(i)) + " " + value1(i) + (data2 != null ? " " + value2(i) : "")); + aapsLogger.debug(i + ": @" + dateUtil.timeStringFromSeconds(secondFromMidnight(i)) + " " + value1(i) + (data2 != null ? " " + value2(i) : "")); } } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt index 6d4895f1f3..6ee3024fc6 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt @@ -31,8 +31,9 @@ class TddCalculator @Inject constructor( val sp: SP, val activePlugin: ActivePluginProvider, val profileFunction: ProfileFunction, - fabricPrivacy: FabricPrivacy -) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, mainApp, sp, profileFunction, activePlugin, fabricPrivacy) { + fabricPrivacy: FabricPrivacy, + private val dateUtil: DateUtil +) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, mainApp, sp, profileFunction, activePlugin, fabricPrivacy, dateUtil) { init { service = TreatmentService(injector) // plugin is not started @@ -85,18 +86,18 @@ class TddCalculator @Inject constructor( return totalTdd } - fun stats(dateUtil: DateUtil): Spanned { + fun stats(): Spanned { val tdds = calculate(7) val averageTdd = averageTDD(tdds) return HtmlHelper.fromHtml( "" + resourceHelper.gs(R.string.tdd) + ":
" + - toText(tdds, dateUtil) + + toText(tdds) + "" + resourceHelper.gs(R.string.average) + ":
" + averageTdd.toText(resourceHelper, tdds.size()) ) } - private fun toText(tdds: LongSparseArray, dateUtil: DateUtil): String { + private fun toText(tdds: LongSparseArray): String { var t = "" for (i in 0 until tdds.size()) { t += "${tdds.valueAt(i).toText(resourceHelper, dateUtil)}
" diff --git a/app/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt b/app/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt index 188266fbb3..7542f104e7 100644 --- a/app/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt +++ b/app/src/test/java/info/nightscout/androidaps/TestBaseWithProfile.kt @@ -10,6 +10,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -26,6 +27,7 @@ open class TestBaseWithProfile : TestBase() { @Mock lateinit var fabricPrivacy: FabricPrivacy @Mock lateinit var profileFunction: ProfileFunction @Mock lateinit var defaultValueHelper: DefaultValueHelper + @Mock lateinit var dateUtil: DateUtil val rxBus = RxBusWrapper() @@ -37,12 +39,14 @@ open class TestBaseWithProfile : TestBase() { it.resourceHelper = resourceHelper it.rxBus = rxBus it.fabricPrivacy = fabricPrivacy + it.configInterface = Config() } if (it is ProfileSwitch) { it.treatmentsPlugin = treatmentsPlugin it.aapsLogger = aapsLogger it.rxBus = rxBus it.resourceHelper = resourceHelper + it.dateUtil = dateUtil } if (it is Treatment) { it.activePlugin = activePluginProvider diff --git a/app/src/test/java/info/nightscout/androidaps/db/BgReadingTest.kt b/app/src/test/java/info/nightscout/androidaps/db/BgReadingTest.kt index 7e37b24660..4b930d4947 100644 --- a/app/src/test/java/info/nightscout/androidaps/db/BgReadingTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/db/BgReadingTest.kt @@ -1,13 +1,16 @@ package info.nightscout.androidaps.db +import android.content.Context import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert @@ -31,6 +34,7 @@ class BgReadingTest : TestBase() { @Mock lateinit var defaultValueHelper: DefaultValueHelper @Mock lateinit var profileFunction: ProfileFunction @Mock lateinit var resourceHelper: ResourceHelper + @Mock lateinit var databaseHelper: DatabaseHelperInterface var injector: HasAndroidInjector = HasAndroidInjector { AndroidInjector { @@ -55,21 +59,21 @@ class BgReadingTest : TestBase() { fun directionToSymbol() { val bgReading = BgReading(injector) bgReading.direction = "DoubleDown" - Assert.assertEquals("\u21ca", bgReading.directionToSymbol()) + Assert.assertEquals("\u21ca", bgReading.directionToSymbol(databaseHelper)) bgReading.direction = "SingleDown" - Assert.assertEquals("\u2193", bgReading.directionToSymbol()) + Assert.assertEquals("\u2193", bgReading.directionToSymbol(databaseHelper)) bgReading.direction = "FortyFiveDown" - Assert.assertEquals("\u2198", bgReading.directionToSymbol()) + Assert.assertEquals("\u2198", bgReading.directionToSymbol(databaseHelper)) bgReading.direction = "Flat" - Assert.assertEquals("\u2192", bgReading.directionToSymbol()) + Assert.assertEquals("\u2192", bgReading.directionToSymbol(databaseHelper)) bgReading.direction = "FortyFiveUp" - Assert.assertEquals("\u2197", bgReading.directionToSymbol()) + Assert.assertEquals("\u2197", bgReading.directionToSymbol(databaseHelper)) bgReading.direction = "SingleUp" - Assert.assertEquals("\u2191", bgReading.directionToSymbol()) + Assert.assertEquals("\u2191", bgReading.directionToSymbol(databaseHelper)) bgReading.direction = "DoubleUp" - Assert.assertEquals("\u21c8", bgReading.directionToSymbol()) + Assert.assertEquals("\u21c8", bgReading.directionToSymbol(databaseHelper)) bgReading.direction = "OUT OF RANGE" - Assert.assertEquals("??", bgReading.directionToSymbol()) + Assert.assertEquals("??", bgReading.directionToSymbol(databaseHelper)) } @Test fun dateTest() { @@ -88,8 +92,8 @@ class BgReadingTest : TestBase() { } @Test fun copyFromTest() { - val databaseHelper = Mockito.mock(DatabaseHelper::class.java) - `when`(MainApp.getDbHelper()).thenReturn(databaseHelper) +// val databaseHelper = Mockito.mock(DatabaseHelper::class.java) +// `when`(MainApp.getDbHelper()).thenReturn(databaseHelper) setReadings(72, 0) val bgReading = BgReading(injector) val copy = BgReading(injector) @@ -100,7 +104,7 @@ class BgReadingTest : TestBase() { copy.copyFrom(bgReading) Assert.assertEquals(81.0, copy.value, 0.1) Assert.assertEquals(now, copy.date) - Assert.assertEquals(bgReading.directionToSymbol(), copy.directionToSymbol()) + Assert.assertEquals(bgReading.directionToSymbol(databaseHelper), copy.directionToSymbol(databaseHelper)) } @Test @@ -119,34 +123,28 @@ class BgReadingTest : TestBase() { @Test fun calculateDirection() { val bgReading = BgReading(injector) val bgReadingsList: List? = null - val databaseHelper = Mockito.mock(DatabaseHelper::class.java) - `when`(MainApp.getDbHelper()).thenReturn(databaseHelper) - `when`(MainApp.getDbHelper().getAllBgreadingsDataFromTime(ArgumentMatchers.anyLong(), ArgumentMatchers.anyBoolean())).thenReturn(bgReadingsList) - Assert.assertEquals("NONE", bgReading.calculateDirection()) +// val databaseHelper = Mockito.mock(DatabaseHelper::class.java) +// `when`(MainApp.getDbHelper()).thenReturn(databaseHelper) + `when`(databaseHelper.getAllBgreadingsDataFromTime(ArgumentMatchers.anyLong(), ArgumentMatchers.anyBoolean())).thenReturn(bgReadingsList) + Assert.assertEquals("NONE", bgReading.calculateDirection(databaseHelper)) setReadings(72, 0) - Assert.assertEquals("DoubleUp", bgReading.calculateDirection()) + Assert.assertEquals("DoubleUp", bgReading.calculateDirection(databaseHelper)) setReadings(76, 60) - Assert.assertEquals("SingleUp", bgReading.calculateDirection()) + Assert.assertEquals("SingleUp", bgReading.calculateDirection(databaseHelper)) setReadings(74, 65) - Assert.assertEquals("FortyFiveUp", bgReading.calculateDirection()) + Assert.assertEquals("FortyFiveUp", bgReading.calculateDirection(databaseHelper)) setReadings(72, 72) - Assert.assertEquals("Flat", bgReading.calculateDirection()) + Assert.assertEquals("Flat", bgReading.calculateDirection(databaseHelper)) setReadings(0, 72) - Assert.assertEquals("DoubleDown", bgReading.calculateDirection()) + Assert.assertEquals("DoubleDown", bgReading.calculateDirection(databaseHelper)) setReadings(60, 76) - Assert.assertEquals("SingleDown", bgReading.calculateDirection()) + Assert.assertEquals("SingleDown", bgReading.calculateDirection(databaseHelper)) setReadings(65, 74) - Assert.assertEquals("FortyFiveDown", bgReading.calculateDirection()) + Assert.assertEquals("FortyFiveDown", bgReading.calculateDirection(databaseHelper)) } @Before fun prepareMock() { - val mainApp = PowerMockito.mockStatic(MainApp::class.java) -// AAPSMocker.mockApplicationContext() -// AAPSMocker.mockSP() -// AAPSMocker.mockL() -// AAPSMocker.mockDatabaseHelper() -// `when`(mainApp.androidInjector()).thenReturn(injector.androidInjector()) } fun setReadings(current_value: Int, previous_value: Int) { @@ -159,6 +157,6 @@ class BgReadingTest : TestBase() { val bgReadings: MutableList = mutableListOf() bgReadings.add(now) bgReadings.add(previous) - `when`(MainApp.getDbHelper().getAllBgreadingsDataFromTime(ArgumentMatchers.anyLong(), ArgumentMatchers.anyBoolean())).thenReturn(bgReadings) + `when`(databaseHelper.getAllBgreadingsDataFromTime(ArgumentMatchers.anyLong(), ArgumentMatchers.anyBoolean())).thenReturn(bgReadings) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index fda1b15ae5..43451779f6 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.interfaces import android.content.Context import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.Config import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBaseWithProfile @@ -57,7 +58,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { @Mock lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin @Mock lateinit var profiler: Profiler - private var buildHelper = BuildHelper() + private var buildHelper = BuildHelper(Config()) lateinit var danaRPump: DanaRPump lateinit var constraintChecker: ConstraintChecker @@ -110,14 +111,14 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { danaRPump = DanaRPump(aapsLogger, sp, injector) hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context) - objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp) + objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config()) comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context) - danaRPlugin = DanaRPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, danaRPump) - danaRSPlugin = DanaRSPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage) - insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsPlugin, sp, commandQueue, profileFunction, context) + danaRPlugin = DanaRPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, danaRPump, dateUtil) + danaRSPlugin = DanaRSPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, dateUtil) + insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsPlugin, sp, commandQueue, profileFunction, context, Config(), dateUtil) openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits, profiler, fabricPrivacy) openAPSAMAPlugin = OpenAPSAMAPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits, profiler, fabricPrivacy) - safetyPlugin = SafetyPlugin(injector, aapsLogger, resourceHelper, sp, rxBus, constraintChecker, openAPSAMAPlugin, openAPSSMBPlugin, sensitivityOref1Plugin, activePlugin, hardLimits, buildHelper, treatmentsPlugin) + safetyPlugin = SafetyPlugin(injector, aapsLogger, resourceHelper, sp, rxBus, constraintChecker, openAPSAMAPlugin, openAPSSMBPlugin, sensitivityOref1Plugin, activePlugin, hardLimits, buildHelper, treatmentsPlugin, Config()) val constraintsPluginsList = ArrayList() constraintsPluginsList.add(safetyPlugin) constraintsPluginsList.add(objectivesPlugin) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt index b4dc882882..a0cd07823e 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt @@ -2,11 +2,11 @@ package info.nightscout.androidaps.plugins.constraints.objectives import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.Config import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.Constraint -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -38,7 +38,7 @@ class ObjectivesPluginTest : TestBase() { } @Before fun prepareMock() { - objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp) + objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config()) objectivesPlugin.onStart() `when`(resourceHelper.gs(R.string.objectivenotstarted)).thenReturn("Objective %1\$d not started") } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.kt index 3e36b8bca0..20474af664 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.constraints.safety import android.content.Context import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.Config import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBaseWithProfile @@ -73,7 +74,7 @@ class SafetyPluginTest : TestBaseWithProfile() { `when`(activePlugin.activePump).thenReturn(virtualPumpPlugin) `when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription) hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context) - safetyPlugin = SafetyPlugin(injector, aapsLogger, resourceHelper, sp, rxBus, constraintChecker, openAPSAMAPlugin, openAPSSMBPlugin, sensitivityOref1Plugin, activePlugin, hardLimits, buildHelper, treatmentsPlugin) + safetyPlugin = SafetyPlugin(injector, aapsLogger, resourceHelper, sp, rxBus, constraintChecker, openAPSAMAPlugin, openAPSSMBPlugin, sensitivityOref1Plugin, activePlugin, hardLimits, buildHelper, treatmentsPlugin, Config()) } @Test fun pumpDescriptionShouldLimitLoopInvocation() { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt index f172acb741..b628f6035a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt @@ -95,7 +95,7 @@ class TriggerBgTest : TriggerTestBase() { private fun generateOneCurrentRecordBgData(): List { val list: MutableList = ArrayList() - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":214,\"mills\":" + (now - 1) + ",\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":214,\"mills\":" + (now - 1) + ",\"direction\":\"Flat\"}")))) return list } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt index ebf0a57fc1..97c26dbcd0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt @@ -103,14 +103,14 @@ class TriggerDeltaTest : TriggerTestBase() { private fun generateValidBgData(): List { val list: MutableList = ArrayList() - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":214,\"mills\":1514766900000,\"direction\":\"Flat\"}")))) - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":216,\"mills\":1514766600000,\"direction\":\"Flat\"}")))) // +2 - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":219,\"mills\":1514766300000,\"direction\":\"Flat\"}")))) // +3 - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":223,\"mills\":1514766000000,\"direction\":\"Flat\"}")))) // +4 - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":222,\"mills\":1514765700000,\"direction\":\"Flat\"}")))) - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":224,\"mills\":1514765400000,\"direction\":\"Flat\"}")))) - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":226,\"mills\":1514765100000,\"direction\":\"Flat\"}")))) - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":228,\"mills\":1514764800000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":214,\"mills\":1514766900000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":216,\"mills\":1514766600000,\"direction\":\"Flat\"}")))) // +2 + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":219,\"mills\":1514766300000,\"direction\":\"Flat\"}")))) // +3 + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":223,\"mills\":1514766000000,\"direction\":\"Flat\"}")))) // +4 + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":222,\"mills\":1514765700000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":224,\"mills\":1514765400000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":226,\"mills\":1514765100000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":228,\"mills\":1514764800000,\"direction\":\"Flat\"}")))) return list } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt index 3cbaa271f2..2b35932914 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt @@ -4,6 +4,7 @@ import android.content.Context import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBaseWithProfile +import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin @@ -51,6 +52,15 @@ open class TriggerTestBase : TestBaseWithProfile() { if (it is TriggerBg) { it.profileFunction = profileFunction } + if (it is TriggerTime) { + it.dateUtil = dateUtil + } + if (it is TriggerTimeRange) { + it.dateUtil = dateUtil + } + if (it is TriggerRecurringTime) { + it.dateUtil = dateUtil + } if (it is TriggerBTDevice) { it.context = context it.automationPlugin = automationPlugin @@ -68,6 +78,9 @@ open class TriggerTestBase : TestBaseWithProfile() { if (it is StaticLabel) { it.resourceHelper = resourceHelper } + if (it is BgReading) { + it.dateUtil = dateUtil + } } } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePluginTest.kt index e66c001aee..26706da190 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePluginTest.kt @@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.general.maintenance import android.content.Context import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.Config import info.nightscout.androidaps.TestBase -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -32,7 +32,7 @@ class MaintenancePluginTest : TestBase() { @Before fun mock() { - sut = MaintenancePlugin(injector, context, resourceHelper, sp, nsSettingsStatus, aapsLogger, buildHelper) + sut = MaintenancePlugin(injector, context, resourceHelper, sp, nsSettingsStatus, aapsLogger, buildHelper, Config()) } @Test fun logfilesTest() { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index bf96b45765..1e4d27804d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.general.smsCommunicator +import android.content.Context import android.telephony.SmsManager import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.Config import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBaseWithProfile @@ -25,7 +27,10 @@ import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentService import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.CommandQueue -import info.nightscout.androidaps.utils.* +import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.T +import info.nightscout.androidaps.utils.XdripCalibrations import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Assert import org.junit.Before @@ -46,6 +51,7 @@ import java.util.* @PrepareForTest(ConstraintChecker::class, FabricPrivacy::class, VirtualPumpPlugin::class, XdripCalibrations::class, SmsManager::class, CommandQueue::class, LocalProfilePlugin::class, DateUtil::class, IobCobCalculatorPlugin::class, OneTimePassword::class) class SmsCommunicatorPluginTest : TestBaseWithProfile() { + @Mock lateinit var context: Context @Mock lateinit var sp: SP @Mock lateinit var constraintChecker: ConstraintChecker @Mock lateinit var activePlugin: ActivePluginProvider @@ -103,7 +109,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { `when`(SmsManager.getDefault()).thenReturn(smsManager) `when`(sp.getString(R.string.key_smscommunicator_allowednumbers, "")).thenReturn("1234;5678") - smsCommunicatorPlugin = SmsCommunicatorPlugin(injector, aapsLogger, resourceHelper, sp, constraintChecker, rxBus, profileFunction, fabricPrivacy, activePlugin, commandQueue, loopPlugin, iobCobCalculatorPlugin, xdripCalibrations, otp) + smsCommunicatorPlugin = SmsCommunicatorPlugin(injector, aapsLogger, resourceHelper, sp, constraintChecker, rxBus, profileFunction, fabricPrivacy, activePlugin, commandQueue, loopPlugin, iobCobCalculatorPlugin, xdripCalibrations, otp, Config(), DateUtil(context, resourceHelper)) smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true) Mockito.doAnswer { invocation: InvocationOnMock -> val callback = invocation.getArgument(1) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/GlucoseStatusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/GlucoseStatusTest.kt index d0a5f7ebeb..b7b421035b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/GlucoseStatusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/GlucoseStatusTest.kt @@ -30,6 +30,7 @@ import java.util.* @PrepareForTest(IobCobCalculatorPlugin::class, DateUtil::class) class GlucoseStatusTest : TestBase() { + @Mock lateinit var dateUtil: DateUtil @Mock lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin val injector = HasAndroidInjector { @@ -38,6 +39,9 @@ class GlucoseStatusTest : TestBase() { it.aapsLogger = aapsLogger it.iobCobCalculatorPlugin = iobCobCalculatorPlugin } + if (it is BgReading) { + it.dateUtil = dateUtil + } } } @@ -129,14 +133,14 @@ class GlucoseStatusTest : TestBase() { private fun generateValidBgData(): List { val list: MutableList = ArrayList() try { - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":214,\"mills\":1514766900000,\"direction\":\"Flat\"}")))) - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":216,\"mills\":1514766600000,\"direction\":\"Flat\"}")))) // +2 - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":219,\"mills\":1514766300000,\"direction\":\"Flat\"}")))) // +3 - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":223,\"mills\":1514766000000,\"direction\":\"Flat\"}")))) // +4 - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":222,\"mills\":1514765700000,\"direction\":\"Flat\"}")))) - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":224,\"mills\":1514765400000,\"direction\":\"Flat\"}")))) - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":226,\"mills\":1514765100000,\"direction\":\"Flat\"}")))) - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":228,\"mills\":1514764800000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":214,\"mills\":1514766900000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":216,\"mills\":1514766600000,\"direction\":\"Flat\"}")))) // +2 + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":219,\"mills\":1514766300000,\"direction\":\"Flat\"}")))) // +3 + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":223,\"mills\":1514766000000,\"direction\":\"Flat\"}")))) // +4 + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":222,\"mills\":1514765700000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":224,\"mills\":1514765400000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":226,\"mills\":1514765100000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":228,\"mills\":1514764800000,\"direction\":\"Flat\"}")))) } catch (e: JSONException) { throw RuntimeException(e) } @@ -146,9 +150,9 @@ class GlucoseStatusTest : TestBase() { private fun generateMostRecentBgData(): List { val list: MutableList = ArrayList() try { - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":214,\"mills\":1514766900000,\"direction\":\"Flat\"}")))) - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":216,\"mills\":1514766800000,\"direction\":\"Flat\"}")))) // +2 - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":216,\"mills\":1514766600000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":214,\"mills\":1514766900000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":216,\"mills\":1514766800000,\"direction\":\"Flat\"}")))) // +2 + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":216,\"mills\":1514766600000,\"direction\":\"Flat\"}")))) } catch (e: JSONException) { throw RuntimeException(e) } @@ -162,7 +166,7 @@ class GlucoseStatusTest : TestBase() { private fun generateOldBgData(): List { val list: MutableList = ArrayList() try { - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":228,\"mills\":1514764800000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":228,\"mills\":1514764800000,\"direction\":\"Flat\"}")))) } catch (e: JSONException) { throw RuntimeException(e) } @@ -172,7 +176,7 @@ class GlucoseStatusTest : TestBase() { private fun generateOneCurrentRecordBgData(): List { val list: MutableList = ArrayList() try { - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":214,\"mills\":1514766900000,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":214,\"mills\":1514766900000,\"direction\":\"Flat\"}")))) } catch (e: JSONException) { throw RuntimeException(e) } @@ -185,15 +189,15 @@ class GlucoseStatusTest : TestBase() { val endTime = 1514766900000L val latestReading = 100.0 // Now - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":$latestReading,\"mills\":$endTime,\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":$latestReading,\"mills\":$endTime,\"direction\":\"Flat\"}")))) // One minute ago - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":" + latestReading + ",\"mills\":" + (endTime - 1000 * 60 * 1) + ",\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":" + latestReading + ",\"mills\":" + (endTime - 1000 * 60 * 1) + ",\"direction\":\"Flat\"}")))) // Two minutes ago - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":" + latestReading + ",\"mills\":" + (endTime - 1000 * 60 * 2) + ",\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":" + latestReading + ",\"mills\":" + (endTime - 1000 * 60 * 2) + ",\"direction\":\"Flat\"}")))) // Three minutes and beyond at constant rate for (i in 3..49) { - list.add(BgReading(NSSgv(JSONObject("{\"mgdl\":" + (latestReading + i * 2) + ",\"mills\":" + (endTime - 1000 * 60 * i) + ",\"direction\":\"Flat\"}")))) + list.add(BgReading(injector, NSSgv(JSONObject("{\"mgdl\":" + (latestReading + i * 2) + ",\"mills\":" + (endTime - 1000 * 60 * i) + ",\"direction\":\"Flat\"}")))) } } catch (e: JSONException) { throw RuntimeException(e) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt index 595c8215d7..a34d8b5022 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt @@ -42,6 +42,7 @@ class IobCobCalculatorPluginTest : TestBase() { @Mock lateinit var sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin @Mock lateinit var defaultValueHelper: DefaultValueHelper @Mock lateinit var fabricPrivacy: FabricPrivacy + @Mock lateinit var dateUtil: DateUtil lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin @@ -52,13 +53,14 @@ class IobCobCalculatorPluginTest : TestBase() { it.defaultValueHelper = defaultValueHelper it.resourceHelper = resourceHelper it.profileFunction = profileFunction + it.dateUtil = dateUtil } } } @Before fun mock() { - iobCobCalculatorPlugin = IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction, activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy) + iobCobCalculatorPlugin = IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction, activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil) } @Test diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt index d3f14725af..0880445d72 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt @@ -44,7 +44,7 @@ class DanaRPluginTest : TestBaseWithProfile() { `when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s") `when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") danaRPump = DanaRPump(aapsLogger, sp, injector) - danaRPlugin = DanaRPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, danaRPump) + danaRPlugin = DanaRPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, danaRPump, dateUtil) } @Test @Throws(Exception::class) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt index 8392d74120..e2d094de22 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt @@ -7,6 +7,7 @@ import info.nightscout.androidaps.db.TemporaryBasal import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Before import org.mockito.Mock @@ -16,6 +17,7 @@ open class DanaRTestBase : TestBase() { @Mock lateinit var sp: SP @Mock lateinit var profileFunction: ProfileFunction @Mock lateinit var activePluginProvider: ActivePluginProvider + @Mock lateinit var dateUtil: DateUtil val injector = HasAndroidInjector { AndroidInjector { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableRTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableRTest.kt index d8a2d12b20..efd97bea09 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableRTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableRTest.kt @@ -36,7 +36,7 @@ class MessageHashTableRTest : DanaRTestBase() { @Test fun runTest() { Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) - val messageHashTable = MessageHashTableR(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, activePlugin, injector) + val messageHashTable = MessageHashTableR(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, activePlugin, injector, dateUtil) val testMessage = messageHashTable.findMessage(0x41f2) Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName) } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarmTest.kt index afb5e6ec6c..e70a9bfe9a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAlarmTest.kt @@ -11,7 +11,7 @@ class MsgHistoryAlarmTest : DanaRTestBase() { val rxBus = RxBusWrapper() @Test fun runTest() { - val packet = MsgHistoryAlarm(aapsLogger, rxBus) + val packet = MsgHistoryAlarm(aapsLogger, rxBus, dateUtil) // nothing left to test } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAllTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAllTest.kt index 47401ff67b..694a523a67 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAllTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAllTest.kt @@ -18,7 +18,7 @@ class MsgHistoryAllTest : DanaRTestBase() { @Test fun runTest() { PowerMockito.mockStatic(MainApp::class.java) `when`(MainApp.getDbHelper()).thenReturn(PowerMockito.mock(DatabaseHelper::class.java)) - val packet = MsgHistoryAll(aapsLogger, RxBusWrapper()) + val packet = MsgHistoryAll(aapsLogger, RxBusWrapper(), dateUtil) // test message decoding val array = ByteArray(100) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHourTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHourTest.kt index dd7d81502a..4240454bb9 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHourTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBasalHourTest.kt @@ -9,7 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner class MsgHistoryBasalHourTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgHistoryBasalHour(aapsLogger, RxBusWrapper()) + val packet = MsgHistoryBasalHour(aapsLogger, RxBusWrapper(), dateUtil) // nothing left to test } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolusTest.kt index 5edd07ed2e..f93be7d72e 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryBolusTest.kt @@ -9,7 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner class MsgHistoryBolusTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgHistoryBolus(aapsLogger, RxBusWrapper()) + val packet = MsgHistoryBolus(aapsLogger, RxBusWrapper(), dateUtil) // nothing left to test } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarboTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarboTest.kt index 225ea67259..e30cf23e14 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarboTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryCarboTest.kt @@ -9,7 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner class MsgHistoryCarboTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgHistoryCarbo(aapsLogger, RxBusWrapper()) + val packet = MsgHistoryCarbo(aapsLogger, RxBusWrapper(), dateUtil) // nothing left to test } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt index b6ef8be268..9c52a30bde 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryDailyInsulinTest.kt @@ -9,7 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner class MsgHistoryDailyInsulinTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgHistoryDailyInsulin(aapsLogger, RxBusWrapper()) + val packet = MsgHistoryDailyInsulin(aapsLogger, RxBusWrapper(), dateUtil) // nothing left to test } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryErrorTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryErrorTest.kt index 756139c88b..e32d657577 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryErrorTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryErrorTest.kt @@ -9,7 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner class MsgHistoryErrorTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgHistoryError(aapsLogger, RxBusWrapper()) + val packet = MsgHistoryError(aapsLogger, RxBusWrapper(), dateUtil) // nothing left to test } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucoseTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucoseTest.kt index e460432652..1e01007392 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucoseTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryGlucoseTest.kt @@ -9,7 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner class MsgHistoryGlucoseTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgHistoryGlucose(aapsLogger, RxBusWrapper()) + val packet = MsgHistoryGlucose(aapsLogger, RxBusWrapper(), dateUtil) // nothing left to test } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNewTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNewTest.kt index 52d000d56d..9cf8f16263 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNewTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryNewTest.kt @@ -9,7 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner class MsgHistoryNewTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgHistoryNew(aapsLogger, RxBusWrapper()) + val packet = MsgHistoryNew(aapsLogger, RxBusWrapper(), dateUtil) // nothing left to test } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefillTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefillTest.kt index 1a2014cb2b..1cfbee9c64 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefillTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryRefillTest.kt @@ -9,7 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner class MsgHistoryRefillTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgHistoryRefill(aapsLogger, RxBusWrapper()) + val packet = MsgHistoryRefill(aapsLogger, RxBusWrapper(), dateUtil) // nothing left to test } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspendTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspendTest.kt index 5863a7596c..d9b6576cda 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspendTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistorySuspendTest.kt @@ -9,7 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner class MsgHistorySuspendTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgHistorySuspend(aapsLogger, RxBusWrapper()) + val packet = MsgHistorySuspend(aapsLogger, RxBusWrapper(), dateUtil) // nothing left to test } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.kt index c314b5d882..678842b9ae 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.kt @@ -24,7 +24,7 @@ class MsgInitConnStatusTimeTest : DanaRTestBase() { @Mock lateinit var commandQueue: CommandQueueProvider @Test fun runTest() { - val packet = MsgInitConnStatusTime(aapsLogger, RxBusWrapper(), resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue) + val packet = MsgInitConnStatusTime(aapsLogger, RxBusWrapper(), resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, dateUtil) // test message decoding packet.handleMessage(createArray(20, 1.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTimeTest.kt index 067d368591..1b5ed6e857 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTimeTest.kt @@ -10,7 +10,7 @@ import java.util.* class MsgSetTimeTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgSetTime(aapsLogger, Date(System.currentTimeMillis())) + val packet = MsgSetTime(aapsLogger, dateUtil, Date(System.currentTimeMillis())) // test message decoding packet.handleMessage(createArray(34, 7.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt index 7a40b86a07..28b69b98ef 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt @@ -11,7 +11,7 @@ import java.util.* class MsgSettingPumpTimeTest : DanaRTestBase() { @Test fun runTest() { - val packet = MsgSettingPumpTime(aapsLogger, danaRPump) + val packet = MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil) danaRPump.units = DanaRPump.UNITS_MGDL // test message decoding val bytes = createArray(34, 7.toByte()) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtendedTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtendedTest.kt index 67403dfcd3..74bf318496 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtendedTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtendedTest.kt @@ -18,7 +18,7 @@ class MsgStatusBolusExtendedTest : DanaRTestBase() { @Test fun runTest() { `when`(activePlugin.activeTreatments).thenReturn(treatmentsPlugin) - val packet = MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin) + val packet = MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil) // test message decoding val array = ByteArray(100) putByteToArray(array, 0, 1) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt index b4f61fd220..e35a45ed1f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPluginTest.kt @@ -45,7 +45,7 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() { `when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s") `when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") danaRPump = DanaRPump(aapsLogger, sp, injector) - danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, rxBus, danaRPump, context, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue) + danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, rxBus, danaRPump, context, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, dateUtil) } @Test @Throws(Exception::class) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt index f72d6cde94..94df6cc4fe 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKoreanTest.kt @@ -31,7 +31,7 @@ class MessageHashTableRKoreanTest : DanaRSTestBase() { @Test fun runTest() { Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) - val messageHashTable = MessageHashTableRKorean(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, activePlugin, injector) + val messageHashTable = MessageHashTableRKorean(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, activePlugin, dateUtil, injector) val testMessage = messageHashTable.findMessage(0x41f2) Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName) } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt index 3f5da64f27..81b3524543 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt @@ -63,6 +63,6 @@ class DanaRSPluginTest : DanaRSTestBase() { Mockito.`when`(resourceHelper.gs(eq(R.string.limitingbasalratio), anyObject(), anyObject())).thenReturn("limitingbasalratio") Mockito.`when`(resourceHelper.gs(eq(R.string.limitingpercentrate), anyObject(), anyObject())).thenReturn("limitingpercentrate") - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage) + danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, dateUtil) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt index 8fe1009923..1907eef740 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import android.content.Context import com.cozmo.danar.util.BleCommandUtil import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.Constraint @@ -7,6 +8,7 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin +import info.nightscout.androidaps.utils.DateUtil import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -19,6 +21,7 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class) class DanaRSMessageHashTableTest : DanaRSTestBase() { + @Mock lateinit var context: Context @Mock lateinit var danaRSPlugin: DanaRSPlugin @Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var constraintChecker: ConstraintChecker @@ -28,8 +31,8 @@ class DanaRSMessageHashTableTest : DanaRSTestBase() { fun runTest() { `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) - val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, danaRSPlugin, activePlugin, constraintChecker, detailedBolusInfoStorage, injector) - val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, 0, 0, 0) + val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, danaRSPlugin, activePlugin, constraintChecker, detailedBolusInfoStorage, injector, DateUtil(context, resourceHelper)) + val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, dateUtil, DanaRPump.CARBS, 0, 0, 0) val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command) Assert.assertEquals(BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong()) } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt index f983386933..e97edfb860 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm +import android.content.Context import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage @@ -17,6 +18,7 @@ import java.util.* @PrepareForTest(RxBusWrapper::class, DetailedBolusInfoStorage::class) class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() { + @Mock lateinit var context: Context @Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var danaRSPlugin: DanaRSPlugin @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage @@ -24,7 +26,7 @@ class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() { @Test fun runTest() { val now = DateUtil.now() - val testPacket = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, now) + val testPacket = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, DateUtil(context, resourceHelper), now) // test getRequestedParams val returnedValues = testPacket.requestParams val expectedValues = getCalender(now) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt index 33e343ee08..402352f235 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt @@ -14,19 +14,19 @@ class DanaRS_Packet_APS_Set_Event_HistoryTest : DanaRSTestBase() { @Test fun runTest() { // test for negative carbs val now = DateUtil.now() - var historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, -1, 0) + var historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, dateUtil, DanaRPump.CARBS, now, -1, 0) var testparams = historyTest.requestParams Assert.assertEquals(0.toByte(), testparams[8]) // 5g carbs - historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, 5, 0) + historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, dateUtil, DanaRPump.CARBS, now, 5, 0) testparams = historyTest.requestParams Assert.assertEquals(5.toByte(), testparams[8]) // 150g carbs - historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, 150, 0) + historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, dateUtil, DanaRPump.CARBS, now, 150, 0) testparams = historyTest.requestParams Assert.assertEquals(150.toByte(), testparams[8]) // test message generation - historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, now, 5, 0) + historyTest = DanaRS_Packet_APS_Set_Event_History(aapsLogger, dateUtil, DanaRPump.CARBS, now, 5, 0) testparams = historyTest.requestParams Assert.assertEquals(5.toByte(), testparams[8]) Assert.assertEquals(11, testparams.size) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt index f8e3472c8e..ca70660272 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil) // test message decoding val array = ByteArray(100) putByteToArray(array, 0, 1.toByte()) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt index 86239a8ea1..ecfbd0ef40 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump, dateUtil) Assert.assertEquals(null, packet.requestParams) // test message decoding packet.handleMessage(createArray(34, 0.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt index bcc56e2f92..b05a2643f9 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt @@ -44,7 +44,7 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest : DanaRSTestBase() { @Before fun mock() { - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage) + danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, dateUtil) Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt index 327aa1c8a6..4297e7683d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt @@ -11,13 +11,13 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() { @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump, dateUtil) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(13, 0.toByte())) Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump, dateUtil) packet.handleMessage(createArray(15, 0.toByte())) Assert.assertEquals(false, packet.failed) packet.handleMessage(createArray(15, 161.toByte())) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt index 3de89db27b..cd3f76de5c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt @@ -9,14 +9,14 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_General_Get_Shipping_InformationTest : DanaRSTestBase() { @Test fun runTest() { - var packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump) + var packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump, dateUtil) Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) // everything ok :) - packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump) + packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump, dateUtil) packet.handleMessage(createArray(18, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.friendlyName) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt index 743d3f66e7..5a5c6c4e81 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_AlarmTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_Alarm(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Alarm(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__ALARM", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt index 1f7dd00783..0a0f87fe56 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_All_HistoryTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_All_History(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_All_History(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__ALL_HISTORY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt index 8451e90b0f..86e962d1df 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_BasalTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_Basal(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Basal(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BASAL", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt index 0442ea98b9..6cb0c847fc 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_Blood_GlucoseTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BLOOD_GLUCOSE", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt index badaa0aa10..da4c629042 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_BolusTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_Bolus(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Bolus(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__BOLUS", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt index 22a99fcc53..2fc07b5eda 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_CarbohydrateTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__CARBOHYDRATE", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt index 91d4bea862..c1e4a772c6 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_DailyTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_Daily(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Daily(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__DAILY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt index 19c8d2ef4e..a53a5c0812 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_PrimeTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_Prime(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Prime(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__PRIME", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt index 8b75ec344f..29641db16e 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_RefillTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_Refill(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Refill(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__REFILL", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt index 66b06f4ed7..5bd6ce327d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_SuspendTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_Suspend(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Suspend(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__SUSPEND", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt index a4e436a373..1c193ea587 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_History_TemporaryTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_History_Temporary(aapsLogger, rxBus, System.currentTimeMillis()) + val packet = DanaRS_Packet_History_Temporary(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) Assert.assertEquals("REVIEW__TEMPORARY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt index 0f90812ed0..d91872f922 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt @@ -61,7 +61,7 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { @Before fun mock() { - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage) + danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, dateUtil) danaRSPlugin.bolusingTreatment = Treatment(treatmentInjector) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt index 8f74812e9e..9ed05dd6f1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt @@ -11,7 +11,7 @@ import org.powermock.modules.junit4.PowerMockRunner class DanaRS_Packet_Option_Get_Pump_TimeTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump) + val packet = DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump, dateUtil) // test params Assert.assertEquals(null, packet.requestParams) // test message decoding diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt index 5fd034e5b6..e6c32cc43a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt @@ -13,7 +13,7 @@ import java.util.* class DanaRS_Packet_Option_Set_Pump_TimeTest : DanaRSTestBase() { @Test fun runTest() { - val packet = DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now()) + val packet = DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, dateUtil, DateUtil.now()) // test params val params = packet.requestParams Assert.assertEquals((Date().date and 0xff).toByte(), params[2]) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt index 23285e59e3..1c7a6083b5 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt @@ -45,7 +45,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() { `when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s") `when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") danaRPump = DanaRPump(aapsLogger, sp, injector) - danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, rxBus, context, danaRPump, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, detailedBolusInfoStorage) + danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, rxBus, context, danaRPump, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, detailedBolusInfoStorage, dateUtil) } @Test diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTable_rv2Test.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTable_rv2Test.kt index b84258c00b..b497e88b95 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTable_rv2Test.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTable_rv2Test.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRv2.comm +import android.content.Context import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint @@ -13,6 +14,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert import org.junit.Test @@ -26,6 +28,7 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, ConfigBuilderPlugin::class) class MessageHashTable_rv2Test : DanaRTestBase() { + @Mock lateinit var context: Context @Mock lateinit var rxBus: RxBusWrapper @Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var constraintChecker: ConstraintChecker @@ -41,7 +44,7 @@ class MessageHashTable_rv2Test : DanaRTestBase() { @Test fun runTest() { `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) - val messageHashTableRv2 = MessageHashTableRv2(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue, activePlugin, detailedBolusInfoStorage, treatmentsPlugin, injector) + val messageHashTableRv2 = MessageHashTableRv2(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue, activePlugin, detailedBolusInfoStorage, treatmentsPlugin, injector, DateUtil(context, resourceHelper)) val forTesting: MessageBase = MsgStatusAPS_v2(aapsLogger, danaRPump) val testPacket: MessageBase = messageHashTableRv2.findMessage(forTesting.command) Assert.assertEquals(0xE001, testPacket.command.toLong()) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2Test.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2Test.kt index 0c3d40916a..bcfacf1e81 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2Test.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgHistoryEvents_v2Test.kt @@ -1,10 +1,12 @@ package info.nightscout.androidaps.plugins.pump.danaRv2.comm +import android.content.Context import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert import org.junit.Test @@ -17,13 +19,14 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(DetailedBolusInfoStorage::class) class MsgHistoryEvents_v2Test : DanaRTestBase() { + @Mock lateinit var context: Context @Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage @Mock lateinit var danaRv2Plugin: DanaRv2Plugin @Mock lateinit var treatmentsPlugin: TreatmentsPlugin @Test @Throws(Exception::class) fun runTest() { - var packet = MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, RxBusWrapper(), treatmentsPlugin, injector, 0) + var packet = MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, RxBusWrapper(), treatmentsPlugin, injector, DateUtil(context, resourceHelper), 0) // test message decoding val array = ByteArray(100) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2Test.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2Test.kt index fa98c68830..fefc050457 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2Test.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2Test.kt @@ -10,7 +10,7 @@ import org.powermock.modules.junit4.PowerMockRunner class MsgStatusTempBasal_v2Test : DanaRTestBase() { @Test fun runTest() { - val packet = MsgStatusTempBasal_v2(aapsLogger, danaRPump) + val packet = MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil) // test message decoding packet.handleMessage(createArray(34, 1.toByte())) Assert.assertEquals(true, danaRPump.isTempBasalInProgress) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPluginUTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPluginUTest.kt index db6d30ef59..cdafb560a6 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPluginUTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPluginUTest.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.virtual import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.Config import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.interfaces.CommandQueueProvider @@ -9,6 +10,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -32,12 +34,13 @@ class VirtualPumpPluginUTest : TestBase() { @Mock lateinit var profileFunction: ProfileFunction @Mock lateinit var treatmentsPlugin: TreatmentsPlugin @Mock lateinit var commandQueue: CommandQueueProvider + @Mock lateinit var dateUtil: DateUtil lateinit var virtualPumpPlugin: VirtualPumpPlugin @Before fun prepareMocks() { - virtualPumpPlugin = VirtualPumpPlugin(HasAndroidInjector { AndroidInjector { } }, aapsLogger, rxBus, fabricPrivacy, resourceHelper, sp, profileFunction, treatmentsPlugin, commandQueue) + virtualPumpPlugin = VirtualPumpPlugin(HasAndroidInjector { AndroidInjector { } }, aapsLogger, rxBus, fabricPrivacy, resourceHelper, sp, profileFunction, treatmentsPlugin, commandQueue, Config(), dateUtil) } @Test diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPluginTest.kt index 000a718c01..f410b29a94 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPluginTest.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.sensitivity import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBase +import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult @@ -24,7 +25,7 @@ class AbstractSensitivityPluginTest : TestBase() { private inner class SensitivityTestClass(pluginDescription: PluginDescription, aapsLogger: AAPSLogger, resourceHelper: ResourceHelper, sp: SP) : AbstractSensitivityPlugin(pluginDescription, HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, resourceHelper, sp) { - override fun detectSensitivity(plugin: IobCobCalculatorPlugin, fromTime: Long, toTime: Long): AutosensResult { + override fun detectSensitivity(plugin: IobCobCalculatorInterface, fromTime: Long, toTime: Long): AutosensResult { return AutosensResult() } } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPluginTest.kt index 8aa4ccad2d..f36a10ec7e 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPluginTest.kt @@ -58,7 +58,7 @@ class TreatmentsPluginTest : TestBaseWithProfile() { `when`(profileFunction.getProfile(ArgumentMatchers.anyLong())).thenReturn(validProfile) `when`(activePluginProvider.activeInsulin).thenReturn(insulinOrefRapidActingPlugin) - sot = TreatmentsPlugin(profileInjector, aapsLogger, rxBus, resourceHelper, context, sp, profileFunction, activePluginProvider, fabricPrivacy) + sot = TreatmentsPlugin(profileInjector, aapsLogger, rxBus, resourceHelper, context, sp, profileFunction, activePluginProvider, fabricPrivacy, dateUtil) sot.service = treatmentService } diff --git a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt index f4ebe83fdd..b375602bfb 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.kt @@ -4,6 +4,7 @@ import android.content.Context import dagger.Lazy import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.Config import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.interfaces.ActivePluginProvider @@ -38,7 +39,7 @@ class CommandQueueTest : TestBaseWithProfile() { @Mock lateinit var virtualPumpPlugin: VirtualPumpPlugin @Mock lateinit var sp: SP - private val buildHelper = BuildHelper() + private val buildHelper = BuildHelper(Config()) val injector = HasAndroidInjector { AndroidInjector { diff --git a/app/src/test/java/info/nightscout/androidaps/utils/DateUtilTest.kt b/app/src/test/java/info/nightscout/androidaps/utils/DateUtilTest.kt index 0edbe93c11..3a70e1a34c 100644 --- a/app/src/test/java/info/nightscout/androidaps/utils/DateUtilTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/utils/DateUtilTest.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.utils +import android.content.Context import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.R import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -14,6 +15,7 @@ import java.util.* @RunWith(PowerMockRunner::class) class DateUtilTest : TestBase() { + @Mock lateinit var context: Context @Mock lateinit var resourceHelper: ResourceHelper @Test @@ -46,22 +48,22 @@ class DateUtilTest : TestBase() { } @Test fun timeStringTest() { - Assert.assertTrue(DateUtil.timeString(Date(1513902750000L)).contains("32")) - Assert.assertTrue(DateUtil.timeString(1513902750000L).contains("32")) + Assert.assertTrue(DateUtil(context, resourceHelper).timeString(Date(1513902750000L)).contains("32")) + Assert.assertTrue(DateUtil(context, resourceHelper).timeString(1513902750000L).contains("32")) } @Test fun dateAndTimeStringTest() { - Assert.assertTrue(DateUtil.dateAndTimeString(1513902750000L).contains("22")) - Assert.assertTrue(DateUtil.dateAndTimeString(1513902750000L).contains("32")) - Assert.assertTrue(DateUtil.dateAndTimeString(Date(1513902750000L)).contains("22")) - Assert.assertTrue(DateUtil.dateAndTimeString(Date(1513902750000L)).contains("32")) + Assert.assertTrue(DateUtil(context, resourceHelper).dateAndTimeString(1513902750000L).contains("22")) + Assert.assertTrue(DateUtil(context, resourceHelper).dateAndTimeString(1513902750000L).contains("32")) + Assert.assertTrue(DateUtil(context, resourceHelper).dateAndTimeString(Date(1513902750000L)).contains("22")) + Assert.assertTrue(DateUtil(context, resourceHelper).dateAndTimeString(Date(1513902750000L)).contains("32")) } @Test fun dateAndTimeRangeStringTest() { - Assert.assertTrue(DateUtil.dateAndTimeRangeString(1513902750000L, 1513902750000L).contains("22")) - Assert.assertTrue(DateUtil.dateAndTimeRangeString(1513902750000L, 1513902750000L).contains("32")) - Assert.assertTrue(DateUtil.dateAndTimeRangeString(1513902750000L, 1513902750000L).contains("22")) - Assert.assertTrue(DateUtil.dateAndTimeRangeString(1513902750000L, 1513902750000L).contains("32")) + Assert.assertTrue(DateUtil(context, resourceHelper).dateAndTimeRangeString(1513902750000L, 1513902750000L).contains("22")) + Assert.assertTrue(DateUtil(context, resourceHelper).dateAndTimeRangeString(1513902750000L, 1513902750000L).contains("32")) + Assert.assertTrue(DateUtil(context, resourceHelper).dateAndTimeRangeString(1513902750000L, 1513902750000L).contains("22")) + Assert.assertTrue(DateUtil(context, resourceHelper).dateAndTimeRangeString(1513902750000L, 1513902750000L).contains("32")) } /* diff --git a/app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.java b/app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.java deleted file mode 100644 index 166ce04b10..0000000000 --- a/app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package info.nightscout.androidaps.utils; - -import org.junit.Assert; -import org.junit.Test; - -public class SntpClientTest { - - @Test - public void ntpTimeTest() { - // no internet - SntpClient.ntpTime(new SntpClient.Callback() { - @Override - public void run() { - Assert.assertFalse(networkConnected); - Assert.assertFalse(success); - Assert.assertEquals(0L, time); - } - }, false); - // internet - SntpClient.doNtpTime(new SntpClient.Callback() { - @Override - public void run() { - Assert.assertTrue(success); - Assert.assertTrue(Math.abs(time - DateUtil.now()) < 60000); - } - }); - } -} \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.kt b/app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.kt new file mode 100644 index 0000000000..79a8541daf --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.kt @@ -0,0 +1,29 @@ +package info.nightscout.androidaps.utils + +import info.nightscout.androidaps.TestBase +import org.junit.Assert +import org.junit.Test +import org.mockito.Mock + +class SntpClientTest : TestBase() { + @Mock lateinit var dateUtil: DateUtil + + @Test + fun ntpTimeTest() { + // no internet + SntpClient(aapsLogger, dateUtil).ntpTime(object : SntpClient.Callback() { + override fun run() { + Assert.assertFalse(networkConnected) + Assert.assertFalse(success) + Assert.assertEquals(0L, time) + } + }, false) + // internet + SntpClient(aapsLogger, dateUtil).doNtpTime(object : SntpClient.Callback() { + override fun run() { + Assert.assertTrue(success) + Assert.assertTrue(Math.abs(time - DateUtil.now()) < 60000) + } + }) + } +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/db/BgReading.java b/core/src/main/java/info/nightscout/androidaps/db/BgReading.java index f2b53b8738..89ef6b473a 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/BgReading.java +++ b/core/src/main/java/info/nightscout/androidaps/db/BgReading.java @@ -33,6 +33,7 @@ public class BgReading implements DataPointWithLabelInterface { @Inject public DefaultValueHelper defaultValueHelper; @Inject public ProfileFunction profileFunction; @Inject public ResourceHelper resourceHelper; + @Inject public DateUtil dateUtil; @DatabaseField(id = true) public long date; @@ -66,7 +67,8 @@ public class BgReading implements DataPointWithLabelInterface { injector.androidInjector().inject(this); } - public BgReading(NSSgv sgv) { + public BgReading(HasAndroidInjector injector, NSSgv sgv) { + injector.androidInjector().inject(this); date = sgv.getMills(); value = sgv.getMgdl(); raw = sgv.getFiltered() != null ? sgv.getFiltered() : value; @@ -125,7 +127,7 @@ public class BgReading implements DataPointWithLabelInterface { public String toString() { return "BgReading{" + "date=" + date + - ", date=" + DateUtil.dateAndTimeString(date) + + ", date=" + dateUtil.dateAndTimeString(date) + ", value=" + value + ", direction=" + direction + ", raw=" + raw + diff --git a/core/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java b/core/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java index 6f95917ace..1300d0bbf9 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java +++ b/core/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java @@ -38,6 +38,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval { @Inject ResourceHelper resourceHelper; @Inject AAPSLogger aapsLogger; @Inject Translator translator; + @Inject DateUtil dateUtil; @DatabaseField(id = true) public long date; @@ -122,7 +123,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval { public String toString() { return "CareportalEvent{" + "date= " + date + - ", date= " + DateUtil.dateAndTimeString(date) + + ", date= " + dateUtil.dateAndTimeString(date) + ", isValid= " + isValid + ", _id= " + _id + ", eventType= " + eventType + @@ -134,7 +135,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval { for (int i = 0; i < list.size(); i++) { CareportalEvent event = list.get(i); if (event.date <= time && event.date > (time - T.mins(5).msecs())) { - aapsLogger.debug(LTag.DATABASE, "Found event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString()); + aapsLogger.debug(LTag.DATABASE, "Found event for time: " + dateUtil.dateAndTimeString(time) + " " + event.toString()); return true; } } diff --git a/core/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java b/core/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java index 49b223d9b9..e1f96431cb 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java +++ b/core/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java @@ -212,7 +212,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface { public String log() { return "ExtendedBolus{" + "date= " + date + - ", date= " + DateUtil.dateAndTimeString(date) + + ", date= " + dateUtil.dateAndTimeString(date) + ", isValid=" + isValid + ", _id= " + _id + ", pumpId= " + pumpId + diff --git a/core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java b/core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java index 09b7d047ba..006a839510 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java +++ b/core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java @@ -73,6 +73,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface { @Inject public AAPSLogger aapsLogger; @Inject public RxBusWrapper rxBus; @Inject public ResourceHelper resourceHelper; + @Inject public DateUtil dateUtil; public ProfileSwitch() { this.injector = StaticInjector.Companion.getInstance(); @@ -233,11 +234,11 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface { @Override public boolean isValid() { - boolean isValid = getProfileObject() != null && getProfileObject().isValid(DateUtil.dateAndTimeString(date)); + boolean isValid = getProfileObject() != null && getProfileObject().isValid(dateUtil.dateAndTimeString(date)); ProfileSwitch active = treatmentsPlugin.getProfileSwitchFromHistory(DateUtil.now()); long activeProfileSwitchDate = active != null ? active.date : -1L; if (!isValid && date == activeProfileSwitchDate) - createNotificationInvalidProfile(DateUtil.dateAndTimeString(date)); + createNotificationInvalidProfile(dateUtil.dateAndTimeString(date)); return isValid; } @@ -246,17 +247,17 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface { rxBus.send(new EventNewNotification(notification)); } - public static boolean isEvent5minBack(AAPSLogger aapsLogger, List list, long time, boolean zeroDurationOnly) { + public boolean isEvent5minBack(List list, long time, boolean zeroDurationOnly) { for (int i = 0; i < list.size(); i++) { ProfileSwitch event = list.get(i); if (event.date <= time && event.date > (time - T.mins(5).msecs())) { if (zeroDurationOnly) { if (event.durationInMinutes == 0) { - aapsLogger.debug(LTag.DATABASE, "Found ProfileSwitch event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString()); + aapsLogger.debug(LTag.DATABASE, "Found ProfileSwitch event for time: " + dateUtil.dateAndTimeString(time) + " " + event.toString()); return true; } } else { - aapsLogger.debug(LTag.DATABASE, "Found ProfileSwitch event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString()); + aapsLogger.debug(LTag.DATABASE, "Found ProfileSwitch event for time: " + dateUtil.dateAndTimeString(time) + " " + event.toString()); return true; } } @@ -314,7 +315,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface { public String toString() { return "ProfileSwitch{" + "date=" + date + - "date=" + DateUtil.dateAndTimeString(date) + + "date=" + dateUtil.dateAndTimeString(date) + ", isValid=" + isValid + ", duration=" + durationInMinutes + ", profileName=" + profileName + diff --git a/core/src/main/java/info/nightscout/androidaps/db/TDD.java b/core/src/main/java/info/nightscout/androidaps/db/TDD.java index eba359f2ad..05b9025491 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/TDD.java +++ b/core/src/main/java/info/nightscout/androidaps/db/TDD.java @@ -46,11 +46,10 @@ public class TDD { } - @Override - public String toString() { + public String toString(DateUtil dateUtil) { return "TDD [" + "date=" + date + - "date(str)=" + DateUtil.dateAndTimeString(date) + + "date(str)=" + dateUtil.dateAndTimeString(date) + ", bolus=" + bolus + ", basal=" + basal + ", total=" + total + diff --git a/core/src/main/java/info/nightscout/androidaps/db/TempTarget.java b/core/src/main/java/info/nightscout/androidaps/db/TempTarget.java index cc9b7db990..92668d255a 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/TempTarget.java +++ b/core/src/main/java/info/nightscout/androidaps/db/TempTarget.java @@ -182,10 +182,10 @@ public class TempTarget implements Interval { else return DecimalFormatter.to1Decimal(low * Constants.MGDL_TO_MMOLL); } - public String toString() { + public String toString(DateUtil dateUtil) { return "TemporaryTarget{" + "date=" + date + - "date=" + DateUtil.dateAndTimeString(date) + + "date=" + dateUtil.dateAndTimeString(date) + ", isValid=" + isValid + ", duration=" + durationInMinutes + ", reason=" + reason + diff --git a/core/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java b/core/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java index cf59c456d3..d4f89fdd7e 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java +++ b/core/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java @@ -404,7 +404,7 @@ public class TemporaryBasal implements Interval, DbObjectBase { public String toString() { return "TemporaryBasal{" + "date=" + date + - ", date=" + DateUtil.dateAndTimeString(date) + + ", date=" + dateUtil.dateAndTimeString(date) + ", isValid=" + isValid + ", pumpId=" + pumpId + ", _id=" + _id + diff --git a/core/src/main/java/info/nightscout/androidaps/db/Treatment.java b/core/src/main/java/info/nightscout/androidaps/db/Treatment.java index 0df0dd0efa..bd3a4c0ebe 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/Treatment.java +++ b/core/src/main/java/info/nightscout/androidaps/db/Treatment.java @@ -37,6 +37,7 @@ public class Treatment implements DataPointWithLabelInterface, DbObjectBase { @Inject public ResourceHelper resourceHelper; @Inject public ProfileFunction profileFunction; @Inject public ActivePluginProvider activePlugin; + @Inject public DateUtil dateUtil; public static final String TABLE_TREATMENTS = "Treatments"; @@ -108,7 +109,7 @@ public class Treatment implements DataPointWithLabelInterface, DbObjectBase { @NonNull public String toString() { return "Treatment{" + "date= " + date + - ", date= " + DateUtil.dateAndTimeString(date) + + ", date= " + dateUtil.dateAndTimeString(date) + ", isValid= " + isValid + ", isSMB= " + isSMB + ", _id= " + _id + diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.java b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.java index 9cd8c74f87..51a1b58c18 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.java @@ -11,7 +11,6 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.Treatment; -import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; @@ -29,8 +28,8 @@ public class AutosensData implements DataPointWithLabelInterface { @Inject AAPSLogger aapsLogger; @Inject SP sp; @Inject ResourceHelper resourceHelper; - @Inject ActivePluginProvider activePlugin; @Inject ProfileFunction profileFunction; + @Inject DateUtil dateUtil; public AutosensData(HasAndroidInjector injector) { injector.androidInjector().inject(this); @@ -56,7 +55,7 @@ public class AutosensData implements DataPointWithLabelInterface { double sens = profile.getIsfMgdl(t.date); double ic = profile.getIc(t.date); min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic; - aapsLogger.debug(LTag.AUTOSENS, "Min 5m carbs impact for " + carbs + "g @" + DateUtil.dateAndTimeString(t.date) + " for " + maxAbsorptionHours + "h calculated to " + min5minCarbImpact + " ISF: " + sens + " IC: " + ic); + aapsLogger.debug(LTag.AUTOSENS, "Min 5m carbs impact for " + carbs + "g @" + dateUtil.dateAndTimeString(t.date) + " for " + maxAbsorptionHours + "h calculated to " + min5minCarbImpact + " ISF: " + sens + " IC: " + ic); } else { min5minCarbImpact = sp.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact); } @@ -71,7 +70,7 @@ public class AutosensData implements DataPointWithLabelInterface { @Override public String toString() { - return String.format(Locale.ENGLISH, "CarbsInPast: time: %s carbs: %.02f min5minCI: %.02f remaining: %.2f", DateUtil.dateAndTimeString(time), carbs, min5minCarbImpact, remaining); + return String.format(Locale.ENGLISH, "CarbsInPast: time: %s carbs: %.02f min5minCI: %.02f remaining: %.2f", dateUtil.dateAndTimeString(time), carbs, min5minCarbImpact, remaining); } } @@ -107,7 +106,7 @@ public class AutosensData implements DataPointWithLabelInterface { @Override public String toString() { return String.format(Locale.ENGLISH, "AutosensData: %s pastSensitivity=%s delta=%.02f avgDelta=%.02f bgi=%.02f deviation=%.02f avgDeviation=%.02f absorbed=%.02f carbsFromBolus=%.02f cob=%.02f autosensRatio=%.02f slopeFromMaxDeviation=%.02f slopeFromMinDeviation=%.02f activeCarbsList=%s", - DateUtil.dateAndTimeString(time), pastSensitivity, delta, avgDelta, bgi, deviation, avgDeviation, absorbed, carbsFromBolus, cob, autosensResult.ratio, slopeFromMaxDeviation, slopeFromMinDeviation, activeCarbsList.toString()); + dateUtil.dateAndTimeString(time), pastSensitivity, delta, avgDelta, bgi, deviation, avgDeviation, absorbed, carbsFromBolus, cob, autosensResult.ratio, slopeFromMaxDeviation, slopeFromMinDeviation, activeCarbsList.toString()); } public List cloneCarbsList() { @@ -134,7 +133,7 @@ public class AutosensData implements DataPointWithLabelInterface { activeCarbsList.remove(i--); if (c.remaining > 0) cob -= c.remaining; - aapsLogger.debug(LTag.AUTOSENS, "Removing carbs at " + DateUtil.dateAndTimeString(toTime) + " after " + maxAbsorptionHours + "h > " + c.toString()); + aapsLogger.debug(LTag.AUTOSENS, "Removing carbs at " + dateUtil.dateAndTimeString(toTime) + " after " + maxAbsorptionHours + "h > " + c.toString()); } } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java index 16fb3e2504..58e156d7a0 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java +++ b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java @@ -44,19 +44,10 @@ public class DateUtil { private final Context context; private final ResourceHelper resourceHelper; - @Deprecated - private static DateUtil instance; - @Inject public DateUtil(Context context, ResourceHelper resourceHelper) { this.context = context; this.resourceHelper = resourceHelper; - instance = this; - } - - @Deprecated - public static DateUtil getInstance() { - return instance; } /** @@ -206,22 +197,22 @@ public class DateUtil { return new DateTime(mills).toString(DateTimeFormat.fullTime()); } - public static String dateAndTimeString(Date date) { - return dateString(date) + " " + instance.timeString(date); + public String dateAndTimeString(Date date) { + return dateString(date) + " " + timeString(date); } - public static String dateAndTimeRangeString(long start, long end) { - return dateAndTimeString(start) + " - " + instance.timeString(end); + public String dateAndTimeRangeString(long start, long end) { + return dateAndTimeString(start) + " - " + timeString(end); } - public static String dateAndTimeString(long mills) { + public String dateAndTimeString(long mills) { if (mills == 0) return ""; - return dateString(mills) + " " + instance.timeString(mills); + return dateString(mills) + " " + timeString(mills); } - public static String dateAndTimeAndSecondsString(long mills) { + public String dateAndTimeAndSecondsString(long mills) { if (mills == 0) return ""; - return dateString(mills) + " " + instance.timeStringWithSeconds(mills); + return dateString(mills) + " " + timeStringWithSeconds(mills); } public static String dateAndTimeFullString(long mills) { @@ -245,11 +236,11 @@ public class DateUtil { private static LongSparseArray timeStrings = new LongSparseArray<>(); - public static String timeStringFromSeconds(int seconds) { + public String timeStringFromSeconds(int seconds) { String cached = timeStrings.get(seconds); if (cached != null) return cached; - String t = instance.timeString(toDate(seconds)); + String t = timeString(toDate(seconds)); timeStrings.put(seconds, t); return t; } From 7dc7c9528b4ecb0398c5b661c028aefd21fd2112 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 8 May 2020 00:23:17 +0200 Subject: [PATCH 041/400] Omni comments --- .../pump/omnipod/defs/state/PodSessionState.java | 14 ++++++++++---- .../comm/OmnipodDashCommunicationManager.java | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java index 97ac22bda1..862976afbc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java @@ -33,13 +33,17 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; public class PodSessionState extends PodState { - @Inject AAPSLogger aapsLogger; - @Inject SP sp; - @Inject OmnipodUtil omnipodUtil; - @Inject DateUtil dateUtil; + @Inject transient AAPSLogger aapsLogger; + @Inject transient SP sp; + @Inject transient OmnipodUtil omnipodUtil; + @Inject transient DateUtil dateUtil; private transient PodStateChangedHandler stateChangedHandler; + // TODO + // the problem you have with injection in this class is that you are mixing + // data storing and handlind. Move these member variables to extra class you can + // easy serialize and load it here by setData(dataInOtherClass) private final Map configuredAlerts; private DateTimeZone timeZone; private DateTime activatedAt; @@ -78,10 +82,12 @@ public class PodSessionState extends PodState { handleUpdates(); } + @Deprecated public void injectDaggerClass(HasAndroidInjector injector) { injector.androidInjector().inject(this); } + @Deprecated public void setStateChangedHandler(PodStateChangedHandler handler) { // FIXME this is an ugly workaround for not being able to serialize the PodStateChangedHandler if (stateChangedHandler != null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java index 4f869bd286..e440d632a5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java @@ -18,12 +18,14 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; * Created by andy on 4.8.2019 */ // TODO refactor to use dagger, just commented out errors +// TODO is this class used? remove if not public class OmnipodDashCommunicationManager implements OmnipodCommunicationManagerInterface { // TODO Dagger // private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM); + // i didn't find where you instantiate this private static OmnipodDashCommunicationManager omnipodCommunicationManager; private String errorMessage; @@ -38,6 +40,7 @@ public class OmnipodDashCommunicationManager implements OmnipodCommunicationMana return null; } + @Deprecated public static OmnipodDashCommunicationManager getInstance() { return omnipodCommunicationManager; } From 15207d1bf10a67af2d7c9a071353e6b8bb5069ca Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 8 May 2020 01:09:30 +0200 Subject: [PATCH 042/400] Omni comments 2 --- .../pump/omnipod/OmnipodPumpPlugin.java | 4 +-- .../OmnipodCommunicationManagerInterface.java | 4 --- .../driver/comm/AapsOmnipodManager.java | 36 +++++++++---------- .../service/RileyLinkOmnipodService.java | 2 +- .../comm/OmnipodDashCommunicationManager.java | 5 --- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 79cee43c89..0c51b5901c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -519,13 +519,13 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } else { aapsLogger.warn(LTag.PUMP, "Result was NOT null."); - Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); + 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("clipboardContent", result.toString()); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - MainApp.instance().startActivity(i); + context.startActivity(i); // OKDialog.show(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.action), // "Pulse Log:\n" + result.toString(), null); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommunicationManagerInterface.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommunicationManagerInterface.java index 3999cd2923..d345a3c385 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommunicationManagerInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommunicationManagerInterface.java @@ -71,9 +71,5 @@ public interface OmnipodCommunicationManagerInterface { */ PumpEnactResult setTime(); - - void setPumpStatus(OmnipodPumpStatus pumpStatusLocal); - - PodInfoRecentPulseLog readPulseLog(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java index f8c67f5471..6632cd0213 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/comm/AapsOmnipodManager.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.comm; +import android.content.Context; import android.content.Intent; import android.text.TextUtils; @@ -83,42 +84,47 @@ import io.reactivex.disposables.Disposable; public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface { - private OmnipodUtil omnipodUtil; - private AAPSLogger aapsLogger; - private RxBusWrapper rxBus; - private ResourceHelper resourceHelper; - private HasAndroidInjector injector; - private ActivePluginProvider activePlugin; - private OmnipodPumpStatus pumpStatus; + private final OmnipodUtil omnipodUtil; + private final AAPSLogger aapsLogger; + private final RxBusWrapper rxBus; + private final ResourceHelper resourceHelper; + private final HasAndroidInjector injector; + private final ActivePluginProvider activePlugin; + private final OmnipodPumpStatus pumpStatus; + private final Context context; private final OmnipodManager delegate; + @Deprecated private static AapsOmnipodManager instance; private Date lastBolusTime; private Double lastBolusUnits; + @Deprecated public static AapsOmnipodManager getInstance() { return instance; } public AapsOmnipodManager(OmnipodCommunicationManager communicationService, PodSessionState podState, - OmnipodPumpStatus _pumpStatus, + OmnipodPumpStatus pumpStatus, OmnipodUtil omnipodUtil, AAPSLogger aapsLogger, RxBusWrapper rxBus, SP sp, ResourceHelper resourceHelper, HasAndroidInjector injector, - ActivePluginProvider activePlugin) { + ActivePluginProvider activePlugin, + Context context) { this.omnipodUtil = omnipodUtil; this.aapsLogger = aapsLogger; this.rxBus = rxBus; this.resourceHelper = resourceHelper; this.injector = injector; this.activePlugin = activePlugin; - this.pumpStatus = _pumpStatus; + this.pumpStatus = pumpStatus; + this.context = context; delegate = new OmnipodManager(aapsLogger, sp, communicationService, podState, podSessionState -> { // Handle pod state changes @@ -460,12 +466,6 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface return new PumpEnactResult(injector).success(true).enacted(true); } - @Override - public void setPumpStatus(OmnipodPumpStatus pumpStatus) { - this.pumpStatus = pumpStatus; - updatePumpStatus(delegate.getPodState()); - } - // TODO should we add this to the OmnipodCommunicationManager interface? public PumpEnactResult getPodInfo(PodInfoType podInfoType) { long time = System.currentTimeMillis(); @@ -706,12 +706,12 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface } private void showErrorDialog(String message, Integer sound) { - Intent intent = new Intent(MainApp.instance(), ErrorHelperActivity.class); + Intent intent = new Intent(context, ErrorHelperActivity.class); intent.putExtra("soundid", sound == null ? 0 : sound); intent.putExtra("status", message); intent.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - MainApp.instance().startActivity(intent); + context.startActivity(intent); } private void showNotification(String message, int urgency, Integer sound) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java index 2ecd3685c0..908748b991 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/service/RileyLinkOmnipodService.java @@ -124,7 +124,7 @@ public class RileyLinkOmnipodService extends RileyLinkService { this.omnipodCommunicationManager = omnipodCommunicationService; this.aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podState, omnipodPumpStatus, - omnipodUtil, aapsLogger, rxBus, sp, resourceHelper, injector, activePlugin); + omnipodUtil, aapsLogger, rxBus, sp, resourceHelper, injector, activePlugin, this); } else { aapsOmnipodManager = AapsOmnipodManager.getInstance(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java index e440d632a5..39ccadd308 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java @@ -117,11 +117,6 @@ public class OmnipodDashCommunicationManager implements OmnipodCommunicationMana return null; } - @Override - public void setPumpStatus(OmnipodPumpStatus pumpStatusLocal) { - - } - @Override public PodInfoRecentPulseLog readPulseLog() { return null; From 73d132649de5085ad49c0e4a79d08c6d7fa1eab8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 8 May 2020 11:37:14 +0200 Subject: [PATCH 043/400] fix tests --- .../interfaces/ConstraintsCheckerTest.kt | 2 +- .../plugins/pump/danaRS/DanaRSPluginTest.kt | 6 +----- .../danaRS/comm/DanaRSMessageHashTableTest.kt | 21 +------------------ .../DanaRS_Packet_APS_History_EventsTest.kt | 5 ++++- ...DanaRS_Packet_APS_Set_Event_HistoryTest.kt | 5 ++++- ...ket_Basal_Get_Temporary_Basal_StateTest.kt | 5 ++++- ...et_Bolus_Get_Step_Bolus_InformationTest.kt | 17 ++++----------- ...S_Packet_Bolus_Set_Step_Bolus_StartTest.kt | 6 +----- ...RS_Packet_Bolus_Set_Step_Bolus_StopTest.kt | 6 +----- ...Packet_General_Get_More_InformationTest.kt | 19 ++++------------- ...et_General_Get_Shipping_InformationTest.kt | 13 ++++-------- .../comm/DanaRS_Packet_History_AlarmTest.kt | 10 ++++----- .../DanaRS_Packet_History_All_HistoryTest.kt | 9 ++++---- .../comm/DanaRS_Packet_History_BasalTest.kt | 9 ++++---- ...DanaRS_Packet_History_Blood_GlucoseTest.kt | 9 ++++---- .../comm/DanaRS_Packet_History_BolusTest.kt | 9 ++++---- .../DanaRS_Packet_History_CarbohydrateTest.kt | 9 ++++---- .../comm/DanaRS_Packet_History_DailyTest.kt | 9 ++++---- .../comm/DanaRS_Packet_History_PrimeTest.kt | 9 ++++---- .../comm/DanaRS_Packet_History_RefillTest.kt | 9 ++++---- .../comm/DanaRS_Packet_History_SuspendTest.kt | 9 ++++---- .../DanaRS_Packet_History_TemporaryTest.kt | 9 ++++---- ...aRS_Packet_Notify_Delivery_CompleteTest.kt | 6 +----- ...Packet_Notify_Delivery_Rate_DisplayTest.kt | 13 ++---------- .../DanaRS_Packet_Option_Get_Pump_TimeTest.kt | 17 ++++----------- .../DanaRS_Packet_Option_Set_Pump_TimeTest.kt | 9 ++++---- 26 files changed, 84 insertions(+), 166 deletions(-) diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index 6cd8b0e2ca..7f5806e962 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -115,7 +115,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context) danaRPlugin = DanaRPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, danaRPump, dateUtil) danaRSPlugin = DanaRSPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil) - insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsPlugin, sp, commandQueue, profileFunction, context, dateUtil) + insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsPlugin, sp, commandQueue, profileFunction, context, Config(), dateUtil) openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits, profiler, fabricPrivacy) openAPSAMAPlugin = OpenAPSAMAPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits, profiler, fabricPrivacy) safetyPlugin = SafetyPlugin(injector, aapsLogger, resourceHelper, sp, rxBus, constraintChecker, openAPSAMAPlugin, openAPSSMBPlugin, sensitivityOref1Plugin, activePlugin, hardLimits, buildHelper, treatmentsPlugin, Config()) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt index 5485c6ae9d..effe08b5f8 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPluginTest.kt @@ -63,10 +63,6 @@ class DanaRSPluginTest : DanaRSTestBase() { Mockito.`when`(resourceHelper.gs(eq(R.string.limitingbasalratio), anyObject(), anyObject())).thenReturn("limitingbasalratio") Mockito.`when`(resourceHelper.gs(eq(R.string.limitingpercentrate), anyObject(), anyObject())).thenReturn("limitingpercentrate") -<<<<<<< HEAD - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy) -======= - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, dateUtil) ->>>>>>> origin/dev + danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt index 4bcf9b4c92..4ad7df5359 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTableTest.kt @@ -1,23 +1,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm -<<<<<<< HEAD import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -======= -import android.content.Context -import com.cozmo.danar.util.BleCommandUtil ->>>>>>> origin/dev import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump -<<<<<<< HEAD import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption -======= -import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin -import info.nightscout.androidaps.utils.DateUtil ->>>>>>> origin/dev import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -30,11 +20,6 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class) class DanaRSMessageHashTableTest : DanaRSTestBase() { -<<<<<<< HEAD -======= - @Mock lateinit var context: Context - @Mock lateinit var danaRSPlugin: DanaRSPlugin ->>>>>>> origin/dev @Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var constraintChecker: ConstraintChecker @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage @@ -43,6 +28,7 @@ class DanaRSMessageHashTableTest : DanaRSTestBase() { AndroidInjector { if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil } if (it is DanaRS_Packet_Bolus_Set_Step_Bolus_Start) { it.constraintChecker = constraintChecker @@ -60,13 +46,8 @@ class DanaRSMessageHashTableTest : DanaRSTestBase() { fun runTest() { `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) -<<<<<<< HEAD val danaRSMessageHashTable = DanaRSMessageHashTable(packetInjector) val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(packetInjector, DanaRPump.CARBS, 0, 0, 0) -======= - val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, danaRSPlugin, activePlugin, constraintChecker, detailedBolusInfoStorage, injector, DateUtil(context, resourceHelper)) - val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, dateUtil, DanaRPump.CARBS, 0, 0, 0) ->>>>>>> origin/dev val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command) Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong()) } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt index 6b7835ffbd..20aaa5591d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.kt @@ -26,8 +26,11 @@ class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_APS_History_Events) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_APS_History_Events) { it.rxBus = rxBus it.resourceHelper = resourceHelper it.activePlugin = activePlugin diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt index b252c07830..36146b4ca9 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt @@ -16,8 +16,11 @@ class DanaRS_Packet_APS_Set_Event_HistoryTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_APS_Set_Event_History) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_APS_Set_Event_History) { } } } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt index 115dba03b0..56e308fc1f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest.kt @@ -14,8 +14,11 @@ class DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Basal_Get_Temporary_Basal_State) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_Basal_Get_Temporary_Basal_State) { it.danaRPump = danaRPump } } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt index 0979f33075..9d250d8872 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest.kt @@ -15,15 +15,17 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Bolus_Get_Step_Bolus_Information) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_Bolus_Get_Step_Bolus_Information) { it.danaRPump = danaRPump } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(packetInjector) val array = createArray(13, 0.toByte()) // 11 + 2 @@ -45,17 +47,6 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest : DanaRSTestBase() { Assert.assertEquals(12.5, danaRPump.lastBolusAmount, 0.01) Assert.assertEquals(25.0, danaRPump.maxBolus, 0.01) Assert.assertEquals(1.0, danaRPump.bolusStep, 0.01) -======= - val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump, dateUtil) - Assert.assertEquals(null, packet.requestParams) - // test message decoding - packet.handleMessage(createArray(34, 0.toByte())) - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(34, 1.toByte())) - val valueRequested: Int = (1 and 0x000000FF shl 8) + (1 and 0x000000FF) - Assert.assertEquals(valueRequested / 100.0, danaRPump.lastBolusAmount, 0.0) - Assert.assertEquals(true, packet.failed) ->>>>>>> origin/dev Assert.assertEquals("BOLUS__GET_STEP_BOLUS_INFORMATION", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt index da0bbc434f..b69ffe2ee3 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest.kt @@ -54,11 +54,7 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest : DanaRSTestBase() { @Before fun mock() { -<<<<<<< HEAD - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy) -======= - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, dateUtil) ->>>>>>> origin/dev + danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil) Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt index f0d67530c5..0b68225a54 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest.kt @@ -2,14 +2,10 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin -<<<<<<< HEAD -import info.nightscout.androidaps.plugins.treatments.Treatment -======= -import info.nightscout.androidaps.db.Treatment ->>>>>>> origin/dev import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt index ee57e0b1f2..7d93a60dbd 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_InformationTest.kt @@ -13,15 +13,17 @@ class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_General_Get_More_Information) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_General_Get_More_Information) { it.danaRPump = danaRPump } } } @Test fun runTest() { -<<<<<<< HEAD var packet = DanaRS_Packet_General_Get_More_Information(packetInjector) packet.handleMessage(createArray(14, 0.toByte())) @@ -48,19 +50,6 @@ class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() { Assert.assertEquals(25, lastBolus.minutes) Assert.assertEquals(1.7, danaRPump.lastBolusAmount, 0.01) -======= - var packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump, dateUtil) - Assert.assertEquals(null, packet.requestParams) - // test message decoding - // test for the length message - packet.handleMessage(createArray(13, 0.toByte())) - Assert.assertEquals(true, packet.failed) - packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump, dateUtil) - packet.handleMessage(createArray(15, 0.toByte())) - Assert.assertEquals(false, packet.failed) - packet.handleMessage(createArray(15, 161.toByte())) - Assert.assertEquals(true, packet.failed) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__GET_MORE_INFORMATION", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt index 8f2d792423..f9247b152b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_InformationTest.kt @@ -12,30 +12,25 @@ class DanaRS_Packet_General_Get_Shipping_InformationTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_General_Get_Shipping_Information) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_General_Get_Shipping_Information) { it.danaRPump = danaRPump } } } @Test fun runTest() { -<<<<<<< HEAD var packet = DanaRS_Packet_General_Get_Shipping_Information(packetInjector) -======= - var packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump, dateUtil) ->>>>>>> origin/dev Assert.assertEquals(null, packet.requestParams) // test message decoding // test for the length message packet.handleMessage(createArray(1, 0.toByte())) Assert.assertEquals(true, packet.failed) // everything ok :) -<<<<<<< HEAD packet = DanaRS_Packet_General_Get_Shipping_Information(packetInjector) -======= - packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump, dateUtil) ->>>>>>> origin/dev packet.handleMessage(createArray(18, 0.toByte())) Assert.assertEquals(false, packet.failed) Assert.assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.friendlyName) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt index 0485d8a06e..7b64daa632 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_AlarmTest.kt @@ -20,7 +20,6 @@ import java.util.* @PrepareForTest(MainApp::class) class DanaRS_Packet_History_AlarmTest : DanaRSTestBase() { -<<<<<<< HEAD @Mock lateinit var databaseHelper: DatabaseHelper @Before @@ -31,8 +30,11 @@ class DanaRS_Packet_History_AlarmTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_Alarm) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_Alarm) { it.rxBus = rxBus } } @@ -59,10 +61,6 @@ class DanaRS_Packet_History_AlarmTest : DanaRSTestBase() { Assert.assertEquals(Date(119, 1, 4, 20, 11, 35).time, packet.danaRHistoryRecord.recordDate) Assert.assertEquals("Occlusion", packet.danaRHistoryRecord.recordAlarm) Assert.assertEquals(3.56, packet.danaRHistoryRecord.recordValue, 0.01) -======= - @Test fun runTest() { - val packet = DanaRS_Packet_History_Alarm(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__ALARM", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt index 7aea8d84a9..6913ec5da1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_HistoryTest.kt @@ -12,19 +12,18 @@ class DanaRS_Packet_History_All_HistoryTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_All_History) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_All_History) { it.rxBus = rxBus } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_History_All_History(packetInjector, System.currentTimeMillis()) -======= - val packet = DanaRS_Packet_History_All_History(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__ALL_HISTORY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt index a34513a30a..227e305eba 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BasalTest.kt @@ -12,19 +12,18 @@ class DanaRS_Packet_History_BasalTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_Basal) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_Basal) { it.rxBus = rxBus } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_History_Basal(packetInjector, System.currentTimeMillis()) -======= - val packet = DanaRS_Packet_History_Basal(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__BASAL", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt index 152bc1e7fc..9c1474ebe2 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_GlucoseTest.kt @@ -12,19 +12,18 @@ class DanaRS_Packet_History_Blood_GlucoseTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_Blood_Glucose) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_Blood_Glucose) { it.rxBus = rxBus } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_History_Blood_Glucose(packetInjector, System.currentTimeMillis()) -======= - val packet = DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__BLOOD_GLUCOSE", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt index 44fede7ae9..202f52d0be 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_BolusTest.kt @@ -12,19 +12,18 @@ class DanaRS_Packet_History_BolusTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_Bolus) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_Bolus) { it.rxBus = rxBus } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_History_Bolus(packetInjector, System.currentTimeMillis()) -======= - val packet = DanaRS_Packet_History_Bolus(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__BOLUS", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt index 4e2544107e..93d40faac9 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_CarbohydrateTest.kt @@ -12,19 +12,18 @@ class DanaRS_Packet_History_CarbohydrateTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_Carbohydrate) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_Carbohydrate) { it.rxBus = rxBus } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_History_Carbohydrate(packetInjector, System.currentTimeMillis()) -======= - val packet = DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__CARBOHYDRATE", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt index 5564ba584c..00b407f32a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_DailyTest.kt @@ -12,19 +12,18 @@ class DanaRS_Packet_History_DailyTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_Daily) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_Daily) { it.rxBus = rxBus } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_History_Daily(packetInjector, System.currentTimeMillis()) -======= - val packet = DanaRS_Packet_History_Daily(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__DAILY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt index 592d45be98..59ed19ac48 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_PrimeTest.kt @@ -12,19 +12,18 @@ class DanaRS_Packet_History_PrimeTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_Prime) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_Prime) { it.rxBus = rxBus } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_History_Prime(packetInjector, System.currentTimeMillis()) -======= - val packet = DanaRS_Packet_History_Prime(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__PRIME", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt index 84ea21d91c..832d52f6e6 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_RefillTest.kt @@ -12,19 +12,18 @@ class DanaRS_Packet_History_RefillTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_Refill) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_Refill) { it.rxBus = rxBus } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_History_Refill(packetInjector, System.currentTimeMillis()) -======= - val packet = DanaRS_Packet_History_Refill(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__REFILL", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt index 7b0300aaef..f1f612fe13 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_SuspendTest.kt @@ -12,19 +12,18 @@ class DanaRS_Packet_History_SuspendTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_Suspend) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_Suspend) { it.rxBus = rxBus } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_History_Suspend(packetInjector, System.currentTimeMillis()) -======= - val packet = DanaRS_Packet_History_Suspend(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__SUSPEND", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt index e0dc156d8a..0a74282ddd 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_TemporaryTest.kt @@ -12,19 +12,18 @@ class DanaRS_Packet_History_TemporaryTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_History_Temporary) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_History_Temporary) { it.rxBus = rxBus } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_History_Temporary(packetInjector, System.currentTimeMillis()) -======= - val packet = DanaRS_Packet_History_Temporary(aapsLogger, rxBus, dateUtil, System.currentTimeMillis()) ->>>>>>> origin/dev Assert.assertEquals("REVIEW__TEMPORARY", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt index 065fc9ce6f..9e437107b1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_CompleteTest.kt @@ -2,14 +2,10 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin -<<<<<<< HEAD -import info.nightscout.androidaps.plugins.treatments.Treatment -======= -import info.nightscout.androidaps.db.Treatment ->>>>>>> origin/dev import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt index b026c4f7bf..d015035113 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_DisplayTest.kt @@ -3,17 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm import android.content.Context import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin -<<<<<<< HEAD -import info.nightscout.androidaps.plugins.treatments.Treatment -======= -import info.nightscout.androidaps.db.Treatment ->>>>>>> origin/dev import org.junit.Assert import org.junit.Before import org.junit.Test @@ -71,12 +67,7 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() { @Before fun mock() { -<<<<<<< HEAD - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy) + danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil) danaRPump.bolusingTreatment = Treatment(packetInjector) -======= - danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage, dateUtil) - danaRSPlugin.bolusingTreatment = Treatment(treatmentInjector) ->>>>>>> origin/dev } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt index 7298f57d19..1c64b0d82a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt @@ -13,15 +13,17 @@ class DanaRS_Packet_Option_Get_Pump_TimeTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Option_Get_Pump_Time) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_Option_Get_Pump_Time) { it.danaRPump = danaRPump } } } @Test fun runTest() { -<<<<<<< HEAD val packet = DanaRS_Packet_Option_Get_Pump_Time(packetInjector) val array = createArray(8, 0.toByte()) // 6 + 2 putByteToArray(array, 0, 19) // year 2019 @@ -33,17 +35,6 @@ class DanaRS_Packet_Option_Get_Pump_TimeTest : DanaRSTestBase() { packet.handleMessage(array) Assert.assertEquals(DateTime(2019, 2, 4, 20, 11, 35).millis, danaRPump.pumpTime) -======= - val packet = DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump, dateUtil) - // test params - Assert.assertEquals(null, packet.requestParams) - // test message decoding - packet.handleMessage(createArray(8, 0.toByte())) - Assert.assertEquals(false, packet.failed) - // this should fail - packet.handleMessage(createArray(8, 1.toByte())) - Assert.assertEquals(true, packet.failed) ->>>>>>> origin/dev Assert.assertEquals("OPTION__GET_PUMP_TIME", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt index f9ca5fe57d..67a9eed70d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_TimeTest.kt @@ -13,19 +13,18 @@ class DanaRS_Packet_Option_Set_Pump_TimeTest : DanaRSTestBase() { private val packetInjector = HasAndroidInjector { AndroidInjector { - if (it is DanaRS_Packet_Option_Set_Pump_Time) { + if (it is DanaRS_Packet) { it.aapsLogger = aapsLogger + it.dateUtil = dateUtil + } + if (it is DanaRS_Packet_Option_Set_Pump_Time) { } } } @Test fun runTest() { -<<<<<<< HEAD val date = Date() val packet = DanaRS_Packet_Option_Set_Pump_Time(packetInjector, date.time) -======= - val packet = DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, dateUtil, DateUtil.now()) ->>>>>>> origin/dev // test params val params = packet.requestParams Assert.assertEquals((date.year - 100 and 0xff).toByte(), params[0]) // 2019 -> 19 From 61a077542cdd0975b29b01fc76b63f8af66c6624 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 8 May 2020 11:56:02 +0200 Subject: [PATCH 044/400] DanaRPump -> danars --- .../androidaps/plugins/pump/danaR/comm/MsgBolusStop.kt | 1 - .../pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt | 2 +- app/src/main/res/values/strings.xml | 2 -- .../plugins/pump/danaR/comm/MsgSettingUserOptionsTest.kt | 1 - .../info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt | 2 +- danars/src/main/res/values/strings.xml | 2 ++ 6 files changed, 4 insertions(+), 6 deletions(-) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt (99%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStop.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStop.kt index bdabef46da..3d4fade70d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStop.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgBolusStop.kt @@ -1,6 +1,5 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm -import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt index 89b3239b11..676290cbba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt @@ -195,7 +195,7 @@ open class DanaRS_Packet_APS_History_Events( status = "PRIMECANNULA " + dateUtil.timeString(datetime) } - else -> { + else -> { aapsLogger.debug(LTag.PUMPCOMM, "Event: " + recordCode + " " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) status = "UNKNOWN " + dateUtil.timeString(datetime) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0d4218e877..35a25bca9b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -557,7 +557,6 @@ nsclientinternal_url nsclientinternal_api_secret danar_bt_name - danar_password Clear log nsclientinternal_autoscroll nsclientinternal_paused @@ -1758,7 +1757,6 @@ statuslights_copy_ns Copy NS settings (if exists)? statuslights_overview_advanced - danars_password Original skin Buttons are always displayed on bottom of screen skin diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingUserOptionsTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingUserOptionsTest.kt index f18dde576b..2be556b1e1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingUserOptionsTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingUserOptionsTest.kt @@ -5,7 +5,6 @@ import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith import org.powermock.modules.junit4.PowerMockRunner -import kotlin.experimental.and @RunWith(PowerMockRunner::class) class MsgSettingUserOptionsTest : DanaRTestBase() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt index 11f679bbb1..e33ddb1dbc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt +++ b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.danaR import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R +import info.nightscout.androidaps.danars.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.logging.AAPSLogger diff --git a/danars/src/main/res/values/strings.xml b/danars/src/main/res/values/strings.xml index f3f951e035..5cef8b70b6 100644 --- a/danars/src/main/res/values/strings.xml +++ b/danars/src/main/res/values/strings.xml @@ -2,6 +2,8 @@ danars_address danars_name + danar_password + danars_password Pairing No device found so far From 040c76d83989a72fd8b3131233d0af855f51d7b4 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 8 May 2020 14:59:30 +0200 Subject: [PATCH 045/400] move pass 1 --- .../activities/MyPreferenceFragment.kt | 1 - .../dependencyInjection/ActivitiesModule.kt | 1 + .../dependencyInjection/PluginsModule.kt | 1 - .../plugins/aps/loop/LoopPlugin.java | 89 ++++--- .../general/maintenance/ImportExportPrefs.kt | 1 - .../plugins/general/nsclient/UploadQueue.java | 3 +- .../PersistentNotificationPlugin.kt | 1 - .../plugins/pump/combo/ComboPlugin.java | 2 +- .../pump/common/PumpPluginAbstract.java | 2 +- .../pump/danaR/AbstractDanaRPlugin.java | 2 +- .../plugins/pump/danaR/DanaRPlugin.java | 2 +- .../danaR/activities/DanaRHistoryActivity.kt | 10 +- .../plugins/pump/danaR/comm/MsgHistoryAll.kt | 2 +- .../pump/danaRKorean/DanaRKoreanPlugin.java | 2 +- .../plugins/pump/danaRv2/DanaRv2Plugin.java | 4 +- .../pump/medtronic/MedtronicPumpPlugin.java | 2 +- .../pump/omnipod/OmnipodPumpPlugin.java | 1 - .../plugins/treatments/TreatmentsPlugin.java | 23 +- .../androidNotification/NotificationHolder.kt | 9 +- app/src/main/jniLibs/README.md | 1 - app/src/main/res/values/strings.xml | 41 ---- .../bolusInfo/DetailedBolusInfoStorageTest.kt | 2 - core/build.gradle | 1 + .../activities/BolusProgressHelperActivity.kt | 0 .../activities/DialogAppCompatActivity.kt | 0 .../activities/ErrorHelperActivity.kt | 5 +- .../androidaps/dialogs/BolusProgressDialog.kt | 4 +- .../androidaps/dialogs/ErrorDialog.kt | 13 +- .../androidaps/events/EventAppExit.kt | 0 .../androidaps/events/EventChargingState.kt | 0 .../events/EventConfigBuilderChange.kt | 0 .../events/EventInitializationChanged.kt | 0 .../androidaps/events/EventNetworkChange.kt | 0 .../events/EventProfileNeedsUpdate.kt | 0 .../events/EventPumpStatusChanged.kt | 4 +- .../androidaps/events/EventStatus.kt | 2 +- .../androidaps/interfaces/DanaRInterface.java | 0 .../interfaces/IobCobCalculatorInterface.java | 3 + .../androidaps/interfaces/LoopInterface.kt | 24 ++ .../interfaces/NotificationHolderInterface.kt | 10 + .../interfaces/UploadQueueInterface.java | 8 + .../plugins/aps/loop/DeviceStatus.java | 0 .../plugins/general/nsclient/NSUpload.java | 232 ++++++++++-------- .../EventDismissBolusProgressIfRunning.kt | 0 .../events/EventOverviewBolusProgress.kt | 0 .../bolusInfo/DetailedBolusInfoStorage.kt | 2 - .../receivers/NetworkChangeReceiver.kt | 0 .../receivers/ReceiverStatusStore.kt | 0 .../androidaps/services/AlarmSoundService.kt | 6 +- .../androidaps/utils/StringUtils.java | 3 - .../extensions/HexByteArrayConversion.kt | 0 .../textValidator/DefaultEditTextValidator.kt | 2 +- .../textValidator/EditTextValidator.java | 0 .../ValidatingEditTextPreference.kt | 2 +- .../validators/AlphaNumericValidator.kt | 0 .../validators/AlphaValidator.kt | 0 .../textValidator/validators/AndValidator.kt | 0 .../validators/CreditCardValidator.kt | 0 .../textValidator/validators/DateValidator.kt | 0 .../validators/DigitLengthRangeValidator.kt | 0 .../validators/DomainValidator.kt | 0 .../validators/DummyValidator.kt | 0 .../validators/EmailValidator.kt | 0 .../validators/EmptyValidator.kt | 0 .../validators/FloatNumericRangeValidator.kt | 0 .../validators/HttpsUrlValidator.kt | 0 .../validators/IpAddressValidator.kt | 0 .../validators/MinDigitLengthValidator.kt | 0 .../validators/MultiPhoneValidator.kt | 0 .../validators/MultiValidator.kt | 0 .../textValidator/validators/NotValidator.kt | 0 .../validators/NumericRangeValidator.kt | 0 .../validators/NumericValidator.kt | 0 .../textValidator/validators/OrValidator.kt | 0 .../validators/PatternValidator.kt | 0 .../validators/PersonFullNameValidator.kt | 0 .../validators/PersonNameValidator.kt | 0 .../validators/PhoneValidator.kt | 0 .../validators/PinStrengthValidator.kt | 0 .../validators/RegexpValidator.kt | 0 .../validators/SameValueValidator.kt | 0 .../textValidator/validators/Validator.kt | 0 .../validators/WebUrlValidator.kt | 0 .../main/res/layout/dialog_bolusprogress.xml | 0 .../src/main/res/layout/dialog_error.xml | 0 .../src/main/res/layout/okcancel.xml | 0 {app => core}/src/main/res/raw/error.mp3 | Bin .../src/main/res/values/fet_attrs.xml | 0 core/src/main/res/values/strings.xml | 28 +++ .../src/main/res/values/validator.xml | 0 danars/build.gradle | 3 + .../plugins/pump/danaR/DanaRFragment.kt | 0 .../plugins/pump/danaR/comm/RecordTypes.kt | 0 .../pump/danaR/events/EventDanaRNewStatus.kt | 0 .../plugins/pump/danaRS/DanaRSPlugin.kt | 51 ++-- .../danaRS/activities/EnterPinActivity.kt | 4 +- .../danaRS/comm/DanaRSMessageHashTable.kt | 0 .../pump/danaRS/comm/DanaRS_Packet.java | 0 ...RS_Packet_APS_Basal_Set_Temporary_Basal.kt | 0 .../comm/DanaRS_Packet_APS_History_Events.kt | 4 +- .../DanaRS_Packet_APS_Set_Event_History.kt | 0 .../DanaRS_Packet_Basal_Get_Basal_Rate.kt | 2 +- ...aRS_Packet_Basal_Get_Profile_Basal_Rate.kt | 0 .../DanaRS_Packet_Basal_Get_Profile_Number.kt | 0 ..._Packet_Basal_Get_Temporary_Basal_State.kt | 0 .../DanaRS_Packet_Basal_Set_Basal_Rate.kt | 0 ...Packet_Basal_Set_Cancel_Temporary_Basal.kt | 0 ...aRS_Packet_Basal_Set_Profile_Basal_Rate.kt | 0 .../DanaRS_Packet_Basal_Set_Profile_Number.kt | 0 .../DanaRS_Packet_Basal_Set_Suspend_Off.kt | 0 .../DanaRS_Packet_Basal_Set_Suspend_On.kt | 0 ...DanaRS_Packet_Basal_Set_Temporary_Basal.kt | 0 .../DanaRS_Packet_Bolus_Get_Bolus_Option.kt | 1 + .../DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt | 0 ...acket_Bolus_Get_Calculation_Information.kt | 0 ...et_Carbohydrate_Calculation_Information.kt | 0 .../DanaRS_Packet_Bolus_Get_Dual_Bolus.kt | 0 .../DanaRS_Packet_Bolus_Get_Extended_Bolus.kt | 0 ...S_Packet_Bolus_Get_Extended_Bolus_State.kt | 0 ...et_Bolus_Get_Extended_Menu_Option_State.kt | 0 .../DanaRS_Packet_Bolus_Get_Initial_Bolus.kt | 0 ...Packet_Bolus_Get_Step_Bolus_Information.kt | 0 .../DanaRS_Packet_Bolus_Set_Bolus_Option.kt | 0 .../DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt | 0 .../DanaRS_Packet_Bolus_Set_Dual_Bolus.kt | 0 .../DanaRS_Packet_Bolus_Set_Extended_Bolus.kt | 0 ..._Packet_Bolus_Set_Extended_Bolus_Cancel.kt | 0 .../DanaRS_Packet_Bolus_Set_Initial_Bolus.kt | 0 ...anaRS_Packet_Bolus_Set_Step_Bolus_Start.kt | 0 ...DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt | 0 .../comm/DanaRS_Packet_Etc_Keep_Connection.kt | 0 .../DanaRS_Packet_Etc_Set_History_Save.kt | 0 .../DanaRS_Packet_General_Delivery_Status.kt | 0 ...aRS_Packet_General_Get_More_Information.kt | 0 .../DanaRS_Packet_General_Get_Password.kt | 0 .../DanaRS_Packet_General_Get_Pump_Check.kt | 0 ...Packet_General_Get_Shipping_Information.kt | 0 ...aRS_Packet_General_Get_Shipping_Version.kt | 0 ...Packet_General_Get_Today_Delivery_Total.kt | 0 ...acket_General_Get_User_Time_Change_Flag.kt | 0 ...cket_General_Initial_Screen_Information.kt | 0 ..._Packet_General_Set_History_Upload_Mode.kt | 0 ...General_Set_User_Time_Change_Flag_Clear.kt | 0 .../danaRS/comm/DanaRS_Packet_History_.kt | 0 .../comm/DanaRS_Packet_History_Alarm.kt | 0 .../comm/DanaRS_Packet_History_All_History.kt | 0 .../comm/DanaRS_Packet_History_Basal.kt | 0 .../DanaRS_Packet_History_Blood_Glucose.kt | 0 .../comm/DanaRS_Packet_History_Bolus.kt | 0 .../DanaRS_Packet_History_Carbohydrate.kt | 0 .../comm/DanaRS_Packet_History_Daily.kt | 0 .../comm/DanaRS_Packet_History_Prime.kt | 0 .../comm/DanaRS_Packet_History_Refill.kt | 0 .../comm/DanaRS_Packet_History_Suspend.kt | 0 .../comm/DanaRS_Packet_History_Temporary.kt | 0 .../danaRS/comm/DanaRS_Packet_Notify_Alarm.kt | 0 .../DanaRS_Packet_Notify_Delivery_Complete.kt | 0 ...aRS_Packet_Notify_Delivery_Rate_Display.kt | 0 ...DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt | 0 .../DanaRS_Packet_Option_Get_Pump_Time.kt | 0 .../DanaRS_Packet_Option_Get_User_Option.kt | 0 .../DanaRS_Packet_Option_Set_Pump_Time.kt | 0 .../DanaRS_Packet_Option_Set_User_Option.kt | 0 .../comm/DanaRS_Packet_Review_Bolus_Avg.kt | 0 ...DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt | 0 .../pump/danaRS/encryption/BleEncryption.java | 0 .../plugins/pump/danaRS/services/BLEComm.kt | 0 .../pump/danaRS/services/DanaRSService.kt | 1 - .../jniLibs/arm64-v8a/libBleEncryption.so | Bin .../jniLibs/armeabi-v7a/libBleEncryption.so | Bin .../src/main/jniLibs/x86/libBleEncryption.so | Bin .../main/jniLibs/x86_64/libBleEncryption.so | Bin .../res/layout/danars_enter_pin_activity.xml | 0 danars/src/main/res/values/strings.xml | 19 +- .../src/main/res/xml/pref_danars.xml | 0 175 files changed, 349 insertions(+), 287 deletions(-) delete mode 100644 app/src/main/jniLibs/README.md rename {app => core}/src/main/java/info/nightscout/androidaps/activities/BolusProgressHelperActivity.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/activities/DialogAppCompatActivity.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt (86%) rename {app => core}/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt (98%) rename {app => core}/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt (89%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventAppExit.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventChargingState.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventProfileNeedsUpdate.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.kt (94%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventStatus.kt (84%) rename {app => core}/src/main/java/info/nightscout/androidaps/interfaces/DanaRInterface.java (100%) create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/LoopInterface.kt create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/NotificationHolderInterface.kt create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/UploadQueueInterface.java rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/aps/loop/DeviceStatus.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java (66%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventDismissBolusProgressIfRunning.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventOverviewBolusProgress.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorage.kt (95%) rename {app => core}/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/receivers/ReceiverStatusStore.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt (91%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/StringUtils.java (86%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt (99%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/EditTextValidator.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt (97%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AlphaNumericValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AlphaValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AndValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/CreditCardValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DateValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DigitLengthRangeValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DomainValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DummyValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/EmailValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/EmptyValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/FloatNumericRangeValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/HttpsUrlValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/IpAddressValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MinDigitLengthValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MultiPhoneValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MultiValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NotValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NumericRangeValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NumericValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/OrValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PatternValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PersonFullNameValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PersonNameValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PhoneValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PinStrengthValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/RegexpValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/SameValueValidator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/Validator.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/WebUrlValidator.kt (100%) rename {app => core}/src/main/res/layout/dialog_bolusprogress.xml (100%) rename {app => core}/src/main/res/layout/dialog_error.xml (100%) rename {app => core}/src/main/res/layout/okcancel.xml (100%) rename {app => core}/src/main/res/raw/error.mp3 (100%) rename {app => core}/src/main/res/values/fet_attrs.xml (100%) rename {app => core}/src/main/res/values/validator.xml (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/RecordTypes.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/events/EventDanaRNewStatus.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt (93%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt (97%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt (98%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt (98%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt (99%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt (99%) rename {app => danars}/src/main/jniLibs/arm64-v8a/libBleEncryption.so (100%) rename {app => danars}/src/main/jniLibs/armeabi-v7a/libBleEncryption.so (100%) rename {app => danars}/src/main/jniLibs/x86/libBleEncryption.so (100%) rename {app => danars}/src/main/jniLibs/x86_64/libBleEncryption.so (100%) rename {app => danars}/src/main/res/layout/danars_enter_pin_activity.xml (100%) rename {app => danars}/src/main/res/xml/pref_danars.xml (100%) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt index 0b8fc440ca..f7872853f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -41,7 +41,6 @@ import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin -import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt index f4b6e9a27a..dbfd40c33d 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt @@ -4,6 +4,7 @@ import dagger.Module import dagger.android.ContributesAndroidInjector import info.nightscout.androidaps.MainActivity import info.nightscout.androidaps.activities.* +import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity import info.nightscout.androidaps.plugins.general.maintenance.activities.PrefImportListActivity 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 de00d631e4..e7b1903389 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt @@ -41,7 +41,6 @@ import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin -import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java index c5c723731c..f04035277e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java @@ -41,9 +41,11 @@ import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.Constraint; +import info.nightscout.androidaps.interfaces.LoopInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.AAPSLogger; @@ -53,7 +55,6 @@ import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui; import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; @@ -65,15 +66,15 @@ import info.nightscout.androidaps.queue.commands.Command; import info.nightscout.androidaps.receivers.ReceiverStatusStore; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; +import info.nightscout.androidaps.utils.HardLimits; import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; -import info.nightscout.androidaps.utils.HardLimits; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.schedulers.Schedulers; @Singleton -public class LoopPlugin extends PluginBase { +public class LoopPlugin extends PluginBase implements LoopInterface { private final HasAndroidInjector injector; private final SP sp; private final RxBusWrapper rxBus; @@ -89,6 +90,7 @@ public class LoopPlugin extends PluginBase { private final IobCobCalculatorPlugin iobCobCalculatorPlugin; private final ReceiverStatusStore receiverStatusStore; private final FabricPrivacy fabricPrivacy; + private final NSUpload nsUpload; private final HardLimits hardLimits; private CompositeDisposable disposable = new CompositeDisposable(); @@ -101,21 +103,15 @@ public class LoopPlugin extends PluginBase { private boolean isSuperBolus; private boolean isDisconnected; - public class LastRun { - public APSResult request = null; - public APSResult constraintsProcessed = null; - public PumpEnactResult tbrSetByPump = null; - public PumpEnactResult smbSetByPump = null; - public String source = null; - public long lastAPSRun = DateUtil.now(); - public long lastTBREnact = 0; - public long lastSMBEnact = 0; - public long lastTBRRequest = 0; - public long lastSMBRequest = 0; - public long lastOpenModeAccept; + @Nullable public LastRun lastRun = null; + + @Nullable @Override public LastRun getLastRun() { + return lastRun; } - @Nullable public LastRun lastRun = null; + @Override public void setLastRun(@Nullable LastRun lastRun) { + this.lastRun = lastRun; + } @Inject public LoopPlugin( @@ -135,6 +131,7 @@ public class LoopPlugin extends PluginBase { IobCobCalculatorPlugin iobCobCalculatorPlugin, ReceiverStatusStore receiverStatusStore, FabricPrivacy fabricPrivacy, + NSUpload nsUpload, HardLimits hardLimits ) { super(new PluginDescription() @@ -161,6 +158,7 @@ public class LoopPlugin extends PluginBase { this.iobCobCalculatorPlugin = iobCobCalculatorPlugin; this.receiverStatusStore = receiverStatusStore; this.fabricPrivacy = fabricPrivacy; + this.nsUpload = nsUpload; this.hardLimits = hardLimits; loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L); @@ -292,7 +290,7 @@ public class LoopPlugin extends PluginBase { return true; } - public boolean isLGS(){ + public boolean isLGS() { Constraint closedLoopEnabled = constraintChecker.isClosedLoopAllowed(); Double MaxIOBallowed = constraintChecker.getMaxIOBAllowed().value(); String APSmode = sp.getString(R.string.key_aps_mode, "open"); @@ -403,18 +401,18 @@ public class LoopPlugin extends PluginBase { } if (lastRun == null) lastRun = new LastRun(); - lastRun.request = result; - lastRun.constraintsProcessed = resultAfterConstraints; - lastRun.lastAPSRun = DateUtil.now(); - lastRun.source = ((PluginBase) usedAPS).getName(); - lastRun.tbrSetByPump = null; - lastRun.smbSetByPump = null; - lastRun.lastTBREnact = 0; - lastRun.lastTBRRequest = 0; - lastRun.lastSMBEnact = 0; - lastRun.lastSMBRequest = 0; + lastRun.setRequest(result); + lastRun.setConstraintsProcessed(resultAfterConstraints); + lastRun.setLastAPSRun(DateUtil.now()); + lastRun.setSource(((PluginBase) usedAPS).getName()); + lastRun.setTbrSetByPump(null); + lastRun.setSmbSetByPump(null); + lastRun.setLastTBREnact(0); + lastRun.setLastTBRRequest(0); + lastRun.setLastSMBEnact(0); + lastRun.setLastSMBRequest(0); - NSUpload.uploadDeviceStatus(this, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore); + nsUpload.uploadDeviceStatus(this, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore); if (isSuspended()) { getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended)); @@ -437,27 +435,27 @@ public class LoopPlugin extends PluginBase { final PumpEnactResult waiting = new PumpEnactResult(getInjector()); waiting.queued = true; if (resultAfterConstraints.tempBasalRequested) - lastRun.tbrSetByPump = waiting; + lastRun.setTbrSetByPump(waiting); if (resultAfterConstraints.bolusRequested) - lastRun.smbSetByPump = waiting; + lastRun.setSmbSetByPump(waiting); rxBus.send(new EventLoopUpdateGui()); fabricPrivacy.logCustom("APSRequest"); applyTBRRequest(resultAfterConstraints, profile, new Callback() { @Override public void run() { if (result.enacted || result.success) { - lastRun.tbrSetByPump = result; - lastRun.lastTBRRequest = lastRun.lastAPSRun; - lastRun.lastTBREnact = DateUtil.now(); + lastRun.setTbrSetByPump(result); + lastRun.setLastTBRRequest(lastRun.getLastAPSRun()); + lastRun.setLastTBREnact(DateUtil.now()); rxBus.send(new EventLoopUpdateGui()); applySMBRequest(resultAfterConstraints, new Callback() { @Override public void run() { //Callback is only called if a bolus was acutally requested if (result.enacted || result.success) { - lastRun.smbSetByPump = result; - lastRun.lastSMBRequest = lastRun.lastAPSRun; - lastRun.lastSMBEnact = DateUtil.now(); + lastRun.setTbrSetByPump(result); + lastRun.setLastTBRRequest(lastRun.getLastAPSRun()); + lastRun.setLastTBREnact(DateUtil.now()); } else { new Thread(() -> { SystemClock.sleep(1000); @@ -472,8 +470,8 @@ public class LoopPlugin extends PluginBase { } }); } else { - lastRun.tbrSetByPump = null; - lastRun.smbSetByPump = null; + lastRun.setTbrSetByPump(null); + lastRun.setSmbSetByPump(null); } } else { if (resultAfterConstraints.isChangeRequested() && allowNotification) { @@ -531,15 +529,15 @@ public class LoopPlugin extends PluginBase { public void acceptChangeRequest() { Profile profile = profileFunction.getProfile(); final LoopPlugin lp = this; - applyTBRRequest(lastRun.constraintsProcessed, profile, new Callback() { + applyTBRRequest(lastRun.getConstraintsProcessed(), profile, new Callback() { @Override public void run() { if (result.enacted) { - lastRun.tbrSetByPump = result; - lastRun.lastTBRRequest = lastRun.lastAPSRun; - lastRun.lastTBREnact = DateUtil.now(); - lastRun.lastOpenModeAccept = DateUtil.now(); - NSUpload.uploadDeviceStatus(lp, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore); + lastRun.setTbrSetByPump(result); + lastRun.setLastTBRRequest(lastRun.getLastAPSRun()); + lastRun.setLastTBREnact(DateUtil.now()); + lastRun.setLastOpenModeAccept(DateUtil.now()); + nsUpload.uploadDeviceStatus(lp, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore); sp.incInt(R.string.key_ObjectivesmanualEnacts); } rxBus.send(new EventAcceptOpenLoopChange()); @@ -773,6 +771,7 @@ public class LoopPlugin extends PluginBase { event.eventType = CareportalEvent.OPENAPSOFFLINE; event.json = data.toString(); MainApp.getDbHelper().createOrUpdate(event); - NSUpload.uploadOpenAPSOffline(event); + nsUpload.uploadOpenAPSOffline(event); } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt index 4d9021bb71..4fa6c43fce 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt @@ -20,7 +20,6 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.maintenance.formats.* -import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.alertDialogs.OKDialog diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/UploadQueue.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/UploadQueue.java index 0786aae250..d9bd5a6307 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/UploadQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/UploadQueue.java @@ -16,6 +16,7 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DbRequest; +import info.nightscout.androidaps.interfaces.UploadQueueInterface; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; @@ -27,7 +28,7 @@ import info.nightscout.androidaps.utils.SP; /** * Created by mike on 21.02.2016. */ -public class UploadQueue { +public class UploadQueue implements UploadQueueInterface { private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT); public static String status() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt index e8d32ed386..ca4b8c1720 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt @@ -14,7 +14,6 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainActivity import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.db.DatabaseHelper import info.nightscout.androidaps.events.* import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index ace9df0a97..de9b4e66fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -485,7 +485,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr getAapsLogger().error("deliverTreatment: Invalid input"); return new PumpEnactResult(getInjector()).success(false).enacted(false) .bolusDelivered(0d).carbsDelivered(0d) - .comment(getResourceHelper().gs(R.string.danar_invalidinput)); + .comment(getResourceHelper().gs(R.string.invalidinput)); } else if (detailedBolusInfo.insulin > 0) { // bolus needed, ask pump to deliver it return deliverBolus(detailedBolusInfo); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java index 0bb38acb76..6d06f2e788 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java @@ -413,7 +413,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI // neither carbs nor bolus requested aapsLogger.error("deliverTreatment: Invalid input"); return new PumpEnactResult(getInjector()).success(false).enacted(false).bolusDelivered(0d).carbsDelivered(0d) - .comment(getResourceHelper().gs(R.string.danar_invalidinput)); + .comment(getResourceHelper().gs(R.string.invalidinput)); } else if (detailedBolusInfo.insulin > 0) { // bolus needed, ask pump to deliver it return deliverBolus(detailedBolusInfo); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java index 064e7c8d5b..b055cacda3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java @@ -224,7 +224,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump result.isTempCancel = false; result.enacted = false; result.success = false; - result.comment = getResourceHelper().gs(R.string.danar_invalidinput); + result.comment = getResourceHelper().gs(R.string.invalidinput); getAapsLogger().error("setTempBasalPercent: Invalid input"); return result; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java index d0d1442225..aae520eb06 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java @@ -180,7 +180,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.success = false; result.bolusDelivered = 0d; result.carbsDelivered = 0d; - result.comment = resourceHelper.gs(R.string.danar_invalidinput); + result.comment = resourceHelper.gs(R.string.invalidinput); aapsLogger.error("deliverTreatment: Invalid input"); return result; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt index 18ffab8460..eb63a70a0e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt @@ -151,7 +151,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() { holder.duration.text = DecimalFormatter.to0Decimal(record.recordDuration.toDouble()) holder.alarm.text = record.recordAlarm when (showingType) { - RecordTypes.RECORD_TYPE_ALARM -> { + RecordTypes.RECORD_TYPE_ALARM -> { holder.time.visibility = View.VISIBLE holder.value.visibility = View.VISIBLE holder.stringValue.visibility = View.GONE @@ -163,7 +163,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() { holder.alarm.visibility = View.VISIBLE } - RecordTypes.RECORD_TYPE_BOLUS -> { + RecordTypes.RECORD_TYPE_BOLUS -> { holder.time.visibility = View.VISIBLE holder.value.visibility = View.VISIBLE holder.stringValue.visibility = View.GONE @@ -175,7 +175,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() { holder.alarm.visibility = View.GONE } - RecordTypes.RECORD_TYPE_DAILY -> { + RecordTypes.RECORD_TYPE_DAILY -> { holder.dailyBasal.text = resourceHelper.gs(R.string.formatinsulinunits, record.recordDailyBasal) holder.dailyBolus.text = resourceHelper.gs(R.string.formatinsulinunits, record.recordDailyBolus) holder.dailyTotal.text = resourceHelper.gs(R.string.formatinsulinunits, record.recordDailyBolus + record.recordDailyBasal) @@ -191,7 +191,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() { holder.alarm.visibility = View.GONE } - RecordTypes.RECORD_TYPE_GLUCOSE -> { + RecordTypes.RECORD_TYPE_GLUCOSE -> { holder.value.text = Profile.toUnitsString(record.recordValue, record.recordValue * Constants.MGDL_TO_MMOLL, profileFunction.getUnits()) holder.time.visibility = View.VISIBLE holder.value.visibility = View.VISIBLE @@ -216,7 +216,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() { holder.alarm.visibility = View.GONE } - RecordTypes.RECORD_TYPE_SUSPEND -> { + RecordTypes.RECORD_TYPE_SUSPEND -> { holder.time.visibility = View.VISIBLE holder.value.visibility = View.GONE holder.stringValue.visibility = View.VISIBLE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt index 3572e0eb54..b25a5b9b1f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt @@ -136,7 +136,7 @@ open class MsgHistoryAll( danaRHistoryRecord.stringRecordValue = strRecordValue } - 17.toByte() -> failed = true + 17.toByte() -> failed = true } MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord) rxBus.send(EventDanaRSyncStatus(dateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java index 201b43f184..ad079c06ce 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java @@ -182,7 +182,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.success = false; result.bolusDelivered = 0d; result.carbsDelivered = 0d; - result.comment = resourceHelper.gs(R.string.danar_invalidinput); + result.comment = resourceHelper.gs(R.string.invalidinput); aapsLogger.error("deliverTreatment: Invalid input"); return result; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java index d9f41d0b3f..992819a136 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java @@ -200,7 +200,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.success = false; result.bolusDelivered = 0d; result.carbsDelivered = 0d; - result.comment = resourceHelper.gs(R.string.danar_invalidinput); + result.comment = resourceHelper.gs(R.string.invalidinput); aapsLogger.error("deliverTreatment: Invalid input"); return result; } @@ -301,7 +301,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.isTempCancel = false; result.enacted = false; result.success = false; - result.comment = resourceHelper.gs(R.string.danar_invalidinput); + result.comment = resourceHelper.gs(R.string.invalidinput); aapsLogger.error("setTempBasalPercent: Invalid input"); return result; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index 95a3f68c12..77df3be676 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -201,7 +201,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter if (pref.getKey().equals(getResourceHelper().gs(R.string.key_rileylink_mac_address))) { String value = sp.getStringOrNull(R.string.key_rileylink_mac_address, null); - pref.setSummary(value == null ? getResourceHelper().gs(R.string.rileylink_error_address_not_set_short) : value); + pref.setSummary(value == null ? getResourceHelper().gs(R.string.not_set_short) : value); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 0c51b5901c..8d5c7b8b41 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -24,7 +24,6 @@ import javax.inject.Inject; import javax.inject.Singleton; 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; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java index 3dd183bff6..4d28d2dcdd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java @@ -75,6 +75,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface private final ResourceHelper resourceHelper; private final ProfileFunction profileFunction; private final ActivePluginProvider activePlugin; + private final NSUpload nsUpload; private final FabricPrivacy fabricPrivacy; private final DateUtil dateUtil; @@ -101,6 +102,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface SP sp, ProfileFunction profileFunction, ActivePluginProvider activePlugin, + NSUpload nsUpload, FabricPrivacy fabricPrivacy, DateUtil dateUtil ) { @@ -122,6 +124,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface this.activePlugin = activePlugin; this.fabricPrivacy = fabricPrivacy; this.dateUtil = dateUtil; + this.nsUpload = nsUpload; } @Override @@ -553,13 +556,13 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface if (newRecordCreated) { if (extendedBolus.durationInMinutes == 0) { if (activePlugin.getActivePump().isFakingTempsByExtendedBoluses()) - NSUpload.uploadTempBasalEnd(extendedBolus.date, true, extendedBolus.pumpId); + nsUpload.uploadTempBasalEnd(extendedBolus.date, true, extendedBolus.pumpId); else - NSUpload.uploadExtendedBolusEnd(extendedBolus.date, extendedBolus.pumpId); + nsUpload.uploadExtendedBolusEnd(extendedBolus.date, extendedBolus.pumpId); } else if (activePlugin.getActivePump().isFakingTempsByExtendedBoluses()) - NSUpload.uploadTempBasalStartAbsolute(new TemporaryBasal(extendedBolus), extendedBolus.insulin); + nsUpload.uploadTempBasalStartAbsolute(new TemporaryBasal(extendedBolus), extendedBolus.insulin); else - NSUpload.uploadExtendedBolus(extendedBolus); + nsUpload.uploadExtendedBolus(extendedBolus); } return newRecordCreated; } @@ -586,11 +589,11 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface boolean newRecordCreated = MainApp.getDbHelper().createOrUpdate(tempBasal); if (newRecordCreated) { if (tempBasal.durationInMinutes == 0) - NSUpload.uploadTempBasalEnd(tempBasal.date, false, tempBasal.pumpId); + nsUpload.uploadTempBasalEnd(tempBasal.date, false, tempBasal.pumpId); else if (tempBasal.isAbsolute) - NSUpload.uploadTempBasalStartAbsolute(tempBasal, null); + nsUpload.uploadTempBasalStartAbsolute(tempBasal, null); else - NSUpload.uploadTempBasalStartPercent(tempBasal, profileFunction.getProfile(tempBasal.date)); + nsUpload.uploadTempBasalStartPercent(tempBasal, profileFunction.getProfile(tempBasal.date)); } return newRecordCreated; } @@ -641,7 +644,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface //log.debug("Adding new Treatment record" + carbsTreatment); } if (newRecordCreated && detailedBolusInfo.isValid) - NSUpload.uploadTreatmentRecord(detailedBolusInfo); + nsUpload.uploadTreatmentRecord(detailedBolusInfo); if (!allowUpdate && !creatOrUpdateResult.success) { getAapsLogger().error("Treatment could not be added to DB", new Exception()); @@ -710,7 +713,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface public void addToHistoryTempTarget(TempTarget tempTarget) { //log.debug("Adding new TemporaryBasal record" + profileSwitch.log()); MainApp.getDbHelper().createOrUpdate(tempTarget); - NSUpload.uploadTempTarget(tempTarget, profileFunction); + nsUpload.uploadTempTarget(tempTarget, profileFunction); } @Override @@ -733,7 +736,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface //log.debug("Adding new TemporaryBasal record" + profileSwitch.log()); rxBus.send(new EventDismissNotification(Notification.PROFILE_SWITCH_MISSING)); MainApp.getDbHelper().createOrUpdate(profileSwitch); - NSUpload.uploadProfileSwitch(profileSwitch); + nsUpload.uploadProfileSwitch(profileSwitch); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationHolder.kt b/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationHolder.kt index 6ee23a85f5..028c63086e 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationHolder.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationHolder.kt @@ -10,6 +10,7 @@ import androidx.core.app.TaskStackBuilder import info.nightscout.androidaps.MainActivity import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.NotificationHolderInterface import info.nightscout.androidaps.utils.resources.IconsProvider import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject @@ -20,11 +21,11 @@ class NotificationHolder @Inject constructor( private val resourceHelper: ResourceHelper, private val context: Context, private val iconsProvider: IconsProvider -) { +) : NotificationHolderInterface { - val channelID = "AndroidAPS-Ongoing" - val notificationID = 4711 - var notification: Notification + override val channelID = "AndroidAPS-Ongoing" + override val notificationID = 4711 + override lateinit var notification: Notification init { val stackBuilder = TaskStackBuilder.create(context) diff --git a/app/src/main/jniLibs/README.md b/app/src/main/jniLibs/README.md deleted file mode 100644 index 7041df4e10..0000000000 --- a/app/src/main/jniLibs/README.md +++ /dev/null @@ -1 +0,0 @@ -# danars-support-lib \ 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 35a25bca9b..b36ff01254 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -62,7 +62,6 @@ Pump integration for DANA Diabecare R pumps Pump integration for domestic DANA Diabecare R pumps Pump integration for DANA Diabecare R pumps with upgraded firmware - Pump integration for DANA Diabecare RS pumps Pump integration for people who do multiple daily injections for their diabetes therapy Pump integration for pumps which don\'t have any driver yet (Open Loop) Sensitivity is calculated the same way like Oref0, but you can specify timeframe to the past. Minimal carb absorption is calculated from max carb absorption time from preferences. @@ -161,7 +160,6 @@ Plugin is disabled Constraints violation Bolus delivery error - Tempbasal delivery error Basal value [%] Accept new temp basal: Treatment @@ -283,9 +281,6 @@ in directory: %1$s DanaR - Connecting - Connected - Disconnected Dana pump settings End User License Agreement MUST NOT BE USED TO MAKE MEDICAL DECISIONS. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. @@ -297,8 +292,6 @@ Pump IOB Daily units Last bolus - Invalid input data - Value not set properly Reload profile View profile SMS Communicator @@ -328,7 +321,6 @@ DanaR profile settings DIA [h] Duration of Insulin Activity - Failed to update basal profile Reload Uploading E bolus @@ -351,7 +343,6 @@ Glucose Refill Suspend - Connecting for %1$d s Pump password (v1 only) Pump password Wrong pump password! @@ -363,8 +354,6 @@ Occlusion Stop STOP PRESSED - Waiting for pump - Going to deliver %1$.2fU You reached allowed limit Loop has been disabled Loop has been enabled @@ -406,11 +395,9 @@ Meal Corr Actions - AndroidAPS started NS upload only (disabled sync) NS upload only. Not effective on SGV unless a local source like xDrip is selected. Not effective on Profiles while NS-Profiles is used. Pump not initialized! - Pump not initialized, profile not set! Prime/Fill Please make sure the amount matches the specification of your infusion set! Other @@ -439,7 +426,6 @@ DanaR Korean Basal rate: Setting of basal profile failed - Basal profile in pump updated Disable EasyUI mode in pump Enable extended boluses on pump Change mode from U/d to U/h on pump @@ -531,7 +517,6 @@ Setting extended bolus Stopping extended bolus Updating basal rates - Disconnecting Executing Virtual pump settings Upload status to NS @@ -609,7 +594,6 @@ COB Superbolus Log app start to NS - ns_logappstartedevent Exiting application to apply settings. DanaRv2 Which type of insulin are you using? @@ -751,20 +735,12 @@ Date INVALID Pairing - danars_pairing_key_ - danars_v3_randompairing_key_ - danars_v3_pairing_key_ - danars_v3_randomsync_key_ Empty reservoir Blood sugar measurement alert Remaining insulin level Missed bolus - DanaRS - Dana Selected pump Bolus speed - danars_bolusspeed - Set basal step to 0.01 U/h Serial number wizard_include_cob wizard_include_trend_bg @@ -938,7 +914,6 @@ History browser Notify on SMB Show SMB on the watch like a standard bolus. - ns_create_announcements_from_errors Create announcements from errors Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments) EVR @@ -994,20 +969,15 @@ SMB disabled in preferences UAM disabled in preferences UAM disabled because it rely on Oref1 sensitivity plugin - Limiting max basal rate to %1$.2f U/h because of %2$s - pump limit openapsma_max_basal openapsama_current_basal_safety_multiplier openapsama_max_daily_safety_multiplier - it must be positive value max basal multiplier max daily basal multiplier openapsma_max_iob A bolus was delivered within the last 3 minutes, skipping SMB Basal set correctly - Limiting max percent rate to %1$d%% because of %2$s treatmentssafety_maxbolus - Limiting bolus to %1$.1f U because of %2$s Limiting extended bolus to %1$.1f U because of %2$s Limiting max IOB to %1$.1f U because of %2$s Limiting carbs to %1$d g because of %2$s @@ -1044,7 +1014,6 @@ Setup Wizard FINISH Select your language - Asked: %1$.2fU Delivered: %2$.2fU Error code: %3$s First insulin increment Second insulin increment Third insulin increment @@ -1183,12 +1152,7 @@ Preferred APS mode Total Calc - Handshaking Send today\'s log files to developers along with this time. Unexpected situation. - Max bolus violation - Command error - Speed error - Insulin limit violation Minimal request change [%] Open Loop will popup new change request only if change is bigger than this value in %. Default value is 20% short_tabtitles @@ -1521,7 +1485,6 @@ TuneUp Failed Pump unreachable Pod unreachable - Not set Medtronic Pump @@ -1636,7 +1599,6 @@ Time and/or Timezone change on pump No pump selected Select units you want to display values in - ns_uploadlocalprofile Upload local profile changes to NS wear_detailediob wear_showbgi @@ -1674,7 +1636,6 @@ BG Tools Show calcuation - Error 12h 24h Automation event @@ -1741,10 +1702,8 @@ Predictions Deviation slope graphconfig - rs_loginsulinchange Log reservoir change Add \"Insulin Change\" event to careportal when detected in history - rs_logcanulachange Log canula change Add \"Site Change\" event to careportal when detected in history Authorization failed diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorageTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorageTest.kt index 28117e5583..9f483da250 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorageTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorageTest.kt @@ -2,13 +2,11 @@ package info.nightscout.androidaps.plugins.pump.common.bolusInfo import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.data.DetailedBolusInfo -import info.nightscout.androidaps.logging.AAPSLogger import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.mockito.Mock import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) diff --git a/core/build.gradle b/core/build.gradle index bde94da837..b3045c0f35 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -46,6 +46,7 @@ dependencies { implementation "androidx.preference:preference-ktx:1.1.1" implementation "androidx.activity:activity:${activityVersion}" implementation "androidx.activity:activity-ktx:${activityVersion}" + implementation 'com.google.android.material:material:1.1.0' implementation "com.google.dagger:dagger-android:$dagger_version" implementation "com.google.dagger:dagger-android-support:$dagger_version" diff --git a/app/src/main/java/info/nightscout/androidaps/activities/BolusProgressHelperActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/BolusProgressHelperActivity.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/activities/BolusProgressHelperActivity.kt rename to core/src/main/java/info/nightscout/androidaps/activities/BolusProgressHelperActivity.kt diff --git a/app/src/main/java/info/nightscout/androidaps/activities/DialogAppCompatActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/DialogAppCompatActivity.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/activities/DialogAppCompatActivity.kt rename to core/src/main/java/info/nightscout/androidaps/activities/DialogAppCompatActivity.kt diff --git a/app/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt similarity index 86% rename from app/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt rename to core/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt index ce02742381..11affb41d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt +++ b/core/src/main/java/info/nightscout/androidaps/activities/ErrorHelperActivity.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.activities import android.os.Bundle -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.dialogs.ErrorDialog import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -9,6 +9,7 @@ import javax.inject.Inject class ErrorHelperActivity : DialogAppCompatActivity() { @Inject lateinit var sp : SP + @Inject lateinit var nsUpload: NSUpload @Override override fun onCreate(savedInstanceState: Bundle?) { @@ -21,7 +22,7 @@ class ErrorHelperActivity : DialogAppCompatActivity() { errorDialog.show(supportFragmentManager, "Error") if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) { - NSUpload.uploadError(intent.getStringExtra("status")) + nsUpload.uploadError(intent.getStringExtra("status")) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt rename to core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt index 8152c25ab0..98e459a5b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt @@ -9,8 +9,8 @@ import android.view.ViewGroup import android.view.Window import android.view.WindowManager import dagger.android.support.DaggerDialogFragment -import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.BolusProgressHelperActivity +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.logging.AAPSLogger @@ -71,7 +71,7 @@ class BolusProgressDialog : DaggerDialogFragment() { savedInstanceState?.let { amount = it.getDouble("amount") } - overview_bolusprogress_title.text = resourceHelper.gs(R.string.overview_bolusprogress_goingtodeliver, amount) + overview_bolusprogress_title.text = resourceHelper.gs(R.string.goingtodeliver, amount) overview_bolusprogress_stop.setOnClickListener { aapsLogger.debug(LTag.UI, "Stop bolus delivery button pressed") stopPressed = true diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt similarity index 89% rename from app/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt rename to core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt index 07917899bf..9d2035b279 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.dialogs +import android.content.Context import android.content.Intent import android.os.Build import android.os.Bundle @@ -9,9 +10,8 @@ import android.view.ViewGroup import android.view.Window import android.view.WindowManager import dagger.android.support.DaggerDialogFragment -import info.nightscout.androidaps.MainApp -import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.services.AlarmSoundService import kotlinx.android.synthetic.main.dialog_error.* @@ -19,7 +19,6 @@ import javax.inject.Inject class ErrorDialog : DaggerDialogFragment() { @Inject lateinit var aapsLogger: AAPSLogger - @Inject lateinit var mainApp: MainApp var helperActivity: ErrorHelperActivity? = null var status: String = "" @@ -82,16 +81,16 @@ class ErrorDialog : DaggerDialogFragment() { private fun startAlarm() { if (sound != 0) { - val alarm = Intent(mainApp, AlarmSoundService::class.java) + val alarm = Intent(context, AlarmSoundService::class.java) alarm.putExtra("soundid", sound) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - mainApp.startForegroundService(alarm) + context?.startForegroundService(alarm) } else { - mainApp.startService(alarm) + context?.startService(alarm) } } } private fun stopAlarm() = - mainApp.stopService(Intent(mainApp, AlarmSoundService::class.java)) + context?.stopService(Intent(context, AlarmSoundService::class.java)) } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventAppExit.kt b/core/src/main/java/info/nightscout/androidaps/events/EventAppExit.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/events/EventAppExit.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventAppExit.kt diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventChargingState.kt b/core/src/main/java/info/nightscout/androidaps/events/EventChargingState.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/events/EventChargingState.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventChargingState.kt diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.kt b/core/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.kt diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.kt b/core/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.kt diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.kt b/core/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.kt diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventProfileNeedsUpdate.kt b/core/src/main/java/info/nightscout/androidaps/events/EventProfileNeedsUpdate.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/events/EventProfileNeedsUpdate.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventProfileNeedsUpdate.kt diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.kt b/core/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.kt similarity index 94% rename from app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.kt index cc92defe8d..0b9ce7ebf0 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.kt +++ b/core/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.events -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.utils.resources.ResourceHelper class EventPumpStatusChanged : EventStatus { @@ -46,7 +46,7 @@ class EventPumpStatusChanged : EventStatus { // status for startup wizard override fun getStatus(resourceHelper: ResourceHelper): String { return when (status) { - Status.CONNECTING -> String.format(resourceHelper.gs(R.string.danar_history_connectingfor), secondsElapsed) + Status.CONNECTING -> String.format(resourceHelper.gs(R.string.connectingfor), secondsElapsed) Status.HANDSHAKING -> resourceHelper.gs(R.string.handshaking) Status.CONNECTED -> resourceHelper.gs(R.string.connected) Status.PERFORMING -> performingAction diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventStatus.kt b/core/src/main/java/info/nightscout/androidaps/events/EventStatus.kt similarity index 84% rename from app/src/main/java/info/nightscout/androidaps/events/EventStatus.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventStatus.kt index 360b62f0e9..88c8073e69 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventStatus.kt +++ b/core/src/main/java/info/nightscout/androidaps/events/EventStatus.kt @@ -3,6 +3,6 @@ package info.nightscout.androidaps.events import info.nightscout.androidaps.utils.resources.ResourceHelper // pass string to startup wizard -abstract class EventStatus :Event() { +abstract class EventStatus : Event() { abstract fun getStatus(resourceHelper: ResourceHelper) : String } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/DanaRInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/DanaRInterface.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/interfaces/DanaRInterface.java rename to core/src/main/java/info/nightscout/androidaps/interfaces/DanaRInterface.java diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java index 2d06449082..75a57b2c07 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java @@ -2,10 +2,13 @@ package info.nightscout.androidaps.interfaces; import androidx.collection.LongSparseArray; +import info.nightscout.androidaps.data.IobTotal; +import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; public interface IobCobCalculatorInterface { LongSparseArray getAutosensDataTable(); + IobTotal[] calculateIobArrayInDia(Profile profile); String lastDataTime(); AutosensData getAutosensData(long toTime); } diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/LoopInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/LoopInterface.kt new file mode 100644 index 0000000000..2ec67b461b --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/LoopInterface.kt @@ -0,0 +1,24 @@ +package info.nightscout.androidaps.interfaces + +import info.nightscout.androidaps.data.PumpEnactResult +import info.nightscout.androidaps.plugins.aps.loop.APSResult +import info.nightscout.androidaps.utils.DateUtil + +interface LoopInterface { + + class LastRun { + var request: APSResult? = null + var constraintsProcessed: APSResult? = null + var tbrSetByPump: PumpEnactResult? = null + var smbSetByPump: PumpEnactResult? = null + var source: String? = null + var lastAPSRun = DateUtil.now() + var lastTBREnact: Long = 0 + var lastSMBEnact: Long = 0 + var lastTBRRequest: Long = 0 + var lastSMBRequest: Long = 0 + var lastOpenModeAccept: Long = 0 + } + + var lastRun: LastRun? +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/NotificationHolderInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/NotificationHolderInterface.kt new file mode 100644 index 0000000000..cbba8f326a --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/NotificationHolderInterface.kt @@ -0,0 +1,10 @@ +package info.nightscout.androidaps.interfaces + +import android.app.Notification + +interface NotificationHolderInterface { + val channelID : String + val notificationID : Int + var notification: Notification + +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/UploadQueueInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/UploadQueueInterface.java new file mode 100644 index 0000000000..d051d43501 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/UploadQueueInterface.java @@ -0,0 +1,8 @@ +package info.nightscout.androidaps.interfaces; + +import info.nightscout.androidaps.db.DbRequest; + +public interface UploadQueueInterface { + + void add(DbRequest dbRequest); +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/DeviceStatus.java b/core/src/main/java/info/nightscout/androidaps/plugins/aps/loop/DeviceStatus.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/DeviceStatus.java rename to core/src/main/java/info/nightscout/androidaps/plugins/aps/loop/DeviceStatus.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java similarity index 66% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java rename to core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java index 48a2b31b35..85331b0f3a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java @@ -1,31 +1,29 @@ package info.nightscout.androidaps.plugins.general.nsclient; +import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.content.pm.ResolveInfo; import android.os.Build; import android.os.Bundle; import androidx.annotation.Nullable; -import androidx.preference.PreferenceManager; import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import org.slf4j.Logger; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Locale; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import javax.inject.Singleton; + +import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.DbRequest; @@ -33,27 +31,50 @@ import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface; +import info.nightscout.androidaps.interfaces.LoopInterface; +import info.nightscout.androidaps.interfaces.ProfileFunction; +import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.UploadQueueInterface; +import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.plugins.aps.loop.APSResult; import info.nightscout.androidaps.plugins.aps.loop.DeviceStatus; -import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; -import info.nightscout.androidaps.interfaces.ProfileFunction; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.receivers.ReceiverStatusStore; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.JsonHelper; -import info.nightscout.androidaps.utils.SP; +import info.nightscout.androidaps.utils.resources.ResourceHelper; +import info.nightscout.androidaps.utils.sharedPreferences.SP; /** * Created by mike on 26.05.2017. */ +@Singleton public class NSUpload { - private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT); - public static void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) { + private final AAPSLogger aapsLogger; + private final ResourceHelper resourceHelper; + private final SP sp; + private final Context context; + private final UploadQueueInterface uploadQueue; + + public NSUpload( + AAPSLogger aapsLogger, + ResourceHelper resourceHelper, + SP sp, + Context context, + UploadQueueInterface uploadQueue + ) { + this.aapsLogger = aapsLogger; + this.resourceHelper = resourceHelper; + this.sp = sp; + this.context = context; + this.uploadQueue = uploadQueue; + } + + public void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) { try { JSONObject data = new JSONObject(); data.put("eventType", CareportalEvent.TEMPBASAL); @@ -63,19 +84,18 @@ public class NSUpload { if (temporaryBasal.pumpId != 0) data.put("pumpId", temporaryBasal.pumpId); data.put("created_at", DateUtil.toISOString(temporaryBasal.date)); - data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); + data.put("enteredBy", "openaps://" + "AndroidAPS"); if (originalExtendedAmount != null) data.put("originalExtendedAmount", originalExtendedAmount); // for back synchronization - UploadQueue.add(new DbRequest("dbAdd", "treatments", data)); + uploadQueue.add(new DbRequest("dbAdd", "treatments", data)); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void uploadTempBasalStartPercent(TemporaryBasal temporaryBasal, Profile profile) { + public void uploadTempBasalStartPercent(TemporaryBasal temporaryBasal, Profile profile) { try { - SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); - boolean useAbsolute = SP.getBoolean("ns_sync_use_absolute", false); + boolean useAbsolute = sp.getBoolean("ns_sync_use_absolute", false); double absoluteRate = 0; if (profile != null) { absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d; @@ -97,31 +117,31 @@ public class NSUpload { if (temporaryBasal.pumpId != 0) data.put("pumpId", temporaryBasal.pumpId); data.put("created_at", DateUtil.toISOString(temporaryBasal.date)); - data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); - UploadQueue.add(new DbRequest("dbAdd", "treatments", data)); + data.put("enteredBy", "openaps://" + "AndroidAPS"); + uploadQueue.add(new DbRequest("dbAdd", "treatments", data)); } } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void uploadTempBasalEnd(long time, boolean isFakedTempBasal, long pumpId) { + public void uploadTempBasalEnd(long time, boolean isFakedTempBasal, long pumpId) { try { JSONObject data = new JSONObject(); data.put("eventType", CareportalEvent.TEMPBASAL); data.put("created_at", DateUtil.toISOString(time)); - data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); + data.put("enteredBy", "openaps://" + "AndroidAPS"); if (isFakedTempBasal) data.put("isFakedTempBasal", isFakedTempBasal); if (pumpId != 0) data.put("pumpId", pumpId); - UploadQueue.add(new DbRequest("dbAdd", "treatments", data)); + uploadQueue.add(new DbRequest("dbAdd", "treatments", data)); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void uploadExtendedBolus(ExtendedBolus extendedBolus) { + public void uploadExtendedBolus(ExtendedBolus extendedBolus) { try { JSONObject data = new JSONObject(); data.put("eventType", CareportalEvent.COMBOBOLUS); @@ -133,14 +153,14 @@ public class NSUpload { if (extendedBolus.pumpId != 0) data.put("pumpId", extendedBolus.pumpId); data.put("created_at", DateUtil.toISOString(extendedBolus.date)); - data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); - UploadQueue.add(new DbRequest("dbAdd", "treatments", data)); + data.put("enteredBy", "openaps://" + "AndroidAPS"); + uploadQueue.add(new DbRequest("dbAdd", "treatments", data)); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void uploadExtendedBolusEnd(long time, long pumpId) { + public void uploadExtendedBolusEnd(long time, long pumpId) { try { JSONObject data = new JSONObject(); data.put("eventType", CareportalEvent.COMBOBOLUS); @@ -150,59 +170,59 @@ public class NSUpload { data.put("enteredinsulin", 0); data.put("relative", 0); data.put("created_at", DateUtil.toISOString(time)); - data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); + data.put("enteredBy", "openaps://" + "AndroidAPS"); if (pumpId != 0) data.put("pumpId", pumpId); - UploadQueue.add(new DbRequest("dbAdd", "treatments", data)); + uploadQueue.add(new DbRequest("dbAdd", "treatments", data)); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void uploadDeviceStatus(LoopPlugin loopPlugin, IobCobCalculatorPlugin iobCobCalculatorPlugin, ProfileFunction profileFunction, PumpInterface pumpInterface, ReceiverStatusStore receiverStatusStore) { + public void uploadDeviceStatus(LoopInterface loopPlugin, IobCobCalculatorInterface iobCobCalculatorPlugin, ProfileFunction profileFunction, PumpInterface pumpInterface, ReceiverStatusStore receiverStatusStore) { Profile profile = profileFunction.getProfile(); String profileName = profileFunction.getProfileName(); if (profile == null) { - log.error("Profile is null. Skipping upload"); + aapsLogger.error("Profile is null. Skipping upload"); return; } DeviceStatus deviceStatus = new DeviceStatus(); try { - LoopPlugin.LastRun lastRun = loopPlugin.lastRun; - if (lastRun != null && lastRun.lastAPSRun > System.currentTimeMillis() - 300 * 1000L) { + LoopInterface.LastRun lastRun = loopPlugin.getLastRun(); + if (lastRun != null && lastRun.getLastAPSRun() > System.currentTimeMillis() - 300 * 1000L) { // do not send if result is older than 1 min - APSResult apsResult = lastRun.request; - apsResult.json().put("timestamp", DateUtil.toISOString(lastRun.lastAPSRun)); + APSResult apsResult = lastRun.getRequest(); + apsResult.json().put("timestamp", DateUtil.toISOString(lastRun.getLastAPSRun())); deviceStatus.suggested = apsResult.json(); - deviceStatus.iob = lastRun.request.iob.json(); - deviceStatus.iob.put("time", DateUtil.toISOString(lastRun.lastAPSRun)); + deviceStatus.iob = lastRun.getRequest().iob.json(); + deviceStatus.iob.put("time", DateUtil.toISOString(lastRun.getLastAPSRun())); JSONObject requested = new JSONObject(); - if (lastRun.tbrSetByPump != null && lastRun.tbrSetByPump.enacted) { // enacted - deviceStatus.enacted = lastRun.request.json(); - deviceStatus.enacted.put("rate", lastRun.tbrSetByPump.json(profile).get("rate")); - deviceStatus.enacted.put("duration", lastRun.tbrSetByPump.json(profile).get("duration")); + if (lastRun.getTbrSetByPump() != null && lastRun.getTbrSetByPump().enacted) { // enacted + deviceStatus.enacted = lastRun.getRequest().json(); + deviceStatus.enacted.put("rate", lastRun.getTbrSetByPump().json(profile).get("rate")); + deviceStatus.enacted.put("duration", lastRun.getTbrSetByPump().json(profile).get("duration")); deviceStatus.enacted.put("recieved", true); - requested.put("duration", lastRun.request.duration); - requested.put("rate", lastRun.request.rate); + requested.put("duration", lastRun.getRequest().duration); + requested.put("rate", lastRun.getRequest().rate); requested.put("temp", "absolute"); deviceStatus.enacted.put("requested", requested); } - if (lastRun.smbSetByPump != null && lastRun.smbSetByPump.enacted) { // enacted + if (lastRun.getTbrSetByPump() != null && lastRun.getTbrSetByPump().enacted) { // enacted if (deviceStatus.enacted == null) { - deviceStatus.enacted = lastRun.request.json(); + deviceStatus.enacted = lastRun.getRequest().json(); } - deviceStatus.enacted.put("smb", lastRun.smbSetByPump.bolusDelivered); - requested.put("smb", lastRun.request.smb); + deviceStatus.enacted.put("smb", lastRun.getTbrSetByPump().bolusDelivered); + requested.put("smb", lastRun.getRequest().smb); deviceStatus.enacted.put("requested", requested); } } else { if (L.isEnabled(LTag.NSCLIENT)) - log.debug("OpenAPS data too old to upload, sending iob only"); + aapsLogger.debug("OpenAPS data too old to upload, sending iob only"); IobTotal[] iob = iobCobCalculatorPlugin.calculateIobArrayInDia(profile); if (iob.length > 0) { deviceStatus.iob = iob[0].json(); @@ -219,13 +239,13 @@ public class NSUpload { deviceStatus.uploaderBattery = batteryLevel; deviceStatus.created_at = DateUtil.toISOString(new Date()); - UploadQueue.add(new DbRequest("dbAdd", "devicestatus", deviceStatus.mongoRecord())); + uploadQueue.add(new DbRequest("dbAdd", "devicestatus", deviceStatus.mongoRecord())); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void uploadTreatmentRecord(DetailedBolusInfo detailedBolusInfo) { + public void uploadTreatmentRecord(DetailedBolusInfo detailedBolusInfo) { JSONObject data = new JSONObject(); try { data.put("eventType", detailedBolusInfo.eventType); @@ -248,21 +268,21 @@ public class NSUpload { data.put("notes", detailedBolusInfo.notes); } } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } uploadCareportalEntryToNS(data); } - public static void uploadProfileSwitch(ProfileSwitch profileSwitch) { + public void uploadProfileSwitch(ProfileSwitch profileSwitch) { try { JSONObject data = getJson(profileSwitch); uploadCareportalEntryToNS(data); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void uploadTempTarget(TempTarget tempTarget, ProfileFunction profileFunction) { + public void uploadTempTarget(TempTarget tempTarget, ProfileFunction profileFunction) { try { JSONObject data = new JSONObject(); data.put("eventType", CareportalEvent.TEMPORARYTARGET); @@ -274,21 +294,21 @@ public class NSUpload { data.put("units", profileFunction.getUnits()); } data.put("created_at", DateUtil.toISOString(tempTarget.date)); - data.put("enteredBy", MainApp.gs(R.string.app_name)); + data.put("enteredBy", "AndroidAPS"); uploadCareportalEntryToNS(data); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void updateProfileSwitch(ProfileSwitch profileSwitch) { + public void updateProfileSwitch(ProfileSwitch profileSwitch) { try { JSONObject data = getJson(profileSwitch); if (profileSwitch._id != null) { - UploadQueue.add(new DbRequest("dbUpdate", "treatments", profileSwitch._id, data)); + uploadQueue.add(new DbRequest("dbUpdate", "treatments", profileSwitch._id, data)); } } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } @@ -305,12 +325,12 @@ public class NSUpload { data.put("percentage", profileSwitch.percentage); } data.put("created_at", DateUtil.toISOString(profileSwitch.date)); - data.put("enteredBy", MainApp.gs(R.string.app_name)); + data.put("enteredBy", "AndroidAPS"); return data; } - public static void uploadCareportalEntryToNS(JSONObject data) { + public void uploadCareportalEntryToNS(JSONObject data) { try { if (data.has("preBolus") && data.has("carbs")) { JSONObject prebolus = new JSONObject(); @@ -325,48 +345,48 @@ public class NSUpload { uploadCareportalEntryToNS(prebolus); } DbRequest dbr = new DbRequest("dbAdd", "treatments", data); - log.debug("Prepared: " + dbr.log()); - UploadQueue.add(dbr); + aapsLogger.debug("Prepared: " + dbr.log()); + uploadQueue.add(dbr); } catch (Exception e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void removeCareportalEntryFromNS(String _id) { - UploadQueue.add(new DbRequest("dbRemove", "treatments", _id)); + public void removeCareportalEntryFromNS(String _id) { + uploadQueue.add(new DbRequest("dbRemove", "treatments", _id)); } - public static void uploadOpenAPSOffline(CareportalEvent event) { + public void uploadOpenAPSOffline(CareportalEvent event) { try { JSONObject data = new JSONObject(event.json); data.put("created_at", DateUtil.toISOString(event.date)); - data.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name)); - UploadQueue.add(new DbRequest("dbAdd", "treatments", data)); + data.put("enteredBy", "openaps://" + "AndroidAPS"); + uploadQueue.add(new DbRequest("dbAdd", "treatments", data)); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void uploadError(String error) { + public void uploadError(String error) { uploadError(error, new Date()); } - public static void uploadError(String error, Date date) { + public void uploadError(String error, Date date) { JSONObject data = new JSONObject(); try { data.put("eventType", "Announcement"); data.put("created_at", DateUtil.toISOString(date)); - data.put("enteredBy", SP.getString("careportal_enteredby", MainApp.gs(R.string.app_name))); + data.put("enteredBy", sp.getString("careportal_enteredby", "AndroidAPS")); data.put("notes", error); data.put("isAnnouncement", true); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } - UploadQueue.add(new DbRequest("dbAdd", "treatments", data)); + uploadQueue.add(new DbRequest("dbAdd", "treatments", data)); } - public static void uploadBg(BgReading reading, String source) { + public void uploadBg(BgReading reading, String source) { JSONObject data = new JSONObject(); try { data.put("device", source); @@ -376,56 +396,56 @@ public class NSUpload { data.put("direction", reading.direction); data.put("type", "sgv"); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } - UploadQueue.add(new DbRequest("dbAdd", "entries", data)); + uploadQueue.add(new DbRequest("dbAdd", "entries", data)); } - public static void uploadAppStart() { - if (SP.getBoolean(R.string.key_ns_logappstartedevent, true)) { + public void uploadAppStart() { + if (sp.getBoolean(R.string.key_ns_logappstartedevent, true)) { JSONObject data = new JSONObject(); try { data.put("eventType", "Note"); data.put("created_at", DateUtil.toISOString(new Date())); - data.put("notes", MainApp.gs(R.string.androidaps_start) + " - " + Build.MANUFACTURER + " " + Build.MODEL); + data.put("notes", resourceHelper.gs(R.string.androidaps_start) + " - " + Build.MANUFACTURER + " " + Build.MODEL); } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } - UploadQueue.add(new DbRequest("dbAdd", "treatments", data)); + uploadQueue.add(new DbRequest("dbAdd", "treatments", data)); } } - public static void uploadProfileStore(JSONObject profileStore) { - if (SP.getBoolean(R.string.key_ns_uploadlocalprofile, false)) { - UploadQueue.add(new DbRequest("dbAdd", "profile", profileStore)); + public void uploadProfileStore(JSONObject profileStore) { + if (sp.getBoolean(R.string.key_ns_uploadlocalprofile, false)) { + uploadQueue.add(new DbRequest("dbAdd", "profile", profileStore)); } } - public static void uploadEvent(String careportalEvent, long time, @Nullable String notes) { + public void uploadEvent(String careportalEvent, long time, @Nullable String notes) { JSONObject data = new JSONObject(); try { data.put("eventType", careportalEvent); data.put("created_at", DateUtil.toISOString(time)); - data.put("enteredBy", SP.getString("careportal_enteredby", MainApp.gs(R.string.app_name))); + data.put("enteredBy", sp.getString("careportal_enteredby", "AndroidAPS")); if (notes != null) { data.put("notes", notes); } } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } - UploadQueue.add(new DbRequest("dbAdd", "treatments", data)); + uploadQueue.add(new DbRequest("dbAdd", "treatments", data)); } - public static void removeFoodFromNS(String _id) { + public void removeFoodFromNS(String _id) { try { - UploadQueue.add(new DbRequest("dbRemove", "food", _id)); + uploadQueue.add(new DbRequest("dbRemove", "food", _id)); } catch (Exception e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void sendToXdrip(BgReading bgReading) { + public void sendToXdrip(BgReading bgReading) { final String XDRIP_PLUS_NS_EMULATOR = "com.eveningoutpost.dexdrip.NS_EMULATOR"; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US); @@ -450,22 +470,22 @@ public class NSUpload { bundle.putString("data", entriesBody.toString()); final Intent intent = new Intent(XDRIP_PLUS_NS_EMULATOR); intent.putExtras(bundle).addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - MainApp.instance().sendBroadcast(intent); - List receivers = MainApp.instance().getPackageManager().queryBroadcastReceivers(intent, 0); + context.sendBroadcast(intent); + List receivers = context.getPackageManager().queryBroadcastReceivers(intent, 0); if (receivers.size() < 1) { - log.debug("No xDrip receivers found. "); + aapsLogger.debug("No xDrip receivers found. "); } else { - log.debug(receivers.size() + " xDrip receivers"); + aapsLogger.debug(receivers.size() + " xDrip receivers"); } } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } } - public static void createNSTreatment(JSONObject data, ProfileStore profileStore, ProfileFunction profileFunction, long eventTime) { + public void createNSTreatment(JSONObject data, ProfileStore profileStore, ProfileFunction profileFunction, long eventTime) { if (JsonHelper.safeGetString(data, "eventType", "").equals(CareportalEvent.PROFILESWITCH)) { ProfileSwitch profileSwitch = profileFunction.prepareProfileSwitch( profileStore, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventDismissBolusProgressIfRunning.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventDismissBolusProgressIfRunning.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventDismissBolusProgressIfRunning.kt rename to core/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventDismissBolusProgressIfRunning.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventOverviewBolusProgress.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventOverviewBolusProgress.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventOverviewBolusProgress.kt rename to core/src/main/java/info/nightscout/androidaps/plugins/general/overview/events/EventOverviewBolusProgress.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorage.kt b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorage.kt similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorage.kt rename to core/src/main/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorage.kt index 51a63f62bb..b74fc2ac00 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorage.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/bolusInfo/DetailedBolusInfoStorage.kt @@ -2,9 +2,7 @@ package info.nightscout.androidaps.plugins.pump.common.bolusInfo import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.logging.AAPSLogger -import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.logging.StacktraceLoggerWrapper import info.nightscout.androidaps.utils.T import java.util.* import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.kt b/core/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.kt rename to core/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.kt diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/ReceiverStatusStore.kt b/core/src/main/java/info/nightscout/androidaps/receivers/ReceiverStatusStore.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/receivers/ReceiverStatusStore.kt rename to core/src/main/java/info/nightscout/androidaps/receivers/ReceiverStatusStore.kt diff --git a/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt b/core/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt similarity index 91% rename from app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt rename to core/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt index 0d261b5071..140cfda5b4 100644 --- a/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt +++ b/core/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt @@ -6,17 +6,17 @@ import android.media.AudioManager import android.media.MediaPlayer import android.os.IBinder import dagger.android.DaggerService -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.interfaces.NotificationHolderInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.utils.androidNotification.NotificationHolder import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject class AlarmSoundService : DaggerService() { @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var notificationHolder: NotificationHolder + @Inject lateinit var notificationHolder: NotificationHolderInterface private var player: MediaPlayer? = null private var resourceId = R.raw.error diff --git a/app/src/main/java/info/nightscout/androidaps/utils/StringUtils.java b/core/src/main/java/info/nightscout/androidaps/utils/StringUtils.java similarity index 86% rename from app/src/main/java/info/nightscout/androidaps/utils/StringUtils.java rename to core/src/main/java/info/nightscout/androidaps/utils/StringUtils.java index ebd31dea17..01b92a680f 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/StringUtils.java +++ b/core/src/main/java/info/nightscout/androidaps/utils/StringUtils.java @@ -1,8 +1,5 @@ package info.nightscout.androidaps.utils; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; - /** * class contains useful String functions */ diff --git a/app/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt rename to core/src/main/java/info/nightscout/androidaps/utils/extensions/HexByteArrayConversion.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt index 21146a9a72..2956a8d2b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/DefaultEditTextValidator.kt @@ -7,7 +7,7 @@ import android.text.TextUtils import android.text.TextWatcher import android.widget.EditText import com.google.android.material.textfield.TextInputLayout -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.utils.textValidator.validators.* class DefaultEditTextValidator : EditTextValidator { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/EditTextValidator.java b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/EditTextValidator.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/EditTextValidator.java rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/EditTextValidator.java diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt index 6130d7acf6..ae75641b4c 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt @@ -6,7 +6,7 @@ import android.util.AttributeSet import androidx.preference.EditTextPreference import androidx.preference.EditTextPreference.OnBindEditTextListener import androidx.preference.PreferenceViewHolder -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R class ValidatingEditTextPreference(ctx: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : EditTextPreference(ctx, attrs, defStyleAttr, defStyleRes) { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AlphaNumericValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AlphaNumericValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AlphaNumericValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AlphaNumericValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AlphaValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AlphaValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AlphaValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AlphaValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AndValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AndValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AndValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/AndValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/CreditCardValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/CreditCardValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/CreditCardValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/CreditCardValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DateValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DateValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DateValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DateValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DigitLengthRangeValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DigitLengthRangeValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DigitLengthRangeValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DigitLengthRangeValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DomainValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DomainValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DomainValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DomainValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DummyValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DummyValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DummyValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/DummyValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/EmailValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/EmailValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/EmailValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/EmailValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/EmptyValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/EmptyValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/EmptyValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/EmptyValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/FloatNumericRangeValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/FloatNumericRangeValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/FloatNumericRangeValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/FloatNumericRangeValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/HttpsUrlValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/HttpsUrlValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/HttpsUrlValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/HttpsUrlValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/IpAddressValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/IpAddressValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/IpAddressValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/IpAddressValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MinDigitLengthValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MinDigitLengthValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MinDigitLengthValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MinDigitLengthValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MultiPhoneValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MultiPhoneValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MultiPhoneValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MultiPhoneValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MultiValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MultiValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MultiValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/MultiValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NotValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NotValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NotValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NotValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NumericRangeValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NumericRangeValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NumericRangeValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NumericRangeValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NumericValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NumericValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NumericValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/NumericValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/OrValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/OrValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/OrValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/OrValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PatternValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PatternValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PatternValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PatternValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PersonFullNameValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PersonFullNameValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PersonFullNameValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PersonFullNameValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PersonNameValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PersonNameValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PersonNameValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PersonNameValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PhoneValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PhoneValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PhoneValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PhoneValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PinStrengthValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PinStrengthValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PinStrengthValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/PinStrengthValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/RegexpValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/RegexpValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/RegexpValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/RegexpValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/SameValueValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/SameValueValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/SameValueValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/SameValueValidator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/Validator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/Validator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/Validator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/Validator.kt diff --git a/app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/WebUrlValidator.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/WebUrlValidator.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/WebUrlValidator.kt rename to core/src/main/java/info/nightscout/androidaps/utils/textValidator/validators/WebUrlValidator.kt diff --git a/app/src/main/res/layout/dialog_bolusprogress.xml b/core/src/main/res/layout/dialog_bolusprogress.xml similarity index 100% rename from app/src/main/res/layout/dialog_bolusprogress.xml rename to core/src/main/res/layout/dialog_bolusprogress.xml diff --git a/app/src/main/res/layout/dialog_error.xml b/core/src/main/res/layout/dialog_error.xml similarity index 100% rename from app/src/main/res/layout/dialog_error.xml rename to core/src/main/res/layout/dialog_error.xml diff --git a/app/src/main/res/layout/okcancel.xml b/core/src/main/res/layout/okcancel.xml similarity index 100% rename from app/src/main/res/layout/okcancel.xml rename to core/src/main/res/layout/okcancel.xml diff --git a/app/src/main/res/raw/error.mp3 b/core/src/main/res/raw/error.mp3 similarity index 100% rename from app/src/main/res/raw/error.mp3 rename to core/src/main/res/raw/error.mp3 diff --git a/app/src/main/res/values/fet_attrs.xml b/core/src/main/res/values/fet_attrs.xml similarity index 100% rename from app/src/main/res/values/fet_attrs.xml rename to core/src/main/res/values/fet_attrs.xml diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index b69a63c11c..2842da7183 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -17,6 +17,34 @@ hypo_target low_mark high_mark + ns_create_announcements_from_errors + ns_logappstartedevent + ns_uploadlocalprofile + + + Error + Not set + Failed to update basal profile + Basal profile in pump updated + Invalid input data + Tempbasal delivery error + Going to deliver %1$.2fU + Waiting for pump + Connecting for %1$d s + Handshaking + Connecting + Connected + Disconnected + Disconnecting + AndroidAPS started + + + Limiting max basal rate to %1$.2f U/h because of %2$s + pump limit + Limiting max percent rate to %1$d%% because of %2$s + it must be positive value + Limiting bolus to %1$.1f U because of %2$s + Pump not initialized, profile not set! Confirmation diff --git a/app/src/main/res/values/validator.xml b/core/src/main/res/values/validator.xml similarity index 100% rename from app/src/main/res/values/validator.xml rename to core/src/main/res/values/validator.xml diff --git a/danars/build.gradle b/danars/build.gradle index 96753367b4..a80ef58dfb 100644 --- a/danars/build.gradle +++ b/danars/build.gradle @@ -50,9 +50,12 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core-ktx:1.2.0' + implementation "androidx.preference:preference-ktx:1.1.1" implementation "androidx.activity:activity:${activityVersion}" implementation "androidx.activity:activity-ktx:${activityVersion}" + // Graphview cannot be upgraded + implementation "com.jjoe64:graphview:4.0.1" implementation "com.google.dagger:dagger-android:$dagger_version" implementation "com.google.dagger:dagger-android-support:$dagger_version" diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/RecordTypes.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/RecordTypes.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/RecordTypes.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/RecordTypes.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/events/EventDanaRNewStatus.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/events/EventDanaRNewStatus.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/events/EventDanaRNewStatus.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/events/EventDanaRNewStatus.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt similarity index 93% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt index 8eb3b26d4e..2cf3e44656 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt +++ b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.kt @@ -8,8 +8,7 @@ import android.os.IBinder import android.text.format.DateFormat import androidx.preference.Preference import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.BuildConfig -import info.nightscout.androidaps.R +import info.nightscout.androidaps.danars.R import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.PumpEnactResult @@ -34,7 +33,6 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSDeviceChange import info.nightscout.androidaps.plugins.pump.danaRS.services.DanaRSService -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.* import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -56,13 +54,14 @@ class DanaRSPlugin @Inject constructor( resourceHelper: ResourceHelper, private val constraintChecker: ConstraintChecker, private val profileFunction: ProfileFunction, - private val treatmentsPlugin: TreatmentsPlugin, + private val activePluginProvider: ActivePluginProvider, private val sp: SP, commandQueue: CommandQueueProvider, private val danaRPump: DanaRPump, private val detailedBolusInfoStorage: DetailedBolusInfoStorage, private val fabricPrivacy: FabricPrivacy, - private val dateUtil: DateUtil + private val dateUtil: DateUtil, + private val config: ConfigInterface ) : PumpPluginBase(PluginDescription() .mainType(PluginType.PUMP) .fragmentClass(DanaRFragment::class.java.name) @@ -85,7 +84,7 @@ class DanaRSPlugin @Inject constructor( if (pref.key == resourceHelper.gs(R.string.key_danars_name)) { val value = sp.getStringOrNull(R.string.key_danars_name, null) pref.summary = value - ?: resourceHelper.gs(R.string.rileylink_error_address_not_set_short) + ?: resourceHelper.gs(R.string.not_set_short) } } @@ -320,7 +319,7 @@ class DanaRSPlugin @Inject constructor( 0x80 -> error = resourceHelper.gs(R.string.insulinlimitviolation) } result.comment = String.format(resourceHelper.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, error) - } else result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + } else result.comment = resourceHelper.gs(R.string.ok) aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered) result } else { @@ -328,7 +327,7 @@ class DanaRSPlugin @Inject constructor( result.success = false result.bolusDelivered = 0.0 result.carbsDelivered = 0.0 - result.comment = resourceHelper.gs(R.string.danar_invalidinput) + result.comment = resourceHelper.gs(R.string.invalidinput) aapsLogger.error("deliverTreatment: Invalid input") result } @@ -348,7 +347,7 @@ class DanaRSPlugin @Inject constructor( val doHighTemp = absoluteAfterConstrain > baseBasalRate if (doTempOff) { // If temp in progress - if (treatmentsPlugin.isTempBasalInProgress) { + if (activePluginProvider.activeTreatments.isTempBasalInProgress) { aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Stopping temp basal (doTempOff)") return cancelTempBasal(false) } @@ -366,7 +365,7 @@ class DanaRSPlugin @Inject constructor( if (percentRate > 500) // Special high temp 500/15min percentRate = 500 // Check if some temp is already in progress - val activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis()) + val activeTemp = activePluginProvider.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis()) if (activeTemp != null) { aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: currently running: $activeTemp") // Correct basal already set ? @@ -413,18 +412,18 @@ class DanaRSPlugin @Inject constructor( result.isTempCancel = false result.enacted = false result.success = false - result.comment = resourceHelper.gs(R.string.danar_invalidinput) + result.comment = resourceHelper.gs(R.string.invalidinput) aapsLogger.error("setTempBasalPercent: Invalid input") return result } if (percentAfterConstraint > pumpDescription.maxTempPercent) percentAfterConstraint = pumpDescription.maxTempPercent val now = System.currentTimeMillis() - val activeTemp = treatmentsPlugin.getTempBasalFromHistory(now) + val activeTemp = activePluginProvider.activeTreatments.getTempBasalFromHistory(now) if (activeTemp != null && activeTemp.percentRate == percentAfterConstraint && activeTemp.plannedRemainingMinutes > 4 && !enforceNew) { result.enacted = false result.success = true result.isTempCancel = false - result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.comment = resourceHelper.gs(R.string.ok) result.duration = danaRPump.tempBasalRemainingMin result.percent = danaRPump.tempBasalPercent result.isPercent = true @@ -442,7 +441,7 @@ class DanaRSPlugin @Inject constructor( if (connectionOK && danaRPump.isTempBasalInProgress && danaRPump.tempBasalPercent == percentAfterConstraint) { result.enacted = true result.success = true - result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.comment = resourceHelper.gs(R.string.ok) result.isTempCancel = false result.duration = danaRPump.tempBasalRemainingMin result.percent = danaRPump.tempBasalPercent @@ -463,7 +462,7 @@ class DanaRSPlugin @Inject constructor( if (connectionOK && danaRPump.isTempBasalInProgress && danaRPump.tempBasalPercent == percent) { result.enacted = true result.success = true - result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.comment = resourceHelper.gs(R.string.ok) result.isTempCancel = false result.duration = danaRPump.tempBasalRemainingMin result.percent = danaRPump.tempBasalPercent @@ -485,11 +484,11 @@ class DanaRSPlugin @Inject constructor( val durationInHalfHours = max(durationInMinutes / 30, 1) insulinAfterConstraint = Round.roundTo(insulinAfterConstraint, pumpDescription.extendedBolusStep) val result = PumpEnactResult(injector) - val runningEB = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) + val runningEB = activePluginProvider.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis()) if (runningEB != null && abs(runningEB.insulin - insulinAfterConstraint) < pumpDescription.extendedBolusStep) { result.enacted = false result.success = true - result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.comment = resourceHelper.gs(R.string.ok) result.duration = danaRPump.extendedBolusRemainingMinutes result.absolute = danaRPump.extendedBolusAbsoluteRate result.isPercent = false @@ -502,7 +501,7 @@ class DanaRSPlugin @Inject constructor( if (connectionOK && danaRPump.isExtendedInProgress && abs(danaRPump.extendedBolusAbsoluteRate - insulinAfterConstraint) < pumpDescription.extendedBolusStep) { result.enacted = true result.success = true - result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.comment = resourceHelper.gs(R.string.ok) result.isTempCancel = false result.duration = danaRPump.extendedBolusRemainingMinutes result.absolute = danaRPump.extendedBolusAbsoluteRate @@ -521,7 +520,7 @@ class DanaRSPlugin @Inject constructor( @Synchronized override fun cancelTempBasal(force: Boolean): PumpEnactResult { val result = PumpEnactResult(injector) - val runningTB = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis()) + val runningTB = activePluginProvider.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis()) if (runningTB != null) { danaRSService?.tempBasalStop() result.enacted = true @@ -530,7 +529,7 @@ class DanaRSPlugin @Inject constructor( return if (!danaRPump.isTempBasalInProgress) { result.success = true result.isTempCancel = true - result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.comment = resourceHelper.gs(R.string.ok) aapsLogger.debug(LTag.PUMP, "cancelRealTempBasal: OK") result } else { @@ -544,7 +543,7 @@ class DanaRSPlugin @Inject constructor( @Synchronized override fun cancelExtendedBolus(): PumpEnactResult { val result = PumpEnactResult(injector) - val runningEB = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) + val runningEB = activePluginProvider.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis()) if (runningEB != null) { danaRSService?.extendedBolusStop() result.enacted = true @@ -552,7 +551,7 @@ class DanaRSPlugin @Inject constructor( } return if (!danaRPump.isExtendedInProgress) { result.success = true - result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + result.comment = resourceHelper.gs(R.string.ok) aapsLogger.debug(LTag.PUMP, "cancelExtendedBolus: OK") result } else { @@ -581,13 +580,13 @@ class DanaRSPlugin @Inject constructor( extended.put("LastBolus", dateUtil.dateAndTimeString(danaRPump.lastBolusTime)) extended.put("LastBolusAmount", danaRPump.lastBolusAmount) } - val tb = treatmentsPlugin.getTempBasalFromHistory(now) + val tb = activePluginProvider.activeTreatments.getTempBasalFromHistory(now) if (tb != null) { extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)) extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date)) extended.put("TempBasalRemaining", tb.plannedRemainingMinutes) } - val eb = treatmentsPlugin.getExtendedBolusFromHistory(now) + val eb = activePluginProvider.activeTreatments.getExtendedBolusFromHistory(now) if (eb != null) { extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()) extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date)) @@ -636,11 +635,11 @@ class DanaRSPlugin @Inject constructor( if (danaRPump.lastBolusTime != 0L) ret += "LastBolus: ${DecimalFormatter.to2Decimal(danaRPump.lastBolusAmount)}U @${DateFormat.format("HH:mm", danaRPump.lastBolusTime)}" - val activeTemp = treatmentsPlugin.getRealTempBasalFromHistory(System.currentTimeMillis()) + val activeTemp = activePluginProvider.activeTreatments.getRealTempBasalFromHistory(System.currentTimeMillis()) if (activeTemp != null) ret += "Temp: ${activeTemp.toStringFull()}" - val activeExtendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) + val activeExtendedBolus = activePluginProvider.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis()) if (activeExtendedBolus != null) ret += "Extended: $activeExtendedBolus\n" diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt index 13eebbaa0e..2c25053da2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt +++ b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/activities/EnterPinActivity.kt @@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.pump.danaRS.activities import android.os.Bundle import android.util.Base64 -import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.NoSplashAppCompatActivity +import info.nightscout.androidaps.danars.R import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin @@ -56,7 +56,7 @@ class EnterPinActivity : NoSplashAppCompatActivity() { bleComm.finishV3Pairing() finish() } - else OKDialog.show(this, resourceHelper.gs(R.string.error), resourceHelper.gs(R.string.danar_invalidinput)) + else OKDialog.show(this, resourceHelper.gs(R.string.error), resourceHelper.gs(R.string.invalidinput)) } } cancel.setOnClickListener { finish() } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRSMessageHashTable.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt index 676290cbba..3427c46b2a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt +++ b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_Events.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.danars.R import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.ExtendedBolus @@ -195,7 +195,7 @@ open class DanaRS_Packet_APS_History_Events( status = "PRIMECANNULA " + dateUtil.timeString(datetime) } - else -> { + else -> { aapsLogger.debug(LTag.PUMPCOMM, "Event: " + recordCode + " " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) status = "UNKNOWN " + dateUtil.timeString(datetime) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_Set_Event_History.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt index b25bc2c587..76dde13995 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt +++ b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.danars.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt index 432f0792dd..252ce8761a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt +++ b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.danars.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_Connection.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_Save.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_Status.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Password.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Shipping_Version.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Alarm.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_All_History.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Basal.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Blood_Glucose.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Bolus.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Carbohydrate.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Daily.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Prime.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Refill.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Suspend.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_History_Temporary.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Alarm.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Get_User_Option.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Option_Set_User_Option.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Bolus_Avg.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Review_Get_Pump_Dec_Ratio.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/encryption/BleEncryption.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/BLEComm.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt rename to danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt index c40eda80fb..43dc6eb34e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt +++ b/danars/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.kt @@ -9,7 +9,6 @@ import android.os.SystemClock import dagger.android.DaggerService import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.PumpEnactResult diff --git a/app/src/main/jniLibs/arm64-v8a/libBleEncryption.so b/danars/src/main/jniLibs/arm64-v8a/libBleEncryption.so similarity index 100% rename from app/src/main/jniLibs/arm64-v8a/libBleEncryption.so rename to danars/src/main/jniLibs/arm64-v8a/libBleEncryption.so diff --git a/app/src/main/jniLibs/armeabi-v7a/libBleEncryption.so b/danars/src/main/jniLibs/armeabi-v7a/libBleEncryption.so similarity index 100% rename from app/src/main/jniLibs/armeabi-v7a/libBleEncryption.so rename to danars/src/main/jniLibs/armeabi-v7a/libBleEncryption.so diff --git a/app/src/main/jniLibs/x86/libBleEncryption.so b/danars/src/main/jniLibs/x86/libBleEncryption.so similarity index 100% rename from app/src/main/jniLibs/x86/libBleEncryption.so rename to danars/src/main/jniLibs/x86/libBleEncryption.so diff --git a/app/src/main/jniLibs/x86_64/libBleEncryption.so b/danars/src/main/jniLibs/x86_64/libBleEncryption.so similarity index 100% rename from app/src/main/jniLibs/x86_64/libBleEncryption.so rename to danars/src/main/jniLibs/x86_64/libBleEncryption.so diff --git a/app/src/main/res/layout/danars_enter_pin_activity.xml b/danars/src/main/res/layout/danars_enter_pin_activity.xml similarity index 100% rename from app/src/main/res/layout/danars_enter_pin_activity.xml rename to danars/src/main/res/layout/danars_enter_pin_activity.xml diff --git a/danars/src/main/res/values/strings.xml b/danars/src/main/res/values/strings.xml index 5cef8b70b6..73b38830ee 100644 --- a/danars/src/main/res/values/strings.xml +++ b/danars/src/main/res/values/strings.xml @@ -4,13 +4,28 @@ danars_name danar_password danars_password + danars_bolusspeed + danars_pairing_key_ + danars_v3_randompairing_key_ + danars_v3_pairing_key_ + danars_v3_randomsync_key_ + rs_logcanulachange + rs_loginsulinchange Pairing No device found so far Pairing OK Pairing timed out Waiting for pairing on pump - OK - Cancel + DanaRS + Dana + Pump integration for DANA Diabecare RS pumps + Max bolus violation + Command error + Speed error + Insulin limit violation + Asked: %1$.2fU Delivered: %2$.2fU Error code: %3$s + Value not set properly + Set basal step to 0.01 U/h diff --git a/app/src/main/res/xml/pref_danars.xml b/danars/src/main/res/xml/pref_danars.xml similarity index 100% rename from app/src/main/res/xml/pref_danars.xml rename to danars/src/main/res/xml/pref_danars.xml From 7708e5961a475252d3ef10af5a1ca0b3de3592a3 Mon Sep 17 00:00:00 2001 From: Philoul Date: Fri, 8 May 2020 17:56:02 +0200 Subject: [PATCH 046/400] Add new icons for basal on ovenview fragment I also add photoshop files (it's bitmap but it's easier to work with them) --- .../res/drawable-hdpi/icon_cp_basal_no_tbr.png | Bin 0 -> 17474 bytes .../drawable-hdpi/icon_cp_basal_tbr_high.png | Bin 0 -> 17644 bytes .../res/drawable-hdpi/icon_cp_basal_tbr_low.png | Bin 0 -> 17650 bytes .../res/drawable-mdpi/icon_cp_basal_no_tbr.png | Bin 0 -> 17622 bytes .../drawable-mdpi/icon_cp_basal_tbr_high.png | Bin 0 -> 17558 bytes .../res/drawable-mdpi/icon_cp_basal_tbr_low.png | Bin 0 -> 17558 bytes .../res/drawable-xhdpi/icon_cp_basal_no_tbr.png | Bin 0 -> 17522 bytes .../drawable-xhdpi/icon_cp_basal_tbr_high.png | Bin 0 -> 17703 bytes .../drawable-xhdpi/icon_cp_basal_tbr_low.png | Bin 0 -> 17692 bytes .../drawable-xxhdpi/icon_cp_basal_no_tbr.png | Bin 0 -> 17667 bytes .../drawable-xxhdpi/icon_cp_basal_tbr_high.png | Bin 0 -> 17926 bytes .../drawable-xxhdpi/icon_cp_basal_tbr_low.png | Bin 0 -> 17932 bytes .../drawable-xxxhdpi/icon_cp_basal_no_tbr.png | Bin 0 -> 15488 bytes .../drawable-xxxhdpi/icon_cp_basal_tbr_high.png | Bin 0 -> 15631 bytes .../drawable-xxxhdpi/icon_cp_basal_tbr_low.png | Bin 0 -> 15636 bytes .../main/res/drawable/icon_cp_basal_no_tbr.png | Bin 0 -> 17622 bytes .../res/drawable/icon_cp_basal_tbr_high.png | Bin 0 -> 17558 bytes .../main/res/drawable/icon_cp_basal_tbr_low.png | Bin 0 -> 17558 bytes icons/temp-basal/icon_cp_basal_100px.psd | Bin 0 -> 28136 bytes icons/temp-basal/icon_cp_basal_150px.psd | Bin 0 -> 33597 bytes icons/temp-basal/icon_cp_basal_200px.psd | Bin 0 -> 38873 bytes icons/temp-basal/icon_cp_basal_50px.psd | Bin 0 -> 23095 bytes icons/temp-basal/icon_cp_basal_75px.psd | Bin 0 -> 24072 bytes 23 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/icon_cp_basal_no_tbr.png create mode 100644 app/src/main/res/drawable-hdpi/icon_cp_basal_tbr_high.png create mode 100644 app/src/main/res/drawable-hdpi/icon_cp_basal_tbr_low.png create mode 100644 app/src/main/res/drawable-mdpi/icon_cp_basal_no_tbr.png create mode 100644 app/src/main/res/drawable-mdpi/icon_cp_basal_tbr_high.png create mode 100644 app/src/main/res/drawable-mdpi/icon_cp_basal_tbr_low.png create mode 100644 app/src/main/res/drawable-xhdpi/icon_cp_basal_no_tbr.png create mode 100644 app/src/main/res/drawable-xhdpi/icon_cp_basal_tbr_high.png create mode 100644 app/src/main/res/drawable-xhdpi/icon_cp_basal_tbr_low.png create mode 100644 app/src/main/res/drawable-xxhdpi/icon_cp_basal_no_tbr.png create mode 100644 app/src/main/res/drawable-xxhdpi/icon_cp_basal_tbr_high.png create mode 100644 app/src/main/res/drawable-xxhdpi/icon_cp_basal_tbr_low.png create mode 100644 app/src/main/res/drawable-xxxhdpi/icon_cp_basal_no_tbr.png create mode 100644 app/src/main/res/drawable-xxxhdpi/icon_cp_basal_tbr_high.png create mode 100644 app/src/main/res/drawable-xxxhdpi/icon_cp_basal_tbr_low.png create mode 100644 app/src/main/res/drawable/icon_cp_basal_no_tbr.png create mode 100644 app/src/main/res/drawable/icon_cp_basal_tbr_high.png create mode 100644 app/src/main/res/drawable/icon_cp_basal_tbr_low.png create mode 100644 icons/temp-basal/icon_cp_basal_100px.psd create mode 100644 icons/temp-basal/icon_cp_basal_150px.psd create mode 100644 icons/temp-basal/icon_cp_basal_200px.psd create mode 100644 icons/temp-basal/icon_cp_basal_50px.psd create mode 100644 icons/temp-basal/icon_cp_basal_75px.psd diff --git a/app/src/main/res/drawable-hdpi/icon_cp_basal_no_tbr.png b/app/src/main/res/drawable-hdpi/icon_cp_basal_no_tbr.png new file mode 100644 index 0000000000000000000000000000000000000000..b94fac29866402036735ff47b8b1ef3f159ca867 GIT binary patch literal 17474 zcmeI4UuYaf7{IqmOPWwDD7E+?>y@Il+1r1&_h-4glH`&m>cx=p?`t)Hb_BX?1uht7A@S#zUnN*W zFC=D_vQTb}z(r$x)rJRFCug+PBU(;R>?`)?TPku;hb~}S^_uCZtwO^0t0LKJ<`b;1 z;vOj^hP;66TzQHev24gHNrlq{F~w$bNl_6~S#gk+1X1P%nHObFlvE+7iV7RN62*Qb zC+hRC}uP2%0)#L*T*^ zdKV=@5;#HTgzSu{sA5W$guQ~O3PPUm(8SBd_ffWVqq-9Fq4+-1sw}H=dar=ib>JhW z+35qNjt*QvzvBO~lnvxcc#O=nMROo4XHk*=v#%dP{r zXw<<1qqodpixH)Hk1uPV1Fo?d;8iftGq=A$#vJ-ln&y-IrjjCsSA zlx%mpu}bN`;AkQF7~t4$H18d(RdgspTV#LpR}}O7 zy0(}%zi-YvT-28Q!$U?A(2Ezn&%iX^-Dx_1bJKWtrzy5PXc}%&3Ziv1$E>{5fBSrT z06p=7#k8WxN}lg*?zEUPTCg@(GSETN@s3BC(5ADatKobv!&paP*iMw#vnhXK+O6ox z7kcQ%M^D{ibA~r8cU{6Gy6dj7LmC9LAdo070!Ube;=(KlB#Mgw5>}zOFbe{S;v#^A zRVXgZfScT%kEC?iuivSWiQ*!FgjFam%z{9oxCkI&6^aY9Ado070!Ube;=(Kl zB#Mgw5>}zOFbe{S;v#^ARVXgZf62-hG8DH-hTPpF{FEbqBJzqy7=gxhhO+ahF z-RO@Uf9cg2t!w?U>%}~mx3XYDADFel$n4OlIy4Z|+)=KhlZd1@4{MR3wa9vAg*=n`gTaEXc_BhL@QYn@bSV3T*2II^a zu2N$Rr@QVX^pgXQYU`G(n+EOqRf^`6+aHU04K+T&xGGkoA;SsSL5gfmu~@#BV_O+% zYQx5wvdezgG?fKqPyvSPKs&yroi$;)rZZu-X|hq>wqbZr^7%&FE&E%kv~1dOH%>zY z0n(P1&ghH<*kRz9Q??2=PQ#&ew;H|U4g+*|FkC_PmX2J#)W(lj(-s1#>21usn!1@k zr|P#l4WY?d8z?Tw!EZ+31die243`|`MVU{?0@uUwGRLLaCQUS5d>?sJ(@QfEAENK0 zPZm;gBHqKnc^&wOXg2$Rp`$6Tg5@Qu+vLX|k7%f6 zBV!7*BaSpxE}3>kaWi^F83(LojHg*t7}0FZOgU?oO&g96Wa4SIRdK}1pRMws;kb&S zg27w{7WC@6CTpoupTdhpMoOqfMo1=jCdEq$m^Dh0psBDl{S zbpjYcT!t~lbF#pPF;#cvYqfXcm?gKW*kJuQoDpXUin_yv7VSN&6N)hovopd>iB{Pl?<1Ed7U z6iX7v2&xnpm1HTIl=v_fe`qFMusb1{G}A~CA=qG9Y))`!-HhZHKdYQ2d3yP^k!-_8 zB0icM`Vm)+^Os3~I%7WfOp3KTJ-1Bye-xDU>AP^N8g73VZ*9Gk6x`M4>P!44Z)4)^ znP7OFWhV=_qwpLlN3vjen!rt>P38;2Fz~MZ&;v!ia}o1a-pzA8Q`B2&;Rdx9l8*q6 z>_*ex!CHog61YY7H-8zpyeukQ*p$~JN?(srz7x*7s$XRH7=&v=Hh0HZF&uq3ppJgBpvT~B!xE36)g?N z+8IVF0>gTsM4nCgH>O?+pM1fGZfxVJTjZXh4a<3#(1^~vYvhnLf>>Zk1Q!M*q(X2Z z78nx2g#ihv5L}1_hD2~-Ktd`67h-`S5nLFMkP5+tSYSv57X~DxLU17#7!tvS0ST!P zT!;mRL~vn1LMj9oVu2wMTo{m$3c-a~U`PZP1|+0Ha3K~L62XN538@fVhy{j3aA80~ zDg+l|fgurG7?6+(!G&00NCX!KB&0%cAr=@C!G!?{sSsR<1%^a$VL(DE1Q%j~ArV{{ zkdO+&g;-!n1Q!M*q(X2Z78nx2g#ihv5L}1_hD2~-Ktd`67h-`SeJ8F?^d1Xfz?WB4 z;ae&W{(JX5@C_HVIxw84sM$3Xb?a>u_4OHeJxozk97P@3Nm26M6t&8{>*hB$QPh&D z!QA@M+Q&yf?Pr&+|K(dJkAHma>Xm=kaFx5^k?QU5_59qt?XjzF+VwkW?_Vb1^&>j> z(5cIAA9`)(j_r3pw&R&=KYZcf@%?+gIJWNVFQ0Xsk*$3_zyH|?lU;eonz=&p&NXvO zy&q57<^6nkX6vKx{O#T8yG}iS@!Qn#70W;GILLluDcvh}9N0?TJ6~S96iz>X z`pQc-zrTCdJ#imwY}4AOUthUp?bEyc4it)4)c?LN1YH3auKMc1U8x7|H6B0q*M~Rm z-F*6!+V+tXGn4y2n*a64{OqCUF8IehWBs{vva2xo!htutZ+Y`Tvg7Dndbd_sHQ#+= zj=E;qzSxmtuN>x=4Gn*L@t?AnvK>#oI6sy9Y=t%Uo+_<8)3b;D`-wwzD+F_eC*OUG Z+I%cwtkJ(%=Dm+(aN|&J--eyP{SS23YQq2k literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/icon_cp_basal_tbr_low.png b/app/src/main/res/drawable-hdpi/icon_cp_basal_tbr_low.png new file mode 100644 index 0000000000000000000000000000000000000000..23aeee14d43cc081272f4c5746839dfd1e85bbb9 GIT binary patch literal 17650 zcmeI4e{37&8OIOWu{MxY1F1m8q?=1uruKZle6f9UT(xmSGH{wDsp@Ki^?dg_xz)Zq z?k5Qu3*6G9b}D(I?B)x>BtjqSZ( zelLzqUua=sdM(+0{ND3?-+MpzKF_`H{o(yXgEx0}tm&XAs&k;fFbuzM@!l)0fS;Mc znKSTfrPaUFp{Ogb@!pqFkN)U7irR8cA1%41;;pi3){=^5mO-*!v!FLcILI^|BMYrW(G&qncZquOKi$_$R%k z$n~CtuPZ~_Yi1L)@8a(6No@8yq)Wviy4SP;EhQyJ<@gkx&L(+@Pi6Rxw7~Hq%ZV&6 zGQ1#jS(%sU@Ri7SKr3f!6?wSO7j_4K^(4k!*OFOwYHBJuB_>UKjODZ0EXxV3ATZE_ zai$GdsWXPNHV}z)3cyiq-Ewu)pgmosY)-g6iGe2H|yR42TQ z3#BzEt*MzzcZ%Z}MbdbtoJwV(1*KC^S1YH*3aF$b=~(y@>20CTo#CM~3RCL?7$t6R|0Qo5pu*{F*aGE2JZ*B#fir(;tVPF%kpj(|HBw?+r5 zx?k5U#dd&~wLOU_Z5xHKQRloEKl^1x^(tcCQ6_~2VO~Z##dEU2M>!Qp`Cjcs9JAt1DK^+V24}3JU9IJxSZUVQ6Hia)r!%$uOxEqS#frBrW_ddhW_~GWzogW?=KinLO zBDWj5n-{{~nwn!#-tIrxpN_yMULfBsNurcvo12>>hV(k9mI^xDNIKs3C>_N#A7~l4 zvt3~9Ko}S#O6=K`e_?`F_~Z*dbYmM&-D1}aEm$tOg+_GArI8@%1hK%d2rdjr$c5lS zEHEsB3j-2zA-E6=42$5xfP`EKF2n-EBDgRhAs2!RvB0nhE(}P>h2TOgFf4)#0}^r} zxDX2ri{Qe5gj@(N!~(-2xG*3g7lI41z_17|3`od@;6f}gEP@LI5^^E95DN^8;KG1} zTnH}20>dJ>Fd!ipf(x<0um~;;NXUiYLM$*Wf(ru@av``73k-|k!hnQa2rk3|!y>pa zAR!lm3$ehk2rdjr$c5lSEHEsB3j-2zA-E6=42$5xfP`EKF2n-E`cPaQ=zlDL0sp*W z3jRyQnN=S=1^?lKR{MvG6g9JsqW12isD=N)?{_I`f}^N2yC_P2grcrBANa=0eH3-s zw+0HEN9%t+`{wgseR1fzyU(q!-ShU_r|G$)nWHOa_r3bU3n#y3z4MMVmwaM&-`rdK zZa;9~(Aoa)Lj8S{&!Gb8GiM{j%c^u~_WN3J+a zJ@$nokIrvjdARe?>yID*vbFNuk=1+m&u#mlxHBeem<8HE%uiF1P1bzj(y$zyJ7)nPq1me82YZNmV?xthDf( z<0sVT?z*GnjSau;`*pH(Z2pGnk*~jYVDQAT&!_)7``+>!zWe?|t6%=+^20yeeC_wn qUvt&7UH+iU15Grx|7%Ytl|Lw)ef%d2tGs_D8Q3~lcw)=0+5ZA#DQju~ literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/icon_cp_basal_no_tbr.png b/app/src/main/res/drawable-mdpi/icon_cp_basal_no_tbr.png new file mode 100644 index 0000000000000000000000000000000000000000..a9d84303f68bc2af7358914def6e289932977b39 GIT binary patch literal 17622 zcmeI4Ux*t;7{FKRpWbO{wL(RxtSO38H~S~qY_cS&*GtbkXxj7cYOg5T&F<{o(qwnt z-Ai)kOVuJRf`|`ViimF_irV^Ai>L*qK8g6Ch=o3C5ft%76zc5X+2oRT%AG=C0!hBi ze&07Uzi+;8XZ9f{ruRLzY4qMvilR16P1a`Mx8T1w-U>hO+jaaj{2H+*54jX|`&R#b z6Lsp%dnjuB6Ju`Po3HPcRjZX%G^+u!-IfitDXP4yYb)vz;L#1RV3?K6Z|6SC(1upY z92DzZ-5v*v#^j0vW>@yjsVhg+l9t(39W8fd=%58Wh3>YRrYm>r)JEZ69)AYFI09wq7jLPwOS}J9EkL`@T zj;6~qwTY-Z_^Xmx^gLT;*-odE?c}nSv%vDDQizCRWcdBqvRFMt7Ru0nQp`mQe?Y|&GK1}9b}}biH*JFG=rgODhryR z1x(L{cKkp)d(rYNchMTsWpa6F$1o=KdeZm6@wQq6yLP=jZHOR3I?&RcTebl^16*s# zQNf-zoXUR=CJWzx0 zs=x^x!{r#RILC`JpO*!0C&$YiS7!S((Q*lV)Gf`>ms38(z(+wABv~l!nOlGg3>6U@hQ<}9mO4byKrUR(6|IQ`H;!_=&f`*3Pbk#@?FrpmhIv=pyu zw3G$F+U7!;MU5%VWM#_ZR?~9e{6IBVW(PG7w5nO^lAju5rV3ooa@oe4 zw#FBlMimAos~MWCsl{R;&vA?*YCO}(=Sxr$1tzcZlGc!NI?$yu>!&<4LL>1#1+Be( zq$hB-5&F@u*X1eG^%OXPsah}|!yivx2U1QbF$E5&OsSYxnTA>{FuDdfwZJJQT>wD{ zdd<^h9gUvuX4TLF<{wOnkk)_rUHk~DVoR>N{t*N33;9=ibY>42%02H zx{@o!qaWaARacXSAKT?V@P0IA!Lz-sD7Ha?wiU+(e)*|n;`)Pt<3hcp+WT<8LPvG2O#vHG9TVYXAziDfr*O)&&dKG7l+VQpf%iyYw2D`alqID z%$RFrcj&O!Vz_5@Q85>QR%K&oaYMh!;2eTPgG_B2YY3WZnQh>B*AY0lI25?$0I+K4 zj@6=*Vnurvt=M+cP!)eYux(R|Zs18_iYJ=#@juR01CDV$OEfjg1QUIO&3Vm9iC5!E zQYQ6n9g=d*L6eGtCN^}50VQ3Bcf)+1QF0B55kNyJN{xI$<>7u|Z9(hVW|2x-O-e)z zHo7hL7dXFchqzMpC8#RbD4u?OO^R*YNyp7!(Shr_ z4;10xQs#raTWdX2guM)KgL;d}*AU>;5u)rrA&}vr1a6Uo&0m!-v#Z)t-hylM{^6pz z6dWETfrBrW_dg@k^yPljLsvIVU+yYOR z%+Q8q-6b@mb$5*%l1>l{42j^vfP_>CF2n*uBDgRhAr*oPvA~cBE(}OWh2TOgFeHKt z0}@gpxDX2riQvM3gj5JF!~#PixG*3g6@m+~z>o+o3`j_Y;6f}gB!UYA5>g?!5DN^6 z;KG1}R0uA_0z)FWFd!inf(x<0kO(deNJxd?LM$*Of(ru@QX#ky3k-?i!hnQS2rk3| zLn62^AR!fk3$ehE2rdjrNQK}+EHEU33j-2TA-E6=42j^vfP_>CF2n*uBDgRhAr*oP zvA~cBE(}OWh2TOgFr=&E8byD|0ZjNW93A*~8@Dx{e-Qpv2dz%d)G2D^0g5{MB1Qdm z1%CfRQA->}T|P`v@=1!?X1(^zmlII;^{Lv}T=&Oce>gpIYMq zFS5<^h4;^A+uzl<{nMuZI8ZywZhzX=&y4UBZ@s#0^NB6@?>@Hi&P?riEL?c^>+fHh z-9Iw-=;d#I-hB6oPo>}Ad-AJ`Ti)Jq>g6}KzjE}B&u=@q^~1Z`e+rk*oxSwVq@pTR(bgLfs30Qd4{O)jrsL_=SG~Ga@kP literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/icon_cp_basal_tbr_high.png b/app/src/main/res/drawable-mdpi/icon_cp_basal_tbr_high.png new file mode 100644 index 0000000000000000000000000000000000000000..ece4bd4cc0eb5c7767400a7f8e7fc577b6cdb95b GIT binary patch literal 17558 zcmeI4Yitx%6vqbyff@{`0fVCB8Uv)x&SQ7>F>bfCUCLJ3+LS6K24!~UZaZOjW}KOJ zw@nPFi9w0rgG5DQ_}~{ztU+U9B*wRqM1y`(K@AX1)BpxQ5b;&-%s%dPyDL|V8qIC8 zyQg=~`QN#}x#!Hi^I;zB>s`CBWmyYFQ44$0sebq?xS#nK!|!X_w;zB%3(WLJo1!kc z-2Kd=_UyfqqB_rL1B1?BW}T!Mg`lh&Sr9B0Oz2HfiT08yD_ej=XTgxBw*|gG_JpS!2X$3k2MbYJZh+70g;kx?N!hDY7NmWceV+HVRUeT8uej<-Jo= z6&B<{0qBkm(;-%_u}rLE13V9vCwL z+YfAG#8SYTQ8<+A8;#y}`T@E+7*f!^p^&5Hn&`MknnD02tx1@Bq#WkWsq&>xKxk5z z1!M=L;3p|?0>^M6hKmjGqQr+KfotV>iQ^J%ohOLSjVDl}TnY{_ttiDMJ}?Gp-`7y3$H477244 zBa14}WW(V&v_ydkD|}SVMngG}i+WI?v@d*`^sSZ#tEHUx`M78Ab|FVY0w=2?1J5?Z zM1?TV#Kf3uMFce}Msso~UhSfR%(Sl3n(Y|Ym~YC$iR;zF_2BNQtlN4pasS(YUm0?*Q0&0@2LaR2^ha_0{Zj;yk zhKr^c`Y5oRKXKvU$mgBTz(6VXfHAQyk13Rj#mHS>TpQ{7)Y5ap@ zRe`1bnJMZ!%Ni#7KQ`tWCna9tBS~4SZ{-sE?^aSSD#I0WG|WVVY>tsbVTF--nPWgy zi2_c|iJUA{bMdcM(kZJGQc07w5>W+Pxh>WgICS6i)fca-oTqrY^|e-PtDX2X>O1-y z?;01blKywbJo8G5wK|ztfkt?oP^GdY5nU-R{D~T{FS-IL}HJ zE=S=$Qu0;7>TUwJh}MNqNyCb|`d2p;<&*P;H&Qodx~C}j(m)3FRweHP>|2c{+>Nya zHzjb1>@EJ1e1e_U=2P>I4Z53){D`-ChzcD1V|n+x66!x(AG-06L;Z*ALs8^yy5=O| zeb76Zx@KRLyZbNiPuIgIULY9}#gLd_>znH%`m_?r52iG@k+j|IkqF1-#nc~Y7`U-n zpzlB>u$(BqXH(vVDYwEWU+|$DTYKu}yJl#?a=|S$q6;pK1W6}|1%^d%VL(DI1Q%j~ zVG&#ykdO<(g;-!%1Q!M*d-Jc|{Sv zrQ*5cT@rl51+Ap}GZZy`14V7SpQ6r9!ryNxYJ{Vx?>1AE^dvG!OJ9{f z{WxkaK6(2?Pw#Q!!Rs;;XO_J6^-YU{Up-@<-gQf7?};B0D<1e}QP2FqcKSZ|i|=^# zw#Q#6zWLqWir4aZoA{yi_bs8UiHKqU2E>lK9V_VobCAVm;DbvbWG>rSqmJvnzHb?w=XeTODu z2hYwcO&q#sUT*c_kCt!#dQ*Dq$lS%LMICe8ud_>z&Z4$jtJa-rkG$-@IizPzZ)&1* H^L@Vql|()h literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/icon_cp_basal_tbr_low.png b/app/src/main/res/drawable-mdpi/icon_cp_basal_tbr_low.png new file mode 100644 index 0000000000000000000000000000000000000000..0479c1a3afeef3c6788613cf3731dcb5160a0faa GIT binary patch literal 17558 zcmeI4Ym5^`9Ke_4AbLJg3C0*%YD`qv?yK8&*R}{(;7;v9j#KVT3~YC&cMI)q-QBzP zNHnMzUx||Aiy=m%iC;8e5H%+FI5qf;kuPd6K8UD6V?@xzh(?^4Bb&Tr@cpPBuz_pI(;c~lDqZ#8urYf_S}Bh1wLASyHd6+D72gMKEHR+1TMdFUM#@ z&&JkD1+Gx-0i#CmCL65T)IX?g+NjBTY)P&=Q&*sa3UF1rUMZW7QqRVGzY3JSW;RCq zD(=Q?Y^fKJ9xAM+dn_B!Qe0v*j!)1jInGObBF!(R1&$Y4PGotJ;RS`06<(s7f3aLQ zlrpwnQU>xXn&IGo+1RM-Ruz`5)oSsY7`N;ZmX~FjOh=cRG z=_8`q>I0^ZuDU9gm#A)wAAdZSJ!o0wTqFHf2Xl+=>7g%QYnZxKbFPStsi_@tq-#pa zvMZ{aGb-u`V5{axhDD7L&2VNaJyzMW;rKvK%&_g6BUb)wRr*ZFRZR`_<#VthZWy|f z;N?=X1b9Z5^fV(T5@|**r6oqxxKv7(fd08xc`#W=M>z$xa@1|+AyVZ2~k4>Z9t)|HGded-oLNi)R zbHvI!{Ws31Yv21Y}@ z5+(9%%D*vCF2n*uBDgRhAr*oPvA~cBE(}OWh2TOgFeHKt0}@gpxDX2riQvM3gj5JF!~#Pi zxG*3g6@m+~z>o+o3`j_Y;6f}gB!UYA5>g?!5DN^6;KG1}R0uA_0z)FWFd!inf(x<0 zkO(deNJxd?LM$*Of(ru@QX#ky3k-?i!hnQS2rk3|L;6Ep-RM0Qz=SWasKK{Xy#4l( zF8GEETI(GsP}HW&C~ET^6!r6Q`1>_Qjd2w9&3cMb9;B%G*5taqD=2E#g1-FH!TLwv z?%#FIYgb?V#*xGCKX)KD7N7mu)ULgI->n_`eBWCy9zH<3hc2joC%TL0Jv4jeEA#jD z?bx>Co}SuY{dnDhxkK}w$<8)6pS|zdzFV()M0o1VSvzm*D{Oo2`>T&lRr)8G ztyirdKDvP_S2oZ6{-CjE_ph%U%g%Xe!|;t$_dWi^-2IbR+*^M7;quXoYP%m9zU27s zTUI@=ZfV!t{JG)R)~SUH9zOQrmD+{{)Ye;`Jm)t4>l;>m`ub~A_pjRC{c~4x>di^^ zgTkFJY%`DEM6LY7V&p}~=Y02$`}vP+*M?qn>qv@v@es4+(RmAh@!lNLx4b{UbJ_aa Fe+RtnL@fXS literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/icon_cp_basal_no_tbr.png b/app/src/main/res/drawable-xhdpi/icon_cp_basal_no_tbr.png new file mode 100644 index 0000000000000000000000000000000000000000..c448cadbdb3d9907936c9b9514f27ce6e3872ed7 GIT binary patch literal 17522 zcmeI4Ux?g99LHl@i@kE7h$udVErpggn?JkRKVf%!*W1=RaO-hBx$BE|HkrK(x0}Qy zce{5gR13ulRj3wTBDE@>lWda7?d`VHUaM4Q zVQ+so`Tf3=`DA{-%;X^lM|VBc-}hi2!!Z3L!{ssbt9jqM)}p`G_eaLj&pK;(kHawQ z@AbZSFs~eYfMK@(s*g{)la+@R)odhzW>#Uc)v%B^!xXl)ETGOnm#xAn-6$r0I`u(< z)wN<`LaqoEYY0y3!wWXty|8OsU6@hxT4GzNuh3GEKm)pfZ8hqKqqK?%Uspl4*UTqa z-^HCNCI-C@*~!W%J7n6Bm6I~33Syeg=98iHD}#oBH?uueS&c{tf(Wy3D_Zud<$5-m=ySKL7E!HShIHBKQ&F| zVI4N0;W{Wz>>6iHo380hn?1UW4)^RBU6V>B>bvXtHX2>KcHA9v2tk0fYos$iZ$W+x zI_9jc!X0yHC>y$s-f_nuzB&X_$i1tOtJiwyct?6dfGxd8n0KTd=Fh42r7j?7%8(6# z3(M$Rk_1WMgcK*_#zk2X(~2Z)5ky503Veqro-V#d#nklLd`v_3H8My*k+NF^G_M1V zm}jR3N*xWjfJi0o+o9u+$F#>yvtDYa-)K0u*r6eI(}ZqlX4Bam8&lvN6VglDe)bRTX4~ zTt1D;L^{uD>9oLA1pqk+(-|PZYF<|J{+U-Q@$hBRWmBE?GA@wTkhG@ea+$Osa6r~X zu9`;rK$aygt%_N#noZSUEgMS5!k0-uV(X|{f_luyJA1DSkWEPf&}1%?uco-Hloq+1 zob#-Vq-Eu74Wy#8?;^9Tt6|-7O?y5zWzod->)~$r#M0LAKwbCingwhJdRbdcglQWU z!l=%9F@E+dK=mqO$pLdvEAUI&@JU5+L6E-u@{s{(>&L=-_tBh&Mv#|bPKhX|#4xAY zQodJj5yz~#O<=>pDKsOlkrZvgr4hZA)oEZ%L9N7x(87k!kOJ@BZR+|hxM-?r%t70| zjthq-2S9gfXgj5vZ8q2_$6428fo0Wo6?pT3pEI=Jz8B?lIMA5Jzc^M6+WPfO(b!o= znAqEF%qvbxvcgA`GOBOw68qm)Qdvu-@->j*GC2r1RYNyIkU`5671T0f6;y?qnhtaE zMl0!()d{VnrKm)NV1wIYXMw}_%~*Z$tI9Qsr&nL2VjFf6)9CEz7Tz^(UM0PK#=PQ6 zO13&(Stb1+C1rd1E?ugIE9~VKy=);TN-yk%8xHELm)kEWlJ412gqlWI5q@cHs=2(=s`)}`0 zccUj>u#}PIlw9CDn>!;$^%ks8mUXm|biC~m8d?z4d8BLPo}Q7hBSB<4Rbo%4{7chr zMbEy_V>do}?iRahc*%0pEj*-~E{z3gCzu6+MR5^8!Y&jSW_Ty276cZ>MF0uAP+XV= zfkklU!!;Wt@81HHbYiQZH3%jP!+(K{|!b$G18 zFbf+QX5W5>xw43UFEGrkz%Up0GK_MRVeU5%KmPGfG^ouPslfU<; zo;vq+<-*vvZ+x;!%zXLVnU_xdb@Kd?jVtIj!KN;-QJeZPLsfB4~@17E(j>$6=HMP1w9R~Ur9n)luCDfriV z{rf}k=PIjj#G$CGZ}7frsK*|^nWFAm(uaoK;o^2#HLGz&GfN;|uUb%>qOy0^Ekzv% zE?oknx{-_hb@t^Lt!ug1Ua`m(tsXF@_f6Yi*Yv=UIz6sRTI|kzSGF!g2UXxIbiG?6d(CW&_Ep^RT&&v*NDmix(mkdPXfZA_D#s`3v=rw>KAGXaL<=0BV7Ua# zCm3FkIZ5V4I{3u$T~Nx}T3H?}YzxA{|8lW0*R^Dpt<`GrS|V=Rqbx5;63Yp!ATUsa zai$DcsWXOiTf<4yPXRcpty`{c8nowEDVY;)E*A3wg`Z$vRVxf+H~~9Ik*zBh%f~sk zosp)7Hr9k)@rS0VEU17gFkA=P@onv_G1E1jF|$L+u)AYmcuk7MFm~JVR;z78J8thJ zL=YftYv~M4S%4h`jyYkgpm!2Z<+gUScicgMt`3GPsNU9*tCu_Y@p?K!0Cl~Cnb*@W z^Vd}4QfDDFxyJ^I3kvX?7dU}qxCFyxhImotld`~V;dq(jvTTbcS}wkiqN(ZSsfZ8J z_mPr$$@c-*b>JhS+3EwPj;6Q@mY1k*iywbJrafeum3$-pb~e`*-P1$gu~#=Vv*vs; zGN(X0;z(2FvT0WpH?LQfQNUWpXqH8d5zTOA$~|VqwBh_fK9ObHHAk%c)hhQJj;k0d z=r819LtNK2Spa+~p(!epR?}%l6O&~olhOnx!vlp&i=|RImGnnmEJn>&xh|OMgqLxF zYYn>A)J!IokaUFNBg# z2%MscOiC&xn6!}OnT(k6q?Dkg#dKLoNX-y!+^h=Kr#r4`Peqn2T)2Kc+yxG-Y;AT_ zbib}yitPX|Yjd$?+J=QNtaF}?pZ&6;dKEG6D3d_TvMbuqphCOANMC*V@BlRYN6b6N zsEq+5$jdONI9cGgaE+X5xbn3+J8{giTT^V%JqlOEMUtZ7aHU0O&+3?Bi~=psHlZ~e zT1~R7ceknNAHzjcO=A++?uWQ=aB(Q`P7Q1)U$)IE9p*UgnzUkB6!o`Ts2_pA7+V0Mj2wFKVfse0a1v1AtxS{DW-fl@N*djrkV={lOGFcFa9eCGaOl1nsV{z2xk&N!>T6hR zn?WKzS_6HIca6(eNk2JrzT`@Zw>!PWO8Wnkl#S)Pa;w_h{;uBIdM7Ekt1mQe@!PzO ziMMBh>2Z;rEZmO5bEF)pg3Z$eZV_!UUy+7^ckQDdC>n!{n78w8Uh0{m5v7eA6s<`< z0ywf8&3XrG86HaD7TMqY<@qeTsx9Kp?;G|G7nKSB@Q@Zb_+fePZ(thjZZ#eGVAE)K zt0}VFZRl=Z2%@z#N36Wlf8%_*3qJ7z`IIOo#4Ov|+-k8?uY<~PL5BxP$2%UusRc%@ zJ#8&VI$B100?S6KM4nFhm!{DQpMAl{ZfyA6EppY+mgTZbXiAseHF8LTAQl)B!G!?{ zsSsR<1%^a$VL(DE1Q%j~ArV{{kdO+&g;-!n1Q!M*q(X2Z78nx2g#ihv5L}1_hD2~- zKtd`67h-`S5nLFMkP5+tSYSv57X~DxLU17#7!tvS0ST!PT!;mRL~vn1LMj9oVu2wM zTo{m$3c-a~U`PZP1|+0Ha3K~L62XN538@fVhy{j3aA80~Dg+l|fgurG7?6+(!G&00 zNCX!KB&0%cAr=@C!G!?{sSsR<1%^a$VL(DE1Q%j~ArV{{kdO+&g;-!nABd|9y~zR? z@bwin_@0WVHeH{B@3^4VzQH0zP2WyYhaRM;^ULt}EsC1pC~Dyzijp6ts7>bKyMMin zqSid!U+5mH|MBg!bNhEGxBTL@yPw%Oo)y|{7T+*)(% zKG(T%%N-lz4|F~M)~f^EZ=96$fpbfzKVx4wHFN9V4{y!<;5TnBC7&3OuH3qA-9v|{ z>px9jaYbRZ{JSI7YovGQpE~uEHy2-f>>t}6ojCs9V3nPD_1o`Ub^rDwUzz{a{_!iH z9i4x0;aTR~Z)cy6ee3AI=I7OCK=H`tt6z9>?~_Lp%iOuIO}uz~PRoDy&(FR4&BfXI z*)>bX9`=z}UI70Fo7UfY@WjbK9XP#jX>sel{EZ#P(P?}m2WL;-d*R`==YRhC`OV+i z|GA!HfBEU|vkM#8+~W6M+Ov1h`?u^k`ozMSU%ohV_QXvOeSWQd?D&Pvm3M0Q9auj7 zO!qg8k(nEE_m9Fc-1qf!o8Q|w_0_p!FYQ=YdgE_Dd;6Nlmwr6``xCvdOg{3%mv5d~ xlQ=lHpdJfR9om4fg|dD4^m>X~US3O$_r|yX^U!styjPj@_YM@EzU!U`{sS=Qd{w3qE*#at%5*DD2-a7R)qwb5(WNBQ6<`-NQj5jCP+yj3PK9aLxHBDsakZM zU9Wfcd^QFy2*$C~aIOCZ}uN#ma&TXXoObgIrRAf|+kJE`%lo$DUl3zm$93Nx37|X{P zUXZwy#EZ25ipX71N?Te{8p^Ks!@*yf$e80)B$ln!YSCIOYFeW#pGu`zPGALrff|fG zX*f!qG3;9#PMUtQz*a52;^?M9yMC2|S#>gzh#M$)`Qs{Af8~JD95%l z($v7FQngCnrD-Y)N}vo3$A)%%Tf54b>6rGI*&$@m-7zqnlUy!{-S&FR<+h=1XWaxu z;3I8oY3C;^fE@z1S+!KKZUPSF)^?+}ogsi`2g4OqZ|lg>iyi#9Jslx{y57Oe?P-{K zYpOBTX$Vc~vw-4&EPTrXCvXfGW4L6V7bQL}3EXWQFL7L&ZP7%_#q*IfHN7|)@*#RY zx+Oj(iQTtxa9#U8LYl2UVCra!qhNUn>$dpu#$#G}(=5r2^xN26TXbI^{k1K+p_w&% zb!be!cF2*YN=4HuD~_y}l~KS}jL|fU8bg}F%9Q%dl4-&50Xddt+ck%*ywxfV8n&Yt zDj3Ylupz4Jnj{vJTq05EW|Ex3F=8q%GKCbJl{iq6Kmb4!xrBG+xm?(Mp6jfsR^5#A zU2D*_rY4i!agJjYQRA6HJf4D*C@^uAPiTcitO$yM>yY_8*LPVutd>eCq~l(_8$wCM z1WwUJraM)LF$p2gGf6S&O5K8%5EDfumTF#o8#nVp4d}LGT9ctA3m2|e4>y5t&uwjX zlytAIRTRqxZq{ZZ&9n^)VNmB>8!!7MMRhBpY%3E$OS5y@&_xAyzL7qE`tSfW{D;gt z$Eb|~!_Uhgr#MOAn>p2RgIw%cib$F1p-Qy7)ns3zF z)7EmNqh+Yaw``PZq#{ ze_v69|5Nc{eARCF9~ZPbFqEUHsjpJh^!F(0pR@4$uM}0~DC*1(ijp3qsGH4)w;x(h zQ44-GnC;EikDYt-;E!+oCN+KPfkf~7*WI-E{7t3j4t()DiwB) z)xZDGufFt+XCFHMd*B$>bFSIuZr(eFa__${7AO7`u{p1&@<;&=W z3$wRRFIlo|!F>5kWm$Xg?5fODM!tXRb3Oe>K0Ncs>B;EkoqIRryuSJ9`)k+!?cb;G`C#80=f3~i1^G`u zePX(Kjf)rm@QU*ElEatp|7AV>(2TtF%d?Yv6Y|OB(=W`NX7}zqvgd)v&Tg%qVlOTl zv3rbP{H1zqX4BE*Fa7J4nJ15|?LRzq%eQK~p8WabrSV1ftB;;s_xagNC(izE%eD`? uAesdc`gS+Ii>XCEc*2BpIXkIQ*!kH literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/icon_cp_basal_no_tbr.png b/app/src/main/res/drawable-xxhdpi/icon_cp_basal_no_tbr.png new file mode 100644 index 0000000000000000000000000000000000000000..0c7597c5ea29c8227772cb21995929afc61217a7 GIT binary patch literal 17667 zcmeI4Uu+ab9LE=pTH6p25s4DB9x>6t-u}D2>uv51X|LEC51Y2yBhi$--MMzd-R`lw z?OpqzsPLfRgFX;qh&~Y&NHHPd0Zr5rd{T)ffWbdeG%*s?7-LY0;_Tku-1d40gDo1& zTyni%XMVr$?0jbCw=?^&&-HJ3aB=&c?G!~V?(0ntz~5c&x9vvwH?e5T8TfN^sduAI zQ60Cr-$m5Rdsa|X*Dv}|*2!ibmQ}MDRx~pQ!j)nPdc&}_m6D=v1`eGAqq>m{{q)v5 zAzIgxpxXuHL1 zi1u8Z&B@R@w?R6a>8HC*3(!(nVpNWg(6M-!m-t90zlIh#USv6uF~=#%EL$#@!(}mSTB9rv>{V5f znob(ns->44-85)dSIL>8Y8 zO=Up=6oKK`Fph5;R~j=N(;hQhG>NKPHVnrklR<4az20K6Y16jTGXW9!NSj95Lz5-I z4glL6w^YzG0lTuQS?_IU0MthZLkhY#6>{`^3mvznB?M5>TZFka)i7^PRfjqOp~>AA zP#lnk-;}@!9K(qW*Ez&XG9QrzZZ*ft9G74lJnPfN)5w^bo}Ub8NS;O%&Sja8uIAvp z_B8^YjT&(2Xo{m?sRVr+biDqU){toyQq|?xUz=NWcQ<|Cux@B(*}gx}C*M0Dq^WY= zw2F$8(u>L{U`xhmf~^+@JkiXQyUl`W!Ty1im|&X~2co>$D)$+-qZlgaOQ&E#Sl2a~ zi$%12j^`Ma7db}ZBQd5^0(nMMfhMY)DsoZ9yYfsX7(PcjZK~t$iu0v4D6Paqfm1Yz ziN<1Usv&eo-jS z57OrjA0FeXejvPc8|5)z`0Em_DNYvn+M23Ld0wqWY%}ka6$`8zg)`zZi=rwxJEFC+ zI;I$-KufVTXtjdIkOb@AZ3_BT7&O&1CV=H!!N9@Ep};#eu2L{U|ci{`j^ zE{k|ERNYp2ii z&ZKy|(|K-h{y&SdI(=tvRckx!xm#QJBn5Z%>FODa}_e@c3rHM?vwHo;V;J|J);U27IcqoBeWN-7A z;uGwgvVfXbmvs*pg>moj5ED4~VR`qj9~!J~4BdF?&|r0AXg%^#Lw8bw-&#X)Aj&=c zSI?(|@QD{lMI}j;5^Q5}V?@7R0flT@hX+a9Js$BA?3fqSSkp9eW6Q`ujUQQEDuJg{ z-q2J_;j=IJ*o{Tc-2$VAj${jO)Vs9s+DMT!f>7WX1Q!k^F6gURKg+mGX5L^fa zjzMtYP(nTg7eaw!5L`HvkPpFyP~aE@7Y-%lLvSG!I0nImLkam1TnGh@L2%(vLOui+ zLV;rtTsV}F55a{{;1~oK4khG6a3K^p2Em0x3HcCQ2nCKoaN$rwJ_Hv+fnyL{IFyhN z!G%!Z7z7s%CFDbJArv?U!G%K!`4C(P1&%>*;ZQ<81Q$YqV-Q?8l#ma>g;3xa1Q!k^ zF6gURKg+mGX5L^fajzMtYP(nTg7eaw!ToPA%{Y@6YfUmD8!}nCY_}#fB@EsSl z+B=Y;sHuA?YU{HU_4`Hm`#nXCa};%U6Gh3pDe4aMrIBOnDQeO4ed%>WmDA@=CLiiv zw`}Xj>|gX7pPX*{@!grdpC0Kr^g^MhaA@1I<Bi}QzxNSKxw)%DwVeUQnjh8S~_O5vT2O{=(Ge18%q(LR`1=} zez`afJQljC)3apz>-WCj?|bj_-uL_7yFdKZ6`h~Ewc(xyilT1qXb*S6@9oz6=9}PW zaMs#Cz^_{}?W+xnntO-!o<;5W{@oPSdQt0+n$gJTB}GrUWmS&>cOjL5+R&_}kdc)E zVA3&=(9+GW^9K*PXiaT)tr8<#B+~}^wf1#cuyS2zx3X?P38=1?P(!dFK?f;d%5))> zOdC?6*=75cpllVhF4|Tx2bx_=tp@36WCh)(X8|p`MMmLxFYOPwd6D-v@r|^H;{}!z zSYBXwkHiHeUZg88SEvC>!K@mWy28sV&B0&Iu7179>Fmq)h|b@pbJo{ko|e{rWUbqUvcIhI0~$ptkGwHslJ!Lm9w!0YlGa6|ig&4rNij(HmwLn3x?5S5UpKBU6h{O#KK1ADxPvQkh6qj&tT~~ZKG;4jp&{1Vm#`5CSt?^@zN6&WadNNcFzZKQBMYpxl zpIN1)RXuMkc8sZ_?Qo@t$>bj2o|_CO_hL8Xo|}*KjRZPzzC{WW}1KyU_{{c`kFjkEG~$4&m$41 z`4rb-UCCJyS8=UE*Ro&maIz{gzCcW1{2njQG>J`?ixAgQOC`crrI^b)U!j5B?}j>oex)nwUbM$6-mv`YZ*Cf04r*nUDdEfi4f&E z%f^m=Nmi_k7&7ERpa$7VWfPr3b`>LS>h$3;F8g75vQ+|0{aurvWz#8rZ#>~ONh^q!S|Ih_D%h^<1a7Sx&qS!=gRY9GR+DSCPkWX)@s zIJh`uxKo3y5sGK^6pdn>Hg#IgWRjX9TkC-xOskcB55;qJpbj7Z#j&a&t6j?yb@UQp zqCa9|o^epBN>h{1%W;e>syq|(dIL}rJ&af3{c6lF#6jF&omLW*R+h6{{&@u`A$BnR!`VdkG9rL3ZCl2 zbuh8cOfWpIa*~C|QFxD(99viQHi4T&Ys@EwVa2=ppI#`+opYGi^RCbIPEl^9 zj+=?rs^lGj9jDQtb+MMFO(+I;(3 z^@tbYz-*)1n!1*&r?qs{R4mJ(;&?h`PffWLKKp`?-B|S8%`t1}N_PE)i6LEo-^e3r z1fjqY2re8-NQdA;C~yRV3x^WYA-E6<9D(4%p@eh@E`$O{Ah>WSAsvDXp}-LcE*wfo zhu}gea0G%2hZ52uxDW~)f#AZSgmeflgaSt(xNs;T9fAv?z!3;897;%s;6f;H1cD2P z64D{K5DFZD;KHGVbOzz0<0xvhkD{dS zQPf@fw|ZY)PEoVBc7&I97fzl1^}(-wCvorLGpAo1lkfQWbAP|-#+6U^J+Zv&#`A|; z!y|X@eRLR;7`=I}{P@Vc1xIJg_cd;sbF>u}!18$uVEKKGu)H-| zM{&ym{#pMA7vCF64E{uVDAjXfBRjj)bK9Ov2RFR+)2ztX2tPyFMa8$my^%DFQ*#&wzjQ5Ll4d`zSD3nQ9Ao0Zo@mm z!_ThScK69$qmSfXI`t`fud-zS4=)xME}XOf+dmym=al^;ojr$M9Dd`~Cr1C_{@~re z%unns?fLFK(cP;SZ5eONnHO$*_rk{buX=uW`l!CS^u=v);pEB39!hm@yKCf)6Qge@ zx9@o6_qnlR@1iX^{k=VZDvZZRo<6yIxOi;N-tqOh=cNmqdyn5x9NzWG<8Y$a?0D`f lQ+dVVH=h0&T(zar4b;L&%ly21Neup^I+k^Y_qFzI{5SSj>G%Ku literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/icon_cp_basal_tbr_low.png b/app/src/main/res/drawable-xxhdpi/icon_cp_basal_tbr_low.png new file mode 100644 index 0000000000000000000000000000000000000000..b7df0c266a22675e7fe71f85649846df7b7e0b95 GIT binary patch literal 17932 zcmeI4e{2)y8ON`!RhA`R;XcjqNkO zbL<2R<%ShJ9^_s;g4 zi{q4+g>LHfTC)B4eV^z1-urpq_qq4IKm26l@`vV>-Cage)SQO;U=#e_ZM7sX3+Nz8O>2Ro#u2EBfc2&3-iQ}EL$5+9-c&C>yr|lf?U^xfN zI~d+Ba6W-|(fOAxPzEi3N{$Lm!Mc2N@K>d+UDuNW%Vsi}ij1Q|O|`MS&*x(~J8QQy z(1X#s61tdW655iSNI@qEG%2Mdbwy3khOQV<(|V=NW;BFe`F_QdsG)?GX9p>=Sux4- z6&zbCNS07cGM$Qc)VoO znqJ!p5#*7UjMQ4Xl7MXjnwm~YptcisWl5>tYkCuy7#$2L=w4DtSEAGC7&X&E09j?4 zFry|HX3nYHQ2QY?p(X`H9R%S!VCU={!#Nnv+rqm9-YM9*2RL5fI6qtDIWb*KjgTrU z(JqUI%hYfi8V>IR9GusA4U1>723$I_sEb%CR^K8Wvp;I8MO9;g-12KI%q_a6hQ4o& zl91Jm_8m)~^4=C9SrVdZDlX~)B`&rBHkoMivlE3DPc$=y8a1Y-VE;hC;b%(~TcXU_ zDl{ZCT}()zAsB!K6^bGY4vzyw9TABUIZ~VRbqQh5^wuDcSUXfB@wiII) zALHt;w}}!mQ<|z*G+j+~S*9$UxMn_V1{)`r7Aj(jnb(qHN(08Kt+W-EElPwa&lxf1 z>K8=G$cO<=>;$r(om4h)Q7A4Sq)Z(?JjOYFOZfC{WZFR@zb?_5;siTiSW`JE(`$MW zO^xaqF$JpH;EcG&qR0tOj+kCqY8Ml2Kn}14XoZ5}5I<|&ZDPuoFldsR=maVKItC6- z4iVm|K}rimQ)-+>Yn;|qT1+NmiXt=w%$uV9z>SlaS7w@)vq7i2#GUGwB?oLQ14WJZJ0Gq!p7ALrg`=%wom|5i- z$hyWWnG|n#I>YVF|Ieb#P2b5|)xr*Y>ekjcNx@xx zFn5cuGd3p1o(V3GYwTpOHDp9w^S@or_7*;ZQ<81Q$YqV-Q?8l#ma>g;3xa z1Q!k^F6gURKg+mGX5L^fajzMtYP(nTg7eaw!5L`HvkPpFyP~aE@7Y-%lLvSG! zIK~&^Dx3Hx3y^?+Uy*_TQ}N8LyZYdNT+mW|Q;4Fvmr~T@KcuM9tML0nib``7HN1hM zguN6sU){O>jXH|Dc~?WQswMmG$7fDHx(?j)_+K*n_RgyPb>Ft?!;J%XuABSH2eu5| z+qY?U?<*tojyzTN)YE6S>WiN_SNDYHy`?=ravvIX{ON@4>AIb6htK!ew`ZNOwY|3E z;*n=Z-zv91`&RVz+Ogk#lP>S+?SC*lYqq$x|BiXbZWb4p_k8VGH7tPTcg%z3i_2ko zb-09MT^y`jab&#t<^2Og7lyVh`R>aNhgXlc#+mE^_JxZt3=My9&*=lJ*Pb0e_0r1T zRq>V`=f#EF|Gwk1JxhDizxd~&=T=`Boqu|8_`==m!|T_a{qdE#S1;fB_UAu;WXti6 zqj$Z(ZRA()-qjTz_+D7r^4{3m?(pgTE4ClnGra2$b1n`o8yXzlmfrk^da7!qH7(I& zUEd$y6xl8O^_Dl+OW*kD^ytZlmMr-5?fb`u&Odnh(x#COffEO>oc!dqWpDOZMCumo ze06K@4>q6sR5_|Co2$Az7v0v*4*qP>ZUaHdu3|I6aD02N*5Bj0+;{Hv7u(AHi7 z-!ED*|C1{R_aE#T`PVzY{LQ@2hqr_uD}Qn0roq+&t3KM(zvshKw;$h@?qtt+MCRC{ zp;sRr+xd@A`@26rkn~?Zf9a3W!;dUvyT%(1H&^n~_Ca;%?9fWr+Rp}#|Lw~23vV0$ x$-OVV^YHz94_)u@TD!9Ecn6%jSFhee>CabpmsS4ue)yAWs9hfHtKRU$zX9JR@sR)k literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/icon_cp_basal_no_tbr.png b/app/src/main/res/drawable-xxxhdpi/icon_cp_basal_no_tbr.png new file mode 100644 index 0000000000000000000000000000000000000000..a6750042e8f217352795bba3d0800ad7c6f81167 GIT binary patch literal 15488 zcmeI3O^6#+9KheM#kMOeTYB&V4?~Jn+fHUC$z(TUlBP|zCe*CUHnm$p?0mf449(2M znMspf1h-cFI0<^Nh}47N!D68(UJ8n$(29t+ideizwWZX9mx|T(&18~HUXs@;J$QJ5 z$>jh2-tWEt%UtHQ`MJj@Cmx&t08EyOg#~m!?_HbjM&BPUo;ihXo9o5H4gmLT^{z4S z_B;0jAdTylMR&3Mgrr(VRMsp7Mq5T5c>|E%-Kxv#QRp%XT-MD@CN< zUO{HDJkR7U8!}>4WK~{BFw?21APR{YVHXqQg*eB@IU&vpF^Nw}g2)7)NOl7KO556! zv{2X=ltWS`Qgz+B#Bt4LGun(tEqj?0QmGWj$GBLGMINlPV!CpRHJxqkB%M43=%}_{ zcXi8Tyu7kvHQY=j;uY$Cf_WMBZXweN*ddBsORjT5l;?&8X=*p7-mq)_&@`2UHE2N7 zbx@ozG_GE?T+69iBT9D7BMYN7DVMvohmO}UhL(2R*<%PnfOKf2Q(37)ZUH)0!&c$! zF*KEJ!)EX5OTESE%j8)`jvco25n-OC9p-O^_6nuZT&27XWfvCEm5uQ+p5@~#KT{Dz zNk~XBekU(TJfG$;&)zEgIm(u%FRg@fh<=Ww#3!X#YA27jV~``{iRVB&UXxw*6z4(X<5HJwL8a|*mei8NJOvTQ?kv$`QKL#}Qvr@5Xo z;QbOU)wR% zbpJT2%eDi(X3Io6-PS$7y2q0j<2S7&tKLDDb>w4EOLKj?-k`d1L6APUe7DEAoj(*l zx<<1K&7d!b_EbBS?=?D!V=cK&*@k^GT^<_2`V?b7yN^qRKT@cpM_ zJo<2g_Z@_W&3Ncxa%k9$hxQ^5n!1~f1=TQhD9Za+ZJ+xG&;uaMCPgtWra4@VN6hOj zSX(UU=zw;-V+Tzz2*NExBM*;^3|WH6_F{z|*8B!+Ytf@1dJ5&bkD&v-**);?Vor!K@S)281k9Tx33&mEyvHkVT4%%m=elTo@3t zNO6(*U{;C?140%lE;1j?N^xO8$Rfo>=7U)&E({1+q`1g@Fe}A{0U?VN7nu)crMNI4 zWRc<`^TDhX7Y2kZQe0#{n3dwffRIIsi_8bJQd}4ivPf}}`CwLx3j;zHDK0V}%t~=# zK*%D+MdpK9DJ~2MS){ngd@w7;g#jUp6c?EfW~I0=AY_r^BJ;tl6c+}BEK*!#KA4r_ z!hn!PBCd(vi=EI!Z*w-$Ynwmj_nt$qd@^crp$x$4!vL(E0N{^xbiV>Xg9qU15%jj` zNdWG%-gx$_eE^KzC>8cpT0dO-{_NxzxvAODt^CV{?XP}ve#f4Y4oQ#rV{^4^xUT#jL;rZ#Qbuwi_B?D$#^pzBsD;CuFY4XT2CVXpyI zw`$L8P^E0>8(@z4?%l@ejX!Y@ym{^EQ^()maY23IoBho1_m<9FFJ1h$G?zVl*|_xj zb>kXyq_h#u=I>vPo0tCF_17A^u9QosN>5!cy|v?lapjeVKKT0d_+!1Pw+De0^TYvF xZ@66&1F8XxIcA7z-+u#l^Z79V*4OU>3qNoD<>bXLCGQ>K((GK}%-$m}{sVxAnacnG literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/icon_cp_basal_tbr_high.png b/app/src/main/res/drawable-xxxhdpi/icon_cp_basal_tbr_high.png new file mode 100644 index 0000000000000000000000000000000000000000..1aaf00fd6100c2611d210e714337cd6973a4fb6b GIT binary patch literal 15631 zcmeI3Yiv_h9Ki49B6ENaMVa`4Yl#A3?Y*~;b-i{SbA@e*#kma`5+1j=r`=_3Z|%LK zT|s4{L4x?f#E6gh#YK}L2=e6kmq;-LuirYL89JR*qQK&8DPAcgA;=Z5whXvtS+ zSZedIo=79;lA04y(4JV_Att&-htE*&s&K}6m>>jHfsTiQVTF&^8IpN<_*+vm20H1Y zcGnpiv;pZ(Pb=LhM*(d!*^DB~S!uh&#MwA&EmuvOS4^rD zQ}c-o2!ap@s|t+c3dTjcWK~wWd*bnA$1XVEP^jS0in?$uM36>WFjDF0 zjR2+%C~{9!1Pj-~rOYn0dR6l0HfKU6%~EvkATAXN(=4g5WGSR}$O+fVH%5V=0yn%| zX4cFaS&Naa?ci)YXXVZ8e3s)`*2y5Axm`}?@W?*N->b`EOXjHI*;=0E=CiOI(>ZjW zXbxEMK0y_3DU040$&*}<9PNXJf205Fkoz{%v4I?rrD@r`m&j>7c;m&M5xQtP6UMaH*;6;%j}pvCQi3X>%HctJFK zZNO|X`n|OlW3AolGuB#cHlsrX4%Tb)iuPJ-a^@b7K0GhATNZn?MoFjk!PE|i*$%86 zFq#Fdk2AGJL4sjE3eSmxLwNWloQVsC7}=ziR5- zZ-)B!V(=^oaS4Vcox zM?v@$%48oy^LjIT;N8w2xh37stVk|02m%Bz5?pvbh?U?%fZ#=f3(p6!5?lxnyhw22 z`5;z;3ju-`2`)Sz#7b}>K=2~Lh3A7<2`&T(UL?5id=M+ag#f{e1Q(tUVkNi`Ab64B z!t+6_1Q!AXFA`jMK8TgzLV(~!f(y?Fu@YPe5WGlm;rSp|f(rqH7YQyrAH+&(Q#;C`RI(M>Z7NQy?Xi3Ymb$mxwx0#akt-k z>E!AD#N5gogF~aE4~~4^{?h~H!K%LDS@A8lS@OU=vk#sBH1TNV2fy!1*e_18+l`e? z)f48TEg)|Z1yr|hsRdS_Q~3kyeycsV)%oR-AK$ugc4+kd`(5=Nv$nVQRbT!rv3>LS z*FQVbf<*u82)4c~gZ8@@;+onHz6h+crF9zv*gkpncU}+;Q(8OOFp6 zynLf=&gkK?6JsCmTlxJ9H65GUS6$s9R0ZoJlQP?w0ixU4qN)k|pYqC6Y3h+Pc37|D b<9AR^>*usC2#p-n>bGU#V)xF+SHJi#zE|-u literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/icon_cp_basal_tbr_low.png b/app/src/main/res/drawable-xxxhdpi/icon_cp_basal_tbr_low.png new file mode 100644 index 0000000000000000000000000000000000000000..67c74252c2a239a57737733b29f1ac178139a86c GIT binary patch literal 15636 zcmeI3Z)_7~7{HIZj8Pa8jY9mBoLw~PXz#9nw)N7M&2?-G6qapd9U8{T1L5I8a9f}@v}**h z@Im96N9@_Vj38Kx)Ed^qq17y}#2uWVL_|k2u7c47;aibZIlf!e$%xn~$$s1QV<&8+ zB=~J@o)8^UYsD_9p+6zE^si~<`@4CsU|SKe`jRXN5EpfhOvYof#wPu?R9qJPHq?}j zObyYy{k9q-AsG%ek+n)fBs~s~ou?T$S?P5!9>!h8EGL~bXeZ@#+QA6B)+g&+(k^Rd z=^)c_f}+MJBvqFbnKa^Z5v51>+iXUn>?c!KT+JquwG2BzkxFtZ#W-jxpOe66ebk;r zEHyQOr^J{T7iC=oeoS6JwM)?ztxGA8GHWiF7_3Psl+B%YzVUe8)S6zm86e0Y&FiVP z_NgM(ENV(mf*0#HgHp=!Rj*6YnZ=nE$*>fhyO@*;xEYqTTWTw$SI7ryWor{6r;9;w z1)Q{#w$m;2jK3Y1&6YBWG4Q6(ghwQnb$$!;^|p!P1pr7najtJ7!{- zM#3?`ju$wcn^P3?SSU`a9wpJLD6v4gYnrCF1X){4KHVnCg3_x!W2z}L+7w9O*{G6; zb9z9EbDbik%AG!HMrj(E-B4_;5>pbOJ~80(QTfy+uhb@E8)Z%BWL|6x27tmLNdoJQ z@=k9BQ(+gJ9;cnJbc=Rxg)3tBMk5|~)D`7jZYDMJP{{0_6FR8yJw~HsLJJ_Yi*{Dg zl~sa0!bdqfI5eX6stPx6cU1|_h?9$O9*&<5ZF0{Ey*43%Lyn7?#u&5zuPO3`$w}29 zX}Xf=Gi_P0aZ|@wi@0gFcG?h=Qpb_XB{b1!HotAU+p_0Z_INUUQccTpym62PG;Xsf z_^4UBnMq~+GEP$N^39ELI=;!haE{(CQO@*b-kwT_N{uQUL{p-AFP9K&I>C;(OH-r+ z&h{uAneXD{PEiO@)6k|Bu#1l}{v=}3|8ddg)^m8#GW$Qhl(QRf`rOEESfBBS#e!xB zTaQaM892XkbTiu}Jw9wSZLB9XzS2p955*YY8CSCzc5O$yn$585jORL8(gV&+Hb`yq zGX7Q5=Y9)#02Bii9*@i8qhK}c(Ih3sSU4zw16nhV9Z+D#3AW_*Y%l0(vSd8di)DIP zOEq9x3myf*Qz(^v49)4y?16VLf6SD0FQY=Sa1sazTEw`}d>|{v1pz^e7#ErkWW~53 zAZQWeLi2&F7#9QtEn-|~K9CjTf`Fh!j0?>NvSM5i5VVMKq4_{oj0*yS7BMa~AIOSv zK|s(V#)aksSurjM2wKFr(0m{(#svXEix?N04`ju-ARuTF<3jU+tQZ#r1TA7*Xg-h? zJ8aiRG@R*VY*f)+6@G#|){aX~=PBF2U016eUH2nbrlxX^qc zE5-!@L5mm{nh#{fxF8^C5#vJhfvgx81OzQ2aam_x>=b42HfJw*ZL?$d$Ctq?pCsSV z93qJRCkbNfHiDR(0{1Hf(L)o&_(t%y=(_~5RC%l8^h$!TyxAD6X-!_Z`aQF19rxJD z%kK>}b?++OwM*VoyrcLZ>&W7oj`xSU7X5AAvQ1T=?OL!&vMzn%%vti&;J{h@61 zvv&WnQ`cW=k9#8_YQ(#K-^oSaE&O8Y#~LH}m#+-GeE8P6i${m*B{ig0}+lpw_jT_^Ks&8Jp*jBlJhilK| zhMxTw9x7@3E%}r-cR?$qv? literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/icon_cp_basal_no_tbr.png b/app/src/main/res/drawable/icon_cp_basal_no_tbr.png new file mode 100644 index 0000000000000000000000000000000000000000..a9d84303f68bc2af7358914def6e289932977b39 GIT binary patch literal 17622 zcmeI4Ux*t;7{FKRpWbO{wL(RxtSO38H~S~qY_cS&*GtbkXxj7cYOg5T&F<{o(qwnt z-Ai)kOVuJRf`|`ViimF_irV^Ai>L*qK8g6Ch=o3C5ft%76zc5X+2oRT%AG=C0!hBi ze&07Uzi+;8XZ9f{ruRLzY4qMvilR16P1a`Mx8T1w-U>hO+jaaj{2H+*54jX|`&R#b z6Lsp%dnjuB6Ju`Po3HPcRjZX%G^+u!-IfitDXP4yYb)vz;L#1RV3?K6Z|6SC(1upY z92DzZ-5v*v#^j0vW>@yjsVhg+l9t(39W8fd=%58Wh3>YRrYm>r)JEZ69)AYFI09wq7jLPwOS}J9EkL`@T zj;6~qwTY-Z_^Xmx^gLT;*-odE?c}nSv%vDDQizCRWcdBqvRFMt7Ru0nQp`mQe?Y|&GK1}9b}}biH*JFG=rgODhryR z1x(L{cKkp)d(rYNchMTsWpa6F$1o=KdeZm6@wQq6yLP=jZHOR3I?&RcTebl^16*s# zQNf-zoXUR=CJWzx0 zs=x^x!{r#RILC`JpO*!0C&$YiS7!S((Q*lV)Gf`>ms38(z(+wABv~l!nOlGg3>6U@hQ<}9mO4byKrUR(6|IQ`H;!_=&f`*3Pbk#@?FrpmhIv=pyu zw3G$F+U7!;MU5%VWM#_ZR?~9e{6IBVW(PG7w5nO^lAju5rV3ooa@oe4 zw#FBlMimAos~MWCsl{R;&vA?*YCO}(=Sxr$1tzcZlGc!NI?$yu>!&<4LL>1#1+Be( zq$hB-5&F@u*X1eG^%OXPsah}|!yivx2U1QbF$E5&OsSYxnTA>{FuDdfwZJJQT>wD{ zdd<^h9gUvuX4TLF<{wOnkk)_rUHk~DVoR>N{t*N33;9=ibY>42%02H zx{@o!qaWaARacXSAKT?V@P0IA!Lz-sD7Ha?wiU+(e)*|n;`)Pt<3hcp+WT<8LPvG2O#vHG9TVYXAziDfr*O)&&dKG7l+VQpf%iyYw2D`alqID z%$RFrcj&O!Vz_5@Q85>QR%K&oaYMh!;2eTPgG_B2YY3WZnQh>B*AY0lI25?$0I+K4 zj@6=*Vnurvt=M+cP!)eYux(R|Zs18_iYJ=#@juR01CDV$OEfjg1QUIO&3Vm9iC5!E zQYQ6n9g=d*L6eGtCN^}50VQ3Bcf)+1QF0B55kNyJN{xI$<>7u|Z9(hVW|2x-O-e)z zHo7hL7dXFchqzMpC8#RbD4u?OO^R*YNyp7!(Shr_ z4;10xQs#raTWdX2guM)KgL;d}*AU>;5u)rrA&}vr1a6Uo&0m!-v#Z)t-hylM{^6pz z6dWETfrBrW_dg@k^yPljLsvIVU+yYOR z%+Q8q-6b@mb$5*%l1>l{42j^vfP_>CF2n*uBDgRhAr*oPvA~cBE(}OWh2TOgFeHKt z0}@gpxDX2riQvM3gj5JF!~#PixG*3g6@m+~z>o+o3`j_Y;6f}gB!UYA5>g?!5DN^6 z;KG1}R0uA_0z)FWFd!inf(x<0kO(deNJxd?LM$*Of(ru@QX#ky3k-?i!hnQS2rk3| zLn62^AR!fk3$ehE2rdjrNQK}+EHEU33j-2TA-E6=42j^vfP_>CF2n*uBDgRhAr*oP zvA~cBE(}OWh2TOgFr=&E8byD|0ZjNW93A*~8@Dx{e-Qpv2dz%d)G2D^0g5{MB1Qdm z1%CfRQA->}T|P`v@=1!?X1(^zmlII;^{Lv}T=&Oce>gpIYMq zFS5<^h4;^A+uzl<{nMuZI8ZywZhzX=&y4UBZ@s#0^NB6@?>@Hi&P?riEL?c^>+fHh z-9Iw-=;d#I-hB6oPo>}Ad-AJ`Ti)Jq>g6}KzjE}B&u=@q^~1Z`e+rk*oxSwVq@pTR(bgLfs30Qd4{O)jrsL_=SG~Ga@kP literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/icon_cp_basal_tbr_high.png b/app/src/main/res/drawable/icon_cp_basal_tbr_high.png new file mode 100644 index 0000000000000000000000000000000000000000..ece4bd4cc0eb5c7767400a7f8e7fc577b6cdb95b GIT binary patch literal 17558 zcmeI4Yitx%6vqbyff@{`0fVCB8Uv)x&SQ7>F>bfCUCLJ3+LS6K24!~UZaZOjW}KOJ zw@nPFi9w0rgG5DQ_}~{ztU+U9B*wRqM1y`(K@AX1)BpxQ5b;&-%s%dPyDL|V8qIC8 zyQg=~`QN#}x#!Hi^I;zB>s`CBWmyYFQ44$0sebq?xS#nK!|!X_w;zB%3(WLJo1!kc z-2Kd=_UyfqqB_rL1B1?BW}T!Mg`lh&Sr9B0Oz2HfiT08yD_ej=XTgxBw*|gG_JpS!2X$3k2MbYJZh+70g;kx?N!hDY7NmWceV+HVRUeT8uej<-Jo= z6&B<{0qBkm(;-%_u}rLE13V9vCwL z+YfAG#8SYTQ8<+A8;#y}`T@E+7*f!^p^&5Hn&`MknnD02tx1@Bq#WkWsq&>xKxk5z z1!M=L;3p|?0>^M6hKmjGqQr+KfotV>iQ^J%ohOLSjVDl}TnY{_ttiDMJ}?Gp-`7y3$H477244 zBa14}WW(V&v_ydkD|}SVMngG}i+WI?v@d*`^sSZ#tEHUx`M78Ab|FVY0w=2?1J5?Z zM1?TV#Kf3uMFce}Msso~UhSfR%(Sl3n(Y|Ym~YC$iR;zF_2BNQtlN4pasS(YUm0?*Q0&0@2LaR2^ha_0{Zj;yk zhKr^c`Y5oRKXKvU$mgBTz(6VXfHAQyk13Rj#mHS>TpQ{7)Y5ap@ zRe`1bnJMZ!%Ni#7KQ`tWCna9tBS~4SZ{-sE?^aSSD#I0WG|WVVY>tsbVTF--nPWgy zi2_c|iJUA{bMdcM(kZJGQc07w5>W+Pxh>WgICS6i)fca-oTqrY^|e-PtDX2X>O1-y z?;01blKywbJo8G5wK|ztfkt?oP^GdY5nU-R{D~T{FS-IL}HJ zE=S=$Qu0;7>TUwJh}MNqNyCb|`d2p;<&*P;H&Qodx~C}j(m)3FRweHP>|2c{+>Nya zHzjb1>@EJ1e1e_U=2P>I4Z53){D`-ChzcD1V|n+x66!x(AG-06L;Z*ALs8^yy5=O| zeb76Zx@KRLyZbNiPuIgIULY9}#gLd_>znH%`m_?r52iG@k+j|IkqF1-#nc~Y7`U-n zpzlB>u$(BqXH(vVDYwEWU+|$DTYKu}yJl#?a=|S$q6;pK1W6}|1%^d%VL(DI1Q%j~ zVG&#ykdO<(g;-!%1Q!M*d-Jc|{Sv zrQ*5cT@rl51+Ap}GZZy`14V7SpQ6r9!ryNxYJ{Vx?>1AE^dvG!OJ9{f z{WxkaK6(2?Pw#Q!!Rs;;XO_J6^-YU{Up-@<-gQf7?};B0D<1e}QP2FqcKSZ|i|=^# zw#Q#6zWLqWir4aZoA{yi_bs8UiHKqU2E>lK9V_VobCAVm;DbvbWG>rSqmJvnzHb?w=XeTODu z2hYwcO&q#sUT*c_kCt!#dQ*Dq$lS%LMICe8ud_>z&Z4$jtJa-rkG$-@IizPzZ)&1* H^L@Vql|()h literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/icon_cp_basal_tbr_low.png b/app/src/main/res/drawable/icon_cp_basal_tbr_low.png new file mode 100644 index 0000000000000000000000000000000000000000..0479c1a3afeef3c6788613cf3731dcb5160a0faa GIT binary patch literal 17558 zcmeI4Ym5^`9Ke_4AbLJg3C0*%YD`qv?yK8&*R}{(;7;v9j#KVT3~YC&cMI)q-QBzP zNHnMzUx||Aiy=m%iC;8e5H%+FI5qf;kuPd6K8UD6V?@xzh(?^4Bb&Tr@cpPBuz_pI(;c~lDqZ#8urYf_S}Bh1wLASyHd6+D72gMKEHR+1TMdFUM#@ z&&JkD1+Gx-0i#CmCL65T)IX?g+NjBTY)P&=Q&*sa3UF1rUMZW7QqRVGzY3JSW;RCq zD(=Q?Y^fKJ9xAM+dn_B!Qe0v*j!)1jInGObBF!(R1&$Y4PGotJ;RS`06<(s7f3aLQ zlrpwnQU>xXn&IGo+1RM-Ruz`5)oSsY7`N;ZmX~FjOh=cRG z=_8`q>I0^ZuDU9gm#A)wAAdZSJ!o0wTqFHf2Xl+=>7g%QYnZxKbFPStsi_@tq-#pa zvMZ{aGb-u`V5{axhDD7L&2VNaJyzMW;rKvK%&_g6BUb)wRr*ZFRZR`_<#VthZWy|f z;N?=X1b9Z5^fV(T5@|**r6oqxxKv7(fd08xc`#W=M>z$xa@1|+AyVZ2~k4>Z9t)|HGded-oLNi)R zbHvI!{Ws31Yv21Y}@ z5+(9%%D*vCF2n*uBDgRhAr*oPvA~cBE(}OWh2TOgFeHKt0}@gpxDX2riQvM3gj5JF!~#Pi zxG*3g6@m+~z>o+o3`j_Y;6f}gB!UYA5>g?!5DN^6;KG1}R0uA_0z)FWFd!inf(x<0 zkO(deNJxd?LM$*Of(ru@QX#ky3k-?i!hnQS2rk3|L;6Ep-RM0Qz=SWasKK{Xy#4l( zF8GEETI(GsP}HW&C~ET^6!r6Q`1>_Qjd2w9&3cMb9;B%G*5taqD=2E#g1-FH!TLwv z?%#FIYgb?V#*xGCKX)KD7N7mu)ULgI->n_`eBWCy9zH<3hc2joC%TL0Jv4jeEA#jD z?bx>Co}SuY{dnDhxkK}w$<8)6pS|zdzFV()M0o1VSvzm*D{Oo2`>T&lRr)8G ztyirdKDvP_S2oZ6{-CjE_ph%U%g%Xe!|;t$_dWi^-2IbR+*^M7;quXoYP%m9zU27s zTUI@=ZfV!t{JG)R)~SUH9zOQrmD+{{)Ye;`Jm)t4>l;>m`ub~A_pjRC{c~4x>di^^ zgTkFJY%`DEM6LY7V&p}~=Y02$`}vP+*M?qn>qv@v@es4+(RmAh@!lNLx4b{UbJ_aa Fe+RtnL@fXS literal 0 HcmV?d00001 diff --git a/icons/temp-basal/icon_cp_basal_100px.psd b/icons/temp-basal/icon_cp_basal_100px.psd new file mode 100644 index 0000000000000000000000000000000000000000..9eee5dbcd2475c2e503bc7e2d1e99277a2eb609a GIT binary patch literal 28136 zcmeHP3v?7!n!c6JJ0T$fZnU_rL%B?*ISy-pZ+}tZQjQ6q1irxcSJLiA*x7`Fv$vlRFicAe4VC zwGf%EnLhv86olXpk+SKeZ2W(3IsdP}+4QHZw8)}YUQK&%0VylNWwWMN*LFudbSER4 zy-Xm;&MN-$?cQQ@&^N329;e&pj?^<9!Nv!9rtQH6?ev44bd|5TwkEr}+tnS8gc;Fe z?hc1o!PPyh*yH28j0@73Y%Mku7O`_y@f=)WzSrGiuIG5h>@0O!Xq&y0>F)g{|G5h}B+dvnH$LqqRDbC?6uK`DiN>V!{k73Q*6Uv|glx6FH%S zyG)Z>@nsu^F>$-Kwv*}`4kv9|5a%rd2oy+@))d+oM;L1>BXCikX67w|u1rhTdqHev zVxuzxQNSJ>Ai%#Gy5Xwl8IQ=!g|o(CbJ#4lGK;OU-R^YR%UurJtv0*MW~;Ui;fxI+ zk>TciLI2`78BQW&rpsRGve|F7fu$)j;y8!O0Au!fM9+w%#Pi0<@zE|n$A>*)jVBTb z1!)hqJnJIXr`VG=u+`QWYg~P;+*QwoI3AQ`YRamu$;ffFh%vaDSV8o#G}AP<1_-6W zpwH#6sAOz3U1jljE6XiDe>tT56*Da}y;Tlxd8N0atc)Shy4~^Bhl!rc(NS#BifA8* z_R*Dk#L1d1yTBHG*dmL>5K3E-ysj{9>1fXXXUJB5LH2-=fAdbA7$}rh9^{ zkLwa{R{Ne<qKp2pL|e@$+2R z91ME`j5Wdr%pzz0#xNj59w*}p_SMJmK|LlKr=N% z2*2Z?#V z8&W+Xb}G_+!`Ci)q{mfHCY}4P%NH4fBw}K%smR9xtWJFLK*jBHNP$d+Jrr!;tlIuf ztrK(1(MZMA9u4V=OrsH9;2LllaOpxo7qekq23)!j(8X+6mjRb91avVQ)@8t@3jtls zhIJWm=|VskvteBZT)Gg@#cWuY0hcZWbTJ#&Wx%Bi0bR_7bs2E!LO>U@VO<7Xx)9LC zY*?28mo5Z!F&oxpz@-ZTUCf4c8F1-BKo_%NT?Smb5YWYJSeF5pE(CNj8`fpOr3(RF z%!YLtaOpxo7qekq23)!j(8X+6mjRb91avWft#xI`-iT&ccn!J>-glPYrgo9Hsn5c7 zJe=~I**OtD$clGH#Yj{HVj5;?5yUnx$At(-6Du+d8x7+EoW}S15Rdcuq;6ZV8*|hJ zMO+6L%Q6{$0lYxgKJVUkAZ4Ql6htgyPz&No3b&?;XyG}|-^Pg1$erH%X&~nkHV$#f zkIbkIs);CyBBV-oMB|1$(XlQhvWkwm-e@o+23aB!%CiV}z59E2$Qb+smXTtCOALd; zI1KJ2Z&eFWeii1dkBF?=E$FtF*D|dE!L4QLdA2^5VZ~Uc*&7nHk_7>Ak(QYk4$ajv zfNV^39o-pFfRG0Xwa%}r2W`lU^Q}I!*~dk_v$;K3LvqaL*h7P z4axW`_3J`Db256X5E2Q!r8_jcRbhtFT*T1u&MCZ73~!z*cG41P5mY+$s1(fpRC`BA7wS@{~s5R{OC0 z1q0JDLK~Oc&U;t^-W_6Cda-PY6G_SSa2xiou~2(&y8J+K8-v zKa_;vnocN`LV5n@t2BxON+`4tt||}Kn?l&v6bg}f4)O^5vXt~N9mK^+i=^*TMzFx5 z@#iH-?^5w+CRE*IENz5hq9_GhtUKnwsN@g{nS`Rmj+EIT3{GX7@K_=g8;L16Yr-hV z{l{7LD;RQGMO)4dr}-5A_;R950s%6LLYT}(LpTcK&ZWb5Ay}Uk>VBt>Le)hq)0RdNDzRtLvFI42YgsB>Pv z-1$b83_Z{AF@8^!1oqJ=fK;B9YfiPx7~yrg4F<+bM0}Gmi-jRLNGYRON&Sj8+1OY zh51n$MjM~lRN$m;LnsRVow^@gjVS3;=_tx2Z~1?}-i=bEVloS z;Y(hTT%}+n0;CP7AQP1LnW$ovQb3ssC}|gXZicjxss%06AW-30B_Ae4rKF~%XJlq& z=TJinVa774h2s&GN|{npQ_?chGt*4DWl&gPO1+`bo;K$nJrjx_c*K!j^wje`b<;{F zw!Y&nE9W2GR-Z9_dE4>5CuqSr>4o3@+l;v@+I{oh{gpWLs_l36GXt;x;JuHc`%X68 z`1G2`-uUUpzkG4(#r5y+*nj$N|Dqp0^XuP#@bUkgshEFHpzB8~*S@*wlLKc9P)Z7D zn@V)bNKbPT6>hK>rh*0!6i-NVJn~c#*5IAiZO6+>ynFdam)EyVq=oVm)6=m688e*k zZU-fPb(L@4T{A_dUsK`o8r&FDLHZo!nn;@ks1}`WU*0tR=91-2w>On6Z(ZJ0^7NWG zLYuU82*bT^eztnW4$J#5NT_N3@8^5Q_vIgcX>iNo+OuURYIpwn3^M(sg#PE-mklnL z5ZC$SB+DmF9)H`8o|~dy{(0w=*$+1#qTlK4zxVJ1_pb*DNAkq(C!ejp&t6zqn0owg zy9yu6d9C5|8K6Zc=vA^-+Lq9K+f&OV^my(Qhn8f2{MLVcAfflu=bx^9tn;7TtGk!* zQ%wY z75t`u{cA7vi!a}IhkHG{vtd{Bk8kOpymoS9WLM^o4_~^g`O$eIs=6c$x?k__+gxC? zuJN>dM9-P{ru*IQhRq+mddmv;>pfeWJH#Dr*O}1dvwyqz>X~Vi>B|2sX)JD7nA2$A zv$tefcsmU7ZTAzj|B`@q5)<5Ux_#y5mrB+iS~Jp{^qCwhZy?d34Xz|oRM zDou&WmZc$Ozo6X+yPT9RKv1DQ8oxkjCCgLK-`fB;Uz)a`E|)5b-DE=@1WjtUNie451^8+h~N7B5gzkbz@o% zwDFh@C)C0pWy9aGQYcv=&tise4~7}M7oPLUx`jV<-})~^4}Uk0%^24mdgw+v8zkVB z135;FbOuH`#C72w#i5*`p&SB->rzG`hH@%FV9cZZVgkw=uzkQ$EAQ)Y5?dy=XFP(6 zJ);?r#-Rm|W+AcXLfl)~o(al;E;&YwayrYI0cfI)f-)ZSbl5v{$Sh+`Mj(bT*~5)} zJN{z=!U`^ELxqx}U`3n@d-Wnf^8fxf1?9o7XcwZM{@L+osGl$U3iTms!Y__U)V~*8 zfHZO)l292*%^Z}dKdwEsj(YLEK?zw2%?YXN1`sNPd#Ogb87MUglv1G78x+73BW9ox zZ!Kd94M*JQ+)C{EnmEdY3y7ju^*=)`dpSm>URpNz47DnRw(V3#_MC+Fpe>Mdg4Mer zx0@2*=v$Z4^V`V-C}qaF*DkE1-gpS2BRrcL?cav2qyM`?Jz2V8)PGl~C(?#d|3OcR zNNk@n3bRHb$j-*|Qc}B4u>3@?xV-m3WE|pYKpF0hM)Wl1(bzg;EX^FrEpzxvC~>uv zY)z%DxMJ(D`1RQpic!YAp<}kWLSr)Ov&IGqdXfpds&teIv3jGtu6dWNXW)w0F&h)t zF6!zchJZRt$59l$@s0-X(ONtr+4tjggInkXa<2SLgY0=6v6?zoM|eIOtzFW!WDcFA zLz{2Et{ctW-u0v(S6`8Se0v1OR?RUv9>0|I{yvn@7svLY{rjb@5_O^f$X06q#RHH= zrw(mJXGrSw;8tqqo>P6)-oFmU(a`w;37rATS(OW&1Pp@B|bIJ_Z`ty2ctB z#E!vwW219EZoDoWkf7}7-hI^mz8IO>v;WdQboeMP`*f!=y63i{j|t^7pqz%16Dox| zw7ah_W%nNJHs`+Tqjn!Ws@q%jdN=0(5T4Gxb^LAWtzP2eXZ~n;8Ju*rJ(^(_Fw|#C{Xq#P!0iQuR#H;1{9HjM!fxuB{YZ~E4F%s zSoq1f@q)Q-K%%z4)&Dlt+Y_TxulEju?|evn`uUy8_?}yeRuRezKsf+1cLL>EOrie# zN?%XPtG_!nAf+7ZdF?_E^~wiV#?QY^Y`6k-&@XlVKGgo_upj>2tL}9VKwAEv14#|p z9}`-_{~R=mw$s)q+S37p5_?*WN)0r|7#ayrImzfGJPAF32EOLM4o9Ih@fj^Lfu{lv zj^CRPWF{&+osq~g^63N}263C2hmPB05fVdK6bvE;LLedRF@}2Q-m2b`2B{}%`@X79 zb=`Z;x#yny-*eBsw^LPF1tn#OLc$RamsRA9MqvVJ=8mj_VnaCQAau(p>LC<1a_qEz zR|P`whluQ0B0H#Qd)@Th6({d_vPd^?*|0y2BfJ#M%XQ@B*Eo&l`820A(N>!yH@Wlg z+me+wOK$Q5I)mEaETk)KMT=Z?*`k@{=0)?(*_Pz|yx5!?eNC0Kisp>Unku`4)z{=E z8!e29)Ex+mb&$(VuH-nUUZtw8uAWexHi2v^*FUguU6-%`bhdZkmxWl z7F)$aKOH)vBU7K2rBBNkrv^_Gb@)m4)d9|IF>=Q1(&8`MM-OQa<0@wud!8^LN<6)- zEG$&s@qo=?VXE0X{n{i-`zf-R^%ab(%E;vzold*WY{V|CTHvsVj_LJ~9F$uhJJgSkCA$)5VkXfH1*kv*>jhbh9TMtLu<*@WmXu|vI$h6+OK#&)w5hSh-yZ=pA5EMY864$^sB1K#&V2nAqiLBC_>^^ z8U08g6+1Z&Ja!w2KTe~IrSa&>P4)~gZ@}_u!ez)P)f>&Y+w)lC0@{+J3ZVIn@|F_| z+4^_i^mAO6Z&)q0`KaV*%~rBy=1&hY@B}+QsHoxR@%Xt;%Sn zRZfRh$uY|B4Fdu~emZ`_wpwVHO^S>9S?PsI`3r0F4<3{jb5>SHx>}uT)LAsCru6h| zNa?hx>1Iu)#gv&=L04pY{8t{7ILd`UB)z_g@P|awK5Ld=b|e+zYv8QtnaumoqIfBX zXL%u-OvNz}hv)B~G-2k0rKR3)lz0{{*E{p|DIO3zMeUaV>)J&y&aZed?aU8dz6iAh zQRA!4gS;QWo{3NBD8KCzVF*;%jKMxo<=qH+%6JzZKT5)9_K%`oP%2j<30xU287@f( zND`L4ONL7l0+NJf?~>t?gn%Sr*}G)8Bq1P4SoSU%E=dST5|+J7hD#Cxl7waNlHrns zfFxnryJWZ|As|Uu_AVJNNeD<1mc2`cOA-Q-gk|rN;gW=aBw^XRWVj?DAW2yEE*UOK z2uKo^y-S8m5(1KhW$%*Vl7xUHVcEN6xFjJUNm%wS87@f(ND`L4ONL7l0+NJf?~>t? zgn%UBYkF6#@6l@70nbxc!-Lc0$!k4%D*FcFlz6$I7QXSPrCEG!@y9 z1JS4ixkw7v=221NVwj3DnsYm6ndX^+97n_$#GneKL}gHnLvG|GMPi*^X~+{B3+$Xj zv@y=)w%IwGgQx_443RE0%$_bhnSM9cp-6=<9|nW{FqlQ2&Srr>97`5DIftiN&}@^- zn<=%j25+X&whGw2FIO`mGZ8E4RH%glCxUg9!O zoQ*Y*W02X!I3Iv#Jxj39+8kC7eDRo33N{rm9LH4I8HZIY66fJy6a44{J@itWwbGw4 zz{3FByz+STgq;>_Kt*t+;8h3Wm5i+02rpi&6fXHogf}6Cbr9OXxN?`#!NQ|Mw8Okm z@Wf$+Ga9}JqH-7%Mi?F}__z_$G^EXFq4+ih9g$3gZ*T{mCpm;Hl%VI|NS?f%f!H$8 zn;%W`HwWg!&XIf!`Gzk+%k6kH;9)8{98!=rUm(;Xq^hU@jvc-u3560VYoC9?OVI*{ zLJz^WM+VzXAw1SZ3ekBP@(7P*KIjp40<(j%_#eU}SYXxUH5DX>UsvI=O~6u3C}9*O zVvB9Z5*U>*QYM;E#Mq&j2+H6T`w90YLcX3z!r3s4g3x}P^}Jm}NPEy0a{Xz-n>hTr zkPcQzGzd#N+;$v=apNN4{Spof+b5QoISufLnRozty&Q;rMhPnLjV5dgD)kK(oR4JT zT>vzDzkLQC?o>cM5rhZi!Ei>AOz~vDx}vNu#_bFsMGB9Lc_R6gGOS&A0v>b>G`cxv z8ttH6@NNbR5D>?Mrjl_jnq;?GJ#$`y(D)(`8Co7?p(~7T669m> zbKgP4@Ar@c#Rr(ImPGy+ll0sb_KBk#kQTWCNEz5~UR9I`CI<@hhqG87jb9UT)L7ZVegI3RXF;;@9c zxP)ONh71`tWXOobIC6*=A=CGp8aQCU!1#fK;^PMmjgOBXiofEA3PlpHM*;sHN{oir z@vI7?l93{j3QMH;!!UAV`46dlurdMy6^>QH5r!y5ctm7WbWH33sxK2}tS}FA5Te4V zFh#f`A}TUEA}lTqn2BNGV+Ly?Cf#cslKjY0ZRF5DtleC2Ys#?F_f2W(t|uA`qsG>j zo%yQE%<67h_qX5NHu;%y%anhu=Q4(WcHdF@?3QI8G`YV%H}&>sH$3^qb06+KcK**> zKWhHw!u=Hse!J@BH$UFjdNFg_1J>%NR&RXkll{jpB_f3atPLkNMMXyFhzVmfgTujs zN0Ns`XqWzBD7N7J(#A7sDW$~py_1qEL^9EPmt5bIQK%tLbmu z^x@Ol<=ea^)_ykP=H@r!NB$$>*=3K_YnSa#8@J?WbIyoe7SpT^zka=_w)n34yFAV3 z5&v0#!~eYd!nSThU99_+pU@zVOUi+9&`teTUb+3?T7#VLQ$+{wPE zx-z@^<2^^;)$QiCb<-^)^MAKxCyz4!*t7iYE3>fENAI+r%4_~|*LS0z9J^=n?ooTr&**uPN43+hI9nI5vmWaF zu68c_>4C>yy=Xmhe%y=gi_iWs|J6M^%6R0HEkCQ>v}*^wFJ1TLz7HzW^X56`uHOE1 zMd_>SGUu)wwSHXgnyo3dOq^;`lsrP|2?fe(!6Hh3(toy{b1YK>5mmY6W6tW_))T&xbf1+OA+a{e|vfKiu|`*-X43Rsb@vc6E74U?D)(0+@!^i zY;#Wc$ZR=$|AULtuYCRZk=5%T=*aAdwT-pDTmMQ*?WB83()Z3-mGL-bNZB+aH)$J` zDl1OeA`!~6U9^|c4~>K(77Y&^N)2VMAs!W=b*MCCF(o8SnYfF>aeY-mlexL3mV zwi41DoGeK>L1OUtNGMSueDI`3X1QcYB5H!cfbN1sG>W1IlMNz-exN6jtvs&SM2+;O z=TUcvGO#?PG-Q#8_YW>gOVW5IUHO!aEDmwm4RAJ~*zcAg1Um%rdabueA^grPy;`SN zXDKz}yCXnH*h`d9FW$Ypr10ur^-`EG4RZL1q{2iSVb$zw2Q}K)4(c}lb|@&14r+qJ zr(4j5#C@9gI{X-H?ce5mfjt(^o8Wu|&KeYsZHqV#X#{9s3<)Nb7NhNew_ou9GEmi6 z0uET4;1b_|Mwb_qDl1`$1BI|IyW3%dB*r=#c76q@6e+<8Y{-f#34fstFK_XBhU_`a zb`xIEhvN>xe4C@9M&y(He8+soKW}H96#;p(-357UJUOrqwz3M>Q3NN2^JX{e`9UBZ zXuj=4G=8Zbeh(Rzgfqr&Tu8ghZB;b>4Pw&%O>^_Q^2QN6Dr#KVjd9t&hh(H0cc{4=*zgzBjGm-20WQ~H0c2!!UKL8 z2)hCh7I8uEO`0eqDHIQTk%90lNh}%$pTR%lXA~L*)+E3=6b;*n6n7ZzX)RVv&kMhZ zb|UKWec$Y*nm@XLK1GU{yBm)3)Wf%4f()A4!lTV3buXk|Cn-ZOuejXWdg=sqtgDwt z^VaaCDS$2@iDWeVTu4Sk9v4B!MUme~dF2vkff;#m~8&Z_Cwp~0ywXam9%;7$*QaIdq199X$=fx_D&4Q^?5t^U6 zhS2Zy$ZTOYe@;ZzJlz zLk--!hVaBFFTNx$i$iniRku8ZeJmuGUUfVm7K5V1PmDrYHh+VenwLgBdS)GuHVKzk zsQ>7M+(v52S-AXFp=N)-;kVSvqCm9$H!yuTehc+J96wa>4{`Xn#1bP%ey_&qsRnjF zkm0}n__ug+;NS1VZ`fxL=uUt$4(tio0Xh2qcn z$ch%8|MtpdV72p9=b?rJ)WLl|E^4}b03GipT-3TdA>SQ}5BX+FOfeIrm6mpe}GYNy)HxABT^+fQC>r%qnLoKTy7Le-wF zJazieH(x3af88t0iqywzj@6-;#c8qU*xIAZspd{``fF)fj$RkjpF{euV){_;a>dHk zt52<>{;RfkIoj+;u0M0;R43K7J&=svfX?0Dhqf7LO)^c!K=uP9j|B)LA?yb&I8KT7 zZNcFV(mjp66#u!8q1b$d@99N7!qlkP|H_)iI%?euegd^?*M3`vJ`yLr54MXs&n-ur z#7Xaep4s6ezTqcW4;AhK!Pf+u;F}ezE!jq_&BS&V4&S-L3d^2h5y` zb9;7O+)eFl#jH@Bkz~8%zPaH(fZEa05IeW}-RRf>wr%y^>UbJ*Z~1O^>?B#?c1JNy z{v{=*``+^CNA~~!mXGYa?a`0sz12^qp?Vnu83X)}blDF=5`%!-f^Z+feUZU$xkS;I sf!%)1`!2hQMBv?*04HotOeG*d0CU-2-Nu=4E^NLE#B5?{rDYsDbknZO3 zGj54M2>v0GHlCyn+xh9YKlzVso8zK<3*P*5)Q7W4+BlpxY5c^(I-kukpBD6X+U;Q` zrMGX`lCJkSC#BzSDKnP&is@=k$s&%fTr|7Nv1q;{-%49jW z!IYn$Z!nq-W^)E`Wbg|a!B&^S@M9$*ikzu5@8CQ>!NW3oEZ1gd{lcX5bX-v2lIvCD z3lzlgnWT=H4z|WnXY(0MnMT7vnVgP59-p7{64jgz1MQ`2Xhz^6pJ~8+zG_xr`D*qe zMFx^DS}?RpSy`a$0rjn^8L((xn6>~QkRcr~CttPDM;j_=p7nDMdfEc0%GiNw&kGfF zuyw9L6tD*y2=Jc>)vy+Gv`wI=!d+lCnvEI8tPEpbmC0f?Wn0b0yNxER(Kyl2hcnoK zL`E6w^tcv=$gmI@IaZU&YR%z$wiF8TFUT(jd9SWQwxBQ z>G3$N7Q4-2&Ne$UvS^DjBgd4TlVP{yWM$-89Qnq4OHRJanMa^4D+|ruPxMsQ;l~Co zi*|x&rz0;fC);Suuvwg@410EVK7=ghjBJM~*J;nqa?!3_MRZ8^exm1a9vF;l-Vh$F zJubqQn`JiIoR*B7e0x?#t~uKTis#`_j@g-O$#vPX@|7Y65Yw-y5)Uu1+(I(S1Uf$% zZYt?V!>QOd@p$3&kYU4T<9Hf(ib?58uLz7Y0ZBLy>0DNu12=mCZ(Be+CmOFa&39!0Nb*CnU%ZUkYMPNdS)hX$t!9(bK_pRx>*7Lq)+N;1IC_d3ETTXf^2?R+ zOkZ5ApK!m2ak91iT}s`IFzIiwI$w3Cyt08$ z>y&}kYeJYRm&gqaUK zLTkv>r8q8EI`j3(9yWH$(w+T%7d6sDvJWJky;}E0f?xnK!O|4uLjYDLKB=KXRyia= zqQV*qmT!i@`c26b?3mXg6jb|KNS9@5g{T5ogG+-;6#}Z5HS5ygQiXsjX3e@ZxKtsa zidnNR4K7s(sAATvOM^=l0;-rb>(by-g@7t%&AK$WR3V^>S+gz;E>#GqV%DrngG&_x zs+cwF(%@2sfGTFqx-_^{A)ty`vn~xTRS2kJ)~ri|OBDjDm^JIt;8KNvDrU{PG`LhD zpo&?uE)6bK2&iJ#tV@GS6#}Z5HS5ygQiXsjX3e@ZxKtsaiusb(6(2kiO*3!|x)#nm zOQ)%=h=lYw!d+bU;7kdF zd$5d%4EPCRkQRc$9CE6fhxAdHv)CsvO0}Tcb}kU9aPwt>NHND02P2FSjLfoo`9R8S zx3C}(nO5VS8i)Y0LD5By`ED5qsgY2{jG|)Dh8&!)aO(9=)^DH89>N-uYX-;kqZN7k z^A&N$m`S(M6ckz0-=}Jc_&xM%+Q((Xa}4*g(Jmq@?5r)a(6ke z*a;3}W_V(?(Ja~}iRn{p73&+Y*h+_2qL*`y$q!-)K}i7J0{r-U1G-a^4yXj46nvsUev)qy z+(FWkeK>2~fy9}vDhWhFETPC_N5o_h2DjW! zxGfP1w!}?1s>3Kq^~X`=D;QE(L0gLTr+qB*ho%!{!UzzN6~bi3@5Q4qu3R*H7lLu} zeZ~@pV1hKFChmX%D+gkqUV@5(y$P#=DuSH_$D?`p7y!-B_0GcGoeC=_ilhNK4el5c zDV-WpR*ait{k||#v~*rf8Of(rV(HQmc#x4~^9$?@nxQ%Prh*d)2p?USnd2p9Ou;Fo zHEumTu66x&@No=zf|FYkgC9;Q~8Xrh7fR5CHX}& z0tt`>&1M;lb)3NZzTN$DaYBcfuWW21D5S&*2ji@ZI}6gB0C zw&CfIE-^=sc<$x5ipGu`S@D5AE1P>_S8>ev#>&%&&p3F?_kREOlXpyAR^^=bmp=$O zqjukSgzk9fsSo$~kDi@==knD*{jXnb{o9vczw+)!dyjR_buIX}=U-j(*L}@hxiju} z*FOEiAK%-y|MBFPUOP(8nHTa-n*XgWr_QTv0 zjm4EC9enng@zGd;m^&%x@oFCY71&-qQ}nK383<`#F1DQ-2q{+|ch#%~keT3NcS<Z+Pk{=E(TwvxV=j|8(h= zQ-AIn-~FT4&u{4cTtxO0jTJq|$9(g%$H$!e)27cv^y1P_diQ-*kSU@yTRwZ?6!XrJ z_U`#TOJ6NDY&(3vSJ<_`d(`a4hZb(@ zwU2qa=OmGpa!==?_ujE||GN3vlArS>V@g+U95uD^-dhg*Wc!)>s^8|1dC6Tl;3`1jpwc2Uq`Q`<~)|EWEqs|R=L6xjySe70 zW4RC09{XK=+k^l9aP8vnmyY|@^pP-R+$HYs-z@)U!^Z(>zPp`_@RfLG!lQi(nu46L zIJUz=K@UsiY6uH(^CaX0jUO(f3AjUctR*^-h0_njBJjjizN%}$$ zc9pSjq{DHC*Nztlk+?x{+{3u)Ka@|3EUJZ z!_O<53)w&$hUsuaF8pCV{4Fw>66duoq`4|j4UP9RrtE)XUV8H~AJM~A$6+(ZdHY_f zk&Xum#P!3Ht{CYUjI@`n#We~+IVOOz7dl+6+zLUIBMAb79_1BbD8G;G2d>G1c0~_E z6x(w(+_F8RSrEpSj$2de<7Ql2$({+yfG)YN80Bb&)dSE(8yRKX=FzbK!6LncHEDq$ z!ekvj`0e=3Fob1X(EBsw5CyB6B)F5|#(yJjn7`35{RIEg)*+O6APbEJ!mi(LY4*pPrXFD z2Mq>bS!p4Q(-ioxz8hy@Eo}tg4FT8~7+|IkcLmhB5q(^ca0lgLe#}Pn-S|~nxp>D! z!(PKcvjb(1Fl3RX?FIh--Vg1!Cw%$6(d@L=DQlV4$=0w9&N6bapefysP8h}7S=yTUyt!>iMS5t_8b3x zQAFojx;nbh`R(FwMRfLf)0rmJy#t5OknlG<#Fs>>b60cI=_YDd*C!A|ZO5A0o6wm{ zhr655m#wW`t>_B~$-Fq!Dt3wJghtaa(Ck3#3)*;~jftr3yTIUxxTy=Zgq8eNXBX-{ zAi`0luhs-+s}fHt-6>e_|gf{@IML&Qq9Yc!-`AZi$Z->BJvh5=qjYIbm4F#r#x_vGdl z^l{jvw6n7XbrW~!(=~y~s;vRNPiWi2XdAAY_TM1y3o;?@fHF1`x9QyOwY#Xj7l_-` zwYz;6>d@RK#a+>!H~uc2)`pj8L$nSp83OluT3^6(%(b?IqwvYQz!}`Yz$2Z)J%ElP=_Ia{&?cg#ghtN71ZdA+ fHI1ChA@clC#&RrAIlY6a%1PY=L&Dj>4%7bvGnpqC literal 0 HcmV?d00001 diff --git a/icons/temp-basal/icon_cp_basal_50px.psd b/icons/temp-basal/icon_cp_basal_50px.psd new file mode 100644 index 0000000000000000000000000000000000000000..9db88a0ffaef689030fbbf7a1b942f532aa5d5a9 GIT binary patch literal 23095 zcmeHP32YqI8Gf_t`-&YqghHWA!K;->1Jy%NAqVVDG@tRE|w<;Z;w9PiMrH zop1hnXQwB_t?b+siu$9uVSXaB{t}rVzvS$A@{%pdey($9uwh^-JeAF5d6o4{Wd%_Q zPp#}^IVr)1A&q2Tr-!nrTUK_i#sbfI(J{}kB=eq7SIC?62YNic{at}jpr0>zCgD(5DfeK!-0^;xH<v$tx+B1R(4LPYA)>aO-@dBO?G!la@rT@ z@9+2dgT7$U3mjf$T2$F7uc$22m6&=)cqJ)ka%x5rJ*byWNO^T-XD3!7s4yN=jMZ6r1w}y8OOMLR`|4$>n8%n#Lu4yufF9QB^=LP*E;7A*qrwAswMgtN4f& zL!U&WR^1it&1NfBt*C3Z0t5!66(yDUbdLAMcty&~Nq)^%Xv(5Wtyk0-U+A4Vr~>vv z2Lb*A(2Ve~%(E�{39hAM|_u-CloRJP-;8dcr~f>Ha|2?;r4$aTYp|>WE5QCN*88 zBSdwq2nXS>?{q(SnxUhJvs?!_GsmjzoU|14mg%AGk>t1}34{887&Cj@Gd%2Bz9}Pe z(xh@~QJW0zB1K#>oRZ`$s}8ccoRCSf=)%6OB4;?J;?>FI}5DCq4;270+fZ+D7M^$z$9p@Jo-iBe1JC~m-qS%^LnjfO`>MP;D@qa)Ow z4A{da`g{5Vi51>Hwukcu`+EG|zCbAD?Fps2Lu{Zo6!eE^$CQc}EHhM_wHvDE-c;SP zBJsmiZ`%Y$3&Cu?GE}`F63R&pXm1X273bDzEB^gRs^};P;ZLu?l-Nkpysfu z)@QJ9r%QX0cHuaGaVfRXw=|IESXtpQOswoQg7`I2bTPhOUZo9a)JYrPN7Q=2xd-#C*h< z*AWrXy6O;}dKv$IBTzE?Q)z1(WA9*5+d#lyi&m&Y-m7n>kDVUnA+9CcB41>Ghdl_ zN$fPVbH>`PXzen$g@tZhk$5HT(y=aI^ja#YDb!{nKT-hLT&?IGRrK9Q3v?=cRl*0Y z&-$V@WeNlH<46_E{y4N7I-N>vf$PBKz-0>oTg;AkIdIuRz!tOPT@GBf5U|DUc$Wj0 zEd*>aJKp8MWeWjY%#L?CaM?n@7PI4B4qUbnu*K|nmjjnA1Z*)o-sQk$3jtfqj(0h5 z*+Re;v*TS3T(%If#q4;O1D7oXY%x3D<-lbN0b9(DcR6s`LckWY<6RD1wh*wz?0A<0 zmn{TrF+1Mnz-0>oTg;AkIdIuRz!tOPT@GBf5U|Dkq2AR{*dxx1urYiRc7W^q%fobk z`7AtJ;nw%8H|FGwsBX-wxx5O*YGfHx)bRxDe5D+tqRR7PK8ppI#`mxwV}2f$9nVZ5 zMND;dHHPEKo(zfUK~gbWG%@Mk?>@U$TWqunJUI)NlK0LYCg9yu{jCkCdwue ziKK{!jDwg;@+3z^8gdpl63Xi-_i*(5vvdr;j5=IicoZ<0 zUxdL%y3bsJ@`cDboKr=!S9tN452Hnd!}%gI7e7Z-*Di_) zI{t=yMBqG?=rKi5DSd28SQRsvp*OekN!W7=o2+3kzTqch=`qFh6HFsBywPm3flujb z%Bqb^xr)_}Ck358CMQ>&j~eLJnv|v7CfMvbhCZ7S(#+d$UCn}I_cj5j@4(>N7 zt+^>Kv!Vifhj=kLt$X4ET5>Wxn@Jo71q;JN0Uu`}%|kj#rj2tULX@)&p5P9eMstL4 zjIQS-ny2SWP&*IMd;@agW$0+OxK5@Pf1xz*ew*g&=@TBh?qxVeaPS&#NL;jrgOs|S z_);k-5#U)vDU3n6?fXBlD0mtMLoR@)$%Cz72#!F5LUq0id4eNcx4Qi4ehrJuse1lc z$|x478jsiDRl~$^uj#7+>;#vjD;5LxQ9wx-qZpx_G8vOHAGLFXzRJdY5EBx#ifw0BxD$boMK+U*o=*U96zOwD(mCX4Q8mVGsz{)^%IhO$!Z~!HfO?l zdgIrdWN3LU$EVml4gK}F9lQejxhA=ky)ludXHXP@+otP}tg{M0gq$sjh;_XxL?g5%rU7qqt@-_}GgRl zbdk2XDA0D1wmN7)(9LubR~zGQW3<1($gR>IWro1YY6w&qtMtoF7*|zwO>JF$LnBjO z2=kcRENmrA72|eQxvFbx>Z;vM-B8%(t~zCYpnCOJ*!IqguL#z3Tz}iWkwuFa#2!j? z_sCa1Ib6GB`}qESZzYw`akt-h)zXn0;@p~t?@(7P+;h$g{DGfud*l!K7vEmH?8ZB< z{>4p?KK0Vf5AXl&(=Q)9H?{Se@BZk4$Nu=rJH6{Rr6;ew`L16+{>-bhZN%jQYpbYD zwKdftYQiaj`Bh-S#hvZd!7HxsKnos8v_DgCKZW-GIC?F5!aTB?aIl?6XAHm@v!|=nwL-lt;k}zG-C^-!hb)=S=PnW0QVn9EEen?=& z3FbsAy_s2V@W3?01n6Xhs~4FG(ln0PZ(p0ClMu?@3HNT&@c!k5z)Hk;f7od}1kWA{ z`$J)WpC@3P8w5JsI~cuQTn+7TS^9%J+=Vpo;Z?)94I5#0F0_L=xzG+~X>mJTjH!d^ zausyz+K91AwB8NdU^#W3_8%z5cvK7bQn;7H;04>5A48gu%``%7rkHF-v_&{YNP}e< zaQG<)O3;-cN`3fU7mvg|6A(&45OoQ8F#}1&x(?Qz5fTH3n1D~RG?}2~(;1vbF>bms zpA-_faHzr#!F)zcO&R4hzeU_473T#dmnz981sU@C3JDUZLz&289qZv{XdQXQ{2b{4 zS}W4w1}Qw849{~iDD?t6&CBsjmd7uk)z92>VRd`Q*Qw6bl#FhSvgOy&A$^9SX3j|0 zBGQ61i7hHZxz<8ifB`pY^g;pUDvH3T9_4FFP~JJCqcilH1vY*!qd(*N*6?StjFz_0 z-fW@%+=8vu{TW>XMv{Kb8RZ&L@&M4(8UtnQ^BVYKlE9OxN7EiCAWYZjpMF2Sr37IE z7qScED_#r)@ka3PmO1^JNjpTCjyK_>M$W&ly7TIU>jSc%FvlI3)rg2m_Y&>#^WVS7 zec_b$6U@6j+IJ4YfAvcU%OX(THhtN)Yb59?_?EQ$+q>KT?2+=;lCnt^Ym6274s_gLs36f=*E(6rr!TK_4o3TUmh2%kWm&)j?yO_ zKc`~?&})WORtxn^5}k>;q8M8C86ky0SaDrd2qt=PFd^3mu$9vl>eB?yePgUj*Hf5Y z8&$SI39Nx|ok*{sDLCgC)e7skra5!lj(t?~CsD`IS!PeF4X~PT7po^UJHJC3dH2A6 z^483L*IWBxK8O4Z`*!1-dHa=@US(eS=d3M#cIwu7p~lw_JWHORdDiv(vwNup5AM5; xTJYi{FFndU^81h50{b>o3G#%E-ywbaH%I3zfk_`mD8BUx#~h`zHk9fH{1+7#I@16E literal 0 HcmV?d00001 diff --git a/icons/temp-basal/icon_cp_basal_75px.psd b/icons/temp-basal/icon_cp_basal_75px.psd new file mode 100644 index 0000000000000000000000000000000000000000..585554299b4e9727fffbc81785cecfb006af35d8 GIT binary patch literal 24072 zcmeHPdvp}l8Naie$0peX5J0x$8KJdk)_3R zW;Qc(?{~lZ-S7VH_kH(H&bha-t-A+NNV^K)wVd28DTqpV zaA7sgN--`BX-xK2dkBlVdSUfqT;RDR((P%NWX=<+4S5-Vpx)EaR2v8d>Kg;+c!K^w zozGwA3)Fc7!LYw690+;ztGcBWQq3|O4@Wze=*>ZHVRfIXroukoz`#K5KwYgQCwzgX zrY4_1=nDqDz~NPfM3o-&ipm^Kh#{wgQy7^~sk|h5uv|JOrPYPi)wm(^()*Q6nGK0b zE$L$|BPD%fAhD{5yyK%hf9VNIoXD8>1roFb)VhU@HyuFRRJ_lg?jvZFHvQNW%Z zAi%#Fx)E-dIa=j9;BE=}gMP2S&g*aN4TQph`f$)c-yaD3{ms5HoY?^+G9nVo$A@xc zgoum<;kvqTsByj@EKQe@!#P$47&A+&^pvFJ@{W;1`XkA`k|eZf4$*Clwx_+_GjAm? zveJNZc21vk?i@iZ6OK!Al2%*jR7&6(8k?}MUu1Q|G%cjrmu1bVZNHpe!rIvu>o(azP<@kp`f>(2{f>=hPpTx zZ!kpXR39gLh0H@#qlFwEtUYdmZm0|TX*T3t&=jllHU#Sf-o{WPPAv$s4WWiOUDsqZ zF@czIO)cXURg#BDxH6*%iCaC~n$c8jOFlxBQ8 z5hCf-Cc=7*qBC+nEUBb8PAcu3b}+KpHO*M`f6%Mt>Xm~HE_;j)B)C1%^YY`82TV2Rnb zE*maO2v}mat;>eX5(1W(ZR@h(vV?#oX4|@KxGW)HiP^R;8!k%-SYo!V%ZAGm0+yI< z>$2gpgn%Vx+q!JHEFoZt*|shlE=velVz#ZzhRYHHmY8kpvf;9XfF)+zx@@>CAz+Ew zwk{hkO9)tEwyn#C%Mt>Xm~HE_;j)B)C1%^YY`82TV2SxNt*bP0XYVplRi zb`v%UNhppys0XU4D2-C2N@>dEhCI=+O;AN$M|UjE3o0)Xkx*VjxZ5L_F4uOZpNnNU zyzt0kP?dwh3bH#}f%4gyvpuDXMz^5bG1<&S6H3I)w98_9HY2Lp%=s}vF-tB;sQqT9 zGbwbK89+8Gx{X<#(1Fkf2}PH-wSzWfBYu?icvvYNTO_@XH6+(kSsX`e6UOtk$!zaM zqPk>GRM7C(>$eH4XCiu35mZ9&9uyWub!HgNevW}Hr?52{cChPq(w*p53_HPT%nWa= zHaee+YhuPU+bg9eY_^9HGj+AlGz8mQpKWuV**5Szb&S@KxY~DCpECsj8F| zBr%~^aT_IAg&cahL67o@zTAQ`qX2X>`LXvn-`8|N%ivAHQ3v{)c-EPutU_-TUajl2 zlMtLA5L&srSEfY;whnP3Go)GKEK+hhJj+opI0X&vp@5CkkmexGpdtMl)G>Hfk_EM3570$r@@1JLm}*eI)%vm7vvH4a82v6Pv<+h zcq~=RA4?g*0*l6nSCHNn;6p47-86*#gyN(q9dWEX=D?_w5eY6r(Ibju5eS1@M;?zb zLgx4soPx7XjDpsGoHfqc(9#ClT5dc|JC`H36w(t_(iOs-Vp_nl8F#J-PMr{0WlV%& z)BuzbHL+WowhzQHzJuDbK8966(X0#Me31et1aQj5!udD|P@~!@BxOLZg1eYxx;k>& zDo)5!IyH(^q-`QI;(KQgmagrK2N~sbT9uY^A}7O%4J;54-p{Txmuk$If=jxR2@kxE zcmJJm^oBm|>4Sp7A5DoU31e#1c#3F2?WGf=xGES9>T!c=m$Ixka=sC2T?Tm+b4i~h zU$t1^6UIz9P3!zJgA6?{X1O?>CZWFs?*^ZM{bGYWn!PNRASXBEfLp1_Z(C{>KoxX> zBx0;fR4E0E3Wdv!t)&74;c--Vj0Ej*^fK6j*f*A)c-uVO5UdfvoLfI6Y0Xb@gam`r zy>uqYVS}DVYGHolJOdsWal?n+La6OopckT(5tVs9^FDHuQ!>8R9zl-G2dIMN5W5c7 z%e;ivBe%=tDsj0>O5BxYrDc_~rn%kIW}Q4^#;h4LPOfy5OMhvZu}`YJtgO7Ee0oL2 z^qCbE6*KXpVy0H5aw-BcTTrD7I6LCZo2R5(^?mlIKr zg2JL=S4n9ZHMS7uF{e>D9Z?08(^23kEG}{tI^A_pSm`V{qbg9i_(FO{^_pvfMKf=? z`{!+QYGy^BjMdf4*KThwo;%$0;T!uIC3Mm~4_|j?$9HH0^$`}EGYKK{|8zx&(Xk&EN~-~8TvkNtkvzJm=*S0)B-xb^+=fvN(~U`_Rm!r(Qx%)}Zz8QuP2T}|u_`P$+3o>`1izkhBK zR-pLI&{I1=iF;?Wofj=oxi?J}CfDGstO}VIk=seytVFG7q<6S$?%6fNUFUVx3`d8% zYBp>FLThH*WChztE?ViU{rl;=c7OZO*7d`GeRb9Rt~piI!;QbLa{Z?Bm#;l?VDkrs zo8LRUVKcvX?aO6rcORPHS#zXu?d@OL)75<8;q3=+J@??om4~-Het7M}x4z%};Gt`z z|6~x?x9Qf?TK{tM{!KrdcjTQz%kMa}V*ZiWFF&&Rg^Sk&lYf{tGVdFw#u`4kbNHd* zstvBYsTr@nbx$XMO0=uy`;TUJOs4B|lNG$6`4aXM1S@aiPvAmmF=Amk9)qQc2Nvgj zkXGSVNGb(vRY&3Qpmz9S=Of-&4M{}RMk45|kZ_@5s){Uc!9;<63i%MhCLE(qHPcs8 z^K>4V#;5?9%<$?*rh+7mJ^tn!cruCMx|`tMhDtwOhY+k}^!I0-frIdgKVg3;>~Hi0 z^wWAkhVw2;YZtGk?sAy&m*3^grhyM%MU+$55oY&nKd95Q{h-dw?T3RhWKgw^tZYph z(pQ=0yL=T)dH&2{D8@5r8Qe{9H=_cqn`0fM5!y&1+(v@QMvS%yXZK`a83!8q2?s(D zLvf9x->%-asHYD?F;v8|gtW**5@YRxb!!`nfxFoP-V$oy-vIvtk{t0i#H`R{}x#{g*Y3t`dHm&FyUeyc{y;m32M`r-WH^>z6-1{BVp?| zzDB*Y_dw=g2JP9g4ei1y>L0syzDzy8=Rls?$&a>J3h1_L)6R#e`?nB{pV)CDx}9je r{q~(drZzrt;%S_}z7t94vAp~aA|nbOKnIZ)331AZh6nP}3fA?%Kf4@! literal 0 HcmV?d00001 From 84f032a7a2a6349cf559396d3a0d905bf751c124 Mon Sep 17 00:00:00 2001 From: Philoul Date: Fri, 8 May 2020 17:58:01 +0200 Subject: [PATCH 047/400] Revert "Temp Basal icon switched" I replace first proposal with a new one with 3 icons This reverts commit 24112eb4 --- .../androidaps/plugins/general/overview/OverviewFragment.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 021c3729e2..7194d39d61 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -667,7 +667,11 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } overview_basebasal?.setTextColor(activeTemp?.let { resourceHelper.gc(R.color.basal) } ?: resourceHelper.gc(R.color.defaulttextcolor)) - overview_basebasal_icon.setImageResource(if (activeTemp == null) R.drawable.icon_cp_basal_start else R.drawable.icon_cp_basal_end) + + if (activeTemp != null) + overview_basebasal_icon.setImageResource(if (activeTemp.tempBasalConvertedToPercent(System.currentTimeMillis(), profile) > 100) R.drawable.icon_cp_basal_tbr_high else R.drawable.icon_cp_basal_tbr_low) + else + overview_basebasal_icon.setImageResource( R.drawable.icon_cp_basal_no_tbr ) // Extended bolus val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) From 7fc631a7296f6d9baa6ecafa17659a3b76e4e1b8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 9 May 2020 10:52:20 +0200 Subject: [PATCH 048/400] RS -> danaRS finished --- .../info/nightscout/androidaps/MainApp.java | 10 +- .../androidaps/db/DatabaseHelper.java | 4 +- .../androidaps/db/DatabaseHelperProvider.java | 68 +++++++++++++ .../dependencyInjection/AppModule.kt | 8 +- .../dependencyInjection/FragmentsModule.kt | 2 +- .../androidaps/dialogs/CarbsDialog.kt | 3 +- .../androidaps/dialogs/CareDialog.kt | 3 +- .../androidaps/dialogs/FillDialog.kt | 31 +----- .../plugins/aps/loop/LoopPlugin.java | 7 +- .../objectives/ObjectivesFragment.kt | 4 +- .../automation/actions/ActionNotification.kt | 3 +- .../Dialogs/NewNSTreatmentDialog.java | 3 +- .../plugins/general/food/FoodFragment.kt | 3 +- .../general/nsclient/NSClientFragment.java | 7 +- .../general/nsclient/NSClientPlugin.java | 4 - .../plugins/general/nsclient/UploadQueue.java | 87 ++++++++++------- .../nsclient/services/NSClientService.java | 62 ++++++------ .../general/overview/OverviewFragment.kt | 8 +- .../general/overview/graphData/GraphData.kt | 4 +- .../plugins/general/wear/WearPlugin.kt | 2 +- .../wearintegration/WatchUpdaterService.java | 8 +- .../profile/local/LocalProfilePlugin.kt | 5 +- .../plugins/pump/combo/ComboPlugin.java | 4 +- .../pump/common/PumpPluginAbstract.java | 4 +- .../pump/danaR/AbstractDanaRPlugin.java | 4 +- .../pump/danaR/comm/MessageHashTableR.kt | 4 +- .../plugins/pump/danaR/comm/MsgError.kt | 5 +- .../plugins/pump/danaR/comm/MsgHistoryAll.kt | 2 +- .../danaR/services/DanaRExecutionService.java | 3 +- .../comm/MessageHashTableRKorean.kt | 4 +- .../services/DanaRKoreanExecutionService.java | 3 +- .../pump/danaRv2/comm/MessageHashTableRv2.kt | 4 +- .../services/DanaRv2ExecutionService.java | 3 +- .../pump/insight/LocalInsightPlugin.java | 27 ++--- .../plugins/pump/mdi/MDIPlugin.java | 4 +- .../medtronic/data/MedtronicHistoryData.java | 5 +- .../wizard/pages/InitPodRefreshAction.java | 3 +- .../plugins/pump/virtual/VirtualPumpPlugin.kt | 4 +- .../androidaps/plugins/source/DexcomPlugin.kt | 11 ++- .../plugins/source/EversensePlugin.kt | 9 +- .../plugins/source/PoctechPlugin.kt | 7 +- .../androidaps/plugins/source/TomatoPlugin.kt | 7 +- .../fragments/TreatmentsBolusFragment.kt | 10 +- .../fragments/TreatmentsCareportalFragment.kt | 10 +- .../TreatmentsExtendedBolusesFragment.kt | 6 +- .../TreatmentsProfileSwitchFragment.kt | 6 +- .../TreatmentsTempTargetFragment.java | 6 +- .../TreatmentsTemporaryBasalsFragment.kt | 6 +- .../androidaps/receivers/KeepAliveReceiver.kt | 6 +- .../androidaps/services/DataService.java | 4 +- .../nightscout/androidaps/utils/HardLimits.kt | 13 +-- .../androidaps/utils/LocalAlertUtils.kt | 5 +- .../androidaps/utils/stats/TddCalculator.kt | 4 +- app/src/main/res/layout/okcancel.xml | 44 +++++++++ app/src/main/res/values/colors.xml | 2 - app/src/main/res/values/strings.xml | 92 +----------------- .../activities/TDDStatsActivity.java | 27 ++--- .../androidaps}/dialogs/NtpProgressDialog.kt | 6 +- .../androidaps/dialogs/ProfileViewerDialog.kt | 12 +-- .../events/EventDanaRSyncStatus.kt | 2 +- .../events/EventExtendedBolusChange.kt | 0 .../nightscout/androidaps/events/EventLoop.kt | 0 .../androidaps}/events/EventNtpStatus.kt | 2 +- .../androidaps/events/EventTempBasalChange.kt | 0 .../interfaces/DatabaseHelperInterface.kt | 18 +++- .../androidaps/interfaces/PumpInterface.java | 2 +- .../plugins/general/nsclient/NSUpload.java | 41 +++++++- .../treatments/fragments/ProfileGraph.kt | 0 .../queue/events/EventQueueChanged.kt | 0 .../utils/DigitsKeyListenerWithComma.java | 0 .../androidaps/utils/NumberPicker.java | 2 +- .../nightscout/androidaps/utils/WarnColors.kt | 2 +- .../CompositeDisposablePlusAssign.kt | 0 .../utils/extensions/Concurrency.kt | 0 core/src/main/res/layout/close.xml | 19 ++++ .../main/res/layout/danar_statsactivity.xml | 0 .../main/res/layout/dialog_profileviewer.xml | 0 .../main/res/layout/number_picker_layout.xml | 0 .../src/main/res/layout/spinner_centered.xml | 0 {app => core}/src/main/res/raw/boluserror.mp3 | Bin core/src/main/res/values/colors.xml | 4 + core/src/main/res/values/strings.xml | 32 ++++++ danars/build.gradle | 6 ++ .../plugins/pump/danaR/DanaRFragment.kt | 8 +- .../danaR/activities/DanaRHistoryActivity.kt | 34 +++---- .../activities/DanaRUserOptionsActivity.kt | 27 +++-- .../plugins/pump/danaRS/DanaRSPlugin.kt | 4 +- .../pump/danaRS/comm/DanaRS_Packet.java | 13 +-- .../comm/DanaRS_Packet_APS_History_Events.kt | 7 +- .../DanaRS_Packet_Bolus_Get_Bolus_Option.kt | 1 - ...DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.kt | 2 +- .../DanaRS_Packet_General_Get_Pump_Check.kt | 2 +- .../danaRS/comm/DanaRS_Packet_History_.kt | 7 +- .../danaRS/comm/DanaRS_Packet_Notify_Alarm.kt | 5 +- .../DanaRS_Packet_Notify_Delivery_Complete.kt | 2 +- ...aRS_Packet_Notify_Delivery_Rate_Display.kt | 2 +- .../plugins/pump/danaRS/services/BLEComm.kt | 7 +- .../pump/danaRS/services/DanaRSService.kt | 4 +- .../src/main/res/layout/danar_fragment.xml | 0 .../main/res/layout/danar_history_item.xml | 0 .../main/res/layout/danar_historyactivity.xml | 0 .../layout/danar_user_options_activity.xml | 0 danars/src/main/res/layout/okcancel.xml | 44 +++++++++ danars/src/main/res/values/strings.xml | 62 ++++++++++++ 104 files changed, 666 insertions(+), 407 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java create mode 100644 app/src/main/res/layout/okcancel.xml rename {app => core}/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java (94%) rename {app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives => core/src/main/java/info/nightscout/androidaps}/dialogs/NtpProgressDialog.kt (94%) rename {app => core}/src/main/java/info/nightscout/androidaps/dialogs/ProfileViewerDialog.kt (89%) rename {app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR => core/src/main/java/info/nightscout/androidaps}/events/EventDanaRSyncStatus.kt (63%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventExtendedBolusChange.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventLoop.kt (100%) rename {app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives => core/src/main/java/info/nightscout/androidaps}/events/EventNtpStatus.kt (61%) rename {app => core}/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/ProfileGraph.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/queue/events/EventQueueChanged.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/DigitsKeyListenerWithComma.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/NumberPicker.java (99%) rename app/src/main/java/info/nightscout/androidaps/utils/SetWarnColor.kt => core/src/main/java/info/nightscout/androidaps/utils/WarnColors.kt (97%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/extensions/CompositeDisposablePlusAssign.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/extensions/Concurrency.kt (100%) create mode 100644 core/src/main/res/layout/close.xml rename {app => core}/src/main/res/layout/danar_statsactivity.xml (100%) rename {app => core}/src/main/res/layout/dialog_profileviewer.xml (100%) rename {app => core}/src/main/res/layout/number_picker_layout.xml (100%) rename {app => core}/src/main/res/layout/spinner_centered.xml (100%) rename {app => core}/src/main/res/raw/boluserror.mp3 (100%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRHistoryActivity.kt (84%) rename {app => danars}/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRUserOptionsActivity.kt (88%) rename {app => danars}/src/main/res/layout/danar_fragment.xml (100%) rename {app => danars}/src/main/res/layout/danar_history_item.xml (100%) rename {app => danars}/src/main/res/layout/danar_historyactivity.xml (100%) rename {app => danars}/src/main/res/layout/danar_user_options_activity.xml (100%) create mode 100644 danars/src/main/res/layout/okcancel.xml diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 85d8f83ed7..27d60be03c 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -23,6 +23,7 @@ import javax.inject.Inject; import dagger.android.AndroidInjector; import dagger.android.DaggerApplication; import info.nightscout.androidaps.db.BgReading; +import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.StaticInjector; import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent; @@ -45,7 +46,7 @@ import info.nightscout.androidaps.utils.ActivityMonitor; import info.nightscout.androidaps.utils.LocaleHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; -public class MainApp extends DaggerApplication implements DatabaseHelperInterface { +public class MainApp extends DaggerApplication { static MainApp sInstance; private static Resources sResources; @@ -57,6 +58,7 @@ public class MainApp extends DaggerApplication implements DatabaseHelperInterfac @Inject ActivityMonitor activityMonitor; @Inject VersionCheckerUtils versionCheckersUtils; @Inject SP sp; + @Inject NSUpload nsUpload; @Inject ConfigBuilderPlugin configBuilderPlugin; @Inject KeepAliveReceiver.KeepAliveManager keepAliveManager; @@ -99,7 +101,7 @@ public class MainApp extends DaggerApplication implements DatabaseHelperInterfac pluginStore.setPlugins(plugins); configBuilderPlugin.initialize(); - NSUpload.uploadAppStart(); + nsUpload.uploadAppStart(); new Thread(() -> keepAliveManager.setAlarm(this)).start(); doMigrations(); @@ -173,8 +175,4 @@ public class MainApp extends DaggerApplication implements DatabaseHelperInterfac keepAliveManager.cancelAlarm(this); super.onTerminate(); } - - @NotNull @Override public List getAllBgreadingsDataFromTime(long mills, boolean ascending) { - return getDbHelper().getAllBgreadingsDataFromTime(mills, ascending); - } } 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 abc6df92c9..b5e5c89819 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -1733,7 +1733,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } */ - public void createProfileSwitchFromJsonIfNotExists(ActivePluginProvider activePluginProvider, JSONObject trJson) { + public void createProfileSwitchFromJsonIfNotExists(ActivePluginProvider activePluginProvider, NSUpload nsUpload, JSONObject trJson) { try { ProfileSwitch profileSwitch = new ProfileSwitch(MainApp.instance()); profileSwitch.date = trJson.getLong("mills"); @@ -1759,7 +1759,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { if (L.isEnabled(LTag.DATABASE)) log.debug("Profile switch prefilled with JSON from local store"); // Update data in NS - NSUpload.updateProfileSwitch(profileSwitch); + nsUpload.updateProfileSwitch(profileSwitch); } else { if (L.isEnabled(LTag.DATABASE)) log.debug("JSON for profile switch doesn't exist. Ignoring: " + trJson.toString()); diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java new file mode 100644 index 0000000000..60c7578b74 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java @@ -0,0 +1,68 @@ +package info.nightscout.androidaps.db; + +import com.j256.ormlite.dao.CloseableIterator; + +import org.jetbrains.annotations.NotNull; + +import java.sql.SQLException; +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; + +@Singleton +public class DatabaseHelperProvider implements DatabaseHelperInterface { + + @Inject DatabaseHelperProvider() {} + + @NotNull @Override public List getAllBgreadingsDataFromTime(long mills, boolean ascending) { + return MainApp.getDbHelper().getAllBgreadingsDataFromTime(mills, ascending); + } + + @Override public void createOrUpdate(@NotNull CareportalEvent careportalEvent) { + MainApp.getDbHelper().createOrUpdate(careportalEvent); + } + + @Override public void createOrUpdate(@NotNull DanaRHistoryRecord record) { + MainApp.getDbHelper().createOrUpdate(record); + } + + @NotNull @Override public List getDanaRHistoryRecordsByType(byte type) { + return MainApp.getDbHelper().getDanaRHistoryRecordsByType(type); + } + + @NotNull @Override public List getTDDs() { + return MainApp.getDbHelper().getTDDs(); + } + + @Override public long size(@NotNull String table) { + return MainApp.getDbHelper().size(table); + } + + @Override public void create(@NotNull DbRequest record) { + try { + MainApp.getDbHelper().create(record); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Override public void deleteAllDbRequests() { + MainApp.getDbHelper().deleteAllDbRequests(); + } + + @Override public int deleteDbRequest(@NotNull String id) { + return MainApp.getDbHelper().deleteDbRequest(id); + } + + @Override public void deleteDbRequestbyMongoId(@NotNull String action, @NotNull String _id) { + MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id); + } + + @NotNull @Override public CloseableIterator getDbRequestInterator() { + return MainApp.getDbHelper().getDbRequestInterator(); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index e405ab91fd..16543e8a86 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -8,13 +8,16 @@ import dagger.Provides import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.db.DatabaseHelperProvider import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.configBuilder.PluginStore import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation +import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.CommandQueue import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.androidNotification.NotificationHolder import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.storage.FileStorage @@ -61,11 +64,12 @@ open class AppModule { @Binds fun bindContext(mainApp: MainApp): Context @Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector - @Binds fun bindDatabaseHelperInterface(mainApp: MainApp): DatabaseHelperInterface @Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider @Binds fun commandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider @Binds fun configInterfaceProvider(config: Config): ConfigInterface @Binds fun treatmentInterfaceProvider(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface - + @Binds fun provideDatabaseHelperInterface(databaseHelperProvider: DatabaseHelperProvider): DatabaseHelperInterface + @Binds fun provideUploadQueueInterface(uploadQueue: UploadQueue): UploadQueueInterface + @Binds fun provideNotificationHolderInterface(notificationHolder: NotificationHolder): NotificationHolderInterface } } 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 89783c9e4f..8748891d07 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/FragmentsModule.kt @@ -10,7 +10,7 @@ import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBFragment import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog -import info.nightscout.androidaps.plugins.constraints.objectives.dialogs.NtpProgressDialog +import info.nightscout.androidaps.dialogs.NtpProgressDialog import info.nightscout.androidaps.plugins.general.actions.ActionsFragment import info.nightscout.androidaps.plugins.general.automation.AutomationFragment import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseActionDialog diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt index 28abd8eb60..31ced947d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -40,6 +40,7 @@ class CarbsDialog : DialogFragmentWithDate() { @Inject lateinit var treatmentsPlugin: TreatmentsPlugin @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin + @Inject lateinit var nsUpload: NSUpload @Inject lateinit var carbsGenerator: CarbsGenerator companion object { @@ -233,7 +234,7 @@ class CarbsDialog : DialogFragmentWithDate() { } else { aapsLogger.debug("USER ENTRY: CARBS $carbsAfterConstraints time: $time duration: $duration") carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes) - NSUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) + nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) } } }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index 1eda2e060e..f9fa675438 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -36,6 +36,7 @@ class CareDialog : DialogFragmentWithDate() { @Inject lateinit var mainApp: MainApp @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var nsUpload: NSUpload @Inject lateinit var translator: Translator enum class EventType { @@ -197,7 +198,7 @@ class CareDialog : DialogFragmentWithDate() { careportalEvent.json = json.toString() aapsLogger.debug("USER ENTRY: CAREPORTAL ${careportalEvent.eventType} json: ${careportalEvent.json}") MainApp.getDbHelper().createOrUpdate(careportalEvent) - NSUpload.uploadCareportalEntryToNS(json) + nsUpload.uploadCareportalEntryToNS(json) }, null) } return true diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt index eb5e9ccf59..580b27228c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -40,9 +40,9 @@ class FillDialog : DialogFragmentWithDate() { @Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var ctx: Context + @Inject lateinit var nsUpload: NSUpload @Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var activePlugin: ActivePluginProvider - @Inject lateinit var injector: HasAndroidInjector override fun onSaveInstanceState(savedInstanceState: Bundle) { super.onSaveInstanceState(savedInstanceState) @@ -124,12 +124,12 @@ class FillDialog : DialogFragmentWithDate() { } if (siteChange) { aapsLogger.debug("USER ENTRY: SITE CHANGE") - generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes, resourceHelper, sp, injector) + nsUpload.generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes) } if (insulinChange) { // add a second for case of both checked aapsLogger.debug("USER ENTRY: INSULIN CHANGE") - generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes, resourceHelper, sp, injector) + nsUpload.generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes) } }, null) } @@ -162,29 +162,4 @@ class FillDialog : DialogFragmentWithDate() { } }) } - - companion object { - fun generateCareportalEvent(eventType: String, time: Long, notes: String, resourceHelper: ResourceHelper, sp: SP, injector: HasAndroidInjector) { - val careportalEvent = CareportalEvent(injector) - careportalEvent.source = Source.USER - careportalEvent.date = time - careportalEvent.json = generateJson(eventType, time, notes, resourceHelper, sp).toString() - careportalEvent.eventType = eventType - MainApp.getDbHelper().createOrUpdate(careportalEvent) - NSUpload.uploadEvent(eventType, time, notes) - } - - private fun generateJson(careportalEvent: String, time: Long, notes: String, resourceHelper: ResourceHelper, sp: SP): JSONObject { - val data = JSONObject() - try { - data.put("eventType", careportalEvent) - data.put("created_at", DateUtil.toISOString(time)) - data.put("mills", time) - data.put("enteredBy", sp.getString("careportal_enteredby", resourceHelper.gs(R.string.app_name))) - if (notes.isNotEmpty()) data.put("notes", notes) - } catch (ignored: JSONException) { - } - return data - } - } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java index f04035277e..6b25f97882 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java @@ -22,6 +22,7 @@ import javax.inject.Singleton; import dagger.Lazy; import dagger.android.HasAndroidInjector; +import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainApp; @@ -103,7 +104,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface { private boolean isSuperBolus; private boolean isDisconnected; - @Nullable public LastRun lastRun = null; + @Nullable private LastRun lastRun = null; @Nullable @Override public LastRun getLastRun() { return lastRun; @@ -412,7 +413,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface { lastRun.setLastSMBEnact(0); lastRun.setLastSMBRequest(0); - nsUpload.uploadDeviceStatus(this, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore); + nsUpload.uploadDeviceStatus(this, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore, BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); if (isSuspended()) { getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended)); @@ -537,7 +538,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface { lastRun.setLastTBRRequest(lastRun.getLastAPSRun()); lastRun.setLastTBREnact(DateUtil.now()); lastRun.setLastOpenModeAccept(DateUtil.now()); - nsUpload.uploadDeviceStatus(lp, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore); + nsUpload.uploadDeviceStatus(lp, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore, BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); sp.incInt(R.string.key_ObjectivesmanualEnacts); } rxBus.send(new EventAcceptOpenLoopChange()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index 1e01d814f6..69a8892bdc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -22,8 +22,8 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog -import info.nightscout.androidaps.plugins.constraints.objectives.dialogs.NtpProgressDialog -import info.nightscout.androidaps.plugins.constraints.objectives.events.EventNtpStatus +import info.nightscout.androidaps.dialogs.NtpProgressDialog +import info.nightscout.androidaps.events.EventNtpStatus import info.nightscout.androidaps.plugins.constraints.objectives.events.EventObjectivesUpdateGui import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective.ExamTask import info.nightscout.androidaps.receivers.ReceiverStatusStore diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt index 7a730585c1..43342f35e5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt @@ -22,6 +22,7 @@ import javax.inject.Inject class ActionNotification(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var nsUpload: NSUpload var text = InputString(injector) @@ -32,7 +33,7 @@ class ActionNotification(injector: HasAndroidInjector) : Action(injector) { override fun doAction(callback: Callback) { val notification = NotificationUserMessage(text.value) rxBus.send(EventNewNotification(notification)) - NSUpload.uploadError(text.value) + nsUpload.uploadError(text.value) rxBus.send(EventRefreshOverview("ActionNotification")) callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java index 8fe577ced3..52d7a25c49 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java @@ -78,6 +78,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O @Inject ActivePluginProvider activePlugin; @Inject TreatmentsPlugin treatmentsPlugin; @Inject HardLimits hardLimits; + @Inject NSUpload nsUpload; @Inject Translator translator; @Inject DateUtil dateUtil; @@ -714,7 +715,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O private void confirmNSTreatmentCreation() { final JSONObject data = gatherData(); - OKDialog.showConfirmation(getContext(), translator.translate(JsonHelper.safeGetString(data, "eventType", resourceHelper.gs(R.string.overview_treatment_label))), buildConfirmText(data), () -> NSUpload.createNSTreatment(data, profileStore, profileFunction, eventTime.getTime())); + OKDialog.showConfirmation(getContext(), translator.translate(JsonHelper.safeGetString(data, "eventType", resourceHelper.gs(R.string.overview_treatment_label))), buildConfirmText(data), () -> nsUpload.createNSTreatment(data, profileStore, profileFunction, eventTime.getTime())); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt index c54e383afc..d4efd0ff96 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt @@ -35,6 +35,7 @@ class FoodFragment : DaggerFragment() { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var foodPlugin: FoodPlugin + @Inject lateinit var nsUpload: NSUpload private val disposable = CompositeDisposable() private lateinit var unfiltered: List @@ -200,7 +201,7 @@ class FoodFragment : DaggerFragment() { activity?.let { activity -> showConfirmation(activity, resourceHelper.gs(R.string.confirmation), resourceHelper.gs(R.string.removerecord) + "\n" + food.name, DialogInterface.OnClickListener { _: DialogInterface?, _: Int -> if (food._id != null && food._id != "") { - NSUpload.removeFoodFromNS(food._id) + nsUpload.removeFoodFromNS(food._id) } foodPlugin.service?.delete(food) }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java index 89d0f65bc7..27310dad90 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java @@ -33,6 +33,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList @Inject SP sp; @Inject ResourceHelper resourceHelper; @Inject RxBusWrapper rxBus; + @Inject UploadQueue uploadQueue; @Inject FabricPrivacy fabricPrivacy; private CompositeDisposable disposable = new CompositeDisposable(); @@ -119,13 +120,13 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList break; case R.id.nsclientinternal_clearqueue: OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> { - UploadQueue.clearQueue(); + uploadQueue.clearQueue(); updateGui(); fabricPrivacy.logCustom("NSClientClearQueue"); }); break; case R.id.nsclientinternal_showqueue: - rxBus.send(new EventNSClientNewLog("QUEUE", nsClientPlugin.queue().textList())); + rxBus.send(new EventNSClientNewLog("QUEUE", uploadQueue.textList())); break; } } @@ -154,7 +155,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList logScrollview.fullScroll(ScrollView.FOCUS_DOWN); } urlTextView.setText(nsClientPlugin.url()); - Spanned queuetext = Html.fromHtml(resourceHelper.gs(R.string.queue) + " " + UploadQueue.size() + ""); + Spanned queuetext = Html.fromHtml(resourceHelper.gs(R.string.queue) + " " + uploadQueue.size() + ""); queueTextView.setText(queuetext); statusTextView.setText(nsClientPlugin.status); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java index da77936384..9443e23e39 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java @@ -253,10 +253,6 @@ public class NSClientPlugin extends PluginBase { rxBus.send(new EventPreferenceChange(resourceHelper, R.string.key_nsclientinternal_paused)); } - public UploadQueue queue() { - return NSClientService.uploadQueue; - } - public String url() { return NSClientService.nsURL; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/UploadQueue.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/UploadQueue.java index d9bd5a6307..08fecd9283 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/UploadQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/UploadQueue.java @@ -8,71 +8,86 @@ import com.j256.ormlite.dao.CloseableIterator; import org.json.JSONException; import org.json.JSONObject; -import org.slf4j.Logger; import java.sql.SQLException; -import info.nightscout.androidaps.MainApp; +import javax.inject.Inject; + import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DbRequest; +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.interfaces.UploadQueueInterface; -import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; -import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientResend; import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService; -import info.nightscout.androidaps.utils.SP; +import info.nightscout.androidaps.utils.sharedPreferences.SP; /** * Created by mike on 21.02.2016. */ public class UploadQueue implements UploadQueueInterface { - private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT); + private final AAPSLogger aapsLogger; + private final DatabaseHelperInterface databaseHelper; + private final Context context; + private final SP sp; + private final RxBusWrapper rxBus; - public static String status() { - return "QUEUE: " + MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS); + @Inject + public UploadQueue( + AAPSLogger aapsLogger, + DatabaseHelperInterface databaseHelper, + Context context, + SP sp, + RxBusWrapper rxBus + ) { + this.aapsLogger = aapsLogger; + this.databaseHelper = databaseHelper; + this.context = context; + this.sp = sp; + this.rxBus = rxBus; } - public static long size() { - return MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS); + public String status() { + return "QUEUE: " + databaseHelper.size(DatabaseHelper.DATABASE_DBREQUESTS); } - private static void startService() { + public long size() { + return databaseHelper.size(DatabaseHelper.DATABASE_DBREQUESTS); + } + + private void startService() { if (NSClientService.handler == null) { - Context context = MainApp.instance(); context.startService(new Intent(context, NSClientService.class)); SystemClock.sleep(2000); } } - public static void add(final DbRequest dbr) { - if (SP.getBoolean(R.string.key_ns_noupload, false)) return; - if (L.isEnabled(LTag.NSCLIENT)) - log.debug("Adding to queue: " + dbr.log()); + public void add(final DbRequest dbr) { + if (sp.getBoolean(R.string.key_ns_noupload, false)) return; + aapsLogger.debug(LTag.NSCLIENT, "Adding to queue: " + dbr.log()); try { - MainApp.getDbHelper().create(dbr); + databaseHelper.create(dbr); } catch (Exception e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } - RxBus.getINSTANCE().send(new EventNSClientResend("newdata")); + rxBus.send(new EventNSClientResend("newdata")); } - static void clearQueue() { + void clearQueue() { startService(); if (NSClientService.handler != null) { NSClientService.handler.post(() -> { - if (L.isEnabled(LTag.NSCLIENT)) - log.debug("ClearQueue"); - MainApp.getDbHelper().deleteAllDbRequests(); - if (L.isEnabled(LTag.NSCLIENT)) - log.debug(status()); + aapsLogger.debug(LTag.NSCLIENT, "ClearQueue"); + databaseHelper.deleteAllDbRequests(); + aapsLogger.debug(LTag.NSCLIENT, status()); }); } } - public static void removeID(final JSONObject record) { + public void removeID(final JSONObject record) { startService(); if (NSClientService.handler != null) { NSClientService.handler.post(() -> { @@ -83,26 +98,24 @@ public class UploadQueue implements UploadQueueInterface { } else { return; } - if (MainApp.getDbHelper().deleteDbRequest(id) == 1) { - if (L.isEnabled(LTag.NSCLIENT)) - log.debug("Removed item from UploadQueue. " + UploadQueue.status()); + if (databaseHelper.deleteDbRequest(id) == 1) { + aapsLogger.debug(LTag.NSCLIENT, "Removed item from UploadQueue. " + status()); } } catch (JSONException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } }); } } - public static void removeID(final String action, final String _id) { + public void removeID(final String action, final String _id) { if (_id == null || _id.equals("")) return; startService(); if (NSClientService.handler != null) { NSClientService.handler.post(() -> { - MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id); - if (L.isEnabled(LTag.NSCLIENT)) - log.debug("Removing " + _id + " from UploadQueue. " + UploadQueue.status()); + databaseHelper.deleteDbRequestbyMongoId(action, _id); + aapsLogger.debug(LTag.NSCLIENT, "Removing " + _id + " from UploadQueue. " + status()); }); } } @@ -111,7 +124,7 @@ public class UploadQueue implements UploadQueueInterface { String result = ""; CloseableIterator iterator; try { - iterator = MainApp.getDbHelper().getDbRequestInterator(); + iterator = databaseHelper.getDbRequestInterator(); try { while (iterator.hasNext()) { DbRequest dbr = iterator.next(); @@ -124,7 +137,7 @@ public class UploadQueue implements UploadQueueInterface { iterator.close(); } } catch (SQLException e) { - log.error("Unhandled exception", e); + aapsLogger.error("Unhandled exception", e); } return result; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java index 3187ccc924..195bb577cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java @@ -31,15 +31,15 @@ import javax.inject.Inject; import dagger.android.DaggerService; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.db.DbRequest; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventConfigBuilderChange; import info.nightscout.androidaps.events.EventNsFood; import info.nightscout.androidaps.events.EventPreferenceChange; +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag; @@ -83,7 +83,7 @@ public class NSClientService extends DaggerService { @Inject AAPSLogger aapsLogger; @Inject NSSettingsStatus nsSettingsStatus; @Inject NSDeviceStatus nsDeviceStatus; - @Inject MainApp mainApp; + @Inject DatabaseHelperInterface databaseHelper; @Inject RxBusWrapper rxBus; @Inject ResourceHelper resourceHelper; @Inject SP sp; @@ -91,6 +91,7 @@ public class NSClientService extends DaggerService { @Inject BuildHelper buildHelper; @Inject Config config; @Inject DateUtil dateUtil; + @Inject UploadQueue uploadQueue; private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT); private CompositeDisposable disposable = new CompositeDisposable(); @@ -124,8 +125,6 @@ public class NSClientService extends DaggerService { private String nsAPIhashCode = ""; - public static UploadQueue uploadQueue = new UploadQueue(); - private final ArrayList reconnections = new ArrayList<>(); private int WATCHDOG_INTERVAL_MINUTES = 2; private int WATCHDOG_RECONNECT_IN = 15; @@ -143,7 +142,7 @@ public class NSClientService extends DaggerService { @Override public void onCreate() { super.onCreate(); - PowerManager powerManager = (PowerManager) mainApp.getApplicationContext().getSystemService(Context.POWER_SERVICE); + PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:NSClientService"); mWakeLock.acquire(); @@ -528,7 +527,7 @@ public class NSClientService extends DaggerService { @Override public void call(final Object... args) { NSClientService.handler.post(() -> { - PowerManager powerManager = (PowerManager) mainApp.getApplicationContext().getSystemService(Context.POWER_SERVICE); + PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:NSClientService_onDataUpdate"); wakeLock.acquire(); @@ -604,7 +603,7 @@ public class NSClientService extends DaggerService { NSTreatment treatment = new NSTreatment(jsonTreatment); // remove from upload queue if Ack is failing - UploadQueue.removeID(jsonTreatment); + uploadQueue.removeID(jsonTreatment); //Find latest date in treatment if (treatment.getMills() != null && treatment.getMills() < System.currentTimeMillis()) if (treatment.getMills() > latestDateInReceivedData) @@ -636,7 +635,7 @@ public class NSClientService extends DaggerService { for (Integer index = 0; index < devicestatuses.length(); index++) { JSONObject jsonStatus = devicestatuses.getJSONObject(index); // remove from upload queue if Ack is failing - UploadQueue.removeID(jsonStatus); + uploadQueue.removeID(jsonStatus); } nsDeviceStatus.handleNewData(devicestatuses); } @@ -652,7 +651,7 @@ public class NSClientService extends DaggerService { JSONObject jsonFood = foods.getJSONObject(index); // remove from upload queue if Ack is failing - UploadQueue.removeID(jsonFood); + uploadQueue.removeID(jsonFood); String action = JsonHelper.safeGetString(jsonFood, "action"); @@ -684,7 +683,7 @@ public class NSClientService extends DaggerService { for (Integer index = 0; index < mbgs.length(); index++) { JSONObject jsonMbg = mbgs.getJSONObject(index); // remove from upload queue if Ack is failing - UploadQueue.removeID(jsonMbg); + uploadQueue.removeID(jsonMbg); } handleNewMbg(mbgs, isDelta); } @@ -695,7 +694,7 @@ public class NSClientService extends DaggerService { // Retreive actual calibration for (Integer index = 0; index < cals.length(); index++) { // remove from upload queue if Ack is failing - UploadQueue.removeID(cals.optJSONObject(index)); + uploadQueue.removeID(cals.optJSONObject(index)); } handleNewCal(cals, isDelta); } @@ -709,7 +708,7 @@ public class NSClientService extends DaggerService { NSSgv sgv = new NSSgv(jsonSgv); // Handle new sgv here // remove from upload queue if Ack is failing - UploadQueue.removeID(jsonSgv); + uploadQueue.removeID(jsonSgv); //Find latest date in sgv if (sgv.getMills() != null && sgv.getMills() < System.currentTimeMillis()) if (sgv.getMills() > latestDateInReceivedData) @@ -795,7 +794,7 @@ public class NSClientService extends DaggerService { } public void resend(final String reason) { - if (UploadQueue.size() == 0) + if (uploadQueue.size() == 0) return; if (!isConnected || !hasWriteAuth) return; @@ -804,8 +803,7 @@ public class NSClientService extends DaggerService { if (mSocket == null || !mSocket.connected()) return; if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) { - if (L.isEnabled(LTag.NSCLIENT)) - log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec"); + aapsLogger.debug(LTag.NSCLIENT, "Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec"); return; } lastResendTime = System.currentTimeMillis(); @@ -815,7 +813,7 @@ public class NSClientService extends DaggerService { CloseableIterator iterator; int maxcount = 30; try { - iterator = mainApp.getDbHelper().getDbRequestInterator(); + iterator = databaseHelper.getDbRequestInterator(); try { while (iterator.hasNext() && maxcount > 0) { DbRequest dbr = iterator.next(); @@ -852,7 +850,7 @@ public class NSClientService extends DaggerService { private void handleAnnouncement(JSONObject announcement) { NSAlarm nsAlarm = new NSAlarm(announcement); - Notification notification = new NotificationWithAction(mainApp, nsAlarm); + Notification notification = new NotificationWithAction(injector, nsAlarm); rxBus.send(new EventNewNotification(notification)); rxBus.send(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(announcement, "message", "received"))); aapsLogger.debug(LTag.NSCLIENT, announcement.toString()); @@ -862,7 +860,7 @@ public class NSClientService extends DaggerService { long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L); if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { NSAlarm nsAlarm = new NSAlarm(alarm); - Notification notification = new NotificationWithAction(mainApp, nsAlarm); + Notification notification = new NotificationWithAction(injector, nsAlarm); rxBus.send(new EventNewNotification(notification)); } rxBus.send(new EventNSClientNewLog("ALARM", JsonHelper.safeGetString(alarm, "message", "received"))); @@ -873,7 +871,7 @@ public class NSClientService extends DaggerService { long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L); if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { NSAlarm nsAlarm = new NSAlarm(alarm); - Notification notification = new NotificationWithAction(mainApp, nsAlarm); + Notification notification = new NotificationWithAction(injector, nsAlarm); rxBus.send(new EventNewNotification(notification)); } rxBus.send(new EventNSClientNewLog("URGENTALARM", JsonHelper.safeGetString(alarm, "message", "received"))); @@ -887,7 +885,7 @@ public class NSClientService extends DaggerService { Intent intent = new Intent(Intents.ACTION_NEW_CAL); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent); + LocalBroadcastManager.getInstance(this).sendBroadcast(intent); } public void handleNewMbg(JSONArray mbgs, boolean isDelta) { @@ -897,7 +895,7 @@ public class NSClientService extends DaggerService { Intent intent = new Intent(Intents.ACTION_NEW_MBG); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent); + LocalBroadcastManager.getInstance(this).sendBroadcast(intent); } public void handleNewProfile(ProfileStore profile, boolean isDelta) { @@ -907,7 +905,7 @@ public class NSClientService extends DaggerService { Intent intent = new Intent(Intents.ACTION_NEW_PROFILE); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent); + LocalBroadcastManager.getInstance(this).sendBroadcast(intent); if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) { bundle = new Bundle(); @@ -916,7 +914,7 @@ public class NSClientService extends DaggerService { intent = new Intent(Intents.ACTION_NEW_PROFILE); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - mainApp.sendBroadcast(intent); + this.sendBroadcast(intent); } } @@ -929,7 +927,7 @@ public class NSClientService extends DaggerService { Intent intent = new Intent(Intents.ACTION_NEW_SGV); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent); + LocalBroadcastManager.getInstance(this).sendBroadcast(intent); } if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) { @@ -940,7 +938,7 @@ public class NSClientService extends DaggerService { Intent intent = new Intent(Intents.ACTION_NEW_SGV); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - mainApp.sendBroadcast(intent); + this.sendBroadcast(intent); } } } @@ -954,7 +952,7 @@ public class NSClientService extends DaggerService { Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent); + LocalBroadcastManager.getInstance(this).sendBroadcast(intent); } if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) { @@ -966,7 +964,7 @@ public class NSClientService extends DaggerService { Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - mainApp.getApplicationContext().sendBroadcast(intent); + this.getApplicationContext().sendBroadcast(intent); } } } @@ -980,7 +978,7 @@ public class NSClientService extends DaggerService { Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent); + LocalBroadcastManager.getInstance(this).sendBroadcast(intent); } if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) { @@ -992,7 +990,7 @@ public class NSClientService extends DaggerService { Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - mainApp.getApplicationContext().sendBroadcast(intent); + this.getApplicationContext().sendBroadcast(intent); } } } @@ -1004,7 +1002,7 @@ public class NSClientService extends DaggerService { Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent); + LocalBroadcastManager.getInstance(this).sendBroadcast(intent); if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) { @@ -1014,7 +1012,7 @@ public class NSClientService extends DaggerService { intent = new Intent(Intents.ACTION_REMOVED_TREATMENT); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - mainApp.getApplicationContext().sendBroadcast(intent); + this.getApplicationContext().sendBroadcast(intent); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 2a462fb44a..bda7d5b249 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -20,6 +20,7 @@ import android.view.View.OnLongClickListener import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView +import androidx.core.text.toSpanned import androidx.recyclerview.widget.LinearLayoutManager import com.jjoe64.graphview.GraphView import dagger.android.HasAndroidInjector @@ -344,8 +345,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList if (loopPlugin.isEnabled(PluginType.LOOP)) { val lastRun = loopPlugin.lastRun loopPlugin.invoke("Accept temp button", false) - if (lastRun?.lastAPSRun != null && lastRun.constraintsProcessed.isChangeRequested) { - OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.pump_tempbasal_label), lastRun.constraintsProcessed.toSpanned(), Runnable { + if (lastRun?.lastAPSRun != null && lastRun.constraintsProcessed?.isChangeRequested == true) { + OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.pump_tempbasal_label), lastRun.constraintsProcessed?.toSpanned() + ?: "".toSpanned(), Runnable { aapsLogger.debug("USER ENTRY: ACCEPT TEMP BASAL") overview_accepttempbutton?.visibility = View.GONE (context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID) @@ -442,7 +444,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList val showAcceptButton = !closedLoopEnabled.value() && // Open mode needed lastRun != null && (lastRun.lastOpenModeAccept == 0L || lastRun.lastOpenModeAccept < lastRun.lastAPSRun) &&// never accepted or before last result - lastRun.constraintsProcessed.isChangeRequested // change is requested + lastRun.constraintsProcessed?.isChangeRequested == true // change is requested if (showAcceptButton && pump.isInitialized && !pump.isSuspended && loopPlugin.isEnabled(PluginType.LOOP)) { overview_accepttempbutton?.visibility = View.VISIBLE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt index 02ccf1480f..70e4f9f8fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt @@ -16,10 +16,10 @@ import info.nightscout.androidaps.data.IobTotal import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.LoopInterface import info.nightscout.androidaps.interfaces.TreatmentsInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin.LastRun import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.overview.graphExtensions.* @@ -197,7 +197,7 @@ class GraphData(injector: HasAndroidInjector, private val graph: GraphView, priv basalScale.setMultiplier(maxY * scale / maxBasalValueFound) } - fun addTargetLine(fromTime: Long, toTimeParam: Long, profile: Profile, lastRun: LastRun?) { + fun addTargetLine(fromTime: Long, toTimeParam: Long, profile: Profile, lastRun: LoopInterface.LastRun?) { var toTime = toTimeParam val targetsSeriesArray: MutableList = ArrayList() var lastTarget = -1.0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt index abff22eae3..02b201f5ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt @@ -104,7 +104,7 @@ class WearPlugin @Inject constructor( .observeOn(Schedulers.io()) .subscribe({ event: EventDismissBolusProgressIfRunning -> if (event.result == null) return@subscribe - val status: String = if (event.result.success) { + val status: String = if (event.result!!.success) { resourceHelper.gs(R.string.success) } else { resourceHelper.gs(R.string.nosuccess) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java index e0a0657826..dd0babf951 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java @@ -531,9 +531,9 @@ public class WatchUpdaterService extends WearableListenerService implements Goog } - final LoopPlugin.LastRun finalLastRun = loopPlugin.lastRun; - if (sp.getBoolean("wear_predictions", true) && finalLastRun != null && finalLastRun.request.hasPredictions && finalLastRun.constraintsProcessed != null) { - List predArray = finalLastRun.constraintsProcessed.getPredictions(); + final LoopPlugin.LastRun finalLastRun = loopPlugin.getLastRun(); + if (sp.getBoolean("wear_predictions", true) && finalLastRun != null && finalLastRun.getRequest().hasPredictions && finalLastRun.getConstraintsProcessed() != null) { + List predArray = finalLastRun.getConstraintsProcessed().getPredictions(); if (!predArray.isEmpty()) { for (BgReading bg : predArray) { @@ -715,7 +715,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog //OpenAPS status if (config.getAPS()) { //we are AndroidAPS - openApsStatus = loopPlugin.lastRun != null && loopPlugin.lastRun.lastTBREnact != 0 ? loopPlugin.lastRun.lastTBREnact : -1; + openApsStatus = loopPlugin.getLastRun() != null && loopPlugin.getLastRun().getLastTBREnact() != 0 ? loopPlugin.getLastRun().getLastTBREnact() : -1; } else { //NSClient or remote openApsStatus = NSDeviceStatus.getOpenApsTimestamp(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index 8d2761cfa3..7944707e57 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -37,7 +37,8 @@ class LocalProfilePlugin @Inject constructor( private val rxBus: RxBusWrapper, resourceHelper: ResourceHelper, private val sp: SP, - private val profileFunction: ProfileFunction + private val profileFunction: ProfileFunction, + private val nsUpload: NSUpload ) : PluginBase(PluginDescription() .mainType(PluginType.PROFILE) .fragmentClass(LocalProfileFragment::class.java.name) @@ -140,7 +141,7 @@ class LocalProfilePlugin @Inject constructor( if (name.contains(".")) namesOK = false } if (namesOK) - rawProfile?.let { NSUpload.uploadProfileStore(it.data) } + rawProfile?.let { nsUpload.uploadProfileStore(it.data) } else activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.profilenamecontainsdot)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index de9b4e66fc..50f40318d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -1259,7 +1259,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr } @NonNull @Override - public JSONObject getJSONStatus(Profile profile, String profileName) { + public JSONObject getJSONStatus(Profile profile, String profileName, String version) { if (!pump.initialized) { return null; } @@ -1281,7 +1281,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr pumpJson.put("status", statusJson); JSONObject extendedJson = new JSONObject(); - extendedJson.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); + extendedJson.put("Version", version); extendedJson.put("ActiveProfile", profileFunction.getProfileName()); PumpState ps = pump.state; if (ps.tbrActive) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java index 6d06f2e788..6227d2ea2a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java @@ -324,7 +324,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI @NonNull @Override - public JSONObject getJSONStatus(Profile profile, String profileName) { + public JSONObject getJSONStatus(Profile profile, String profileName, String version) { if ((getPumpStatusData().lastConnection + 5 * 60 * 1000L) < System.currentTimeMillis()) { return new JSONObject(); @@ -337,7 +337,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI try { battery.put("percent", getPumpStatusData().batteryRemaining); status.put("status", getPumpStatusData().pumpStatusType != null ? getPumpStatusData().pumpStatusType.getStatus() : "normal"); - extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); + extended.put("Version", version); try { extended.put("ActiveProfile", profileName); } catch (Exception ignored) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java index b055cacda3..3e0a853dc5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java @@ -366,7 +366,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump } @NonNull @Override - public JSONObject getJSONStatus(Profile profile, String profilename) { + public JSONObject getJSONStatus(Profile profile, String profilename, String version) { DanaRPump pump = danaRPump; long now = System.currentTimeMillis(); if (pump.getLastConnection() + 5 * 60 * 1000L < System.currentTimeMillis()) { @@ -380,7 +380,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump battery.put("percent", pump.getBatteryRemaining()); status.put("status", pump.getPumpSuspended() ? "suspended" : "normal"); status.put("timestamp", DateUtil.toISOString(pump.getLastConnection())); - extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); + extended.put("Version", version); if (pump.getLastBolusTime() != 0) { extended.put("LastBolus", dateUtil.dateAndTimeString(pump.getLastBolusTime())); extended.put("LastBolusAmount", pump.getLastBolusAmount()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableR.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableR.kt index dd4c59cee4..630bb9ecad 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableR.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageHashTableR.kt @@ -7,6 +7,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker +import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin @@ -28,6 +29,7 @@ class MessageHashTableR @Inject constructor( configBuilderPlugin: ConfigBuilderPlugin, commandQueue: CommandQueueProvider, activePlugin: ActivePluginProvider, + nsUpload: NSUpload, injector: HasAndroidInjector, dateUtil: DateUtil ) : MessageHashTableBase { @@ -54,7 +56,7 @@ class MessageHashTableR @Inject constructor( put(MsgSetTempBasalStop(aapsLogger)) // 0x0403 CMD_PUMPSET_EXERCISE_STOP put(MsgSetExtendedBolusStop(aapsLogger)) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S - put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS + put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump, nsUpload)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgError.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgError.kt index 6069520870..08d4c57324 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgError.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgError.kt @@ -13,7 +13,8 @@ class MsgError( private val aapsLogger: AAPSLogger, private val rxBus: RxBusWrapper, private val resourceHelper: ResourceHelper, - private val danaRPump: DanaRPump + private val danaRPump: DanaRPump, + private val nsUpload: NSUpload ) : MessageBase() { init { @@ -41,6 +42,6 @@ class MsgError( failed = false } aapsLogger.debug(LTag.PUMPCOMM, "Error detected: $errorString") - NSUpload.uploadError(errorString) + nsUpload.uploadError(errorString) } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt index b25a5b9b1f..26f48639d2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgHistoryAll.kt @@ -5,7 +5,7 @@ import info.nightscout.androidaps.db.DanaRHistoryRecord 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.danaR.events.EventDanaRSyncStatus +import info.nightscout.androidaps.events.EventDanaRSyncStatus import info.nightscout.androidaps.utils.DateUtil open class MsgHistoryAll( diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java index 73fe0ec10c..2a357761f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java @@ -83,6 +83,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { @Inject MessageHashTableR messageHashTableR; @Inject ActivePluginProvider activePlugin; @Inject ProfileFunction profileFunction; + @Inject NSUpload nsUpload; @Inject SP sp; @Inject HasAndroidInjector injector; @@ -214,7 +215,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, resourceHelper.gs(R.string.approachingdailylimit), Notification.URGENT); rxBus.send(new EventNewNotification(reportFail)); - NSUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U"); + nsUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U"); lastApproachingDailyLimit = System.currentTimeMillis(); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKorean.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKorean.kt index 882ab11739..67ce3eb6b4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKorean.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MessageHashTableRKorean.kt @@ -7,6 +7,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker +import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaR.comm.* @@ -30,6 +31,7 @@ class MessageHashTableRKorean @Inject constructor( commandQueue: CommandQueueProvider, activePlugin: ActivePluginProvider, dateUtil: DateUtil, + nsUpload: NSUpload, injector: HasAndroidInjector ) : MessageHashTableBase { @@ -52,7 +54,7 @@ class MessageHashTableRKorean @Inject constructor( put(MsgSetTempBasalStop(aapsLogger)) // 0x0403 CMD_PUMPSET_EXERCISE_STOP put(MsgSetExtendedBolusStop(aapsLogger)) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S - put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS + put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump, nsUpload)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java index 2f00754404..d8da9b78c2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java @@ -75,6 +75,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { @Inject MessageHashTableRKorean messageHashTableRKorean; @Inject ActivePluginProvider activePlugin; @Inject ProfileFunction profileFunction; + @Inject NSUpload nsUpload; @Inject DateUtil dateUtil; public DanaRKoreanExecutionService() { @@ -203,7 +204,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, resourceHelper.gs(R.string.approachingdailylimit), Notification.URGENT); rxBus.send(new EventNewNotification(reportFail)); - NSUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U"); + nsUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U"); lastApproachingDailyLimit = System.currentTimeMillis(); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt index 8833ea6b3f..836de3d6cc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MessageHashTableRv2.kt @@ -7,6 +7,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker +import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump @@ -35,6 +36,7 @@ class MessageHashTableRv2 @Inject constructor( activePlugin: ActivePluginProvider, detailedBolusInfoStorage: DetailedBolusInfoStorage, treatmentsPlugin: TreatmentsPlugin, + nsUpload: NSUpload, injector: HasAndroidInjector, dateUtil: DateUtil ) : MessageHashTableBase { @@ -60,7 +62,7 @@ class MessageHashTableRv2 @Inject constructor( put(MsgSetTempBasalStop(aapsLogger)) // 0x0403 CMD_PUMPSET_EXERCISE_STOP put(MsgSetExtendedBolusStop(aapsLogger)) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S - put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS + put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump, nsUpload)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java index 4c664ea1df..f072d3a8e1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java @@ -99,6 +99,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { @Inject DetailedBolusInfoStorage detailedBolusInfoStorage; @Inject TreatmentsPlugin treatmentsPlugin; @Inject ProfileFunction profileFunction; + @Inject NSUpload nsUpload; @Inject SP sp; @Inject DateUtil dateUtil; @@ -255,7 +256,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, resourceHelper.gs(R.string.approachingdailylimit), Notification.URGENT); rxBus.send(new EventNewNotification(reportFail)); - NSUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U"); + nsUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U"); lastApproachingDailyLimit = System.currentTimeMillis(); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index d44470bad1..f8d1cf1ce5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -27,7 +27,6 @@ import javax.inject.Inject; import javax.inject.Singleton; import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -39,6 +38,7 @@ import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TDD; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.interfaces.CommandQueueProvider; @@ -46,6 +46,7 @@ import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.ConstraintsInterface; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpPluginBase; @@ -53,7 +54,6 @@ import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.common.ManufacturerType; -import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; @@ -132,7 +132,6 @@ import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_erro import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.NoActiveTBRToCanceLException; import info.nightscout.androidaps.plugins.pump.insight.utils.ExceptionTranslator; import info.nightscout.androidaps.plugins.pump.insight.utils.ParameterBlockUtil; -import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.TimeChangeType; @@ -149,7 +148,9 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, private final SP sp; private final CommandQueueProvider commandQueue; private final ProfileFunction profileFunction; + private final NSUpload nsUpload; private final Context context; + private final UploadQueue uploadQueue; private final DateUtil dateUtil; public static final String ALERT_CHANNEL_ID = "AndroidAPS-InsightAlert"; @@ -209,7 +210,9 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, SP sp, CommandQueueProvider commandQueue, ProfileFunction profileFunction, + NSUpload nsUpload, Context context, + UploadQueue uploadQueue, Config config, DateUtil dateUtil ) { @@ -230,7 +233,9 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, this.sp = sp; this.commandQueue = commandQueue; this.profileFunction = profileFunction; + this.nsUpload = nsUpload; this.context = context; + this.uploadQueue = uploadQueue; this.dateUtil = dateUtil; pumpDescription = new PumpDescription(); @@ -929,8 +934,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, if (extendedBolus.durationInMinutes <= 0) { final String _id = extendedBolus._id; if (NSUpload.isIdValid(_id)) - NSUpload.removeCareportalEntryFromNS(_id); - else UploadQueue.removeID("dbAdd", _id); + nsUpload.removeCareportalEntryFromNS(_id); + else uploadQueue.removeID("dbAdd", _id); MainApp.getDbHelper().delete(extendedBolus); } else treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus); @@ -978,7 +983,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, } @NonNull @Override - public JSONObject getJSONStatus(Profile profile, String profileName) { + public JSONObject getJSONStatus(Profile profile, String profileName, String version) { long now = System.currentTimeMillis(); if (connectionService == null) return null; if (System.currentTimeMillis() - connectionService.getLastConnected() > (60 * 60 * 1000)) { @@ -991,7 +996,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, final JSONObject extended = new JSONObject(); try { status.put("timestamp", DateUtil.toISOString(connectionService.getLastConnected())); - extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); + extended.put("Version", version); try { extended.put("ActiveProfile", profileFunction.getProfileName()); } catch (Exception e) { @@ -1451,8 +1456,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, ExtendedBolus extendedBolus = MainApp.getDbHelper().getExtendedBolusByPumpId(bolusID.id); if (extendedBolus != null) { final String _id = extendedBolus._id; - if (NSUpload.isIdValid(_id)) NSUpload.removeCareportalEntryFromNS(_id); - else UploadQueue.removeID("dbAdd", _id); + if (NSUpload.isIdValid(_id)) nsUpload.removeCareportalEntryFromNS(_id); + else uploadQueue.removeID("dbAdd", _id); MainApp.getDbHelper().delete(extendedBolus); } } else { @@ -1583,7 +1588,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, careportalEvent.eventType = CareportalEvent.NOTE; careportalEvent.json = data.toString(); MainApp.getDbHelper().createOrUpdate(careportalEvent); - NSUpload.uploadCareportalEntryToNS(data); + nsUpload.uploadCareportalEntryToNS(data); } catch (JSONException e) { aapsLogger.error("Unhandled exception", e); } @@ -1617,7 +1622,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, careportalEvent.eventType = event; careportalEvent.json = data.toString(); MainApp.getDbHelper().createOrUpdate(careportalEvent); - NSUpload.uploadCareportalEntryToNS(data); + nsUpload.uploadCareportalEntryToNS(data); } catch (JSONException e) { aapsLogger.error("Unhandled exception", e); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java index b5d7fafb4e..44550ebea6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java @@ -227,14 +227,14 @@ public class MDIPlugin extends PumpPluginBase implements PumpInterface { } @NonNull @Override - public JSONObject getJSONStatus(Profile profile, String profileName) { + public JSONObject getJSONStatus(Profile profile, String profileName, String version) { long now = System.currentTimeMillis(); JSONObject pump = new JSONObject(); JSONObject status = new JSONObject(); JSONObject extended = new JSONObject(); try { status.put("status", "normal"); - extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); + extended.put("Version", version); try { extended.put("ActiveProfile", profileName); } catch (Exception e) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java index d8f5c47b4f..76f011da16 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java @@ -78,6 +78,7 @@ public class MedtronicHistoryData { private final AAPSLogger aapsLogger; private final SP sp; private final ActivePluginProvider activePlugin; + private final NSUpload nsUpload; private final MedtronicUtil medtronicUtil; private final MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder; @@ -106,6 +107,7 @@ public class MedtronicHistoryData { AAPSLogger aapsLogger, SP sp, ActivePluginProvider activePlugin, + NSUpload nsUpload, MedtronicUtil medtronicUtil, MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder ) { @@ -115,6 +117,7 @@ public class MedtronicHistoryData { this.aapsLogger = aapsLogger; this.sp = sp; this.activePlugin = activePlugin; + this.nsUpload = nsUpload; this.medtronicUtil = medtronicUtil; this.medtronicPumpHistoryDecoder = medtronicPumpHistoryDecoder; } @@ -543,7 +546,7 @@ public class MedtronicHistoryData { careportalEvent.eventType = event; careportalEvent.json = data.toString(); MainApp.getDbHelper().createOrUpdate(careportalEvent); - NSUpload.uploadCareportalEntryToNS(data); + nsUpload.uploadCareportalEntryToNS(data); } catch (JSONException e) { aapsLogger.error("Unhandled exception", e); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java index 37c6d420f7..70dac25789 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/wizard/pages/InitPodRefreshAction.java @@ -35,6 +35,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish @Inject OmnipodUtil omnipodUtil; @Inject AAPSLogger aapsLogger; @Inject SP sp; + @Inject NSUpload nsUpload; public InitPodRefreshAction(HasAndroidInjector injector, PodManagementActivity podManagementActivity, PodActionType actionType) { injector.androidInjector().inject(this); @@ -86,7 +87,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish careportalEvent.eventType = event; careportalEvent.json = data.toString(); MainApp.getDbHelper().createOrUpdate(careportalEvent); - NSUpload.uploadCareportalEntryToNS(data); + nsUpload.uploadCareportalEntryToNS(data); } catch (JSONException e) { aapsLogger.error(LTag.PUMPCOMM, "Unhandled exception when uploading SiteChange event.", e); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt index 3db377a230..e8916b5647 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt @@ -337,7 +337,7 @@ class VirtualPumpPlugin @Inject constructor( return result } - override fun getJSONStatus(profile: Profile, profileName: String): JSONObject { + override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject { val now = System.currentTimeMillis() if (!sp.getBoolean("virtualpump_uploadstatus", false)) { return JSONObject() @@ -349,7 +349,7 @@ class VirtualPumpPlugin @Inject constructor( try { battery.put("percent", batteryPercent) status.put("status", "normal") - extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION) + extended.put("Version", version) try { extended.put("ActiveProfile", profileName) } catch (ignored: Exception) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt index 7e854f7e96..41d1c07ddc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt @@ -31,7 +31,8 @@ class DexcomPlugin @Inject constructor( private val sp: SP, private val mainApp: MainApp, resourceHelper: ResourceHelper, - aapsLogger: AAPSLogger + aapsLogger: AAPSLogger, + private val nsUpload: NSUpload ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) @@ -78,10 +79,10 @@ class DexcomPlugin @Inject constructor( bgReading.raw = 0.0 if (MainApp.getDbHelper().createIfNotExists(bgReading, "Dexcom$sensorType")) { if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) { - NSUpload.uploadBg(bgReading, "AndroidAPS-Dexcom$sensorType") + nsUpload.uploadBg(bgReading, "AndroidAPS-Dexcom$sensorType") } if (sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) { - NSUpload.sendToXdrip(bgReading) + nsUpload.sendToXdrip(bgReading) } } } @@ -108,7 +109,7 @@ class DexcomPlugin @Inject constructor( careportalEvent.eventType = CareportalEvent.BGCHECK careportalEvent.json = jsonObject.toString() MainApp.getDbHelper().createOrUpdate(careportalEvent) - NSUpload.uploadCareportalEntryToNS(jsonObject) + nsUpload.uploadCareportalEntryToNS(jsonObject) } } } @@ -128,7 +129,7 @@ class DexcomPlugin @Inject constructor( careportalEvent.eventType = CareportalEvent.SENSORCHANGE careportalEvent.json = jsonObject.toString() MainApp.getDbHelper().createOrUpdate(careportalEvent) - NSUpload.uploadCareportalEntryToNS(jsonObject) + nsUpload.uploadCareportalEntryToNS(jsonObject) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt index 6b0021fbcf..9141d57214 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt @@ -29,7 +29,8 @@ class EversensePlugin @Inject constructor( private val sp: SP, resourceHelper: ResourceHelper, aapsLogger: AAPSLogger, - private val dateUtil: DateUtil + private val dateUtil: DateUtil, + private val nsUpload: NSUpload ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) @@ -77,10 +78,10 @@ class EversensePlugin @Inject constructor( bgReading.raw = 0.0 val isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Eversense") if (isNew && sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) { - NSUpload.uploadBg(bgReading, "AndroidAPS-Eversense") + nsUpload.uploadBg(bgReading, "AndroidAPS-Eversense") } if (isNew && sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) { - NSUpload.sendToXdrip(bgReading) + nsUpload.sendToXdrip(bgReading) } } } @@ -103,7 +104,7 @@ class EversensePlugin @Inject constructor( data.put("glucoseType", "Finger") data.put("glucose", calibrationGlucoseLevels[i]) data.put("units", Constants.MGDL) - NSUpload.uploadCareportalEntryToNS(data) + nsUpload.uploadCareportalEntryToNS(data) } } catch (e: JSONException) { aapsLogger.error("Unhandled exception", e) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt index c33cfaee0f..2032dd4479 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt @@ -26,7 +26,8 @@ class PoctechPlugin @Inject constructor( injector: HasAndroidInjector, resourceHelper: ResourceHelper, aapsLogger: AAPSLogger, - private val sp: SP + private val sp: SP, + private val nsUpload: NSUpload ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) @@ -58,10 +59,10 @@ class PoctechPlugin @Inject constructor( if (safeGetString(json, "units", Constants.MGDL) == "mmol/L") bgReading.value = bgReading.value * Constants.MMOLL_TO_MGDL val isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Poctech") if (isNew && sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) { - NSUpload.uploadBg(bgReading, "AndroidAPS-Poctech") + nsUpload.uploadBg(bgReading, "AndroidAPS-Poctech") } if (isNew && sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) { - NSUpload.sendToXdrip(bgReading) + nsUpload.sendToXdrip(bgReading) } } } catch (e: JSONException) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt index db4c658614..1ba7958b61 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt @@ -22,7 +22,8 @@ class TomatoPlugin @Inject constructor( injector: HasAndroidInjector, resourceHelper: ResourceHelper, aapsLogger: AAPSLogger, - private val sp: SP + private val sp: SP, + private val nsUpload: NSUpload ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) @@ -46,10 +47,10 @@ class TomatoPlugin @Inject constructor( bgReading.date = bundle.getLong("com.fanqies.tomatofn.Extras.Time") val isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Tomato") if (isNew && sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) { - NSUpload.uploadBg(bgReading, "AndroidAPS-Tomato") + nsUpload.uploadBg(bgReading, "AndroidAPS-Tomato") } if (isNew && sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) { - NSUpload.sendToXdrip(bgReading) + nsUpload.sendToXdrip(bgReading) } } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt index 63574ea8d2..e6d2f02883 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt @@ -42,6 +42,8 @@ class TreatmentsBolusFragment : DaggerFragment() { @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var treatmentsPlugin: TreatmentsPlugin @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var nsUpload: NSUpload + @Inject lateinit var uploadQueue: UploadQueue @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, @@ -68,9 +70,9 @@ class TreatmentsBolusFragment : DaggerFragment() { val futureTreatments = treatmentsPlugin.service.getTreatmentDataFromTime(DateUtil.now() + 1000, true) for (treatment in futureTreatments) { if (NSUpload.isIdValid(treatment._id)) - NSUpload.removeCareportalEntryFromNS(treatment._id) + nsUpload.removeCareportalEntryFromNS(treatment._id) else - UploadQueue.removeID("dbAdd", treatment._id) + uploadQueue.removeID("dbAdd", treatment._id) treatmentsPlugin.service.delete(treatment) } updateGui() @@ -166,9 +168,9 @@ class TreatmentsBolusFragment : DaggerFragment() { treatmentsPlugin.service.update(treatment) } else { if (NSUpload.isIdValid(treatment._id)) - NSUpload.removeCareportalEntryFromNS(treatment._id) + nsUpload.removeCareportalEntryFromNS(treatment._id) else - UploadQueue.removeID("dbAdd", treatment._id) + uploadQueue.removeID("dbAdd", treatment._id) treatmentsPlugin.service.delete(treatment) } updateGui() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt index 9307238211..191957a8f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt @@ -38,6 +38,8 @@ class TreatmentsCareportalFragment : DaggerFragment() { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var translator: Translator + @Inject lateinit var nsUpload: NSUpload + @Inject lateinit var uploadQueue: UploadQueue @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, @@ -66,9 +68,9 @@ class TreatmentsCareportalFragment : DaggerFragment() { val careportalEvent = events[i] if (careportalEvent.json.contains(resourceHelper.gs(R.string.androidaps_start))) { if (NSUpload.isIdValid(careportalEvent._id)) - NSUpload.removeCareportalEntryFromNS(careportalEvent._id) + nsUpload.removeCareportalEntryFromNS(careportalEvent._id) else - UploadQueue.removeID("dbAdd", careportalEvent._id) + uploadQueue.removeID("dbAdd", careportalEvent._id) MainApp.getDbHelper().delete(careportalEvent) } } @@ -136,9 +138,9 @@ class TreatmentsCareportalFragment : DaggerFragment() { resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(careportalEvent.date) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { if (NSUpload.isIdValid(careportalEvent._id)) - NSUpload.removeCareportalEntryFromNS(careportalEvent._id) + nsUpload.removeCareportalEntryFromNS(careportalEvent._id) else - UploadQueue.removeID("dbAdd", careportalEvent._id) + uploadQueue.removeID("dbAdd", careportalEvent._id) MainApp.getDbHelper().delete(careportalEvent) }, null) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt index d2dcd632ea..91e3b098fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt @@ -40,6 +40,8 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy + @Inject lateinit var nsUpload: NSUpload + @Inject lateinit var uploadQueue: UploadQueue @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, @@ -116,8 +118,8 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)} """.trimIndent(), DialogInterface.OnClickListener { _: DialogInterface, _: Int -> val id = extendedBolus._id - if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id) - else UploadQueue.removeID("dbAdd", id) + if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) + else uploadQueue.removeID("dbAdd", id) MainApp.getDbHelper().delete(extendedBolus) }, null) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt index 77934e304c..886c0ec34e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt @@ -43,6 +43,8 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { @Inject lateinit var localProfilePlugin: LocalProfilePlugin @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var fabricPrivacy: FabricPrivacy + @Inject lateinit var nsUpload: NSUpload + @Inject lateinit var uploadQueue: UploadQueue @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, @@ -135,8 +137,8 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { val id = profileSwitch._id - if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id) - else UploadQueue.removeID("dbAdd", id) + if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) + else uploadQueue.removeID("dbAdd", id) MainApp.getDbHelper().delete(profileSwitch) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java index 7df7db72be..980e9efe7d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.java @@ -47,6 +47,8 @@ public class TreatmentsTempTargetFragment extends DaggerFragment { @Inject RxBusWrapper rxBus; @Inject ProfileFunction profileFunction; @Inject ResourceHelper resourceHelper; + @Inject NSUpload nsUpload; + @Inject UploadQueue uploadQueue; @Inject FabricPrivacy fabricPrivacy; @Inject DateUtil dateUtil; @@ -146,9 +148,9 @@ public class TreatmentsTempTargetFragment extends DaggerFragment { (dialog, id) -> { final String _id = tempTarget._id; if (NSUpload.isIdValid(_id)) { - NSUpload.removeCareportalEntryFromNS(_id); + nsUpload.removeCareportalEntryFromNS(_id); } else { - UploadQueue.removeID("dbAdd", _id); + uploadQueue.removeID("dbAdd", _id); } MainApp.getDbHelper().delete(tempTarget); }, null); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt index 4ff6b15950..8b8aee6b91 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt @@ -44,6 +44,8 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var nsUpload: NSUpload + @Inject lateinit var uploadQueue: UploadQueue @Inject lateinit var dateUtil: DateUtil override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, @@ -165,8 +167,8 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { """.trimIndent(), DialogInterface.OnClickListener { _: DialogInterface?, _: Int -> val id = tempBasal._id - if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id) - else UploadQueue.removeID("dbAdd", id) + if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) + else uploadQueue.removeID("dbAdd", id) MainApp.getDbHelper().delete(tempBasal) }, null) } diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt index a3dda44325..b6705ac733 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt @@ -8,15 +8,16 @@ import android.content.Intent import android.os.PowerManager import android.os.SystemClock import dagger.android.DaggerBroadcastReceiver +import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.Config import info.nightscout.androidaps.events.EventProfileNeedsUpdate import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.queue.commands.Command @@ -39,6 +40,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var receiverStatusStore: ReceiverStatusStore @Inject lateinit var config: Config + @Inject lateinit var nsUpload: NSUpload @Inject lateinit var dateUtil: DateUtil companion object { @@ -108,7 +110,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { else if (DateUtil.isOlderThan(activePlugin.activeAPS.lastAPSRun, 5)) shouldUploadStatus = true if (DateUtil.isOlderThan(lastIobUpload, IOB_UPDATE_FREQUENCY) && shouldUploadStatus) { lastIobUpload = DateUtil.now() - NSUpload.uploadDeviceStatus(loopPlugin, iobCobCalculatorPlugin, profileFunction, activePlugin.activePump, receiverStatusStore) + nsUpload.uploadDeviceStatus(loopPlugin, iobCobCalculatorPlugin, profileFunction, activePlugin.activePump, receiverStatusStore, BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION) } } diff --git a/app/src/main/java/info/nightscout/androidaps/services/DataService.java b/app/src/main/java/info/nightscout/androidaps/services/DataService.java index 83891275a2..cf1833e892 100644 --- a/app/src/main/java/info/nightscout/androidaps/services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/services/DataService.java @@ -20,6 +20,7 @@ import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.BundleLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; +import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; @@ -42,6 +43,7 @@ public class DataService extends DaggerIntentService { @Inject AAPSLogger aapsLogger; @Inject SP sp; @Inject RxBusWrapper rxBus; + @Inject NSUpload nsUpload; @Inject SmsCommunicatorPlugin smsCommunicatorPlugin; @Inject DexcomPlugin dexcomPlugin; @Inject EversensePlugin eversensePlugin; @@ -210,7 +212,7 @@ public class DataService extends DaggerIntentService { } else if (eventType.equals(CareportalEvent.COMBOBOLUS)) { MainApp.getDbHelper().createExtendedBolusFromJsonIfNotExists(json); } else if (eventType.equals(CareportalEvent.PROFILESWITCH)) { - MainApp.getDbHelper().createProfileSwitchFromJsonIfNotExists(activePlugin, json); + MainApp.getDbHelper().createProfileSwitchFromJsonIfNotExists(activePlugin, nsUpload, json); } else if (eventType.equals(CareportalEvent.SITECHANGE) || eventType.equals(CareportalEvent.INSULINCHANGE) || eventType.equals(CareportalEvent.SENSORCHANGE) || diff --git a/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt b/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt index c9e2835ceb..bec9c0fa16 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt @@ -12,11 +12,12 @@ import javax.inject.Singleton @Singleton class HardLimits @Inject constructor( - val aapsLogger: AAPSLogger, - val rxBus: RxBusWrapper, - val sp: SP, - val resourceHelper: ResourceHelper, - val context: Context + private val aapsLogger: AAPSLogger, + private val rxBus: RxBusWrapper, + private val sp: SP, + private val resourceHelper: ResourceHelper, + private val context: Context, + private val nsUpload: NSUpload ) { val CHILD = 0 @@ -90,7 +91,7 @@ class HardLimits @Inject constructor( msg += ".\n" msg += String.format(resourceHelper.gs(R.string.valuelimitedto), value, newvalue) aapsLogger.error(msg) - NSUpload.uploadError(msg) + nsUpload.uploadError(msg) ToastUtils.showToastInUiThread(context, rxBus, msg, R.raw.error) } return newvalue diff --git a/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt b/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt index eff444aa6e..f5ac9d64ce 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/LocalAlertUtils.kt @@ -31,6 +31,7 @@ class LocalAlertUtils @Inject constructor( private val profileFunction: ProfileFunction, private val iobCobCalculatorPlugin: IobCobCalculatorPlugin, private val config: Config, + private val nsUpload: NSUpload, private val dateUtil: DateUtil ) { @@ -53,7 +54,7 @@ class LocalAlertUtils @Inject constructor( sp.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold()) rxBus.send(EventNewNotification(n)) if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) { - NSUpload.uploadError(n.text) + nsUpload.uploadError(n.text) } } if (!isStatusOutdated && !alarmTimeoutExpired) rxBus.send(EventDismissNotification(Notification.PUMP_UNREACHABLE)) @@ -101,7 +102,7 @@ class LocalAlertUtils @Inject constructor( sp.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold()) rxBus.send(EventNewNotification(n)) if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) { - NSUpload.uploadError(n.text) + nsUpload.uploadError(n.text) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt index 6ee3024fc6..1e567dd94a 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt @@ -11,6 +11,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.treatments.TreatmentService import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DateUtil @@ -32,8 +33,9 @@ class TddCalculator @Inject constructor( val activePlugin: ActivePluginProvider, val profileFunction: ProfileFunction, fabricPrivacy: FabricPrivacy, + nsUpload: NSUpload, private val dateUtil: DateUtil -) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, mainApp, sp, profileFunction, activePlugin, fabricPrivacy, dateUtil) { +) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, mainApp, sp, profileFunction, activePlugin, nsUpload, fabricPrivacy, dateUtil) { init { service = TreatmentService(injector) // plugin is not started diff --git a/app/src/main/res/layout/okcancel.xml b/app/src/main/res/layout/okcancel.xml new file mode 100644 index 0000000000..f1322fd566 --- /dev/null +++ b/app/src/main/res/layout/okcancel.xml @@ -0,0 +1,44 @@ + + + + +