Re-enabled logging to local db
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="uk.org.openseizuredetector"
|
||||
android:versionCode="91"
|
||||
android:versionName="3.7.0b">
|
||||
android:versionCode="92"
|
||||
android:versionName="3.9.0a">
|
||||
<!-- android:allowBackup="false" -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
|
||||
@@ -67,6 +67,7 @@ public class LogManager {
|
||||
|
||||
|
||||
public LogManager(Context context) {
|
||||
Log.d(TAG,"LogManger Constructor");
|
||||
mLogRemote = false;
|
||||
mLogRemoteMobile = false;
|
||||
mOSDUrl = null;
|
||||
@@ -74,17 +75,21 @@ public class LogManager {
|
||||
|
||||
Handler handler = new Handler();
|
||||
mUtil = new OsdUtil(mContext, handler);
|
||||
|
||||
openDb();
|
||||
startRemoteLogTimer();
|
||||
}
|
||||
|
||||
private boolean openDb() {
|
||||
Log.d(TAG, "openDb");
|
||||
try {
|
||||
mOSDDb = new OsdDbHelper(mDbTableName, mContext);
|
||||
if (!checkTableExists(mOSDDb, mDbTableName)) {
|
||||
Log.e(TAG,"ERROR - Table does not exist");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
Log.d(TAG,"table "+mDbTableName+" exists ok");
|
||||
}
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
Log.e(TAG, "Failed to open Database: " + e.toString());
|
||||
@@ -96,6 +101,7 @@ public class LogManager {
|
||||
private boolean checkTableExists(OsdDbHelper osdDb, String osdTableName) {
|
||||
Cursor c = null;
|
||||
boolean tableExists = false;
|
||||
Log.d(TAG,"checkTableExists()");
|
||||
try {
|
||||
c = osdDb.getWritableDatabase().query(osdTableName, null,
|
||||
null, null, null, null, null);
|
||||
@@ -120,6 +126,9 @@ public class LogManager {
|
||||
String SQLStr = "SQLStr";
|
||||
|
||||
try {
|
||||
double roiRatio = -1;
|
||||
if (sdData.specPower != 0)
|
||||
roiRatio = 10. * sdData.roiPower / sdData.specPower;
|
||||
SQLStr = "INSERT INTO "+ mDbTableName
|
||||
+ "(dataTime, wearer_id, BattPC, specPow, roiRatio, avAcc, sdAcc, hr, status, dataJSON, uploaded)"
|
||||
+ " VALUES("
|
||||
@@ -127,7 +136,7 @@ public class LogManager {
|
||||
+ -1 + ","
|
||||
+ sdData.batteryPc + ","
|
||||
+ sdData.specPower + ","
|
||||
+ 10. * sdData.roiPower / sdData.specPower + ","
|
||||
+ roiRatio + ","
|
||||
+ sdData.getAvAcc() + ","
|
||||
+ sdData.getSdAcc() + ","
|
||||
+ sdData.mHR + ","
|
||||
@@ -136,6 +145,7 @@ public class LogManager {
|
||||
+ 0
|
||||
+")";
|
||||
mOSDDb.getWritableDatabase().execSQL(SQLStr);
|
||||
Log.d(TAG,"data written to database");
|
||||
|
||||
} catch (SQLException e) {
|
||||
Log.e(TAG,"writeToLocalDb(): Error Writing Data: " + e.toString());
|
||||
@@ -302,10 +312,11 @@ public class LogManager {
|
||||
public static final int DATABASE_VERSION = 1;
|
||||
public static final String DATABASE_NAME = "OsdData.db";
|
||||
private String mOsdTableName;
|
||||
private String TAG = "OsdDbHelper";
|
||||
private String TAG = "LogManager.OsdDbHelper";
|
||||
|
||||
public OsdDbHelper(String osdTableName, Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
Log.d(TAG,"OsdDbHelper constructor");
|
||||
mOsdTableName = osdTableName;
|
||||
}
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
|
||||
@@ -219,9 +219,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
updatePrefs();
|
||||
|
||||
// Create our log manager.
|
||||
//mLm = new LogManager(mLogDataRemote, mLogDataRemoteMobile,
|
||||
// mOSDUname, mOSDPasswd, mOSDWearerId, mOSDUrl, this);
|
||||
//mLm = new LogManager(this);
|
||||
mLm = new LogManager(this);
|
||||
|
||||
Log.v(TAG, "onStartCommand: Datasource =" + mSdDataSourceName);
|
||||
switch (mSdDataSourceName) {
|
||||
@@ -1109,7 +1107,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
if (mLogData) {
|
||||
Log.v(TAG, "logData() - writing data to SD Card");
|
||||
writeToSD();
|
||||
//mLm.writeToLocalDb(mSdData);
|
||||
mLm.writeToLocalDb(mSdData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<resources>
|
||||
<string name="app_name">OpenSeizureDetector</string>
|
||||
<string name="changelog">
|
||||
"V3.7.0 - Added support for Garmin Blood Oxygen Saturation measurements
|
||||
"V3.9.x - Added logging of data to remote server
|
||||
\nV3.7.0 - Added support for Garmin Blood Oxygen Saturation measurements
|
||||
\nV3.6.2 - Fix of issue with log file permissions on some Android 10 devices and added more translatable strings with polish translation.
|
||||
\nV3.6.1 - Possible fix for issue with shutting down system and expanded Polish translation to all settings screens.
|
||||
\nV3.6 - Added phone sensor data source for testing without a watches
|
||||
|
||||
Reference in New Issue
Block a user