Minor tidying up - removing unused variables etc.

This commit is contained in:
Graham Jones
2022-02-21 20:13:57 +00:00
parent 39ea02020f
commit 256536fa4f
4 changed files with 100 additions and 78 deletions

View File

@@ -24,7 +24,6 @@ package uk.org.openseizuredetector;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor; import android.database.Cursor;
import android.database.DatabaseUtils; import android.database.DatabaseUtils;
import android.database.SQLException; import android.database.SQLException;
@@ -33,8 +32,6 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.format.Time;
import android.util.Log; import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
@@ -50,15 +47,13 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.function.Consumer; import java.util.function.Consumer;
import static android.database.sqlite.SQLiteDatabase.openOrCreateDatabase; //import static android.database.sqlite.SQLiteDatabase.openOrCreateDatabase;
/** /**
* LogManager is a class to handle all aspects of Data Logging within OpenSeizureDetector. * LogManager is a class to handle all aspects of Data Logging within OpenSeizureDetector.
* It performs several functions: * It performs several functions:
* - It will store seizure detector data to a local database on demand (it is called by the SdServer background service) * - It will store seizure detector data to a local database on demand (it is called by the SdServer background service)
* - <FIXME: Not Yet Implemented> It will retrieve data from the local database for display on the user interface * - It will store system log data to the local database on demand (called by any part of OSD via the osdUtil functions)
* - <FIXME: Not Yet Implemented> It will periodically trim the local database to retain only a specified number of days worth of data
* to avoid the local storage use increasing continuously.
* - It will periodically attempt to upload the oldest logged data to the osdApi remote database - the interface to the * - It will periodically attempt to upload the oldest logged data to the osdApi remote database - the interface to the
* remote database is handled by the WebApiConnection class. It only tries to do one transaction with the external database * remote database is handled by the WebApiConnection class. It only tries to do one transaction with the external database
* at a time - if the periodic timer times out and an upload is in progress it will not do anything and wait for the next timeout.* * at a time - if the periodic timer times out and an upload is in progress it will not do anything and wait for the next timeout.*
@@ -71,13 +66,15 @@ import static android.database.sqlite.SQLiteDatabase.openOrCreateDatabase;
* - Mark all the uploaded datapoints as uploaded. * - Mark all the uploaded datapoints as uploaded.
*/ */
public class LogManager { public class LogManager {
private String TAG = "LogManager"; static final private String TAG = "LogManager";
private String mDbName = "osdData"; //private String mDbName = "osdData";
private String mDbTableName = "datapoints"; final private String mDpTableName = "datapoints";
final private String mSysLogTableName = "syslog";
private boolean mLogRemote; private boolean mLogRemote;
private boolean mLogRemoteMobile; private boolean mLogRemoteMobile;
private String mAuthToken; private String mAuthToken;
private OsdDbHelper mOSDDb; static private OsdDbHelper mDpDb; // Datapoints table helper.
private OsdDbHelper mSysLogDb; // Datapoints table helper.
private RemoteLogTimer mRemoteLogTimer; private RemoteLogTimer mRemoteLogTimer;
private Context mContext; private Context mContext;
private OsdUtil mUtil; private OsdUtil mUtil;
@@ -99,7 +96,6 @@ public class LogManager {
boolean logRemote, boolean logRemoteMobile, String authToken, boolean logRemote, boolean logRemoteMobile, String authToken,
long eventDuration, long remoteLogPeriod, long eventDuration, long remoteLogPeriod,
boolean autoPruneDb, long dataRetentionPeriod) { boolean autoPruneDb, long dataRetentionPeriod) {
String prefVal;
Log.d(TAG, "LogManger Constructor"); Log.d(TAG, "LogManger Constructor");
mContext = context; mContext = context;
Handler handler = new Handler(); Handler handler = new Handler();
@@ -147,7 +143,6 @@ public class LogManager {
cNames.append(", ").append(n); cNames.append(", ").append(n);
} }
//Log.v(TAG,"cursor2Json() - c="+c.toString()+", columns="+cNames+", number of rows="+c.getCount()); //Log.v(TAG,"cursor2Json() - c="+c.toString()+", columns="+cNames+", number of rows="+c.getCount());
String retVal = "";
c.moveToFirst(); c.moveToFirst();
//JSONObject Root = new JSONObject(); //JSONObject Root = new JSONObject();
JSONArray dataPointArray = new JSONArray(); JSONArray dataPointArray = new JSONArray();
@@ -176,17 +171,30 @@ public class LogManager {
private boolean openDb() { private boolean openDb() {
Log.d(TAG, "openDb"); Log.d(TAG, "openDb");
try { try {
mOSDDb = new OsdDbHelper(mDbTableName, mContext); mDpDb = new OsdDbHelper(mDpTableName, mContext);
if (!checkTableExists(mOSDDb, mDbTableName)) { if (!checkTableExists(mDpDb, mDpTableName)) {
Log.e(TAG, "ERROR - Table does not exist"); Log.e(TAG, "ERROR - Table does not exist");
return false; return false;
} else { } else {
Log.d(TAG, "table " + mDbTableName + " exists ok"); Log.d(TAG, "table " + mDpTableName + " exists ok");
}
} catch (SQLException e) {
Log.e(TAG, "Failed to open Database: " + e.toString());
mDpDb = null;
return false;
}
try {
mSysLogDb = new OsdDbHelper(mSysLogTableName, mContext);
if (!checkTableExists(mSysLogDb, mSysLogTableName)) {
Log.e(TAG, "ERROR - SysLog table does not exist");
return false;
} else {
Log.d(TAG, "table " + mSysLogTableName + " exists ok");
} }
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
Log.e(TAG, "Failed to open Database: " + e.toString()); Log.e(TAG, "Failed to open Syslog Database: " + e.toString());
mOSDDb = null; mSysLogDb = null;
return false; return false;
} }
} }
@@ -199,6 +207,7 @@ public class LogManager {
c = osdDb.getWritableDatabase().query(osdTableName, null, c = osdDb.getWritableDatabase().query(osdTableName, null,
null, null, null, null, null); null, null, null, null, null);
tableExists = true; tableExists = true;
c.close();
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, osdTableName + " doesn't exist :((("); Log.d(TAG, osdTableName + " doesn't exist :(((");
} }
@@ -210,8 +219,8 @@ public class LogManager {
* Write data to local database * Write data to local database
* FIXME - I am sure we should not be using raw SQL Srings to do this! * FIXME - I am sure we should not be using raw SQL Srings to do this!
*/ */
public void writeToLocalDb(SdData sdData) { public void writeDatapointToLocalDb(SdData sdData) {
Log.v(TAG, "writeToLocalDb()"); Log.v(TAG, "writeDatapointToLocalDb()");
Date curDate = new Date(); Date curDate = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -219,10 +228,10 @@ public class LogManager {
String SQLStr = "SQLStr"; String SQLStr = "SQLStr";
try { try {
double roiRatio = -1; //double roiRatio = -1;
if (sdData.specPower != 0) //if (sdData.specPower != 0)
roiRatio = 10. * sdData.roiPower / sdData.specPower; // roiRatio = 10. * sdData.roiPower / sdData.specPower;
SQLStr = "INSERT INTO " + mDbTableName SQLStr = "INSERT INTO " + mDpTableName
+ "(dataTime, status, dataJSON, uploaded)" + "(dataTime, status, dataJSON, uploaded)"
+ " VALUES(" + " VALUES("
+ "'" + dateStr + "'," + "'" + dateStr + "',"
@@ -230,8 +239,8 @@ public class LogManager {
+ DatabaseUtils.sqlEscapeString(sdData.toJSON(true)) + "," + DatabaseUtils.sqlEscapeString(sdData.toJSON(true)) + ","
+ 0 + 0
+ ")"; + ")";
mOSDDb.getWritableDatabase().execSQL(SQLStr); mDpDb.getWritableDatabase().execSQL(SQLStr);
Log.d(TAG, "data written to database"); Log.v(TAG, "data written to database");
} catch (SQLException e) { } catch (SQLException e) {
Log.e(TAG, "writeToLocalDb(): Error Writing Data: " + e.toString()); Log.e(TAG, "writeToLocalDb(): Error Writing Data: " + e.toString());
@@ -240,6 +249,38 @@ public class LogManager {
} }
/**
* Write syslog string to local database
* FIXME - I am sure we should not be using raw SQL Srings to do this!
*/
public void writeLogEntryToLocalDb(String logText, int statusVal) {
Log.v(TAG, "writeLogEntryToLocalDb()");
Date curDate = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateStr = dateFormat.format(curDate);
String SQLStr = "SQLStr";
try {
SQLStr = "INSERT INTO " + mSysLogTableName
+ "(dataTime, status, dataJSON, uploaded)"
+ " VALUES("
+ "'" + dateStr + "',"
+ statusVal + ","
+ DatabaseUtils.sqlEscapeString(logText) + ","
+ 0
+ ")";
mSysLogDb.getWritableDatabase().execSQL(SQLStr);
Log.v(TAG, "syslog entry written to database: "+logText);
} catch (SQLException e) {
Log.e(TAG, "writeToLocalDb(): Error Writing Data: " + e.toString());
Log.e(TAG, "SQLStr was " + SQLStr);
}
}
/** /**
* Returns a json representation of datapoint 'id'. * Returns a json representation of datapoint 'id'.
* *
@@ -248,14 +289,14 @@ public class LogManager {
*/ */
public String getDatapointById(long id) { public String getDatapointById(long id) {
Log.d(TAG, "getDatapointById() - id=" + id); Log.d(TAG, "getDatapointById() - id=" + id);
Cursor c = null; Cursor c;
String retVal; String retVal;
try { try {
String selectStr = "select * from " + mDbTableName + " where id=" + id + ";"; String selectStr = "select * from " + mDpTableName + " where id=" + id + ";";
String[] selectArgs = new String[]{String.format("%d", id)}; //String[] selectArgs = new String[]{String.format("%d", id)};
//c = mOSDDb.getWritableDatabase().query(mDbTableName, null, //c = mOSDDb.getWritableDatabase().query(mDbTableName, null,
// selectStr, selectArgs, null, null, null); // selectStr, selectArgs, null, null, null);
c = mOSDDb.getWritableDatabase().rawQuery(selectStr, null); c = mDpDb.getWritableDatabase().rawQuery(selectStr, null);
retVal = cursor2Json(c); retVal = cursor2Json(c);
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, "getDatapointById(): Error Querying Database: " + e.getLocalizedMessage()); Log.d(TAG, "getDatapointById(): Error Querying Database: " + e.getLocalizedMessage());
@@ -274,10 +315,9 @@ public class LogManager {
*/ */
public boolean setDatapointToUploaded(int id, int eventId) { public boolean setDatapointToUploaded(int id, int eventId) {
Log.d(TAG, "setDatapointToUploaded() - id=" + id); Log.d(TAG, "setDatapointToUploaded() - id=" + id);
Cursor c = null;
ContentValues cv = new ContentValues(); ContentValues cv = new ContentValues();
cv.put("uploaded", eventId); cv.put("uploaded", eventId);
int nRowsUpdated = mOSDDb.getWritableDatabase().update(mDbTableName, cv, "id = ?", int nRowsUpdated = mDpDb.getWritableDatabase().update(mDpTableName, cv, "id = ?",
new String[]{String.format("%d", id)}); new String[]{String.format("%d", id)});
return (nRowsUpdated == 1); return (nRowsUpdated == 1);
@@ -287,20 +327,19 @@ public class LogManager {
/** /**
* setDatapointStatus() - Update the status of data point id. * setDatapointStatus() - Update the status of data point id.
* *
* @param id * @param id datapont id
* @param statusVal * @param statusVal the status to set for the datapoint.
* @return true on success or false on failure * @return true on success or false on failure
*/ */
public boolean setDatapointStatus(Long id, int statusVal) { public boolean setDatapointStatus(Long id, int statusVal) {
Log.d(TAG, "setDatapointStatus() - id=" + id + ", statusVal=" + statusVal); Log.d(TAG, "setDatapointStatus() - id=" + id + ", statusVal=" + statusVal);
Cursor c = null; //Cursor c = null;
ContentValues cv = new ContentValues(); ContentValues cv = new ContentValues();
cv.put("status", statusVal); cv.put("status", statusVal);
int nRowsUpdated = mOSDDb.getWritableDatabase().update(mDbTableName, cv, "id = ?", int nRowsUpdated = mDpDb.getWritableDatabase().update(mDpTableName, cv, "id = ?",
new String[]{String.format("%d", id)}); new String[]{String.format("%d", id)});
return (nRowsUpdated == 1); return (nRowsUpdated == 1);
} }
@@ -314,7 +353,7 @@ public class LogManager {
String[] columns = {"*"}; String[] columns = {"*"};
String whereClause = "DataTime>? AND DataTime<?"; String whereClause = "DataTime>? AND DataTime<?";
String[] whereArgs = {startDateStr, endDateStr}; String[] whereArgs = {startDateStr, endDateStr};
new SelectQueryTask(mDbTableName, columns, whereClause, whereArgs, new SelectQueryTask(mDpTableName, columns, whereClause, whereArgs,
null, null, "dataTime DESC", (Cursor cursor) -> { null, null, "dataTime DESC", (Cursor cursor) -> {
Log.v(TAG, "getDataPointsByDate - returned " + cursor); Log.v(TAG, "getDataPointsByDate - returned " + cursor);
if (cursor != null) { if (cursor != null) {
@@ -341,7 +380,7 @@ public class LogManager {
String whereClause = getEventWhereClause(includeWarnings); String whereClause = getEventWhereClause(includeWarnings);
//sqlStr = "SELECT * from " + mDbTableName + " where Status in (" + statusListStr + ") order by dataTime desc;"; //sqlStr = "SELECT * from " + mDbTableName + " where Status in (" + statusListStr + ") order by dataTime desc;";
String[] columns = {"*"}; String[] columns = {"*"};
new SelectQueryTask(mDbTableName, columns, whereClause, whereArgs, new SelectQueryTask(mDpTableName, columns, whereClause, whereArgs,
null, null, "dataTime DESC", (Cursor cursor) -> { null, null, "dataTime DESC", (Cursor cursor) -> {
Log.v(TAG, "getEventsList - returned " + cursor); Log.v(TAG, "getEventsList - returned " + cursor);
if (cursor != null) { if (cursor != null) {
@@ -370,7 +409,6 @@ public class LogManager {
*/ */
public int pruneLocalDb() { public int pruneLocalDb() {
Log.d(TAG, "pruneLocalDb()"); Log.d(TAG, "pruneLocalDb()");
Cursor c = null;
int retVal; int retVal;
long currentDateMillis = new Date().getTime(); long currentDateMillis = new Date().getTime();
long endDateMillis = currentDateMillis - 24 * 3600 * 1000 * mDataRetentionPeriod; long endDateMillis = currentDateMillis - 24 * 3600 * 1000 * mDataRetentionPeriod;
@@ -381,7 +419,7 @@ public class LogManager {
try { try {
String selectStr = "DataTime<=?"; String selectStr = "DataTime<=?";
String[] selectArgs = {endDateStr}; String[] selectArgs = {endDateStr};
retVal = mOSDDb.getWritableDatabase().delete(mDbTableName, selectStr, selectArgs); retVal = mDpDb.getWritableDatabase().delete(mDpTableName, selectStr, selectArgs);
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, "Error deleting datapoints" + e.toString()); Log.d(TAG, "Error deleting datapoints" + e.toString());
retVal = 0; retVal = 0;
@@ -418,7 +456,7 @@ public class LogManager {
whereArgs[i] = whereArgsStatus[i]; whereArgs[i] = whereArgsStatus[i];
} }
whereArgs[whereArgsStatus.length] = endDateStr; whereArgs[whereArgsStatus.length] = endDateStr;
new SelectQueryTask(mDbTableName, columns, whereClause, whereArgs, new SelectQueryTask(mDpTableName, columns, whereClause, whereArgs,
null, null, "dataTime DESC", (Cursor cursor) -> { null, null, "dataTime DESC", (Cursor cursor) -> {
Log.v(TAG, "getEventsList - returned " + cursor); Log.v(TAG, "getEventsList - returned " + cursor);
Long recordId = new Long(-1); Long recordId = new Long(-1);
@@ -451,7 +489,7 @@ public class LogManager {
String[] columns = {"*", "(julianday(dataTime)-julianday(datetime('" + dateStr + "'))) as ddiff"}; String[] columns = {"*", "(julianday(dataTime)-julianday(datetime('" + dateStr + "'))) as ddiff"};
//SQLStr = "SELECT *, (julianday(dataTime)-julianday(datetime('" + dateStr + "'))) as ddiff from " + mDbTableName + " order by ABS(ddiff) asc;"; //SQLStr = "SELECT *, (julianday(dataTime)-julianday(datetime('" + dateStr + "'))) as ddiff from " + mDbTableName + " order by ABS(ddiff) asc;";
String orderByStr = "ABS(ddiff) asc"; String orderByStr = "ABS(ddiff) asc";
new SelectQueryTask(mDbTableName, columns, null, null, new SelectQueryTask(mDpTableName, columns, null, null,
null, null, orderByStr, (Cursor cursor) -> { null, null, orderByStr, (Cursor cursor) -> {
Log.v(TAG, "getEventsNearestDatapointToDate - returned " + cursor); Log.v(TAG, "getEventsNearestDatapointToDate - returned " + cursor);
Long recordId = new Long(-1); Long recordId = new Long(-1);
@@ -484,7 +522,7 @@ public class LogManager {
String[] whereArgs = getEventWhereArgs(includeWarnings); String[] whereArgs = getEventWhereArgs(includeWarnings);
String whereClause = getEventWhereClause(includeWarnings); String whereClause = getEventWhereClause(includeWarnings);
String[] columns = {"*"}; String[] columns = {"*"};
new SelectQueryTask(mDbTableName, columns, whereClause, whereArgs, new SelectQueryTask(mDpTableName, columns, whereClause, whereArgs,
null, null, null, (Cursor cursor) -> { null, null, null, (Cursor cursor) -> {
Log.v(TAG, "getLocalEventsCount - returned " + cursor); Log.v(TAG, "getLocalEventsCount - returned " + cursor);
Long eventCount = Long.valueOf(0); Long eventCount = Long.valueOf(0);
@@ -507,7 +545,7 @@ public class LogManager {
String[] whereArgs = null; String[] whereArgs = null;
String whereClause = null; String whereClause = null;
String[] columns = {"*"}; String[] columns = {"*"};
new SelectQueryTask(mDbTableName, columns, whereClause, whereArgs, new SelectQueryTask(mDpTableName, columns, whereClause, whereArgs,
null, null, null, (Cursor cursor) -> { null, null, null, (Cursor cursor) -> {
Log.v(TAG, "getLocalDatapointsCount - returned " + cursor); Log.v(TAG, "getLocalDatapointsCount - returned " + cursor);
Long eventCount = Long.valueOf(0); Long eventCount = Long.valueOf(0);
@@ -525,17 +563,8 @@ public class LogManager {
* Executes the sqlite query (=SELECT statement) * Executes the sqlite query (=SELECT statement)
* Use as new SelectQueryTask(xxx,xxx,xx,xxxx).execute() * Use as new SelectQueryTask(xxx,xxx,xx,xxxx).execute()
* *
* @param table - table name to query
* @param columns - array of strings of column names to return
* @param selection - where clause
* @param selectionArgs - arguments for where clause (array of strings)
* @param groupBy;
* @param having;
* @param orderBy;
* @param callback
* @return A Cursor object containing the result of the query.
*/ */
private class SelectQueryTask extends AsyncTask<Void, Void, Cursor> { static private class SelectQueryTask extends AsyncTask<Void, Void, Cursor> {
// Based on https://stackoverflow.com/a/21120199/2104584 // Based on https://stackoverflow.com/a/21120199/2104584
String mTable; String mTable;
String[] mColumns; String[] mColumns;
@@ -570,7 +599,7 @@ public class LogManager {
+ ", mHaving =" + mHaving + ", mOrderBy=" + mOrderBy); + ", mHaving =" + mHaving + ", mOrderBy=" + mOrderBy);
try { try {
Cursor resultSet = mOSDDb.getWritableDatabase().query(mTable, mColumns, mSelection, Cursor resultSet = mDpDb.getWritableDatabase().query(mTable, mColumns, mSelection,
mSelectionArgs, mGroupBy, mHaving, mOrderBy); mSelectionArgs, mGroupBy, mHaving, mOrderBy);
resultSet.moveToFirst(); resultSet.moveToFirst();
return (resultSet); return (resultSet);
@@ -603,11 +632,9 @@ public class LogManager {
private String[] getEventWhereArgs(boolean includeWarnings) { private String[] getEventWhereArgs(boolean includeWarnings) {
String[] whereArgs; String[] whereArgs;
if (includeWarnings) { if (includeWarnings) {
String[] whereArgsWarnings = {"1", "2", "3", "5"}; whereArgs = new String[]{"1", "2", "3", "5"};
whereArgs = whereArgsWarnings;
} else { } else {
String[] whereArgsNoWarnings = {"2", "3", "5"}; whereArgs = new String[]{"2", "3", "5"};
whereArgs = whereArgsNoWarnings;
} }
return (whereArgs); return (whereArgs);
} }
@@ -661,7 +688,7 @@ public class LogManager {
Log.v(TAG, "uploadSdData() - eventId=" + eventId); Log.v(TAG, "uploadSdData() - eventId=" + eventId);
String eventJsonStr = getDatapointById(eventId); String eventJsonStr = getDatapointById(eventId);
Log.v(TAG, "uploadSdData() - eventJsonStr=" + eventJsonStr); Log.v(TAG, "uploadSdData() - eventJsonStr=" + eventJsonStr);
int eventType; //int eventType;
JSONObject eventObj; JSONObject eventObj;
int eventAlarmStatus; int eventAlarmStatus;
String eventDateStr; String eventDateStr;
@@ -729,8 +756,7 @@ public class LogManager {
finishUpload(); finishUpload();
return; return;
} }
Log.v(TAG, "eventCallback() EventId=" + eventId + ", eventDateStr=" + eventDateStr + ", eventDate=" + eventDate.toString()); Log.v(TAG, "eventCallback() EventId=" + eventId + ", eventDateStr=" + eventDateStr + ", eventDate=" + eventDate);
long eventDateMillis = eventDate.getTime(); long eventDateMillis = eventDate.getTime();
long startDateMillis = eventDateMillis - 1000 * mEventDuration / 2; long startDateMillis = eventDateMillis - 1000 * mEventDuration / 2;
long endDateMillis = eventDateMillis + 1000 * mEventDuration / 2; long endDateMillis = eventDateMillis + 1000 * mEventDuration / 2;
@@ -802,7 +828,7 @@ public class LogManager {
* close() - shut down the logging system * close() - shut down the logging system
*/ */
public void close() { public void close() {
mOSDDb.close(); mDpDb.close();
stopRemoteLogTimer(); stopRemoteLogTimer();
if (mWac != null) { if (mWac != null) {
Log.i(TAG,"Stopping Remote Database"); Log.i(TAG,"Stopping Remote Database");
@@ -866,12 +892,12 @@ public class LogManager {
} }
public class OsdDbHelper extends SQLiteOpenHelper { static public class OsdDbHelper extends SQLiteOpenHelper {
// If you change the database schema, you must increment the database version. // If you change the database schema, you must increment the database version.
public static final int DATABASE_VERSION = 1; public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "OsdData.db"; public static final String DATABASE_NAME = "OsdData.db";
private String mOsdTableName; private final String mOsdTableName;
private String TAG = "LogManager.OsdDbHelper"; private static final String TAG = "LogManager.OsdDbHelper";
public OsdDbHelper(String osdTableName, Context context) { public OsdDbHelper(String osdTableName, Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION); super(context, DATABASE_NAME, null, DATABASE_VERSION);
@@ -904,6 +930,8 @@ public class LogManager {
} }
} }
/** /**
* Upload recorded data to the remote database periodically. * Upload recorded data to the remote database periodically.
*/ */

View File

@@ -43,10 +43,6 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.location.Location; import android.location.Location;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.ToneGenerator; import android.media.ToneGenerator;
@@ -78,8 +74,6 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import uk.org.openseizuredetector.LogManager;
/** /**
* Based on example at: * Based on example at:
* http://stackoverflow.com/questions/14309256/using-nanohttpd-in-android * http://stackoverflow.com/questions/14309256/using-nanohttpd-in-android
@@ -898,7 +892,7 @@ public class SdServer extends Service implements SdDataReceiver {
} }
} else { } else {
Log.i(TAG, "sendSMSAlarm() - SMS Alarms Disabled - not doing anything!"); Log.i(TAG, "sendSMSAlarm() - SMS Alarms Disabled - not doing anything!");
mUtil.showToast(getString(R.string.sms_alarm_disabled)); mUtil.showToast(getString(R.string.sms_alarms_disabled));
} }
if (mPhoneAlarm) { if (mPhoneAlarm) {
if (!mCancelAudible) { if (!mCancelAudible) {
@@ -1142,7 +1136,7 @@ public class SdServer extends Service implements SdDataReceiver {
if (mLogData) { if (mLogData) {
Log.v(TAG, "logData() - writing data to Database"); Log.v(TAG, "logData() - writing data to Database");
//writeToSD(); //writeToSD();
mLm.writeToLocalDb(mSdData); mLm.writeDatapointToLocalDb(mSdData);
} }
} }

View File

@@ -81,6 +81,7 @@ public class StartupActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Log.i(TAG,"onCreate()"); Log.i(TAG,"onCreate()");
setContentView(R.layout.startup_activity);
// Set our custom uncaught exception handler to report issues. // Set our custom uncaught exception handler to report issues.
//Thread.setDefaultUncaughtExceptionHandler(new OsdUncaughtExceptionHandler(StartupActivity.this)); //Thread.setDefaultUncaughtExceptionHandler(new OsdUncaughtExceptionHandler(StartupActivity.this));
@@ -109,7 +110,6 @@ public class StartupActivity extends Activity {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.startup_activity);
Button b; Button b;

View File

@@ -129,7 +129,7 @@
<string name="sms_location_alarm_active">SMS Location Alarm Active</string> <string name="sms_location_alarm_active">SMS Location Alarm Active</string>
<string name="sms_location_alarm_disabled">SMS Location Alarm Disabled</string> <string name="sms_location_alarm_disabled">SMS Location Alarm Disabled</string>
<string name="cancel_audible_not_sending_sms">Cancel Audible Active - not sending SMS</string> <string name="cancel_audible_not_sending_sms">Cancel Audible Active - not sending SMS</string>
<string name="sms_alarm_disabled">SMS Alarms Disabled - not doing anything!</string> <!--<string name="sms_alarm_disabled">SMS Alarms Disabled - not doing anything!</string>-->
<string name="no_wifi_connection">Network State Changed - no Wifi Connection</string> <string name="no_wifi_connection">Network State Changed - no Wifi Connection</string>
<string name="no_active_network">Network State Changed - No Active Network</string> <string name="no_active_network">Network State Changed - No Active Network</string>
<string name="problem_parsing_preferences">Problem Parsing Preferences - Something won\'t work - Please go back to Settings and correct it!</string> <string name="problem_parsing_preferences">Problem Parsing Preferences - Something won\'t work - Please go back to Settings and correct it!</string>
@@ -193,7 +193,7 @@
<string name="enable_audible_alarm_title">Enable Audible Alarm</string> <string name="enable_audible_alarm_title">Enable Audible Alarm</string>
<string name="enable_audible_warning_summary">Issue an audible alarm if the seizure detector enters a warning (pre-alarm) condition.</string> <string name="enable_audible_warning_summary">Issue an audible alarm if the seizure detector enters a warning (pre-alarm) condition.</string>
<string name="enable_audible_warning_title">Enable Audible Warnings</string> <string name="enable_audible_warning_title">Enable Audible Warnings</string>
<string name="enable_audible_fault_summary">Issue an audible alarm if the system detects a fault (e.g. can not talk to Pebble).</string> <string name="enable_audible_fault_summary">Issue an audible alarm if the system detects a fault (e.g. can not talk to watch).</string>
<string name="enable_audible_fault_title">Enable Audible System FaultWarnings</string> <string name="enable_audible_fault_title">Enable Audible System FaultWarnings</string>
<string name="fault_timer_period_title">Fault Timer Duration (sec)</string> <string name="fault_timer_period_title">Fault Timer Duration (sec)</string>
<string name="fault_timer_period_summary">Duration that fault alarms are muted before initiating.</string> <string name="fault_timer_period_summary">Duration that fault alarms are muted before initiating.</string>