Remove the alerter and related prefs.
This commit is contained in:
parent
e09d337c02
commit
ec383bb082
|
@ -81,7 +81,6 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
private ComboPlugin() {
|
||||
definePumpCapabilities();
|
||||
MainApp.bus().register(this);
|
||||
startAlerter();
|
||||
ruffyScripter = RuffyCommandsV1Impl.getInstance(MainApp.instance());
|
||||
}
|
||||
|
||||
|
@ -115,61 +114,6 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
return pump;
|
||||
}
|
||||
|
||||
/**
|
||||
* The alerter frequently checks the result of the last executed command via the lastCmdResult
|
||||
* field and shows a notification with sound and vibration if an error occurred.
|
||||
* More details on the error can then be looked up in the Combo tab.
|
||||
* <p>
|
||||
* The alarm is re-raised every 5 minutes for as long as the error persist. As soon
|
||||
* as a command succeeds no more new alerts are raised.
|
||||
*/
|
||||
private void startAlerter() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
NotificationManager mgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
int id = 1000;
|
||||
long lastAlarmTime = 0;
|
||||
while (true) {
|
||||
CommandResult localLastCmdResult = pump.lastCmdResult;
|
||||
if (!SP.getBoolean(R.string.combo_disable_alarms, false) &&
|
||||
localLastCmdResult != null && !localLastCmdResult.success) {
|
||||
long now = System.currentTimeMillis();
|
||||
long fiveMinutesSinceLastAlarm = lastAlarmTime + (5 * 60 * 1000) + (15 * 1000);
|
||||
boolean loopEnabled = ConfigBuilderPlugin.getActiveLoop() != null;
|
||||
if (now > fiveMinutesSinceLastAlarm && loopEnabled) {
|
||||
log.error("Command result: " + localLastCmdResult);
|
||||
PumpState localPumpState = pump.state;
|
||||
if (localPumpState.errorMsg != null) {
|
||||
log.warn("Pump is in error state, displaying; " + localPumpState.errorMsg);
|
||||
}
|
||||
long[] vibratePattern = new long[]{1000, 2000, 1000, 2000, 1000};
|
||||
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
|
||||
NotificationCompat.Builder notificationBuilder =
|
||||
new NotificationCompat.Builder(context)
|
||||
.setSmallIcon(R.drawable.notif_icon)
|
||||
.setSmallIcon(R.drawable.icon_bolus)
|
||||
.setContentTitle("Combo communication error")
|
||||
.setContentText(localLastCmdResult.message)
|
||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||
.setLights(Color.BLUE, 1000, 0)
|
||||
.setSound(uri)
|
||||
.setVibrate(vibratePattern);
|
||||
mgr.notify(id, notificationBuilder.build());
|
||||
lastAlarmTime = now;
|
||||
} else {
|
||||
// TODO would it be useful to have a 'last error' field in the ui showing the most recent
|
||||
// failed command? the next command that runs successful with will override this error
|
||||
log.warn("Pump still in error state, but alarm raised recently, so not triggering again: " + localLastCmdResult.message);
|
||||
}
|
||||
}
|
||||
SystemClock.sleep(5 * 1000);
|
||||
}
|
||||
}
|
||||
}, "combo-alerter").start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return ComboFragment.class.getName();
|
||||
|
|
|
@ -751,12 +751,6 @@
|
|||
<string name="connectiontimedout">Connection timed out</string>
|
||||
<string name="bolusstopping">Stopping bolus delivery</string>
|
||||
<string name="bolusstopped">Bolus delivery stopped</string>
|
||||
<string name="key_combo_ignore_transient_errors" translatable="false">combo_ignore_transient_tbr_errors</string>
|
||||
<string name="combo_ignore_transient_errors">Ignore transient errors</string>
|
||||
<string name="combo_ignore_transient_errors_summary">Ignore a connect failure for a background operation unless the next attempt also fails.</string>
|
||||
<string name="key_combo_disable_alarms" translatable="false">combo_disable_alerts</string>
|
||||
<string name="combo_disable_alarms">Disable alarms</string>
|
||||
<string name="combo_disable_alarms_summary">Ignore all errors encountered while communicating with the pump. Alarms raised by the pump (including those caused by AndroidAPS) will still be raised on the pump.</string>
|
||||
<string name="bolusprogramming">Programming pump for bolusing</string>
|
||||
<string name="combo_refresh">Refresh</string>
|
||||
<string name="combo_stats">Stats</string>
|
||||
|
|
|
@ -9,16 +9,6 @@
|
|||
android:title="@string/pairpump">
|
||||
<intent android:action="info.nightscout.androidaps.plugins.PumpCombo.activities.PairActivity"/>
|
||||
</Preference>
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_combo_ignore_transient_errors"
|
||||
android:summary="@string/combo_ignore_transient_errors_summary"
|
||||
android:title="@string/combo_ignore_transient_errors" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_combo_disable_alarms"
|
||||
android:title="@string/combo_disable_alarms"
|
||||
android:summary="@string/combo_disable_alarms_summary"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in a new issue