report wrong alarm data #2

This commit is contained in:
Milos Kozak 2017-10-13 08:21:37 +02:00
parent 91e286b2ae
commit 6124ef25a4

View file

@ -323,12 +323,18 @@ public class NSClientService extends Service {
*/ */
@Override @Override
public void call(final Object... args) { public void call(final Object... args) {
JSONObject data = (JSONObject) args[0]; JSONObject data;
try {
data = (JSONObject) args[0];
} catch (Exception e) {
Crashlytics.log("Wrong Announcement from NS: " + args[0]);
return;
}
if (Config.detailedLog) if (Config.detailedLog)
try { try {
MainApp.bus().post(new EventNSClientNewLog("ANNOUNCEMENT", data.has("message") ? data.getString("message") : "received")); MainApp.bus().post(new EventNSClientNewLog("ANNOUNCEMENT", data.has("message") ? data.getString("message") : "received"));
} catch (JSONException e) { } catch (Exception e) {
log.error("Unhandled exception", e); Crashlytics.logException(e);
} }
BroadcastAnnouncement.handleAnnouncement(data, getApplicationContext()); BroadcastAnnouncement.handleAnnouncement(data, getApplicationContext());
log.debug(data.toString()); log.debug(data.toString());
@ -356,7 +362,7 @@ public class NSClientService extends Service {
JSONObject data; JSONObject data;
try { try {
data = (JSONObject) args[0]; data = (JSONObject) args[0];
} catch (ClassCastException e) { } catch (Exception e) {
Crashlytics.log("Wrong alarm from NS: " + args[0]); Crashlytics.log("Wrong alarm from NS: " + args[0]);
return; return;
} }
@ -381,7 +387,13 @@ public class NSClientService extends Service {
*/ */
@Override @Override
public void call(final Object... args) { public void call(final Object... args) {
JSONObject data = (JSONObject) args[0]; JSONObject data;
try {
data = (JSONObject) args[0];
} catch (Exception e) {
Crashlytics.log("Wrong Urgent alarm from NS: " + args[0]);
return;
}
if (Config.detailedLog) if (Config.detailedLog)
MainApp.bus().post(new EventNSClientNewLog("URGENTALARM", "received")); MainApp.bus().post(new EventNSClientNewLog("URGENTALARM", "received"));
BroadcastUrgentAlarm.handleUrgentAlarm(data, getApplicationContext()); BroadcastUrgentAlarm.handleUrgentAlarm(data, getApplicationContext());
@ -400,9 +412,15 @@ public class NSClientService extends Service {
*/ */
@Override @Override
public void call(final Object... args) { public void call(final Object... args) {
JSONObject data;
try {
data = (JSONObject) args[0];
} catch (Exception e) {
Crashlytics.log("Wrong Urgent alarm from NS: " + args[0]);
return;
}
if (Config.detailedLog) if (Config.detailedLog)
MainApp.bus().post(new EventNSClientNewLog("CLEARALARM", "received")); MainApp.bus().post(new EventNSClientNewLog("CLEARALARM", "received"));
JSONObject data = (JSONObject) args[0];
BroadcastClearAlarm.handleClearAlarm(data, getApplicationContext()); BroadcastClearAlarm.handleClearAlarm(data, getApplicationContext());
log.debug(data.toString()); log.debug(data.toString());
} }