Skip to content

Commit

Permalink
Merge of aaps v2.2.2
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'remotes/official/master' into omnipod_dev

# Conflicts:
#	app/src/main/res/values/strings.xml
  • Loading branch information
winemug committed Apr 7, 2019
2 parents 87990a0 + c2cf6d1 commit 340903a
Show file tree
Hide file tree
Showing 32 changed files with 1,678 additions and 70 deletions.
23 changes: 11 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {

dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.3'
}
}
apply plugin: "com.android.application"
Expand All @@ -15,7 +15,7 @@ apply plugin: "jacoco-android"
apply plugin: 'com.jakewharton.butterknife'

ext {
supportLibraryVersion = "27.1.0"
supportLibraryVersion = "27.1.1"
ormLiteVersion = "4.46"
powermockVersion = "1.7.3"
dexmakerVersion = "1.2"
Expand Down Expand Up @@ -63,7 +63,7 @@ android {
targetSdkVersion 25
multiDexEnabled true
versionCode 1500
version "2.2"
version "2.2.2"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
Expand Down Expand Up @@ -91,7 +91,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled(project.hasProperty('coverage') ? true : false)
testCoverageEnabled(project.hasProperty('coverage'))
}
}
productFlavors {
Expand Down Expand Up @@ -185,15 +185,14 @@ dependencies {
implementation "com.android.support:design:${supportLibraryVersion}"
implementation "com.android.support:percent:${supportLibraryVersion}"
implementation "com.wdullaer:materialdatetimepicker:2.3.0"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation "com.squareup:otto:1.3.7"
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
implementation "com.j256.ormlite:ormlite-android:${ormLiteVersion}"
implementation("com.github.tony19:logback-android-classic:1.1.1-6") {
exclude group: "com.google.android", module: "android"
}
implementation "org.apache.commons:commons-lang3:3.6"
implementation "org.slf4j:slf4j-api:1.7.12"
implementation "org.apache.commons:commons-lang3:3.7"
implementation "org.slf4j:slf4j-api:1.7.21"
implementation "com.jjoe64:graphview:4.0.1"
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.1.1"
implementation 'com.google.android.gms:play-services-wearable:10.2.1'
Expand All @@ -208,8 +207,8 @@ dependencies {
// excluding org.json which is provided by Android
exclude group: "org.json", module: "json"
}
implementation "com.google.code.gson:gson:2.7"
implementation "com.google.guava:guava:20.0"
implementation "com.google.code.gson:gson:2.8.2"
implementation "com.google.guava:guava:24.1-jre"

implementation "net.danlew:android.joda:2.9.9.1"
implementation "uk.com.robust-it:cloning:1.9.9"
Expand All @@ -221,17 +220,17 @@ dependencies {

testImplementation "junit:junit:4.12"
testImplementation "org.json:json:20140107"
testImplementation "org.mockito:mockito-core:2.7.22"
testImplementation "org.mockito:mockito-core:2.8.47"
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
testImplementation "joda-time:joda-time:2.9.4.2"
testImplementation "joda-time:joda-time:2.9.9"
testImplementation "com.google.truth:truth:0.39"
testImplementation 'org.robolectric:robolectric:3.8'
testImplementation "org.skyscreamer:jsonassert:1.5.0"

androidTestImplementation "org.mockito:mockito-core:2.7.22"
androidTestImplementation "org.mockito:mockito-core:2.8.47"
androidTestImplementation "com.google.dexmaker:dexmaker:${dexmakerVersion}"
androidTestImplementation "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) {
return null;
}

sizeRecords = Math.min(sizeRecords, 9);

if (data.get(0).date < DateUtil.now() - 7 * 60 * 1000L && !allowOldData) {
return null;
}
Expand All @@ -93,10 +91,14 @@ public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) {
return status.round();
}

ArrayList<Double> now_value_list = new ArrayList<Double>();
ArrayList<Double> last_deltas = new ArrayList<Double>();
ArrayList<Double> short_deltas = new ArrayList<Double>();
ArrayList<Double> long_deltas = new ArrayList<Double>();

// Use the latest sgv value in the now calculations
now_value_list.add(now.value);

for (int i = 1; i < sizeRecords; i++) {
if (data.get(i).value > 38) {
BgReading then = data.get(i);
Expand All @@ -111,8 +113,9 @@ public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) {

// use the average of all data points in the last 2.5m for all further "now" calculations
if (0 < minutesago && minutesago < 2.5) {
now.value = (now.value + then.value) / 2;
now_date = (now_date + then_date) / 2;
// Keep and average all values within the last 2.5 minutes
now_value_list.add(then.value);
now.value = average(now_value_list);
// short_deltas are calculated from everything ~5-15 minutes ago
} else if (2.5 < minutesago && minutesago < 17.5) {
//console.error(minutesago, avgdelta);
Expand All @@ -124,6 +127,9 @@ public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) {
// long_deltas are calculated from everything ~20-40 minutes ago
} else if (17.5 < minutesago && minutesago < 42.5) {
long_deltas.add(avgdelta);
} else {
// Do not process any more records after >= 42.5 minutes
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ public void createTemptargetFromJsonIfNotExists(JSONObject trJson) {
String units = JsonHelper.safeGetString(trJson, "units", Constants.MGDL);
TempTarget tempTarget = new TempTarget()
.date(trJson.getLong("mills"))
.duration(trJson.getInt("duration"))
.duration(JsonHelper.safeGetInt(trJson, "duration"))
.low(Profile.toMgdl(trJson.getDouble("targetBottom"), units))
.high(Profile.toMgdl(trJson.getDouble("targetTop"), units))
.reason(JsonHelper.safeGetString(trJson, "reason", ""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,13 @@ public void setData(Profile profile,
mProfile.put("max_daily_safety_multiplier", SP.getInt(R.string.key_openapsama_max_daily_safety_multiplier, 3));
mProfile.put("current_basal_safety_multiplier", SP.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4d));

mProfile.put("high_temptarget_raises_sensitivity", SP.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity));
mProfile.put("low_temptarget_lowers_sensitivity", SP.getBoolean(R.string.key_low_temptarget_lowers_sensitivity, SMBDefaults.low_temptarget_lowers_sensitivity));
// TODO AS-FIX
// mProfile.put("high_temptarget_raises_sensitivity", SP.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity));
mProfile.put("high_temptarget_raises_sensitivity", false);
//mProfile.put("low_temptarget_lowers_sensitivity", SP.getBoolean(R.string.key_low_temptarget_lowers_sensitivity, SMBDefaults.low_temptarget_lowers_sensitivity));
mProfile.put("low_temptarget_lowers_sensitivity", false);


mProfile.put("sensitivity_raises_target", SMBDefaults.sensitivity_raises_target);
mProfile.put("resistance_lowers_target", SMBDefaults.resistance_lowers_target);
mProfile.put("adv_target_adjustments", SMBDefaults.adv_target_adjustments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ private void processCAL(String[] splitted, Sms receivedSms) {
String passCode = generatePasscode();
String reply = String.format(MainApp.gs(R.string.smscommunicator_calibrationreplywithcode), cal, passCode);
receivedSms.processed = true;
messageToConfirm = new AuthRequest(this, receivedSms, reply, passCode, new SmsAction() {
messageToConfirm = new AuthRequest(this, receivedSms, reply, passCode, new SmsAction(cal) {
@Override
public void run() {
boolean result = XdripCalibrations.sendIntent(aDouble);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ public final void run() {
//log.debug("TIME: " + new Date(bgTime).toString() + " BG: " + bg + " SENS: " + sens + " DELTA: " + delta + " AVGDELTA: " + avgDelta + " IOB: " + iob.iob + " ACTIVITY: " + iob.activity + " BGI: " + bgi + " DEVIATION: " + deviation);

// add an extra negative deviation if a high temptarget is running and exercise mode is set
if (SP.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity)) {
// TODO AS-FIX
if (false && SP.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity)) {
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(bgTime);
if (tempTarget != null && tempTarget.target() >= 100) {
autosensData.extraDeviation.add(-(tempTarget.target() - 100) / 20);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public enum DoseStepSize
new DoseStepSizeEntry(5f, 10f, 0.2f), //
new DoseStepSizeEntry(10f, Double.MAX_VALUE, 0.5f)),

InsightBasal(
new DoseStepSizeEntry(0f, 5f, 0.01f),
new DoseStepSizeEntry(5f, Double.MAX_VALUE, 0.1f)),

MedtronicVeoBasal( //
new DoseStepSizeEntry(0f, 1f, 0.025f), //
new DoseStepSizeEntry(1f, 10f, 0.05f), //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ public enum PumpType {
AccuChekInsight("Accu-Chek Insight", 0.05d, DoseStepSize.InsightBolus, //
new DoseSettings(0.05d, 15, 24*60, 0.05d), //
PumpTempBasalType.Percent,
new DoseSettings(10, 15, 12*60,0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
new DoseSettings(10, 15, 24*60,0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.02d, 0.01d, null, PumpCapability.InsightCapabilities), //

AccuChekInsightBluetooth("Accu-Chek Insight", 0.01d, null, //
new DoseSettings(0.01d, 15, 24*60, 0.05d), //
PumpTempBasalType.Percent,
new DoseSettings(10, 15, 24*60,0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.02d, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities), //

// Animas
AnimasVibe("Animas Vibe", 0.05d, null, // AnimasBolus?
new DoseSettings(0.05d, 30, 12*60, 0.05d), //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public LocalInsightPlugin() {
.preferencesId(R.xml.pref_insight_local));

pumpDescription = new PumpDescription();
pumpDescription.setPumpDescription(PumpType.AccuChekInsight);
pumpDescription.setPumpDescription(PumpType.AccuChekInsightBluetooth);
}

public TBROverNotificationBlock getTBROverNotificationBlock() {
Expand Down Expand Up @@ -318,7 +318,7 @@ private void updatePumpTimeIfNeeded() throws Exception {
calendar.set(Calendar.HOUR_OF_DAY, pumpTime.getHour());
calendar.set(Calendar.MINUTE, pumpTime.getMinute());
calendar.set(Calendar.SECOND, pumpTime.getSecond());
if (Math.abs(calendar.getTimeInMillis() - System.currentTimeMillis()) > 10000) {
if (calendar.get(Calendar.HOUR_OF_DAY) != pumpTime.getHour() || Math.abs(calendar.getTimeInMillis() - System.currentTimeMillis()) > 10000) {
calendar.setTime(new Date());
pumpTime.setYear(calendar.get(Calendar.YEAR));
pumpTime.setMonth(calendar.get(Calendar.MONTH) + 1);
Expand Down Expand Up @@ -424,7 +424,7 @@ public PumpEnactResult setNewBasalProfile(Profile profile) {
if (profile.getBasalValues().length > i + 1)
nextValue = profile.getBasalValues()[i + 1];
BasalProfileBlock profileBlock = new BasalProfileBlock();
profileBlock.setBasalAmount(basalValue.value);
profileBlock.setBasalAmount(basalValue.value > 5 ? Math.round(basalValue.value / 0.1) * 0.1 : Math.round(basalValue.value / 0.01) * 0.01);
profileBlock.setDuration((((nextValue != null ? nextValue.timeAsSeconds : 24 * 60 * 60) - basalValue.timeAsSeconds) / 60));
profileBlocks.add(profileBlock);
}
Expand Down Expand Up @@ -479,7 +479,7 @@ public boolean isThisProfileSet(Profile profile) {
nextValue = profile.getBasalValues()[i + 1];
if (profileBlock.getDuration() * 60 != (nextValue != null ? nextValue.timeAsSeconds : 24 * 60 * 60) - basalValue.timeAsSeconds)
return false;
if (Math.abs(profileBlock.getBasalAmount() - basalValue.value) > 0.01D)
if (Math.abs(profileBlock.getBasalAmount() - basalValue.value) > (basalValue.value > 5 ? 0.05 : 0.005))
return false;
}
return true;
Expand Down Expand Up @@ -513,14 +513,15 @@ public int getBatteryLevel() {
@Override
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
PumpEnactResult result = new PumpEnactResult();
if (detailedBolusInfo.insulin > 0) {
double insulin = Math.round(detailedBolusInfo.insulin / 0.01) * 0.01;
if (insulin > 0) {
try {
synchronized ($bolusLock) {
DeliverBolusMessage bolusMessage = new DeliverBolusMessage();
bolusMessage.setBolusType(BolusType.STANDARD);
bolusMessage.setDuration(0);
bolusMessage.setExtendedAmount(0);
bolusMessage.setImmediateAmount(detailedBolusInfo.insulin);
bolusMessage.setImmediateAmount(insulin);
bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId();
bolusCancelled = false;
}
Expand All @@ -530,7 +531,7 @@ public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
t.isSMB = detailedBolusInfo.isSMB;
final EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.t = t;
bolusingEvent.status = MainApp.gs(R.string.insight_delivered, 0d, detailedBolusInfo.insulin);
bolusingEvent.status = MainApp.gs(R.string.insight_delivered, 0d, insulin);
bolusingEvent.percent = 0;
MainApp.bus().post(bolusingEvent);
int trials = 0;
Expand Down Expand Up @@ -568,7 +569,7 @@ public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
synchronized ($bolusLock) {
if (bolusCancelled || trials == -1 || trials++ >= 5) {
if (!bolusCancelled) {
bolusingEvent.status = MainApp.gs(R.string.insight_delivered, detailedBolusInfo.insulin, detailedBolusInfo.insulin);
bolusingEvent.status = MainApp.gs(R.string.insight_delivered, insulin, insulin);
bolusingEvent.percent = 100;
MainApp.bus().post(bolusingEvent);
}
Expand All @@ -595,6 +596,7 @@ public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
result.enacted = true;
}
result.carbsDelivered = detailedBolusInfo.carbs;
result.bolusDelivered = insulin;
return result;
}

Expand Down Expand Up @@ -1190,6 +1192,7 @@ private void processDateTimeChangedEvent(DateTimeChangedEvent event) {
}

private void processCannulaFilledEvent(CannulaFilledEvent event) {
if (!SP.getBoolean("insight_log_site_changes", false)) return;
long timestamp = parseDate(event.getEventYear(), event.getEventMonth(), event.getEventDay(),
event.getEventHour(), event.getEventMinute(), event.getEventSecond()) + timeOffset;
uploadCareportalEvent(timestamp, CareportalEvent.SITECHANGE);
Expand Down Expand Up @@ -1217,7 +1220,7 @@ private void processTubeFilledEvent(TubeFilledEvent event) {
}

private void processSniffingDoneEvent(SniffingDoneEvent event) {
if (!SP.getBoolean("insight_log_site_changes", false)) return;
if (!SP.getBoolean("insight_log_reservoir_changes", false)) return;
long timestamp = parseDate(event.getEventYear(), event.getEventMonth(), event.getEventDay(),
event.getEventHour(), event.getEventMinute(), event.getEventSecond()) + timeOffset;
uploadCareportalEvent(timestamp, CareportalEvent.INSULINCHANGE);
Expand Down Expand Up @@ -1540,6 +1543,11 @@ public Constraint<Double> applyBolusConstraints(Constraint<Double> insulin) {
return insulin;
}

@Override
public Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
return applyBolusConstraints(insulin);
}

@Override
public void onStateChanged(InsightState state) {
if (state == InsightState.CONNECTED) {
Expand Down
Loading

0 comments on commit 340903a

Please sign in to comment.