2016-06-05 01:40:35 +02:00
|
|
|
package info.nightscout.androidaps;
|
|
|
|
|
2017-07-24 01:50:27 +02:00
|
|
|
import android.content.IntentFilter;
|
2016-06-24 17:16:17 +02:00
|
|
|
import android.content.res.Resources;
|
2017-09-06 20:00:36 +02:00
|
|
|
import android.os.SystemClock;
|
2019-07-05 01:22:45 +02:00
|
|
|
|
2019-12-24 16:07:17 +01:00
|
|
|
import androidx.annotation.ColorRes;
|
2019-05-16 13:57:37 +02:00
|
|
|
import androidx.annotation.PluralsRes;
|
2019-12-24 16:07:17 +01:00
|
|
|
import androidx.annotation.StringRes;
|
|
|
|
import androidx.core.content.ContextCompat;
|
2019-05-16 13:57:37 +02:00
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2016-06-24 17:48:11 +02:00
|
|
|
import com.crashlytics.android.Crashlytics;
|
2019-04-05 00:32:26 +02:00
|
|
|
import com.google.firebase.analytics.FirebaseAnalytics;
|
2016-06-05 01:40:35 +02:00
|
|
|
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
|
|
|
|
2017-12-22 02:55:40 +01:00
|
|
|
import net.danlew.android.joda.JodaTimeAndroid;
|
|
|
|
|
2019-12-13 13:12:36 +01:00
|
|
|
import org.json.JSONException;
|
2016-08-05 23:54:03 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2018-03-05 22:30:48 +01:00
|
|
|
import java.io.File;
|
2016-08-05 23:54:03 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2019-12-23 13:27:15 +01:00
|
|
|
import javax.inject.Inject;
|
|
|
|
|
2019-12-13 02:12:19 +01:00
|
|
|
import dagger.android.AndroidInjector;
|
2019-12-21 20:17:08 +01:00
|
|
|
import dagger.android.DaggerApplication;
|
2019-12-13 13:12:36 +01:00
|
|
|
import info.nightscout.androidaps.data.Profile;
|
2016-08-05 23:54:03 +02:00
|
|
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
2019-12-13 02:12:19 +01:00
|
|
|
import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent;
|
2016-07-18 20:19:55 +02:00
|
|
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
2018-03-31 00:36:03 +02:00
|
|
|
import info.nightscout.androidaps.interfaces.PluginType;
|
|
|
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
2019-12-28 01:52:20 +01:00
|
|
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
2018-07-29 15:37:28 +02:00
|
|
|
import info.nightscout.androidaps.logging.L;
|
2019-12-28 01:52:20 +01:00
|
|
|
import info.nightscout.androidaps.logging.LTag;
|
2019-03-02 14:37:53 +01:00
|
|
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
2019-02-28 23:16:50 +01:00
|
|
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
2019-12-13 13:12:36 +01:00
|
|
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
2019-03-02 15:13:42 +01:00
|
|
|
import info.nightscout.androidaps.plugins.constraints.dstHelper.DstHelperPlugin;
|
2019-02-28 23:16:50 +01:00
|
|
|
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
|
2019-10-25 11:38:23 +02:00
|
|
|
import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin;
|
2019-03-07 10:32:29 +01:00
|
|
|
import info.nightscout.androidaps.plugins.constraints.storage.StorageConstraintPlugin;
|
2019-10-25 11:38:23 +02:00
|
|
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerPlugin;
|
2019-09-01 13:43:11 +02:00
|
|
|
import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin;
|
2018-09-18 10:05:19 +02:00
|
|
|
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin;
|
2019-03-02 14:37:53 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin;
|
2019-02-28 23:16:50 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.food.FoodPlugin;
|
2019-03-02 14:37:53 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.maintenance.LoggerUtils;
|
2019-02-28 23:16:50 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
|
|
|
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin;
|
2019-03-02 14:37:53 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
|
2019-12-30 00:53:44 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin;
|
2019-03-02 14:37:53 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.wear.WearPlugin;
|
2019-12-28 15:00:16 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatusLinePlugin;
|
2019-03-02 14:37:53 +01:00
|
|
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefUltraRapidActingPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
2019-02-28 23:16:50 +01:00
|
|
|
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
|
2019-02-26 20:38:27 +01:00
|
|
|
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
|
|
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin;
|
2019-07-05 17:04:54 +02:00
|
|
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
2019-02-26 20:38:27 +01:00
|
|
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
2019-02-28 23:16:50 +01:00
|
|
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
|
|
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
|
|
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
|
2019-12-30 23:26:48 +01:00
|
|
|
import info.nightscout.androidaps.plugins.source.NSClientSourcePlugin;
|
2019-12-13 02:12:19 +01:00
|
|
|
import info.nightscout.androidaps.plugins.source.RandomBgPlugin;
|
2019-12-30 23:26:48 +01:00
|
|
|
import info.nightscout.androidaps.plugins.source.DexcomPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.source.EversensePlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.source.GlimpPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.source.MM640gPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.source.PoctechPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.source.TomatoPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.source.XdripPlugin;
|
2019-02-28 23:16:50 +01:00
|
|
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
2017-07-24 01:50:27 +02:00
|
|
|
import info.nightscout.androidaps.receivers.DataReceiver;
|
2016-12-16 02:00:53 +01:00
|
|
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
2019-07-18 19:09:49 +02:00
|
|
|
import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver;
|
2018-07-29 15:37:28 +02:00
|
|
|
import info.nightscout.androidaps.services.Intents;
|
2019-12-13 02:12:19 +01:00
|
|
|
import info.nightscout.androidaps.utils.ActivityMonitor;
|
2019-02-26 20:38:27 +01:00
|
|
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
2019-10-25 11:38:23 +02:00
|
|
|
import info.nightscout.androidaps.utils.LocaleHelper;
|
2019-12-13 13:12:36 +01:00
|
|
|
import info.nightscout.androidaps.utils.SP;
|
2016-06-24 17:48:11 +02:00
|
|
|
import io.fabric.sdk.android.Fabric;
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2019-10-22 15:24:37 +02:00
|
|
|
import static info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt.triggerCheckVersion;
|
2019-04-22 14:10:12 +02:00
|
|
|
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2019-12-21 20:17:08 +01:00
|
|
|
public class MainApp extends DaggerApplication {
|
|
|
|
static Logger log = LoggerFactory.getLogger(L.CORE);
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2019-12-21 20:17:08 +01:00
|
|
|
static MainApp sInstance;
|
2016-07-07 10:34:20 +02:00
|
|
|
public static Resources sResources;
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2019-12-21 20:17:08 +01:00
|
|
|
static FirebaseAnalytics mFirebaseAnalytics;
|
2019-04-05 00:32:26 +02:00
|
|
|
|
2019-12-21 20:17:08 +01:00
|
|
|
static DatabaseHelper sDatabaseHelper = null;
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2019-12-21 20:17:08 +01:00
|
|
|
static ArrayList<PluginBase> pluginsList = null;
|
2016-07-18 20:19:55 +02:00
|
|
|
|
2019-12-21 20:17:08 +01:00
|
|
|
static DataReceiver dataReceiver = new DataReceiver();
|
2019-07-18 19:09:49 +02:00
|
|
|
TimeDateOrTZChangeReceiver timeDateOrTZChangeReceiver;
|
2017-07-24 01:50:27 +02:00
|
|
|
|
2018-03-05 22:30:48 +01:00
|
|
|
public static boolean devBranch;
|
|
|
|
public static boolean engineeringMode;
|
|
|
|
|
2019-12-31 09:41:02 +01:00
|
|
|
@Inject AAPSLogger aapsLogger;
|
|
|
|
@Inject ActivityMonitor activityMonitor;
|
2019-12-27 04:17:49 +01:00
|
|
|
|
2019-12-30 00:53:44 +01:00
|
|
|
@Inject ActionsPlugin actionsPlugin;
|
|
|
|
@Inject AutomationPlugin automationPlugin;
|
|
|
|
@Inject CareportalPlugin careportalPlugin;
|
2019-12-28 15:00:16 +01:00
|
|
|
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
2019-12-30 00:53:44 +01:00
|
|
|
@Inject DanaRPlugin danaRPlugin;
|
|
|
|
@Inject DanaRSPlugin danaRSPlugin;
|
|
|
|
@Inject DanaRv2Plugin danaRv2Plugin;
|
|
|
|
@Inject DanaRKoreanPlugin danaRKoreanPlugin;
|
2020-01-02 20:48:36 +01:00
|
|
|
@Inject DstHelperPlugin dstHelperPlugin;
|
2019-12-27 04:17:49 +01:00
|
|
|
@Inject InsulinOrefFreePeakPlugin insulinOrefFreePeakPlugin;
|
|
|
|
@Inject InsulinOrefRapidActingPlugin insulinOrefRapidActingPlugin;
|
|
|
|
@Inject InsulinOrefUltraRapidActingPlugin insulinOrefUltraRapidActingPlugin;
|
2019-12-30 13:40:42 +01:00
|
|
|
@Inject IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
2019-12-30 00:53:44 +01:00
|
|
|
@Inject LocalProfilePlugin localProfilePlugin;
|
2019-12-30 11:35:49 +01:00
|
|
|
@Inject LoopPlugin loopPlugin;
|
2019-12-30 00:53:44 +01:00
|
|
|
@Inject ObjectivesPlugin objectivesPlugin;
|
2019-12-28 01:14:04 +01:00
|
|
|
@Inject SafetyPlugin safetyPlugin;
|
2019-12-27 04:17:49 +01:00
|
|
|
@Inject SmsCommunicatorPlugin smsCommunicatorPlugin;
|
2019-12-28 01:14:04 +01:00
|
|
|
@Inject OpenAPSMAPlugin openAPSMAPlugin;
|
|
|
|
@Inject OpenAPSAMAPlugin openAPSAMAPlugin;
|
|
|
|
@Inject OpenAPSSMBPlugin openAPSSMBPlugin;
|
2019-12-30 00:53:44 +01:00
|
|
|
@Inject OverviewPlugin overviewPlugin;
|
2019-12-30 10:02:40 +01:00
|
|
|
@Inject RandomBgPlugin randomBgPlugin;
|
2019-12-30 23:26:48 +01:00
|
|
|
@Inject DexcomPlugin dexcomPlugin;
|
|
|
|
@Inject EversensePlugin eversensePlugin;
|
|
|
|
@Inject GlimpPlugin glimpPlugin;
|
2020-01-01 23:23:16 +01:00
|
|
|
@Inject MaintenancePlugin maintenancePlugin;
|
2019-12-30 23:26:48 +01:00
|
|
|
@Inject MM640gPlugin mM640GPlugin;
|
|
|
|
@Inject NSClientSourcePlugin nSClientSourcePlugin;
|
|
|
|
@Inject PoctechPlugin poctechPlugin;
|
|
|
|
@Inject TomatoPlugin tomatoPlugin;
|
|
|
|
@Inject XdripPlugin xdripPlugin;
|
2019-12-28 15:00:16 +01:00
|
|
|
@Inject StatusLinePlugin statusLinePlugin;
|
2019-12-30 00:53:44 +01:00
|
|
|
@Inject TidepoolPlugin tidepoolPlugin;
|
2019-12-28 22:51:04 +01:00
|
|
|
@Inject TreatmentsPlugin treatmentsPlugin;
|
2019-12-30 00:53:44 +01:00
|
|
|
@Inject VirtualPumpPlugin virtualPumpPlugin;
|
|
|
|
@Inject VersionCheckerPlugin versionCheckerPlugin;
|
2019-12-30 19:52:51 +01:00
|
|
|
@Inject WearPlugin wearPlugin;
|
2019-12-23 13:27:15 +01:00
|
|
|
|
2016-06-05 01:40:35 +02:00
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
|
|
|
super.onCreate();
|
2019-12-13 02:12:19 +01:00
|
|
|
|
2018-08-07 21:45:35 +02:00
|
|
|
log.debug("onCreate");
|
2018-02-22 13:30:36 +01:00
|
|
|
sInstance = this;
|
|
|
|
sResources = getResources();
|
2019-10-25 11:38:23 +02:00
|
|
|
LocaleHelper.INSTANCE.update(this);
|
2018-03-31 00:36:03 +02:00
|
|
|
sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class);
|
2018-02-22 13:30:36 +01:00
|
|
|
|
2019-12-31 12:01:15 +01:00
|
|
|
/* TODO: put back
|
2019-11-12 13:44:02 +01:00
|
|
|
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> {
|
|
|
|
if (ex instanceof InternalError) {
|
|
|
|
// usually the app trying to spawn a thread while being killed
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
log.error("Uncaught exception crashing app", ex);
|
|
|
|
});
|
2019-12-31 12:01:15 +01:00
|
|
|
*/
|
2019-08-22 11:12:15 +02:00
|
|
|
|
2018-02-22 13:30:36 +01:00
|
|
|
try {
|
|
|
|
if (FabricPrivacy.fabricEnabled()) {
|
|
|
|
Fabric.with(this, new Crashlytics());
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
2018-07-29 15:37:28 +02:00
|
|
|
log.error("Error with Fabric init! " + e);
|
2018-02-22 13:30:36 +01:00
|
|
|
}
|
|
|
|
|
2019-12-31 09:41:02 +01:00
|
|
|
registerActivityLifecycleCallbacks(activityMonitor);
|
2019-10-15 23:50:09 +02:00
|
|
|
|
2019-04-05 00:32:26 +02:00
|
|
|
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
|
2019-12-25 10:11:14 +01:00
|
|
|
mFirebaseAnalytics.setAnalyticsCollectionEnabled(!Boolean.getBoolean("disableFirebase") && FabricPrivacy.fabricEnabled());
|
2019-04-05 00:32:26 +02:00
|
|
|
|
2017-12-22 02:55:40 +01:00
|
|
|
JodaTimeAndroid.init(this);
|
2018-02-22 13:30:36 +01:00
|
|
|
|
2016-11-08 19:10:25 +01:00
|
|
|
log.info("Version: " + BuildConfig.VERSION_NAME);
|
|
|
|
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
|
2019-04-11 10:16:52 +02:00
|
|
|
log.info("Remote: " + BuildConfig.REMOTE);
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2018-07-23 20:58:20 +02:00
|
|
|
String extFilesDir = LoggerUtils.getLogDirectory();
|
2018-03-31 00:36:03 +02:00
|
|
|
File engineeringModeSemaphore = new File(extFilesDir, "engineering_mode");
|
2018-03-18 19:48:41 +01:00
|
|
|
|
|
|
|
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile();
|
2019-04-25 16:13:21 +02:00
|
|
|
devBranch = BuildConfig.VERSION.contains("-") || BuildConfig.VERSION.matches(".*[a-zA-Z]+.*");
|
2018-03-18 19:48:41 +01:00
|
|
|
|
2017-07-24 01:50:27 +02:00
|
|
|
registerLocalBroadcastReceiver();
|
|
|
|
|
2019-04-22 14:10:12 +02:00
|
|
|
//trigger here to see the new version on app start after an update
|
|
|
|
triggerCheckVersion();
|
|
|
|
|
2016-07-18 20:19:55 +02:00
|
|
|
if (pluginsList == null) {
|
2016-08-05 23:54:03 +02:00
|
|
|
pluginsList = new ArrayList<>();
|
2016-07-18 20:19:55 +02:00
|
|
|
// Register all tabs in app here
|
2019-12-30 00:53:44 +01:00
|
|
|
pluginsList.add(overviewPlugin);
|
2019-12-30 13:40:42 +01:00
|
|
|
pluginsList.add(iobCobCalculatorPlugin);
|
2019-12-30 00:53:44 +01:00
|
|
|
if (!Config.NSCLIENT) pluginsList.add(actionsPlugin);
|
2019-12-27 04:17:49 +01:00
|
|
|
pluginsList.add(insulinOrefRapidActingPlugin);
|
|
|
|
pluginsList.add(insulinOrefUltraRapidActingPlugin);
|
2019-12-23 13:27:15 +01:00
|
|
|
pluginsList.add(insulinOrefFreePeakPlugin);
|
2017-06-24 11:04:09 +02:00
|
|
|
pluginsList.add(SensitivityOref0Plugin.getPlugin());
|
2017-06-30 11:56:36 +02:00
|
|
|
pluginsList.add(SensitivityAAPSPlugin.getPlugin());
|
2017-07-07 15:08:21 +02:00
|
|
|
pluginsList.add(SensitivityWeightedAveragePlugin.getPlugin());
|
2018-06-19 20:41:40 +02:00
|
|
|
pluginsList.add(SensitivityOref1Plugin.getPlugin());
|
2019-12-30 00:53:44 +01:00
|
|
|
if (Config.PUMPDRIVERS) pluginsList.add(danaRPlugin);
|
|
|
|
if (Config.PUMPDRIVERS) pluginsList.add(danaRKoreanPlugin);
|
|
|
|
if (Config.PUMPDRIVERS) pluginsList.add(danaRv2Plugin);
|
|
|
|
if (Config.PUMPDRIVERS) pluginsList.add(danaRSPlugin);
|
2019-03-02 12:18:06 +01:00
|
|
|
if (Config.PUMPDRIVERS) pluginsList.add(LocalInsightPlugin.getPlugin());
|
2018-08-07 21:07:43 +02:00
|
|
|
if (Config.PUMPDRIVERS) pluginsList.add(ComboPlugin.getPlugin());
|
2019-10-22 08:02:28 +02:00
|
|
|
if (Config.PUMPDRIVERS) pluginsList.add(MedtronicPumpPlugin.getPlugin());
|
|
|
|
if (!Config.NSCLIENT) pluginsList.add(MDIPlugin.getPlugin());
|
2019-12-30 00:53:44 +01:00
|
|
|
pluginsList.add(virtualPumpPlugin);
|
|
|
|
pluginsList.add(careportalPlugin);
|
2019-12-30 11:35:49 +01:00
|
|
|
if (Config.APS) pluginsList.add(loopPlugin);
|
2019-12-28 01:14:04 +01:00
|
|
|
if (Config.APS) pluginsList.add(openAPSMAPlugin);
|
|
|
|
if (Config.APS) pluginsList.add(openAPSAMAPlugin);
|
|
|
|
if (Config.APS) pluginsList.add(openAPSSMBPlugin);
|
2017-10-07 17:48:03 +02:00
|
|
|
pluginsList.add(NSProfilePlugin.getPlugin());
|
2019-12-30 00:53:44 +01:00
|
|
|
if (!Config.NSCLIENT) pluginsList.add(localProfilePlugin);
|
2019-12-28 22:51:04 +01:00
|
|
|
pluginsList.add(treatmentsPlugin);
|
2019-12-28 01:14:04 +01:00
|
|
|
if (!Config.NSCLIENT) pluginsList.add(safetyPlugin);
|
2019-12-30 00:53:44 +01:00
|
|
|
if (!Config.NSCLIENT) pluginsList.add(versionCheckerPlugin);
|
2019-10-24 23:06:43 +02:00
|
|
|
if (Config.APS) pluginsList.add(StorageConstraintPlugin.getPlugin());
|
|
|
|
if (Config.APS) pluginsList.add(SignatureVerifierPlugin.getPlugin());
|
2019-12-30 00:53:44 +01:00
|
|
|
if (Config.APS) pluginsList.add(objectivesPlugin);
|
2019-12-30 23:26:48 +01:00
|
|
|
pluginsList.add(xdripPlugin);
|
|
|
|
pluginsList.add(nSClientSourcePlugin);
|
|
|
|
pluginsList.add(mM640GPlugin);
|
|
|
|
pluginsList.add(glimpPlugin);
|
|
|
|
pluginsList.add(dexcomPlugin);
|
|
|
|
pluginsList.add(poctechPlugin);
|
|
|
|
pluginsList.add(tomatoPlugin);
|
|
|
|
pluginsList.add(eversensePlugin);
|
2019-12-30 10:02:40 +01:00
|
|
|
pluginsList.add(randomBgPlugin);
|
2019-12-27 04:17:49 +01:00
|
|
|
if (!Config.NSCLIENT) pluginsList.add(smsCommunicatorPlugin);
|
2017-10-17 20:55:23 +02:00
|
|
|
pluginsList.add(FoodPlugin.getPlugin());
|
2016-11-17 16:38:58 +01:00
|
|
|
|
2019-12-30 19:52:51 +01:00
|
|
|
pluginsList.add(wearPlugin);
|
2019-12-28 15:00:16 +01:00
|
|
|
pluginsList.add(statusLinePlugin);
|
2018-06-17 23:33:32 +02:00
|
|
|
pluginsList.add(PersistentNotificationPlugin.getPlugin());
|
2018-03-23 22:44:37 +01:00
|
|
|
pluginsList.add(NSClientPlugin.getPlugin());
|
2019-12-30 00:53:44 +01:00
|
|
|
// if (engineeringMode) pluginsList.add(tidepoolPlugin);
|
2020-01-01 23:23:16 +01:00
|
|
|
pluginsList.add(maintenancePlugin);
|
2019-12-30 00:53:44 +01:00
|
|
|
pluginsList.add(automationPlugin);
|
2020-01-02 20:48:36 +01:00
|
|
|
pluginsList.add(dstHelperPlugin);
|
2016-11-17 16:38:58 +01:00
|
|
|
|
2019-12-27 04:17:49 +01:00
|
|
|
pluginsList.add(configBuilderPlugin);
|
2016-07-18 20:19:55 +02:00
|
|
|
|
2019-12-27 04:17:49 +01:00
|
|
|
configBuilderPlugin.initialize();
|
2016-07-18 20:19:55 +02:00
|
|
|
}
|
2018-03-19 17:06:22 +01:00
|
|
|
|
2018-07-10 17:55:50 +02:00
|
|
|
NSUpload.uploadAppStart();
|
2017-08-23 13:28:07 +02:00
|
|
|
|
2019-12-27 04:17:49 +01:00
|
|
|
final PumpInterface pump = configBuilderPlugin.getActivePump();
|
2018-03-31 00:36:03 +02:00
|
|
|
if (pump != null) {
|
|
|
|
new Thread(() -> {
|
2017-09-06 20:00:36 +02:00
|
|
|
SystemClock.sleep(5000);
|
2019-12-27 04:17:49 +01:00
|
|
|
configBuilderPlugin.getCommandQueue().readStatus("Initialization", null);
|
2018-03-31 00:36:03 +02:00
|
|
|
}).start();
|
|
|
|
}
|
2019-12-13 13:12:36 +01:00
|
|
|
|
2019-12-24 16:07:17 +01:00
|
|
|
new Thread(() -> KeepAliveReceiver.setAlarm(this)).start();
|
2019-12-13 13:12:36 +01:00
|
|
|
doMigrations();
|
|
|
|
}
|
|
|
|
|
2019-12-27 04:17:49 +01:00
|
|
|
|
2019-12-13 13:12:36 +01:00
|
|
|
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 = ProfileFunctions.getInstance().getProfile();
|
|
|
|
if (p != null && p.getData() != null && p.getData().has("units")) {
|
|
|
|
try {
|
|
|
|
newUnits = p.getData().getString("units");
|
|
|
|
} catch (JSONException e) {
|
|
|
|
log.error("Unhandled exception", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SP.putString(R.string.key_units, newUnits);
|
|
|
|
}
|
2017-07-24 01:50:27 +02:00
|
|
|
}
|
|
|
|
|
2019-12-21 20:17:08 +01:00
|
|
|
@Override
|
|
|
|
protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
|
|
|
|
return DaggerAppComponent
|
|
|
|
.builder()
|
|
|
|
.application(this)
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
|
2017-07-24 01:50:27 +02:00
|
|
|
private void registerLocalBroadcastReceiver() {
|
2019-12-24 16:07:17 +01:00
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
|
2017-07-24 01:50:27 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_TREATMENT));
|
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_CHANGED_TREATMENT));
|
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_REMOVED_TREATMENT));
|
2017-07-24 01:55:01 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_SGV));
|
2017-07-24 01:58:23 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_PROFILE));
|
2017-07-24 02:02:54 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_MBG));
|
2017-07-24 02:09:26 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_CAL));
|
|
|
|
|
2019-07-18 19:09:49 +02:00
|
|
|
this.timeDateOrTZChangeReceiver = new TimeDateOrTZChangeReceiver();
|
|
|
|
this.timeDateOrTZChangeReceiver.registerBroadcasts(this);
|
2018-07-26 17:31:23 +02:00
|
|
|
|
2016-12-16 02:00:53 +01:00
|
|
|
}
|
|
|
|
|
2019-12-30 00:53:44 +01:00
|
|
|
@Deprecated
|
2019-12-24 16:07:17 +01:00
|
|
|
public static String gs(@StringRes int id) {
|
2018-01-14 21:42:36 +01:00
|
|
|
return sResources.getString(id);
|
|
|
|
}
|
|
|
|
|
2019-12-30 00:53:44 +01:00
|
|
|
@Deprecated
|
2019-12-24 16:07:17 +01:00
|
|
|
public static String gs(@StringRes int id, Object... args) {
|
2018-01-25 20:26:07 +01:00
|
|
|
return sResources.getString(id, args);
|
|
|
|
}
|
|
|
|
|
2019-12-30 00:53:44 +01:00
|
|
|
@Deprecated
|
2018-06-09 22:07:41 +02:00
|
|
|
public static String gq(@PluralsRes int id, int quantity, Object... args) {
|
|
|
|
return sResources.getQuantityString(id, quantity, args);
|
|
|
|
}
|
|
|
|
|
2019-12-30 00:53:44 +01:00
|
|
|
@Deprecated
|
2019-12-24 16:07:17 +01:00
|
|
|
public static int gc(@ColorRes int id) {
|
|
|
|
return ContextCompat.getColor(instance(), id);
|
2018-03-10 19:22:31 +01:00
|
|
|
}
|
|
|
|
|
2019-12-30 00:53:44 +01:00
|
|
|
@Deprecated
|
2016-06-05 01:40:35 +02:00
|
|
|
public static MainApp instance() {
|
|
|
|
return sInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static DatabaseHelper getDbHelper() {
|
2016-07-07 10:34:20 +02:00
|
|
|
return sDatabaseHelper;
|
2016-06-05 01:40:35 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 00:32:26 +02:00
|
|
|
public static FirebaseAnalytics getFirebaseAnalytics() {
|
|
|
|
return mFirebaseAnalytics;
|
|
|
|
}
|
|
|
|
|
2016-07-18 20:19:55 +02:00
|
|
|
public static ArrayList<PluginBase> getPluginsList() {
|
|
|
|
return pluginsList;
|
|
|
|
}
|
|
|
|
|
2018-03-31 00:36:03 +02:00
|
|
|
public static ArrayList<PluginBase> getSpecificPluginsList(PluginType type) {
|
2016-08-05 23:54:03 +02:00
|
|
|
ArrayList<PluginBase> newList = new ArrayList<>();
|
2016-07-18 20:19:55 +02:00
|
|
|
|
|
|
|
if (pluginsList != null) {
|
2016-08-05 23:54:03 +02:00
|
|
|
for (PluginBase p : pluginsList) {
|
2016-07-18 20:19:55 +02:00
|
|
|
if (p.getType() == type)
|
|
|
|
newList.add(p);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.error("pluginsList=null");
|
|
|
|
}
|
|
|
|
return newList;
|
|
|
|
}
|
|
|
|
|
2018-03-31 00:36:03 +02:00
|
|
|
public static ArrayList<PluginBase> getSpecificPluginsVisibleInList(PluginType type) {
|
2017-04-29 16:59:44 +02:00
|
|
|
ArrayList<PluginBase> newList = new ArrayList<>();
|
|
|
|
|
|
|
|
if (pluginsList != null) {
|
|
|
|
for (PluginBase p : pluginsList) {
|
|
|
|
if (p.getType() == type)
|
|
|
|
if (p.showInList(type))
|
|
|
|
newList.add(p);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.error("pluginsList=null");
|
|
|
|
}
|
|
|
|
return newList;
|
|
|
|
}
|
|
|
|
|
2019-12-27 19:20:38 +01:00
|
|
|
public ArrayList<PluginBase> getSpecificPluginsListByInterface(Class interfaceClass) {
|
2016-08-05 23:54:03 +02:00
|
|
|
ArrayList<PluginBase> newList = new ArrayList<>();
|
2016-07-18 20:19:55 +02:00
|
|
|
|
|
|
|
if (pluginsList != null) {
|
2016-08-05 23:54:03 +02:00
|
|
|
for (PluginBase p : pluginsList) {
|
|
|
|
if (p.getClass() != ConfigBuilderPlugin.class && interfaceClass.isAssignableFrom(p.getClass()))
|
2016-07-18 20:19:55 +02:00
|
|
|
newList.add(p);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.error("pluginsList=null");
|
|
|
|
}
|
|
|
|
return newList;
|
|
|
|
}
|
|
|
|
|
2018-03-31 00:36:03 +02:00
|
|
|
public static ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, PluginType type) {
|
2017-04-29 16:59:44 +02:00
|
|
|
ArrayList<PluginBase> newList = new ArrayList<>();
|
|
|
|
|
|
|
|
if (pluginsList != null) {
|
|
|
|
for (PluginBase p : pluginsList) {
|
|
|
|
if (p.getClass() != ConfigBuilderPlugin.class && interfaceClass.isAssignableFrom(p.getClass()))
|
|
|
|
if (p.showInList(type))
|
|
|
|
newList.add(p);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.error("pluginsList=null");
|
|
|
|
}
|
|
|
|
return newList;
|
|
|
|
}
|
|
|
|
|
2018-03-18 17:38:05 +01:00
|
|
|
public static boolean isEngineeringModeOrRelease() {
|
2018-08-07 21:07:43 +02:00
|
|
|
if (!Config.APS)
|
2018-03-24 17:09:56 +01:00
|
|
|
return true;
|
2018-03-17 21:23:45 +01:00
|
|
|
return engineeringMode || !devBranch;
|
|
|
|
}
|
|
|
|
|
2018-05-02 18:39:37 +02:00
|
|
|
public static boolean isDev() {
|
|
|
|
return devBranch;
|
|
|
|
}
|
|
|
|
|
2019-03-02 14:37:53 +01:00
|
|
|
public static int getIcon() {
|
|
|
|
if (Config.NSCLIENT)
|
|
|
|
return R.mipmap.ic_yellowowl;
|
|
|
|
else if (Config.PUMPCONTROL)
|
|
|
|
return R.mipmap.ic_pumpcontrol;
|
|
|
|
else
|
|
|
|
return R.mipmap.ic_launcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getNotificationIcon() {
|
|
|
|
if (Config.NSCLIENT)
|
|
|
|
return R.drawable.ic_notif_nsclient;
|
|
|
|
else if (Config.PUMPCONTROL)
|
|
|
|
return R.drawable.ic_notif_pumpcontrol;
|
|
|
|
else
|
|
|
|
return R.drawable.ic_notif_aaps;
|
|
|
|
}
|
|
|
|
|
2016-06-05 01:40:35 +02:00
|
|
|
@Override
|
|
|
|
public void onTerminate() {
|
2019-12-28 01:52:20 +01:00
|
|
|
|
|
|
|
aapsLogger.debug(LTag.CORE, "onTerminate");
|
2018-07-26 17:31:23 +02:00
|
|
|
|
2019-12-24 16:07:17 +01:00
|
|
|
if (timeDateOrTZChangeReceiver != null)
|
2019-07-18 19:09:49 +02:00
|
|
|
unregisterReceiver(timeDateOrTZChangeReceiver);
|
2019-12-31 09:41:02 +01:00
|
|
|
unregisterActivityLifecycleCallbacks(activityMonitor);
|
2019-12-24 16:07:17 +01:00
|
|
|
KeepAliveReceiver.cancelAlarm(this);
|
|
|
|
super.onTerminate();
|
2016-06-05 01:40:35 +02:00
|
|
|
}
|
2018-10-15 23:20:06 +02:00
|
|
|
|
|
|
|
public static int dpToPx(int dp) {
|
|
|
|
float scale = sResources.getDisplayMetrics().density;
|
2019-07-05 01:22:45 +02:00
|
|
|
return (int) (dp * scale + 0.5f);
|
2016-06-05 01:40:35 +02:00
|
|
|
}
|
2019-12-13 02:12:19 +01:00
|
|
|
|
2016-12-16 02:00:53 +01:00
|
|
|
}
|