Merge branch 'dev' into automation

This commit is contained in:
Milos Kozak 2019-03-30 15:47:23 +01:00
commit cabdb1d2fb
20 changed files with 160 additions and 126 deletions

View file

@ -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"
@ -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"
@ -63,7 +63,7 @@ android {
targetSdkVersion 25
multiDexEnabled true
versionCode 1500
version "2.1.3-dev"
version "2.2.1-dev"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
@ -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 {
@ -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'
@ -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"
@ -223,17 +222,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}"
}

View file

@ -65,6 +65,7 @@ public interface PumpInterface {
PumpEnactResult loadTDDs();
public boolean canHandleDST();
List<CustomAction> getCustomActions();

View file

@ -12,18 +12,17 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
import info.nightscout.androidaps.utils.T;
/**
* Created by Rumen on 31.10.2018.
*/
public class DstHelperPlugin extends PluginBase implements ConstraintsInterface {
public static final int DISABLE_TIMEFRAME_HOURS = -3;
public static final int WARN_PRIOR_TIMEFRAME_HOURS = 24;
private static Logger log = LoggerFactory.getLogger(L.CONSTRAINTS);
private int minutesToChange = 0;
static DstHelperPlugin plugin = null;
@ -43,83 +42,53 @@ public class DstHelperPlugin extends PluginBase implements ConstraintsInterface
);
}
public int dstTest(Calendar c) throws Exception {
// c = Calendar.getInstance(TimeZone.getDefault());
// c = Calendar.getInstance(TimeZone.getTimeZone("Australia/Lord_Howe"));
// c.setTimeInMillis(DateUtil.fromISODateString("2018-10-07T01:00:00Z").getTime());
long zoneOffset = c.get(Calendar.ZONE_OFFSET);
long d1 = c.getTimeInMillis() - zoneOffset;
c.setTimeInMillis(d1);
int offset1 = c.get(Calendar.DST_OFFSET);
c.add(Calendar.DATE, 1);
long d2 = c.getTimeInMillis();
int diffInHours = (int) ((d1 - d2) / -T.hours(1).msecs());
long offsetDetectedTime = 0;
// comparing millis because change can be < 1 hour
// log.debug("Starting from: "+startTimeString + " to "+endTimeString);
// log.debug("start "+offset1+" end "+c.get(Calendar.DST_OFFSET));
if (offset1 != c.get(Calendar.DST_OFFSET)) {
//we have a time change in next 24 hours, but when exactly
// log.debug("Daylight saving time detected between " + startTimeString + " and " + endTimeString);
// log.debug("Diff in hours is: "+diffInHours);
c.setTimeInMillis(d1 - zoneOffset);
offset1 = c.get(Calendar.DST_OFFSET);
for (int i = 0; i <= diffInHours * 4; i++) {
if (offset1 != c.get(Calendar.DST_OFFSET)) {
log.debug("Detected offset in " + ((i / 4) - zoneOffset / T.hours(1).msecs()) + " hours value is " + (offset1 - c.get(Calendar.DST_OFFSET)) / T.mins(1).msecs() + " minutes");
offsetDetectedTime = c.getTimeInMillis() - d1;
break;
}
c.add(Calendar.MINUTE, 15);
}
}
int minutesLeft = (int) ((offsetDetectedTime / T.mins(1).msecs()));
/*log.debug("zoneoffset(minutes):"+zoneOffset/T.mins(1).msecs());
log.debug("Start offset: "+offset1/T.mins(1).msecs());
log.debug("End offset :" + c.get(Calendar.DST_OFFSET)/T.mins(1).msecs());
log.debug("Now is:"+startTimeString);
log.debug("Detected in(min): "+(offsetDetectedTime/T.mins(1).msecs()));
log.debug("Returning value of: " + minutesLeft); */
minutesToChange = minutesLeft;
return minutesLeft;
public static boolean wasDST(Calendar now) {
Calendar ago = (Calendar) now.clone();
ago.add(Calendar.HOUR, DISABLE_TIMEFRAME_HOURS);
return now.get(Calendar.DST_OFFSET) != ago.get(Calendar.DST_OFFSET);
}
//Return false if time to DST change is less than 91 and positive
public static boolean willBeDST(Calendar now) {
Calendar ago = (Calendar) now.clone();
ago.add(Calendar.HOUR, WARN_PRIOR_TIMEFRAME_HOURS);
return now.get(Calendar.DST_OFFSET) != ago.get(Calendar.DST_OFFSET);
}
//Return false if time to DST change happened in the last 3 hours.
@Override
public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) {
try {
this.dstTest(Calendar.getInstance());
} catch (Exception e) {
e.printStackTrace();
}
if (this.minutesToChange <= 90 && minutesToChange > 0 && value.value()) {
try {
LoopPlugin loopPlugin = LoopPlugin.getPlugin();
if (loopPlugin.suspendedTo() == 0L) {
// loopPlugin.suspendTo(System.currentTimeMillis() + minutesToChange * T.mins(1).msecs());
warnUser(Notification.DST_LOOP_DISABLED, MainApp.gs(R.string.dst_loop_disabled_warning));
} else
log.debug("Loop already suspended");
} catch (Exception e) {
e.printStackTrace();
}
value.set(false, "DST in 90 minutes or less", this);
} else if (minutesToChange <= 24 * T.hours(1).mins() && minutesToChange > 0) {
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
if (pump == null || pump.canHandleDST()) {
log.debug("Pump can handle DST");
return value;
}
Calendar cal = Calendar.getInstance();
if (willBeDST(cal)) {
warnUser(Notification.DST_IN_24H, MainApp.gs(R.string.dst_in_24h_warning));
}
if (!value.value()) {
log.debug("Already not allowed - don't check further");
return value;
}
if (wasDST(cal)) {
LoopPlugin loopPlugin = LoopPlugin.getPlugin();
if (!loopPlugin.isSuspended()) {
warnUser(Notification.DST_LOOP_DISABLED, MainApp.gs(R.string.dst_loop_disabled_warning));
} else {
log.debug("Loop already suspended");
}
value.set(false, "DST in last 3 hours.", this);
}
return value;
}
// display warning
void warnUser(int id, String warningText) {
private void warnUser(int id, String warningText) {
Notification notification = new Notification(id, warningText, Notification.LOW);
MainApp.bus().post(new EventNewNotification(notification));
}
}

View file

@ -1391,4 +1391,9 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
}
@Override
public boolean canHandleDST() {
return false;
}
}

