wakelock on bolusing
This commit is contained in:
parent
129c88478f
commit
d11f0b1ea1
1 changed files with 9 additions and 0 deletions
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.PowerManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
@ -70,8 +71,12 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
|
|
||||||
static Date lastDeviceStatusUpload = new Date(0);
|
static Date lastDeviceStatusUpload = new Date(0);
|
||||||
|
|
||||||
|
PowerManager.WakeLock mWakeLock;
|
||||||
|
|
||||||
public ConfigBuilderPlugin() {
|
public ConfigBuilderPlugin() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
||||||
|
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "DanaConnection");;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -334,6 +339,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpEnactResult deliverTreatmentFromBolusWizard(Context context, Double insulin, Integer carbs, Double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
|
public PumpEnactResult deliverTreatmentFromBolusWizard(Context context, Double insulin, Integer carbs, Double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
|
||||||
|
mWakeLock.acquire();
|
||||||
insulin = applyBolusConstraints(insulin);
|
insulin = applyBolusConstraints(insulin);
|
||||||
carbs = applyCarbsConstraints(carbs);
|
carbs = applyCarbsConstraints(carbs);
|
||||||
|
|
||||||
|
@ -366,11 +372,13 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc);
|
uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc);
|
||||||
MainApp.bus().post(new EventTreatmentChange());
|
MainApp.bus().post(new EventTreatmentChange());
|
||||||
}
|
}
|
||||||
|
mWakeLock.release();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context) {
|
public PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context) {
|
||||||
|
mWakeLock.acquire();
|
||||||
insulin = applyBolusConstraints(insulin);
|
insulin = applyBolusConstraints(insulin);
|
||||||
carbs = applyCarbsConstraints(carbs);
|
carbs = applyCarbsConstraints(carbs);
|
||||||
|
|
||||||
|
@ -403,6 +411,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
t.sendToNSClient();
|
t.sendToNSClient();
|
||||||
MainApp.bus().post(new EventTreatmentChange());
|
MainApp.bus().post(new EventTreatmentChange());
|
||||||
}
|
}
|
||||||
|
mWakeLock.release();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue