diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java index 3fec202ae0..e4d65eadc0 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java @@ -96,7 +96,12 @@ public class DataService extends IntentService { boolean isNSProfile = ConfigBuilderPlugin.getActiveProfileInterface().getClass().equals(NSProfilePlugin.class); - boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false); + boolean acceptNSData = !SP.getBoolean(R.string.key_ns_upload_only, false); + Bundle bundles = intent.getExtras(); + if (bundles != null && bundles.containsKey("islocal")) { + acceptNSData = acceptNSData || bundles.getBoolean("islocal"); + } + if (intent != null) { final String action = intent.getAction(); @@ -125,7 +130,7 @@ public class DataService extends IntentService { } else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) { // always handle Profile if NSProfile is enabled without looking at nsUploadOnly handleNewDataFromNSClient(intent); - } else if (!nsUploadOnly && + } else if (acceptNSData && (Intents.ACTION_NEW_TREATMENT.equals(action) || Intents.ACTION_CHANGED_TREATMENT.equals(action) || Intents.ACTION_REMOVED_TREATMENT.equals(action) || diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java index 43c46bf072..94b83c56bd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java @@ -24,11 +24,12 @@ import info.nightscout.utils.SP; public class BroadcastTreatment { private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class); - public static void handleNewTreatment(JSONObject treatment, boolean isDelta) { + public static void handleNewTreatment(JSONObject treatment, boolean isDelta, boolean isLocalBypass) { Bundle bundle = new Bundle(); bundle.putString("treatment", treatment.toString()); bundle.putBoolean("delta", isDelta); + bundle.putBoolean("islocal", isLocalBypass); Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java index 4590490ecf..1ab93a53d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java @@ -110,7 +110,7 @@ public class DBAccessReceiver extends BroadcastReceiver { JSONObject data = new JSONObject(request.data); data.put("mills", DateUtil.fromISODateString(data.getString("created_at")).getTime()); data.put("_id", data.get("NSCLIENT_ID")); // this is only fake id - BroadcastTreatment.handleNewTreatment(data, false); + BroadcastTreatment.handleNewTreatment(data, false, true); } catch (Exception e) { log.error("Unhadled exception", e); }