restrict wrong password notification to once every 30 seconds

This commit is contained in:
AdrianLxM 2018-05-05 20:59:11 +02:00
parent c8c7e12056
commit 70b2b1502f
4 changed files with 17 additions and 6 deletions

View file

@ -64,6 +64,8 @@ public abstract class AbstractDanaRExecutionService extends Service {
protected IBinder mBinder;
protected final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
protected long lastWrongPumpPassword;
public abstract boolean updateBasalsInPump(final Profile profile);

View file

@ -97,8 +97,11 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error;
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;
}

View file

@ -105,8 +105,11 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error;
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;
}

View file

@ -120,8 +120,11 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public void connect() {
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
notification.soundId = R.raw.error;
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;
}