catch bus errors, enable only for dev

This commit is contained in:
Milos Kozak 2018-08-29 08:10:06 +02:00
parent 105485c9b6
commit a172458e76
3 changed files with 10 additions and 6 deletions

View file

@ -13,11 +13,12 @@ import java.util.Set;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
/** Logs events has they're being posted to and dispatched from the event bus. /**
* * Logs events has they're being posted to and dispatched from the event bus.
* <p>
* A summary of event-receiver calls that occurred so far is logged * A summary of event-receiver calls that occurred so far is logged
* after 10s (after startup) and then again every 60s. * after 10s (after startup) and then again every 60s.
* */ */
public class LoggingBus extends Bus { public class LoggingBus extends Bus {
private static Logger log = LoggerFactory.getLogger(L.EVENTS); private static Logger log = LoggerFactory.getLogger(L.EVENTS);
@ -49,7 +50,10 @@ public class LoggingBus extends Bus {
log.debug(" source: <unknown>"); log.debug(" source: <unknown>");
} }
super.post(event); try {
super.post(event);
} catch (IllegalStateException ignored) {
}
} }
@Override @Override

View file

@ -137,7 +137,7 @@ public class MainApp extends Application {
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile(); engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile();
devBranch = BuildConfig.VERSION.contains("dev"); devBranch = BuildConfig.VERSION.contains("dev");
sBus = L.isEnabled(L.EVENTS) ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY); sBus = L.isEnabled(L.EVENTS) && devBranch ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY);
registerLocalBroadcastReceiver(); registerLocalBroadcastReceiver();

View file

@ -68,7 +68,7 @@ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterfac
log.debug("Received Dexcom Data", data); log.debug("Received Dexcom Data", data);
if (data == null) return; if (data == null) return;
try { try {
JSONArray jsonArray = new JSONArray(data); JSONArray jsonArray = new JSONArray(data);
if (L.isEnabled(L.BGSOURCE)) if (L.isEnabled(L.BGSOURCE))