Merge branch 'dev' into omnipod_eros_dev_dagger_history_fix

This commit is contained in:
Bart Sopers 2020-05-04 17:36:29 +02:00
commit 1798d260eb
99 changed files with 872 additions and 855 deletions

View file

@ -247,6 +247,8 @@ allprojects {
dependencies { dependencies {
wearApp project(':wear') wearApp project(':wear')
implementation project(':core')
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-wearable:17.0.0' implementation 'com.google.android.gms:play-services-wearable:17.0.0'
implementation "com.google.android.gms:play-services-location:17.0.0" implementation "com.google.android.gms:play-services-location:17.0.0"

View file

@ -41,6 +41,8 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
@ -53,11 +55,13 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest
import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.resources.IconsProvider
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 io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import java.util.*
import javax.inject.Inject import javax.inject.Inject
import kotlin.system.exitProcess import kotlin.system.exitProcess
@ -77,6 +81,9 @@ class MainActivity : NoSplashAppCompatActivity() {
@Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var activePlugin: ActivePluginProvider
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var protectionCheck: ProtectionCheck @Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var iconsProvider: IconsProvider
@Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var signatureVerifierPlugin: SignatureVerifierPlugin
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
private var pluginPreferencesMenuItem: MenuItem? = null private var pluginPreferencesMenuItem: MenuItem? = null
@ -107,7 +114,7 @@ class MainActivity : NoSplashAppCompatActivity() {
//Check here if loop plugin is disabled. Else check via constraints //Check here if loop plugin is disabled. Else check via constraints
if (!loopPlugin.isEnabled(PluginType.LOOP)) versionCheckerUtils.triggerCheckVersion() if (!loopPlugin.isEnabled(PluginType.LOOP)) versionCheckerUtils.triggerCheckVersion()
fabricPrivacy.setUserStats() setUserStats()
setupViews() setupViews()
disposable.add(rxBus disposable.add(rxBus
.toObservable(EventRebuildTabs::class.java) .toObservable(EventRebuildTabs::class.java)
@ -283,7 +290,7 @@ class MainActivity : NoSplashAppCompatActivity() {
Linkify.addLinks(messageSpanned, Linkify.WEB_URLS) Linkify.addLinks(messageSpanned, Linkify.WEB_URLS)
AlertDialog.Builder(this) AlertDialog.Builder(this)
.setTitle(resourceHelper.gs(R.string.app_name) + " " + BuildConfig.VERSION) .setTitle(resourceHelper.gs(R.string.app_name) + " " + BuildConfig.VERSION)
.setIcon(resourceHelper.getIcon()) .setIcon(iconsProvider.getIcon())
.setMessage(messageSpanned) .setMessage(messageSpanned)
.setPositiveButton(resourceHelper.gs(R.string.ok), null) .setPositiveButton(resourceHelper.gs(R.string.ok), null)
.create().also { .create().also {
@ -323,4 +330,35 @@ class MainActivity : NoSplashAppCompatActivity() {
} }
return actionBarDrawerToggle.onOptionsItemSelected(item) return actionBarDrawerToggle.onOptionsItemSelected(item)
} }
// Correct place for calling setUserStats() would be probably MainApp
// but we need to have it called at least once a day. Thus this location
private fun setUserStats() {
if (!fabricPrivacy.fabricEnabled()) return
val closedLoopEnabled = if (constraintChecker.isClosedLoopAllowed().value()) "CLOSED_LOOP_ENABLED" else "CLOSED_LOOP_DISABLED"
// Size is limited to 36 chars
val remote = BuildConfig.REMOTE.toLowerCase(Locale.getDefault())
.replace("https://", "")
.replace("http://", "")
.replace(".git", "")
.replace(".com/", ":")
.replace(".org/", ":")
.replace(".net/", ":")
fabricPrivacy.firebaseAnalytics.setUserProperty("Mode", BuildConfig.APPLICATION_ID + "-" + closedLoopEnabled)
fabricPrivacy.firebaseAnalytics.setUserProperty("Language", sp.getString(R.string.key_language, Locale.getDefault().language))
fabricPrivacy.firebaseAnalytics.setUserProperty("Version", BuildConfig.VERSION)
fabricPrivacy.firebaseAnalytics.setUserProperty("HEAD", BuildConfig.HEAD)
fabricPrivacy.firebaseAnalytics.setUserProperty("Remote", remote)
val hashes: List<String> = signatureVerifierPlugin.shortHashes()
if (hashes.isNotEmpty()) fabricPrivacy.firebaseAnalytics.setUserProperty("Hash", hashes[0])
activePlugin.activePump.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Pump", it::class.java.simpleName) }
if (!Config.NSCLIENT && !Config.PUMPCONTROL)
activePlugin.activeAPS.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Aps", it::class.java.simpleName) }
activePlugin.activeBgSource.let { fabricPrivacy.firebaseAnalytics.setUserProperty("BgSource", it::class.java.simpleName) }
fabricPrivacy.firebaseAnalytics.setUserProperty("Profile", activePlugin.activeProfileInterface.javaClass.simpleName)
activePlugin.activeSensitivity.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Sensitivity", it::class.java.simpleName) }
activePlugin.activeInsulin.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Insulin", it::class.java.simpleName) }
}
} }

View file

@ -26,7 +26,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.interfaces.Interval; import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg; import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg;
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
@ -156,8 +156,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
CareportalEvent event = list.get(i); CareportalEvent event = list.get(i);
if (event.date <= time && event.date > (time - T.mins(5).msecs())) { if (event.date <= time && event.date > (time - T.mins(5).msecs())) {
if (L.isEnabled(L.DATABASE)) aapsLogger.debug(LTag.DATABASE, "Found event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString());
aapsLogger.debug("Found event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString());
return true; return true;
} }
} }

View file

@ -47,6 +47,7 @@ import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.interfaces.ActivePluginProvider; 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.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
@ -72,7 +73,7 @@ import info.nightscout.androidaps.utils.ToastUtils;
* direct calls to the corresponding methods (eg. resetDatabases) should be done by a central service. * direct calls to the corresponding methods (eg. resetDatabases) should be done by a central service.
*/ */
public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATABASE);
public static final String DATABASE_NAME = "AndroidAPSDb"; public static final String DATABASE_NAME = "AndroidAPSDb";
public static final String DATABASE_BGREADINGS = "BgReadings"; public static final String DATABASE_BGREADINGS = "BgReadings";
@ -123,7 +124,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
@Override @Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) { public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try { try {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.info("onCreate"); log.info("onCreate");
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class); TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
TableUtils.createTableIfNotExists(connectionSource, BgReading.class); TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
@ -366,7 +367,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public static long roundDateToSec(long date) { public static long roundDateToSec(long date) {
long rounded = date - date % 1000; long rounded = date - date % 1000;
if (rounded != date) if (rounded != date)
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Rounding " + date + " to " + rounded); log.debug("Rounding " + date + " to " + rounded);
return rounded; return rounded;
} }
@ -378,17 +379,17 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
BgReading old = getDaoBgReadings().queryForId(bgReading.date); BgReading old = getDaoBgReadings().queryForId(bgReading.date);
if (old == null) { if (old == null) {
getDaoBgReadings().create(bgReading); getDaoBgReadings().create(bgReading);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("BG: New record from: " + from + " " + bgReading.toString()); log.debug("BG: New record from: " + from + " " + bgReading.toString());
scheduleBgChange(bgReading); scheduleBgChange(bgReading);
return true; return true;
} }
if (!old.isEqual(bgReading)) { if (!old.isEqual(bgReading)) {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("BG: Similiar found: " + old.toString()); log.debug("BG: Similiar found: " + old.toString());
old.copyFrom(bgReading); old.copyFrom(bgReading);
getDaoBgReadings().update(old); getDaoBgReadings().update(old);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("BG: Updating record from: " + from + " New data: " + old.toString()); log.debug("BG: Updating record from: " + from + " New data: " + old.toString());
scheduleBgChange(bgReading); scheduleBgChange(bgReading);
return false; return false;
@ -411,7 +412,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleBgChange(@Nullable final BgReading bgReading) { private static void scheduleBgChange(@Nullable final BgReading bgReading) {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Firing EventNewBg"); log.debug("Firing EventNewBg");
RxBus.Companion.getINSTANCE().send(new EventNewBG(bgReading)); RxBus.Companion.getINSTANCE().send(new EventNewBG(bgReading));
scheduledBgPost = null; scheduledBgPost = null;
@ -640,7 +641,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoTempTargets().delete(old); // need to delete/create because date may change too getDaoTempTargets().delete(old); // need to delete/create because date may change too
old.copyFrom(tempTarget); old.copyFrom(tempTarget);
getDaoTempTargets().create(old); getDaoTempTargets().create(old);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPTARGET: Updating record by date from: " + Source.getString(tempTarget.source) + " " + old.toString()); log.debug("TEMPTARGET: Updating record by date from: " + Source.getString(tempTarget.source) + " " + old.toString());
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();
return true; return true;
@ -660,7 +661,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoTempTargets().delete(old); // need to delete/create because date may change too getDaoTempTargets().delete(old); // need to delete/create because date may change too
old.copyFrom(tempTarget); old.copyFrom(tempTarget);
getDaoTempTargets().create(old); getDaoTempTargets().create(old);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPTARGET: Updating record by _id from: " + Source.getString(tempTarget.source) + " " + old.toString()); log.debug("TEMPTARGET: Updating record by _id from: " + Source.getString(tempTarget.source) + " " + old.toString());
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();
return true; return true;
@ -668,14 +669,14 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
getDaoTempTargets().create(tempTarget); getDaoTempTargets().create(tempTarget);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString()); log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString());
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();
return true; return true;
} }
if (tempTarget.source == Source.USER) { if (tempTarget.source == Source.USER) {
getDaoTempTargets().create(tempTarget); getDaoTempTargets().create(tempTarget);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString()); log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString());
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();
return true; return true;
@ -698,7 +699,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleTemporaryTargetChange() { private static void scheduleTemporaryTargetChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Firing EventTempTargetChange"); log.debug("Firing EventTempTargetChange");
RxBus.Companion.getINSTANCE().send(new EventTempTargetChange()); RxBus.Companion.getINSTANCE().send(new EventTempTargetChange());
scheduledTemTargetPost = null; scheduledTemTargetPost = null;
@ -824,7 +825,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
List<TemporaryBasal> trList = getDaoTemporaryBasal().query(preparedQuery); List<TemporaryBasal> trList = getDaoTemporaryBasal().query(preparedQuery);
if (trList.size() > 0) { if (trList.size() > 0) {
// do nothing, pump history record cannot be changed // do nothing, pump history record cannot be changed
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
return false; return false;
} }
@ -842,7 +843,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
old.copyFromPump(tempBasal); old.copyFromPump(tempBasal);
old.source = Source.PUMP; old.source = Source.PUMP;
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPBASAL: Updated record with Pump Data : " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); log.debug("TEMPBASAL: Updated record with Pump Data : " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
getDaoTemporaryBasal().update(old); getDaoTemporaryBasal().update(old);
@ -854,7 +855,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
getDaoTemporaryBasal().create(tempBasal); getDaoTemporaryBasal().create(tempBasal);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
updateEarliestDataChange(tempBasal.date); updateEarliestDataChange(tempBasal.date);
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
@ -872,7 +873,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too
old.copyFrom(tempBasal); old.copyFrom(tempBasal);
getDaoTemporaryBasal().create(old); getDaoTemporaryBasal().create(old);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPBASAL: Updating record by date from: " + Source.getString(tempBasal.source) + " " + old.toString()); log.debug("TEMPBASAL: Updating record by date from: " + Source.getString(tempBasal.source) + " " + old.toString());
updateEarliestDataChange(oldDate); updateEarliestDataChange(oldDate);
updateEarliestDataChange(old.date); updateEarliestDataChange(old.date);
@ -895,7 +896,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too
old.copyFrom(tempBasal); old.copyFrom(tempBasal);
getDaoTemporaryBasal().create(old); getDaoTemporaryBasal().create(old);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPBASAL: Updating record by _id from: " + Source.getString(tempBasal.source) + " " + old.toString()); log.debug("TEMPBASAL: Updating record by _id from: " + Source.getString(tempBasal.source) + " " + old.toString());
updateEarliestDataChange(oldDate); updateEarliestDataChange(oldDate);
updateEarliestDataChange(old.date); updateEarliestDataChange(old.date);
@ -905,7 +906,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
getDaoTemporaryBasal().create(tempBasal); getDaoTemporaryBasal().create(tempBasal);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
updateEarliestDataChange(tempBasal.date); updateEarliestDataChange(tempBasal.date);
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
@ -913,7 +914,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
if (tempBasal.source == Source.USER) { if (tempBasal.source == Source.USER) {
getDaoTemporaryBasal().create(tempBasal); getDaoTemporaryBasal().create(tempBasal);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
updateEarliestDataChange(tempBasal.date); updateEarliestDataChange(tempBasal.date);
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
@ -970,7 +971,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleTemporaryBasalChange() { private static void scheduleTemporaryBasalChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Firing EventTempBasalChange"); log.debug("Firing EventTempBasalChange");
RxBus.Companion.getINSTANCE().send(new EventReloadTempBasalData()); RxBus.Companion.getINSTANCE().send(new EventReloadTempBasalData());
RxBus.Companion.getINSTANCE().send(new EventTempBasalChange()); RxBus.Companion.getINSTANCE().send(new EventTempBasalChange());
@ -1065,7 +1066,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public void deleteTempBasalById(String _id) { public void deleteTempBasalById(String _id) {
TemporaryBasal stored = findTempBasalById(_id); TemporaryBasal stored = findTempBasalById(_id);
if (stored != null) { if (stored != null) {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("TEMPBASAL: Removing TempBasal record from database: " + stored.toString()); log.debug("TEMPBASAL: Removing TempBasal record from database: " + stored.toString());
delete(stored); delete(stored);
updateEarliestDataChange(stored.date); updateEarliestDataChange(stored.date);
@ -1120,7 +1121,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public boolean createOrUpdate(ExtendedBolus extendedBolus) { public boolean createOrUpdate(ExtendedBolus extendedBolus) {
try { try {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("EXTENDEDBOLUS: createOrUpdate: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log()); log.debug("EXTENDEDBOLUS: createOrUpdate: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
ExtendedBolus old; ExtendedBolus old;
@ -1145,7 +1146,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
getDaoExtendedBolus().createOrUpdate(extendedBolus); getDaoExtendedBolus().createOrUpdate(extendedBolus);
} }
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log()); log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
updateEarliestDataChange(extendedBolus.date); updateEarliestDataChange(extendedBolus.date);
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
@ -1159,7 +1160,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoExtendedBolus().delete(old); // need to delete/create because date may change too getDaoExtendedBolus().delete(old); // need to delete/create because date may change too
old.copyFrom(extendedBolus); old.copyFrom(extendedBolus);
getDaoExtendedBolus().create(old); getDaoExtendedBolus().create(old);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("EXTENDEDBOLUS: Updating record by date from: " + Source.getString(extendedBolus.source) + " " + old.log()); log.debug("EXTENDEDBOLUS: Updating record by date from: " + Source.getString(extendedBolus.source) + " " + old.log());
updateEarliestDataChange(oldDate); updateEarliestDataChange(oldDate);
updateEarliestDataChange(old.date); updateEarliestDataChange(old.date);
@ -1182,7 +1183,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoExtendedBolus().delete(old); // need to delete/create because date may change too getDaoExtendedBolus().delete(old); // need to delete/create because date may change too
old.copyFrom(extendedBolus); old.copyFrom(extendedBolus);
getDaoExtendedBolus().create(old); getDaoExtendedBolus().create(old);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("EXTENDEDBOLUS: Updating record by _id from: " + Source.getString(extendedBolus.source) + " " + old.log()); log.debug("EXTENDEDBOLUS: Updating record by _id from: " + Source.getString(extendedBolus.source) + " " + old.log());
updateEarliestDataChange(oldDate); updateEarliestDataChange(oldDate);
updateEarliestDataChange(old.date); updateEarliestDataChange(old.date);
@ -1192,7 +1193,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
getDaoExtendedBolus().create(extendedBolus); getDaoExtendedBolus().create(extendedBolus);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log()); log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
updateEarliestDataChange(extendedBolus.date); updateEarliestDataChange(extendedBolus.date);
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
@ -1200,7 +1201,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
if (extendedBolus.source == Source.USER) { if (extendedBolus.source == Source.USER) {
getDaoExtendedBolus().create(extendedBolus); getDaoExtendedBolus().create(extendedBolus);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log()); log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
updateEarliestDataChange(extendedBolus.date); updateEarliestDataChange(extendedBolus.date);
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
@ -1249,10 +1250,26 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<ExtendedBolus>(); return new ArrayList<ExtendedBolus>();
} }
public List<ExtendedBolus> getExtendedBolusDataFromTime(long from, long to, boolean ascending) {
try {
List<ExtendedBolus> extendedBoluses;
QueryBuilder<ExtendedBolus, Long> queryBuilder = getDaoExtendedBolus().queryBuilder();
queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where();
where.between("date", from, to);
PreparedQuery<ExtendedBolus> preparedQuery = queryBuilder.prepare();
extendedBoluses = getDaoExtendedBolus().query(preparedQuery);
return extendedBoluses;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<ExtendedBolus>();
}
public void deleteExtendedBolusById(String _id) { public void deleteExtendedBolusById(String _id) {
ExtendedBolus stored = findExtendedBolusById(_id); ExtendedBolus stored = findExtendedBolusById(_id);
if (stored != null) { if (stored != null) {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("EXTENDEDBOLUS: Removing ExtendedBolus record from database: " + stored.toString()); log.debug("EXTENDEDBOLUS: Removing ExtendedBolus record from database: " + stored.toString());
delete(stored); delete(stored);
updateEarliestDataChange(stored.date); updateEarliestDataChange(stored.date);
@ -1306,7 +1323,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleExtendedBolusChange() { private static void scheduleExtendedBolusChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Firing EventExtendedBolusChange"); log.debug("Firing EventExtendedBolusChange");
RxBus.Companion.getINSTANCE().send(new EventReloadTreatmentData(new EventExtendedBolusChange())); RxBus.Companion.getINSTANCE().send(new EventReloadTreatmentData(new EventExtendedBolusChange()));
if (earliestDataChange != null) if (earliestDataChange != null)
@ -1468,11 +1485,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
if (list.size() == 1) { if (list.size() == 1) {
CareportalEvent record = list.get(0); CareportalEvent record = list.get(0);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Removing CareportalEvent record from database: " + record.toString()); log.debug("Removing CareportalEvent record from database: " + record.toString());
delete(record); delete(record);
} else { } else {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("CareportalEvent not found database: " + _id); log.debug("CareportalEvent not found database: " + _id);
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -1492,12 +1509,12 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
if (list.size() == 0) { if (list.size() == 0) {
careportalEvent = new CareportalEvent(MainApp.instance()); careportalEvent = new CareportalEvent(MainApp.instance());
careportalEvent.source = Source.NIGHTSCOUT; careportalEvent.source = Source.NIGHTSCOUT;
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Adding CareportalEvent record to database: " + trJson.toString()); log.debug("Adding CareportalEvent record to database: " + trJson.toString());
// Record does not exists. add // Record does not exists. add
} else if (list.size() == 1) { } else if (list.size() == 1) {
careportalEvent = list.get(0); careportalEvent = list.get(0);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Updating CareportalEvent record in database: " + trJson.toString()); log.debug("Updating CareportalEvent record in database: " + trJson.toString());
} else { } else {
log.error("Something went wrong"); log.error("Something went wrong");
@ -1516,7 +1533,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleCareportalEventChange() { private static void scheduleCareportalEventChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Firing scheduleCareportalEventChange"); log.debug("Firing scheduleCareportalEventChange");
RxBus.Companion.getINSTANCE().send(new EventCareportalEventChange()); RxBus.Companion.getINSTANCE().send(new EventCareportalEventChange());
scheduledCareportalEventPost = null; scheduledCareportalEventPost = null;
@ -1629,7 +1646,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
profileSwitch.profileName = old.profileName; // preserver profileName to prevent multiple CPP extension profileSwitch.profileName = old.profileName; // preserver profileName to prevent multiple CPP extension
getDaoProfileSwitch().delete(old); // need to delete/create because date may change too getDaoProfileSwitch().delete(old); // need to delete/create because date may change too
getDaoProfileSwitch().create(profileSwitch); getDaoProfileSwitch().create(profileSwitch);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString()); log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString());
scheduleProfileSwitchChange(); scheduleProfileSwitchChange();
return true; return true;
@ -1649,7 +1666,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoProfileSwitch().delete(old); // need to delete/create because date may change too getDaoProfileSwitch().delete(old); // need to delete/create because date may change too
old.copyFrom(profileSwitch); old.copyFrom(profileSwitch);
getDaoProfileSwitch().create(old); getDaoProfileSwitch().create(old);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString()); log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString());
scheduleProfileSwitchChange(); scheduleProfileSwitchChange();
return true; return true;
@ -1659,14 +1676,14 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
// look for already added percentage from NS // look for already added percentage from NS
profileSwitch.profileName = PercentageSplitter.pureName(profileSwitch.profileName); profileSwitch.profileName = PercentageSplitter.pureName(profileSwitch.profileName);
getDaoProfileSwitch().create(profileSwitch); getDaoProfileSwitch().create(profileSwitch);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString()); log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
scheduleProfileSwitchChange(); scheduleProfileSwitchChange();
return true; return true;
} }
if (profileSwitch.source == Source.USER) { if (profileSwitch.source == Source.USER) {
getDaoProfileSwitch().create(profileSwitch); getDaoProfileSwitch().create(profileSwitch);
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString()); log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
scheduleProfileSwitchChange(); scheduleProfileSwitchChange();
return true; return true;
@ -1689,7 +1706,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static void scheduleProfileSwitchChange() { private static void scheduleProfileSwitchChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Firing EventProfileNeedsUpdate"); log.debug("Firing EventProfileNeedsUpdate");
RxBus.Companion.getINSTANCE().send(new EventReloadProfileSwitchData()); RxBus.Companion.getINSTANCE().send(new EventReloadProfileSwitchData());
RxBus.Companion.getINSTANCE().send(new EventProfileNeedsUpdate()); RxBus.Companion.getINSTANCE().send(new EventProfileNeedsUpdate());
@ -1741,17 +1758,17 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
Profile profile = store.getSpecificProfile(profileSwitch.profileName); Profile profile = store.getSpecificProfile(profileSwitch.profileName);
if (profile != null) { if (profile != null) {
profileSwitch.profileJson = profile.getData().toString(); profileSwitch.profileJson = profile.getData().toString();
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Profile switch prefilled with JSON from local store"); log.debug("Profile switch prefilled with JSON from local store");
// Update data in NS // Update data in NS
NSUpload.updateProfileSwitch(profileSwitch); NSUpload.updateProfileSwitch(profileSwitch);
} else { } else {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("JSON for profile switch doesn't exist. Ignoring: " + trJson.toString()); log.debug("JSON for profile switch doesn't exist. Ignoring: " + trJson.toString());
return; return;
} }
} else { } else {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Store for profile switch doesn't exist. Ignoring: " + trJson.toString()); log.debug("Store for profile switch doesn't exist. Ignoring: " + trJson.toString());
return; return;
} }
@ -1767,7 +1784,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public void deleteProfileSwitchById(String _id) { public void deleteProfileSwitchById(String _id) {
ProfileSwitch stored = findProfileSwitchById(_id); ProfileSwitch stored = findProfileSwitchById(_id);
if (stored != null) { if (stored != null) {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("PROFILESWITCH: Removing ProfileSwitch record from database: " + stored.toString()); log.debug("PROFILESWITCH: Removing ProfileSwitch record from database: " + stored.toString());
delete(stored); delete(stored);
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();

View file

@ -1,16 +1,13 @@
package info.nightscout.androidaps.db; package info.nightscout.androidaps.db;
import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;
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.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DateUtil;
@ -21,7 +18,7 @@ import info.nightscout.androidaps.utils.DateUtil;
*/ */
@DatabaseTable(tableName = DatabaseHelper.DATABASE_DBREQUESTS) @DatabaseTable(tableName = DatabaseHelper.DATABASE_DBREQUESTS)
public class DbRequest { public class DbRequest {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATABASE);
@DatabaseField(id = true) @DatabaseField(id = true)
public String nsClientID = null; public String nsClientID = null;

View file

@ -22,6 +22,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.interfaces.Interval; import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
@ -253,13 +254,11 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
if (event.date <= time && event.date > (time - T.mins(5).msecs())) { if (event.date <= time && event.date > (time - T.mins(5).msecs())) {
if (zeroDurationOnly) { if (zeroDurationOnly) {
if (event.durationInMinutes == 0) { if (event.durationInMinutes == 0) {
if (L.isEnabled(L.DATABASE)) aapsLogger.debug(LTag.DATABASE, "Found ProfileSwitch event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString());
aapsLogger.debug("Found ProfileSwitch event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString());
return true; return true;
} }
} else { } else {
if (L.isEnabled(L.DATABASE)) aapsLogger.debug(LTag.DATABASE, "Found ProfileSwitch event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString());
aapsLogger.debug("Found ProfileSwitch event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString());
return true; return true;
} }
} }

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.interfaces.Interval; import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
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;
@ -21,7 +22,7 @@ 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 {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATABASE);
@DatabaseField(id = true) @DatabaseField(id = true)
public long date; public long date;

View file

@ -110,6 +110,8 @@ public class TemporaryBasal implements Interval, DbObjectBase {
} }
public TemporaryBasal(ExtendedBolus extendedBolus) { public TemporaryBasal(ExtendedBolus extendedBolus) {
injector = MainApp.instance();
injector.androidInjector().inject(this);
double basal = profileFunction.getProfile(extendedBolus.date).getBasal(extendedBolus.date); double basal = profileFunction.getProfile(extendedBolus.date).getBasal(extendedBolus.date);
this.date = extendedBolus.date; this.date = extendedBolus.date;
this.isValid = extendedBolus.isValid; this.isValid = extendedBolus.isValid;

View file

@ -5,12 +5,56 @@ import dagger.Component
import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.core.dependencyInjection.CoreModule
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.data.ProfileStore
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.db.BgReading
import info.nightscout.androidaps.db.CareportalEvent
import info.nightscout.androidaps.db.ProfileSwitch
import info.nightscout.androidaps.db.TemporaryBasal
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback
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.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.general.overview.graphData.GraphData
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
import info.nightscout.androidaps.plugins.general.smsCommunicator.AuthRequest
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
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.plugins.treatments.Treatment
import info.nightscout.androidaps.queue.CommandQueue
import info.nightscout.androidaps.queue.commands.*
import info.nightscout.androidaps.setupwizard.SWEventListener
import info.nightscout.androidaps.setupwizard.SWScreen
import info.nightscout.androidaps.setupwizard.elements.*
import info.nightscout.androidaps.utils.wizard.BolusWizard
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
@Component( @Component(
modules = [ modules = [
AndroidInjectionModule::class, AndroidInjectionModule::class,
CoreModule::class,
ActivitiesModule::class, ActivitiesModule::class,
FragmentsModule::class, FragmentsModule::class,
AppModule::class, AppModule::class,

View file

@ -1,112 +1,37 @@
package info.nightscout.androidaps.dependencyInjection package info.nightscout.androidaps.dependencyInjection
import android.content.Context import android.content.Context
import androidx.preference.PreferenceManager
import dagger.Binds import dagger.Binds
import dagger.Lazy import dagger.Lazy
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import dagger.android.ContributesAndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.data.ProfileStore
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.db.BgReading
import info.nightscout.androidaps.db.CareportalEvent
import info.nightscout.androidaps.db.ProfileSwitch
import info.nightscout.androidaps.db.TemporaryBasal
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.AAPSLoggerProduction
import info.nightscout.androidaps.plugins.aps.loop.APSResult
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
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.configBuilder.ProfileFunction
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
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.general.overview.graphData.GraphData
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.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
import info.nightscout.androidaps.plugins.general.smsCommunicator.AuthRequest
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
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.plugins.treatments.Treatment
import info.nightscout.androidaps.queue.CommandQueue import info.nightscout.androidaps.queue.CommandQueue
import info.nightscout.androidaps.queue.commands.*
import info.nightscout.androidaps.setupwizard.SWEventListener
import info.nightscout.androidaps.setupwizard.SWScreen
import info.nightscout.androidaps.setupwizard.elements.*
import info.nightscout.androidaps.utils.CryptoUtil
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.resources.ResourceHelperImplementation
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import info.nightscout.androidaps.utils.sharedPreferences.SPImplementation
import info.nightscout.androidaps.utils.storage.FileStorage import info.nightscout.androidaps.utils.storage.FileStorage
import info.nightscout.androidaps.utils.storage.Storage import info.nightscout.androidaps.utils.storage.Storage
import info.nightscout.androidaps.utils.wizard.BolusWizard
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
import javax.inject.Singleton import javax.inject.Singleton
@Module(includes = [AppModule.AppBindings::class, PluginsModule::class]) @Module(includes = [AppModule.AppBindings::class, PluginsModule::class])
open class AppModule { open class AppModule {
@Provides
@Singleton
fun provideSharedPreferences(context: Context, resourceHelper: ResourceHelper): SP {
return SPImplementation(PreferenceManager.getDefaultSharedPreferences(context), resourceHelper)
}
@Provides @Provides
@Singleton @Singleton
fun provideProfileFunction(injector: HasAndroidInjector, aapsLogger: AAPSLogger, sp: SP, resourceHelper: ResourceHelper, activePlugin: ActivePluginProvider, fabricPrivacy: FabricPrivacy): ProfileFunction { fun provideProfileFunction(injector: HasAndroidInjector, aapsLogger: AAPSLogger, sp: SP, resourceHelper: ResourceHelper, activePlugin: ActivePluginProvider, fabricPrivacy: FabricPrivacy): ProfileFunction {
return ProfileFunctionImplementation(injector, aapsLogger, sp, resourceHelper, activePlugin, fabricPrivacy) return ProfileFunctionImplementation(injector, aapsLogger, sp, resourceHelper, activePlugin, fabricPrivacy)
} }
@Provides
@Singleton
fun provideResources(mainApp: MainApp): ResourceHelper {
return ResourceHelperImplementation(mainApp)
}
@Provides
@Singleton
fun provideAAPSLogger(): AAPSLogger {
return AAPSLoggerProduction()
/* if (BuildConfig.DEBUG) {
AAPSLoggerDebug()
} else {
AAPSLoggerProduction()
}
*/
}
@Provides @Provides
fun providesPlugins(@PluginsModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>, fun providesPlugins(@PluginsModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>,
@PluginsModule.PumpDriver pumpDrivers: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>, @PluginsModule.PumpDriver pumpDrivers: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
@ -133,10 +58,7 @@ open class AppModule {
@Binds fun bindContext(mainApp: MainApp): Context @Binds fun bindContext(mainApp: MainApp): Context
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector @Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
@Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
@Binds
fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
@Binds fun commandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider @Binds fun commandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
} }

View file

@ -1,68 +0,0 @@
package info.nightscout.androidaps.logging
import android.util.Log
/**
* Created by adrian on 2019-12-27.
*/
class AAPSLoggerDebug : AAPSLogger {
override fun debug(message: String) {
Log.d(LTag.CORE.tag, message)
}
override fun debug(enable: Boolean, tag: LTag, message: String) {
if (enable) Log.d(LTag.CORE.tag, message)
}
override fun debug(tag: LTag, message: String) {
Log.d(tag.tag, message)
}
override fun debug(tag: LTag, format: String, vararg arguments: Any?) {
Log.d(tag.tag, String.format(format, arguments))
}
override fun warn(tag: LTag, message: String) {
Log.w(tag.tag, message)
}
override fun warn(tag: LTag, format: String, vararg arguments: Any?) {
Log.w(tag.tag, String.format(format, arguments))
}
override fun info(tag: LTag, message: String) {
Log.i(tag.tag, message)
}
override fun info(tag: LTag, format: String, vararg arguments: Any?) {
Log.i(tag.tag, String.format(format, arguments))
}
override fun error(tag: LTag, message: String) {
Log.e(tag.tag, message)
}
override fun error(message: String) {
Log.e(LTag.CORE.tag, message)
}
override fun error(message: String, throwable: Throwable) {
Log.e(LTag.CORE.tag, message, throwable)
}
override fun error(format: String, vararg arguments: Any?) {
Log.e(LTag.CORE.tag, String.format(format, arguments))
}
override fun error(tag: LTag, message: String, throwable: Throwable) {
Log.e(tag.tag, message, throwable)
}
override fun error(tag: LTag, format: String, vararg arguments: Any?) {
Log.e(tag.tag, String.format(format, arguments))
}
}

View file

@ -1,80 +0,0 @@
package info.nightscout.androidaps.logging
import androidx.preference.PreferenceManager
import info.nightscout.androidaps.MainApp
import java.util.*
object L {
private var logElements: MutableList<LogElement> = ArrayList()
const val CORE = "CORE"
const val BGSOURCE = "BGSOURCE"
const val DATASERVICE = "DATASERVICE"
const val DATABASE = "DATABASE"
const val DATAFOOD = "DATAFOOD"
const val DATATREATMENTS = "DATATREATMENTS"
const val NSCLIENT = "NSCLIENT"
const val PUMP = "PUMP"
const val PUMPCOMM = "PUMPCOMM"
const val PUMPBTCOMM = "PUMPBTCOMM"
init {
LTag.values().forEach { logElements.add(LogElement(it)) }
}
private fun findByName(name: String): LogElement {
for (element in logElements) {
if (element.name == name) return element
}
return LogElement(false)
}
@JvmStatic
fun isEnabled(name: String): Boolean {
return findByName(name).enabled
}
fun getLogElements(): List<LogElement> {
return logElements
}
fun resetToDefaults() {
for (element in logElements) {
element.resetToDefault()
}
}
class LogElement {
var name: String
var defaultValue: Boolean
var enabled: Boolean
private var requiresRestart = false
internal constructor(tag: LTag) {
this.name = tag.tag
this.defaultValue = tag.defaultValue
this.requiresRestart = tag.requiresRestart
//TODO: remove after getting rid of old logging style "if (L.isEnabled(...))"
@Suppress("DEPRECATION")
enabled = PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).getBoolean(getSPName(), defaultValue)
}
internal constructor(defaultValue: Boolean) {
name = "NONEXISTING"
this.defaultValue = defaultValue
enabled = defaultValue
}
private fun getSPName(): String = "log_$name"
fun enable(enabled: Boolean) {
this.enabled = enabled
@Suppress("DEPRECATION")
PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).edit().putBoolean(getSPName(), enabled).apply()
}
fun resetToDefault() {
enable(defaultValue)
}
}
}

View file

@ -3,9 +3,8 @@ package info.nightscout.androidaps.plugins.aps.loop;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
/* /*
@ -366,7 +365,7 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
*/ */
public class DeviceStatus { public class DeviceStatus {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
public String device = null; public String device = null;
public JSONObject pump = null; public JSONObject pump = null;

View file

@ -16,7 +16,6 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
@ -32,6 +31,7 @@ import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.events.EventFoodDatabaseChanged; import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
import info.nightscout.androidaps.events.EventNsFood; import info.nightscout.androidaps.events.EventNsFood;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.FabricPrivacy;
@ -43,7 +43,7 @@ import io.reactivex.schedulers.Schedulers;
*/ */
public class FoodService extends OrmLiteBaseService<DatabaseHelper> { public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
private Logger log = StacktraceLoggerWrapper.getLogger(L.DATAFOOD); private Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATAFOOD);
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor(); private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
@ -98,7 +98,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
try { try {
if (L.isEnabled(L.DATAFOOD)) if (L.isEnabled(LTag.DATAFOOD))
log.info("onCreate"); log.info("onCreate");
TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class); TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class);
} catch (SQLException e) { } catch (SQLException e) {
@ -108,7 +108,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
} }
public void onUpgrade(ConnectionSource connectionSource, int oldVersion, int newVersion) { public void onUpgrade(ConnectionSource connectionSource, int oldVersion, int newVersion) {
if (L.isEnabled(L.DATAFOOD)) if (L.isEnabled(LTag.DATAFOOD))
log.info("onUpgrade"); log.info("onUpgrade");
// this.resetFood(); // this.resetFood();
} }
@ -147,7 +147,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATAFOOD)) if (L.isEnabled(LTag.DATAFOOD))
log.debug("Firing EventFoodChange"); log.debug("Firing EventFoodChange");
RxBus.Companion.getINSTANCE().send(event); RxBus.Companion.getINSTANCE().send(event);
callback.setPost(null); callback.setPost(null);
@ -258,7 +258,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void deleteByNSId(String _id) throws SQLException { public void deleteByNSId(String _id) throws SQLException {
Food stored = this.findByNSId(_id); Food stored = this.findByNSId(_id);
if (stored != null) { if (stored != null) {
if (L.isEnabled(L.DATAFOOD)) if (L.isEnabled(LTag.DATAFOOD))
log.debug("Removing Food record from database: " + stored.toString()); log.debug("Removing Food record from database: " + stored.toString());
this.delete(stored); this.delete(stored);
} }
@ -312,7 +312,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void createOrUpdate(Food food) { public void createOrUpdate(Food food) {
try { try {
this.getDao().createOrUpdate(food); this.getDao().createOrUpdate(food);
if (L.isEnabled(L.DATAFOOD)) if (L.isEnabled(LTag.DATAFOOD))
log.debug("Created or Updated: " + food.toString()); log.debug("Created or Updated: " + food.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Unable to createOrUpdate Food", e); log.error("Unable to createOrUpdate Food", e);
@ -323,7 +323,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void create(Food food) { public void create(Food food) {
try { try {
this.getDao().create(food); this.getDao().create(food);
if (L.isEnabled(L.DATAFOOD)) if (L.isEnabled(LTag.DATAFOOD))
log.debug("New record: " + food.toString()); log.debug("New record: " + food.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Unable to create Food", e); log.error("Unable to create Food", e);

View file

@ -1,19 +1,14 @@
package info.nightscout.androidaps.plugins.general.maintenance; package info.nightscout.androidaps.plugins.general.maintenance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.LoggerContext;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
/** /**
* This class provides serveral methods for log-handling (eg. sending logs as emails). * This class provides serveral methods for log-handling (eg. sending logs as emails).
*/ */
public class LoggerUtils { public class LoggerUtils {
private static final Logger LOGGER = StacktraceLoggerWrapper.getLogger(L.CORE);
public static String SUFFIX = ".log.zip"; public static String SUFFIX = ".log.zip";
/** /**

View file

@ -9,9 +9,12 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.logging.L
import kotlinx.android.synthetic.main.activity_logsetting.* import kotlinx.android.synthetic.main.activity_logsetting.*
import javax.inject.Inject
class LogSettingActivity : NoSplashAppCompatActivity() { class LogSettingActivity : NoSplashAppCompatActivity() {
@Inject lateinit var l :L
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_logsetting) setContentView(R.layout.activity_logsetting)
@ -19,7 +22,7 @@ class LogSettingActivity : NoSplashAppCompatActivity() {
createViewsForSettings() createViewsForSettings()
logsettings_reset.setOnClickListener { logsettings_reset.setOnClickListener {
L.resetToDefaults() l.resetToDefaults()
createViewsForSettings() createViewsForSettings()
} }
ok.setOnClickListener { finish() } ok.setOnClickListener { finish() }
@ -27,7 +30,7 @@ class LogSettingActivity : NoSplashAppCompatActivity() {
private fun createViewsForSettings() { private fun createViewsForSettings() {
logsettings_placeholder.removeAllViews() logsettings_placeholder.removeAllViews()
for (element in L.getLogElements()) { for (element in l.getLogElements()) {
val logViewHolder = LogViewHolder(element) val logViewHolder = LogViewHolder(element)
logsettings_placeholder.addView(logViewHolder.baseView) logsettings_placeholder.addView(logViewHolder.baseView)
} }

View file

@ -35,6 +35,7 @@ import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.aps.loop.APSResult; import info.nightscout.androidaps.plugins.aps.loop.APSResult;
import info.nightscout.androidaps.plugins.aps.loop.DeviceStatus; import info.nightscout.androidaps.plugins.aps.loop.DeviceStatus;
@ -50,7 +51,7 @@ import info.nightscout.androidaps.utils.SP;
* Created by mike on 26.05.2017. * Created by mike on 26.05.2017.
*/ */
public class NSUpload { public class NSUpload {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
public static void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) { public static void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) {
try { try {
@ -200,7 +201,7 @@ public class NSUpload {
deviceStatus.enacted.put("requested", requested); deviceStatus.enacted.put("requested", requested);
} }
} else { } else {
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(LTag.NSCLIENT))
log.debug("OpenAPS data too old to upload, sending iob only"); log.debug("OpenAPS data too old to upload, sending iob only");
IobTotal[] iob = iobCobCalculatorPlugin.calculateIobArrayInDia(profile); IobTotal[] iob = iobCobCalculatorPlugin.calculateIobArrayInDia(profile);
if (iob.length > 0) { if (iob.length > 0) {

View file

@ -9,7 +9,6 @@ import com.j256.ormlite.dao.CloseableIterator;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.SQLException; import java.sql.SQLException;
@ -18,6 +17,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.DbRequest; import info.nightscout.androidaps.db.DbRequest;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientResend; import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientResend;
@ -28,7 +28,7 @@ import info.nightscout.androidaps.utils.SP;
* Created by mike on 21.02.2016. * Created by mike on 21.02.2016.
*/ */
public class UploadQueue { public class UploadQueue {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
public static String status() { public static String status() {
return "QUEUE: " + MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS); return "QUEUE: " + MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS);
@ -48,7 +48,7 @@ public class UploadQueue {
public static void add(final DbRequest dbr) { public static void add(final DbRequest dbr) {
if (SP.getBoolean(R.string.key_ns_noupload, false)) return; if (SP.getBoolean(R.string.key_ns_noupload, false)) return;
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(LTag.NSCLIENT))
log.debug("Adding to queue: " + dbr.log()); log.debug("Adding to queue: " + dbr.log());
try { try {
MainApp.getDbHelper().create(dbr); MainApp.getDbHelper().create(dbr);
@ -62,10 +62,10 @@ public class UploadQueue {
startService(); startService();
if (NSClientService.handler != null) { if (NSClientService.handler != null) {
NSClientService.handler.post(() -> { NSClientService.handler.post(() -> {
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(LTag.NSCLIENT))
log.debug("ClearQueue"); log.debug("ClearQueue");
MainApp.getDbHelper().deleteAllDbRequests(); MainApp.getDbHelper().deleteAllDbRequests();
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(LTag.NSCLIENT))
log.debug(status()); log.debug(status());
}); });
} }
@ -83,7 +83,7 @@ public class UploadQueue {
return; return;
} }
if (MainApp.getDbHelper().deleteDbRequest(id) == 1) { if (MainApp.getDbHelper().deleteDbRequest(id) == 1) {
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(LTag.NSCLIENT))
log.debug("Removed item from UploadQueue. " + UploadQueue.status()); log.debug("Removed item from UploadQueue. " + UploadQueue.status());
} }
} catch (JSONException e) { } catch (JSONException e) {
@ -100,7 +100,7 @@ public class UploadQueue {
if (NSClientService.handler != null) { if (NSClientService.handler != null) {
NSClientService.handler.post(() -> { NSClientService.handler.post(() -> {
MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id); MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(LTag.NSCLIENT))
log.debug("Removing " + _id + " from UploadQueue. " + UploadQueue.status()); log.debug("Removing " + _id + " from UploadQueue. " + UploadQueue.status());
}); });
} }

View file

@ -3,10 +3,10 @@ package info.nightscout.androidaps.plugins.general.nsclient.acks;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart; import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
@ -16,7 +16,7 @@ import io.socket.client.Ack;
* Created by mike on 29.12.2015. * Created by mike on 29.12.2015.
*/ */
public class NSAddAck extends Event implements Ack { public class NSAddAck extends Event implements Ack {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
public String _id = null; public String _id = null;
public String nsClientID = null; public String nsClientID = null;
public JSONObject json = null; public JSONObject json = null;
@ -48,7 +48,7 @@ public class NSAddAck extends Event implements Ack {
RxBus.Companion.getINSTANCE().send(new EventNSClientRestart()); RxBus.Companion.getINSTANCE().send(new EventNSClientRestart());
return; return;
} }
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(LTag.NSCLIENT))
log.debug("DBACCESS " + response.getString("result")); log.debug("DBACCESS " + response.getString("result"));
} }
return; return;

View file

@ -3,10 +3,9 @@ package info.nightscout.androidaps.plugins.general.nsclient.acks;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.bus.RxBus;
import io.socket.client.Ack; import io.socket.client.Ack;
@ -15,10 +14,11 @@ import io.socket.client.Ack;
* Created by mike on 21.02.2016. * Created by mike on 21.02.2016.
*/ */
public class NSUpdateAck extends Event implements Ack { public class NSUpdateAck extends Event implements Ack {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
public boolean result = false; public boolean result = false;
public String _id; public String _id;
public String action; public String action;
public void call(Object... args) { public void call(Object... args) {
JSONObject response = (JSONObject) args[0]; JSONObject response = (JSONObject) args[0];
if (response.has("result")) if (response.has("result"))

View file

@ -3,13 +3,12 @@ package info.nightscout.androidaps.plugins.general.nsclient.data;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
public class NSMbg { public class NSMbg {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
public long date; public long date;
public double mbg; public double mbg;
public String json; public String json;

View file

@ -6,6 +6,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
/** /**
@ -13,7 +14,7 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
* {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100} * {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100}
*/ */
public class NSSgv { public class NSSgv {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private JSONObject data; private JSONObject data;

View file

@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.general.nsclient.data;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
public class NSTreatment { public class NSTreatment {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private JSONObject data; private JSONObject data;
private String action = null; // "update", "remove" or null (add) private String action = null; // "update", "remove" or null (add)
@ -82,15 +81,47 @@ public class NSTreatment {
return ret; return ret;
} }
public String getAction() { return action; } public String getAction() {
public JSONObject getData() { return data; } return action;
public String get_id() { return getStringOrNull("_id"); } }
public String getEnteredBy() { return getStringOrNull("enteredBy"); }
public String getEventType() { return getStringOrNull("eventType"); } public JSONObject getData() {
public Integer getHapp_id() { return getIntegerOrNull("happ_id"); } return data;
public Integer getDuration() { return getIntegerOrNull("duration"); } }
public Integer getMgdl() { return getIntegerOrNull("mgdl"); }
public Double getAbsolute() { return getDoubleOrNull("absolute"); } public String get_id() {
public Long getMills() { return getLongOrNull("mills"); } return getStringOrNull("_id");
public Date getCreated_at() { return getDateOrNull("created_at"); } }
public String getEnteredBy() {
return getStringOrNull("enteredBy");
}
public String getEventType() {
return getStringOrNull("eventType");
}
public Integer getHapp_id() {
return getIntegerOrNull("happ_id");
}
public Integer getDuration() {
return getIntegerOrNull("duration");
}
public Integer getMgdl() {
return getIntegerOrNull("mgdl");
}
public Double getAbsolute() {
return getDoubleOrNull("absolute");
}
public Long getMills() {
return getLongOrNull("mills");
}
public Date getCreated_at() {
return getDateOrNull("created_at");
}
} }

View file

@ -92,7 +92,7 @@ public class NSClientService extends DaggerService {
@Inject NSClientPlugin nsClientPlugin; @Inject NSClientPlugin nsClientPlugin;
@Inject BuildHelper buildHelper; @Inject BuildHelper buildHelper;
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
static public PowerManager.WakeLock mWakeLock; static public PowerManager.WakeLock mWakeLock;
@ -178,7 +178,7 @@ public class NSClientService extends DaggerService {
.toObservable(EventAppExit.class) .toObservable(EventAppExit.class)
.observeOn(Schedulers.io()) .observeOn(Schedulers.io())
.subscribe(event -> { .subscribe(event -> {
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(LTag.NSCLIENT))
log.debug("EventAppExit received"); log.debug("EventAppExit received");
destroy(); destroy();
stopSelf(); stopSelf();
@ -367,7 +367,7 @@ public class NSClientService extends DaggerService {
private Emitter.Listener onDisconnect = new Emitter.Listener() { private Emitter.Listener onDisconnect = new Emitter.Listener() {
@Override @Override
public void call(Object... args) { public void call(Object... args) {
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(LTag.NSCLIENT))
log.debug("disconnect reason: {}", args); log.debug("disconnect reason: {}", args);
rxBus.send(new EventNSClientNewLog("NSCLIENT", "disconnect event")); rxBus.send(new EventNSClientNewLog("NSCLIENT", "disconnect event"));
} }
@ -804,7 +804,7 @@ public class NSClientService extends DaggerService {
if (mSocket == null || !mSocket.connected()) return; if (mSocket == null || !mSocket.connected()) return;
if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) { if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) {
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(LTag.NSCLIENT))
log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec"); log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
return; return;
} }

View file

@ -24,6 +24,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.services.AlarmSoundService import info.nightscout.androidaps.services.AlarmSoundService
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.resources.IconsProvider
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 java.util.* import java.util.*
@ -36,7 +37,8 @@ class NotificationStore @Inject constructor(
private val sp: SP, private val sp: SP,
private val rxBus: RxBusWrapper, private val rxBus: RxBusWrapper,
private val resourceHelper: ResourceHelper, private val resourceHelper: ResourceHelper,
private val context: Context private val context: Context,
private val iconsProvider: IconsProvider
) { ) {
var store: MutableList<Notification> = ArrayList() var store: MutableList<Notification> = ArrayList()
@ -109,8 +111,8 @@ class NotificationStore @Inject constructor(
private fun raiseSystemNotification(n: Notification) { private fun raiseSystemNotification(n: Notification) {
val mgr = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val mgr = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val largeIcon = resourceHelper.decodeResource(resourceHelper.getIcon()) val largeIcon = resourceHelper.decodeResource(iconsProvider.getIcon())
val smallIcon = resourceHelper.getNotificationIcon() val smallIcon = iconsProvider.getNotificationIcon()
val sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM) val sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM)
val notificationBuilder = NotificationCompat.Builder(context, CHANNEL_ID) val notificationBuilder = NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(smallIcon) .setSmallIcon(smallIcon)

View file

@ -28,6 +28,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutos
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.androidNotification.NotificationHolder
import info.nightscout.androidaps.utils.resources.IconsProvider
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 +46,8 @@ 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 notificationHolder: NotificationHolder private var notificationHolder: NotificationHolder,
private val iconsProvider: IconsProvider
) : PluginBase(PluginDescription() ) : PluginBase(PluginDescription()
.mainType(PluginType.GENERAL) .mainType(PluginType.GENERAL)
.neverVisible(true) .neverVisible(true)
@ -209,8 +211,8 @@ class PersistentNotificationPlugin @Inject constructor(
builder.setOngoing(true) builder.setOngoing(true)
builder.setOnlyAlertOnce(true) builder.setOnlyAlertOnce(true)
builder.setCategory(NotificationCompat.CATEGORY_STATUS) builder.setCategory(NotificationCompat.CATEGORY_STATUS)
builder.setSmallIcon(resourceHelper.getNotificationIcon()) builder.setSmallIcon(iconsProvider.getNotificationIcon())
builder.setLargeIcon(resourceHelper.decodeResource(resourceHelper.getIcon())) builder.setLargeIcon(resourceHelper.decodeResource(iconsProvider.getIcon()))
if (line1 != null) builder.setContentTitle(line1) if (line1 != null) builder.setContentTitle(line1)
if (line2 != null) builder.setContentText(line2) if (line2 != null) builder.setContentText(line2)
if (line3 != null) builder.setSubText(line3) if (line3 != null) builder.setSubText(line3)

View file

@ -4,13 +4,13 @@ import android.bluetooth.BluetoothSocket;
import android.os.SystemClock; import android.os.SystemClock;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase; import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageHashTableBase; import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageHashTableBase;
@ -21,7 +21,7 @@ import info.nightscout.androidaps.utils.CRC;
* Created by mike on 17.07.2016. * Created by mike on 17.07.2016.
*/ */
public class SerialIOThread extends AbstractSerialIOThread { public class SerialIOThread extends AbstractSerialIOThread {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPBTCOMM); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.PUMPBTCOMM);
private InputStream mInputStream = null; private InputStream mInputStream = null;
private OutputStream mOutputStream = null; private OutputStream mOutputStream = null;
@ -76,7 +76,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
message = hashTable.findMessage(command); message = hashTable.findMessage(command);
} }
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("<<<<< " + message.getMessageName() + " " + MessageBase.toHexString(extractedBuff)); log.debug("<<<<< " + message.getMessageName() + " " + MessageBase.toHexString(extractedBuff));
// process the message content // process the message content
@ -152,7 +152,7 @@ public class SerialIOThread extends AbstractSerialIOThread {
processedMessage = message; processedMessage = message;
byte[] messageBytes = message.getRawMessageBytes(); byte[] messageBytes = message.getRawMessageBytes();
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug(">>>>> " + message.getMessageName() + " " + MessageBase.toHexString(messageBytes)); log.debug(">>>>> " + message.getMessageName() + " " + MessageBase.toHexString(messageBytes));
try { try {
@ -172,11 +172,11 @@ public class SerialIOThread extends AbstractSerialIOThread {
SystemClock.sleep(200); SystemClock.sleep(200);
if (!message.isReceived()) { if (!message.isReceived()) {
message.handleMessageNotReceived(); message.handleMessageNotReceived();
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.error("Reply not received " + message.getMessageName()); log.error("Reply not received " + message.getMessageName());
if (message.getCommand() == 0xF0F1) { if (message.getCommand() == 0xF0F1) {
danaRPump.setNewPump(false); danaRPump.setNewPump(false);
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(LTag.PUMPCOMM))
log.debug("Old firmware detected"); log.debug("Old firmware detected");
} }
} }
@ -188,28 +188,28 @@ public class SerialIOThread extends AbstractSerialIOThread {
try { try {
mInputStream.close(); mInputStream.close();
} catch (Exception e) { } catch (Exception e) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug(e.getMessage()); log.debug(e.getMessage());
} }
try { try {
mOutputStream.close(); mOutputStream.close();
} catch (Exception e) { } catch (Exception e) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug(e.getMessage()); log.debug(e.getMessage());
} }
try { try {
mRfCommSocket.close(); mRfCommSocket.close();
} catch (Exception e) { } catch (Exception e) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug(e.getMessage()); log.debug(e.getMessage());
} }
try { try {
System.runFinalization(); System.runFinalization();
} catch (Exception e) { } catch (Exception e) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug(e.getMessage()); log.debug(e.getMessage());
} }
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("Disconnected: " + reason); log.debug("Disconnected: " + reason);
} }

View file

@ -11,7 +11,6 @@ import info.nightscout.androidaps.events.EventInitializationChanged
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.L
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.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
@ -71,7 +70,6 @@ class DanaRUserOptionsActivity : NoSplashAppCompatActivity() {
save_user_options.setOnClickListener { onSaveClick() } save_user_options.setOnClickListener { onSaveClick() }
if (L.isEnabled(L.PUMP))
aapsLogger.debug(LTag.PUMP, aapsLogger.debug(LTag.PUMP,
"UserOptionsLoaded:" + (System.currentTimeMillis() - danaRPump.lastConnection) / 1000 + " s ago" "UserOptionsLoaded:" + (System.currentTimeMillis() - danaRPump.lastConnection) / 1000 + " s ago"
+ "\ntimeDisplayType:" + danaRPump.timeDisplayType + "\ntimeDisplayType:" + danaRPump.timeDisplayType

View file

@ -13,6 +13,7 @@ import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.utils.CRC; import info.nightscout.androidaps.utils.CRC;
@ -23,7 +24,7 @@ import info.nightscout.androidaps.utils.CRC;
*/ */
public class MessageBase { public class MessageBase {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.PUMPCOMM);
public byte[] buffer = new byte[512]; public byte[] buffer = new byte[512];
private int position = 6; private int position = 6;
@ -96,7 +97,7 @@ public class MessageBase {
} }
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
if (L.isEnabled(L.PUMPCOMM)) { if (L.isEnabled(LTag.PUMPCOMM)) {
if (bytes.length > 6) { if (bytes.length > 6) {
int command = (bytes[5] & 0xFF) | ((bytes[4] << 8) & 0xFF00); int command = (bytes[5] & 0xFF) | ((bytes[4] << 8) & 0xFF00);
log.debug("UNPROCESSED MSG: " + getMessageName() + " Command: " + String.format("%04X", command) + " Data: " + toHexString(bytes)); log.debug("UNPROCESSED MSG: " + getMessageName() + " Command: " + String.format("%04X", command) + " Data: " + toHexString(bytes));

View file

@ -1,11 +1,7 @@
package info.nightscout.androidaps.plugins.pump.danaR.comm package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.logging.L.isEnabled
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper.Companion.getLogger
import org.slf4j.Logger
class MsgSetTempBasalStop( class MsgSetTempBasalStop(
private val aapsLogger: AAPSLogger private val aapsLogger: AAPSLogger

View file

@ -2,10 +2,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm
import com.cozmo.danar.util.BleCommandUtil import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.logging.L.isEnabled
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import org.slf4j.LoggerFactory
class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear( class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(
private val aapsLogger: AAPSLogger private val aapsLogger: AAPSLogger
@ -15,6 +12,7 @@ class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR
aapsLogger.debug(LTag.PUMPCOMM, "New message") aapsLogger.debug(LTag.PUMPCOMM, "New message")
} }
override fun handleMessage(data: ByteArray) { override fun handleMessage(data: ByteArray) {
val result = intFromBuff(data, 0, 1) val result = intFromBuff(data, 0, 1)
if (result == 0) { if (result == 0) {

View file

@ -26,6 +26,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
@ -44,7 +45,7 @@ import info.nightscout.androidaps.utils.SP;
*/ */
public class BLEComm { public class BLEComm {
private Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPBTCOMM); private Logger log = StacktraceLoggerWrapper.getLogger(LTag.PUMPBTCOMM);
private final long WRITE_DELAY_MILLIS = 50; private final long WRITE_DELAY_MILLIS = 50;
@ -81,7 +82,7 @@ public class BLEComm {
private BluetoothGattCharacteristic UART_Write; private BluetoothGattCharacteristic UART_Write;
private boolean initialize() { private boolean initialize() {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("Initializing BLEComm."); log.debug("Initializing BLEComm.");
if (mBluetoothManager == null) { if (mBluetoothManager == null) {
@ -139,7 +140,7 @@ public class BLEComm {
return false; return false;
} }
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("Trying to create a new connection from: " + from); log.debug("Trying to create a new connection from: " + from);
mBluetoothDeviceName = device.getName(); mBluetoothDeviceName = device.getName();
mBluetoothGatt = device.connectGatt(context, false, mGattCallback); mBluetoothGatt = device.connectGatt(context, false, mGattCallback);
@ -152,7 +153,7 @@ public class BLEComm {
} }
public synchronized void disconnect(String from) { public synchronized void disconnect(String from) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("disconnect from: " + from); log.debug("disconnect from: " + from);
// cancel previous scheduled disconnection to prevent closing upcomming connection // cancel previous scheduled disconnection to prevent closing upcomming connection
@ -172,7 +173,7 @@ public class BLEComm {
} }
public synchronized void close() { public synchronized void close() {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("BluetoothAdapter close"); log.debug("BluetoothAdapter close");
if (mBluetoothGatt == null) { if (mBluetoothGatt == null) {
return; return;
@ -193,7 +194,7 @@ public class BLEComm {
} }
public void onServicesDiscovered(BluetoothGatt gatt, int status) { public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("onServicesDiscovered"); log.debug("onServicesDiscovered");
if (status == BluetoothGatt.GATT_SUCCESS) { if (status == BluetoothGatt.GATT_SUCCESS) {
findCharacteristic(); findCharacteristic();
@ -203,21 +204,21 @@ public class BLEComm {
} }
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("onCharacteristicRead" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); log.debug("onCharacteristicRead" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
addToReadBuffer(characteristic.getValue()); addToReadBuffer(characteristic.getValue());
readDataParsing(); readDataParsing();
} }
public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) { public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("onCharacteristicChanged" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); log.debug("onCharacteristicChanged" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
addToReadBuffer(characteristic.getValue()); addToReadBuffer(characteristic.getValue());
new Thread(() -> readDataParsing()).start(); new Thread(() -> readDataParsing()).start();
} }
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("onCharacteristicWrite" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); log.debug("onCharacteristicWrite" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
new Thread(() -> { new Thread(() -> {
synchronized (mSendQueue) { synchronized (mSendQueue) {
@ -233,7 +234,7 @@ public class BLEComm {
}; };
private synchronized void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) { private synchronized void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("setCharacteristicNotification"); log.debug("setCharacteristicNotification");
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
log.error("BluetoothAdapter not initialized_ERROR"); log.error("BluetoothAdapter not initialized_ERROR");
@ -245,7 +246,7 @@ public class BLEComm {
} }
public synchronized void readCharacteristic(BluetoothGattCharacteristic characteristic) { public synchronized void readCharacteristic(BluetoothGattCharacteristic characteristic) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("readCharacteristic"); log.debug("readCharacteristic");
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
log.error("BluetoothAdapter not initialized_ERROR"); log.error("BluetoothAdapter not initialized_ERROR");
@ -269,7 +270,7 @@ public class BLEComm {
characteristic.setValue(data); characteristic.setValue(data);
characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data)); log.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data));
mBluetoothGatt.writeCharacteristic(characteristic); mBluetoothGatt.writeCharacteristic(characteristic);
}).start(); }).start();
@ -290,7 +291,7 @@ public class BLEComm {
} }
private List<BluetoothGattService> getSupportedGattServices() { private List<BluetoothGattService> getSupportedGattServices() {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("getSupportedGattServices"); log.debug("getSupportedGattServices");
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
log.error("BluetoothAdapter not initialized_ERROR"); log.error("BluetoothAdapter not initialized_ERROR");
@ -326,7 +327,7 @@ public class BLEComm {
} }
private synchronized void onConnectionStateChangeSynchronized(BluetoothGatt gatt, int status, int newState) { private synchronized void onConnectionStateChangeSynchronized(BluetoothGatt gatt, int status, int newState) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("onConnectionStateChange"); log.debug("onConnectionStateChange");
if (newState == BluetoothProfile.STATE_CONNECTED) { if (newState == BluetoothProfile.STATE_CONNECTED) {
@ -336,7 +337,7 @@ public class BLEComm {
isConnected = false; isConnected = false;
isConnecting = false; isConnecting = false;
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED)); RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED));
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected
} }
} }
@ -372,7 +373,7 @@ public class BLEComm {
if ((readBuffer[idxStartByte] == PACKET_START_BYTE) && (readBuffer[idxStartByte + 1] == PACKET_START_BYTE)) { if ((readBuffer[idxStartByte] == PACKET_START_BYTE) && (readBuffer[idxStartByte + 1] == PACKET_START_BYTE)) {
if (idxStartByte > 0) { if (idxStartByte > 0) {
// if buffer doesn't start with signature remove the leading trash // if buffer doesn't start with signature remove the leading trash
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("Shifting the input buffer by " + idxStartByte + " bytes"); log.debug("Shifting the input buffer by " + idxStartByte + " bytes");
System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte); System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte);
bufferLength -= idxStartByte; bufferLength -= idxStartByte;
@ -427,16 +428,16 @@ public class BLEComm {
// 1st packet // 1st packet
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK: case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK:
if (inputBuffer.length == 4 && inputBuffer[2] == 'O' && inputBuffer[3] == 'K') { if (inputBuffer.length == 4 && inputBuffer[2] == 'O' && inputBuffer[3] == 'K') {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer)); log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer));
// Grab pairing key from preferences if exists // Grab pairing key from preferences if exists
String pairingKey = SP.getString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null); String pairingKey = SP.getString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null);
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("Using stored pairing key: " + pairingKey); log.debug("Using stored pairing key: " + pairingKey);
if (pairingKey != null) { if (pairingKey != null) {
byte[] encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey); byte[] encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey);
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null);
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug(">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)); log.debug(">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes));
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
} else { } else {
@ -445,7 +446,7 @@ public class BLEComm {
} }
} else if (inputBuffer.length == 6 && inputBuffer[2] == 'P' && inputBuffer[3] == 'U' && inputBuffer[4] == 'M' && inputBuffer[5] == 'P') { } else if (inputBuffer.length == 6 && inputBuffer[2] == 'P' && inputBuffer[3] == 'U' && inputBuffer[4] == 'M' && inputBuffer[5] == 'P') {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer)); log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer));
mSendQueue.clear(); mSendQueue.clear();
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.pumperror))); RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.pumperror)));
@ -453,13 +454,13 @@ public class BLEComm {
Notification n = new Notification(Notification.PUMPERROR, MainApp.gs(R.string.pumperror), Notification.URGENT); Notification n = new Notification(Notification.PUMPERROR, MainApp.gs(R.string.pumperror), Notification.URGENT);
RxBus.Companion.getINSTANCE().send(new EventNewNotification(n)); RxBus.Companion.getINSTANCE().send(new EventNewNotification(n));
} else if (inputBuffer.length == 6 && inputBuffer[2] == 'B' && inputBuffer[3] == 'U' && inputBuffer[4] == 'S' && inputBuffer[5] == 'Y') { } else if (inputBuffer.length == 6 && inputBuffer[2] == 'B' && inputBuffer[3] == 'U' && inputBuffer[4] == 'S' && inputBuffer[5] == 'Y') {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer)); log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer));
mSendQueue.clear(); mSendQueue.clear();
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.pumpbusy))); RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.pumpbusy)));
} else { } else {
// ERROR in response, wrong serial number // ERROR in response, wrong serial number
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer)); log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer));
mSendQueue.clear(); mSendQueue.clear();
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.connectionerror))); RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.connectionerror)));
@ -470,7 +471,7 @@ public class BLEComm {
break; break;
// 2nd packet, pairing key // 2nd packet, pairing key
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY: case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY:
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(inputBuffer)); log.debug("<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(inputBuffer));
if (inputBuffer[2] == (byte) 0x00) { if (inputBuffer[2] == (byte) 0x00) {
// Paring is not requested, sending time info // Paring is not requested, sending time info
@ -481,7 +482,7 @@ public class BLEComm {
} }
break; break;
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST: case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST:
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(inputBuffer)); log.debug("<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(inputBuffer));
if (inputBuffer[2] != (byte) 0x00) { if (inputBuffer[2] != (byte) 0x00) {
disconnect("passkey request failed"); disconnect("passkey request failed");
@ -489,7 +490,7 @@ public class BLEComm {
break; break;
// Paring response, OK button on pump pressed // Paring response, OK button on pump pressed
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN: case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN:
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(inputBuffer)); log.debug("<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(inputBuffer));
// Paring is successfull, sending time info // Paring is successfull, sending time info
RxBus.Companion.getINSTANCE().send(new EventDanaRSPairingSuccess()); RxBus.Companion.getINSTANCE().send(new EventDanaRSPairingSuccess());
@ -497,24 +498,24 @@ public class BLEComm {
byte[] pairingKey = {inputBuffer[2], inputBuffer[3]}; byte[] pairingKey = {inputBuffer[2], inputBuffer[3]};
// store pairing key to preferences // store pairing key to preferences
SP.putString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)); SP.putString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey));
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)); log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey));
break; break;
// time and user password information. last packet in handshake // time and user password information. last packet in handshake
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION: case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION:
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */ DanaRS_Packet.toHexString(inputBuffer)); log.debug("<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */ DanaRS_Packet.toHexString(inputBuffer));
int size = inputBuffer.length; int size = inputBuffer.length;
int pass = ((inputBuffer[size - 1] & 0x000000FF) << 8) + ((inputBuffer[size - 2] & 0x000000FF)); int pass = ((inputBuffer[size - 1] & 0x000000FF) << 8) + ((inputBuffer[size - 2] & 0x000000FF));
pass = pass ^ 3463; pass = pass ^ 3463;
danaRPump.setRsPassword(Integer.toHexString(pass)); danaRPump.setRsPassword(Integer.toHexString(pass));
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("Pump user password: " + Integer.toHexString(pass)); log.debug("Pump user password: " + Integer.toHexString(pass));
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)); RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED));
isConnected = true; isConnected = true;
isConnecting = false; isConnecting = false;
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("RS connected and status read"); log.debug("RS connected and status read");
break; break;
} }
@ -533,7 +534,7 @@ public class BLEComm {
message = danaRSMessageHashTable.findMessage(receivedCommand); message = danaRSMessageHashTable.findMessage(receivedCommand);
} }
if (message != null) { if (message != null) {
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug("<<<<< " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(inputBuffer)); log.debug("<<<<< " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(inputBuffer));
// process received data // process received data
message.handleMessage(inputBuffer); message.handleMessage(inputBuffer);
@ -570,7 +571,7 @@ public class BLEComm {
byte[] command = {(byte) message.getType(), (byte) message.getOpCode()}; byte[] command = {(byte) message.getType(), (byte) message.getOpCode()};
byte[] params = message.getRequestParams(); byte[] params = message.getRequestParams();
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug(">>>>> " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params)); log.debug(">>>>> " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params));
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(message.getOpCode(), params, null); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(message.getOpCode(), params, null);
// If there is another message not completely sent, add to queue only // If there is another message not completely sent, add to queue only
@ -652,7 +653,7 @@ public class BLEComm {
MainApp.instance().startActivity(i); MainApp.instance().startActivity(i);
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null);
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug(">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes)); log.debug(">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes));
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
} }
@ -666,14 +667,14 @@ public class BLEComm {
return; return;
} }
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, devicename); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, devicename);
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes)); log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes));
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
} }
private void SendTimeInfo() { private void SendTimeInfo() {
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null);
if (L.isEnabled(L.PUMPBTCOMM)) if (L.isEnabled(LTag.PUMPBTCOMM))
log.debug(">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)); log.debug(">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes));
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
} }

View file

@ -2,13 +2,12 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.cgms;
import org.joda.time.LocalDateTime; import org.joda.time.LocalDateTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.MedtronicHistoryDecoder; import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.MedtronicHistoryDecoder;
@ -23,7 +22,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.RecordDeco
public class MedtronicCGMSHistoryDecoder extends MedtronicHistoryDecoder<CGMSHistoryEntry> { public class MedtronicCGMSHistoryDecoder extends MedtronicHistoryDecoder<CGMSHistoryEntry> {
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM); private static final Logger LOG = StacktraceLoggerWrapper.getLogger(LTag.PUMPCOMM);
// CGMSValuesWriter cgmsValuesWriter = null; // CGMSValuesWriter cgmsValuesWriter = null;

View file

@ -364,7 +364,7 @@ public class BasalProfile {
private boolean isLogEnabled() { private boolean isLogEnabled() {
return L.isEnabled(L.PUMPCOMM); return L.isEnabled(LTag.PUMPCOMM);
} }
public boolean verify(PumpType pumpType) { public boolean verify(PumpType pumpType) {

View file

@ -42,7 +42,7 @@ public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.commo
public TempBasalPair(AAPSLogger aapsLogger, byte[] response) { public TempBasalPair(AAPSLogger aapsLogger, byte[] response) {
super(); super();
if (L.isEnabled(L.PUMPCOMM)) if (L.isEnabled(LTag.PUMPCOMM))
aapsLogger.debug(LTag.PUMPBTCOMM, "Received TempBasal response: " + ByteUtil.getHex(response)); aapsLogger.debug(LTag.PUMPBTCOMM, "Received TempBasal response: " + ByteUtil.getHex(response));
isPercent = response[0] == 1; isPercent = response[0] == 1;

View file

@ -82,7 +82,6 @@ public class OmnipodManager {
this.podStateChangedHandler = podStateChangedHandler; this.podStateChangedHandler = podStateChangedHandler;
} }
public synchronized Single<SetupActionResult> pairAndPrime() { public synchronized Single<SetupActionResult> pairAndPrime() {
logStartingCommandExecution("pairAndPrime"); logStartingCommandExecution("pairAndPrime");

View file

@ -8,6 +8,7 @@ import java.util.Date;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
@ -19,7 +20,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
public class OmnipodUIPostprocessor { public class OmnipodUIPostprocessor {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP); private static final Logger LOG = LoggerFactory.getLogger(LTag.PUMP.name());
private OmnipodPumpStatus pumpStatus; private OmnipodPumpStatus pumpStatus;
private OmnipodPumpPluginInterface omnipodPumpPlugin; private OmnipodPumpPluginInterface omnipodPumpPlugin;
@ -102,7 +103,7 @@ public class OmnipodUIPostprocessor {
private boolean isLogEnabled() { private boolean isLogEnabled() {
return L.isEnabled(L.PUMP); return L.isEnabled(LTag.PUMP);
} }
public RxBusWrapper getRxBus() { public RxBusWrapper getRxBus() {

View file

@ -12,8 +12,6 @@ import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.logging.L.isEnabled
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
@ -48,7 +46,6 @@ class EversensePlugin @Inject constructor(
override fun handleNewData(intent: Intent) { override fun handleNewData(intent: Intent) {
if (!isEnabled(PluginType.BGSOURCE)) return if (!isEnabled(PluginType.BGSOURCE)) return
val bundle = intent.extras ?: return val bundle = intent.extras ?: return
if (isEnabled(L.BGSOURCE)) {
if (bundle.containsKey("currentCalibrationPhase")) aapsLogger.debug(LTag.BGSOURCE, "currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase")) if (bundle.containsKey("currentCalibrationPhase")) aapsLogger.debug(LTag.BGSOURCE, "currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase"))
if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress")) if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress"))
if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel")) if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel"))
@ -64,17 +61,14 @@ class EversensePlugin @Inject constructor(
if (bundle.containsKey("sensorInsertionTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "sensorInsertionTimestamp: " + DateUtil.dateAndTimeString(bundle.getLong("sensorInsertionTimestamp"))) if (bundle.containsKey("sensorInsertionTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "sensorInsertionTimestamp: " + DateUtil.dateAndTimeString(bundle.getLong("sensorInsertionTimestamp")))
if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber")) if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber"))
if (bundle.containsKey("transmitterConnectionState")) aapsLogger.debug(LTag.BGSOURCE, "transmitterConnectionState: " + bundle.getString("transmitterConnectionState")) if (bundle.containsKey("transmitterConnectionState")) aapsLogger.debug(LTag.BGSOURCE, "transmitterConnectionState: " + bundle.getString("transmitterConnectionState"))
}
if (bundle.containsKey("glucoseLevels")) { if (bundle.containsKey("glucoseLevels")) {
val glucoseLevels = bundle.getIntArray("glucoseLevels") val glucoseLevels = bundle.getIntArray("glucoseLevels")
val glucoseRecordNumbers = bundle.getIntArray("glucoseRecordNumbers") val glucoseRecordNumbers = bundle.getIntArray("glucoseRecordNumbers")
val glucoseTimestamps = bundle.getLongArray("glucoseTimestamps") val glucoseTimestamps = bundle.getLongArray("glucoseTimestamps")
if (glucoseLevels != null && glucoseRecordNumbers != null && glucoseTimestamps != null) { if (glucoseLevels != null && glucoseRecordNumbers != null && glucoseTimestamps != null) {
if (isEnabled(L.BGSOURCE)) {
aapsLogger.debug(LTag.BGSOURCE, "glucoseLevels" + Arrays.toString(glucoseLevels)) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevels" + Arrays.toString(glucoseLevels))
aapsLogger.debug(LTag.BGSOURCE, "glucoseRecordNumbers" + Arrays.toString(glucoseRecordNumbers)) aapsLogger.debug(LTag.BGSOURCE, "glucoseRecordNumbers" + Arrays.toString(glucoseRecordNumbers))
aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamps" + Arrays.toString(glucoseTimestamps)) aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamps" + Arrays.toString(glucoseTimestamps))
}
for (i in glucoseLevels.indices) { for (i in glucoseLevels.indices) {
val bgReading = BgReading() val bgReading = BgReading()
bgReading.value = glucoseLevels[i].toDouble() bgReading.value = glucoseLevels[i].toDouble()
@ -95,11 +89,9 @@ class EversensePlugin @Inject constructor(
val calibrationTimestamps = bundle.getLongArray("calibrationTimestamps") val calibrationTimestamps = bundle.getLongArray("calibrationTimestamps")
val calibrationRecordNumbers = bundle.getLongArray("calibrationRecordNumbers") val calibrationRecordNumbers = bundle.getLongArray("calibrationRecordNumbers")
if (calibrationGlucoseLevels != null && calibrationTimestamps != null && calibrationRecordNumbers != null) { if (calibrationGlucoseLevels != null && calibrationTimestamps != null && calibrationRecordNumbers != null) {
if (isEnabled(L.BGSOURCE)) {
aapsLogger.debug(LTag.BGSOURCE, "calibrationGlucoseLevels" + Arrays.toString(calibrationGlucoseLevels)) aapsLogger.debug(LTag.BGSOURCE, "calibrationGlucoseLevels" + Arrays.toString(calibrationGlucoseLevels))
aapsLogger.debug(LTag.BGSOURCE, "calibrationTimestamps" + Arrays.toString(calibrationTimestamps)) aapsLogger.debug(LTag.BGSOURCE, "calibrationTimestamps" + Arrays.toString(calibrationTimestamps))
aapsLogger.debug(LTag.BGSOURCE, "calibrationRecordNumbers" + Arrays.toString(calibrationRecordNumbers)) aapsLogger.debug(LTag.BGSOURCE, "calibrationRecordNumbers" + Arrays.toString(calibrationRecordNumbers))
}
for (i in calibrationGlucoseLevels.indices) { for (i in calibrationGlucoseLevels.indices) {
try { try {
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(calibrationTimestamps[i]) == null) { if (MainApp.getDbHelper().getCareportalEventFromTimestamp(calibrationTimestamps[i]) == null) {

View file

@ -19,26 +19,6 @@ public class SP {
return sharedPreferences.getAll(); return sharedPreferences.getAll();
} }
@Deprecated
static public void clear() {
sharedPreferences.edit().clear().apply();
}
@Deprecated
static public boolean contains(String key) {
return sharedPreferences.contains(key);
}
@Deprecated
static public boolean contains(int resourceId) {
return sharedPreferences.contains(MainApp.gs(resourceId));
}
@Deprecated
static public String getString(int resourceID, String defaultValue) {
return sharedPreferences.getString(MainApp.gs(resourceID), defaultValue);
}
@Deprecated @Deprecated
static public String getString(String key, String defaultValue) { static public String getString(String key, String defaultValue) {
return sharedPreferences.getString(key, defaultValue); return sharedPreferences.getString(key, defaultValue);
@ -53,102 +33,6 @@ public class SP {
} }
} }
@Deprecated
static public boolean getBoolean(String key, Boolean defaultValue) {
try {
return sharedPreferences.getBoolean(key, defaultValue);
} catch (Exception e) {
return defaultValue;
}
}
@Deprecated
static public Double getDouble(int resourceID, Double defaultValue) {
return SafeParse.stringToDouble(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString()));
}
@Deprecated
static public Double getDouble(String key, Double defaultValue) {
return SafeParse.stringToDouble(sharedPreferences.getString(key, defaultValue.toString()));
}
@Deprecated
static public int getInt(int resourceID, Integer defaultValue) {
try {
return sharedPreferences.getInt(MainApp.gs(resourceID), defaultValue);
} catch (Exception e) {
return SafeParse.stringToInt(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString()));
}
}
@Deprecated
static public int getInt(String key, Integer defaultValue) {
try {
return sharedPreferences.getInt(key, defaultValue);
} catch (Exception e) {
return SafeParse.stringToInt(sharedPreferences.getString(key, defaultValue.toString()));
}
}
@Deprecated
static public long getLong(int resourceID, Long defaultValue) {
try {
return sharedPreferences.getLong(MainApp.gs(resourceID), defaultValue);
} catch (Exception e) {
return SafeParse.stringToLong(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString()));
}
}
@Deprecated
static public long getLong(String key, Long defaultValue) {
try {
return sharedPreferences.getLong(key, defaultValue);
} catch (Exception e) {
return SafeParse.stringToLong(sharedPreferences.getString(key, defaultValue.toString()));
}
}
@Deprecated
static public void putBoolean(String key, boolean value) {
sharedPreferences.edit().putBoolean(key, value).apply();
}
@Deprecated
static public void putBoolean(int resourceID, boolean value) {
sharedPreferences.edit().putBoolean(MainApp.gs(resourceID), value).apply();
}
@Deprecated
static public void putDouble(String key, double value) {
sharedPreferences.edit().putString(key, Double.toString(value)).apply();
}
@Deprecated
static public void putLong(String key, long value) {
sharedPreferences.edit().putLong(key, value).apply();
}
@Deprecated
static public void putLong(int resourceID, long value) {
sharedPreferences.edit().putLong(MainApp.gs(resourceID), value).apply();
}
@Deprecated
static public void putInt(String key, int value) {
sharedPreferences.edit().putInt(key, value).apply();
}
@Deprecated
static public void putInt(int resourceID, int value) {
sharedPreferences.edit().putInt(MainApp.gs(resourceID), value).apply();
}
@Deprecated
static public void incInt(int resourceID) {
int value = getInt(resourceID, 0) + 1;
sharedPreferences.edit().putInt(MainApp.gs(resourceID), value).apply();
}
@Deprecated @Deprecated
static public void putString(int resourceID, String value) { static public void putString(int resourceID, String value) {
sharedPreferences.edit().putString(MainApp.gs(resourceID), value).apply(); sharedPreferences.edit().putString(MainApp.gs(resourceID), value).apply();
@ -159,11 +43,6 @@ public class SP {
sharedPreferences.edit().putString(key, value).apply(); sharedPreferences.edit().putString(key, value).apply();
} }
@Deprecated
static public void remove(int resourceID) {
sharedPreferences.edit().remove(MainApp.gs(resourceID)).apply();
}
@Deprecated @Deprecated
static public void remove(String key) { static public void remove(String key) {
sharedPreferences.edit().remove(key).apply(); sharedPreferences.edit().remove(key).apply();

View file

@ -18,13 +18,12 @@ package info.nightscout.androidaps.utils;
import android.os.SystemClock; import android.os.SystemClock;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.DatagramPacket; import java.net.DatagramPacket;
import java.net.DatagramSocket; import java.net.DatagramSocket;
import java.net.InetAddress; import java.net.InetAddress;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
/** /**
@ -40,7 +39,7 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
* </pre> * </pre>
*/ */
public class SntpClient { public class SntpClient {
private static Logger log = StacktraceLoggerWrapper.getLogger(L.CORE); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.CORE);
//private static final int REFERENCE_TIME_OFFSET = 16; //private static final int REFERENCE_TIME_OFFSET = 16;
private static final int ORIGINATE_TIME_OFFSET = 24; private static final int ORIGINATE_TIME_OFFSET = 24;

View file

@ -10,6 +10,7 @@ import androidx.core.app.TaskStackBuilder
import info.nightscout.androidaps.MainActivity import info.nightscout.androidaps.MainActivity
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.utils.resources.IconsProvider
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -17,7 +18,8 @@ import javax.inject.Singleton
@Singleton @Singleton
class NotificationHolder @Inject constructor( class NotificationHolder @Inject constructor(
private val resourceHelper: ResourceHelper, private val resourceHelper: ResourceHelper,
private val context: Context private val context: Context,
private val iconsProvider: IconsProvider
) { ) {
val channelID = "AndroidAPS-Ongoing" val channelID = "AndroidAPS-Ongoing"
@ -32,8 +34,8 @@ class NotificationHolder @Inject constructor(
.setOngoing(true) .setOngoing(true)
.setOnlyAlertOnce(true) .setOnlyAlertOnce(true)
.setCategory(NotificationCompat.CATEGORY_STATUS) .setCategory(NotificationCompat.CATEGORY_STATUS)
.setSmallIcon(resourceHelper.getNotificationIcon()) .setSmallIcon(iconsProvider.getNotificationIcon())
.setLargeIcon(resourceHelper.decodeResource(resourceHelper.getIcon())) .setLargeIcon(resourceHelper.decodeResource(iconsProvider.getIcon()))
.setContentTitle(resourceHelper.gs(R.string.loading)) .setContentTitle(resourceHelper.gs(R.string.loading))
.setContentIntent(stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)) .setContentIntent(stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT))
notification = builder.build() notification = builder.build()

View file

@ -0,0 +1,24 @@
package info.nightscout.androidaps.utils.resources
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class IconsProvider @Inject constructor() {
fun getIcon(): Int =
when {
Config.NSCLIENT -> R.mipmap.ic_yellowowl
Config.PUMPCONTROL -> R.mipmap.ic_pumpcontrol
else -> R.mipmap.ic_launcher
}
fun getNotificationIcon(): Int =
when {
Config.NSCLIENT -> R.drawable.ic_notif_nsclient
Config.PUMPCONTROL -> R.drawable.ic_notif_pumpcontrol
else -> R.drawable.ic_notif_aaps
}
}

View file

@ -39,17 +39,9 @@
<color name="tempTargetConfirmation">#77dd77</color> <color name="tempTargetConfirmation">#77dd77</color>
<color name="colorPrimary">#212121</color>
<color name="colorPrimaryDark">#000000</color>
<color name="colorAccent">#40bbaa</color>
<color name="mdtp_accent_color">#40bbaa</color> <color name="mdtp_accent_color">#40bbaa</color>
<color name="colorInitializingBorder">#00695c</color> <color name="colorInitializingBorder">#00695c</color>
<color name="dialog_title_background">#303030</color>
<color name="activity_title_background">#121212</color>
<color name="dialog_title_color">#FFFFFF</color>
<color name="dialog_title_icon_tint">#FFFFFF</color>
<color name="cardColorBackground">#121212</color> <color name="cardColorBackground">#121212</color>
<color name="cardObjectiveText">#779ECB</color> <color name="cardObjectiveText">#779ECB</color>
@ -91,12 +83,6 @@
<color name="splashBackground">#2E2E2E</color> <color name="splashBackground">#2E2E2E</color>
<color name="warningAlertBackground">#FFFB8C00</color>
<color name="warningAlertHeaderText">#FF000000</color>
<color name="errorAlertBackground">#FFFF5555</color>
<color name="errorAlertHeaderText">#FF000000</color>
<color name="toastBorder">#666666</color> <color name="toastBorder">#666666</color>
<color name="toastBase">#ffffff</color> <color name="toastBase">#ffffff</color>
<color name="toastOk">#77dd77</color> <color name="toastOk">#77dd77</color>

View file

@ -250,7 +250,6 @@
<string name="openapsma_maxbasal_summary">This value is called max basal in OpenAPS context</string> <string name="openapsma_maxbasal_summary">This value is called max basal in OpenAPS context</string>
<string name="openapsma_maxiob_title">Maximum basal IOB OpenAPS can deliver [U]</string> <string name="openapsma_maxiob_title">Maximum basal IOB OpenAPS can deliver [U]</string>
<string name="openapsma_maxiob_summary">This value is called Max IOB in OpenAPS context\nThis is maximal insulin in [U] APS can deliver at once.</string> <string name="openapsma_maxiob_summary">This value is called Max IOB in OpenAPS context\nThis is maximal insulin in [U] APS can deliver at once.</string>
<string name="dismiss">DISMISS</string>
<string name="language" translatable="false">Language</string> <string name="language" translatable="false">Language</string>
<string name="password_preferences_encrypt_prompt">You will be asked for master password, which will be used to encrypt exported preferences.</string> <string name="password_preferences_encrypt_prompt">You will be asked for master password, which will be used to encrypt exported preferences.</string>
@ -1761,7 +1760,6 @@
<string name="timeformat24h">24h</string> <string name="timeformat24h">24h</string>
<string name="automation_event">Automation event</string> <string name="automation_event">Automation event</string>
<string name="alreadyset">Already set</string> <string name="alreadyset">Already set</string>
<string name="message">Message</string>
<string name="clearqueueconfirm">Clear queue? All data in queue will be lost!</string> <string name="clearqueueconfirm">Clear queue? All data in queue will be lost!</string>
<string name="key_xdripstatus_detailediob" translatable="false">xdripstatus_detailediob</string> <string name="key_xdripstatus_detailediob" translatable="false">xdripstatus_detailediob</string>
<string name="key_xdripstatus_showbgi" translatable="false">xdripstatus_showbgi</string> <string name="key_xdripstatus_showbgi" translatable="false">xdripstatus_showbgi</string>
@ -1769,7 +1767,6 @@
<string name="key_snoozedTo" translatable="false">snoozedTo</string> <string name="key_snoozedTo" translatable="false">snoozedTo</string>
<string name="key_snooze_dst_in24h" translatable="false">snooze_dst_in24h</string> <string name="key_snooze_dst_in24h" translatable="false">snooze_dst_in24h</string>
<string name="key_snooze_loopdisabled" translatable="false">snooze_loopdisabled</string> <string name="key_snooze_loopdisabled" translatable="false">snooze_loopdisabled</string>
<string name="key_enable_fabric" translatable="false">enable_fabric</string>
<string name="sixdigitnumber" translatable="false">^\\d{6}</string> <string name="sixdigitnumber" translatable="false">^\\d{6}</string>
<string name="ebstopsloop">Use of Extended bolus feature will stop closed loop mode for the time of running extended bolus. Do you really want it?</string> <string name="ebstopsloop">Use of Extended bolus feature will stop closed loop mode for the time of running extended bolus. Do you really want it?</string>
<string name="closed_loop_disabled_with_eb">Closed loop disabled because of running Extended bolus</string> <string name="closed_loop_disabled_with_eb">Closed loop disabled because of running Extended bolus</string>

View file

@ -70,30 +70,6 @@
<item name="android:textColor">#ff0000</item> <item name="android:textColor">#ff0000</item>
</style> </style>
<style name="AppThemeWarningDialog" parent="AppTheme">
<item name="alertDialogTheme">@style/AppThemeWarningDialogTheme</item>
<item name="dialogTitleBackground">@color/warningAlertBackground</item>
<item name="dialogTitleColor">@color/warningAlertHeaderText</item>
<item name="dialogTitleIconTint">@color/warningAlertHeaderText</item>
</style>
<style name="AppThemeWarningDialogTheme" parent="Theme.AppCompat.Dialog.MinWidth">
<item name="android:windowBackground">@drawable/alert_border_warning</item>
<item name="colorAccent">@color/warningAlertBackground</item>
</style>
<style name="AppThemeErrorDialog" parent="AppTheme">
<item name="alertDialogTheme">@style/AppThemeErrorDialogTheme</item>
<item name="dialogTitleBackground">@color/errorAlertBackground</item>
<item name="dialogTitleColor">@color/errorAlertHeaderText</item>
<item name="dialogTitleIconTint">@color/errorAlertHeaderText</item>
</style>
<style name="AppThemeErrorDialogTheme" parent="Theme.AppCompat.Dialog.MinWidth">
<item name="android:windowBackground">@drawable/alert_border_error</item>
<item name="colorAccent">@color/errorAlertBackground</item>
</style>
<style name="WizardPagePodContent"> <style name="WizardPagePodContent">
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>

View file

@ -2,13 +2,14 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/omnipod_name"> <PreferenceCategory android:title="@string/omnipod_name">
<Preference <info.nightscout.androidaps.plugins.pump.common.ui.RileyLinkSelectPreference
android:id="@+id/rileylink_mac_address_omnipod"
android:enabled="true" android:enabled="true"
android:key="@string/key_rileylink_mac_address"
android:summary="" android:summary=""
android:title="RileyLink Configuration"> android:title="RileyLink Configuration"
android:key="@string/key_rileylink_mac_address">
<intent android:action="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" /> <intent android:action="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" />
</Preference> </info.nightscout.androidaps.plugins.pump.common.ui.RileyLinkSelectPreference>
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"

View file

@ -9,14 +9,15 @@ import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock;
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 dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion; import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion;
import info.nightscout.androidaps.testing.mockers.AAPSMocker;
import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.SP;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -32,6 +33,8 @@ public class PodSessionStateTest {
//// AAPSMocker.mockSP(); //// AAPSMocker.mockSP();
// } // }
@Mock HasAndroidInjector hasAndroidInjector;
//@Test //@Test
public void times() { public void times() {
DateTimeZone timeZone = DateTimeZone.UTC; DateTimeZone timeZone = DateTimeZone.UTC;
@ -45,7 +48,7 @@ public class PodSessionStateTest {
PodSessionState podSessionState = new PodSessionState(timeZone, 0x0, PodSessionState podSessionState = new PodSessionState(timeZone, 0x0,
new FirmwareVersion(1, 1, 1), new FirmwareVersion(1, 1, 1),
new FirmwareVersion(2, 2, 2), new FirmwareVersion(2, 2, 2),
0, 0, 0, 0); 0, 0, 0, 0, hasAndroidInjector);
assertEquals(now, podSessionState.getTime()); assertEquals(now, podSessionState.getTime());
assertEquals(Duration.standardHours(1).plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), podSessionState.getScheduleOffset()); assertEquals(Duration.standardHours(1).plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), podSessionState.getScheduleOffset());
@ -64,7 +67,7 @@ public class PodSessionStateTest {
PodSessionState podSessionState = new PodSessionState(timeZone, 0x0, PodSessionState podSessionState = new PodSessionState(timeZone, 0x0,
new FirmwareVersion(1, 1, 1), new FirmwareVersion(1, 1, 1),
new FirmwareVersion(2, 2, 2), new FirmwareVersion(2, 2, 2),
0, 0, 0, 0); 0, 0, 0, 0, hasAndroidInjector);
DateTimeZone newTimeZone = DateTimeZone.forOffsetHours(2); DateTimeZone newTimeZone = DateTimeZone.forOffsetHours(2);
DateTimeZone.setDefault(newTimeZone); DateTimeZone.setDefault(newTimeZone);
@ -88,7 +91,7 @@ public class PodSessionStateTest {
PodSessionState podSessionState = new PodSessionState(timeZone, 0x0, PodSessionState podSessionState = new PodSessionState(timeZone, 0x0,
new FirmwareVersion(1, 1, 1), new FirmwareVersion(1, 1, 1),
new FirmwareVersion(2, 2, 2), new FirmwareVersion(2, 2, 2),
0, 0, 0, 0); 0, 0, 0, 0, hasAndroidInjector);
DateTimeZone newTimeZone = DateTimeZone.forOffsetHours(2); DateTimeZone newTimeZone = DateTimeZone.forOffsetHours(2);
DateTimeZone.setDefault(newTimeZone); DateTimeZone.setDefault(newTimeZone);

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.driver.comm; package info.nightscout.androidaps.plugins.pump.omnipod.driver.comm;
import org.joda.time.Duration; import org.joda.time.Duration;
import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
@ -15,11 +16,12 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.powermock.api.mockito.PowerMockito.when; import static org.powermock.api.mockito.PowerMockito.when;
@Ignore("Not dev/dagger compliant. Needs to be fixed")
public class AapsOmnipodManagerTest { public class AapsOmnipodManagerTest {
@Rule @Rule
public ExpectedException thrown = ExpectedException.none(); public ExpectedException thrown = ExpectedException.none();
@Test //@Test
public void validProfile() { public void validProfile() {
Profile profile = mock(Profile.class); Profile profile = mock(Profile.class);
@ -59,14 +61,14 @@ public class AapsOmnipodManagerTest {
assertEquals(3.05D, entry3.getRate(), 0.000001); assertEquals(3.05D, entry3.getRate(), 0.000001);
} }
@Test //@Test
public void invalidProfileNullProfile() { public void invalidProfileNullProfile() {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Profile can not be null"); thrown.expectMessage("Profile can not be null");
AapsOmnipodManager.mapProfileToBasalSchedule(null); AapsOmnipodManager.mapProfileToBasalSchedule(null);
} }
@Test //@Test
public void invalidProfileNullEntries() { public void invalidProfileNullEntries() {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Basal values can not be null"); thrown.expectMessage("Basal values can not be null");
@ -84,10 +86,10 @@ public class AapsOmnipodManagerTest {
AapsOmnipodManager.mapProfileToBasalSchedule(profile); AapsOmnipodManager.mapProfileToBasalSchedule(profile);
} }
@Test //@Test
public void invalidProfileNonZeroOffset() { public void invalidProfileNonZeroOffset() {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("First basal schedule entry should have 0 offset"); thrown.expectMessage("Invalid start time");
Profile profile = mock(Profile.class); Profile profile = mock(Profile.class);
@ -102,7 +104,7 @@ public class AapsOmnipodManagerTest {
AapsOmnipodManager.mapProfileToBasalSchedule(profile); AapsOmnipodManager.mapProfileToBasalSchedule(profile);
} }
@Test //@Test
public void invalidProfileMoreThan24Hours() { public void invalidProfileMoreThan24Hours() {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid start time"); thrown.expectMessage("Invalid start time");
@ -125,7 +127,7 @@ public class AapsOmnipodManagerTest {
AapsOmnipodManager.mapProfileToBasalSchedule(profile); AapsOmnipodManager.mapProfileToBasalSchedule(profile);
} }
@Test //@Test
public void invalidProfileNegativeOffset() { public void invalidProfileNegativeOffset() {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid start time"); thrown.expectMessage("Invalid start time");
@ -143,7 +145,7 @@ public class AapsOmnipodManagerTest {
AapsOmnipodManager.mapProfileToBasalSchedule(profile); AapsOmnipodManager.mapProfileToBasalSchedule(profile);
} }
@Test //@Test
public void invalidProfileUnsupportedPrecision() { public void invalidProfileUnsupportedPrecision() {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Unsupported basal rate precision"); thrown.expectMessage("Unsupported basal rate precision");

View file

@ -1,7 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.3.71' ext {
kotlin_version = '1.3.71'
android_ktx_version = '1.2.0'
rxjava_version = '2.2.19'
rxandroid_version = '2.1.1'
rxkotlin_version = '2.4.0'
room_version = '2.2.5'
lifecycle_version = '2.2.0'
dagger_version = '2.27'
}
repositories { repositories {
google() google()
jcenter() jcenter()

1
core/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

68
core/build.gradle Normal file
View file

@ -0,0 +1,68 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
kotlinOptions {
jvmTarget = '1.8'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled(project.hasProperty('coverage'))
}
firebaseDisable {
System.setProperty("disableFirebase", "true")
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
//Logger
implementation 'org.slf4j:slf4j-api:1.7.30'
//Fabric
implementation 'com.google.firebase:firebase-core:17.3.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
transitive = true;
}
//RxBus
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "org.apache.commons:commons-lang3:3.9"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

0
core/consumer-rules.pro Normal file
View file

21
core/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,25 @@
package info.nightscout.androidaps.core
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("info.nightscout.androidaps.core.test", appContext.packageName)
}
}

View file

@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.nightscout.androidaps.core" />

View file

@ -0,0 +1,31 @@
package info.nightscout.androidaps.core.dependencyInjection
import android.content.Context
import android.preference.PreferenceManager
import dagger.Module
import dagger.Provides
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.AAPSLoggerProduction
import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.resources.ResourceHelperImplementation
import info.nightscout.androidaps.utils.sharedPreferences.SP
import info.nightscout.androidaps.utils.sharedPreferences.SPImplementation
import javax.inject.Singleton
@Module
open class CoreModule {
@Provides
@Singleton
fun provideResources(context: Context): ResourceHelper = ResourceHelperImplementation(context)
@Provides
@Singleton
fun provideSharedPreferences(context: Context, resourceHelper: ResourceHelper): SP = SPImplementation(PreferenceManager.getDefaultSharedPreferences(context), resourceHelper)
@Provides
@Singleton
fun provideAAPSLogger(l: L): AAPSLogger = AAPSLoggerProduction(l)
}

View file

@ -6,55 +6,49 @@ import org.slf4j.LoggerFactory
* Created by adrian on 2019-12-27. * Created by adrian on 2019-12-27.
*/ */
class AAPSLoggerProduction : AAPSLogger { class AAPSLoggerProduction constructor(val l: L) : AAPSLogger {
override fun debug(message: String) { override fun debug(message: String) {
LoggerFactory.getLogger(LTag.CORE.tag).debug(stackLogMarker() + message) LoggerFactory.getLogger(LTag.CORE.tag).debug(stackLogMarker() + message)
} }
override fun debug(enable: Boolean, tag: LTag, message: String) { override fun debug(enable: Boolean, tag: LTag, message: String) {
if (enable && L.isEnabled(tag.tag)) { if (enable && l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + message) LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + message)
} }
}
override fun debug(tag: LTag, message: String) { override fun debug(tag: LTag, message: String) {
if (L.isEnabled(tag.tag)) { if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + message) LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + message)
} }
}
override fun debug(tag: LTag, format: String, vararg arguments: Any?) { override fun debug(tag: LTag, format: String, vararg arguments: Any?) {
if (L.isEnabled(tag.tag)) if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + format, arguments) LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + format, arguments)
} }
override fun warn(tag: LTag, message: String) { override fun warn(tag: LTag, message: String) {
if (L.isEnabled(tag.tag)) { if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).warn(stackLogMarker() + message) LoggerFactory.getLogger(tag.tag).warn(stackLogMarker() + message)
} }
}
override fun warn(tag: LTag, format: String, vararg arguments: Any?) { override fun warn(tag: LTag, format: String, vararg arguments: Any?) {
LoggerFactory.getLogger(tag.tag).warn(stackLogMarker() + format, arguments) LoggerFactory.getLogger(tag.tag).warn(stackLogMarker() + format, arguments)
} }
override fun info(tag: LTag, message: String) { override fun info(tag: LTag, message: String) {
if (L.isEnabled(tag.tag)) { if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).info(stackLogMarker() + message) LoggerFactory.getLogger(tag.tag).info(stackLogMarker() + message)
}
} }
override fun info(tag: LTag, format: String, vararg arguments: Any?) { override fun info(tag: LTag, format: String, vararg arguments: Any?) {
if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).info(stackLogMarker() + format, arguments) LoggerFactory.getLogger(tag.tag).info(stackLogMarker() + format, arguments)
} }
override fun error(tag: LTag, message: String) { override fun error(tag: LTag, message: String) {
if (L.isEnabled(tag.tag)) {
LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + message) LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + message)
} }
}
override fun error(message: String) { override fun error(message: String) {
LoggerFactory.getLogger(LTag.CORE.tag).error(stackLogMarker() + message) LoggerFactory.getLogger(LTag.CORE.tag).error(stackLogMarker() + message)
@ -69,17 +63,13 @@ class AAPSLoggerProduction : AAPSLogger {
} }
override fun error(tag: LTag, message: String, throwable: Throwable) { override fun error(tag: LTag, message: String, throwable: Throwable) {
if (L.isEnabled(tag.tag)) {
LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + message, throwable) LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + message, throwable)
} }
}
override fun error(tag: LTag, format: String, vararg arguments: Any?) { override fun error(tag: LTag, format: String, vararg arguments: Any?) {
if (L.isEnabled(tag.tag)) {
LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + format, arguments) LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + format, arguments)
} }
} }
}
fun StackTraceElement.toLogString(): String = "[${this.className.substringAfterLast(".")}.${this.methodName}():${this.lineNumber}]: " fun StackTraceElement.toLogString(): String = "[${this.className.substringAfterLast(".")}.${this.methodName}():${this.lineNumber}]: "

View file

@ -0,0 +1,81 @@
package info.nightscout.androidaps.logging
import info.nightscout.androidaps.utils.sharedPreferences.SP
import java.util.*
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class L @Inject constructor(
private val sp: SP
) {
private var logElements: MutableList<LogElement> = ArrayList()
companion object {
@Deprecated("Use Dagger")
lateinit var instance: L
@Deprecated("Use Dagger")
@JvmStatic
fun isEnabled(ltag: LTag): Boolean {
return instance.findByName(ltag.name).enabled
}
}
init {
instance= this
LTag.values().forEach { logElements.add(LogElement(it, sp)) }
}
fun findByName(name: String): LogElement {
for (element in logElements) {
if (element.name == name) return element
}
return LogElement(false, sp)
}
fun getLogElements(): List<LogElement> {
return logElements
}
fun resetToDefaults() {
for (element in logElements) {
element.resetToDefault()
}
}
class LogElement {
var sp : SP
var name: String
var defaultValue: Boolean
var enabled: Boolean
private var requiresRestart = false
internal constructor(tag: LTag, sp: SP) {
this.sp = sp
this.name = tag.tag
this.defaultValue = tag.defaultValue
this.requiresRestart = tag.requiresRestart
enabled = sp.getBoolean(getSPName(), defaultValue)
}
internal constructor(defaultValue: Boolean, sp: SP) {
this.sp = sp
name = "NONEXISTING"
this.defaultValue = defaultValue
enabled = defaultValue
}
private fun getSPName(): String = "log_$name"
fun enable(enabled: Boolean) {
this.enabled = enabled
sp.putBoolean(getSPName(), enabled)
}
fun resetToDefault() {
enable(defaultValue)
}
}
}

View file

@ -34,7 +34,7 @@ class StacktraceLoggerWrapper(private val delegate: Logger) : Logger by delegate
companion object { companion object {
@JvmStatic @JvmStatic
@Deprecated("please inject AAPSLogger") @Deprecated("please inject AAPSLogger")
fun getLogger(name: String) = StacktraceLoggerWrapper(LoggerFactory.getLogger(name)) fun getLogger(ltag: LTag) = StacktraceLoggerWrapper(LoggerFactory.getLogger(ltag.name))
@JvmStatic @JvmStatic
@Deprecated("please inject AAPSLogger") @Deprecated("please inject AAPSLogger")

View file

@ -4,17 +4,11 @@ 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.core.R
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.ActivePluginProvider
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.configBuilder.ConstraintChecker
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 io.fabric.sdk.android.Fabric
import java.util.*
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -27,13 +21,10 @@ import javax.inject.Singleton
class FabricPrivacy @Inject constructor( class FabricPrivacy @Inject constructor(
context: Context, context: Context,
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val sp: SP, private val sp: SP
private val constraintChecker: ConstraintChecker,
private val signatureVerifierPlugin: SignatureVerifierPlugin,
private val activePlugin: ActivePluginProvider
) { ) {
private var firebaseAnalytics: FirebaseAnalytics var firebaseAnalytics: FirebaseAnalytics
init { init {
instance = this instance = this
@ -49,7 +40,7 @@ class FabricPrivacy @Inject constructor(
private lateinit var instance: FabricPrivacy private lateinit var instance: FabricPrivacy
@JvmStatic @JvmStatic
@Deprecated("use dagger") @Deprecated("Use Dagger")
fun getInstance(): FabricPrivacy = instance fun getInstance(): FabricPrivacy = instance
} }
@ -122,31 +113,4 @@ class FabricPrivacy @Inject constructor(
fun fabricEnabled(): Boolean { fun fabricEnabled(): Boolean {
return sp.getBoolean(R.string.key_enable_fabric, true) return sp.getBoolean(R.string.key_enable_fabric, true)
} }
fun setUserStats() {
if (!fabricEnabled()) return
val closedLoopEnabled = if (constraintChecker.isClosedLoopAllowed().value()) "CLOSED_LOOP_ENABLED" else "CLOSED_LOOP_DISABLED"
// Size is limited to 36 chars
val remote = BuildConfig.REMOTE.toLowerCase(Locale.getDefault())
.replace("https://", "")
.replace("http://", "")
.replace(".git", "")
.replace(".com/", ":")
.replace(".org/", ":")
.replace(".net/", ":")
firebaseAnalytics.setUserProperty("Mode", BuildConfig.APPLICATION_ID + "-" + closedLoopEnabled)
firebaseAnalytics.setUserProperty("Language", sp.getString(R.string.key_language, Locale.getDefault().language))
firebaseAnalytics.setUserProperty("Version", BuildConfig.VERSION)
firebaseAnalytics.setUserProperty("HEAD", BuildConfig.HEAD)
firebaseAnalytics.setUserProperty("Remote", remote)
val hashes: List<String> = signatureVerifierPlugin.shortHashes()
if (hashes.isNotEmpty()) firebaseAnalytics.setUserProperty("Hash", hashes[0])
activePlugin.activePump.let { firebaseAnalytics.setUserProperty("Pump", it::class.java.simpleName) }
if (!Config.NSCLIENT && !Config.PUMPCONTROL)
activePlugin.activeAPS.let { firebaseAnalytics.setUserProperty("Aps", it::class.java.simpleName) }
activePlugin.activeBgSource.let { firebaseAnalytics.setUserProperty("BgSource", it::class.java.simpleName) }
firebaseAnalytics.setUserProperty("Profile", activePlugin.activeProfileInterface.javaClass.simpleName)
activePlugin.activeSensitivity.let { firebaseAnalytics.setUserProperty("Sensitivity", it::class.java.simpleName) }
activePlugin.activeInsulin.let { firebaseAnalytics.setUserProperty("Insulin", it::class.java.simpleName) }
}
} }

View file

@ -1,15 +1,11 @@
package info.nightscout.androidaps.utils; package info.nightscout.androidaps.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
/** /**
* Created by mike on 23.06.2016. * Created by mike on 23.06.2016.
*/ */
public class SafeParse { public class SafeParse {
private static Logger log = StacktraceLoggerWrapper.getLogger(SafeParse.class); // TODO return logging with dagger
// private static Logger log = StacktraceLoggerWrapper.getLogger(SafeParse.class);
public static Double stringToDouble(String input) { public static Double stringToDouble(String input) {
Double result = 0d; Double result = 0d;
input = input.replace(",", "."); input = input.replace(",", ".");
@ -19,7 +15,7 @@ public class SafeParse {
try { try {
result = Double.parseDouble(input); result = Double.parseDouble(input);
} catch (Exception e) { } catch (Exception e) {
log.error("Error parsing " + input + " to double"); // log.error("Error parsing " + input + " to double");
} }
return result; return result;
} }
@ -33,7 +29,7 @@ public class SafeParse {
try { try {
result = Integer.parseInt(input); result = Integer.parseInt(input);
} catch (Exception e) { } catch (Exception e) {
log.error("Error parsing " + input + " to int"); // log.error("Error parsing " + input + " to int");
} }
return result; return result;
} }
@ -47,7 +43,7 @@ public class SafeParse {
try { try {
result = Long.parseLong(input); result = Long.parseLong(input);
} catch (Exception e) { } catch (Exception e) {
log.error("Error parsing " + input + " to long"); // log.error("Error parsing " + input + " to long");
} }
return result; return result;
} }

View file

@ -14,7 +14,7 @@ import android.widget.Toast;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.appcompat.view.ContextThemeWrapper; import androidx.appcompat.view.ContextThemeWrapper;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.core.R;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;

View file

@ -10,7 +10,7 @@ import androidx.annotation.LayoutRes
import androidx.annotation.StyleRes import androidx.annotation.StyleRes
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.view.ContextThemeWrapper import androidx.appcompat.view.ContextThemeWrapper
import info.nightscout.androidaps.R import info.nightscout.androidaps.core.R
object AlertDialogHelper { object AlertDialogHelper {

View file

@ -6,7 +6,7 @@ import android.content.Context
import android.content.DialogInterface import android.content.DialogInterface
import android.os.SystemClock import android.os.SystemClock
import android.text.Spanned import android.text.Spanned
import info.nightscout.androidaps.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.utils.extensions.runOnUiThread import info.nightscout.androidaps.utils.extensions.runOnUiThread
object OKDialog { object OKDialog {

View file

@ -5,7 +5,7 @@ import android.content.Context
import android.content.DialogInterface import android.content.DialogInterface
import android.os.SystemClock import android.os.SystemClock
import androidx.annotation.StringRes import androidx.annotation.StringRes
import info.nightscout.androidaps.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.utils.extensions.runOnUiThread import info.nightscout.androidaps.utils.extensions.runOnUiThread
// if you need error dialog - duplicate to ErrorDialog and make it and use: AppThemeErrorDialog & R.drawable.ic_header_error instead // if you need error dialog - duplicate to ErrorDialog and make it and use: AppThemeErrorDialog & R.drawable.ic_header_error instead

View file

@ -15,8 +15,6 @@ interface ResourceHelper {
fun gsa(@ArrayRes id:Int): Array<String> fun gsa(@ArrayRes id:Int): Array<String>
fun openRawResourceFd(@RawRes id : Int) : AssetFileDescriptor? fun openRawResourceFd(@RawRes id : Int) : AssetFileDescriptor?
fun getIcon() : Int
fun getNotificationIcon() : Int
fun decodeResource(id : Int) : Bitmap fun decodeResource(id : Int) : Bitmap
fun getDisplayMetrics(): DisplayMetrics fun getDisplayMetrics(): DisplayMetrics
fun dpToPx(dp: Int): Int fun dpToPx(dp: Int): Int

View file

@ -12,8 +12,7 @@ import androidx.annotation.ColorRes
import androidx.annotation.PluralsRes import androidx.annotation.PluralsRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import info.nightscout.androidaps.Config import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.R
import javax.inject.Inject import javax.inject.Inject
/** /**
@ -42,20 +41,6 @@ class ResourceHelperImplementation @Inject constructor(private val context: Cont
override fun openRawResourceFd(id: Int): AssetFileDescriptor = override fun openRawResourceFd(id: Int): AssetFileDescriptor =
context.resources.openRawResourceFd(id) context.resources.openRawResourceFd(id)
override fun getIcon(): Int =
when {
Config.NSCLIENT -> R.mipmap.ic_yellowowl
Config.PUMPCONTROL -> R.mipmap.ic_pumpcontrol
else -> R.mipmap.ic_launcher
}
override fun getNotificationIcon(): Int =
when {
Config.NSCLIENT -> R.drawable.ic_notif_nsclient
Config.PUMPCONTROL -> R.drawable.ic_notif_pumpcontrol
else -> R.drawable.ic_notif_aaps
}
override fun decodeResource(id: Int): Bitmap = override fun decodeResource(id: Int): Bitmap =
BitmapFactory.decodeResource(context.resources, id) BitmapFactory.decodeResource(context.resources, id)

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#212121</color>
<color name="colorPrimaryDark">#000000</color>
<color name="colorAccent">#40bbaa</color>
<color name="dialog_title_background">#303030</color>
<color name="activity_title_background">#121212</color>
<color name="dialog_title_color">#FFFFFF</color>
<color name="dialog_title_icon_tint">#FFFFFF</color>
<color name="warningAlertBackground">#FFFB8C00</color>
<color name="warningAlertHeaderText">#FF000000</color>
<color name="errorAlertBackground">#FFFF5555</color>
<color name="errorAlertHeaderText">#FF000000</color>
</resources>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="key_enable_fabric" translatable="false">enable_fabric</string>
<string name="confirmation">Confirmation</string>
<string name="message">Message</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="dismiss">DISMISS</string>
</resources>

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="dialogTitleBackground">@color/dialog_title_background</item>
<item name="dialogTitleColor">@color/dialog_title_color</item>
<item name="dialogTitleIconTint">@color/dialog_title_icon_tint</item>
</style>
<style name="AppThemeWarningDialog" parent="AppTheme">
<item name="alertDialogTheme">@style/AppThemeWarningDialogTheme</item>
<item name="dialogTitleBackground">@color/warningAlertBackground</item>
<item name="dialogTitleColor">@color/warningAlertHeaderText</item>
<item name="dialogTitleIconTint">@color/warningAlertHeaderText</item>
</style>
<style name="AppThemeWarningDialogTheme" parent="Theme.AppCompat.Dialog.MinWidth">
<item name="android:windowBackground">@drawable/alert_border_warning</item>
<item name="colorAccent">@color/warningAlertBackground</item>
</style>
<style name="AppThemeErrorDialog" parent="AppTheme">
<item name="alertDialogTheme">@style/AppThemeErrorDialogTheme</item>
<item name="dialogTitleBackground">@color/errorAlertBackground</item>
<item name="dialogTitleColor">@color/errorAlertHeaderText</item>
<item name="dialogTitleIconTint">@color/errorAlertHeaderText</item>
</style>
<style name="AppThemeErrorDialogTheme" parent="Theme.AppCompat.Dialog.MinWidth">
<item name="android:windowBackground">@drawable/alert_border_error</item>
<item name="colorAccent">@color/errorAlertBackground</item>
</style>
</resources>

View file

@ -0,0 +1,18 @@
package info.nightscout.androidaps.core
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

View file

@ -13,3 +13,5 @@ files:
translation: /app/src/main/res/values-%android_code%/protection.xml translation: /app/src/main/res/values-%android_code%/protection.xml
- source: /app/src/main/res/values/validator.xml - source: /app/src/main/res/values/validator.xml
translation: /app/src/main/res/values-%android_code%/validator.xml translation: /app/src/main/res/values-%android_code%/validator.xml
- source: /core/src/main/res/values/strings.xml
translation: /core/src/main/res/values-%android_code%/strings.xml

View file

@ -1 +1 @@
include ':app', ':wear' include ':app', ':wear', ':core'