From 0eb08c2eaf85305dc35132a15f8983b1cf984b08 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 27 Aug 2018 19:07:46 +0200 Subject: [PATCH 1/2] Combo: remove fabric logging. --- .../plugins/PumpCombo/ComboPlugin.java | 37 +--------- .../ruffyscripter/RuffyScripter.java | 71 ------------------- 2 files changed, 1 insertion(+), 107 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index 2ea594c4df..af30d6ea58 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -7,8 +7,6 @@ import android.support.annotation.Nullable; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; -import com.crashlytics.android.answers.CustomEvent; - import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,7 +64,6 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil; import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.DateUtil; -import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.SP; /** @@ -556,10 +553,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint } if (waitLoops > 0) { long waitDuration = (System.currentTimeMillis() - waitStartTime) / 1000; - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusTimestampWait") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration))); if (L.isEnabled(L.PUMP)) log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing"); } @@ -681,11 +674,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint 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)); } - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("bolus", String.valueOf(lastPumpBolus.amount)) - .putCustomAttribute("issue", "record with same timestamp existed and was overridden")); return false; } } catch (Exception e) { @@ -693,11 +681,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint if (dbi.isSMB) { 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)); - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("bolus", String.valueOf(lastPumpBolus.amount)) - .putCustomAttribute("issue", "adding record caused exception")); } return false; } @@ -1111,10 +1094,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) { if (L.isEnabled(L.PUMP)) log.debug("Creating temp basal from pump TBR"); - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("type", "new TBR on pump")); TemporaryBasal newTempBasal = new TemporaryBasal() .date(now) .percent(state.tbrPercent) @@ -1124,10 +1103,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint } else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) { if (L.isEnabled(L.PUMP)) log.debug("Ending AAPS-TBR since pump has no TBR active"); - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("type", "TBR cancelled on pump")); TemporaryBasal tempStop = new TemporaryBasal() .date(now) .duration(0) @@ -1138,10 +1113,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) { if (L.isEnabled(L.PUMP)) log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR"); - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("type", "TBR on pump differs from AAPS TBR")); TemporaryBasal tempStop = new TemporaryBasal() .date(now - 1000) .duration(0) @@ -1262,19 +1233,13 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint if (bolusSet.size() != historyResult.history.bolusHistory.size()) { if (L.isEnabled(L.PUMP)) log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB."); - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("bolus", "") - .putCustomAttribute("issue", "multiple pump history records with the same time and amount")); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string. combo_error_multiple_boluses_with_identical_timestamp), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history); - if (pumpHistoryChanged) { - if (L.isEnabled(L.PUMP)) + if (L.isEnabled(L.PUMP) && pumpHistoryChanged) { log.debug("Setting 'pumpHistoryChanged' true"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java index 5b569e479e..b6c63045e0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java @@ -10,7 +10,6 @@ import android.os.SystemClock; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.crashlytics.android.answers.CustomEvent; import com.google.common.base.Joiner; import org.monkey.d.ruffy.ruffy.driver.IRTHandler; @@ -39,8 +38,6 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadH import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadPumpStateCommand; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetBasalProfileCommand; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetTbrCommand; -import info.nightscout.androidaps.BuildConfig; -import info.nightscout.utils.FabricPrivacy; /** * Provides scripting 'runtime' and operations. consider moving operations into a separate @@ -76,14 +73,6 @@ public class RuffyScripter implements RuffyCommands { @Override public void fail(String message) throws RemoteException { log.warn("Ruffy warns: " + message); - if (message.startsWith("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")) - 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")) - 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 - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", message.substring(0, 98))); } @Override @@ -173,10 +162,6 @@ public class RuffyScripter implements RuffyCommands { if (!boundSucceeded) { log.error("No connection to ruffy. Pump control unavailable."); - } else { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboScripterInit") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION)); } } @@ -227,9 +212,6 @@ public class RuffyScripter implements RuffyCommands { @Override public CommandResult readQuickInfo(int numberOfBolusRecordsToRetrieve) { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadQuickInfoCmd") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION)); return runCommand(new ReadQuickInfoCommand(numberOfBolusRecordsToRetrieve)); } @@ -435,11 +417,6 @@ public class RuffyScripter implements RuffyCommands { } } log.debug("Recovery from connection loss " + (connected ? "succeeded" : "failed")); - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromConnectionLoss") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : "")) - .putCustomAttribute("success", connected ? "true" : "else")); return connected; } @@ -450,12 +427,6 @@ public class RuffyScripter implements RuffyCommands { private PumpState recoverFromCommandFailure() { Menu menu = this.currentMenu; if (menu == null) { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : "")) - .putCustomAttribute("exit", "1") - .putCustomAttribute("success", "false")); return new PumpState(); } MenuType type = menu.getType(); @@ -469,21 +440,8 @@ public class RuffyScripter implements RuffyCommands { } try { PumpState pumpState = readPumpStateInternal(); - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : "")) - .putCustomAttribute("exit", "2") - .putCustomAttribute("success", "true")); return pumpState; } catch (Exception e) { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("exit", "3") - .putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : "")) - .putCustomAttribute("success", "false")); - log.debug("Reading pump state during recovery failed", e); return new PumpState(); } @@ -505,11 +463,6 @@ public class RuffyScripter implements RuffyCommands { long initialUpdateTime = menuLastUpdated; while (initialUpdateTime == menuLastUpdated) { if (System.currentTimeMillis() > timeoutExpired) { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboConnectTimeout") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION) - .putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : "")) - .putCustomAttribute("previousCommand", previousCommand)); throw new CommandException("Timeout connecting to pump"); } SystemClock.sleep(50); @@ -818,18 +771,12 @@ public class RuffyScripter implements RuffyCommands { @Override public CommandResult deliverBolus(double amount, BolusProgressReporter bolusProgressReporter) { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusCmd") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION)); return runCommand(new BolusCommand(amount, bolusProgressReporter)); } @Override public void cancelBolus() { if (activeCmd instanceof BolusCommand) { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusCmdCancel") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION)); ((BolusCommand) activeCmd).requestCancellation(); } else { log.error("cancelBolus called, but active command is not a bolus:" + activeCmd); @@ -838,49 +785,31 @@ public class RuffyScripter implements RuffyCommands { @Override public CommandResult setTbr(int percent, int duration) { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboSetTbrCmd") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION)); return runCommand(new SetTbrCommand(percent, duration)); } @Override public CommandResult cancelTbr() { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboCancelTbrCmd") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION)); return runCommand(new CancelTbrCommand()); } @Override public CommandResult confirmAlert(int warningCode) { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboConfirmAlertCmd") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION)); return runCommand(new ConfirmAlertCommand(warningCode)); } @Override public CommandResult readHistory(PumpHistoryRequest request) { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadHistoryCmd") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION)); return runCommand(new ReadHistoryCommand(request)); } @Override public CommandResult readBasalProfile() { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadBasalProfileCmd") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION)); return runCommand(new ReadBasalProfileCommand()); } @Override public CommandResult setBasalProfile(BasalProfile basalProfile) { - FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboSetBasalProfileCmd") - .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) - .putCustomAttribute("version", BuildConfig.VERSION)); return runCommand(new SetBasalProfileCommand(basalProfile)); } From 3fd3d0f0595c063b38169bcef194fc86bfa7578f Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 27 Aug 2018 19:03:46 +0200 Subject: [PATCH 2/2] Combo: remove dead code. --- .../plugins/PumpCombo/ComboPlugin.java | 3 +-- .../ruffyscripter/RuffyScripter.java | 21 ++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index af30d6ea58..d8a90c2e9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -326,7 +326,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint return basalProfile; } - @NonNull @Override public long lastDataTime() { return pump.lastSuccessfulCmdTime; @@ -1240,7 +1239,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history); if (L.isEnabled(L.PUMP) && pumpHistoryChanged) { - log.debug("Setting 'pumpHistoryChanged' true"); + log.debug("Setting 'pumpHistoryChanged' true"); } List updatedPumpBolusHistory = historyResult.history.bolusHistory; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java index b6c63045e0..e69cf3b462 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ruffyscripter/RuffyScripter.java @@ -54,8 +54,6 @@ public class RuffyScripter implements RuffyCommands { private volatile long menuLastUpdated = 0; private volatile boolean unparsableMenuEncountered; - - private String previousCommand = ""; private volatile Command activeCmd = null; private boolean started = false; @@ -64,43 +62,43 @@ public class RuffyScripter implements RuffyCommands { private IRTHandler mHandler = new IRTHandler.Stub() { @Override - public void log(String message) throws RemoteException { + public void log(String message) { if (log.isTraceEnabled()) { log.trace("Ruffy says: " + message); } } @Override - public void fail(String message) throws RemoteException { + public void fail(String message) { log.warn("Ruffy warns: " + message); } @Override - public void requestBluetooth() throws RemoteException { + public void requestBluetooth() { log.trace("Ruffy invoked requestBluetooth callback"); } @Override - public void rtStopped() throws RemoteException { + public void rtStopped() { log.debug("rtStopped callback invoked"); currentMenu = null; } @Override - public void rtStarted() throws RemoteException { + public void rtStarted() { log.debug("rtStarted callback invoked"); } @Override - public void rtClearDisplay() throws RemoteException { + public void rtClearDisplay() { } @Override - public void rtUpdateDisplay(byte[] quarter, int which) throws RemoteException { + public void rtUpdateDisplay(byte[] quarter, int which) { } @Override - public void rtDisplayHandleMenu(Menu menu) throws RemoteException { + public void rtDisplayHandleMenu(Menu menu) { // method is called every ~500ms log.debug("rtDisplayHandleMenu: " + menu); @@ -113,7 +111,7 @@ public class RuffyScripter implements RuffyCommands { } @Override - public void rtDisplayHandleNoMenu() throws RemoteException { + public void rtDisplayHandleNoMenu() { log.warn("rtDisplayHandleNoMenu callback invoked"); unparsableMenuEncountered = true; } @@ -348,7 +346,6 @@ public class RuffyScripter implements RuffyCommands { // ignore } } - previousCommand = "" + activeCmd; activeCmd = null; } }