View file

@ -488,4 +488,12 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
}
@Override
public boolean canHandleDST() {
return false;
}
}

View file

@ -827,4 +827,9 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
}
@Override
public boolean canHandleDST() {
return false;
}
}

View file

@ -1569,4 +1569,9 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
Notification notification = new Notification(Notification.INSIGHT_TIMEOUT_DURING_HANDSHAKE, MainApp.gs(R.string.timeout_during_handshake), Notification.URGENT);
new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventNewNotification(notification)));
}
@Override
public boolean canHandleDST() {
return true;
}
}

View file

@ -260,4 +260,9 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
}
@Override
public boolean canHandleDST() {
return true;
}
}

View file

@ -455,6 +455,11 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
return pumpType;
}
@Override
public boolean canHandleDST() {
return true;
}
public void refreshConfiguration() {
String pumptype = SP.getString(R.string.key_virtualpump_type, "Generic AAPS");

View file

@ -1130,7 +1130,6 @@
<string name="tomato">Tomato (MiaoMiao)</string>
<string name="tomato_short">Tomato</string>
<string name="dst_in_24h_warning">Daglig spaar tyd verandering in 24 h of minder</string>
<string name="dst_loop_disabled_warning">Daglig spaar tyd verander in minder as 3 ure - geslote lus afgeskakel</string>
<string name="storage">interne berging beperking</string>
<string name="diskfull">Bevry ten minste %1$d MB van intene stoorspasie! Lus gedeaktiveer!</string>
<plurals name="objective_days">

View file

@ -1131,7 +1131,6 @@
<string name="tomato">Tomato(MяоМяо)</string>
<string name="tomato_short">Tomato</string>
<string name="dst_in_24h_warning">Смяна на времето след по-малко от 24ч</string>
<string name="dst_loop_disabled_warning">Смяна на времето след по-малко от 3 часа - минавам в отворен режим</string>
<string name="storage">Ограничение поради липса на памет</string>
<string name="diskfull">Освободете поне %1$d Мб в паметта на телефона! Loop изключен!</string>
<plurals name="objective_days">

View file

@ -1148,7 +1148,6 @@
<string name="tomato">Tomato (MiaoMiao)</string>
<string name="tomato_short">Tomato</string>
<string name="dst_in_24h_warning">Změna letního času za méně než 24 hodin</string>
<string name="dst_loop_disabled_warning">Změna letního času za méně než 3 hodiny - Uzavřená smyčka zastavena</string>
<string name="storage">omezení vnitřního úložiště</string>
<string name="diskfull">Uvolněte alespoň %1$d MB z vnitřního úložiště! Smyčka zakázána!</string>
<string name="wrongformat">Chybný formát</string>

View file

@ -1133,7 +1133,6 @@ Unerwartetes Verhalten.</string>
<string name="tomato">Tomato (MiaoMiao)</string>
<string name="tomato_short">Tomato</string>
<string name="dst_in_24h_warning">Zeitumstellung in weniger als 24 Stunden</string>
<string name="dst_loop_disabled_warning">Zeitumstellung in weniger als 3 Stunden - Closed loop deaktiviert</string>
<string name="storage">interne Speicherbegrenzung</string>
<string name="diskfull">Mindestens %1$d MB freier interer Speicher benötigt! Loop abgeschaltet!</string>
<plurals name="objective_days">

View file

@ -267,6 +267,10 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S
<string name="smscommunicator_bolusreplywithcode">Renvoyer le code %2$s pour injecter le bolus %1$.2fU</string>
<string name="smscommunicator_calibrationreplywithcode">Renvoyer le code %2$s pour envoyer la calibration %1$.2f</string>
<string name="smscommunicator_bolusfailed">Échec du Bolus</string>
<string name="bolusdelivered">Bolus %1$.2fU délivré avec succès</string>
<string name="bolusrequested">%1$.2fU vont être injectées</string>
<string name="smscommunicator_bolusdelivered">Bolus %1$.2fU délivré avec succès</string>
<string name="bolusdelivering">En train d\'injecter %1$.2fU</string>
<string name="smscommunicator_remotecommandsallowed">Autoriser les commandes à distance par SMS</string>
<string name="glucosetype_finger">Doigt</string>
<string name="glucosetype_sensor">Capteur</string>
@ -336,11 +340,24 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S
<string name="valuelimitedto">%1$.2f limité à %2$.2f</string>
<string name="valueoutofrange" formatted="false">La valeur %s est hors des limites strictes</string>
<string name="smscommunicator_remotecommandnotallowed">La commande à distance n\'est pas autorisée</string>
<string name="smscommunicator_remotebolusnotallowed">Bolus à distance non disponible. Réessayez plus tard.</string>
<string name="smscommunicator_basalreplywithcode">Pour démarrer Basal %1$.2fU/h pendant %2$d min, renvoyer le code %3$s</string>
<string name="smscommunicator_profilereplywithcode">Pour changer le profil vers %1$s %2$d%%, renvoyer le code %3$s</string>
<string name="smscommunicator_extendedreplywithcode">Pour démarrer le Bolus étendu %1$.2fU pendant %2$d min, renvoyer le code %3$s</string>
<string name="smscommunicator_basalpctreplywithcode">Pour démarrer le Basal %1$d% pendant %2$d min, renvoyer le code %3$s</string>
<string name="smscommunicator_suspendreplywithcode">Envoyer le code %2$s pour suspendre la Boucle pour %1$d minutes</string>
<string name="smscommunicator_tempbasalset">Démarrage réussi pour %1$.2fU/h de basal temporaire pour %2$d min</string>
<string name="smscommunicator_extendedset">Le Bolus étendu %1$.2fU pendant %2$d min a commencé avec succès</string>
<string name="smscommunicator_tempbasalset_percent">Démarrage réussi pour %1$d%% de Basal temporaire pour %2$d min</string>
<string name="smscommunicator_tempbasalfailed">Le démarrage du basal temporaire a échoué</string>
<string name="smscommunicator_extendedfailed">Le départ du Bolus étendu a échoué</string>
<string name="smscommunicator_basalstopreplywithcode">Envoyer le code %1$s pour arrêter le Basal temporaire</string>
<string name="smscommunicator_extendedstopreplywithcode">Pour arrêter le Bolus étendu, renvoyer le code %1$s</string>
<string name="smscommunicator_tempbasalcanceled">Basal temporaire annulé</string>
<string name="smscommunicator_extendedcanceled">Bolus étendu annulé</string>
<string name="smscommunicator_tempbasalcancelfailed">Echec de l\'annulation du basal temporaire</string>
<string name="smscommunicator_extendedcancelfailed">Échec de l\'annulation du Bolus étendu</string>
<string name="smscommunicator_unknowncommand">Commande inconnue ou mauvaise réponse</string>
<string name="quickwizard">Assistant Rapide</string>
<string name="quickwizardsettings">Paramètres de l\'Assistant Rapide</string>
<string name="overview_editquickwizard_buttontext">Texte du bouton :</string>
@ -1132,9 +1149,12 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S
<string name="tomato">Tomato (MiaoMiao)</string>
<string name="tomato_short">Tomato</string>
<string name="dst_in_24h_warning">Changement d\'heure d\'été dans moins de 24 heures</string>
<string name="dst_loop_disabled_warning">Changement d\'heure d\'été dans moins de 3 heures - Boucle fermée désactivée</string>
<string name="storage">stockage interne limité</string>
<string name="diskfull">Boucle désactivée ! Libérez au moins %1$d Mo du stockage interne !</string>
<string name="wrongformat">Format incorrect</string>
<string name="sms_wrongcode">Code incorrect. Commande annulée.</string>
<string name="notconfigured">Non configuré</string>
<string name="profileswitchcreated">Changement de profil effectué</string>
<plurals name="objective_days">
<item quantity="one">%1$d jour</item>
<item quantity="other">%1$d jours</item>

View file

@ -1131,7 +1131,6 @@ Stel in en gebruik tijdelijk en standaard tijdelijke streefdoelen (bv. bij sport
<string name="tomato">Tomato (MiaoMiao)</string>
<string name="tomato_short">Tomato</string>
<string name="dst_in_24h_warning">Zomer/wintertijd omschakeling binnen 24 uur</string>
<string name="dst_loop_disabled_warning">Zomer/wintertijd omschakeling in minder dan 3 uur - Closed loop gedeactiveerd</string>
<string name="storage">interne opslag bijna vol</string>
<string name="diskfull">Maak minstens %1$d MB vrij in interne opslag! Loop is uitgeschakeld!</string>
<plurals name="objective_days">

View file

@ -1112,6 +1112,7 @@
<string name="short_status_extended">Estendido: %1$.2f / %2$.2f U por %3$d min</string>
<string name="short_status_multiwave">Multionda: %1$.2f / %2$.2f U por %3$d min</string>
<string name="short_status_reservoir">Reser:%1$.2fU</string>
<string name="short_status_battery">Bat.: %1$d%%</string>
<string name="max_recovery_duration">Duração máxima da recuperação [s]</string>
<string name="min_recovery_duration">Duração mínima da recuperação [s]</string>
<string name="recovery_duration">Duração da recuperação</string>
@ -1121,8 +1122,12 @@
<string name="profile_per_unit">/U</string>
<string name="dexcom_lognssensorchange_title">Registar mudança de sensor para NS</string>
<string name="dexcom_lognssensorchange_summary">Criar evento \"Mudança de Sensor\" automaticamente no NS aquando do início do sensor</string>
<string name="tomato">Tomato (MiaoMiao)</string>
<string name="tomato_short">Tomato</string>
<string name="storage">restrição de armazenamento interno</string>
<string name="diskfull">Liberte pelo menos %1$d MB do armazenamento interno! Loop desativado!</string>
<string name="notconfigured">Não configurado</string>
<string name="profileswitchcreated">Troca de perfil criada</string>
<plurals name="objective_days">
<item quantity="one">%1$d dia</item>
<item quantity="other">%1$d dias</item>

View file

@ -413,7 +413,7 @@
<string name="minago">%1$d мин. назад</string>
<string name="sms_minago">%1$d мин. назад</string>
<string name="localprofile">локальный профиль</string>
<string name="openapsama">Помощник болюса OpenAPS MA</string>
<string name="openapsama">Помощник болюса OpenAPS AMA</string>
<string name="short_avgdelta">краткосрочная средняя дельта</string>
<string name="long_avgdelta">Долгосрочная средняя дельта</string>
<string name="array_of_elements">Массив %1$d элементов. \nActual актуальная величина:</string>
@ -422,7 +422,7 @@
<string name="openapsama_useautosens">Пользоваться функцией Autosens</string>
<string name="refresheventsfromnightscout">обновить данные из NS</string>
<string name="deletefuturetreatments">Удалить назначения из будущего</string>
<string name="eatingsoon">Близкий прием пищи</string>
<string name="eatingsoon">Ожидаемый прием пищи</string>
<string name="hypo">Гипо</string>
<string name="activity">Нагрузка</string>
<string name="removerecord">удалить запись</string>
@ -648,7 +648,7 @@
<string name="enableuam">Включить непредвиденный прием пищи UAM</string>
<string name="enablesmb">Включить супер микро болюс SMB</string>
<string name="enablesmb_summary">Для ускорения действия используйте супер микро болюсы SMB вместо временного базала</string>
<string name="enableuam_summary">Поиск непредвиденного приема пищи</string>
<string name="enableuam_summary">Поиск незапланированного приема пищи</string>
<string name="insulin_oref_peak">Время пика действующего инс IOB</string>
<string name="insulin_peak_time">время пика (в мин.)</string>
<string name="free_peak_oref">Свободный от пиков Oref</string>
@ -866,7 +866,7 @@
<string name="allow_automated_crash_reporting">Разрешить отправлять сообщения о неполадках и данные об использовании опций разработчикам при помощи сервиса fabric.io.</string>
<string name="g5appnotdetected">Пожалуйста, обновите приложение Dexcom до поддерживаемой версии</string>
<string name="start_activity_tt">Включить временную цель TT Нагрузка</string>
<string name="start_eating_soon_tt">Включить временную цель TT Скорый прием пищи</string>
<string name="start_eating_soon_tt">Включить временную цель TT Ожидаемый прием пищи</string>
<string name="temptargetshort">Временная цель (TT)</string>
<string name="do_not_bolus_record_only">Не подавать болюс, только внести запись</string>
<string name="category">Категория</string>
@ -1150,7 +1150,6 @@ Context | Edit Context</string>
<string name="tomato">Томато (MiaoMiao)</string>
<string name="tomato_short">Томато</string>
<string name="dst_in_24h_warning">Переход на летнее/зимнее время через 24 часа или менее</string>
<string name="dst_loop_disabled_warning">Переход на летнее/зимнее время менее чем через 3 часа - замкнутый цикл отключен</string>
<string name="storage">ограничение по объему карты памяти</string>
<string name="diskfull">Освободите по крайней мере %1$d MB из внутренней памяти! Цикл остановлен!</string>
<string name="wrongformat">Неверный формат</string>

View file

@ -1364,7 +1364,7 @@
<string name="key_smbmaxminutes" translatable="false">smbmaxminutes</string>
<string name="dst_plugin_name" translatable="false">Dayligh Saving time</string>
<string name="dst_in_24h_warning">Dayligh Saving time change in 24h or less</string>
<string name="dst_loop_disabled_warning">Dayligh Saving time change in less than 3 hours - Closed loop diabled</string>
<string name="dst_loop_disabled_warning">Daylight saving time change less than 3 hours ago - Closed loop disabled</string>
<string name="storage">internal storage constraint</string>
<string name="diskfull">Free at least %1$d MB from internal storage! Loop disabled!</string>
<string name="wrongformat">Wrong format</string>

View file

@ -9,7 +9,11 @@ import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import info.AAPSMocker;
@ -27,39 +31,46 @@ public class DstHelperPluginTest {
public void runTest() throws Exception {
AAPSMocker.mockMainApp();
AAPSMocker.mockApplicationContext();
// test different time zones
//Starting with Europe/Sofia
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Europe/Sofia"));
c.setTimeInMillis(DateUtil.fromISODateString("2018-10-28T02:00:00Z").getTime());
int minutesLeftToChange = plugin.dstTest(c);
Assert.assertEquals(60, minutesLeftToChange);
c.setTimeInMillis(DateUtil.fromISODateString("2018-03-25T02:00:00Z").getTime());
minutesLeftToChange = plugin.dstTest(c);
Assert.assertEquals(60, minutesLeftToChange);
// try something with half hour somewhere in Australia
c = Calendar.getInstance(TimeZone.getTimeZone("Australia/Lord_Howe"));
c.setTimeInMillis(DateUtil.fromISODateString("2018-04-01T00:00:00Z").getTime());
minutesLeftToChange = plugin.dstTest(c);
// try something with half hour somewhere in Australia
c = Calendar.getInstance(TimeZone.getTimeZone("Australia/Lord_Howe"));
c.setTimeInMillis(DateUtil.fromISODateString("2018-04-01T00:00:00Z").getTime());
minutesLeftToChange = plugin.dstTest(c);
Assert.assertEquals(90, minutesLeftToChange);
c = Calendar.getInstance(TimeZone.getTimeZone("Australia/Lord_Howe"));
// and back
c.setTimeInMillis(DateUtil.fromISODateString("2018-10-07T00:00:00Z").getTime());
minutesLeftToChange = plugin.dstTest(c);
Assert.assertEquals(120, minutesLeftToChange);
c.setTimeInMillis(DateUtil.fromISODateString("2018-10-08T00:00:00Z").getTime());
minutesLeftToChange = plugin.dstTest(c);
Assert.assertEquals(0, minutesLeftToChange);
TimeZone tz = TimeZone.getTimeZone("Europe/Rome");
TimeZone.setDefault(tz);
Calendar cal = Calendar.getInstance(tz, Locale.ITALIAN);
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ITALIAN);
Date dateBeforeDST = df.parse("2018-03-25 01:55");
cal.setTime(dateBeforeDST);
Assert.assertEquals(false, plugin.wasDST(cal));
Assert.assertEquals(true, plugin.willBeDST(cal));
TimeZone.setDefault(tz);
cal = Calendar.getInstance(tz, Locale.ITALIAN);
dateBeforeDST = df.parse("2018-03-25 03:05");
cal.setTime(dateBeforeDST);
Assert.assertEquals(true, plugin.wasDST(cal));
Assert.assertEquals(false, plugin.willBeDST(cal));
TimeZone.setDefault(tz);
cal = Calendar.getInstance(tz, Locale.ITALIAN);
dateBeforeDST = df.parse("2018-03-25 02:05"); //Cannot happen!!!
cal.setTime(dateBeforeDST);
Assert.assertEquals(true, plugin.wasDST(cal));
Assert.assertEquals(false, plugin.willBeDST(cal));
TimeZone.setDefault(tz);
cal = Calendar.getInstance(tz, Locale.ITALIAN);
dateBeforeDST = df.parse("2018-03-25 05:55"); //Cannot happen!!!
cal.setTime(dateBeforeDST);
Assert.assertEquals(true, plugin.wasDST(cal));
Assert.assertEquals(false, plugin.willBeDST(cal));
TimeZone.setDefault(tz);
cal = Calendar.getInstance(tz, Locale.ITALIAN);
dateBeforeDST = df.parse("2018-03-25 06:05"); //Cannot happen!!!
cal.setTime(dateBeforeDST);
Assert.assertEquals(false, plugin.wasDST(cal));
Assert.assertEquals(false, plugin.willBeDST(cal));
// DST event was 30 mins
c.setTimeInMillis(DateUtil.fromISODateString("2018-04-01T02:00:00Z").getTime());
minutesLeftToChange = plugin.dstTest(c);
// Assert.assertEquals(630, plugin.zoneOffsetInMinutes(c));
Assert.assertEquals(0, minutesLeftToChange);
}
}

View file

@ -77,10 +77,12 @@ public class DateUtilTest {
assertTrue(DateUtil.dateAndTimeRangeString(1513902750000L, 1513902750000L).contains("32"));
}
/*
@Test
public void timeStringFromSecondsTest() {
Assert.assertEquals("1:00 AM", DateUtil.timeStringFromSeconds((int) T.hours(1).secs()));
}
*/
@Test
public void timeFrameStringTest() {