Merge branch 'dev' of github.com:MilosKozak/AndroidAPS into skip-neutral-temps
This commit is contained in:
commit
d5293d896d
67 changed files with 688 additions and 759 deletions
|
@ -1,39 +1,25 @@
|
||||||
package info.nightscout.androidaps;
|
package info.nightscout.androidaps;
|
||||||
|
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.NotificationManager;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
|
|
||||||
import androidx.annotation.ColorRes;
|
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.core.app.NotificationCompat;
|
|
||||||
import androidx.core.app.TaskStackBuilder;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import com.crashlytics.android.Crashlytics;
|
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
|
||||||
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
||||||
|
|
||||||
import net.danlew.android.joda.JodaTimeAndroid;
|
import net.danlew.android.joda.JodaTimeAndroid;
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.AndroidInjector;
|
import dagger.android.AndroidInjector;
|
||||||
import dagger.android.DaggerApplication;
|
import dagger.android.DaggerApplication;
|
||||||
import dagger.android.HasAndroidInjector;
|
|
||||||
import info.nightscout.androidaps.data.Profile;
|
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent;
|
import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
@ -41,7 +27,6 @@ import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore;
|
import info.nightscout.androidaps.plugins.configBuilder.PluginStore;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
|
||||||
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils;
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.receivers.BTReceiver;
|
import info.nightscout.androidaps.receivers.BTReceiver;
|
||||||
|
@ -49,39 +34,24 @@ import info.nightscout.androidaps.receivers.ChargingStateReceiver;
|
||||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||||
import info.nightscout.androidaps.receivers.NetworkChangeReceiver;
|
import info.nightscout.androidaps.receivers.NetworkChangeReceiver;
|
||||||
import info.nightscout.androidaps.receivers.ReceiverStatusStore;
|
|
||||||
import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver;
|
import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver;
|
||||||
import info.nightscout.androidaps.services.Intents;
|
import info.nightscout.androidaps.services.Intents;
|
||||||
import info.nightscout.androidaps.utils.ActivityMonitor;
|
import info.nightscout.androidaps.utils.ActivityMonitor;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
|
||||||
import info.nightscout.androidaps.utils.LocaleHelper;
|
import info.nightscout.androidaps.utils.LocaleHelper;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.fabric.sdk.android.Fabric;
|
|
||||||
|
|
||||||
public class MainApp extends DaggerApplication {
|
public class MainApp extends DaggerApplication {
|
||||||
|
|
||||||
static MainApp sInstance;
|
static MainApp sInstance;
|
||||||
private static Resources sResources;
|
private static Resources sResources;
|
||||||
|
|
||||||
static FirebaseAnalytics firebaseAnalytics;
|
|
||||||
|
|
||||||
static DatabaseHelper sDatabaseHelper = null;
|
static DatabaseHelper sDatabaseHelper = null;
|
||||||
|
|
||||||
private String CHANNEL_ID = "AndroidAPS-Ongoing"; // TODO: move to OngoingNotificationProvider (and dagger)
|
|
||||||
private int ONGOING_NOTIFICATION_ID = 4711; // TODO: move to OngoingNotificationProvider (and dagger)
|
|
||||||
private Notification notification; // TODO: move to OngoingNotificationProvider (and dagger)
|
|
||||||
|
|
||||||
@Inject PluginStore pluginStore;
|
@Inject PluginStore pluginStore;
|
||||||
@Inject public HasAndroidInjector injector;
|
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
@Inject ReceiverStatusStore receiverStatusStore;
|
|
||||||
@Inject ActivityMonitor activityMonitor;
|
@Inject ActivityMonitor activityMonitor;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
|
||||||
@Inject ResourceHelper resourceHelper;
|
|
||||||
@Inject VersionCheckerUtils versionCheckersUtils;
|
@Inject VersionCheckerUtils versionCheckersUtils;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
@Inject ProfileFunction profileFunction;
|
|
||||||
|
|
||||||
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
||||||
@Inject KeepAliveReceiver.KeepAliveManager keepAliveManager;
|
@Inject KeepAliveReceiver.KeepAliveManager keepAliveManager;
|
||||||
|
@ -95,7 +65,6 @@ public class MainApp extends DaggerApplication {
|
||||||
sInstance = this;
|
sInstance = this;
|
||||||
sResources = getResources();
|
sResources = getResources();
|
||||||
LocaleHelper.INSTANCE.update(this);
|
LocaleHelper.INSTANCE.update(this);
|
||||||
generateEmptyNotification();
|
|
||||||
sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class);
|
sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class);
|
||||||
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> {
|
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> {
|
||||||
|
@ -106,19 +75,8 @@ public class MainApp extends DaggerApplication {
|
||||||
aapsLogger.error("Uncaught exception crashing app", ex);
|
aapsLogger.error("Uncaught exception crashing app", ex);
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
|
||||||
if (fabricPrivacy.fabricEnabled()) {
|
|
||||||
Fabric.with(this, new Crashlytics());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
aapsLogger.error("Error with Fabric init! " + e);
|
|
||||||
}
|
|
||||||
|
|
||||||
registerActivityLifecycleCallbacks(activityMonitor);
|
registerActivityLifecycleCallbacks(activityMonitor);
|
||||||
|
|
||||||
firebaseAnalytics = FirebaseAnalytics.getInstance(this);
|
|
||||||
firebaseAnalytics.setAnalyticsCollectionEnabled(!Boolean.getBoolean("disableFirebase") && fabricPrivacy.fabricEnabled());
|
|
||||||
|
|
||||||
JodaTimeAndroid.init(this);
|
JodaTimeAndroid.init(this);
|
||||||
|
|
||||||
aapsLogger.debug("Version: " + BuildConfig.VERSION_NAME);
|
aapsLogger.debug("Version: " + BuildConfig.VERSION_NAME);
|
||||||
|
@ -143,26 +101,6 @@ public class MainApp extends DaggerApplication {
|
||||||
|
|
||||||
private void doMigrations() {
|
private void doMigrations() {
|
||||||
|
|
||||||
// guarantee that the unreachable threshold is at least 30 and of type String
|
|
||||||
// Added in 1.57 at 21.01.2018
|
|
||||||
int unreachable_threshold = sp.getInt(R.string.key_pump_unreachable_threshold, 30);
|
|
||||||
sp.remove(R.string.key_pump_unreachable_threshold);
|
|
||||||
if (unreachable_threshold < 30) unreachable_threshold = 30;
|
|
||||||
sp.putString(R.string.key_pump_unreachable_threshold, Integer.toString(unreachable_threshold));
|
|
||||||
|
|
||||||
// 2.5 -> 2.6
|
|
||||||
if (!sp.contains(R.string.key_units)) {
|
|
||||||
String newUnits = Constants.MGDL;
|
|
||||||
Profile p = profileFunction.getProfile();
|
|
||||||
if (p != null && p.getData() != null && p.getData().has("units")) {
|
|
||||||
try {
|
|
||||||
newUnits = p.getData().getString("units");
|
|
||||||
} catch (JSONException e) {
|
|
||||||
aapsLogger.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sp.putString(R.string.key_units, newUnits);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -212,11 +150,6 @@ public class MainApp extends DaggerApplication {
|
||||||
return sResources.getString(id);
|
return sResources.getString(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String gs(@StringRes int id, Object... args) {
|
|
||||||
return sResources.getString(id, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static MainApp instance() {
|
public static MainApp instance() {
|
||||||
return sInstance;
|
return sInstance;
|
||||||
|
@ -226,46 +159,6 @@ public class MainApp extends DaggerApplication {
|
||||||
return sDatabaseHelper;
|
return sDatabaseHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FirebaseAnalytics getFirebaseAnalytics() {
|
|
||||||
return firebaseAnalytics;
|
|
||||||
}
|
|
||||||
|
|
||||||
// global Notification has been moved to MainApp because PersistentNotificationPlugin is initialized too late
|
|
||||||
private void generateEmptyNotification() {
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID);
|
|
||||||
builder.setOngoing(true)
|
|
||||||
.setOnlyAlertOnce(true)
|
|
||||||
.setCategory(NotificationCompat.CATEGORY_STATUS)
|
|
||||||
.setSmallIcon(resourceHelper.getNotificationIcon())
|
|
||||||
.setLargeIcon(resourceHelper.decodeResource(resourceHelper.getIcon()));
|
|
||||||
builder.setContentTitle(resourceHelper.gs(R.string.loading));
|
|
||||||
Intent resultIntent = new Intent(this, MainApp.class);
|
|
||||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
|
|
||||||
stackBuilder.addParentStack(MainActivity.class);
|
|
||||||
stackBuilder.addNextIntent(resultIntent);
|
|
||||||
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
builder.setContentIntent(resultPendingIntent);
|
|
||||||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
notification = builder.build();
|
|
||||||
mNotificationManager.notify(ONGOING_NOTIFICATION_ID, notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int notificationId() {
|
|
||||||
return ONGOING_NOTIFICATION_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String channelId() {
|
|
||||||
return CHANNEL_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotification(Notification notification) {
|
|
||||||
this.notification = notification;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Notification getNotification() {
|
|
||||||
return notification;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTerminate() {
|
public void onTerminate() {
|
||||||
aapsLogger.debug(LTag.CORE, "onTerminate");
|
aapsLogger.debug(LTag.CORE, "onTerminate");
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class Profile {
|
||||||
|
|
||||||
// Default constructor for DB
|
// Default constructor for DB
|
||||||
public Profile() {
|
public Profile() {
|
||||||
MainApp.instance().injector.androidInjector().inject(this);
|
MainApp.instance().androidInjector().inject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Profile(HasAndroidInjector injector) {
|
protected Profile(HasAndroidInjector injector) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
||||||
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
|
@ -999,7 +1000,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void createTempBasalFromJsonIfNotExists(JSONObject trJson) {
|
public void createTempBasalFromJsonIfNotExists(JSONObject trJson) {
|
||||||
try {
|
try {
|
||||||
if (trJson.has("originalExtendedAmount")) { // extended bolus uploaded as temp basal
|
if (trJson.has("originalExtendedAmount")) { // extended bolus uploaded as temp basal
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus()
|
ExtendedBolus extendedBolus = new ExtendedBolus(MainApp.instance())
|
||||||
.source(Source.NIGHTSCOUT)
|
.source(Source.NIGHTSCOUT)
|
||||||
.date(trJson.getLong("mills"))
|
.date(trJson.getLong("mills"))
|
||||||
.pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0)
|
.pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0)
|
||||||
|
@ -1014,7 +1015,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
createOrUpdate(extendedBolus);
|
createOrUpdate(extendedBolus);
|
||||||
} else if (trJson.has("isFakedTempBasal")) { // extended bolus end uploaded as temp basal end
|
} else if (trJson.has("isFakedTempBasal")) { // extended bolus end uploaded as temp basal end
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
ExtendedBolus extendedBolus = new ExtendedBolus(MainApp.instance());
|
||||||
extendedBolus.source = Source.NIGHTSCOUT;
|
extendedBolus.source = Source.NIGHTSCOUT;
|
||||||
extendedBolus.date = trJson.getLong("mills");
|
extendedBolus.date = trJson.getLong("mills");
|
||||||
extendedBolus.pumpId = trJson.has("pumpId") ? trJson.getLong("pumpId") : 0;
|
extendedBolus.pumpId = trJson.has("pumpId") ? trJson.getLong("pumpId") : 0;
|
||||||
|
@ -1029,7 +1030,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
createOrUpdate(extendedBolus);
|
createOrUpdate(extendedBolus);
|
||||||
} else {
|
} else {
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal()
|
TemporaryBasal tempBasal = new TemporaryBasal( MainApp.instance())
|
||||||
.date(trJson.getLong("mills"))
|
.date(trJson.getLong("mills"))
|
||||||
.source(Source.NIGHTSCOUT)
|
.source(Source.NIGHTSCOUT)
|
||||||
.pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0);
|
.pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0);
|
||||||
|
@ -1288,7 +1289,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void createExtendedBolusFromJsonIfNotExists(JSONObject json) {
|
public void createExtendedBolusFromJsonIfNotExists(JSONObject json) {
|
||||||
ExtendedBolus extendedBolus = ExtendedBolus.createFromJson(json);
|
ExtendedBolus extendedBolus = ExtendedBolus.createFromJson(MainApp.instance(), json);
|
||||||
if (extendedBolus != null)
|
if (extendedBolus != null)
|
||||||
createOrUpdate(extendedBolus);
|
createOrUpdate(extendedBolus);
|
||||||
}
|
}
|
||||||
|
@ -1480,7 +1481,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
List<CareportalEvent> list = getDaoCareportalEvents().query(preparedQuery);
|
List<CareportalEvent> list = getDaoCareportalEvents().query(preparedQuery);
|
||||||
CareportalEvent careportalEvent;
|
CareportalEvent careportalEvent;
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
careportalEvent = new CareportalEvent();
|
careportalEvent = new CareportalEvent(MainApp.instance());
|
||||||
careportalEvent.source = Source.NIGHTSCOUT;
|
careportalEvent.source = Source.NIGHTSCOUT;
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Adding CareportalEvent record to database: " + trJson.toString());
|
log.debug("Adding CareportalEvent record to database: " + trJson.toString());
|
||||||
|
@ -1708,9 +1709,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void createProfileSwitchFromJsonIfNotExists(JSONObject trJson) {
|
public void createProfileSwitchFromJsonIfNotExists(ActivePluginProvider activePluginProvider, JSONObject trJson) {
|
||||||
try {
|
try {
|
||||||
ProfileSwitch profileSwitch = new ProfileSwitch(MainApp.instance().injector);
|
ProfileSwitch profileSwitch = new ProfileSwitch(MainApp.instance());
|
||||||
profileSwitch.date = trJson.getLong("mills");
|
profileSwitch.date = trJson.getLong("mills");
|
||||||
if (trJson.has("duration"))
|
if (trJson.has("duration"))
|
||||||
profileSwitch.durationInMinutes = trJson.getInt("duration");
|
profileSwitch.durationInMinutes = trJson.getInt("duration");
|
||||||
|
@ -1725,7 +1726,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
if (trJson.has("profileJson"))
|
if (trJson.has("profileJson"))
|
||||||
profileSwitch.profileJson = trJson.getString("profileJson");
|
profileSwitch.profileJson = trJson.getString("profileJson");
|
||||||
else {
|
else {
|
||||||
ProfileInterface profileInterface = PluginStore.Companion.getInstance().getActiveProfileInterface();
|
ProfileInterface profileInterface = activePluginProvider.getActiveProfileInterface();
|
||||||
ProfileStore store = profileInterface.getProfile();
|
ProfileStore store = profileInterface.getProfile();
|
||||||
if (store != null) {
|
if (store != null) {
|
||||||
Profile profile = store.getSpecificProfile(profileSwitch.profileName);
|
Profile profile = store.getSpecificProfile(profileSwitch.profileName);
|
||||||
|
|
|
@ -10,18 +10,20 @@ import com.j256.ormlite.field.DatabaseField;
|
||||||
import com.j256.ormlite.table.DatabaseTable;
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore;
|
import info.nightscout.androidaps.plugins.configBuilder.PluginStore;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
|
@ -38,7 +40,10 @@ import info.nightscout.androidaps.utils.Round;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_EXTENDEDBOLUSES)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_EXTENDEDBOLUSES)
|
||||||
public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE);
|
|
||||||
|
@Inject ActivePluginProvider activePlugin;
|
||||||
|
|
||||||
|
private HasAndroidInjector injector;
|
||||||
|
|
||||||
@DatabaseField(id = true)
|
@DatabaseField(id = true)
|
||||||
public long date;
|
public long date;
|
||||||
|
@ -64,10 +69,19 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public double dia = Constants.defaultDIA;
|
public double dia = Constants.defaultDIA;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ExtendedBolus() {
|
public ExtendedBolus() {
|
||||||
|
injector = MainApp.instance();
|
||||||
|
injector.androidInjector().inject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExtendedBolus(long date) {
|
public ExtendedBolus(HasAndroidInjector injector) {
|
||||||
|
this.injector = injector;
|
||||||
|
injector.androidInjector().inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExtendedBolus(HasAndroidInjector injector, long date) {
|
||||||
|
this(injector);
|
||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +138,8 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
pumpId = t.pumpId;
|
pumpId = t.pumpId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ExtendedBolus createFromJson(JSONObject json) {
|
public static ExtendedBolus createFromJson(HasAndroidInjector injector, JSONObject json) {
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus()
|
ExtendedBolus extendedBolus = new ExtendedBolus(injector)
|
||||||
.source(Source.NIGHTSCOUT)
|
.source(Source.NIGHTSCOUT)
|
||||||
.date(JsonHelper.safeGetLong(json, "mills"))
|
.date(JsonHelper.safeGetLong(json, "mills"))
|
||||||
.durationInMinutes(JsonHelper.safeGetInt(json, "duration"))
|
.durationInMinutes(JsonHelper.safeGetInt(json, "duration"))
|
||||||
|
@ -219,7 +233,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
|
|
||||||
public IobTotal iobCalc(long time) {
|
public IobTotal iobCalc(long time) {
|
||||||
IobTotal result = new IobTotal(time);
|
IobTotal result = new IobTotal(time);
|
||||||
InsulinInterface insulinInterface = PluginStore.Companion.getInstance().getActiveInsulin();
|
InsulinInterface insulinInterface = activePlugin.getActiveInsulin();
|
||||||
|
|
||||||
double realDuration = getDurationToTime(time);
|
double realDuration = getDurationToTime(time);
|
||||||
|
|
||||||
|
@ -251,7 +265,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
|
|
||||||
public IobTotal iobCalc(long time, Profile profile, AutosensResult lastAutosensResult, boolean exercise_mode, int half_basal_exercise_target, boolean isTempTarget) {
|
public IobTotal iobCalc(long time, Profile profile, AutosensResult lastAutosensResult, boolean exercise_mode, int half_basal_exercise_target, boolean isTempTarget) {
|
||||||
IobTotal result = new IobTotal(time);
|
IobTotal result = new IobTotal(time);
|
||||||
InsulinInterface insulinInterface = PluginStore.Companion.getInstance().getActiveInsulin();
|
InsulinInterface insulinInterface = activePlugin.getActiveInsulin();
|
||||||
|
|
||||||
double realDuration = getDurationToTime(time);
|
double realDuration = getDurationToTime(time);
|
||||||
double netBasalAmount = 0d;
|
double netBasalAmount = 0d;
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
@Inject public ResourceHelper resourceHelper;
|
@Inject public ResourceHelper resourceHelper;
|
||||||
|
|
||||||
public ProfileSwitch() {
|
public ProfileSwitch() {
|
||||||
this.injector = MainApp.instance().injector;
|
this.injector = MainApp.instance();
|
||||||
injector.androidInjector().inject(this);
|
injector.androidInjector().inject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPTARGETS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPTARGETS)
|
||||||
public class TempTarget implements Interval {
|
public class TempTarget implements Interval {
|
||||||
|
@ -195,10 +196,10 @@ public class TempTarget implements Interval {
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
public String friendlyDescription(String units) {
|
public String friendlyDescription(String units, ResourceHelper resourceHelper) {
|
||||||
return Profile.toTargetRangeString(low, high, Constants.MGDL, units) +
|
return Profile.toTargetRangeString(low, high, Constants.MGDL, units) +
|
||||||
units +
|
units +
|
||||||
"@" + MainApp.gs(R.string.mins, durationInMinutes) +
|
"@" + resourceHelper.gs(R.string.mins, durationInMinutes) +
|
||||||
(reason != null && !reason.equals("") ? "(" + reason + ")" : "");
|
(reason != null && !reason.equals("") ? "(" + reason + ")" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@ package info.nightscout.androidaps.db;
|
||||||
import com.j256.ormlite.field.DatabaseField;
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
import com.j256.ormlite.table.DatabaseTable;
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -15,17 +13,16 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 21.05.2017.
|
* Created by mike on 21.05.2017.
|
||||||
|
@ -33,9 +30,12 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPORARYBASALS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPORARYBASALS)
|
||||||
public class TemporaryBasal implements Interval, DbObjectBase {
|
public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE);
|
|
||||||
|
|
||||||
|
@Inject public AAPSLogger aapsLogger;
|
||||||
@Inject public ProfileFunction profileFunction;
|
@Inject public ProfileFunction profileFunction;
|
||||||
|
@Inject public ActivePluginProvider activePlugin;
|
||||||
|
@Inject public SP sp;
|
||||||
|
|
||||||
private HasAndroidInjector injector;
|
private HasAndroidInjector injector;
|
||||||
|
|
||||||
@DatabaseField(id = true)
|
@DatabaseField(id = true)
|
||||||
|
@ -246,12 +246,12 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
public IobTotal iobCalc(long time, Profile profile) {
|
public IobTotal iobCalc(long time, Profile profile) {
|
||||||
|
|
||||||
if (isFakeExtended) {
|
if (isFakeExtended) {
|
||||||
log.error("iobCalc should only be called on Extended boluses separately");
|
aapsLogger.error("iobCalc should only be called on Extended boluses separately");
|
||||||
return new IobTotal(time);
|
return new IobTotal(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
IobTotal result = new IobTotal(time);
|
IobTotal result = new IobTotal(time);
|
||||||
InsulinInterface insulinInterface = PluginStore.Companion.getInstance().getActiveInsulin();
|
InsulinInterface insulinInterface = activePlugin.getActiveInsulin();
|
||||||
|
|
||||||
int realDuration = getDurationToTime(time);
|
int realDuration = getDurationToTime(time);
|
||||||
double netBasalAmount = 0d;
|
double netBasalAmount = 0d;
|
||||||
|
@ -301,12 +301,12 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
public IobTotal iobCalc(long time, Profile profile, AutosensResult lastAutosensResult, boolean exercise_mode, int half_basal_exercise_target, boolean isTempTarget) {
|
public IobTotal iobCalc(long time, Profile profile, AutosensResult lastAutosensResult, boolean exercise_mode, int half_basal_exercise_target, boolean isTempTarget) {
|
||||||
|
|
||||||
if (isFakeExtended) {
|
if (isFakeExtended) {
|
||||||
log.error("iobCalc should only be called on Extended boluses separately");
|
aapsLogger.error("iobCalc should only be called on Extended boluses separately");
|
||||||
return new IobTotal(time);
|
return new IobTotal(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
IobTotal result = new IobTotal(time);
|
IobTotal result = new IobTotal(time);
|
||||||
InsulinInterface insulinInterface = PluginStore.Companion.getInstance().getActiveInsulin();
|
InsulinInterface insulinInterface = activePlugin.getActiveInsulin();
|
||||||
|
|
||||||
double realDuration = getDurationToTime(time);
|
double realDuration = getDurationToTime(time);
|
||||||
double netBasalAmount = 0d;
|
double netBasalAmount = 0d;
|
||||||
|
@ -452,7 +452,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
rate = absoluteRate;
|
rate = absoluteRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)) {
|
if (sp.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && sp.getBoolean(R.string.key_danar_useextended, false)) {
|
||||||
Profile profile = profileFunction.getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
double basal = profile.getBasal();
|
double basal = profile.getBasal();
|
||||||
|
@ -483,7 +483,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
rate = absoluteRate;
|
rate = absoluteRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)) {
|
if (sp.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && sp.getBoolean(R.string.key_danar_useextended, false)) {
|
||||||
double basal = profile.getBasal();
|
double basal = profile.getBasal();
|
||||||
if (basal != 0) {
|
if (basal != 0) {
|
||||||
return Math.round(rate * 100d / basal) + "% ";
|
return Math.round(rate * 100d / basal) + "% ";
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback
|
||||||
|
import info.nightscout.androidaps.plugins.aps.loop.APSResult
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalAdapterAMAJS
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class APSModule {
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun loggerCallbackInjector(): LoggerCallback
|
||||||
|
@ContributesAndroidInjector abstract fun apsResultInjector(): APSResult
|
||||||
|
@ContributesAndroidInjector abstract fun determineBasalResultSMBInjector(): DetermineBasalResultSMB
|
||||||
|
@ContributesAndroidInjector abstract fun determineBasalResultAMAInjector(): DetermineBasalResultAMA
|
||||||
|
@ContributesAndroidInjector abstract fun determineBasalAdapterAMAJSInjector(): DetermineBasalAdapterAMAJS
|
||||||
|
@ContributesAndroidInjector abstract fun determineBasalAdapterSMBJSInjector(): DetermineBasalAdapterSMBJS
|
||||||
|
@ContributesAndroidInjector abstract fun autosensDataInjector(): AutosensData
|
||||||
|
@ContributesAndroidInjector abstract fun iobCobThreadInjector(): IobCobThread
|
||||||
|
@ContributesAndroidInjector abstract fun iobCobOref1ThreadInjector(): IobCobOref1Thread
|
||||||
|
}
|
|
@ -57,161 +57,21 @@ import javax.inject.Singleton
|
||||||
FragmentsModule::class,
|
FragmentsModule::class,
|
||||||
AppModule::class,
|
AppModule::class,
|
||||||
ReceiversModule::class,
|
ReceiversModule::class,
|
||||||
ServicesModule::class
|
ServicesModule::class,
|
||||||
|
AutomationModule::class,
|
||||||
|
CommandQueueModule::class,
|
||||||
|
ObjectivesModule::class,
|
||||||
|
WizardModule::class,
|
||||||
|
MedtronicModule::class,
|
||||||
|
APSModule::class,
|
||||||
|
PreferencesModule::class,
|
||||||
|
OverviewModule::class,
|
||||||
|
DataClassesModule::class,
|
||||||
|
SMSModule::class
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
interface AppComponent : AndroidInjector<MainApp> {
|
interface AppComponent : AndroidInjector<MainApp> {
|
||||||
|
|
||||||
fun injectProfileStore(profileStore: ProfileStore)
|
|
||||||
fun injectPumpEnactResult(pumpEnactResult: PumpEnactResult)
|
|
||||||
fun injectAPSResult(apsResult: APSResult)
|
|
||||||
fun injectDetermineBasalResultSMB(determineBasalResultSMB: DetermineBasalResultSMB)
|
|
||||||
fun injectDetermineBasalResultAMA(determineBasalResultAMA: DetermineBasalResultAMA)
|
|
||||||
fun injectDetermineBasalAdapterSMBJS(determineBasalAdapterSMBJS: DetermineBasalAdapterSMBJS)
|
|
||||||
|
|
||||||
fun injectCommandQueue(commandQueue: CommandQueue)
|
|
||||||
fun injectCommandBolus(commandBolus: CommandBolus)
|
|
||||||
fun injectCommandCancelExtendedBolus(commandCancelExtendedBolus: CommandCancelExtendedBolus)
|
|
||||||
fun injectCommandCancelTempBasal(commandCancelTempBasal: CommandCancelTempBasal)
|
|
||||||
fun injectCommandExtendedBolus(commandExtendedBolus: CommandExtendedBolus)
|
|
||||||
fun injectCommandInsightSetTBROverNotification(commandInsightSetTBROverNotification: CommandInsightSetTBROverNotification)
|
|
||||||
fun injectCommandLoadEvents(commandLoadEvents: CommandLoadEvents)
|
|
||||||
fun injectCommandLoadHistory(commandLoadHistory: CommandLoadHistory)
|
|
||||||
fun injectCommandLoadTDDs(commandLoadTDDs: CommandLoadTDDs)
|
|
||||||
fun injectCommandReadStatus(commandReadStatus: CommandReadStatus)
|
|
||||||
fun injectCommandSetProfile(commandSetProfile: CommandSetProfile)
|
|
||||||
fun injectCommandCommandSMBBolus(commandSMBBolus: CommandSMBBolus)
|
|
||||||
fun injectCommandStartPump(commandStartPump: CommandStartPump)
|
|
||||||
fun injectCommandStopPump(commandStopPump: CommandStopPump)
|
|
||||||
fun injectCommandTempBasalAbsolute(commandTempBasalAbsolute: CommandTempBasalAbsolute)
|
|
||||||
fun injectCommandTempBasalPercent(commandTempBasalPercent: CommandTempBasalPercent)
|
|
||||||
fun injectCommandSetUserSettings(commandSetUserSettings: CommandSetUserSettings)
|
|
||||||
|
|
||||||
fun injectObjective(objective: Objective)
|
|
||||||
fun injectObjective0(objective0: Objective0)
|
|
||||||
fun injectObjective1(objective1: Objective1)
|
|
||||||
fun injectObjective2(objective2: Objective2)
|
|
||||||
fun injectObjective3(objective3: Objective3)
|
|
||||||
fun injectObjective4(objective4: Objective4)
|
|
||||||
fun injectObjective5(objective5: Objective5)
|
|
||||||
fun injectObjective6(objective6: Objective6)
|
|
||||||
fun injectObjective7(objective7: Objective7)
|
|
||||||
fun injectObjective8(objective8: Objective8)
|
|
||||||
fun injectObjective9(objective9: Objective9)
|
|
||||||
fun injectObjective10(objective10: Objective10)
|
|
||||||
|
|
||||||
fun injectAutomationEvent(automationEvent: AutomationEvent)
|
|
||||||
|
|
||||||
fun injectTrigger(trigger: Trigger)
|
|
||||||
fun injectTrigger(triggerAutosensValue: TriggerAutosensValue)
|
|
||||||
fun injectTrigger(triggerBg: TriggerBg)
|
|
||||||
fun injectTrigger(triggerBolusAgo: TriggerBolusAgo)
|
|
||||||
fun injectTrigger(triggerBTDevice: TriggerBTDevice)
|
|
||||||
fun injectTrigger(triggerCOB: TriggerCOB)
|
|
||||||
fun injectTrigger(triggerConnector: TriggerConnector)
|
|
||||||
fun injectTrigger(triggerDelta: TriggerDelta)
|
|
||||||
fun injectTrigger(triggerDummy: TriggerDummy)
|
|
||||||
fun injectTrigger(triggerIob: TriggerIob)
|
|
||||||
fun injectTrigger(triggerLocation: TriggerLocation)
|
|
||||||
fun injectTrigger(triggerProfilePercent: TriggerProfilePercent)
|
|
||||||
fun injectTrigger(triggerPumpLastConnection: TriggerPumpLastConnection)
|
|
||||||
fun injectTrigger(triggerRecurringTime: TriggerRecurringTime)
|
|
||||||
fun injectTrigger(triggerTempTarget: TriggerTempTarget)
|
|
||||||
fun injectTrigger(triggerTime: TriggerTime)
|
|
||||||
fun injectTrigger(triggerTimeRange: TriggerTimeRange)
|
|
||||||
fun injectTrigger(triggerWifiSsid: TriggerWifiSsid)
|
|
||||||
|
|
||||||
fun injectAction(action: Action)
|
|
||||||
fun injectActionDummy(action: ActionDummy)
|
|
||||||
fun injectActionLoopDisable(action: ActionLoopDisable)
|
|
||||||
fun injectActionLoopEnable(action: ActionLoopEnable)
|
|
||||||
fun injectActionLoopResume(action: ActionLoopResume)
|
|
||||||
fun injectAction(action: ActionLoopSuspend)
|
|
||||||
fun injectActionLoopSuspend(action: ActionNotification)
|
|
||||||
fun injectActionProfileSwitch(action: ActionProfileSwitch)
|
|
||||||
fun injectAction(action: ActionProfileSwitchPercent)
|
|
||||||
fun injectActionProfileSwitchPercent(action: ActionSendSMS)
|
|
||||||
fun injectActionStartTempTarget(action: ActionStartTempTarget)
|
|
||||||
fun injectActionStopTempTarget(action: ActionStopTempTarget)
|
|
||||||
|
|
||||||
fun injectElement(element: Element)
|
|
||||||
fun injectElement(inputBg: InputBg)
|
|
||||||
fun injectElement(inputButton: InputButton)
|
|
||||||
fun injectElement(comparator: Comparator)
|
|
||||||
fun injectElement(comparatorExists: ComparatorExists)
|
|
||||||
fun injectElement(comparatorConnect: ComparatorConnect)
|
|
||||||
fun injectElement(inputDateTime: InputDateTime)
|
|
||||||
fun injectElement(inputDelta: InputDelta)
|
|
||||||
fun injectElement(inputDropdownMenu: InputDropdownMenu)
|
|
||||||
fun injectElement(inputDouble: InputDouble)
|
|
||||||
fun injectElement(inputDuration: InputDuration)
|
|
||||||
fun injectElement(inputInsulin: InputInsulin)
|
|
||||||
fun injectElement(inputLocationMode: InputLocationMode)
|
|
||||||
fun injectElement(inputPercent: InputPercent)
|
|
||||||
fun injectElement(inputProfileName: InputProfileName)
|
|
||||||
fun injectElement(inputString: InputString)
|
|
||||||
fun injectElement(inputTempTarget: InputTempTarget)
|
|
||||||
fun injectElement(inputTimeRange: InputTimeRange)
|
|
||||||
fun injectElement(inputTime: InputTime)
|
|
||||||
fun injectElement(inputWeekDay: InputWeekDay)
|
|
||||||
fun injectElement(labelWithElement: LabelWithElement)
|
|
||||||
fun injectElement(staticLabel: StaticLabel)
|
|
||||||
|
|
||||||
fun injectAutosensDate(autosensData: AutosensData)
|
|
||||||
fun injectIobCobThread(iobCobThread: IobCobThread)
|
|
||||||
fun injectIobCobOref1Thread(iobCobOref1Thread: IobCobOref1Thread)
|
|
||||||
|
|
||||||
fun injectTreatment(treatment: Treatment)
|
|
||||||
fun injectBgReading(bgReading: BgReading)
|
|
||||||
fun injectProfileSwitch(profileSwitch: ProfileSwitch)
|
|
||||||
fun injectTemporaryBasal(temporaryBasal: TemporaryBasal)
|
|
||||||
fun injectCareportalEvent(careportalEvent: CareportalEvent)
|
|
||||||
|
|
||||||
fun injectNotification(notificationWithAction: NotificationWithAction)
|
|
||||||
|
|
||||||
fun injectLoggerCallback(loggerCallback: LoggerCallback)
|
|
||||||
fun injectBolusWizard(bolusWizard: BolusWizard)
|
|
||||||
fun injectQuickWizardEntry(quickWizardEntry: QuickWizardEntry)
|
|
||||||
|
|
||||||
fun injectAuthRequest(authRequest: AuthRequest)
|
|
||||||
|
|
||||||
fun injectSWBreak(swBreak: SWBreak)
|
|
||||||
fun injectSWButton(swButton: SWButton)
|
|
||||||
fun injectSWEditNumberWithUnits(swEditNumberWithUnits: SWEditNumberWithUnits)
|
|
||||||
fun injectSWEditString(swEditString: SWEditString)
|
|
||||||
fun injectSWEditEncryptedPassword(swSWEditEncryptedPassword: SWEditEncryptedPassword)
|
|
||||||
fun injectSWEditUrl(swEditUrl: SWEditUrl)
|
|
||||||
fun injectSWFragment(swFragment: SWFragment)
|
|
||||||
fun injectSSWHtmlLink(swHtmlLink: SWHtmlLink)
|
|
||||||
fun injectSWInfotext(swInfotext: SWInfotext)
|
|
||||||
fun injectSWItem(swItem: SWItem)
|
|
||||||
fun injectSWPlugin(swPlugin: SWPlugin)
|
|
||||||
fun injectSWRadioButton(swRadioButton: SWRadioButton)
|
|
||||||
fun injectSWScreen(swScreen: SWScreen)
|
|
||||||
fun injectSWEventListener(swEventListener: SWEventListener)
|
|
||||||
|
|
||||||
fun injectProfile(profile: Profile)
|
|
||||||
fun injectGlucoseStatus(glucoseStatus: GlucoseStatus)
|
|
||||||
|
|
||||||
fun injectGraphData(graphData: GraphData)
|
|
||||||
|
|
||||||
//Medtronic
|
|
||||||
fun injectRileyLinkCommunicationManager(rileyLinkCommunicationManager: RileyLinkCommunicationManager)
|
|
||||||
fun injectMedtronicCommunicationManager(medtronicCommunicationManager: MedtronicCommunicationManager)
|
|
||||||
fun injectMedtronicUITask(medtronicUITask: MedtronicUITask)
|
|
||||||
fun injectServiceTask(serviceTask: ServiceTask)
|
|
||||||
fun injectPumpTask(pumpTask: PumpTask)
|
|
||||||
fun injectDiscoverGattServicesTask(discoverGattServicesTask: DiscoverGattServicesTask)
|
|
||||||
fun injectInitializePumpManagerTask(initializePumpManagerTask: InitializePumpManagerTask)
|
|
||||||
fun injectResetRileyLinkConfigurationTask(resetRileyLinkConfigurationTask: ResetRileyLinkConfigurationTask)
|
|
||||||
fun injectWakeAndTuneTask(wakeAndTuneTask: WakeAndTuneTask)
|
|
||||||
fun injectRadioResponse(radioResponse: RadioResponse)
|
|
||||||
fun injectRileyLinkBLE(rileyLinkBLE: RileyLinkBLE)
|
|
||||||
fun injectRFSpy(rfSpy: RFSpy)
|
|
||||||
fun injectSendAndListen(sendAndListen: SendAndListen)
|
|
||||||
fun injectSetPreamble(setPreamble: SetPreamble)
|
|
||||||
fun injectRadioPacket(radioPacket: RadioPacket)
|
|
||||||
|
|
||||||
@Component.Builder
|
@Component.Builder
|
||||||
interface Builder {
|
interface Builder {
|
||||||
|
|
||||||
|
|
|
@ -131,180 +131,9 @@ open class AppModule {
|
||||||
@Module
|
@Module
|
||||||
interface AppBindings {
|
interface AppBindings {
|
||||||
|
|
||||||
@ContributesAndroidInjector fun profileStoreInjector(): ProfileStore
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun pumpEnactResultInjector(): PumpEnactResult
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun apsResultInjector(): APSResult
|
|
||||||
@ContributesAndroidInjector fun determineBasalResultSMBInjector(): DetermineBasalResultSMB
|
|
||||||
@ContributesAndroidInjector fun determineBasalResultAMAInjector(): DetermineBasalResultAMA
|
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
|
||||||
fun determineBasalAdapterSMBJSInjector(): DetermineBasalAdapterSMBJS
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun commandQueueInjector(): CommandQueue
|
|
||||||
@ContributesAndroidInjector fun commandBolusInjector(): CommandBolus
|
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
|
||||||
fun commandCancelExtendedBolusInjector(): CommandCancelExtendedBolus
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun commandCancelTempBasalInjector(): CommandCancelTempBasal
|
|
||||||
@ContributesAndroidInjector fun commandExtendedBolusInjector(): CommandExtendedBolus
|
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
|
||||||
fun commandInsightSetTBROverNotificationInjector(): CommandInsightSetTBROverNotification
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun commandLoadEventsInjector(): CommandLoadEvents
|
|
||||||
@ContributesAndroidInjector fun commandLoadHistoryInjector(): CommandLoadHistory
|
|
||||||
@ContributesAndroidInjector fun commandLoadTDDsInjector(): CommandLoadTDDs
|
|
||||||
@ContributesAndroidInjector fun commandReadStatusInjector(): CommandReadStatus
|
|
||||||
@ContributesAndroidInjector fun commandSetProfileInjector(): CommandSetProfile
|
|
||||||
@ContributesAndroidInjector fun commandCommandSMBBolusInjector(): CommandSMBBolus
|
|
||||||
@ContributesAndroidInjector fun commandStartPumpInjector(): CommandStartPump
|
|
||||||
@ContributesAndroidInjector fun commandStopPumpInjector(): CommandStopPump
|
|
||||||
@ContributesAndroidInjector fun commandTempBasalAbsoluteInjector(): CommandTempBasalAbsolute
|
|
||||||
@ContributesAndroidInjector fun commandTempBasalPercentInjector(): CommandTempBasalPercent
|
|
||||||
@ContributesAndroidInjector fun commandSetUserSettingsInjector(): CommandSetUserSettings
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun objectiveInjector(): Objective
|
|
||||||
@ContributesAndroidInjector fun objective0Injector(): Objective0
|
|
||||||
@ContributesAndroidInjector fun objective1Injector(): Objective1
|
|
||||||
@ContributesAndroidInjector fun objective2Injector(): Objective2
|
|
||||||
@ContributesAndroidInjector fun objective3Injector(): Objective3
|
|
||||||
@ContributesAndroidInjector fun objective4Injector(): Objective4
|
|
||||||
@ContributesAndroidInjector fun objective5Injector(): Objective5
|
|
||||||
@ContributesAndroidInjector fun objective6Injector(): Objective6
|
|
||||||
@ContributesAndroidInjector fun objective7Injector(): Objective7
|
|
||||||
@ContributesAndroidInjector fun objective8Injector(): Objective8
|
|
||||||
@ContributesAndroidInjector fun objective9Injector(): Objective9
|
|
||||||
@ContributesAndroidInjector fun objective10Injector(): Objective10
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun automationEventInjector(): AutomationEvent
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun triggerInjector(): Trigger
|
|
||||||
@ContributesAndroidInjector fun triggerAutosensValueInjector(): TriggerAutosensValue
|
|
||||||
@ContributesAndroidInjector fun triggerBgInjector(): TriggerBg
|
|
||||||
@ContributesAndroidInjector fun triggerBolusAgoInjector(): TriggerBolusAgo
|
|
||||||
@ContributesAndroidInjector fun triggerCOBInjector(): TriggerCOB
|
|
||||||
@ContributesAndroidInjector fun triggerConnectorInjector(): TriggerConnector
|
|
||||||
@ContributesAndroidInjector fun triggerDeltaInjector(): TriggerDelta
|
|
||||||
@ContributesAndroidInjector fun triggerDummyInjector(): TriggerDummy
|
|
||||||
@ContributesAndroidInjector fun triggerIobInjector(): TriggerIob
|
|
||||||
@ContributesAndroidInjector fun triggerLocationInjector(): TriggerLocation
|
|
||||||
@ContributesAndroidInjector fun triggerProfilePercentInjector(): TriggerProfilePercent
|
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
|
||||||
fun triggerPumpLastConnectionInjector(): TriggerPumpLastConnection
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun triggerBTDeviceInjector(): TriggerBTDevice
|
|
||||||
@ContributesAndroidInjector fun triggerRecurringTimeInjector(): TriggerRecurringTime
|
|
||||||
@ContributesAndroidInjector fun triggerTempTargetInjector(): TriggerTempTarget
|
|
||||||
@ContributesAndroidInjector fun triggerTime(): TriggerTime
|
|
||||||
@ContributesAndroidInjector fun triggerTimeRangeInjector(): TriggerTimeRange
|
|
||||||
@ContributesAndroidInjector fun triggerWifiSsidInjector(): TriggerWifiSsid
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun actionInjector(): Action
|
|
||||||
@ContributesAndroidInjector fun actionLoopDisableInjector(): ActionLoopDisable
|
|
||||||
@ContributesAndroidInjector fun actionLoopEnableInjector(): ActionLoopEnable
|
|
||||||
@ContributesAndroidInjector fun actionLoopResumeInjector(): ActionLoopResume
|
|
||||||
@ContributesAndroidInjector fun actionLoopSuspendInjector(): ActionLoopSuspend
|
|
||||||
@ContributesAndroidInjector fun actionNotificationInjector(): ActionNotification
|
|
||||||
@ContributesAndroidInjector fun actionProfileSwitchInjector(): ActionProfileSwitch
|
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
|
||||||
fun actionProfileSwitchPercentInjector(): ActionProfileSwitchPercent
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun actionSendSMSInjector(): ActionSendSMS
|
|
||||||
@ContributesAndroidInjector fun actionStartTempTargetInjector(): ActionStartTempTarget
|
|
||||||
@ContributesAndroidInjector fun actionStopTempTargetInjector(): ActionStopTempTarget
|
|
||||||
@ContributesAndroidInjector fun actionDummyInjector(): ActionDummy
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun elementInjector(): Element
|
|
||||||
@ContributesAndroidInjector fun inputBgInjector(): InputBg
|
|
||||||
@ContributesAndroidInjector fun inputButtonInjector(): InputButton
|
|
||||||
@ContributesAndroidInjector fun comparatorInjector(): Comparator
|
|
||||||
@ContributesAndroidInjector fun comparatorConnectInjector(): ComparatorConnect
|
|
||||||
@ContributesAndroidInjector fun comparatorExistsInjector(): ComparatorExists
|
|
||||||
@ContributesAndroidInjector fun inputDateTimeInjector(): InputDateTime
|
|
||||||
@ContributesAndroidInjector fun inputDeltaInjector(): InputDelta
|
|
||||||
@ContributesAndroidInjector fun inputDoubleInjector(): InputDouble
|
|
||||||
@ContributesAndroidInjector fun inputDropdownMenuInjector(): InputDropdownMenu
|
|
||||||
@ContributesAndroidInjector fun inputDurationInjector(): InputDuration
|
|
||||||
@ContributesAndroidInjector fun inputInsulinInjector(): InputInsulin
|
|
||||||
@ContributesAndroidInjector fun inputLocationModeInjector(): InputLocationMode
|
|
||||||
@ContributesAndroidInjector fun inputPercentInjector(): InputPercent
|
|
||||||
@ContributesAndroidInjector fun inputProfileNameInjector(): InputProfileName
|
|
||||||
@ContributesAndroidInjector fun inputStringInjector(): InputString
|
|
||||||
@ContributesAndroidInjector fun inputTempTargetInjector(): InputTempTarget
|
|
||||||
@ContributesAndroidInjector fun inputTimeRangeInjector(): InputTimeRange
|
|
||||||
@ContributesAndroidInjector fun inputTimeInjector(): InputTime
|
|
||||||
@ContributesAndroidInjector fun inputWeekDayInjector(): InputWeekDay
|
|
||||||
@ContributesAndroidInjector fun labelWithElementInjector(): LabelWithElement
|
|
||||||
@ContributesAndroidInjector fun staticLabelInjector(): StaticLabel
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun autosensDataInjector(): AutosensData
|
|
||||||
@ContributesAndroidInjector fun iobCobThreadInjector(): IobCobThread
|
|
||||||
@ContributesAndroidInjector fun iobCobOref1ThreadInjector(): IobCobOref1Thread
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun bgReadingInjector(): BgReading
|
|
||||||
@ContributesAndroidInjector fun treatmentInjector(): Treatment
|
|
||||||
@ContributesAndroidInjector fun profileSwitchInjector(): ProfileSwitch
|
|
||||||
@ContributesAndroidInjector fun temporaryBasalInjector(): TemporaryBasal
|
|
||||||
@ContributesAndroidInjector fun careportalEventInjector(): CareportalEvent
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun notificationWithActionInjector(): NotificationWithAction
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun loggerCallbackInjector(): LoggerCallback
|
|
||||||
@ContributesAndroidInjector fun loggerBolusWizard(): BolusWizard
|
|
||||||
@ContributesAndroidInjector fun loggerQuickWizardEntry(): QuickWizardEntry
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun authRequestInjector(): AuthRequest
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun swBreakInjector(): SWBreak
|
|
||||||
@ContributesAndroidInjector fun swButtonInjector(): SWButton
|
|
||||||
@ContributesAndroidInjector fun swEditNumberWithUnitsInjector(): SWEditNumberWithUnits
|
|
||||||
@ContributesAndroidInjector fun swEditStringInjector(): SWEditString
|
|
||||||
@ContributesAndroidInjector fun swEditEncryptedPasswordInjector(): SWEditEncryptedPassword
|
|
||||||
@ContributesAndroidInjector fun swEditUrlInjector(): SWEditUrl
|
|
||||||
@ContributesAndroidInjector fun swFragmentInjector(): SWFragment
|
|
||||||
@ContributesAndroidInjector fun swHtmlLinkInjector(): SWHtmlLink
|
|
||||||
@ContributesAndroidInjector fun swInfotextInjector(): SWInfotext
|
|
||||||
@ContributesAndroidInjector fun swItemInjector(): SWItem
|
|
||||||
@ContributesAndroidInjector fun swPluginInjector(): SWPlugin
|
|
||||||
@ContributesAndroidInjector fun swRadioButtonInjector(): SWRadioButton
|
|
||||||
@ContributesAndroidInjector fun swScreenInjector(): SWScreen
|
|
||||||
@ContributesAndroidInjector fun swEventListenerInjector(): SWEventListener
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun profileInjector(): Profile
|
|
||||||
@ContributesAndroidInjector fun glucoseStatusInjector(): GlucoseStatus
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun graphDataInjector(): GraphData
|
|
||||||
|
|
||||||
@ContributesAndroidInjector fun cryptoUtilInjector(): CryptoUtil
|
|
||||||
@ContributesAndroidInjector fun importExportPrefsInjector(): ImportExportPrefs
|
|
||||||
@ContributesAndroidInjector fun encryptedPrefsFormatInjector(): EncryptedPrefsFormat
|
|
||||||
@ContributesAndroidInjector fun classicPrefsFormatInjector(): ClassicPrefsFormat
|
|
||||||
|
|
||||||
@Binds fun bindContext(mainApp: MainApp): Context
|
@Binds fun bindContext(mainApp: MainApp): Context
|
||||||
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
|
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
|
||||||
|
|
||||||
// Medtronic
|
|
||||||
@ContributesAndroidInjector fun rileyLinkCommunicationManagerProvider(): RileyLinkCommunicationManager
|
|
||||||
@ContributesAndroidInjector fun medtronicCommunicationManagerProvider(): MedtronicCommunicationManager
|
|
||||||
@ContributesAndroidInjector fun medtronicUITaskProvider(): MedtronicUITask
|
|
||||||
@ContributesAndroidInjector fun serviceTaskProvider(): ServiceTask
|
|
||||||
@ContributesAndroidInjector fun pumpTaskProvider(): PumpTask
|
|
||||||
@ContributesAndroidInjector fun discoverGattServicesTaskProvider(): DiscoverGattServicesTask
|
|
||||||
@ContributesAndroidInjector fun initializePumpManagerTaskProvider(): InitializePumpManagerTask
|
|
||||||
@ContributesAndroidInjector fun resetRileyLinkConfigurationTaskProvider(): ResetRileyLinkConfigurationTask
|
|
||||||
@ContributesAndroidInjector fun wakeAndTuneTaskProvider(): WakeAndTuneTask
|
|
||||||
@ContributesAndroidInjector fun radioResponseProvider(): RadioResponse
|
|
||||||
@ContributesAndroidInjector fun rileyLinkBLEProvider(): RileyLinkBLE
|
|
||||||
@ContributesAndroidInjector fun rfSpyProvider(): RFSpy
|
|
||||||
@ContributesAndroidInjector fun sendAndListenProvider(): SendAndListen
|
|
||||||
@ContributesAndroidInjector fun setPreambleProvider(): SetPreamble
|
|
||||||
@ContributesAndroidInjector fun radioPacketProvider(): RadioPacket
|
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
|
fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.AutomationEvent
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.actions.*
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.elements.*
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.triggers.*
|
||||||
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
|
import info.nightscout.androidaps.queue.commands.*
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class AutomationModule {
|
||||||
|
@ContributesAndroidInjector abstract fun automationEventInjector(): AutomationEvent
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun triggerInjector(): Trigger
|
||||||
|
@ContributesAndroidInjector abstract fun triggerAutosensValueInjector(): TriggerAutosensValue
|
||||||
|
@ContributesAndroidInjector abstract fun triggerBgInjector(): TriggerBg
|
||||||
|
@ContributesAndroidInjector abstract fun triggerBolusAgoInjector(): TriggerBolusAgo
|
||||||
|
@ContributesAndroidInjector abstract fun triggerCOBInjector(): TriggerCOB
|
||||||
|
@ContributesAndroidInjector abstract fun triggerConnectorInjector(): TriggerConnector
|
||||||
|
@ContributesAndroidInjector abstract fun triggerDeltaInjector(): TriggerDelta
|
||||||
|
@ContributesAndroidInjector abstract fun triggerDummyInjector(): TriggerDummy
|
||||||
|
@ContributesAndroidInjector abstract fun triggerIobInjector(): TriggerIob
|
||||||
|
@ContributesAndroidInjector abstract fun triggerLocationInjector(): TriggerLocation
|
||||||
|
@ContributesAndroidInjector abstract fun triggerProfilePercentInjector(): TriggerProfilePercent
|
||||||
|
@ContributesAndroidInjector abstract fun triggerPumpLastConnectionInjector(): TriggerPumpLastConnection
|
||||||
|
@ContributesAndroidInjector abstract fun triggerBTDeviceInjector(): TriggerBTDevice
|
||||||
|
@ContributesAndroidInjector abstract fun triggerRecurringTimeInjector(): TriggerRecurringTime
|
||||||
|
@ContributesAndroidInjector abstract fun triggerTempTargetInjector(): TriggerTempTarget
|
||||||
|
@ContributesAndroidInjector abstract fun triggerTime(): TriggerTime
|
||||||
|
@ContributesAndroidInjector abstract fun triggerTimeRangeInjector(): TriggerTimeRange
|
||||||
|
@ContributesAndroidInjector abstract fun triggerWifiSsidInjector(): TriggerWifiSsid
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun actionInjector(): Action
|
||||||
|
@ContributesAndroidInjector abstract fun actionLoopDisableInjector(): ActionLoopDisable
|
||||||
|
@ContributesAndroidInjector abstract fun actionLoopEnableInjector(): ActionLoopEnable
|
||||||
|
@ContributesAndroidInjector abstract fun actionLoopResumeInjector(): ActionLoopResume
|
||||||
|
@ContributesAndroidInjector abstract fun actionLoopSuspendInjector(): ActionLoopSuspend
|
||||||
|
@ContributesAndroidInjector abstract fun actionNotificationInjector(): ActionNotification
|
||||||
|
@ContributesAndroidInjector abstract fun actionProfileSwitchInjector(): ActionProfileSwitch
|
||||||
|
@ContributesAndroidInjector abstract fun actionProfileSwitchPercentInjector(): ActionProfileSwitchPercent
|
||||||
|
@ContributesAndroidInjector abstract fun actionSendSMSInjector(): ActionSendSMS
|
||||||
|
@ContributesAndroidInjector abstract fun actionStartTempTargetInjector(): ActionStartTempTarget
|
||||||
|
@ContributesAndroidInjector abstract fun actionStopTempTargetInjector(): ActionStopTempTarget
|
||||||
|
@ContributesAndroidInjector abstract fun actionDummyInjector(): ActionDummy
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun elementInjector(): Element
|
||||||
|
@ContributesAndroidInjector abstract fun inputBgInjector(): InputBg
|
||||||
|
@ContributesAndroidInjector abstract fun inputButtonInjector(): InputButton
|
||||||
|
@ContributesAndroidInjector abstract fun comparatorInjector(): Comparator
|
||||||
|
@ContributesAndroidInjector abstract fun comparatorConnectInjector(): ComparatorConnect
|
||||||
|
@ContributesAndroidInjector abstract fun comparatorExistsInjector(): ComparatorExists
|
||||||
|
@ContributesAndroidInjector abstract fun inputDateTimeInjector(): InputDateTime
|
||||||
|
@ContributesAndroidInjector abstract fun inputDeltaInjector(): InputDelta
|
||||||
|
@ContributesAndroidInjector abstract fun inputDoubleInjector(): InputDouble
|
||||||
|
@ContributesAndroidInjector abstract fun inputDropdownMenuInjector(): InputDropdownMenu
|
||||||
|
@ContributesAndroidInjector abstract fun inputDurationInjector(): InputDuration
|
||||||
|
@ContributesAndroidInjector abstract fun inputInsulinInjector(): InputInsulin
|
||||||
|
@ContributesAndroidInjector abstract fun inputLocationModeInjector(): InputLocationMode
|
||||||
|
@ContributesAndroidInjector abstract fun inputPercentInjector(): InputPercent
|
||||||
|
@ContributesAndroidInjector abstract fun inputProfileNameInjector(): InputProfileName
|
||||||
|
@ContributesAndroidInjector abstract fun inputStringInjector(): InputString
|
||||||
|
@ContributesAndroidInjector abstract fun inputTempTargetInjector(): InputTempTarget
|
||||||
|
@ContributesAndroidInjector abstract fun inputTimeRangeInjector(): InputTimeRange
|
||||||
|
@ContributesAndroidInjector abstract fun inputTimeInjector(): InputTime
|
||||||
|
@ContributesAndroidInjector abstract fun inputWeekDayInjector(): InputWeekDay
|
||||||
|
@ContributesAndroidInjector abstract fun labelWithElementInjector(): LabelWithElement
|
||||||
|
@ContributesAndroidInjector abstract fun staticLabelInjector(): StaticLabel
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
|
import info.nightscout.androidaps.queue.commands.*
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class CommandQueueModule {
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun pumpEnactResultInjector(): PumpEnactResult
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun commandQueueInjector(): CommandQueue
|
||||||
|
@ContributesAndroidInjector abstract fun commandBolusInjector(): CommandBolus
|
||||||
|
@ContributesAndroidInjector abstract fun commandCancelExtendedBolusInjector(): CommandCancelExtendedBolus
|
||||||
|
@ContributesAndroidInjector abstract fun commandCancelTempBasalInjector(): CommandCancelTempBasal
|
||||||
|
@ContributesAndroidInjector abstract fun commandExtendedBolusInjector(): CommandExtendedBolus
|
||||||
|
@ContributesAndroidInjector abstract fun commandInsightSetTBROverNotificationInjector(): CommandInsightSetTBROverNotification
|
||||||
|
@ContributesAndroidInjector abstract fun commandLoadEventsInjector(): CommandLoadEvents
|
||||||
|
@ContributesAndroidInjector abstract fun commandLoadHistoryInjector(): CommandLoadHistory
|
||||||
|
@ContributesAndroidInjector abstract fun commandLoadTDDsInjector(): CommandLoadTDDs
|
||||||
|
@ContributesAndroidInjector abstract fun commandReadStatusInjector(): CommandReadStatus
|
||||||
|
@ContributesAndroidInjector abstract fun commandSetProfileInjector(): CommandSetProfile
|
||||||
|
@ContributesAndroidInjector abstract fun commandCommandSMBBolusInjector(): CommandSMBBolus
|
||||||
|
@ContributesAndroidInjector abstract fun commandStartPumpInjector(): CommandStartPump
|
||||||
|
@ContributesAndroidInjector abstract fun commandStopPumpInjector(): CommandStopPump
|
||||||
|
@ContributesAndroidInjector abstract fun commandTempBasalAbsoluteInjector(): CommandTempBasalAbsolute
|
||||||
|
@ContributesAndroidInjector abstract fun commandTempBasalPercentInjector(): CommandTempBasalPercent
|
||||||
|
@ContributesAndroidInjector abstract fun commandSetUserSettingsInjector(): CommandSetUserSettings
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.Profile
|
||||||
|
import info.nightscout.androidaps.data.ProfileStore
|
||||||
|
import info.nightscout.androidaps.db.BgReading
|
||||||
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
|
import info.nightscout.androidaps.db.ExtendedBolus
|
||||||
|
import info.nightscout.androidaps.db.ProfileSwitch
|
||||||
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.TreatmentService
|
||||||
|
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
||||||
|
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class DataClassesModule {
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun profileInjector(): Profile
|
||||||
|
@ContributesAndroidInjector abstract fun glucoseStatusInjector(): GlucoseStatus
|
||||||
|
@ContributesAndroidInjector abstract fun profileStoreInjector(): ProfileStore
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun bgReadingInjector(): BgReading
|
||||||
|
@ContributesAndroidInjector abstract fun treatmentInjector(): Treatment
|
||||||
|
@ContributesAndroidInjector abstract fun profileSwitchInjector(): ProfileSwitch
|
||||||
|
@ContributesAndroidInjector abstract fun temporaryBasalInjector(): TemporaryBasal
|
||||||
|
@ContributesAndroidInjector abstract fun careportalEventInjector(): CareportalEvent
|
||||||
|
@ContributesAndroidInjector abstract fun extendedBolusInjector(): ExtendedBolus
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun treatmentServiceInjector(): TreatmentService
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun bolusWizardInjector(): BolusWizard
|
||||||
|
@ContributesAndroidInjector abstract fun quickWizardEntryInjector(): QuickWizardEntry
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.AutomationEvent
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.actions.*
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.elements.*
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.triggers.*
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SendAndListen
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SetPreamble
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioPacket
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.*
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
|
||||||
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
|
import info.nightscout.androidaps.queue.commands.*
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class MedtronicModule {
|
||||||
|
@ContributesAndroidInjector abstract fun rileyLinkCommunicationManagerProvider(): RileyLinkCommunicationManager
|
||||||
|
@ContributesAndroidInjector abstract fun medtronicCommunicationManagerProvider(): MedtronicCommunicationManager
|
||||||
|
@ContributesAndroidInjector abstract fun medtronicUITaskProvider(): MedtronicUITask
|
||||||
|
@ContributesAndroidInjector abstract fun serviceTaskProvider(): ServiceTask
|
||||||
|
@ContributesAndroidInjector abstract fun pumpTaskProvider(): PumpTask
|
||||||
|
@ContributesAndroidInjector abstract fun discoverGattServicesTaskProvider(): DiscoverGattServicesTask
|
||||||
|
@ContributesAndroidInjector abstract fun initializePumpManagerTaskProvider(): InitializePumpManagerTask
|
||||||
|
@ContributesAndroidInjector abstract fun resetRileyLinkConfigurationTaskProvider(): ResetRileyLinkConfigurationTask
|
||||||
|
@ContributesAndroidInjector abstract fun wakeAndTuneTaskProvider(): WakeAndTuneTask
|
||||||
|
@ContributesAndroidInjector abstract fun radioResponseProvider(): RadioResponse
|
||||||
|
@ContributesAndroidInjector abstract fun rileyLinkBLEProvider(): RileyLinkBLE
|
||||||
|
@ContributesAndroidInjector abstract fun rfSpyProvider(): RFSpy
|
||||||
|
@ContributesAndroidInjector abstract fun sendAndListenProvider(): SendAndListen
|
||||||
|
@ContributesAndroidInjector abstract fun setPreambleProvider(): SetPreamble
|
||||||
|
@ContributesAndroidInjector abstract fun radioPacketProvider(): RadioPacket
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class ObjectivesModule {
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun objectiveInjector(): Objective
|
||||||
|
@ContributesAndroidInjector abstract fun objective0Injector(): Objective0
|
||||||
|
@ContributesAndroidInjector abstract fun objective1Injector(): Objective1
|
||||||
|
@ContributesAndroidInjector abstract fun objective2Injector(): Objective2
|
||||||
|
@ContributesAndroidInjector abstract fun objective3Injector(): Objective3
|
||||||
|
@ContributesAndroidInjector abstract fun objective4Injector(): Objective4
|
||||||
|
@ContributesAndroidInjector abstract fun objective5Injector(): Objective5
|
||||||
|
@ContributesAndroidInjector abstract fun objective6Injector(): Objective6
|
||||||
|
@ContributesAndroidInjector abstract fun objective7Injector(): Objective7
|
||||||
|
@ContributesAndroidInjector abstract fun objective8Injector(): Objective8
|
||||||
|
@ContributesAndroidInjector abstract fun objective9Injector(): Objective9
|
||||||
|
@ContributesAndroidInjector abstract fun objective10Injector(): Objective10
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.plugins.aps.loop.APSResult
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
|
||||||
|
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class OverviewModule {
|
||||||
|
@ContributesAndroidInjector abstract fun notificationWithActionInjector(): NotificationWithAction
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun graphDataInjector(): GraphData
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.ClassicPrefsFormat
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
||||||
|
import info.nightscout.androidaps.utils.CryptoUtil
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class PreferencesModule {
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun cryptoUtilInjector(): CryptoUtil
|
||||||
|
@ContributesAndroidInjector abstract fun importExportPrefsInjector(): ImportExportPrefs
|
||||||
|
@ContributesAndroidInjector abstract fun encryptedPrefsFormatInjector(): EncryptedPrefsFormat
|
||||||
|
@ContributesAndroidInjector abstract fun classicPrefsFormatInjector(): ClassicPrefsFormat
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.AuthRequest
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class SMSModule {
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun authRequestInjector(): AuthRequest
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.setupwizard.SWEventListener
|
||||||
|
import info.nightscout.androidaps.setupwizard.SWScreen
|
||||||
|
import info.nightscout.androidaps.setupwizard.elements.*
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class WizardModule {
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun swBreakInjector(): SWBreak
|
||||||
|
@ContributesAndroidInjector abstract fun swButtonInjector(): SWButton
|
||||||
|
@ContributesAndroidInjector abstract fun swEditNumberWithUnitsInjector(): SWEditNumberWithUnits
|
||||||
|
@ContributesAndroidInjector abstract fun swEditStringInjector(): SWEditString
|
||||||
|
@ContributesAndroidInjector abstract fun swEditEncryptedPasswordInjector(): SWEditEncryptedPassword
|
||||||
|
@ContributesAndroidInjector abstract fun swEditUrlInjector(): SWEditUrl
|
||||||
|
@ContributesAndroidInjector abstract fun swFragmentInjector(): SWFragment
|
||||||
|
@ContributesAndroidInjector abstract fun swHtmlLinkInjector(): SWHtmlLink
|
||||||
|
@ContributesAndroidInjector abstract fun swInfotextInjector(): SWInfotext
|
||||||
|
@ContributesAndroidInjector abstract fun swItemInjector(): SWItem
|
||||||
|
@ContributesAndroidInjector abstract fun swPluginInjector(): SWPlugin
|
||||||
|
@ContributesAndroidInjector abstract fun swRadioButtonInjector(): SWRadioButton
|
||||||
|
@ContributesAndroidInjector abstract fun swScreenInjector(): SWScreen
|
||||||
|
@ContributesAndroidInjector abstract fun swEventListenerInjector(): SWEventListener
|
||||||
|
}
|
|
@ -68,6 +68,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
import info.nightscout.androidaps.utils.HardLimits;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
@ -88,6 +89,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
private final ReceiverStatusStore receiverStatusStore;
|
private final ReceiverStatusStore receiverStatusStore;
|
||||||
private final FabricPrivacy fabricPrivacy;
|
private final FabricPrivacy fabricPrivacy;
|
||||||
|
private final HardLimits hardLimits;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -132,7 +134,8 @@ public class LoopPlugin extends PluginBase {
|
||||||
Lazy<ActionStringHandler> actionStringHandler, // TODO Adrian use RxBus instead of Lazy
|
Lazy<ActionStringHandler> actionStringHandler, // TODO Adrian use RxBus instead of Lazy
|
||||||
IobCobCalculatorPlugin iobCobCalculatorPlugin,
|
IobCobCalculatorPlugin iobCobCalculatorPlugin,
|
||||||
ReceiverStatusStore receiverStatusStore,
|
ReceiverStatusStore receiverStatusStore,
|
||||||
FabricPrivacy fabricPrivacy
|
FabricPrivacy fabricPrivacy,
|
||||||
|
HardLimits hardLimits
|
||||||
) {
|
) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.LOOP)
|
.mainType(PluginType.LOOP)
|
||||||
|
@ -158,6 +161,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
||||||
this.receiverStatusStore = receiverStatusStore;
|
this.receiverStatusStore = receiverStatusStore;
|
||||||
this.fabricPrivacy = fabricPrivacy;
|
this.fabricPrivacy = fabricPrivacy;
|
||||||
|
this.hardLimits = hardLimits;
|
||||||
|
|
||||||
loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
||||||
isSuperBolus = sp.getBoolean("isSuperBolus", false);
|
isSuperBolus = sp.getBoolean("isSuperBolus", false);
|
||||||
|
@ -288,6 +292,21 @@ public class LoopPlugin extends PluginBase {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLGS(){
|
||||||
|
Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed();
|
||||||
|
Double MaxIOBallowed = constraintChecker.getMaxIOBAllowed().value();
|
||||||
|
String APSmode = sp.getString(R.string.key_aps_mode, "open");
|
||||||
|
PumpInterface pump = activePlugin.getActivePump();
|
||||||
|
boolean isLGS = false;
|
||||||
|
|
||||||
|
if (!isSuspended() && !pump.isSuspended())
|
||||||
|
if (closedLoopEnabled.value())
|
||||||
|
if ((MaxIOBallowed.equals(hardLimits.getMAXIOB_LGS())) || (APSmode.equals("lgs")))
|
||||||
|
isLGS = true;
|
||||||
|
|
||||||
|
return isLGS;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSuperBolus() {
|
public boolean isSuperBolus() {
|
||||||
if (loopSuspendedTill == 0)
|
if (loopSuspendedTill == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -12,21 +12,6 @@ class PluginStore @Inject constructor(
|
||||||
val aapsLogger: AAPSLogger
|
val aapsLogger: AAPSLogger
|
||||||
) : ActivePluginProvider {
|
) : ActivePluginProvider {
|
||||||
|
|
||||||
// TODO remove
|
|
||||||
init {
|
|
||||||
pluginStore = this
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
var pluginStore: PluginStore? = null
|
|
||||||
|
|
||||||
@Deprecated("Use dagger instead")
|
|
||||||
fun getInstance(): PluginStore {
|
|
||||||
checkNotNull(pluginStore) { "Accessing PluginStore before first instantiation" }
|
|
||||||
return pluginStore!!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lateinit var plugins: List<@JvmSuppressWildcards PluginBase>
|
lateinit var plugins: List<@JvmSuppressWildcards PluginBase>
|
||||||
|
|
||||||
private var activeBgSource: BgSourceInterface? = null
|
private var activeBgSource: BgSourceInterface? = null
|
||||||
|
@ -165,8 +150,7 @@ class PluginStore @Inject constructor(
|
||||||
* @return
|
* @return
|
||||||
</T> */
|
</T> */
|
||||||
private fun <T> determineActivePlugin(pluginInterface: Class<T>, pluginType: PluginType): T? {
|
private fun <T> determineActivePlugin(pluginInterface: Class<T>, pluginType: PluginType): T? {
|
||||||
val pluginsInCategory: ArrayList<PluginBase>
|
val pluginsInCategory: ArrayList<PluginBase> = getSpecificPluginsListByInterface(pluginInterface)
|
||||||
pluginsInCategory = pluginStore!!.getSpecificPluginsListByInterface(pluginInterface)
|
|
||||||
return determineActivePlugin(pluginsInCategory, pluginType)
|
return determineActivePlugin(pluginsInCategory, pluginType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
@NonNull @Override
|
@NonNull @Override
|
||||||
public Constraint<Boolean> isClosedLoopAllowed(@NonNull Constraint<Boolean> value) {
|
public Constraint<Boolean> isClosedLoopAllowed(@NonNull Constraint<Boolean> value) {
|
||||||
String mode = sp.getString(R.string.key_aps_mode, "open");
|
String mode = sp.getString(R.string.key_aps_mode, "open");
|
||||||
if (!mode.equals("closed"))
|
if ((mode.equals("open")))
|
||||||
value.set(getAapsLogger(), false, getResourceHelper().gs(R.string.closedmodedisabledinpreferences), this);
|
value.set(getAapsLogger(), false, getResourceHelper().gs(R.string.closedmodedisabledinpreferences), this);
|
||||||
|
|
||||||
if (!buildHelper.isEngineeringModeOrRelease()) {
|
if (!buildHelper.isEngineeringModeOrRelease()) {
|
||||||
|
@ -266,6 +266,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
@NonNull @Override
|
@NonNull @Override
|
||||||
public Constraint<Double> applyMaxIOBConstraints(@NonNull Constraint<Double> maxIob) {
|
public Constraint<Double> applyMaxIOBConstraints(@NonNull Constraint<Double> maxIob) {
|
||||||
double maxIobPref;
|
double maxIobPref;
|
||||||
|
String apsmode = sp.getString(R.string.key_aps_mode, "open");
|
||||||
if (openAPSSMBPlugin.isEnabled(PluginType.APS))
|
if (openAPSSMBPlugin.isEnabled(PluginType.APS))
|
||||||
maxIobPref = sp.getDouble(R.string.key_openapssmb_max_iob, 3d);
|
maxIobPref = sp.getDouble(R.string.key_openapssmb_max_iob, 3d);
|
||||||
else
|
else
|
||||||
|
@ -276,6 +277,9 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
maxIob.setIfSmaller(getAapsLogger(), hardLimits.maxIobAMA(), String.format(getResourceHelper().gs(R.string.limitingiob), hardLimits.maxIobAMA(), getResourceHelper().gs(R.string.hardlimit)), this);
|
maxIob.setIfSmaller(getAapsLogger(), hardLimits.maxIobAMA(), String.format(getResourceHelper().gs(R.string.limitingiob), hardLimits.maxIobAMA(), getResourceHelper().gs(R.string.hardlimit)), this);
|
||||||
if (openAPSSMBPlugin.isEnabled(PluginType.APS))
|
if (openAPSSMBPlugin.isEnabled(PluginType.APS))
|
||||||
maxIob.setIfSmaller(getAapsLogger(), hardLimits.maxIobSMB(), String.format(getResourceHelper().gs(R.string.limitingiob), hardLimits.maxIobSMB(), getResourceHelper().gs(R.string.hardlimit)), this);
|
maxIob.setIfSmaller(getAapsLogger(), hardLimits.maxIobSMB(), String.format(getResourceHelper().gs(R.string.limitingiob), hardLimits.maxIobSMB(), getResourceHelper().gs(R.string.hardlimit)), this);
|
||||||
|
if ((apsmode.equals("lgs")))
|
||||||
|
maxIob.setIfSmaller(getAapsLogger(), hardLimits.getMAXIOB_LGS(), String.format(getResourceHelper().gs(R.string.limitingiob), hardLimits.getMAXIOB_LGS(), getResourceHelper().gs(R.string.lowglucosesuspend)), this);
|
||||||
|
|
||||||
return maxIob;
|
return maxIob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.starttemptarget
|
override fun friendlyName(): Int = R.string.starttemptarget
|
||||||
override fun shortDescription(): String = resourceHelper.gs(R.string.starttemptarget) + ": " + tt().friendlyDescription(value.units)
|
override fun shortDescription(): String = resourceHelper.gs(R.string.starttemptarget) + ": " + tt().friendlyDescription(value.units, resourceHelper)
|
||||||
@DrawableRes override fun icon(): Int = R.drawable.icon_cp_cgm_target
|
@DrawableRes override fun icon(): Int = R.drawable.icon_cp_cgm_target
|
||||||
|
|
||||||
override fun doAction(callback: Callback) {
|
override fun doAction(callback: Callback) {
|
||||||
|
|
|
@ -622,8 +622,17 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
|
|
||||||
loopPlugin.isEnabled(PluginType.LOOP) -> {
|
loopPlugin.isEnabled(PluginType.LOOP) -> {
|
||||||
overview_apsmode?.text = if (closedLoopEnabled.value()) resourceHelper.gs(R.string.closedloop) else resourceHelper.gs(R.string.openloop)
|
val isLGS = loopPlugin.isLGS
|
||||||
overview_apsmode?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
|
overview_apsmode?.text =
|
||||||
|
if (closedLoopEnabled.value())
|
||||||
|
if (isLGS)
|
||||||
|
resourceHelper.gs(R.string.lgs)
|
||||||
|
else
|
||||||
|
resourceHelper.gs(R.string.closedloop)
|
||||||
|
else
|
||||||
|
resourceHelper.gs(R.string.openloop)
|
||||||
|
|
||||||
|
overview_apsmode?.setBackgroundColor(if (isLGS) resourceHelper.gc(R.color.ribbonUnusual) else resourceHelper.gc(R.color.ribbonDefault))
|
||||||
overview_apsmode?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
|
overview_apsmode?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,17 +28,17 @@ class StatusLightHandler @Inject constructor(
|
||||||
*/
|
*/
|
||||||
fun updateStatusLights(careportal_canulaage: TextView?, careportal_insulinage: TextView?, careportal_reservoirlevel: TextView?, careportal_sensorage: TextView?, careportal_pbage: TextView?, careportal_batterylevel: TextView?) {
|
fun updateStatusLights(careportal_canulaage: TextView?, careportal_insulinage: TextView?, careportal_reservoirlevel: TextView?, careportal_sensorage: TextView?, careportal_pbage: TextView?, careportal_batterylevel: TextView?) {
|
||||||
val pump = activePlugin.activePump
|
val pump = activePlugin.activePump
|
||||||
handleAge(careportal_canulaage, "cage", CareportalEvent.SITECHANGE, R.string.key_statuslights_cage_warning, 48.0, R.string.key_statuslights_cage_critical, 72.0)
|
handleAge(careportal_canulaage, CareportalEvent.SITECHANGE, R.string.key_statuslights_cage_warning, 48.0, R.string.key_statuslights_cage_critical, 72.0)
|
||||||
handleAge(careportal_insulinage, "iage", CareportalEvent.INSULINCHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0)
|
handleAge(careportal_insulinage, CareportalEvent.INSULINCHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0)
|
||||||
handleAge(careportal_sensorage, "sage", CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
|
handleAge(careportal_sensorage, CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
|
||||||
handleAge(careportal_pbage, "bage", CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)
|
handleAge(careportal_pbage, CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)
|
||||||
if (!Config.NSCLIENT)
|
if (!Config.NSCLIENT)
|
||||||
handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel)
|
handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U")
|
||||||
if (!Config.NSCLIENT && pump.model() != PumpType.AccuChekCombo)
|
if (!Config.NSCLIENT && pump.model() != PumpType.AccuChekCombo)
|
||||||
handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble())
|
handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleAge(view: TextView?, nsSettingPlugin: String, eventName: String, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) {
|
private fun handleAge(view: TextView?, eventName: String, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) {
|
||||||
val warn = sp.getDouble(warnSettings, defaultWarnThreshold)
|
val warn = sp.getDouble(warnSettings, defaultWarnThreshold)
|
||||||
val urgent = sp.getDouble(urgentSettings, defaultUrgentThreshold)
|
val urgent = sp.getDouble(urgentSettings, defaultUrgentThreshold)
|
||||||
val careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(eventName)
|
val careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(eventName)
|
||||||
|
@ -50,11 +50,11 @@ class StatusLightHandler @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double) {
|
private fun handleLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double, units: String) {
|
||||||
val resUrgent = sp.getDouble(criticalSetting, criticalDefaultValue)
|
val resUrgent = sp.getDouble(criticalSetting, criticalDefaultValue)
|
||||||
val resWarn = sp.getDouble(warnSetting, warnDefaultValue)
|
val resWarn = sp.getDouble(warnSetting, warnDefaultValue)
|
||||||
@Suppress("SetTextI18n")
|
@Suppress("SetTextI18n")
|
||||||
view?.text = " " + DecimalFormatter.to0Decimal(level)
|
view?.text = " " + DecimalFormatter.to0Decimal(level) + units
|
||||||
warnColors.setColorInverse(view, level, resWarn, resUrgent)
|
warnColors.setColorInverse(view, level, resWarn, resUrgent)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,12 +4,12 @@ import android.app.Service
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import dagger.android.DaggerService
|
import dagger.android.DaggerService
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.events.EventAppExit
|
import info.nightscout.androidaps.events.EventAppExit
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -21,8 +21,8 @@ class DummyService : DaggerService() {
|
||||||
|
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var mainApp: MainApp
|
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@Inject lateinit var notificationHolder: NotificationHolder
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ class DummyService : DaggerService() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
// TODO: I guess this was moved here in order to adhere to the 5 seconds rule to call "startForeground" after a Service was called as Foreground service?
|
// TODO: I guess this was moved here in order to adhere to the 5 seconds rule to call "startForeground" after a Service was called as Foreground service?
|
||||||
// As onCreate() is not called every time a service is started, copied to onStartCommand().
|
// As onCreate() is not called every time a service is started, copied to onStartCommand().
|
||||||
startForeground(mainApp.notificationId(), mainApp.notification)
|
startForeground(notificationHolder.notificationID, notificationHolder.notification)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAppExit::class.java)
|
.toObservable(EventAppExit::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe({
|
.subscribe({
|
||||||
aapsLogger.debug(LTag.CORE, "EventAppExit received")
|
aapsLogger.debug(LTag.CORE, "EventAppExit received")
|
||||||
stopSelf()
|
stopSelf()
|
||||||
}) { fabricPrivacy.logException(it) }
|
}) { fabricPrivacy::logException }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class DummyService : DaggerService() {
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||||
super.onStartCommand(intent, flags, startId)
|
super.onStartCommand(intent, flags, startId)
|
||||||
startForeground(mainApp.notificationId(), mainApp.notification)
|
startForeground(notificationHolder.notificationID, notificationHolder.notification)
|
||||||
return Service.START_STICKY
|
return Service.START_STICKY
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,6 @@ import androidx.core.app.TaskStackBuilder
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.MainActivity
|
import info.nightscout.androidaps.MainActivity
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.events.*
|
import info.nightscout.androidaps.events.*
|
||||||
|
@ -28,6 +27,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorP
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
@ -45,7 +45,7 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
private var iobCobCalculatorPlugin: IobCobCalculatorPlugin,
|
private var iobCobCalculatorPlugin: IobCobCalculatorPlugin,
|
||||||
private var rxBus: RxBusWrapper,
|
private var rxBus: RxBusWrapper,
|
||||||
private var context: Context,
|
private var context: Context,
|
||||||
private var mainApp: MainApp
|
private var notificationHolder: NotificationHolder
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
|
@ -109,7 +109,7 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
private fun createNotificationChannel() {
|
private fun createNotificationChannel() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
val mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
val channel = NotificationChannel(mainApp.channelId(), mainApp.channelId() as CharSequence, NotificationManager.IMPORTANCE_HIGH)
|
val channel = NotificationChannel(notificationHolder.channelID, notificationHolder.channelID as CharSequence, NotificationManager.IMPORTANCE_HIGH)
|
||||||
mNotificationManager.createNotificationChannel(channel)
|
mNotificationManager.createNotificationChannel(channel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,20 +176,20 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
val msgReadIntent = Intent()
|
val msgReadIntent = Intent()
|
||||||
.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
|
.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
|
||||||
.setAction(READ_ACTION)
|
.setAction(READ_ACTION)
|
||||||
.putExtra(CONVERSATION_ID, mainApp.notificationId())
|
.putExtra(CONVERSATION_ID, notificationHolder.notificationID)
|
||||||
.setPackage(PACKAGE)
|
.setPackage(PACKAGE)
|
||||||
val msgReadPendingIntent = PendingIntent.getBroadcast(context,
|
val msgReadPendingIntent = PendingIntent.getBroadcast(context,
|
||||||
mainApp.notificationId(),
|
notificationHolder.notificationID,
|
||||||
msgReadIntent,
|
msgReadIntent,
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT)
|
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
val msgReplyIntent = Intent()
|
val msgReplyIntent = Intent()
|
||||||
.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
|
.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
|
||||||
.setAction(REPLY_ACTION)
|
.setAction(REPLY_ACTION)
|
||||||
.putExtra(CONVERSATION_ID, mainApp.notificationId())
|
.putExtra(CONVERSATION_ID, notificationHolder.notificationID)
|
||||||
.setPackage(PACKAGE)
|
.setPackage(PACKAGE)
|
||||||
val msgReplyPendingIntent = PendingIntent.getBroadcast(
|
val msgReplyPendingIntent = PendingIntent.getBroadcast(
|
||||||
context,
|
context,
|
||||||
mainApp.notificationId(),
|
notificationHolder.notificationID,
|
||||||
msgReplyIntent,
|
msgReplyIntent,
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT)
|
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
// Build a RemoteInput for receiving voice input from devices
|
// Build a RemoteInput for receiving voice input from devices
|
||||||
|
@ -205,7 +205,7 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
} else {
|
} else {
|
||||||
line1 = resourceHelper.gs(R.string.noprofileset)
|
line1 = resourceHelper.gs(R.string.noprofileset)
|
||||||
}
|
}
|
||||||
val builder = NotificationCompat.Builder(context, mainApp.channelId())
|
val builder = NotificationCompat.Builder(context, notificationHolder.channelID)
|
||||||
builder.setOngoing(true)
|
builder.setOngoing(true)
|
||||||
builder.setOnlyAlertOnce(true)
|
builder.setOnlyAlertOnce(true)
|
||||||
builder.setCategory(NotificationCompat.CATEGORY_STATUS)
|
builder.setCategory(NotificationCompat.CATEGORY_STATUS)
|
||||||
|
@ -231,7 +231,7 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
builder.setContentIntent(resultPendingIntent)
|
builder.setContentIntent(resultPendingIntent)
|
||||||
val mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
val notification = builder.build()
|
val notification = builder.build()
|
||||||
mNotificationManager.notify(mainApp.notificationId(), notification)
|
mNotificationManager.notify(notificationHolder.notificationID, notification)
|
||||||
mainApp.notification = notification
|
notificationHolder.notification = notification
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -37,6 +37,7 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
|
||||||
@Inject ResourceHelper resourceHelper;
|
@Inject ResourceHelper resourceHelper;
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject RxBusWrapper rxBus;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -80,12 +81,12 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventComboPumpUpdateGUI.class)
|
.toObservable(EventComboPumpUpdateGUI.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(event -> updateGui(), exception -> FabricPrivacy.getInstance().logException(exception))
|
.subscribe(event -> updateGui(), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventQueueChanged.class)
|
.toObservable(EventQueueChanged.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(event -> updateGui(), exception -> FabricPrivacy.getInstance().logException(exception))
|
.subscribe(event -> updateGui(), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
updateGui();
|
updateGui();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class MessageHashTableR @Inject constructor(
|
||||||
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
||||||
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
||||||
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
||||||
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||||
put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
|
put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
|
||||||
put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
|
put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
|
||||||
// 0x0301 CMD_PUMPINIT_TIME_INFO
|
// 0x0301 CMD_PUMPINIT_TIME_INFO
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus
|
import info.nightscout.androidaps.db.ExtendedBolus
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
@ -10,6 +11,7 @@ import info.nightscout.androidaps.utils.DateUtil
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
|
|
||||||
class MsgStatusBolusExtended(
|
class MsgStatusBolusExtended(
|
||||||
|
private val injector: HasAndroidInjector,
|
||||||
private val aapsLogger: AAPSLogger,
|
private val aapsLogger: AAPSLogger,
|
||||||
private val danaRPump: DanaRPump,
|
private val danaRPump: DanaRPump,
|
||||||
private val activePlugin: ActivePluginProvider
|
private val activePlugin: ActivePluginProvider
|
||||||
|
@ -60,11 +62,11 @@ class MsgStatusBolusExtended(
|
||||||
if (extendedBolus != null) {
|
if (extendedBolus != null) {
|
||||||
if (danaRPump.isExtendedInProgress) {
|
if (danaRPump.isExtendedInProgress) {
|
||||||
if (extendedBolus.absoluteRate() != danaRPump.extendedBolusAbsoluteRate) { // Close current extended
|
if (extendedBolus.absoluteRate() != danaRPump.extendedBolusAbsoluteRate) { // Close current extended
|
||||||
val exStop = ExtendedBolus(danaRPump.extendedBolusStart - 1000)
|
val exStop = ExtendedBolus(injector, danaRPump.extendedBolusStart - 1000)
|
||||||
exStop.source = Source.USER
|
exStop.source = Source.USER
|
||||||
activePlugin.activeTreatments.addToHistoryExtendedBolus(exStop)
|
activePlugin.activeTreatments.addToHistoryExtendedBolus(exStop)
|
||||||
// Create new
|
// Create new
|
||||||
val newExtended = ExtendedBolus()
|
val newExtended = ExtendedBolus(injector)
|
||||||
.date(danaRPump.extendedBolusStart)
|
.date(danaRPump.extendedBolusStart)
|
||||||
.insulin(danaRPump.extendedBolusAmount)
|
.insulin(danaRPump.extendedBolusAmount)
|
||||||
.durationInMinutes(danaRPump.extendedBolusMinutes)
|
.durationInMinutes(danaRPump.extendedBolusMinutes)
|
||||||
|
@ -73,13 +75,13 @@ class MsgStatusBolusExtended(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Close current temp basal
|
// Close current temp basal
|
||||||
val exStop = ExtendedBolus(now)
|
val exStop = ExtendedBolus(injector, now)
|
||||||
.source(Source.USER)
|
.source(Source.USER)
|
||||||
activePlugin.activeTreatments.addToHistoryExtendedBolus(exStop)
|
activePlugin.activeTreatments.addToHistoryExtendedBolus(exStop)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (danaRPump.isExtendedInProgress) { // Create new
|
if (danaRPump.isExtendedInProgress) { // Create new
|
||||||
val newExtended = ExtendedBolus()
|
val newExtended = ExtendedBolus(injector)
|
||||||
.date(danaRPump.extendedBolusStart)
|
.date(danaRPump.extendedBolusStart)
|
||||||
.insulin(danaRPump.extendedBolusAmount)
|
.insulin(danaRPump.extendedBolusAmount)
|
||||||
.durationInMinutes(danaRPump.extendedBolusMinutes)
|
.durationInMinutes(danaRPump.extendedBolusMinutes)
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump);
|
MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump);
|
||||||
MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump);
|
MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump);
|
||||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector);
|
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector);
|
||||||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin);
|
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin);
|
||||||
MsgCheckValue checkValue = new MsgCheckValue(aapsLogger, danaRPump, danaRPlugin);
|
MsgCheckValue checkValue = new MsgCheckValue(aapsLogger, danaRPump, danaRPlugin);
|
||||||
|
|
||||||
if (danaRPump.isNewPump()) {
|
if (danaRPump.isNewPump()) {
|
||||||
|
@ -259,7 +259,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF)));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class MessageHashTableRKorean @Inject constructor(
|
||||||
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
||||||
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
||||||
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
||||||
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||||
put(MsgStatusBasic_k(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
|
put(MsgStatusBasic_k(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
|
||||||
put(MsgStatus_k(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
|
put(MsgStatus_k(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
|
||||||
put(MsgInitConnStatusTime_k(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) // 0x0301 CMD_PUMPINIT_TIME_INFO
|
put(MsgInitConnStatusTime_k(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) // 0x0301 CMD_PUMPINIT_TIME_INFO
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
//MsgStatus_k statusMsg = new MsgStatus_k();
|
//MsgStatus_k statusMsg = new MsgStatus_k();
|
||||||
MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k(aapsLogger, danaRPump);
|
MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k(aapsLogger, danaRPump);
|
||||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector);
|
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector);
|
||||||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin);
|
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin);
|
||||||
MsgCheckValue_k checkValue = new MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin);
|
MsgCheckValue_k checkValue = new MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin);
|
||||||
|
|
||||||
if (danaRPump.isNewPump()) {
|
if (danaRPump.isNewPump()) {
|
||||||
|
@ -246,7 +246,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF)));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ open class DanaRS_Packet_APS_History_Events(
|
||||||
val param1 = (intFromBuff(data, 7, 1) shl 8 and 0xFF00) + (intFromBuff(data, 8, 1) and 0xFF)
|
val param1 = (intFromBuff(data, 7, 1) shl 8 and 0xFF00) + (intFromBuff(data, 8, 1) and 0xFF)
|
||||||
val param2 = (intFromBuff(data, 9, 1) shl 8 and 0xFF00) + (intFromBuff(data, 10, 1) and 0xFF)
|
val param2 = (intFromBuff(data, 9, 1) shl 8 and 0xFF00) + (intFromBuff(data, 10, 1) and 0xFF)
|
||||||
val temporaryBasal = TemporaryBasal(injector).date(datetime).source(Source.PUMP).pumpId(datetime)
|
val temporaryBasal = TemporaryBasal(injector).date(datetime).source(Source.PUMP).pumpId(datetime)
|
||||||
val extendedBolus = ExtendedBolus().date(datetime).source(Source.PUMP).pumpId(datetime)
|
val extendedBolus = ExtendedBolus(injector).date(datetime).source(Source.PUMP).pumpId(datetime)
|
||||||
val status: String
|
val status: String
|
||||||
when (recordCode.toInt()) {
|
when (recordCode.toInt()) {
|
||||||
DanaRPump.TEMPSTART -> {
|
DanaRPump.TEMPSTART -> {
|
||||||
|
|
|
@ -67,7 +67,7 @@ class MsgHistoryEvents_v2 constructor(
|
||||||
.date(datetime)
|
.date(datetime)
|
||||||
.source(Source.PUMP)
|
.source(Source.PUMP)
|
||||||
.pumpId(datetime)
|
.pumpId(datetime)
|
||||||
val extendedBolus = ExtendedBolus()
|
val extendedBolus = ExtendedBolus(injector)
|
||||||
.date(datetime)
|
.date(datetime)
|
||||||
.source(Source.PUMP)
|
.source(Source.PUMP)
|
||||||
.pumpId(datetime)
|
.pumpId(datetime)
|
||||||
|
|
|
@ -817,7 +817,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
insightBolusID.timestamp = System.currentTimeMillis();
|
insightBolusID.timestamp = System.currentTimeMillis();
|
||||||
insightBolusID.pumpSerial = connectionService.getPumpSystemIdentification().getSerialNumber();
|
insightBolusID.pumpSerial = connectionService.getPumpSystemIdentification().getSerialNumber();
|
||||||
MainApp.getDbHelper().createOrUpdate(insightBolusID);
|
MainApp.getDbHelper().createOrUpdate(insightBolusID);
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
ExtendedBolus extendedBolus = new ExtendedBolus(getInjector());
|
||||||
extendedBolus.date = insightBolusID.timestamp;
|
extendedBolus.date = insightBolusID.timestamp;
|
||||||
extendedBolus.source = Source.PUMP;
|
extendedBolus.source = Source.PUMP;
|
||||||
extendedBolus.durationInMinutes = durationInMinutes;
|
extendedBolus.durationInMinutes = durationInMinutes;
|
||||||
|
@ -1409,7 +1409,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, true);
|
treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, true);
|
||||||
}
|
}
|
||||||
if ((event.getBolusType() == BolusType.EXTENDED || event.getBolusType() == BolusType.MULTIWAVE)) {
|
if ((event.getBolusType() == BolusType.EXTENDED || event.getBolusType() == BolusType.MULTIWAVE)) {
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
ExtendedBolus extendedBolus = new ExtendedBolus(getInjector());
|
||||||
extendedBolus.date = bolusID.timestamp;
|
extendedBolus.date = bolusID.timestamp;
|
||||||
extendedBolus.source = Source.PUMP;
|
extendedBolus.source = Source.PUMP;
|
||||||
extendedBolus.durationInMinutes = event.getDuration();
|
extendedBolus.durationInMinutes = event.getDuration();
|
||||||
|
@ -1452,7 +1452,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
MainApp.getDbHelper().delete(extendedBolus);
|
MainApp.getDbHelper().delete(extendedBolus);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
ExtendedBolus extendedBolus = new ExtendedBolus(getInjector());
|
||||||
extendedBolus.date = bolusID.timestamp;
|
extendedBolus.date = bolusID.timestamp;
|
||||||
extendedBolus.source = Source.PUMP;
|
extendedBolus.source = Source.PUMP;
|
||||||
extendedBolus.durationInMinutes = event.getDuration();
|
extendedBolus.durationInMinutes = event.getDuration();
|
||||||
|
|
|
@ -105,7 +105,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
private final RileyLinkServiceData rileyLinkServiceData;
|
private final RileyLinkServiceData rileyLinkServiceData;
|
||||||
private final ServiceTaskExecutor serviceTaskExecutor;
|
private final ServiceTaskExecutor serviceTaskExecutor;
|
||||||
|
|
||||||
protected static MedtronicPumpPlugin plugin = null;
|
|
||||||
private RileyLinkMedtronicService rileyLinkMedtronicService;
|
private RileyLinkMedtronicService rileyLinkMedtronicService;
|
||||||
|
|
||||||
// variables for handling statuses and history
|
// variables for handling statuses and history
|
||||||
|
@ -149,7 +148,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
PumpType.Medtronic_522_722, // we default to most basic model, correct model from config is loaded later
|
PumpType.Medtronic_522_722, // we default to most basic model, correct model from config is loaded later
|
||||||
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy
|
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy
|
||||||
);
|
);
|
||||||
this.plugin = this;
|
|
||||||
|
|
||||||
this.rileyLinkUtil = rileyLinkUtil;
|
this.rileyLinkUtil = rileyLinkUtil;
|
||||||
this.medtronicUtil = medtronicUtil;
|
this.medtronicUtil = medtronicUtil;
|
||||||
|
@ -194,14 +192,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static MedtronicPumpPlugin getPlugin() {
|
|
||||||
if (plugin == null)
|
|
||||||
throw new IllegalStateException("Plugin not injected jet");
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePreferenceSummary(@NotNull Preference pref) {
|
public void updatePreferenceSummary(@NotNull Preference pref) {
|
||||||
super.updatePreferenceSummary(pref);
|
super.updatePreferenceSummary(pref);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
|
@ -73,6 +74,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class MedtronicHistoryData {
|
public class MedtronicHistoryData {
|
||||||
|
|
||||||
|
private final HasAndroidInjector injector;
|
||||||
private final AAPSLogger aapsLogger;
|
private final AAPSLogger aapsLogger;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final ActivePluginProvider activePlugin;
|
private final ActivePluginProvider activePlugin;
|
||||||
|
@ -100,6 +102,7 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MedtronicHistoryData(
|
public MedtronicHistoryData(
|
||||||
|
HasAndroidInjector injector,
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
SP sp,
|
SP sp,
|
||||||
ActivePluginProvider activePlugin,
|
ActivePluginProvider activePlugin,
|
||||||
|
@ -108,6 +111,7 @@ public class MedtronicHistoryData {
|
||||||
) {
|
) {
|
||||||
this.allHistory = new ArrayList<>();
|
this.allHistory = new ArrayList<>();
|
||||||
|
|
||||||
|
this.injector = injector;
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.activePlugin = activePlugin;
|
this.activePlugin = activePlugin;
|
||||||
|
@ -533,7 +537,7 @@ public class MedtronicHistoryData {
|
||||||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||||
data.put("created_at", DateUtil.toISOString(date));
|
data.put("created_at", DateUtil.toISOString(date));
|
||||||
data.put("eventType", event);
|
data.put("eventType", event);
|
||||||
CareportalEvent careportalEvent = new CareportalEvent();
|
CareportalEvent careportalEvent = new CareportalEvent(injector);
|
||||||
careportalEvent.date = date;
|
careportalEvent.date = date;
|
||||||
careportalEvent.source = Source.USER;
|
careportalEvent.source = Source.USER;
|
||||||
careportalEvent.eventType = event;
|
careportalEvent.eventType = event;
|
||||||
|
@ -954,7 +958,7 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
case Audio:
|
case Audio:
|
||||||
case Extended: {
|
case Extended: {
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
ExtendedBolus extendedBolus = new ExtendedBolus(injector);
|
||||||
extendedBolus.date = tryToGetByLocalTime(bolus.atechDateTime);
|
extendedBolus.date = tryToGetByLocalTime(bolus.atechDateTime);
|
||||||
extendedBolus.source = Source.PUMP;
|
extendedBolus.source = Source.PUMP;
|
||||||
extendedBolus.insulin = bolusDTO.getDeliveredAmount();
|
extendedBolus.insulin = bolusDTO.getDeliveredAmount();
|
||||||
|
@ -1021,7 +1025,7 @@ public class MedtronicHistoryData {
|
||||||
String operation = "editTBR";
|
String operation = "editTBR";
|
||||||
|
|
||||||
if (temporaryBasalDb == null) {
|
if (temporaryBasalDb == null) {
|
||||||
temporaryBasalDb = new TemporaryBasal();
|
temporaryBasalDb = new TemporaryBasal(injector);
|
||||||
temporaryBasalDb.date = tryToGetByLocalTime(treatment.atechDateTime);
|
temporaryBasalDb.date = tryToGetByLocalTime(treatment.atechDateTime);
|
||||||
|
|
||||||
operation = "addTBR";
|
operation = "addTBR";
|
||||||
|
@ -1055,7 +1059,7 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
if (tempBasal == null) {
|
if (tempBasal == null) {
|
||||||
// add
|
// add
|
||||||
tempBasal = new TemporaryBasal();
|
tempBasal = new TemporaryBasal(injector);
|
||||||
tempBasal.date = tryToGetByLocalTime(tempBasalProcess.itemOne.atechDateTime);
|
tempBasal.date = tryToGetByLocalTime(tempBasalProcess.itemOne.atechDateTime);
|
||||||
|
|
||||||
tempBasal.source = Source.PUMP;
|
tempBasal.source = Source.PUMP;
|
||||||
|
|
|
@ -283,7 +283,7 @@ class VirtualPumpPlugin @Inject constructor(
|
||||||
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult {
|
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult {
|
||||||
val result = cancelExtendedBolus()
|
val result = cancelExtendedBolus()
|
||||||
if (!result.success) return result
|
if (!result.success) return result
|
||||||
val extendedBolus = ExtendedBolus()
|
val extendedBolus = ExtendedBolus(injector)
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
.insulin(insulin)
|
.insulin(insulin)
|
||||||
.durationInMinutes(durationInMinutes)
|
.durationInMinutes(durationInMinutes)
|
||||||
|
@ -321,7 +321,7 @@ class VirtualPumpPlugin @Inject constructor(
|
||||||
override fun cancelExtendedBolus(): PumpEnactResult {
|
override fun cancelExtendedBolus(): PumpEnactResult {
|
||||||
val result = PumpEnactResult(injector)
|
val result = PumpEnactResult(injector)
|
||||||
if (treatmentsPlugin.isInHistoryExtendedBoluslInProgress) {
|
if (treatmentsPlugin.isInHistoryExtendedBoluslInProgress) {
|
||||||
val exStop = ExtendedBolus(System.currentTimeMillis())
|
val exStop = ExtendedBolus(injector, System.currentTimeMillis())
|
||||||
exStop.source = Source.USER
|
exStop.source = Source.USER
|
||||||
treatmentsPlugin.addToHistoryExtendedBolus(exStop)
|
treatmentsPlugin.addToHistoryExtendedBolus(exStop)
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ class RandomBgPlugin @Inject constructor(
|
||||||
|
|
||||||
val cal = GregorianCalendar()
|
val cal = GregorianCalendar()
|
||||||
val currentMinute = cal.get(Calendar.MINUTE) + (cal.get(Calendar.HOUR_OF_DAY) % 2) * 60
|
val currentMinute = cal.get(Calendar.MINUTE) + (cal.get(Calendar.HOUR_OF_DAY) % 2) * 60
|
||||||
val bgMgdl = min + (max - min) + (max - min) * sin(currentMinute / 120.0 * 2 * PI)
|
val bgMgdl = min + ((max - min) + (max - min) * sin(currentMinute / 120.0 * 2 * PI))/2
|
||||||
|
|
||||||
val bgReading = BgReading()
|
val bgReading = BgReading()
|
||||||
bgReading.value = bgMgdl
|
bgReading.value = bgMgdl
|
||||||
|
|
|
@ -18,8 +18,6 @@ import com.j256.ormlite.table.TableUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -29,6 +27,9 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.db.ICallback;
|
import info.nightscout.androidaps.db.ICallback;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
|
@ -36,13 +37,12 @@ import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.events.EventNsTreatment;
|
import info.nightscout.androidaps.events.EventNsTreatment;
|
||||||
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.JsonHelper;
|
import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
@ -54,16 +54,22 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATATREATMENTS);
|
|
||||||
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
@Inject RxBusWrapper rxBus;
|
||||||
|
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static final ScheduledExecutorService treatmentEventWorker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService treatmentEventWorker = Executors.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledTreatmentEventPost = null;
|
private static ScheduledFuture<?> scheduledTreatmentEventPost = null;
|
||||||
|
|
||||||
public TreatmentService() {
|
public TreatmentService(HasAndroidInjector injector) {
|
||||||
|
injector.androidInjector().inject(this);
|
||||||
onCreate();
|
onCreate();
|
||||||
dbInitialize();
|
dbInitialize();
|
||||||
disposable.add(RxBus.Companion.getINSTANCE()
|
disposable.add(rxBus
|
||||||
.toObservable(EventNsTreatment.class)
|
.toObservable(EventNsTreatment.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
|
@ -75,7 +81,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
} else { // EventNsTreatment.REMOVE
|
} else { // EventNsTreatment.REMOVE
|
||||||
this.deleteNS(payload);
|
this.deleteNS(payload);
|
||||||
}
|
}
|
||||||
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
}, fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +107,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
try {
|
try {
|
||||||
return DaoManager.createDao(this.getConnectionSource(), Treatment.class);
|
return DaoManager.createDao(this.getConnectionSource(), Treatment.class);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Cannot create Dao for Treatment.class");
|
aapsLogger.error("Cannot create Dao for Treatment.class");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -111,35 +117,33 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
try {
|
try {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.info(LTag.DATATREATMENTS, "onCreate");
|
||||||
log.info("onCreate");
|
|
||||||
TableUtils.createTableIfNotExists(this.getConnectionSource(), Treatment.class);
|
TableUtils.createTableIfNotExists(this.getConnectionSource(), Treatment.class);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Can't create database", e);
|
aapsLogger.error("Can't create database", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpgrade(ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
public void onUpgrade(ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
||||||
if (oldVersion == 7 && newVersion == 8) {
|
if (oldVersion == 7 && newVersion == 8) {
|
||||||
log.debug("Upgrading database from v7 to v8");
|
aapsLogger.debug("Upgrading database from v7 to v8");
|
||||||
try {
|
try {
|
||||||
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Can't create database", e);
|
aapsLogger.error("Can't create database", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
} else if (oldVersion == 8 && newVersion == 9) {
|
} else if (oldVersion == 8 && newVersion == 9) {
|
||||||
log.debug("Upgrading database from v8 to v9");
|
aapsLogger.debug("Upgrading database from v8 to v9");
|
||||||
try {
|
try {
|
||||||
getDao().executeRaw("ALTER TABLE `" + Treatment.TABLE_TREATMENTS + "` ADD COLUMN boluscalc STRING;");
|
getDao().executeRaw("ALTER TABLE `" + Treatment.TABLE_TREATMENTS + "` ADD COLUMN boluscalc STRING;");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.info(LTag.DATATREATMENTS, "onUpgrade");
|
||||||
log.info("onUpgrade");
|
|
||||||
// this.resetFood();
|
// this.resetFood();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +153,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
try {
|
try {
|
||||||
getDao().executeRaw("ALTER TABLE `" + Treatment.TABLE_TREATMENTS + "` DROP COLUMN boluscalc STRING;");
|
getDao().executeRaw("ALTER TABLE `" + Treatment.TABLE_TREATMENTS + "` DROP COLUMN boluscalc STRING;");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +164,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
TableUtils.createTableIfNotExists(this.getConnectionSource(), Treatment.class);
|
TableUtils.createTableIfNotExists(this.getConnectionSource(), Treatment.class);
|
||||||
DatabaseHelper.updateEarliestDataChange(0);
|
DatabaseHelper.updateEarliestDataChange(0);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
scheduleTreatmentChange(null, true);
|
scheduleTreatmentChange(null, true);
|
||||||
}
|
}
|
||||||
|
@ -185,13 +189,11 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
|
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Firing EventReloadTreatmentData");
|
||||||
log.debug("Firing EventReloadTreatmentData");
|
rxBus.send(event);
|
||||||
RxBus.Companion.getINSTANCE().send(event);
|
|
||||||
if (DatabaseHelper.earliestDataChange != null) {
|
if (DatabaseHelper.earliestDataChange != null) {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Firing EventNewHistoryData");
|
||||||
log.debug("Firing EventNewHistoryData");
|
rxBus.send(new EventNewHistoryData(DatabaseHelper.earliestDataChange));
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewHistoryData(DatabaseHelper.earliestDataChange));
|
|
||||||
}
|
}
|
||||||
DatabaseHelper.earliestDataChange = null;
|
DatabaseHelper.earliestDataChange = null;
|
||||||
callback.setPost(null);
|
callback.setPost(null);
|
||||||
|
@ -212,13 +214,11 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
*/
|
*/
|
||||||
public void scheduleTreatmentChange(@Nullable final Treatment treatment, boolean runImmediately) {
|
public void scheduleTreatmentChange(@Nullable final Treatment treatment, boolean runImmediately) {
|
||||||
if (runImmediately) {
|
if (runImmediately) {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Firing EventReloadTreatmentData");
|
||||||
log.debug("Firing EventReloadTreatmentData");
|
rxBus.send(new EventReloadTreatmentData(new EventTreatmentChange(treatment)));
|
||||||
RxBus.Companion.getINSTANCE().send(new EventReloadTreatmentData(new EventTreatmentChange(treatment)));
|
|
||||||
if (DatabaseHelper.earliestDataChange != null) {
|
if (DatabaseHelper.earliestDataChange != null) {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Firing EventNewHistoryData");
|
||||||
log.debug("Firing EventNewHistoryData");
|
rxBus.send(new EventNewHistoryData(DatabaseHelper.earliestDataChange));
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewHistoryData(DatabaseHelper.earliestDataChange));
|
|
||||||
}
|
}
|
||||||
DatabaseHelper.earliestDataChange = null;
|
DatabaseHelper.earliestDataChange = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -240,7 +240,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
try {
|
try {
|
||||||
return this.getDao().queryForAll();
|
return this.getDao().queryForAll();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
@ -266,16 +266,16 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
if (treatment != null) {
|
if (treatment != null) {
|
||||||
|
|
||||||
if (MedtronicHistoryData.doubleBolusDebug)
|
if (MedtronicHistoryData.doubleBolusDebug)
|
||||||
log.debug("DoubleBolusDebug: createTreatmentFromJsonIfNotExists:: medtronicPump={}", MedtronicPumpPlugin.getPlugin().isEnabled());
|
aapsLogger.debug(LTag.DATATREATMENTS, "DoubleBolusDebug: createTreatmentFromJsonIfNotExists:: medtronicPump={}", medtronicPumpPlugin.isEnabled());
|
||||||
|
|
||||||
if (!MedtronicPumpPlugin.getPlugin().isEnabled())
|
if (!medtronicPumpPlugin.isEnabled())
|
||||||
createOrUpdate(treatment);
|
createOrUpdate(treatment);
|
||||||
else
|
else
|
||||||
createOrUpdateMedtronic(treatment, true);
|
createOrUpdateMedtronic(treatment, true);
|
||||||
} else
|
} else
|
||||||
log.error("Date is null: " + treatment.toString());
|
aapsLogger.error("Date is null: " + treatment.toString());
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
// return true if new record is created
|
// return true if new record is created
|
||||||
public UpdateReturn createOrUpdate(Treatment treatment) {
|
public UpdateReturn createOrUpdate(Treatment treatment) {
|
||||||
if (treatment != null && treatment.source == Source.NONE) {
|
if (treatment != null && treatment.source == Source.NONE) {
|
||||||
log.error("Coder error: source is not set for treatment: " + treatment, new Exception());
|
aapsLogger.error("Coder error: source is not set for treatment: " + treatment, new Exception());
|
||||||
//FabricPrivacy.logException(new Exception("Coder error: source is not set for treatment: " + treatment));
|
//FabricPrivacy.logException(new Exception("Coder error: source is not set for treatment: " + treatment));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -298,8 +298,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
boolean sameSource = existingTreatment.source == treatment.source;
|
boolean sameSource = existingTreatment.source == treatment.source;
|
||||||
if (!equalRePumpHistory) {
|
if (!equalRePumpHistory) {
|
||||||
// another treatment exists. Update it with the treatment coming from the pump
|
// another treatment exists. Update it with the treatment coming from the pump
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Pump record already found in database: " + existingTreatment.toString() + " wanting to add " + treatment.toString());
|
||||||
log.debug("Pump record already found in database: " + existingTreatment.toString() + " wanting to add " + treatment.toString());
|
|
||||||
long oldDate = existingTreatment.date;
|
long oldDate = existingTreatment.date;
|
||||||
|
|
||||||
//preserve carbs
|
//preserve carbs
|
||||||
|
@ -323,8 +322,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
boolean equalRePumpHistory = existingTreatment.equalsRePumpHistory(treatment);
|
boolean equalRePumpHistory = existingTreatment.equalsRePumpHistory(treatment);
|
||||||
boolean sameSource = existingTreatment.source == treatment.source;
|
boolean sameSource = existingTreatment.source == treatment.source;
|
||||||
long oldDate = existingTreatment.date;
|
long oldDate = existingTreatment.date;
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Pump record already found in database: " + existingTreatment.toString() + " wanting to add " + treatment.toString());
|
||||||
log.debug("Pump record already found in database: " + existingTreatment.toString() + " wanting to add " + treatment.toString());
|
|
||||||
|
|
||||||
//preserve carbs
|
//preserve carbs
|
||||||
if (existingTreatment.isValid && existingTreatment.carbs > 0 && treatment.carbs == 0) {
|
if (existingTreatment.isValid && existingTreatment.carbs > 0 && treatment.carbs == 0) {
|
||||||
|
@ -340,8 +338,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
return new UpdateReturn(equalRePumpHistory || sameSource, false);
|
return new UpdateReturn(equalRePumpHistory || sameSource, false);
|
||||||
}
|
}
|
||||||
getDao().create(treatment);
|
getDao().create(treatment);
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
||||||
log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
|
||||||
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
scheduleTreatmentChange(treatment, true);
|
scheduleTreatmentChange(treatment, true);
|
||||||
return new UpdateReturn(true, true);
|
return new UpdateReturn(true, true);
|
||||||
|
@ -355,8 +352,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
getDao().delete(old); // need to delete/create because date may change too
|
getDao().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(treatment);
|
old.copyFrom(treatment);
|
||||||
getDao().create(old);
|
getDao().create(old);
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Updating record by date from: " + Source.getString(treatment.source) + " " + old.toString());
|
||||||
log.debug("Updating record by date from: " + Source.getString(treatment.source) + " " + old.toString());
|
|
||||||
if (historyChange) {
|
if (historyChange) {
|
||||||
DatabaseHelper.updateEarliestDataChange(oldDate);
|
DatabaseHelper.updateEarliestDataChange(oldDate);
|
||||||
DatabaseHelper.updateEarliestDataChange(old.date);
|
DatabaseHelper.updateEarliestDataChange(old.date);
|
||||||
|
@ -364,8 +360,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
scheduleTreatmentChange(treatment, false);
|
scheduleTreatmentChange(treatment, false);
|
||||||
return new UpdateReturn(true, true);
|
return new UpdateReturn(true, true);
|
||||||
}
|
}
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Equal record by date from: " + Source.getString(treatment.source) + " " + old.toString());
|
||||||
log.debug("Equal record by date from: " + Source.getString(treatment.source) + " " + old.toString());
|
|
||||||
return new UpdateReturn(true, false);
|
return new UpdateReturn(true, false);
|
||||||
}
|
}
|
||||||
// find by NS _id
|
// find by NS _id
|
||||||
|
@ -378,8 +373,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
getDao().delete(old); // need to delete/create because date may change too
|
getDao().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(treatment);
|
old.copyFrom(treatment);
|
||||||
getDao().create(old);
|
getDao().create(old);
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Updating record by _id from: " + Source.getString(treatment.source) + " " + old.toString());
|
||||||
log.debug("Updating record by _id from: " + Source.getString(treatment.source) + " " + old.toString());
|
|
||||||
if (historyChange) {
|
if (historyChange) {
|
||||||
DatabaseHelper.updateEarliestDataChange(oldDate);
|
DatabaseHelper.updateEarliestDataChange(oldDate);
|
||||||
DatabaseHelper.updateEarliestDataChange(old.date);
|
DatabaseHelper.updateEarliestDataChange(old.date);
|
||||||
|
@ -387,28 +381,25 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
scheduleTreatmentChange(treatment, false);
|
scheduleTreatmentChange(treatment, false);
|
||||||
return new UpdateReturn(true, true);
|
return new UpdateReturn(true, true);
|
||||||
}
|
}
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Equal record by _id from: " + Source.getString(treatment.source) + " " + old.toString());
|
||||||
log.debug("Equal record by _id from: " + Source.getString(treatment.source) + " " + old.toString());
|
|
||||||
return new UpdateReturn(true, false);
|
return new UpdateReturn(true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getDao().create(treatment);
|
getDao().create(treatment);
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
||||||
log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
|
||||||
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
scheduleTreatmentChange(treatment, false);
|
scheduleTreatmentChange(treatment, false);
|
||||||
return new UpdateReturn(true, true);
|
return new UpdateReturn(true, true);
|
||||||
}
|
}
|
||||||
if (treatment.source == Source.USER) {
|
if (treatment.source == Source.USER) {
|
||||||
getDao().create(treatment);
|
getDao().create(treatment);
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
||||||
log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
|
||||||
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
scheduleTreatmentChange(treatment, true);
|
scheduleTreatmentChange(treatment, true);
|
||||||
return new UpdateReturn(true, true);
|
return new UpdateReturn(true, true);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return new UpdateReturn(false, false);
|
return new UpdateReturn(false, false);
|
||||||
}
|
}
|
||||||
|
@ -417,7 +408,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
public UpdateReturn createOrUpdateMedtronic(Treatment treatment, boolean fromNightScout) {
|
public UpdateReturn createOrUpdateMedtronic(Treatment treatment, boolean fromNightScout) {
|
||||||
|
|
||||||
if (MedtronicHistoryData.doubleBolusDebug)
|
if (MedtronicHistoryData.doubleBolusDebug)
|
||||||
log.debug("DoubleBolusDebug: createOrUpdateMedtronic:: originalTreatment={}, fromNightScout={}", treatment, fromNightScout);
|
aapsLogger.debug(LTag.DATATREATMENTS, "DoubleBolusDebug: createOrUpdateMedtronic:: originalTreatment={}, fromNightScout={}", treatment, fromNightScout);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
treatment.date = DatabaseHelper.roundDateToSec(treatment.date);
|
treatment.date = DatabaseHelper.roundDateToSec(treatment.date);
|
||||||
|
@ -425,12 +416,11 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
Treatment existingTreatment = getRecord(treatment.pumpId, treatment.date);
|
Treatment existingTreatment = getRecord(treatment.pumpId, treatment.date);
|
||||||
|
|
||||||
if (MedtronicHistoryData.doubleBolusDebug)
|
if (MedtronicHistoryData.doubleBolusDebug)
|
||||||
log.debug("DoubleBolusDebug: createOrUpdateMedtronic:: existingTreatment={}", treatment);
|
aapsLogger.debug(LTag.DATATREATMENTS, "DoubleBolusDebug: createOrUpdateMedtronic:: existingTreatment={}", treatment);
|
||||||
|
|
||||||
if (existingTreatment == null) {
|
if (existingTreatment == null) {
|
||||||
getDao().create(treatment);
|
getDao().create(treatment);
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
||||||
log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
|
||||||
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
scheduleTreatmentChange(treatment, true);
|
scheduleTreatmentChange(treatment, true);
|
||||||
return new UpdateReturn(true, true);
|
return new UpdateReturn(true, true);
|
||||||
|
@ -438,7 +428,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
|
|
||||||
if (existingTreatment.date == treatment.date) {
|
if (existingTreatment.date == treatment.date) {
|
||||||
if (MedtronicHistoryData.doubleBolusDebug)
|
if (MedtronicHistoryData.doubleBolusDebug)
|
||||||
log.debug("DoubleBolusDebug: createOrUpdateMedtronic::(existingTreatment.date==treatment.date)");
|
aapsLogger.debug(LTag.DATATREATMENTS, "DoubleBolusDebug: createOrUpdateMedtronic::(existingTreatment.date==treatment.date)");
|
||||||
|
|
||||||
// we will do update only, if entry changed
|
// we will do update only, if entry changed
|
||||||
if (!optionalTreatmentCopy(existingTreatment, treatment, fromNightScout)) {
|
if (!optionalTreatmentCopy(existingTreatment, treatment, fromNightScout)) {
|
||||||
|
@ -450,7 +440,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
return new UpdateReturn(true, false);
|
return new UpdateReturn(true, false);
|
||||||
} else {
|
} else {
|
||||||
if (MedtronicHistoryData.doubleBolusDebug)
|
if (MedtronicHistoryData.doubleBolusDebug)
|
||||||
log.debug("DoubleBolusDebug: createOrUpdateMedtronic::(existingTreatment.date != treatment.date)");
|
aapsLogger.debug(LTag.DATATREATMENTS, "DoubleBolusDebug: createOrUpdateMedtronic::(existingTreatment.date != treatment.date)");
|
||||||
|
|
||||||
// date is different, we need to remove entry
|
// date is different, we need to remove entry
|
||||||
getDao().delete(existingTreatment);
|
getDao().delete(existingTreatment);
|
||||||
|
@ -463,7 +453,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled SQL exception: {}", e.getMessage(), e);
|
aapsLogger.error("Unhandled SQL exception: {}", e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return new UpdateReturn(false, false);
|
return new UpdateReturn(false, false);
|
||||||
}
|
}
|
||||||
|
@ -471,7 +461,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
|
|
||||||
private boolean optionalTreatmentCopy(Treatment oldTreatment, Treatment newTreatment, boolean fromNightScout) {
|
private boolean optionalTreatmentCopy(Treatment oldTreatment, Treatment newTreatment, boolean fromNightScout) {
|
||||||
|
|
||||||
log.debug("optionalTreatmentCopy [old={}, new={}]", oldTreatment.toString(), newTreatment.toString());
|
aapsLogger.debug(LTag.DATATREATMENTS, "optionalTreatmentCopy [old={}, new={}]", oldTreatment.toString(), newTreatment.toString());
|
||||||
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
|
@ -537,7 +527,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("optionalTreatmentCopy [changed={}, newAfterChange={}]", changed, oldTreatment.toString());
|
aapsLogger.debug(LTag.DATATREATMENTS, "optionalTreatmentCopy [changed={}, newAfterChange={}]", changed, oldTreatment.toString());
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +541,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private void treatmentCopy(Treatment oldTreatment, Treatment newTreatment, boolean fromNightScout) {
|
private void treatmentCopy(Treatment oldTreatment, Treatment newTreatment, boolean fromNightScout) {
|
||||||
|
|
||||||
log.debug("treatmentCopy [old={}, new={}]", oldTreatment.toString(), newTreatment.toString());
|
aapsLogger.debug(LTag.DATATREATMENTS, "treatmentCopy [old={}, new={}]", oldTreatment.toString(), newTreatment.toString());
|
||||||
|
|
||||||
|
|
||||||
if (fromNightScout) {
|
if (fromNightScout) {
|
||||||
|
@ -574,7 +564,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
oldTreatment.copyFrom(newTreatment);
|
oldTreatment.copyFrom(newTreatment);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("treatmentCopy [newAfterChange={}]", oldTreatment.toString());
|
aapsLogger.debug(LTag.DATATREATMENTS, "treatmentCopy [newAfterChange={}]", oldTreatment.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +585,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
try {
|
try {
|
||||||
record = getDao().queryForId(date);
|
record = getDao().queryForId(date);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
log.error("Error getting entry by id ({}", date);
|
aapsLogger.error("Error getting entry by id ({}", date);
|
||||||
}
|
}
|
||||||
|
|
||||||
return record;
|
return record;
|
||||||
|
@ -619,7 +609,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
if (result.isEmpty())
|
if (result.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
if (result.size() > 1)
|
if (result.size() > 1)
|
||||||
log.warn("Multiple records with the same pump id found (returning first one): " + result.toString());
|
aapsLogger.warn(LTag.DATATREATMENTS, "Multiple records with the same pump id found (returning first one): " + result.toString());
|
||||||
return result.get(0);
|
return result.get(0);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -642,12 +632,11 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
private void deleteByNSId(String _id) {
|
private void deleteByNSId(String _id) {
|
||||||
Treatment stored = findByNSId(_id);
|
Treatment stored = findByNSId(_id);
|
||||||
if (stored != null) {
|
if (stored != null) {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
aapsLogger.debug(LTag.DATATREATMENTS, "Removing Treatment record from database: " + stored.toString());
|
||||||
log.debug("Removing Treatment record from database: " + stored.toString());
|
|
||||||
try {
|
try {
|
||||||
getDao().delete(stored);
|
getDao().delete(stored);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
DatabaseHelper.updateEarliestDataChange(stored.date);
|
DatabaseHelper.updateEarliestDataChange(stored.date);
|
||||||
this.scheduleTreatmentChange(stored, false);
|
this.scheduleTreatmentChange(stored, false);
|
||||||
|
@ -667,7 +656,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
this.scheduleTreatmentChange(treatment, true);
|
this.scheduleTreatmentChange(treatment, true);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,7 +665,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
getDao().update(treatment);
|
getDao().update(treatment);
|
||||||
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
scheduleTreatmentChange(treatment, true);
|
scheduleTreatmentChange(treatment, true);
|
||||||
}
|
}
|
||||||
|
@ -705,7 +694,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
return trList.get(0);
|
return trList.get(0);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -722,7 +711,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
treatments = daoTreatments.query(preparedQuery);
|
treatments = daoTreatments.query(preparedQuery);
|
||||||
return treatments;
|
return treatments;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
@ -739,7 +728,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
treatments = daoTreatments.query(preparedQuery);
|
treatments = daoTreatments.query(preparedQuery);
|
||||||
return treatments;
|
return treatments;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
this.service = new TreatmentService();
|
this.service = new TreatmentService(getInjector());
|
||||||
initializeData(range());
|
initializeData(range());
|
||||||
super.onStart();
|
super.onStart();
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
|
@ -423,7 +423,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
Profile profile = profileFunction.getProfile(e.date);
|
Profile profile = profileFunction.getProfile(e.date);
|
||||||
if (profile == null) continue;
|
if (profile == null) continue;
|
||||||
if (truncate && e.end() > truncateTime) {
|
if (truncate && e.end() > truncateTime) {
|
||||||
ExtendedBolus dummyExt = new ExtendedBolus();
|
ExtendedBolus dummyExt = new ExtendedBolus(getInjector());
|
||||||
dummyExt.copyFrom(e);
|
dummyExt.copyFrom(e);
|
||||||
dummyExt.cutEndTo(truncateTime);
|
dummyExt.cutEndTo(truncateTime);
|
||||||
calc = dummyExt.iobCalc(time);
|
calc = dummyExt.iobCalc(time);
|
||||||
|
@ -498,7 +498,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
Profile profile = profileFunction.getProfile(e.date);
|
Profile profile = profileFunction.getProfile(e.date);
|
||||||
if (profile == null) continue;
|
if (profile == null) continue;
|
||||||
if (e.end() > truncateTime) {
|
if (e.end() > truncateTime) {
|
||||||
ExtendedBolus dummyExt = new ExtendedBolus();
|
ExtendedBolus dummyExt = new ExtendedBolus(getInjector());
|
||||||
dummyExt.copyFrom(e);
|
dummyExt.copyFrom(e);
|
||||||
dummyExt.cutEndTo(truncateTime);
|
dummyExt.cutEndTo(truncateTime);
|
||||||
calc = dummyExt.iobCalc(time, profile, lastAutosensResult, exercise_mode, half_basal_exercise_target, isTempTarget);
|
calc = dummyExt.iobCalc(time, profile, lastAutosensResult, exercise_mode, half_basal_exercise_target, isTempTarget);
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class TreatmentsTempTargetFragment extends DaggerFragment {
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject RxBusWrapper rxBus;
|
||||||
@Inject ProfileFunction profileFunction;
|
@Inject ProfileFunction profileFunction;
|
||||||
@Inject ResourceHelper resourceHelper;
|
@Inject ResourceHelper resourceHelper;
|
||||||
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -139,7 +140,7 @@ public class TreatmentsTempTargetFragment extends DaggerFragment {
|
||||||
remove.setOnClickListener(v -> {
|
remove.setOnClickListener(v -> {
|
||||||
final TempTarget tempTarget = (TempTarget) v.getTag();
|
final TempTarget tempTarget = (TempTarget) v.getTag();
|
||||||
OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.removerecord),
|
OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.removerecord),
|
||||||
resourceHelper.gs(R.string.careportal_temporarytarget) + ": " + tempTarget.friendlyDescription(profileFunction.getUnits()) +
|
resourceHelper.gs(R.string.careportal_temporarytarget) + ": " + tempTarget.friendlyDescription(profileFunction.getUnits(), resourceHelper) +
|
||||||
"\n" + DateUtil.dateAndTimeString(tempTarget.date),
|
"\n" + DateUtil.dateAndTimeString(tempTarget.date),
|
||||||
(dialog, id) -> {
|
(dialog, id) -> {
|
||||||
final String _id = tempTarget._id;
|
final String _id = tempTarget._id;
|
||||||
|
@ -189,7 +190,7 @@ public class TreatmentsTempTargetFragment extends DaggerFragment {
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempTargetChange.class)
|
.toObservable(EventTempTargetChange.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(event -> updateGui(), exception -> FabricPrivacy.getInstance().logException(exception))
|
.subscribe(event -> updateGui(), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
updateGui();
|
updateGui();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,17 @@ import android.media.AudioManager
|
||||||
import android.media.MediaPlayer
|
import android.media.MediaPlayer
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import dagger.android.DaggerService
|
import dagger.android.DaggerService
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AlarmSoundService : DaggerService() {
|
class AlarmSoundService : DaggerService() {
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var notificationHolder: NotificationHolder
|
||||||
|
|
||||||
private var player: MediaPlayer? = null
|
private var player: MediaPlayer? = null
|
||||||
private var resourceId = R.raw.error
|
private var resourceId = R.raw.error
|
||||||
|
@ -26,11 +26,11 @@ class AlarmSoundService : DaggerService() {
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
aapsLogger.debug(LTag.CORE, "onCreate")
|
aapsLogger.debug(LTag.CORE, "onCreate")
|
||||||
startForeground(mainApp.notificationId(), mainApp.notification)
|
startForeground(notificationHolder.notificationID, notificationHolder.notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||||
startForeground(mainApp.notificationId(), mainApp.notification)
|
startForeground(notificationHolder.notificationID, notificationHolder.notification)
|
||||||
|
|
||||||
player?.let { if (it.isPlaying) it.stop() }
|
player?.let { if (it.isPlaying) it.stop() }
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.events.EventNsTreatment;
|
import info.nightscout.androidaps.events.EventNsTreatment;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.BundleLogger;
|
import info.nightscout.androidaps.logging.BundleLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
@ -51,6 +52,7 @@ public class DataService extends DaggerIntentService {
|
||||||
@Inject TomatoPlugin tomatoPlugin;
|
@Inject TomatoPlugin tomatoPlugin;
|
||||||
@Inject XdripPlugin xdripPlugin;
|
@Inject XdripPlugin xdripPlugin;
|
||||||
@Inject NSProfilePlugin nsProfilePlugin;
|
@Inject NSProfilePlugin nsProfilePlugin;
|
||||||
|
@Inject ActivePluginProvider activePlugin;
|
||||||
|
|
||||||
public DataService() {
|
public DataService() {
|
||||||
super("DataService");
|
super("DataService");
|
||||||
|
@ -208,7 +210,7 @@ public class DataService extends DaggerIntentService {
|
||||||
} else if (eventType.equals(CareportalEvent.COMBOBOLUS)) {
|
} else if (eventType.equals(CareportalEvent.COMBOBOLUS)) {
|
||||||
MainApp.getDbHelper().createExtendedBolusFromJsonIfNotExists(json);
|
MainApp.getDbHelper().createExtendedBolusFromJsonIfNotExists(json);
|
||||||
} else if (eventType.equals(CareportalEvent.PROFILESWITCH)) {
|
} else if (eventType.equals(CareportalEvent.PROFILESWITCH)) {
|
||||||
MainApp.getDbHelper().createProfileSwitchFromJsonIfNotExists(json);
|
MainApp.getDbHelper().createProfileSwitchFromJsonIfNotExists(activePlugin, json);
|
||||||
} else if (eventType.equals(CareportalEvent.SITECHANGE) ||
|
} else if (eventType.equals(CareportalEvent.SITECHANGE) ||
|
||||||
eventType.equals(CareportalEvent.INSULINCHANGE) ||
|
eventType.equals(CareportalEvent.INSULINCHANGE) ||
|
||||||
eventType.equals(CareportalEvent.SENSORCHANGE) ||
|
eventType.equals(CareportalEvent.SENSORCHANGE) ||
|
||||||
|
|
|
@ -12,7 +12,6 @@ import android.os.IBinder
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import com.google.android.gms.location.LocationServices
|
import com.google.android.gms.location.LocationServices
|
||||||
import dagger.android.DaggerService
|
import dagger.android.DaggerService
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.events.EventAppExit
|
import info.nightscout.androidaps.events.EventAppExit
|
||||||
import info.nightscout.androidaps.events.EventLocationChange
|
import info.nightscout.androidaps.events.EventLocationChange
|
||||||
|
@ -21,6 +20,7 @@ import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
|
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
@ -32,7 +32,7 @@ class LocationService : DaggerService() {
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var notificationHolder: NotificationHolder
|
||||||
@Inject lateinit var lastLocationDataContainer: LastLocationDataContainer
|
@Inject lateinit var lastLocationDataContainer: LastLocationDataContainer
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
@ -73,13 +73,13 @@ class LocationService : DaggerService() {
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||||
super.onStartCommand(intent, flags, startId)
|
super.onStartCommand(intent, flags, startId)
|
||||||
startForeground(mainApp.notificationId(), mainApp.notification)
|
startForeground(notificationHolder.notificationID, notificationHolder.notification)
|
||||||
return Service.START_STICKY
|
return Service.START_STICKY
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
startForeground(mainApp.notificationId(), mainApp.notification)
|
startForeground(notificationHolder.notificationID, notificationHolder.notification)
|
||||||
|
|
||||||
// Get last location once until we get regular update
|
// Get last location once until we get regular update
|
||||||
LocationServices.getFusedLocationProviderClient(this).lastLocation.addOnSuccessListener {
|
LocationServices.getFusedLocationProviderClient(this).lastLocation.addOnSuccessListener {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.androidaps.utils
|
package info.nightscout.androidaps.utils
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.crashlytics.android.Crashlytics
|
import com.crashlytics.android.Crashlytics
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
import info.nightscout.androidaps.BuildConfig
|
import info.nightscout.androidaps.BuildConfig
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
@ -13,6 +13,7 @@ import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
|
import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import io.fabric.sdk.android.Fabric
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -24,16 +25,24 @@ import javax.inject.Singleton
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
class FabricPrivacy @Inject constructor(
|
class FabricPrivacy @Inject constructor(
|
||||||
|
context: Context,
|
||||||
private val aapsLogger: AAPSLogger,
|
private val aapsLogger: AAPSLogger,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val constraintChecker: ConstraintChecker,
|
private val constraintChecker: ConstraintChecker,
|
||||||
private val mainApp: MainApp,
|
|
||||||
private val signatureVerifierPlugin: SignatureVerifierPlugin,
|
private val signatureVerifierPlugin: SignatureVerifierPlugin,
|
||||||
private val activePlugin: ActivePluginProvider
|
private val activePlugin: ActivePluginProvider
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
private var firebaseAnalytics: FirebaseAnalytics
|
||||||
|
|
||||||
init {
|
init {
|
||||||
instance = this
|
instance = this
|
||||||
|
firebaseAnalytics = FirebaseAnalytics.getInstance(context)
|
||||||
|
firebaseAnalytics.setAnalyticsCollectionEnabled(!java.lang.Boolean.getBoolean("disableFirebase") && fabricEnabled())
|
||||||
|
|
||||||
|
if (fabricEnabled()) {
|
||||||
|
Fabric.with(context, Crashlytics())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -48,7 +57,7 @@ class FabricPrivacy @Inject constructor(
|
||||||
fun logCustom(event: Bundle) {
|
fun logCustom(event: Bundle) {
|
||||||
try {
|
try {
|
||||||
if (fabricEnabled()) {
|
if (fabricEnabled()) {
|
||||||
mainApp.firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, event)
|
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, event)
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.CORE, "Ignoring recently opted-out event: $event")
|
aapsLogger.debug(LTag.CORE, "Ignoring recently opted-out event: $event")
|
||||||
}
|
}
|
||||||
|
@ -63,7 +72,7 @@ class FabricPrivacy @Inject constructor(
|
||||||
fun logCustom(event: String) {
|
fun logCustom(event: String) {
|
||||||
try {
|
try {
|
||||||
if (fabricEnabled()) {
|
if (fabricEnabled()) {
|
||||||
mainApp.firebaseAnalytics.logEvent(event, Bundle())
|
firebaseAnalytics.logEvent(event, Bundle())
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.CORE, "Ignoring recently opted-out event: $event")
|
aapsLogger.debug(LTag.CORE, "Ignoring recently opted-out event: $event")
|
||||||
}
|
}
|
||||||
|
@ -125,19 +134,19 @@ class FabricPrivacy @Inject constructor(
|
||||||
.replace(".com/", ":")
|
.replace(".com/", ":")
|
||||||
.replace(".org/", ":")
|
.replace(".org/", ":")
|
||||||
.replace(".net/", ":")
|
.replace(".net/", ":")
|
||||||
mainApp.firebaseAnalytics.setUserProperty("Mode", BuildConfig.APPLICATION_ID + "-" + closedLoopEnabled)
|
firebaseAnalytics.setUserProperty("Mode", BuildConfig.APPLICATION_ID + "-" + closedLoopEnabled)
|
||||||
mainApp.firebaseAnalytics.setUserProperty("Language", sp.getString(R.string.key_language, Locale.getDefault().language))
|
firebaseAnalytics.setUserProperty("Language", sp.getString(R.string.key_language, Locale.getDefault().language))
|
||||||
mainApp.firebaseAnalytics.setUserProperty("Version", BuildConfig.VERSION)
|
firebaseAnalytics.setUserProperty("Version", BuildConfig.VERSION)
|
||||||
mainApp.firebaseAnalytics.setUserProperty("HEAD", BuildConfig.HEAD)
|
firebaseAnalytics.setUserProperty("HEAD", BuildConfig.HEAD)
|
||||||
mainApp.firebaseAnalytics.setUserProperty("Remote", remote)
|
firebaseAnalytics.setUserProperty("Remote", remote)
|
||||||
val hashes: List<String> = signatureVerifierPlugin.shortHashes()
|
val hashes: List<String> = signatureVerifierPlugin.shortHashes()
|
||||||
if (hashes.isNotEmpty()) mainApp.firebaseAnalytics.setUserProperty("Hash", hashes[0])
|
if (hashes.isNotEmpty()) firebaseAnalytics.setUserProperty("Hash", hashes[0])
|
||||||
activePlugin.activePump.let { mainApp.firebaseAnalytics.setUserProperty("Pump", it::class.java.simpleName) }
|
activePlugin.activePump.let { firebaseAnalytics.setUserProperty("Pump", it::class.java.simpleName) }
|
||||||
if (!Config.NSCLIENT && !Config.PUMPCONTROL)
|
if (!Config.NSCLIENT && !Config.PUMPCONTROL)
|
||||||
activePlugin.activeAPS.let { mainApp.firebaseAnalytics.setUserProperty("Aps", it::class.java.simpleName) }
|
activePlugin.activeAPS.let { firebaseAnalytics.setUserProperty("Aps", it::class.java.simpleName) }
|
||||||
activePlugin.activeBgSource.let { mainApp.firebaseAnalytics.setUserProperty("BgSource", it::class.java.simpleName) }
|
activePlugin.activeBgSource.let { firebaseAnalytics.setUserProperty("BgSource", it::class.java.simpleName) }
|
||||||
mainApp.firebaseAnalytics.setUserProperty("Profile", activePlugin.activeProfileInterface.javaClass.simpleName)
|
firebaseAnalytics.setUserProperty("Profile", activePlugin.activeProfileInterface.javaClass.simpleName)
|
||||||
activePlugin.activeSensitivity.let { mainApp.firebaseAnalytics.setUserProperty("Sensitivity", it::class.java.simpleName) }
|
activePlugin.activeSensitivity.let { firebaseAnalytics.setUserProperty("Sensitivity", it::class.java.simpleName) }
|
||||||
activePlugin.activeInsulin.let { mainApp.firebaseAnalytics.setUserProperty("Insulin", it::class.java.simpleName) }
|
activePlugin.activeInsulin.let { firebaseAnalytics.setUserProperty("Insulin", it::class.java.simpleName) }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -45,6 +45,10 @@ class HardLimits @Inject constructor(
|
||||||
val MAXIOB_SMB = doubleArrayOf(3.0, 7.0, 12.0, 25.0)
|
val MAXIOB_SMB = doubleArrayOf(3.0, 7.0, 12.0, 25.0)
|
||||||
val MAXBASAL = doubleArrayOf(2.0, 5.0, 10.0, 12.0)
|
val MAXBASAL = doubleArrayOf(2.0, 5.0, 10.0, 12.0)
|
||||||
|
|
||||||
|
//LGS Hard limits
|
||||||
|
//No IOB at all
|
||||||
|
val MAXIOB_LGS = 0.0
|
||||||
|
|
||||||
private fun loadAge(): Int {
|
private fun loadAge(): Int {
|
||||||
val sp_age = sp.getString(R.string.key_age, "")
|
val sp_age = sp.getString(R.string.key_age, "")
|
||||||
val age: Int
|
val age: Int
|
||||||
|
|
|
@ -145,7 +145,7 @@ public class SP {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
static public void incInt(int resourceID) {
|
static public void incInt(int resourceID) {
|
||||||
int value = SP.getInt(resourceID, 0) + 1;
|
int value = getInt(resourceID, 0) + 1;
|
||||||
sharedPreferences.edit().putInt(MainApp.gs(resourceID), value).apply();
|
sharedPreferences.edit().putInt(MainApp.gs(resourceID), value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package info.nightscout.androidaps.utils.androidNotification
|
||||||
|
|
||||||
|
import android.app.Notification
|
||||||
|
import android.app.NotificationManager
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import androidx.core.app.NotificationCompat
|
||||||
|
import androidx.core.app.TaskStackBuilder
|
||||||
|
import info.nightscout.androidaps.MainActivity
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class NotificationHolder @Inject constructor(
|
||||||
|
private val resourceHelper: ResourceHelper,
|
||||||
|
private val context: Context
|
||||||
|
) {
|
||||||
|
|
||||||
|
val channelID = "AndroidAPS-Ongoing"
|
||||||
|
val notificationID = 4711
|
||||||
|
var notification: Notification
|
||||||
|
|
||||||
|
init {
|
||||||
|
val stackBuilder = TaskStackBuilder.create(context)
|
||||||
|
.addParentStack(MainActivity::class.java)
|
||||||
|
.addNextIntent(Intent(context, MainApp::class.java))
|
||||||
|
val builder = NotificationCompat.Builder(context, channelID)
|
||||||
|
.setOngoing(true)
|
||||||
|
.setOnlyAlertOnce(true)
|
||||||
|
.setCategory(NotificationCompat.CATEGORY_STATUS)
|
||||||
|
.setSmallIcon(resourceHelper.getNotificationIcon())
|
||||||
|
.setLargeIcon(resourceHelper.decodeResource(resourceHelper.getIcon()))
|
||||||
|
.setContentTitle(resourceHelper.gs(R.string.loading))
|
||||||
|
.setContentIntent(stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT))
|
||||||
|
notification = builder.build()
|
||||||
|
(context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).notify(notificationID, notification)
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,7 +35,7 @@ class TddCalculator @Inject constructor(
|
||||||
) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, mainApp, sp, profileFunction, activePlugin, fabricPrivacy) {
|
) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, mainApp, sp, profileFunction, activePlugin, fabricPrivacy) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
service = TreatmentService() // plugin is not started
|
service = TreatmentService(injector) // plugin is not started
|
||||||
}
|
}
|
||||||
|
|
||||||
fun calculate(days: Long): LongSparseArray<TDD> {
|
fun calculate(days: Long): LongSparseArray<TDD> {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package info.nightscout.androidaps.utils.textValidator
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.core.content.res.TypedArrayUtils
|
|
||||||
import androidx.preference.EditTextPreference
|
import androidx.preference.EditTextPreference
|
||||||
import androidx.preference.EditTextPreference.OnBindEditTextListener
|
import androidx.preference.EditTextPreference.OnBindEditTextListener
|
||||||
import androidx.preference.PreferenceViewHolder
|
import androidx.preference.PreferenceViewHolder
|
||||||
|
@ -23,8 +22,7 @@ class ValidatingEditTextPreference(ctx: Context, attrs: AttributeSet, defStyleAt
|
||||||
: this(ctx, attrs, defStyle, 0)
|
: this(ctx, attrs, defStyle, 0)
|
||||||
|
|
||||||
constructor(ctx: Context, attrs: AttributeSet)
|
constructor(ctx: Context, attrs: AttributeSet)
|
||||||
: this(ctx, attrs, TypedArrayUtils.getAttr(ctx, R.attr.editTextPreferenceStyle,
|
: this(ctx, attrs, R.attr.editTextPreferenceStyle)
|
||||||
R.attr.editTextPreferenceStyle))
|
|
||||||
|
|
||||||
private lateinit var editTextValidator: EditTextValidator
|
private lateinit var editTextValidator: EditTextValidator
|
||||||
|
|
||||||
|
@ -33,4 +31,4 @@ class ValidatingEditTextPreference(ctx: Context, attrs: AttributeSet, defStyleAt
|
||||||
holder?.isDividerAllowedAbove = false
|
holder?.isDividerAllowedAbove = false
|
||||||
holder?.isDividerAllowedBelow = false
|
holder?.isDividerAllowedBelow = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
<string-array name="aps_modeArray">
|
<string-array name="aps_modeArray">
|
||||||
<item>@string/closedloop</item>
|
<item>@string/closedloop</item>
|
||||||
<item>@string/openloop</item>
|
<item>@string/openloop</item>
|
||||||
|
<item>@string/lowglucosesuspend</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="aps_modeValues" translatable="false">
|
<string-array name="aps_modeValues" translatable="false">
|
||||||
<item>closed</item>
|
<item>closed</item>
|
||||||
<item>open</item>
|
<item>open</item>
|
||||||
|
<item>lgs</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="unitsArray">
|
<string-array name="unitsArray">
|
||||||
|
|
|
@ -86,6 +86,7 @@
|
||||||
<color name="ribbonCritical">#ff0400</color>
|
<color name="ribbonCritical">#ff0400</color>
|
||||||
<color name="ribbonTextDefault">#FFFFFF</color>
|
<color name="ribbonTextDefault">#FFFFFF</color>
|
||||||
<color name="ribbonTextWarning">#303030</color>
|
<color name="ribbonTextWarning">#303030</color>
|
||||||
|
<color name="ribbonUnusual">#01017A</color>
|
||||||
<color name="ribbonTextCritical">#FFFFFF</color>
|
<color name="ribbonTextCritical">#FFFFFF</color>
|
||||||
|
|
||||||
<color name="splashBackground">#2E2E2E</color>
|
<color name="splashBackground">#2E2E2E</color>
|
||||||
|
|
|
@ -187,10 +187,12 @@
|
||||||
|
|
||||||
<string name="closedloop">Closed Loop</string>
|
<string name="closedloop">Closed Loop</string>
|
||||||
<string name="openloop">Open Loop</string>
|
<string name="openloop">Open Loop</string>
|
||||||
|
<string name="lowglucosesuspend">Low Glucose Suspend</string>
|
||||||
<string name="disabledloop">Loop Disabled</string>
|
<string name="disabledloop">Loop Disabled</string>
|
||||||
<string name="disableloop">Disable loop</string>
|
<string name="disableloop">Disable loop</string>
|
||||||
<string name="enableloop">Enable loop</string>
|
<string name="enableloop">Enable loop</string>
|
||||||
|
|
||||||
|
<string name="lgs">LGS</string>
|
||||||
<string name="openloop_newsuggestion">New suggestion available</string>
|
<string name="openloop_newsuggestion">New suggestion available</string>
|
||||||
<string name="unsupportednsversion">Unsupported version of Nightscout</string>
|
<string name="unsupportednsversion">Unsupported version of Nightscout</string>
|
||||||
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>
|
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>
|
||||||
|
|
|
@ -310,6 +310,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
@Test
|
@Test
|
||||||
fun iobAMAShouldBeLimited() {
|
fun iobAMAShouldBeLimited() {
|
||||||
// No limit by default
|
// No limit by default
|
||||||
|
`when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("closed")
|
||||||
`when`(sp.getDouble(R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5)
|
`when`(sp.getDouble(R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5)
|
||||||
`when`(sp.getString(R.string.key_age, "")).thenReturn("teenage")
|
`when`(sp.getString(R.string.key_age, "")).thenReturn("teenage")
|
||||||
openAPSAMAPlugin.setPluginEnabled(PluginType.APS, true)
|
openAPSAMAPlugin.setPluginEnabled(PluginType.APS, true)
|
||||||
|
@ -325,6 +326,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
@Test
|
@Test
|
||||||
fun iobSMBShouldBeLimited() {
|
fun iobSMBShouldBeLimited() {
|
||||||
// No limit by default
|
// No limit by default
|
||||||
|
`when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("closed")
|
||||||
`when`(sp.getDouble(R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0)
|
`when`(sp.getDouble(R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0)
|
||||||
`when`(sp.getString(R.string.key_age, "")).thenReturn("teenage")
|
`when`(sp.getString(R.string.key_age, "")).thenReturn("teenage")
|
||||||
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
|
openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true)
|
||||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.receivers.ReceiverStatusStore
|
import info.nightscout.androidaps.receivers.ReceiverStatusStore
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
import info.nightscout.androidaps.utils.HardLimits
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
@ -49,11 +50,15 @@ class LoopPluginTest : TestBase() {
|
||||||
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Mock lateinit var receiverStatusStore: ReceiverStatusStore
|
@Mock lateinit var receiverStatusStore: ReceiverStatusStore
|
||||||
|
|
||||||
|
private lateinit var hardLimits: HardLimits
|
||||||
|
|
||||||
lateinit var loopPlugin: LoopPlugin
|
lateinit var loopPlugin: LoopPlugin
|
||||||
|
|
||||||
val injector = HasAndroidInjector { AndroidInjector { } }
|
val injector = HasAndroidInjector { AndroidInjector { } }
|
||||||
@Before fun prepareMock() {
|
@Before fun prepareMock() {
|
||||||
loopPlugin = LoopPlugin(injector, aapsLogger, rxBus, sp, constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, treatmentsPlugin, virtualPumpPlugin, actionStringHandler, iobCobCalculatorPlugin, receiverStatusStore, fabricPrivacy)
|
hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context)
|
||||||
|
|
||||||
|
loopPlugin = LoopPlugin(injector, aapsLogger, rxBus, sp, constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, treatmentsPlugin, virtualPumpPlugin, actionStringHandler, iobCobCalculatorPlugin, receiverStatusStore, fabricPrivacy, hardLimits)
|
||||||
`when`(activePlugin.getActivePump()).thenReturn(virtualPumpPlugin)
|
`when`(activePlugin.getActivePump()).thenReturn(virtualPumpPlugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +66,7 @@ class LoopPluginTest : TestBase() {
|
||||||
fun testPluginInterface() {
|
fun testPluginInterface() {
|
||||||
`when`(resourceHelper.gs(R.string.loop)).thenReturn("Loop")
|
`when`(resourceHelper.gs(R.string.loop)).thenReturn("Loop")
|
||||||
`when`(resourceHelper.gs(R.string.loop_shortname)).thenReturn("LOOP")
|
`when`(resourceHelper.gs(R.string.loop_shortname)).thenReturn("LOOP")
|
||||||
|
`when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("closed")
|
||||||
val pumpDescription = PumpDescription()
|
val pumpDescription = PumpDescription()
|
||||||
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
|
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
|
||||||
Assert.assertEquals(LoopFragment::class.java.name, loopPlugin.pluginDescription.fragmentClass)
|
Assert.assertEquals(LoopFragment::class.java.name, loopPlugin.pluginDescription.fragmentClass)
|
||||||
|
|
|
@ -230,6 +230,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun iobShouldBeLimited() {
|
@Test fun iobShouldBeLimited() {
|
||||||
|
`when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("closed")
|
||||||
`when`(sp.getDouble(R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5)
|
`when`(sp.getDouble(R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5)
|
||||||
`when`(sp.getString(R.string.key_age, "")).thenReturn("teenage")
|
`when`(sp.getString(R.string.key_age, "")).thenReturn("teenage")
|
||||||
|
|
||||||
|
|
|
@ -1,45 +1,36 @@
|
||||||
package info.nightscout.androidaps.plugins.general.maintenance
|
package info.nightscout.androidaps.plugins.general.maintenance
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.ClassicPrefsFormat
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.ClassicPrefsFormat
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.Prefs
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.Prefs
|
||||||
import info.nightscout.androidaps.testing.mockers.AAPSMocker
|
|
||||||
import info.nightscout.androidaps.testing.utils.SingleStringStorage
|
import info.nightscout.androidaps.testing.utils.SingleStringStorage
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.hamcrest.CoreMatchers
|
import org.hamcrest.CoreMatchers
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.ArgumentMatchers.anyInt
|
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
import org.mockito.Mockito
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(AAPSMocker::class, MainApp::class, File::class)
|
@PrepareForTest(File::class)
|
||||||
|
|
||||||
class ClassicPrefsFormatTest : TestBase() {
|
class ClassicPrefsFormatTest : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
|
|
||||||
@Before
|
|
||||||
fun mock() {
|
|
||||||
AAPSMocker.prepareMock()
|
|
||||||
AAPSMocker.resetMockedSharedPrefs()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun preferenceLoadingTest() {
|
fun preferenceLoadingTest() {
|
||||||
val test = "key1::val1\nkeyB::valB"
|
val test = "key1::val1\nkeyB::valB"
|
||||||
|
|
||||||
val classicFormat = ClassicPrefsFormat(resourceHelper, SingleStringStorage(test))
|
val classicFormat = ClassicPrefsFormat(resourceHelper, SingleStringStorage(test))
|
||||||
val prefs = classicFormat.loadPreferences(AAPSMocker.getMockedFile(), "")
|
val prefs = classicFormat.loadPreferences(getMockedFile(), "")
|
||||||
|
|
||||||
Assert.assertThat(prefs.values.size, CoreMatchers.`is`(2))
|
Assert.assertThat(prefs.values.size, CoreMatchers.`is`(2))
|
||||||
Assert.assertThat(prefs.values["key1"], CoreMatchers.`is`("val1"))
|
Assert.assertThat(prefs.values["key1"], CoreMatchers.`is`("val1"))
|
||||||
|
@ -59,7 +50,14 @@ class ClassicPrefsFormatTest : TestBase() {
|
||||||
mapOf()
|
mapOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
classicFormat.savePreferences(AAPSMocker.getMockedFile(), prefs)
|
classicFormat.savePreferences(getMockedFile(), prefs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getMockedFile(): File {
|
||||||
|
val file = Mockito.mock(File::class.java)
|
||||||
|
`when`(file.exists()).thenReturn(true)
|
||||||
|
`when`(file.canRead()).thenReturn(true)
|
||||||
|
`when`(file.canWrite()).thenReturn(true)
|
||||||
|
return file
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.general.maintenance
|
package info.nightscout.androidaps.plugins.general.maintenance
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.*
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.*
|
||||||
import info.nightscout.androidaps.testing.mockers.AAPSMocker
|
|
||||||
import info.nightscout.androidaps.testing.utils.SingleStringStorage
|
import info.nightscout.androidaps.testing.utils.SingleStringStorage
|
||||||
import info.nightscout.androidaps.utils.CryptoUtil
|
import info.nightscout.androidaps.utils.CryptoUtil
|
||||||
import info.nightscout.androidaps.utils.assumeAES256isSupported
|
import info.nightscout.androidaps.utils.assumeAES256isSupported
|
||||||
|
@ -24,19 +22,17 @@ import java.io.File
|
||||||
|
|
||||||
@PowerMockIgnore("javax.crypto.*")
|
@PowerMockIgnore("javax.crypto.*")
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(AAPSMocker::class, MainApp::class, File::class, ResourceHelper::class)
|
@PrepareForTest(File::class)
|
||||||
|
|
||||||
class EncryptedPrefsFormatTest : TestBase() {
|
class EncryptedPrefsFormatTest : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
|
|
||||||
var cryptoUtil: CryptoUtil = CryptoUtil(aapsLogger)
|
private var cryptoUtil: CryptoUtil = CryptoUtil(aapsLogger)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun mock() {
|
fun mock() {
|
||||||
AAPSMocker.prepareMock()
|
|
||||||
AAPSMocker.resetMockedSharedPrefs()
|
|
||||||
Mockito.`when`(resourceHelper.gs(ArgumentMatchers.anyInt())).thenReturn("mock translation")
|
Mockito.`when`(resourceHelper.gs(ArgumentMatchers.anyInt())).thenReturn("mock translation")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +52,7 @@ class EncryptedPrefsFormatTest : TestBase() {
|
||||||
|
|
||||||
val storage = SingleStringStorage(frozenPrefs)
|
val storage = SingleStringStorage(frozenPrefs)
|
||||||
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
||||||
val prefs = encryptedFormat.loadPreferences(AAPSMocker.getMockedFile(), "sikret")
|
val prefs = encryptedFormat.loadPreferences(getMockedFile(), "sikret")
|
||||||
|
|
||||||
assumeAES256isSupported(cryptoUtil)
|
assumeAES256isSupported(cryptoUtil)
|
||||||
|
|
||||||
|
@ -82,7 +78,7 @@ class EncryptedPrefsFormatTest : TestBase() {
|
||||||
PrefsMetadataKey.ENCRYPTION to PrefMetadata(EncryptedPrefsFormat.FORMAT_KEY_ENC, PrefsStatus.OK)
|
PrefsMetadataKey.ENCRYPTION to PrefMetadata(EncryptedPrefsFormat.FORMAT_KEY_ENC, PrefsStatus.OK)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
encryptedFormat.savePreferences(AAPSMocker.getMockedFile(), prefs, "sikret")
|
encryptedFormat.savePreferences(getMockedFile(), prefs, "sikret")
|
||||||
aapsLogger.debug(storage.contents)
|
aapsLogger.debug(storage.contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +95,8 @@ class EncryptedPrefsFormatTest : TestBase() {
|
||||||
PrefsMetadataKey.ENCRYPTION to PrefMetadata(EncryptedPrefsFormat.FORMAT_KEY_ENC, PrefsStatus.OK)
|
PrefsMetadataKey.ENCRYPTION to PrefMetadata(EncryptedPrefsFormat.FORMAT_KEY_ENC, PrefsStatus.OK)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
encryptedFormat.savePreferences(AAPSMocker.getMockedFile(), prefsIn, "tajemnica")
|
encryptedFormat.savePreferences(getMockedFile(), prefsIn, "tajemnica")
|
||||||
val prefsOut = encryptedFormat.loadPreferences(AAPSMocker.getMockedFile(), "tajemnica")
|
val prefsOut = encryptedFormat.loadPreferences(getMockedFile(), "tajemnica")
|
||||||
|
|
||||||
assumeAES256isSupported(cryptoUtil)
|
assumeAES256isSupported(cryptoUtil)
|
||||||
|
|
||||||
|
@ -129,7 +125,7 @@ class EncryptedPrefsFormatTest : TestBase() {
|
||||||
|
|
||||||
val storage = SingleStringStorage(frozenPrefs)
|
val storage = SingleStringStorage(frozenPrefs)
|
||||||
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
||||||
val prefs = encryptedFormat.loadPreferences(AAPSMocker.getMockedFile(), "it-is-NOT-right-secret")
|
val prefs = encryptedFormat.loadPreferences(getMockedFile(), "it-is-NOT-right-secret")
|
||||||
|
|
||||||
Assert.assertThat(prefs.values.size, CoreMatchers.`is`(0))
|
Assert.assertThat(prefs.values.size, CoreMatchers.`is`(0))
|
||||||
|
|
||||||
|
@ -156,7 +152,7 @@ class EncryptedPrefsFormatTest : TestBase() {
|
||||||
|
|
||||||
val storage = SingleStringStorage(frozenPrefs)
|
val storage = SingleStringStorage(frozenPrefs)
|
||||||
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
||||||
val prefs = encryptedFormat.loadPreferences(AAPSMocker.getMockedFile(), "sikret")
|
val prefs = encryptedFormat.loadPreferences(getMockedFile(), "sikret")
|
||||||
|
|
||||||
assumeAES256isSupported(cryptoUtil)
|
assumeAES256isSupported(cryptoUtil)
|
||||||
|
|
||||||
|
@ -183,7 +179,7 @@ class EncryptedPrefsFormatTest : TestBase() {
|
||||||
|
|
||||||
val storage = SingleStringStorage(frozenPrefs)
|
val storage = SingleStringStorage(frozenPrefs)
|
||||||
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
||||||
val prefs = encryptedFormat.loadPreferences(AAPSMocker.getMockedFile(), "sikret")
|
val prefs = encryptedFormat.loadPreferences(getMockedFile(), "sikret")
|
||||||
|
|
||||||
Assert.assertThat(prefs.values.size, CoreMatchers.`is`(0))
|
Assert.assertThat(prefs.values.size, CoreMatchers.`is`(0))
|
||||||
Assert.assertThat(prefs.metadata[PrefsMetadataKey.ENCRYPTION]?.status, CoreMatchers.`is`(PrefsStatus.ERROR))
|
Assert.assertThat(prefs.metadata[PrefsMetadataKey.ENCRYPTION]?.status, CoreMatchers.`is`(PrefsStatus.ERROR))
|
||||||
|
@ -198,7 +194,7 @@ class EncryptedPrefsFormatTest : TestBase() {
|
||||||
|
|
||||||
val storage = SingleStringStorage(frozenPrefs)
|
val storage = SingleStringStorage(frozenPrefs)
|
||||||
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
||||||
val prefs = encryptedFormat.loadPreferences(AAPSMocker.getMockedFile(), "sikret")
|
val prefs = encryptedFormat.loadPreferences(getMockedFile(), "sikret")
|
||||||
|
|
||||||
Assert.assertThat(prefs.values.size, CoreMatchers.`is`(0))
|
Assert.assertThat(prefs.values.size, CoreMatchers.`is`(0))
|
||||||
Assert.assertThat(prefs.metadata[PrefsMetadataKey.FILE_FORMAT]?.status, CoreMatchers.`is`(PrefsStatus.ERROR))
|
Assert.assertThat(prefs.metadata[PrefsMetadataKey.FILE_FORMAT]?.status, CoreMatchers.`is`(PrefsStatus.ERROR))
|
||||||
|
@ -210,7 +206,7 @@ class EncryptedPrefsFormatTest : TestBase() {
|
||||||
|
|
||||||
val storage = SingleStringStorage(frozenPrefs)
|
val storage = SingleStringStorage(frozenPrefs)
|
||||||
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
||||||
encryptedFormat.loadPreferences(AAPSMocker.getMockedFile(), "sikret")
|
encryptedFormat.loadPreferences(getMockedFile(), "sikret")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = PrefFormatError::class)
|
@Test(expected = PrefFormatError::class)
|
||||||
|
@ -229,7 +225,14 @@ class EncryptedPrefsFormatTest : TestBase() {
|
||||||
|
|
||||||
val storage = SingleStringStorage(frozenPrefs)
|
val storage = SingleStringStorage(frozenPrefs)
|
||||||
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
val encryptedFormat = EncryptedPrefsFormat(resourceHelper, cryptoUtil, storage)
|
||||||
encryptedFormat.loadPreferences(AAPSMocker.getMockedFile(), "sikret")
|
encryptedFormat.loadPreferences(getMockedFile(), "sikret")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getMockedFile(): File {
|
||||||
|
val file = Mockito.mock(File::class.java)
|
||||||
|
Mockito.`when`(file.exists()).thenReturn(true)
|
||||||
|
Mockito.`when`(file.canRead()).thenReturn(true)
|
||||||
|
Mockito.`when`(file.canWrite()).thenReturn(true)
|
||||||
|
return file
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
@ -14,11 +15,15 @@ open class DanaRTestBase : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
@Mock lateinit var profileFunction: ProfileFunction
|
||||||
|
@Mock lateinit var activePluginProvider: ActivePluginProvider
|
||||||
|
|
||||||
val injector = HasAndroidInjector {
|
val injector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
if (it is TemporaryBasal) {
|
if (it is TemporaryBasal) {
|
||||||
|
it.aapsLogger = aapsLogger
|
||||||
|
it.activePlugin = activePluginProvider
|
||||||
it.profileFunction = profileFunction
|
it.profileFunction = profileFunction
|
||||||
|
it.sp = sp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ class MsgStatusBolusExtendedTest : DanaRTestBase() {
|
||||||
@Test
|
@Test
|
||||||
fun runTest() {
|
fun runTest() {
|
||||||
`when`(activePlugin.activeTreatments).thenReturn(treatmentsPlugin)
|
`when`(activePlugin.activeTreatments).thenReturn(treatmentsPlugin)
|
||||||
val packet = MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)
|
val packet = MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
val array = ByteArray(100)
|
val array = ByteArray(100)
|
||||||
putByteToArray(array, 0, 1)
|
putByteToArray(array, 0, 1)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
import info.nightscout.androidaps.TestBaseWithProfile
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -17,7 +16,10 @@ open class DanaRSTestBase : TestBaseWithProfile() {
|
||||||
val injector = HasAndroidInjector {
|
val injector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
if (it is TemporaryBasal) {
|
if (it is TemporaryBasal) {
|
||||||
|
it.aapsLogger = aapsLogger
|
||||||
|
it.activePlugin = activePluginProvider
|
||||||
it.profileFunction = profileFunction
|
it.profileFunction = profileFunction
|
||||||
|
it.sp = sp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.RawHistoryPage;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.RawHistoryPage;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
//import uk.org.lidalia.slf4jtest.TestLogger;
|
//import uk.org.lidalia.slf4jtest.TestLogger;
|
||||||
|
|
|
@ -37,7 +37,10 @@ class TreatmentsPluginTest : TestBaseWithProfile() {
|
||||||
val injector = HasAndroidInjector {
|
val injector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
if (it is TemporaryBasal) {
|
if (it is TemporaryBasal) {
|
||||||
|
it.aapsLogger = aapsLogger
|
||||||
|
it.activePlugin = activePluginProvider
|
||||||
it.profileFunction = profileFunction
|
it.profileFunction = profileFunction
|
||||||
|
it.sp = sp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
package info.nightscout.androidaps.testing.mockers;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
|
|
||||||
import org.mockito.ArgumentMatchers;
|
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.testing.mocks.SharedPreferencesMock;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import static org.powermock.api.mockito.PowerMockito.mockStatic;
|
|
||||||
|
|
||||||
public class AAPSMocker {
|
|
||||||
|
|
||||||
private static final Map<String, SharedPreferences> mockedSharedPrefs = new HashMap<>();
|
|
||||||
|
|
||||||
public static void prepareMock() throws Exception {
|
|
||||||
Context mockedContext = mock(Context.class);
|
|
||||||
mockStatic(MainApp.class, InvocationOnMock::callRealMethod);
|
|
||||||
|
|
||||||
PowerMockito.when(mockedContext, "getSharedPreferences", ArgumentMatchers.anyString(), ArgumentMatchers.anyInt()).thenAnswer(invocation -> {
|
|
||||||
|
|
||||||
final String key = invocation.getArgument(0);
|
|
||||||
if (mockedSharedPrefs.containsKey(key)) {
|
|
||||||
return mockedSharedPrefs.get(key);
|
|
||||||
} else {
|
|
||||||
SharedPreferencesMock newPrefs = new SharedPreferencesMock();
|
|
||||||
mockedSharedPrefs.put(key, newPrefs);
|
|
||||||
return newPrefs;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
resetMockedSharedPrefs();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resetMockedSharedPrefs() {
|
|
||||||
mockedSharedPrefs.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getMockedFile() {
|
|
||||||
File file = mock(File.class);
|
|
||||||
when(file.exists()).thenReturn(true);
|
|
||||||
when(file.canRead()).thenReturn(true);
|
|
||||||
when(file.canWrite()).thenReturn(true);
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,20 +3,14 @@ package info.nightscout.androidaps.testing.utils
|
||||||
import info.nightscout.androidaps.utils.storage.Storage
|
import info.nightscout.androidaps.utils.storage.Storage
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class SingleStringStorage : Storage {
|
class SingleStringStorage(var contents: String) : Storage {
|
||||||
|
|
||||||
var contents: String = ""
|
|
||||||
|
|
||||||
constructor(contents: String) {
|
|
||||||
this.contents = contents
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getFileContents(file: File): String {
|
override fun getFileContents(file: File): String {
|
||||||
return contents
|
return contents
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun putFileContents(file: File, putContents: String) {
|
override fun putFileContents(file: File, contents: String) {
|
||||||
contents = putContents
|
this.contents = contents
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
|
Loading…
Reference in a new issue