V4.0.0s - fixed issue with system not shutting down properly after enabling SMS alarms.
This commit is contained in:
BIN
app/release/app-release-4.0.0s.apk
Normal file
BIN
app/release/app-release-4.0.0s.apk
Normal file
Binary file not shown.
@@ -3,7 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="uk.org.openseizuredetector"
|
package="uk.org.openseizuredetector"
|
||||||
android:versionCode="95"
|
android:versionCode="95"
|
||||||
android:versionName="4.0.0r">
|
android:versionName="4.0.0s">
|
||||||
<!-- android:allowBackup="false" -->
|
<!-- android:allowBackup="false" -->
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
|
|||||||
@@ -120,15 +120,15 @@ public class LogManager {
|
|||||||
|
|
||||||
mUtil = new OsdUtil(mContext, handler);
|
mUtil = new OsdUtil(mContext, handler);
|
||||||
openDb();
|
openDb();
|
||||||
Log.i(TAG,"Starting Remote Database Interface");
|
Log.i(TAG, "Starting Remote Database Interface");
|
||||||
mWac = new WebApiConnection(mContext);
|
mWac = new WebApiConnection(mContext);
|
||||||
mWac.setStoredToken(mAuthToken);
|
mWac.setStoredToken(mAuthToken);
|
||||||
|
|
||||||
if (mLogRemote) {
|
if (mLogRemote) {
|
||||||
Log.i(TAG,"Starting Remote Log Timer");
|
Log.i(TAG, "Starting Remote Log Timer");
|
||||||
startRemoteLogTimer();
|
startRemoteLogTimer();
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG,"mLogRemote is false - not starting remote log timer");
|
Log.i(TAG, "mLogRemote is false - not starting remote log timer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAutoPruneDb) {
|
if (mAutoPruneDb) {
|
||||||
@@ -182,13 +182,13 @@ public class LogManager {
|
|||||||
Log.d(TAG, "openDb");
|
Log.d(TAG, "openDb");
|
||||||
try {
|
try {
|
||||||
if (mOsdDb == null) {
|
if (mOsdDb == null) {
|
||||||
Log.i(TAG,"openDb: mOsdDb is null - initialising");
|
Log.i(TAG, "openDb: mOsdDb is null - initialising");
|
||||||
mOsdDb = new OsdDbHelper(mContext).getWritableDatabase();
|
mOsdDb = new OsdDbHelper(mContext).getWritableDatabase();
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG,"openDb: mOsdDb has been initialised already so not doing anything");
|
Log.i(TAG, "openDb: mOsdDb has been initialised already so not doing anything");
|
||||||
}
|
}
|
||||||
if (!checkTableExists(mOsdDb, mDpTableName)) {
|
if (!checkTableExists(mOsdDb, mDpTableName)) {
|
||||||
Log.e(TAG, "ERROR - Table "+mDpTableName+" does not exist");
|
Log.e(TAG, "ERROR - Table " + mDpTableName + " does not exist");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "table " + mDpTableName + " exists ok");
|
Log.d(TAG, "table " + mDpTableName + " exists ok");
|
||||||
@@ -246,6 +246,8 @@ public class LogManager {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.e(TAG, "writeToLocalDb(): Error Writing Data: " + e.toString());
|
Log.e(TAG, "writeToLocalDb(): Error Writing Data: " + e.toString());
|
||||||
Log.e(TAG, "SQLStr was " + SQLStr);
|
Log.e(TAG, "SQLStr was " + SQLStr);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
Log.e(TAG, "writeToLocalDb(): Null Pointer Exception: " + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -532,7 +534,6 @@ 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()
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
static 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
|
||||||
@@ -579,6 +580,9 @@ public class LogManager {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Log.e(TAG, "SelectQueryTask.doInBackground(): Illegal Argument Exception: " + e.toString());
|
Log.e(TAG, "SelectQueryTask.doInBackground(): Illegal Argument Exception: " + e.toString());
|
||||||
return (null);
|
return (null);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
Log.e(TAG, "SelectQueryTask.doInBackground(): Null Pointer Exception: " + e.toString());
|
||||||
|
return (null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,7 +809,7 @@ public class LogManager {
|
|||||||
mOsdDb.close();
|
mOsdDb.close();
|
||||||
mOsdDb = null;
|
mOsdDb = null;
|
||||||
if (mWac != null) {
|
if (mWac != null) {
|
||||||
Log.i(TAG,"Stopping Remote Database Interface");
|
Log.i(TAG, "Stopping Remote Database Interface");
|
||||||
mWac.close();
|
mWac.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -898,19 +902,18 @@ public class LogManager {
|
|||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
// This database is only a cache for online data, so its upgrade policy is
|
// This database is only a cache for online data, so its upgrade policy is
|
||||||
// to simply to discard the data and start over
|
// to simply to discard the data and start over
|
||||||
Log.i(TAG,"onUpgrade()");
|
Log.i(TAG, "onUpgrade()");
|
||||||
db.execSQL("Drop table if exists " + mDpTableName + ";");
|
db.execSQL("Drop table if exists " + mDpTableName + ";");
|
||||||
onCreate(db);
|
onCreate(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
Log.i(TAG,"onDowngrade()");
|
Log.i(TAG, "onDowngrade()");
|
||||||
onUpgrade(db, oldVersion, newVersion);
|
onUpgrade(db, oldVersion, newVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload recorded data to the remote database periodically.
|
* Upload recorded data to the remote database periodically.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -144,6 +144,8 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
|
|||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
|
||||||
Log.i(TAG, "SharedPreference " + s + " Changed.");
|
Log.i(TAG, "SharedPreference " + s + " Changed.");
|
||||||
|
|
||||||
|
// if we have enabled the SMS alarm, we may need extra permissions approving. This is handled in
|
||||||
|
// StartUpActivity, so we exit this activity and start start-up activity.
|
||||||
if (s.equals("SMSAlarm")) {
|
if (s.equals("SMSAlarm")) {
|
||||||
if (sharedPreferences.getBoolean("SMSAlarm", false) == true) {
|
if (sharedPreferences.getBoolean("SMSAlarm", false) == true) {
|
||||||
Log.i(TAG, "onSharedPreferenceChanged(): SMS Alarm Enabled - Restarting start-up activity to check permissions");
|
Log.i(TAG, "onSharedPreferenceChanged(): SMS Alarm Enabled - Restarting start-up activity to check permissions");
|
||||||
@@ -152,10 +154,12 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
|
|||||||
startActivity(i);
|
startActivity(i);
|
||||||
Log.i(TAG,"onSharedPreferenceChanged() - finishing PrefActivity");
|
Log.i(TAG,"onSharedPreferenceChanged() - finishing PrefActivity");
|
||||||
finish();
|
finish();
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "OnSharedPreferenceChanged(): SMS Alarm disabled so do not need permissions");
|
Log.i(TAG, "OnSharedPreferenceChanged(): SMS Alarm disabled so do not need permissions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// For all other preference changes we just restart SdServer so it is not as alarming for the user!
|
||||||
//mUtil.showToast("Setting " + s + " Changed - restarting server");
|
//mUtil.showToast("Setting " + s + " Changed - restarting server");
|
||||||
mPrefChanged = true;
|
mPrefChanged = true;
|
||||||
mUtil.stopServer();
|
mUtil.stopServer();
|
||||||
|
|||||||
@@ -691,11 +691,11 @@ public abstract class SdDataSource {
|
|||||||
|
|
||||||
// get time since the last data was received from the watch.
|
// get time since the last data was received from the watch.
|
||||||
tdiff = (tnow.toMillis(false) - mDataStatusTime.toMillis(false));
|
tdiff = (tnow.toMillis(false) - mDataStatusTime.toMillis(false));
|
||||||
Log.v(TAG, "faultCheck() - tdiff=" + tdiff + ", mDataUpatePeriod=" + mDataUpdatePeriod + ", mAppRestartTimeout=" + mAppRestartTimeout
|
//Log.v(TAG, "faultCheck() - tdiff=" + tdiff + ", mDataUpatePeriod=" + mDataUpdatePeriod + ", mAppRestartTimeout=" + mAppRestartTimeout
|
||||||
+ ", combined = " + (mDataUpdatePeriod + mAppRestartTimeout) * 1000);
|
// + ", combined = " + (mDataUpdatePeriod + mAppRestartTimeout) * 1000);
|
||||||
if (!mWatchAppRunningCheck &&
|
if (!mWatchAppRunningCheck &&
|
||||||
(tdiff > (mDataUpdatePeriod + mAppRestartTimeout) * 1000)) {
|
(tdiff > (mDataUpdatePeriod + mAppRestartTimeout) * 1000)) {
|
||||||
Log.v(TAG, "faultCheck() - watch app not running so not doing anything");
|
//Log.v(TAG, "faultCheck() - watch app not running so not doing anything");
|
||||||
mAlarmCount = 0;
|
mAlarmCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1132,9 +1132,13 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
*/
|
*/
|
||||||
public void logData() {
|
public void logData() {
|
||||||
if (mLogData) {
|
if (mLogData) {
|
||||||
|
if (mLm != null) {
|
||||||
Log.v(TAG, "logData() - writing data to Database");
|
Log.v(TAG, "logData() - writing data to Database");
|
||||||
//writeToSD();
|
//writeToSD();
|
||||||
mLm.writeDatapointToLocalDb(mSdData);
|
mLm.writeDatapointToLocalDb(mSdData);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG,"logData() - mLm is null - this should not happen");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,18 +182,24 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
if (mUtil.isServerRunning()) {
|
if (mUtil.isServerRunning()) {
|
||||||
Log.i(TAG, "onStart() - server running - stopping it");
|
Log.i(TAG, "onStart() - server running - stopping it - isServerRunning="+mUtil.isServerRunning());
|
||||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - server already running - stopping it.");
|
mUtil.writeToSysLogFile("StartupActivity.onStart() - server already running - stopping it.");
|
||||||
mUtil.stopServer();
|
mUtil.stopServer();
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "onStart() - server not running - isServerRunning="+mUtil.isServerRunning());
|
||||||
}
|
}
|
||||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - starting server");
|
// Wait 0.1 second to give the server chance to shutdown in case we have just shut it down below, then start it
|
||||||
Log.i(TAG, "onStart() - starting server");
|
mHandler.postDelayed(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
mUtil.writeToSysLogFile("StartupActivity.onStart() - starting server after delay - isServerRunning="+mUtil.isServerRunning());
|
||||||
|
Log.i(TAG, "onStart() - starting server after delay -isServerRunning="+mUtil.isServerRunning());
|
||||||
mUtil.startServer();
|
mUtil.startServer();
|
||||||
|
|
||||||
// Bind to the service.
|
// Bind to the service.
|
||||||
Log.i(TAG, "onStart() - binding to server");
|
Log.i(TAG, "onStart() - binding to server");
|
||||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - binding to server");
|
mUtil.writeToSysLogFile("StartupActivity.onStart() - binding to server");
|
||||||
mUtil.bindToServer(getApplicationContext(), mConnection);
|
mUtil.bindToServer(getApplicationContext(), mConnection);
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
|
||||||
// Check power management settings
|
// Check power management settings
|
||||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||||
@@ -218,7 +224,7 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
mHandler.post(serverStatusRunnable);
|
mHandler.post(serverStatusRunnable);
|
||||||
//updateServerStatus();
|
//updateServerStatus();
|
||||||
}
|
}
|
||||||
}, 0, 2000);
|
}, 0, 5000);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -641,15 +647,6 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
for (int i = 0; i < permissions.length; i++) {
|
for (int i = 0; i < permissions.length; i++) {
|
||||||
Log.i(TAG, "Permission " + permissions[i] + " = " + grantResults[i]);
|
Log.i(TAG, "Permission " + permissions[i] + " = " + grantResults[i]);
|
||||||
}
|
}
|
||||||
//mUtil.showToast(getString(R.string.RestartingServerMsg));
|
|
||||||
//mUtil.stopServer();
|
|
||||||
// Wait 0.1 second to give the server chance to shutdown, then re-start it
|
|
||||||
//mHandler.postDelayed(new Runnable() {
|
|
||||||
//public void run() {
|
|
||||||
//mUtil.startServer();
|
|
||||||
//}
|
|
||||||
//}, 100);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user