From d5599f1f00ae09fe4e1950462772681fc0253367 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 16 Jul 2017 16:00:04 +0200 Subject: [PATCH 1/8] catch TransactionTooLargeException --- .../broadcasts/BroadcastTreatment.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 382d8734dd..d56e75ba73 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 @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ResolveInfo; import android.os.Bundle; +import android.os.TransactionTooLargeException; import org.json.JSONArray; import org.json.JSONException; @@ -46,9 +47,17 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); + try { + List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); + log.debug("TREAT_ADD " + part.length() + " " + x.size() + " receivers"); + } catch (RuntimeException exception){ + if(exception.getCause() instanceof TransactionTooLargeException){ + log.error("TREAT_ADD " + part.length() + " ERROR: no receiver size, CAUSE: " + exception.getMessage()); + } else { + throw exception; + } + } - log.debug("TREAT_ADD " + part.length() + " " + x.size() + " receivers"); } } From c64c5f54015804ba8c3430b5ec0c5fb5bd235a19 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 16 Jul 2017 16:38:01 +0200 Subject: [PATCH 2/8] NS client quickfix - catch even more --- .../NSClientInternal/broadcasts/BroadcastTreatment.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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 d56e75ba73..baf81c45c9 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 @@ -50,12 +50,8 @@ public class BroadcastTreatment { try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("TREAT_ADD " + part.length() + " " + x.size() + " receivers"); - } catch (RuntimeException exception){ - if(exception.getCause() instanceof TransactionTooLargeException){ - log.error("TREAT_ADD " + part.length() + " ERROR: no receiver size, CAUSE: " + exception.getMessage()); - } else { - throw exception; - } + } catch (Throwable exception){ + log.debug("TREAT_ADD " + part.length() + " ERROR: no receiver size, CAUSE: " + exception.getMessage()); } } From 0d1ff3d721cc14e68c683eadad2c7eaa833c292c Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 16 Jul 2017 16:49:26 +0200 Subject: [PATCH 3/8] ns client quickfix now catch all --- .../broadcasts/BroadcastAckAlarm.java | 8 ++++-- .../broadcasts/BroadcastAlarm.java | 5 ++++ .../broadcasts/BroadcastAnnouncement.java | 4 +++ .../broadcasts/BroadcastCals.java | 4 +++ .../broadcasts/BroadcastClearAlarm.java | 4 +++ .../broadcasts/BroadcastDeviceStatus.java | 8 ++++++ .../broadcasts/BroadcastMbgs.java | 4 +++ .../broadcasts/BroadcastProfile.java | 4 +++ .../broadcasts/BroadcastSgvs.java | 8 ++++++ .../broadcasts/BroadcastStatus.java | 4 +++ .../broadcasts/BroadcastTreatment.java | 28 ++++++++++++++----- .../broadcasts/BroadcastUrgentAlarm.java | 4 +++ 12 files changed, 76 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java index 4e6566e330..8b27da530a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java @@ -29,9 +29,13 @@ public class BroadcastAckAlarm { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); + try { + List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); + log.debug("ACKALARM " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } - log.debug("ACKALARM " + x.size() + " receivers"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java index 46e2ef1e68..1653a55bc6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java @@ -26,8 +26,13 @@ public class BroadcastAlarm { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + + try{ List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("ALARM " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java index bb4d3de726..a39a59558f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java @@ -27,8 +27,12 @@ public class BroadcastAnnouncement { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("ANNOUNCEMENT " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java index 6601207851..6445f13f94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java @@ -27,8 +27,12 @@ public class BroadcastCals { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("CAL " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java index 7272a81d95..c3c1e41994 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java @@ -26,8 +26,12 @@ public class BroadcastClearAlarm { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("CLEARALARM " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java index 15d8fe5b5d..1f338b0038 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java @@ -26,9 +26,13 @@ public class BroadcastDeviceStatus { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("DEVICESTATUS " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) { List splitted = BroadcastTreatment.splitArray(statuses); @@ -40,9 +44,13 @@ public class BroadcastDeviceStatus { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("DEVICESTATUS " + part.length() + " records " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java index 1430fbaf1a..7d66352328 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java @@ -27,8 +27,12 @@ public class BroadcastMbgs { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("MBG " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java index 4edad5db33..0b64da8384 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java @@ -28,9 +28,13 @@ public class BroadcastProfile { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("PROFILE " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java index e846b8171b..308a1fe395 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java @@ -28,9 +28,13 @@ public class BroadcastSgvs { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("SGV " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } public static void handleNewSgv(JSONArray sgvs, Context context, boolean isDelta) { @@ -41,9 +45,13 @@ public class BroadcastSgvs { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("SGV " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java index 20055aa108..8edd749a95 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java @@ -38,8 +38,12 @@ public class BroadcastStatus { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("STATUS: " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } 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 baf81c45c9..8975b54181 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 @@ -32,9 +32,13 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("TREAT_ADD " + treatment.getEventType() + " " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) { @@ -50,9 +54,9 @@ public class BroadcastTreatment { try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("TREAT_ADD " + part.length() + " " + x.size() + " receivers"); - } catch (Throwable exception){ - log.debug("TREAT_ADD " + part.length() + " ERROR: no receiver size, CAUSE: " + exception.getMessage()); - } + } catch (Exception e){ + //for testing + } } } @@ -65,11 +69,11 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - try { log.debug("TREAT_CHANGE " + treatment.getString("_id") + " " + x.size() + " receivers"); - } catch (JSONException e) { + } catch (Exception e) { } } @@ -83,9 +87,13 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("TREAT_CHANGE " + part.length() + " " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } @@ -97,11 +105,13 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - try { + log.debug("TREAT_REMOVE " + treatment.getString("_id") + " " + x.size() + " receivers"); - } catch (JSONException e) { + } catch (Exception e){ + //for testing } } @@ -113,9 +123,13 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("TREAT_REMOVE " + treatments.length() + " treatments " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java index 10d0f068f5..3093e610bf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java @@ -26,8 +26,12 @@ public class BroadcastUrgentAlarm { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); + try { List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); log.debug("URGENTALARM " + x.size() + " receivers"); + } catch (Exception e){ + //for testing + } } } From c7538737693ba746d92e16a8cb9ab996d87e2970 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 18 Jul 2017 22:15:17 +0200 Subject: [PATCH 4/8] setting to disable local broadcasts in NSClient --- .../broadcasts/BroadcastAckAlarm.java | 2 ++ .../broadcasts/BroadcastAlarm.java | 4 ++++ .../broadcasts/BroadcastAnnouncement.java | 4 ++++ .../broadcasts/BroadcastCals.java | 4 ++++ .../broadcasts/BroadcastClearAlarm.java | 4 ++++ .../broadcasts/BroadcastDeviceStatus.java | 6 ++++++ .../broadcasts/BroadcastMbgs.java | 4 ++++ .../broadcasts/BroadcastProfile.java | 4 ++++ .../broadcasts/BroadcastQueueStatus.java | 4 ++++ .../broadcasts/BroadcastSgvs.java | 4 ++++ .../broadcasts/BroadcastStatus.java | 4 ++++ .../broadcasts/BroadcastTreatment.java | 19 +++++++++++++++++++ .../broadcasts/BroadcastUrgentAlarm.java | 4 ++++ app/src/main/res/values/strings.xml | 2 ++ .../main/res/xml/pref_nsclientinternal.xml | 5 +++++ 15 files changed, 74 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java index 8b27da530a..3b01e038ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java @@ -12,6 +12,7 @@ import java.util.List; import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm; +import info.nightscout.utils.SP; /** * Created by mike on 11.06.2017. @@ -21,6 +22,7 @@ public class BroadcastAckAlarm { private static Logger log = LoggerFactory.getLogger(BroadcastAckAlarm.class); public static void handleClearAlarm(NSAlarm originalAlarm, Context context, long silenceTimeInMsec) { + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; Bundle bundle = new Bundle(); bundle.putInt("level", originalAlarm.getLevel()); bundle.putString("group", originalAlarm.getGroup()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java index 1653a55bc6..01857bd8c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory; import java.util.List; import info.nightscout.androidaps.Services.Intents; +import info.nightscout.utils.SP; /** * Created by mike on 26.06.2016. @@ -20,6 +21,9 @@ public class BroadcastAlarm { private static Logger log = LoggerFactory.getLogger(BroadcastAlarm.class); public static void handleAlarm(JSONObject alarm, Context context) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("data", alarm.toString()); Intent intent = new Intent(Intents.ACTION_ALARM); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java index a39a59558f..96279a039e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java @@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory; import java.util.List; import info.nightscout.androidaps.Services.Intents; +import info.nightscout.utils.SP; /** * Created by mike on 26.06.2016. @@ -21,6 +22,9 @@ public class BroadcastAnnouncement { private static Logger log = LoggerFactory.getLogger(BroadcastAnnouncement.class); public static void handleAnnouncement(JSONObject announcement, Context context) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("data", announcement.toString()); Intent intent = new Intent(Intents.ACTION_ANNOUNCEMENT); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java index 6445f13f94..e8e1cd4758 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory; import java.util.List; import info.nightscout.androidaps.Services.Intents; +import info.nightscout.utils.SP; /** * Created by mike on 26.06.2016. @@ -20,6 +21,9 @@ public class BroadcastCals { private static Logger log = LoggerFactory.getLogger(BroadcastCals.class); public static void handleNewCal(JSONArray cals, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("cals", cals.toString()); bundle.putBoolean("delta", isDelta); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java index c3c1e41994..768df01be2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory; import java.util.List; import info.nightscout.androidaps.Services.Intents; +import info.nightscout.utils.SP; /** * Created by mike on 26.06.2016. @@ -20,6 +21,9 @@ public class BroadcastClearAlarm { private static Logger log = LoggerFactory.getLogger(BroadcastClearAlarm.class); public static void handleClearAlarm(JSONObject clearalarm, Context context) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("data", clearalarm.toString()); Intent intent = new Intent(Intents.ACTION_CLEAR_ALARM); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java index 1f338b0038..4d1321241a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java @@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory; import java.util.List; import info.nightscout.androidaps.Services.Intents; +import info.nightscout.utils.SP; public class BroadcastDeviceStatus { @@ -35,6 +36,11 @@ public class BroadcastDeviceStatus { } } public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) { + + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + + List splitted = BroadcastTreatment.splitArray(statuses); for (JSONArray part: splitted) { Bundle bundle = new Bundle(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java index 7d66352328..d11a542714 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory; import java.util.List; import info.nightscout.androidaps.Services.Intents; +import info.nightscout.utils.SP; /** * Created by mike on 26.06.2016. @@ -20,6 +21,9 @@ public class BroadcastMbgs { private static Logger log = LoggerFactory.getLogger(BroadcastMbgs.class); public static void handleNewMbg(JSONArray mbgs, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("mbgs", mbgs.toString()); bundle.putBoolean("delta", isDelta); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java index 0b64da8384..3fe6bf4c35 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java @@ -12,6 +12,7 @@ import java.util.List; import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.data.ProfileStore; +import info.nightscout.utils.SP; /** @@ -21,6 +22,9 @@ public class BroadcastProfile { private static Logger log = LoggerFactory.getLogger(BroadcastProfile.class); public static void handleNewTreatment(ProfileStore profile, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("profile", profile.getData().toString()); bundle.putBoolean("delta", isDelta); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java index fbcc1ed7a3..eedeb4574d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java @@ -6,12 +6,16 @@ import android.os.Bundle; import android.os.PowerManager; import info.nightscout.androidaps.Services.Intents; +import info.nightscout.utils.SP; /** * Created by mike on 28.02.2016. */ public class BroadcastQueueStatus { public static void handleNewStatus(int size, Context context) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "sendQueue"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java index 308a1fe395..52e88295c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java @@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory; import java.util.List; import info.nightscout.androidaps.Services.Intents; +import info.nightscout.utils.SP; /** * Created by mike on 22.02.2016. @@ -21,6 +22,9 @@ public class BroadcastSgvs { private static Logger log = LoggerFactory.getLogger(BroadcastSgvs.class); public static void handleNewSgv(JSONObject sgv, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("sgv", sgv.toString()); bundle.putBoolean("delta", isDelta); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java index 8edd749a95..82870b960e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java @@ -15,6 +15,7 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; +import info.nightscout.utils.SP; /** * Created by mike on 24.02.2016. @@ -23,6 +24,9 @@ public class BroadcastStatus { private static Logger log = LoggerFactory.getLogger(BroadcastStatus.class); public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); try { bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName); 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 8975b54181..dbd6414152 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 @@ -17,6 +17,7 @@ import java.util.List; import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment; +import info.nightscout.utils.SP; /** * Created by mike on 20.02.2016. @@ -25,6 +26,9 @@ public class BroadcastTreatment { private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class); public static void handleNewTreatment(NSTreatment treatment, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("treatment", treatment.getData().toString()); bundle.putBoolean("delta", isDelta); @@ -42,6 +46,9 @@ public class BroadcastTreatment { } public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + List splitted = splitArray(treatments); for (JSONArray part: splitted) { Bundle bundle = new Bundle(); @@ -62,6 +69,9 @@ public class BroadcastTreatment { } public void handleChangedTreatment(JSONObject treatment, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("treatment", treatment.toString()); bundle.putBoolean("delta", isDelta); @@ -78,6 +88,9 @@ public class BroadcastTreatment { } public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + List splitted = splitArray(treatments); for (JSONArray part: splitted) { Bundle bundle = new Bundle(); @@ -98,6 +111,9 @@ public class BroadcastTreatment { } public static void handleRemovedTreatment(JSONObject treatment, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("treatment", treatment.toString()); bundle.putBoolean("delta", isDelta); @@ -116,6 +132,9 @@ public class BroadcastTreatment { } public static void handleRemovedTreatment(JSONArray treatments, Context context, boolean isDelta) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("treatments", treatments.toString()); bundle.putBoolean("delta", isDelta); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java index 3093e610bf..335c500c98 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory; import java.util.List; import info.nightscout.androidaps.Services.Intents; +import info.nightscout.utils.SP; /** * Created by mike on 26.06.2016. @@ -20,6 +21,9 @@ public class BroadcastUrgentAlarm { private static Logger log = LoggerFactory.getLogger(BroadcastUrgentAlarm.class); public static void handleUrgentAlarm(JSONObject urgentalarm, Context context) { + + if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; + Bundle bundle = new Bundle(); bundle.putString("data", urgentalarm.toString()); Intent intent = new Intent(Intents.ACTION_URGENT_ALARM); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a44e5ef758..a8083e7bc6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -580,6 +580,7 @@ Superbolus Log app start to NS ns_logappstartedevent + nsclient_localbroadcasts Exiting application to apply settings. DanaRv2 Insulin @@ -685,4 +686,5 @@ Values not stored! Overview Notifications Pass the Overview Notifications through as wear confirmation messages. + Enable loacal broadcasts to other apps (like xDrip). diff --git a/app/src/main/res/xml/pref_nsclientinternal.xml b/app/src/main/res/xml/pref_nsclientinternal.xml index 8c12efd5de..4eb1553a1c 100644 --- a/app/src/main/res/xml/pref_nsclientinternal.xml +++ b/app/src/main/res/xml/pref_nsclientinternal.xml @@ -27,6 +27,11 @@ android:key="@string/key_ns_logappstartedevent" android:title="@string/ns_logappstartedevent" /> + + Date: Tue, 18 Jul 2017 22:18:10 +0200 Subject: [PATCH 5/8] local broadcasts better setting title --- app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_nsclientinternal.xml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a8083e7bc6..b22b5f160c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -687,4 +687,5 @@ Overview Notifications Pass the Overview Notifications through as wear confirmation messages. Enable loacal broadcasts to other apps (like xDrip). + Enable local Broadcasts. diff --git a/app/src/main/res/xml/pref_nsclientinternal.xml b/app/src/main/res/xml/pref_nsclientinternal.xml index 4eb1553a1c..5f401d6c0e 100644 --- a/app/src/main/res/xml/pref_nsclientinternal.xml +++ b/app/src/main/res/xml/pref_nsclientinternal.xml @@ -30,7 +30,9 @@ + android:title="@string/ns_localbroadcasts_title" + android:summary="@string/ns_localbroadcasts"/> + From c1e030d78901b70330f5b1fb3bc269f0ea3dfd9b Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 19 Jul 2017 16:05:13 +0200 Subject: [PATCH 6/8] nsclient remove debug data that puts stress on the broadcast system --- .../NSClientInternal/broadcasts/BroadcastAckAlarm.java | 7 ------- .../NSClientInternal/broadcasts/BroadcastAlarm.java | 8 -------- .../broadcasts/BroadcastAnnouncement.java | 7 ------- .../NSClientInternal/broadcasts/BroadcastCals.java | 7 ------- .../NSClientInternal/broadcasts/BroadcastClearAlarm.java | 7 ------- .../broadcasts/BroadcastDeviceStatus.java | 7 ------- .../NSClientInternal/broadcasts/BroadcastMbgs.java | 7 ------- .../NSClientInternal/broadcasts/BroadcastProfile.java | 7 ------- .../NSClientInternal/broadcasts/BroadcastSgvs.java | 7 ------- .../NSClientInternal/broadcasts/BroadcastStatus.java | 7 ------- .../NSClientInternal/broadcasts/BroadcastTreatment.java | 7 ------- .../NSClientInternal/broadcasts/BroadcastUrgentAlarm.java | 7 ------- 12 files changed, 85 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java index 3b01e038ab..35789a426c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java @@ -31,13 +31,6 @@ public class BroadcastAckAlarm { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - log.debug("ACKALARM " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } - } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java index 01857bd8c1..03fe04f8fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java @@ -30,13 +30,5 @@ public class BroadcastAlarm { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - - try{ - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("ALARM " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java index 96279a039e..3f9a43a14a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java @@ -31,12 +31,5 @@ public class BroadcastAnnouncement { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("ANNOUNCEMENT " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java index e8e1cd4758..7a7772357c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java @@ -31,12 +31,5 @@ public class BroadcastCals { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("CAL " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java index 768df01be2..4f2716cf85 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java @@ -30,12 +30,5 @@ public class BroadcastClearAlarm { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("CLEARALARM " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java index 4d1321241a..4cad77df11 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java @@ -50,13 +50,6 @@ public class BroadcastDeviceStatus { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("DEVICESTATUS " + part.length() + " records " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java index d11a542714..f45ade6b32 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java @@ -31,12 +31,5 @@ public class BroadcastMbgs { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("MBG " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java index 3fe6bf4c35..ec62ccbf6f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java @@ -32,13 +32,6 @@ public class BroadcastProfile { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("PROFILE " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java index 52e88295c1..56350080ef 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java @@ -49,13 +49,6 @@ public class BroadcastSgvs { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("SGV " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java index 82870b960e..15432c8e79 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java @@ -42,12 +42,5 @@ public class BroadcastStatus { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("STATUS: " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } 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 dbd6414152..66edb99141 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 @@ -142,13 +142,6 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("TREAT_REMOVE " + treatments.length() + " treatments " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java index 335c500c98..442eb729c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java @@ -30,12 +30,5 @@ public class BroadcastUrgentAlarm { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("URGENTALARM " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } From 621c32d832e52d972c40841fff063db0eb731927 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 19 Jul 2017 16:06:36 +0200 Subject: [PATCH 7/8] nsclient remove debug data that puts stress on the broadcast system 2 --- .../broadcasts/BroadcastTreatment.java | 35 ------------------- 1 file changed, 35 deletions(-) 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 66edb99141..60540d7613 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 @@ -36,13 +36,6 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("TREAT_ADD " + treatment.getEventType() + " " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) { @@ -58,13 +51,6 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - log.debug("TREAT_ADD " + part.length() + " " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } - } } @@ -79,12 +65,6 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("TREAT_CHANGE " + treatment.getString("_id") + " " + x.size() + " receivers"); - } catch (Exception e) { - } } public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) { @@ -100,13 +80,6 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("TREAT_CHANGE " + part.length() + " " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } } @@ -121,14 +94,6 @@ public class BroadcastTreatment { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - - log.debug("TREAT_REMOVE " + treatment.getString("_id") + " " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } public static void handleRemovedTreatment(JSONArray treatments, Context context, boolean isDelta) { From e6ce35485af2d46c591543cf1bbff2bd63e1e113 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 19 Jul 2017 16:09:34 +0200 Subject: [PATCH 8/8] nsclient remove debug data that puts stress on the broadcast system 3 --- .../NSClientInternal/broadcasts/BroadcastDeviceStatus.java | 7 ------- .../plugins/NSClientInternal/broadcasts/BroadcastSgvs.java | 7 ------- 2 files changed, 14 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java index 4cad77df11..9053c6becb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java @@ -27,13 +27,6 @@ public class BroadcastDeviceStatus { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("DEVICESTATUS " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java index 56350080ef..29e2031869 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java @@ -32,13 +32,6 @@ public class BroadcastSgvs { intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - try { - List x = context.getPackageManager().queryBroadcastReceivers(intent, 0); - - log.debug("SGV " + x.size() + " receivers"); - } catch (Exception e){ - //for testing - } } public static void handleNewSgv(JSONArray sgvs, Context context, boolean isDelta) {