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/data/GlucoseStatus.java b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java index 1623028a82..ad4f161799 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java @@ -64,14 +64,21 @@ public class GlucoseStatus { return this; } + + @Nullable - public static GlucoseStatus getGlucoseStatusData() { + public static GlucoseStatus getGlucoseStatusData(){ + return getGlucoseStatusData(false); + } + + @Nullable + public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) { // load 45min long fromtime = (long) (System.currentTimeMillis() - 60 * 1000L * 45); List data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false); int sizeRecords = data.size(); - if (sizeRecords < 1 || data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L) { + if (sizeRecords < 1 || (data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L && !allowOldData)) { return null; } diff --git a/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java b/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java index 70dd37a6ab..08d1a7295a 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java +++ b/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java @@ -181,7 +181,7 @@ public class QuickWizardEntry { try { return storage.getInt("useBG"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return YES; } @@ -190,7 +190,7 @@ public class QuickWizardEntry { try { return storage.getInt("useCOB"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return NO; } @@ -199,7 +199,7 @@ public class QuickWizardEntry { try { return storage.getInt("useBolusIOB"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return YES; } @@ -208,7 +208,7 @@ public class QuickWizardEntry { try { return storage.getInt("useBasalIOB"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return YES; } @@ -217,7 +217,7 @@ public class QuickWizardEntry { try { return storage.getInt("useTrend"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return NO; } @@ -226,7 +226,7 @@ public class QuickWizardEntry { try { return storage.getInt("useSuperBolus"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return NO; } @@ -235,7 +235,7 @@ public class QuickWizardEntry { try { return storage.getInt("useTempTarget"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return NO; } 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); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 91045ba4d6..6ea01692fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -316,7 +316,7 @@ public class WatchUpdaterService extends WearableListenerService implements if (last_bg == null) return; List graph_bgs = MainApp.getDbHelper().getBgreadingsDataFromTime(startTime, true); - GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); + GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(true); if (!graph_bgs.isEmpty()) { DataMap entries = dataMapSingleBG(last_bg, glucoseStatus); diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index c61b80cc6d..974b4fb721 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -187,10 +187,7 @@ public class RuffyScripter implements RuffyCommands { if (!ruffyService.isConnected()) { return false; } - if (System.currentTimeMillis() - menuLastUpdated >= 1500) { - waitForScreenUpdate(); - } - return System.currentTimeMillis() - menuLastUpdated < 1500; + return ruffyService.isConnected() && System.currentTimeMillis() - menuLastUpdated < 10 * 1000; } catch (RemoteException e) { return false; } @@ -202,10 +199,12 @@ public class RuffyScripter implements RuffyCommands { return; } try { - log.debug("Disconnecting, requested by ...", new Exception()); + log.debug("Disconnecting"); ruffyService.doRTDisconnect(); } catch (RemoteException e) { // ignore + } catch (Exception e) { + log.warn("Disconnect not happy", e); } } diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index c23c2930a9..ea5b41176b 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -569,6 +569,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){ + if("delta_granularity".equals(key)){ + ListenerService.requestData(this); + } + if(layoutSet){ setDataFields(); setColor();