Combo: use PrivacyFabric to align with dev.

This commit is contained in:
Johannes Mockenhaupt 2018-03-16 15:52:21 +01:00
parent 30d522e1a8
commit 6bebb30da0
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 28 additions and 26 deletions

View file

@ -52,6 +52,7 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHi
import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.CommandQueue; import info.nightscout.androidaps.queue.CommandQueue;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.FabricPrivacy;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
@ -585,7 +586,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
} }
if (waitLoops > 0) { if (waitLoops > 0) {
long waitDuration = (System.currentTimeMillis() - waitStartTime) / 1000; long waitDuration = (System.currentTimeMillis() - waitStartTime) / 1000;
Answers.getInstance().logCustom(new CustomEvent("ComboBolusTimestampWait") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusTimestampWait")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration))); .putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration)));
@ -690,7 +691,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
} }
Answers.getInstance().logCustom(new CustomEvent("ComboBolusToDbError") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("bolus", String.valueOf(lastPumpBolus.amount)) .putCustomAttribute("bolus", String.valueOf(lastPumpBolus.amount))
@ -702,7 +703,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (dbi.isSMB) { if (dbi.isSMB) {
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
Answers.getInstance().logCustom(new CustomEvent("ComboBolusToDbError") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("bolus", String.valueOf(lastPumpBolus.amount)) .putCustomAttribute("bolus", String.valueOf(lastPumpBolus.amount))
@ -1085,7 +1086,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
TemporaryBasal aapsTbr = MainApp.getConfigBuilder().getTempBasalFromHistory(now); TemporaryBasal aapsTbr = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) { if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
log.debug("Creating temp basal from pump TBR"); log.debug("Creating temp basal from pump TBR");
Answers.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("type", "new TBR on pump")); .putCustomAttribute("type", "new TBR on pump"));
@ -1098,7 +1099,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
MainApp.getConfigBuilder().addToHistoryTempBasal(newTempBasal); MainApp.getConfigBuilder().addToHistoryTempBasal(newTempBasal);
} else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) { } else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) {
log.debug("Ending AAPS-TBR since pump has no TBR active"); log.debug("Ending AAPS-TBR since pump has no TBR active");
Answers.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("type", "TBR cancelled on pump")); .putCustomAttribute("type", "TBR cancelled on pump"));
@ -1111,7 +1112,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
&& (aapsTbr.percentRate != state.tbrPercent || && (aapsTbr.percentRate != state.tbrPercent ||
Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) { Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) {
log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR"); log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR");
Answers.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("type", "TBR on pump differs from AAPS TBR")); .putCustomAttribute("type", "TBR on pump differs from AAPS TBR"));
@ -1286,7 +1287,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
HashSet<Bolus> bolusSet = new HashSet<>(historyResult.history.bolusHistory); HashSet<Bolus> bolusSet = new HashSet<>(historyResult.history.bolusHistory);
if (bolusSet.size() != historyResult.history.bolusHistory.size()) { if (bolusSet.size() != historyResult.history.bolusHistory.size()) {
log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB."); log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB.");
Answers.getInstance().logCustom(new CustomEvent("ComboBolusToDbError") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("bolus", "") .putCustomAttribute("bolus", "")

View file

@ -41,6 +41,7 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadP
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetBasalProfileCommand; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetBasalProfileCommand;
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetTbrCommand; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetTbrCommand;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.utils.FabricPrivacy;
/** /**
* Provides scripting 'runtime' and operations. consider moving operations into a separate * Provides scripting 'runtime' and operations. consider moving operations into a separate
@ -75,13 +76,13 @@ public class RuffyScripter implements RuffyCommands {
public void fail(String message) throws RemoteException { public void fail(String message) throws RemoteException {
log.warn("Ruffy warns: " + message); log.warn("Ruffy warns: " + message);
if (message.startsWith("no connection possible")) if (message.startsWith("no connection possible"))
Answers.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "no connection possible")); FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "no connection possible"));
else if (message.startsWith("Error sending keep alive while rtModeRunning is still true")) else if (message.startsWith("Error sending keep alive while rtModeRunning is still true"))
Answers.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "Error sending keep alive while rtModeRunning is still true")); FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "Error sending keep alive while rtModeRunning is still true"));
else if (message.startsWith("Error sending keep alive. rtModeRunning is false, so this is most likely a race condition during disconnect")) else if (message.startsWith("Error sending keep alive. rtModeRunning is false, so this is most likely a race condition during disconnect"))
Answers.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "Error sending keep alive. rtModeRunning is false, so this is most likely a race condition during disconnect")); FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "Error sending keep alive. rtModeRunning is false, so this is most likely a race condition during disconnect"));
else else
Answers.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", message.substring(0, 98))); FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", message.substring(0, 98)));
} }
@Override @Override
@ -171,7 +172,7 @@ public class RuffyScripter implements RuffyCommands {
if (!boundSucceeded) { if (!boundSucceeded) {
log.error("No connection to ruffy. Pump control unavailable."); log.error("No connection to ruffy. Pump control unavailable.");
} else { } else {
Answers.getInstance().logCustom(new CustomEvent("ComboScripterInit") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboScripterInit")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
} }
@ -224,7 +225,7 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult readQuickInfo(int numberOfBolusRecordsToRetrieve) { public CommandResult readQuickInfo(int numberOfBolusRecordsToRetrieve) {
Answers.getInstance().logCustom(new CustomEvent("ComboReadQuickInfoCmd") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadQuickInfoCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ReadQuickInfoCommand(numberOfBolusRecordsToRetrieve)); return runCommand(new ReadQuickInfoCommand(numberOfBolusRecordsToRetrieve));
@ -425,7 +426,7 @@ public class RuffyScripter implements RuffyCommands {
} }
} }
log.debug("Recovery from connection loss " + (connected ? "succeeded" : "failed")); log.debug("Recovery from connection loss " + (connected ? "succeeded" : "failed"));
Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromConnectionLoss") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromConnectionLoss")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : "")) .putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
@ -440,7 +441,7 @@ public class RuffyScripter implements RuffyCommands {
private PumpState recoverFromCommandFailure() { private PumpState recoverFromCommandFailure() {
Menu menu = this.currentMenu; Menu menu = this.currentMenu;
if (menu == null) { if (menu == null) {
Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : "")) .putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
@ -459,7 +460,7 @@ public class RuffyScripter implements RuffyCommands {
} }
try { try {
PumpState pumpState = readPumpStateInternal(); PumpState pumpState = readPumpStateInternal();
Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : "")) .putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
@ -467,7 +468,7 @@ public class RuffyScripter implements RuffyCommands {
.putCustomAttribute("success", "true")); .putCustomAttribute("success", "true"));
return pumpState; return pumpState;
} catch (Exception e) { } catch (Exception e) {
Answers.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("exit", "3") .putCustomAttribute("exit", "3")
@ -495,7 +496,7 @@ public class RuffyScripter implements RuffyCommands {
long initialUpdateTime = menuLastUpdated; long initialUpdateTime = menuLastUpdated;
while (initialUpdateTime == menuLastUpdated) { while (initialUpdateTime == menuLastUpdated) {
if (System.currentTimeMillis() > timeoutExpired) { if (System.currentTimeMillis() > timeoutExpired) {
Answers.getInstance().logCustom(new CustomEvent("ComboConnectTimeout") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboConnectTimeout")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : "")) .putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
@ -808,7 +809,7 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult deliverBolus(double amount, BolusProgressReporter bolusProgressReporter) { public CommandResult deliverBolus(double amount, BolusProgressReporter bolusProgressReporter) {
Answers.getInstance().logCustom(new CustomEvent("ComboBolusCmd") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new BolusCommand(amount, bolusProgressReporter)); return runCommand(new BolusCommand(amount, bolusProgressReporter));
@ -817,7 +818,7 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public void cancelBolus() { public void cancelBolus() {
if (activeCmd instanceof BolusCommand) { if (activeCmd instanceof BolusCommand) {
Answers.getInstance().logCustom(new CustomEvent("ComboBolusCmdCancel") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusCmdCancel")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
((BolusCommand) activeCmd).requestCancellation(); ((BolusCommand) activeCmd).requestCancellation();
@ -828,7 +829,7 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult setTbr(int percent, int duration) { public CommandResult setTbr(int percent, int duration) {
Answers.getInstance().logCustom(new CustomEvent("ComboSetTbrCmd") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboSetTbrCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new SetTbrCommand(percent, duration)); return runCommand(new SetTbrCommand(percent, duration));
@ -836,7 +837,7 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult cancelTbr() { public CommandResult cancelTbr() {
Answers.getInstance().logCustom(new CustomEvent("ComboCancelTbrCmd") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboCancelTbrCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new CancelTbrCommand()); return runCommand(new CancelTbrCommand());
@ -844,7 +845,7 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult confirmAlert(int warningCode) { public CommandResult confirmAlert(int warningCode) {
Answers.getInstance().logCustom(new CustomEvent("ComboConfirmAlertCmd") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboConfirmAlertCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ConfirmAlertCommand(warningCode)); return runCommand(new ConfirmAlertCommand(warningCode));
@ -852,7 +853,7 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult readHistory(PumpHistoryRequest request) { public CommandResult readHistory(PumpHistoryRequest request) {
Answers.getInstance().logCustom(new CustomEvent("ComboReadHistoryCmd") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadHistoryCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ReadHistoryCommand(request)); return runCommand(new ReadHistoryCommand(request));
@ -860,7 +861,7 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult readBasalProfile() { public CommandResult readBasalProfile() {
Answers.getInstance().logCustom(new CustomEvent("ComboReadBasalProfileCmd") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadBasalProfileCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ReadBasalProfileCommand()); return runCommand(new ReadBasalProfileCommand());
@ -868,7 +869,7 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult setBasalProfile(BasalProfile basalProfile) { public CommandResult setBasalProfile(BasalProfile basalProfile) {
Answers.getInstance().logCustom(new CustomEvent("ComboSetBasalProfileCmd") FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboSetBasalProfileCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new SetBasalProfileCommand(basalProfile)); return runCommand(new SetBasalProfileCommand(basalProfile));