Fixed unvalidated events notification and possible crash when sending SMS if mLocationFinder is null (As reported by a user)
This commit is contained in:
@@ -1137,7 +1137,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
//writeToSD();
|
//writeToSD();
|
||||||
mLm.writeDatapointToLocalDb(mSdData);
|
mLm.writeDatapointToLocalDb(mSdData);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG,"logData() - mLm is null - this should not happen");
|
Log.e(TAG, "logData() - mLm is null - this should not happen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1289,6 +1289,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
Log.v(TAG, "SmsTimer.onFinish()");
|
Log.v(TAG, "SmsTimer.onFinish()");
|
||||||
mTimeLeft = 0;
|
mTimeLeft = 0;
|
||||||
|
if (mLocationFinder!=null) {
|
||||||
mLocationFinder.getLocation(this);
|
mLocationFinder.getLocation(this);
|
||||||
Location loc = mLocationFinder.getLastLocation();
|
Location loc = mLocationFinder.getLastLocation();
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
@@ -1298,6 +1299,10 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "SmsTimer.onFinish() - Last Location is Null so sending first SMS without location.");
|
Log.i(TAG, "SmsTimer.onFinish() - Last Location is Null so sending first SMS without location.");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(TAG,"SmsTimer.onFinish - mLocationFinder is null - this should not happen!");
|
||||||
|
mUtil.showToast("SmsTimer.onFinish - mLocationFinder is null - this should not happen! - Please report this issue!")
|
||||||
|
}
|
||||||
Log.i(TAG, "SmsTimer.onFinish() - Sending to " + mSMSNumbers.length + " Numbers");
|
Log.i(TAG, "SmsTimer.onFinish() - Sending to " + mSMSNumbers.length + " Numbers");
|
||||||
mUtil.writeToSysLogFile("SdServer.SmsTimer.onFinish()");
|
mUtil.writeToSysLogFile("SdServer.SmsTimer.onFinish()");
|
||||||
Time tnow = new Time(Time.getCurrentTimezone());
|
Time tnow = new Time(Time.getCurrentTimezone());
|
||||||
@@ -1550,28 +1555,26 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
// Retrieve events from remote database
|
// Retrieve events from remote database
|
||||||
if (mLm.mWac.getEvents((JSONObject remoteEventsObj) -> {
|
if (mLm.mWac.getEvents((JSONObject remoteEventsObj) -> {
|
||||||
Log.v(TAG, "CheckEvents.getEvents.Callback()");
|
Log.v(TAG, "CheckEvents.getEvents.Callback()");
|
||||||
long firstUnvalidatedEvent;
|
Boolean haveUnvalidatedEvent = false;
|
||||||
if (remoteEventsObj == null) {
|
if (remoteEventsObj == null) {
|
||||||
Log.e(TAG, "CheckEvents.Callback: Error Retrieving events");
|
Log.e(TAG, "CheckEvents.Callback: Error Retrieving events");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
JSONArray eventsArray = remoteEventsObj.getJSONArray("events");
|
JSONArray eventsArray = remoteEventsObj.getJSONArray("events");
|
||||||
// A bit of a hack to display in reverse chronological order
|
// A bit of a hack to display in reverse chronological order
|
||||||
firstUnvalidatedEvent = -1;
|
|
||||||
for (int i = eventsArray.length() - 1; i >= 0; i--) {
|
for (int i = eventsArray.length() - 1; i >= 0; i--) {
|
||||||
JSONObject eventObj = eventsArray.getJSONObject(i);
|
JSONObject eventObj = eventsArray.getJSONObject(i);
|
||||||
Long id = eventObj.getLong("id");
|
|
||||||
String typeStr = eventObj.getString("type");
|
String typeStr = eventObj.getString("type");
|
||||||
//Log.v(TAG,"CheckEventsTimer: id="+id+", typeStr="+typeStr);
|
//Log.v(TAG,"CheckEventsTimer: id="+id+", typeStr="+typeStr);
|
||||||
if (typeStr.equals("null")) {
|
if (typeStr.equals("null") || typeStr.equals("")) {
|
||||||
firstUnvalidatedEvent = id;
|
haveUnvalidatedEvent = true;
|
||||||
//Log.v(TAG,"CheckEventsTimer:setting firstUnvalidatedEvent to "+firstUnvalidatedEvent);
|
//Log.v(TAG,"CheckEventsTimer:setting firstUnvalidatedEvent to "+firstUnvalidatedEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.v(TAG, "CheckEventsTimer.onFinish.callback - firstUnvalidatedEvent = " +
|
Log.v(TAG, "CheckEventsTimer.onFinish.callback - haveUnvalidatedEvent = " +
|
||||||
firstUnvalidatedEvent);
|
haveUnvalidatedEvent);
|
||||||
if (firstUnvalidatedEvent >= 0) {
|
if (haveUnvalidatedEvent) {
|
||||||
showEventNotification(firstUnvalidatedEvent);
|
showEventNotification();
|
||||||
mNM.cancel(DATASHARE_NOTIFICATION_ID);
|
mNM.cancel(DATASHARE_NOTIFICATION_ID);
|
||||||
} else {
|
} else {
|
||||||
mNM.cancel(EVENT_NOTIFICATION_ID);
|
mNM.cancel(EVENT_NOTIFICATION_ID);
|
||||||
@@ -1622,7 +1625,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
/**
|
/**
|
||||||
* Show a notification to tell the user that we have unvalidated events.
|
* Show a notification to tell the user that we have unvalidated events.
|
||||||
*/
|
*/
|
||||||
private void showEventNotification(long eventId) {
|
private void showEventNotification() {
|
||||||
Log.v(TAG, "showEventNotification()");
|
Log.v(TAG, "showEventNotification()");
|
||||||
int iconId;
|
int iconId;
|
||||||
String titleStr;
|
String titleStr;
|
||||||
|
|||||||
Reference in New Issue
Block a user