fix Dana password handling

This commit is contained in:
Milos Kozak 2018-08-25 14:08:04 +02:00
parent 7da4e4fd70
commit 324ba072bb
11 changed files with 32 additions and 38 deletions

View file

@ -1264,14 +1264,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
treatmentButton.setVisibility(View.GONE);
}
}
if (wizardButton != null) {
if (pump.isInitialized() && !pump.isSuspended() && wizardButton != null) {
if (SP.getBoolean(R.string.key_show_wizard_button, true)) {
wizardButton.setVisibility(View.VISIBLE);
} else {
wizardButton.setVisibility(View.GONE);
}
}
if (insulinButton != null) {
if (pump.isInitialized() && !pump.isSuspended() && insulinButton != null) {
if (SP.getBoolean(R.string.key_show_insulin_button, true)) {
insulinButton.setVisibility(View.VISIBLE);
} else {

View file

@ -145,7 +145,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
@Override
public boolean isInitialized() {
DanaRPump pump = DanaRPump.getInstance();
return pump.lastConnection > 0 && pump.isExtendedBolusEnabled && pump.maxBasal > 0;
return pump.lastConnection > 0 && pump.isExtendedBolusEnabled && pump.maxBasal > 0 && pump.isPasswordOK();
}
@Override

View file

@ -249,4 +249,10 @@ public class DanaRPump {
return record;
}
public boolean isPasswordOK() {
if (password != -1 && password != SP.getInt(R.string.key_danar_password, -1)) {
return false;
}
return true;
}
}

View file

@ -3,8 +3,13 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/**
@ -36,6 +41,13 @@ public class MsgInitConnStatusOption extends MessageBase {
log.debug("Pump password: " + DanaRPump.getInstance().password);
}
if (!DanaRPump.getInstance().isPasswordOK()) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.WRONG_PUMP_PASSWORD));
}
// This is last message of initial sequence
ConfigBuilderPlugin.getPlugin().getActivePump().finishHandshaking();
}

View file

@ -67,8 +67,6 @@ public abstract class AbstractDanaRExecutionService extends Service {
protected final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
protected long lastWrongPumpPassword = 0;
protected long lastApproachingDailyLimit = 0;
@ -239,6 +237,4 @@ public abstract class AbstractDanaRExecutionService extends Service {
result.comment = "OK";
return result;
}
}

View file

@ -98,15 +98,6 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
}
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
if (System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error;
lastWrongPumpPassword = System.currentTimeMillis();
}
return;
}
if (mConnectionInProgress)
return;

View file

@ -149,7 +149,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
@Override
public boolean isInitialized() {
DanaRPump pump = DanaRPump.getInstance();
return pump.lastConnection > 0 && pump.maxBasal > 0 && !pump.isConfigUD && !pump.isEasyModeEnabled && pump.isExtendedBolusEnabled;
return pump.lastConnection > 0 && pump.maxBasal > 0 && !pump.isConfigUD && !pump.isEasyModeEnabled && pump.isExtendedBolusEnabled && pump.isPasswordOK();
}
@Override

View file

@ -46,5 +46,12 @@ public class MsgInitConnStatusBasic_k extends MessageBase {
} else {
MainApp.bus().post(new EventDismissNotification(Notification.EASYMODE_ENABLED));
}
if (!DanaRPump.getInstance().isPasswordOK()) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.WRONG_PUMP_PASSWORD));
}
}
}

View file

@ -102,15 +102,6 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
}
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
if (System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error;
lastWrongPumpPassword = System.currentTimeMillis();
}
return;
}
if (mConnectionInProgress)
return;

View file

@ -112,7 +112,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@Override
public boolean isInitialized() {
return DanaRPump.getInstance().lastConnection > 0 && DanaRPump.getInstance().maxBasal > 0;
return DanaRPump.getInstance().lastConnection > 0 && DanaRPump.getInstance().maxBasal > 0 && DanaRPump.getInstance().isPasswordOK();
}
@Override

View file

@ -121,15 +121,6 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
}
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
if (System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error;
lastWrongPumpPassword = System.currentTimeMillis();
}
return;
}
if (mConnectionInProgress)
return;