Progress with app shutdown - it now usually shuts down correctly, but logging out of data sharing is still a problem.
This commit is contained in:
BIN
app/release/app-release-4.0.0g.apk
Normal file
BIN
app/release/app-release-4.0.0g.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="92"
|
android:versionCode="92"
|
||||||
android:versionName="4.0.0f">
|
android:versionName="4.0.0g">
|
||||||
<!-- 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" />
|
||||||
|
|||||||
@@ -804,6 +804,10 @@ public class LogManager {
|
|||||||
public void close() {
|
public void close() {
|
||||||
mOSDDb.close();
|
mOSDDb.close();
|
||||||
stopRemoteLogTimer();
|
stopRemoteLogTimer();
|
||||||
|
if (mWac != null) {
|
||||||
|
Log.i(TAG,"Stopping Remote Database");
|
||||||
|
mWac.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public class OsdUtil implements ActivityCompat.OnRequestPermissionsResultCallbac
|
|||||||
* Stop the SdServer service
|
* Stop the SdServer service
|
||||||
*/
|
*/
|
||||||
public void stopServer() {
|
public void stopServer() {
|
||||||
Log.d(TAG, "OsdUtil.stopServer() - stopping Server... - mNbound=" + mNbound);
|
Log.i(TAG, "OsdUtil.stopServer() - stopping Server... - mNbound=" + mNbound);
|
||||||
writeToSysLogFile("stopserver() - stopping server");
|
writeToSysLogFile("stopserver() - stopping server");
|
||||||
|
|
||||||
// then send an Intent to stop the service.
|
// then send an Intent to stop the service.
|
||||||
|
|||||||
@@ -282,8 +282,8 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
|
|
||||||
// Initialise Notification channel for API level 26 and over
|
// Initialise Notification channel for API level 26 and over
|
||||||
// from https://stackoverflow.com/questions/44443690/notificationcompat-with-api-26
|
// from https://stackoverflow.com/questions/44443690/notificationcompat-with-api-26
|
||||||
mNM= (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
|
mNM = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
mNotificationBuilder = new NotificationCompat.Builder(this,mNotChId);
|
mNotificationBuilder = new NotificationCompat.Builder(this, mNotChId);
|
||||||
if (Build.VERSION.SDK_INT >= 26) {
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
NotificationChannel channel = new NotificationChannel(mNotChId,
|
NotificationChannel channel = new NotificationChannel(mNotChId,
|
||||||
mNotChName,
|
mNotChName,
|
||||||
@@ -299,7 +299,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
Log.v(TAG, "showing Notification and calling startForeground (Android 8 and higher)");
|
Log.v(TAG, "showing Notification and calling startForeground (Android 8 and higher)");
|
||||||
mUtil.writeToSysLogFile("SdServer.onStartCommand() - showing Notification and calling startForeground (Android 8 and higher)");
|
mUtil.writeToSysLogFile("SdServer.onStartCommand() - showing Notification and calling startForeground (Android 8 and higher)");
|
||||||
showNotification(0);
|
showNotification(0);
|
||||||
startForeground(NOTIFICATION_ID,mNotification);
|
startForeground(NOTIFICATION_ID, mNotification);
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "showing Notification");
|
Log.v(TAG, "showing Notification");
|
||||||
mUtil.writeToSysLogFile("SdServer.onStartCommand() - showing Notification");
|
mUtil.writeToSysLogFile("SdServer.onStartCommand() - showing Notification");
|
||||||
@@ -308,7 +308,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
// Record last time we sent an SMS so we can limit rate of SMS
|
// Record last time we sent an SMS so we can limit rate of SMS
|
||||||
// sending to one per minute. We set it to one minute ago (60000 milliseconds)
|
// sending to one per minute. We set it to one minute ago (60000 milliseconds)
|
||||||
mSMSTime = new Time(Time.getCurrentTimezone());
|
mSMSTime = new Time(Time.getCurrentTimezone());
|
||||||
mSMSTime.set(mSMSTime.toMillis(false)-60000);
|
mSMSTime.set(mSMSTime.toMillis(false) - 60000);
|
||||||
|
|
||||||
|
|
||||||
// Start timer to log data regularly..
|
// Start timer to log data regularly..
|
||||||
@@ -428,6 +428,8 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
Log.v(TAG, "onDestroy(): cancelling notification");
|
Log.v(TAG, "onDestroy(): cancelling notification");
|
||||||
mUtil.writeToSysLogFile("SdServer.onDestroy - cancelling notification");
|
mUtil.writeToSysLogFile("SdServer.onDestroy - cancelling notification");
|
||||||
mNM.cancel(NOTIFICATION_ID);
|
mNM.cancel(NOTIFICATION_ID);
|
||||||
|
mNM.cancel(EVENT_NOTIFICATION_ID);
|
||||||
|
|
||||||
|
|
||||||
// stop this service.
|
// stop this service.
|
||||||
Log.v(TAG, "onDestroy(): calling stopSelf()");
|
Log.v(TAG, "onDestroy(): calling stopSelf()");
|
||||||
@@ -439,6 +441,11 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
mUtil.writeToSysLogFile("SdServer.onDestroy() -error " + e.toString());
|
mUtil.writeToSysLogFile("SdServer.onDestroy() -error " + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mLm != null) {
|
||||||
|
Log.i(TAG, "Closing Down Log Manager");
|
||||||
|
mLm.close();
|
||||||
|
}
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -448,7 +455,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
* Show a notification while this service is running.
|
* Show a notification while this service is running.
|
||||||
*/
|
*/
|
||||||
private void showNotification(int alarmLevel) {
|
private void showNotification(int alarmLevel) {
|
||||||
Log.v(TAG, "showNotification() - alarmLevel="+alarmLevel);
|
Log.v(TAG, "showNotification() - alarmLevel=" + alarmLevel);
|
||||||
int iconId;
|
int iconId;
|
||||||
String titleStr;
|
String titleStr;
|
||||||
Uri soundUri = null;
|
Uri soundUri = null;
|
||||||
@@ -483,7 +490,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mCancelAudible) {
|
if (mCancelAudible) {
|
||||||
Log.v(TAG,"ShowNotification - Not beeping because mCancelAudible set");
|
Log.v(TAG, "ShowNotification - Not beeping because mCancelAudible set");
|
||||||
soundUri = null;
|
soundUri = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,7 +519,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
.build();
|
.build();
|
||||||
if (mMp3Alarm) {
|
if (mMp3Alarm) {
|
||||||
if (soundUri != null) {
|
if (soundUri != null) {
|
||||||
Log.v(TAG, "showNotification - setting Notification Sound to "+soundUri.toString());
|
Log.v(TAG, "showNotification - setting Notification Sound to " + soundUri.toString());
|
||||||
mNotificationBuilder.setSound(soundUri);
|
mNotificationBuilder.setSound(soundUri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -543,7 +550,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void raiseManualAlarm() {
|
public void raiseManualAlarm() {
|
||||||
Log.d(TAG,"raiseManualAlarm()");
|
Log.d(TAG, "raiseManualAlarm()");
|
||||||
SdData sdData = mSdData;
|
SdData sdData = mSdData;
|
||||||
sdData.alarmState = 5;
|
sdData.alarmState = 5;
|
||||||
onSdDataReceived(sdData);
|
onSdDataReceived(sdData);
|
||||||
@@ -557,7 +564,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
*/
|
*/
|
||||||
public void onSdDataReceived(SdData sdData) {
|
public void onSdDataReceived(SdData sdData) {
|
||||||
Log.v(TAG, "onSdDataReceived() - " + sdData.toString());
|
Log.v(TAG, "onSdDataReceived() - " + sdData.toString());
|
||||||
Log.v(TAG,"onSdDataReceived(), sdData.fallAlarmStanding="+sdData.fallAlarmStanding);
|
Log.v(TAG, "onSdDataReceived(), sdData.fallAlarmStanding=" + sdData.fallAlarmStanding);
|
||||||
|
|
||||||
if (sdData.alarmState == 0) {
|
if (sdData.alarmState == 0) {
|
||||||
if ((!mLatchAlarms) ||
|
if ((!mLatchAlarms) ||
|
||||||
@@ -632,7 +639,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
startLatchTimer();
|
startLatchTimer();
|
||||||
}
|
}
|
||||||
// Handle fall alarm
|
// Handle fall alarm
|
||||||
Log.v(TAG,"sdData.fallAlarmStanding="+sdData.fallAlarmStanding );
|
Log.v(TAG, "sdData.fallAlarmStanding=" + sdData.fallAlarmStanding);
|
||||||
if ((sdData.alarmState == 3) || (sdData.fallAlarmStanding)) {
|
if ((sdData.alarmState == 3) || (sdData.fallAlarmStanding)) {
|
||||||
sdData.alarmPhrase = "FALL";
|
sdData.alarmPhrase = "FALL";
|
||||||
sdData.fallAlarmStanding = true;
|
sdData.fallAlarmStanding = true;
|
||||||
@@ -778,7 +785,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
mUtil.writeToSysLogFile("onSdDataFault() - starting Fault Timer");
|
mUtil.writeToSysLogFile("onSdDataFault() - starting Fault Timer");
|
||||||
}
|
}
|
||||||
|
|
||||||
showNotification(-1);
|
showNotification(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* from http://stackoverflow.com/questions/12154940/how-to-make-a-beep-in-android */
|
/* from http://stackoverflow.com/questions/12154940/how-to-make-a-beep-in-android */
|
||||||
@@ -802,8 +809,8 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
*/
|
*/
|
||||||
public void faultWarningBeep() {
|
public void faultWarningBeep() {
|
||||||
if (mCancelAudible) {
|
if (mCancelAudible) {
|
||||||
Log.v(TAG, "faultWarningBeep() - CancelAudible Active - silent beep...");
|
Log.v(TAG, "faultWarningBeep() - CancelAudible Active - silent beep...");
|
||||||
} else {
|
} else {
|
||||||
if (mAudibleFaultWarning) {
|
if (mAudibleFaultWarning) {
|
||||||
if (mMp3Alarm) {
|
if (mMp3Alarm) {
|
||||||
Log.v(TAG, "Not making MP3 fault beep - handled by notification");
|
Log.v(TAG, "Not making MP3 fault beep - handled by notification");
|
||||||
@@ -913,14 +920,14 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
DialogInterface.OnClickListener smsCancelClickListener = new DialogInterface.OnClickListener() {
|
DialogInterface.OnClickListener smsCancelClickListener = new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
switch (which){
|
switch (which) {
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
Log.v(TAG,"smsCancelClickListener - Positive button");
|
Log.v(TAG, "smsCancelClickListener - Positive button");
|
||||||
//Yes button clicked
|
//Yes button clicked
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
Log.v(TAG,"smsCancelClickListener - Negative button");
|
Log.v(TAG, "smsCancelClickListener - Negative button");
|
||||||
//No button clicked
|
//No button clicked
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -928,7 +935,6 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the timer that will send and SMS alert after a given period.
|
* Start the timer that will send and SMS alert after a given period.
|
||||||
*/
|
*/
|
||||||
@@ -961,10 +967,8 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the timer that will automatically re-set a latched alarm after a given period.
|
* Start the timer that will automatically re-set a latched alarm after a given period.
|
||||||
*/
|
*/
|
||||||
private void startLatchTimer() {
|
private void startLatchTimer() {
|
||||||
if (mLatchAlarms) {
|
if (mLatchAlarms) {
|
||||||
@@ -1076,7 +1080,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
} else {
|
} else {
|
||||||
if (webServer.isAlive()) {
|
if (webServer.isAlive()) {
|
||||||
Log.w(TAG, "stopWebServer() - server still alive???");
|
Log.w(TAG, "stopWebServer() - server still alive???");
|
||||||
mUtil.writeToSysLogFile( "stopWebServer() - server still alive???");
|
mUtil.writeToSysLogFile("stopWebServer() - server still alive???");
|
||||||
} else {
|
} else {
|
||||||
mUtil.writeToSysLogFile("stopWebServer() - server died ok");
|
mUtil.writeToSysLogFile("stopWebServer() - server died ok");
|
||||||
Log.v(TAG, "stopWebServer() - server died ok");
|
Log.v(TAG, "stopWebServer() - server died ok");
|
||||||
@@ -1166,7 +1170,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
mUtil.writeToSysLogFile("updatePrefs() - mLatchAlarmTimerPeriod = " + mLatchAlarmPeriod);
|
mUtil.writeToSysLogFile("updatePrefs() - mLatchAlarmTimerPeriod = " + mLatchAlarmPeriod);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.v(TAG, "updatePrefs() - Problem with LatchAlarmTimerPeriod preference!");
|
Log.v(TAG, "updatePrefs() - Problem with LatchAlarmTimerPeriod preference!");
|
||||||
mUtil.writeToSysLogFile( "updatePrefs() - Problem with LatchAlarmTimerPeriod preference!");
|
mUtil.writeToSysLogFile("updatePrefs() - Problem with LatchAlarmTimerPeriod preference!");
|
||||||
mUtil.showToast(getString(R.string.problem_parsing_preferences));
|
mUtil.showToast(getString(R.string.problem_parsing_preferences));
|
||||||
}
|
}
|
||||||
mAudibleFaultWarning = SP.getBoolean("AudibleFaultWarning", true);
|
mAudibleFaultWarning = SP.getBoolean("AudibleFaultWarning", true);
|
||||||
@@ -1192,30 +1196,30 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
mUtil.writeToSysLogFile("updatePrefs() - mAuidbleWarning = " + mAudibleWarning);
|
mUtil.writeToSysLogFile("updatePrefs() - mAuidbleWarning = " + mAudibleWarning);
|
||||||
mMp3Alarm = SP.getBoolean("UseMp3Alarm", false);
|
mMp3Alarm = SP.getBoolean("UseMp3Alarm", false);
|
||||||
Log.v(TAG, "updatePrefs() - mMp3Alarm = " + mMp3Alarm);
|
Log.v(TAG, "updatePrefs() - mMp3Alarm = " + mMp3Alarm);
|
||||||
mUtil.writeToSysLogFile( "updatePrefs() - mMp3Alarm = " + mMp3Alarm);
|
mUtil.writeToSysLogFile("updatePrefs() - mMp3Alarm = " + mMp3Alarm);
|
||||||
|
|
||||||
mSMSAlarm = SP.getBoolean("SMSAlarm", false);
|
mSMSAlarm = SP.getBoolean("SMSAlarm", false);
|
||||||
Log.v(TAG, "updatePrefs() - mSMSAlarm = " + mSMSAlarm);
|
Log.v(TAG, "updatePrefs() - mSMSAlarm = " + mSMSAlarm);
|
||||||
mUtil.writeToSysLogFile( "updatePrefs() - mSMSAlarm = " + mSMSAlarm);
|
mUtil.writeToSysLogFile("updatePrefs() - mSMSAlarm = " + mSMSAlarm);
|
||||||
mPhoneAlarm = SP.getBoolean("PhoneCallAlarm", false);
|
mPhoneAlarm = SP.getBoolean("PhoneCallAlarm", false);
|
||||||
Log.v(TAG, "updatePrefs() - mSMSAlarm = " + mSMSAlarm);
|
Log.v(TAG, "updatePrefs() - mSMSAlarm = " + mSMSAlarm);
|
||||||
mUtil.writeToSysLogFile( "updatePrefs() - mSMSAlarm = " + mSMSAlarm);
|
mUtil.writeToSysLogFile("updatePrefs() - mSMSAlarm = " + mSMSAlarm);
|
||||||
String SMSNumberStr = SP.getString("SMSNumbers", "");
|
String SMSNumberStr = SP.getString("SMSNumbers", "");
|
||||||
mSMSNumbers = SMSNumberStr.split(",");
|
mSMSNumbers = SMSNumberStr.split(",");
|
||||||
mSMSMsgStr = SP.getString("SMSMsg", "Seizure Detected!!!");
|
mSMSMsgStr = SP.getString("SMSMsg", "Seizure Detected!!!");
|
||||||
Log.v(TAG, "updatePrefs() - SMSNumberStr = " + SMSNumberStr);
|
Log.v(TAG, "updatePrefs() - SMSNumberStr = " + SMSNumberStr);
|
||||||
mUtil.writeToSysLogFile( "updatePrefs() - SMSNumberStr = " + SMSNumberStr);
|
mUtil.writeToSysLogFile("updatePrefs() - SMSNumberStr = " + SMSNumberStr);
|
||||||
Log.v(TAG, "updatePrefs() - mSMSNumbers = " + mSMSNumbers);
|
Log.v(TAG, "updatePrefs() - mSMSNumbers = " + mSMSNumbers);
|
||||||
mUtil.writeToSysLogFile( "updatePrefs() - mSMSNumbers = " + mSMSNumbers);
|
mUtil.writeToSysLogFile("updatePrefs() - mSMSNumbers = " + mSMSNumbers);
|
||||||
mLogAlarms = SP.getBoolean("LogAlarms", true);
|
mLogAlarms = SP.getBoolean("LogAlarms", true);
|
||||||
Log.v(TAG, "updatePrefs() - mLogAlarms = " + mLogAlarms);
|
Log.v(TAG, "updatePrefs() - mLogAlarms = " + mLogAlarms);
|
||||||
mUtil.writeToSysLogFile("updatePrefs() - mLogAlarms = " + mLogAlarms);
|
mUtil.writeToSysLogFile("updatePrefs() - mLogAlarms = " + mLogAlarms);
|
||||||
mLogData = SP.getBoolean("LogData", true);
|
mLogData = SP.getBoolean("LogData", true);
|
||||||
Log.v(TAG, "SdServer.updatePrefs() - mLogData = " + mLogData);
|
Log.v(TAG, "SdServer.updatePrefs() - mLogData = " + mLogData);
|
||||||
mUtil.writeToSysLogFile( "updatePrefs() - mLogData = " + mLogData);
|
mUtil.writeToSysLogFile("updatePrefs() - mLogData = " + mLogData);
|
||||||
mLogDataRemote = SP.getBoolean("LogDataRemote", false);
|
mLogDataRemote = SP.getBoolean("LogDataRemote", false);
|
||||||
Log.v(TAG, "updatePrefs() - mLogDataRemote = " + mLogDataRemote);
|
Log.v(TAG, "updatePrefs() - mLogDataRemote = " + mLogDataRemote);
|
||||||
mUtil.writeToSysLogFile( "updatePrefs() - mLogDataRemote = " + mLogDataRemote);
|
mUtil.writeToSysLogFile("updatePrefs() - mLogDataRemote = " + mLogDataRemote);
|
||||||
mLogDataRemoteMobile = SP.getBoolean("LogDataRemoteMobile", false);
|
mLogDataRemoteMobile = SP.getBoolean("LogDataRemoteMobile", false);
|
||||||
Log.v(TAG, "updatePrefs() - mLogDataRemoteMobile = " + mLogDataRemoteMobile);
|
Log.v(TAG, "updatePrefs() - mLogDataRemoteMobile = " + mLogDataRemoteMobile);
|
||||||
mUtil.writeToSysLogFile("updatePrefs() - mLogDataRemoteMobile = " + mLogDataRemoteMobile);
|
mUtil.writeToSysLogFile("updatePrefs() - mLogDataRemoteMobile = " + mLogDataRemoteMobile);
|
||||||
@@ -1247,7 +1251,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
//Log.v(TAG, "updatePrefs() - mOSDWearerId = " + mOSDWearerId);
|
//Log.v(TAG, "updatePrefs() - mOSDWearerId = " + mOSDWearerId);
|
||||||
mOSDUrl = SP.getString("OSDUrl", "http://openseizuredetector.org.uk/webApi");
|
mOSDUrl = SP.getString("OSDUrl", "http://openseizuredetector.org.uk/webApi");
|
||||||
Log.v(TAG, "updatePrefs() - mOSDUrl = " + mOSDUrl);
|
Log.v(TAG, "updatePrefs() - mOSDUrl = " + mOSDUrl);
|
||||||
mUtil.writeToSysLogFile( "updatePrefs() - mOSDUrl = " + mOSDUrl);
|
mUtil.writeToSysLogFile("updatePrefs() - mOSDUrl = " + mOSDUrl);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.v(TAG, "updatePrefs() - Problem parsing preferences!");
|
Log.v(TAG, "updatePrefs() - Problem parsing preferences!");
|
||||||
mUtil.writeToSysLogFile("SdServer.updatePrefs() - Error " + ex.toString());
|
mUtil.writeToSysLogFile("SdServer.updatePrefs() - Error " + ex.toString());
|
||||||
@@ -1316,10 +1320,10 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
/**
|
/**
|
||||||
* Use the separate OpenSeizureDetector Dialler app to generate a phone call alarm to the numbers selected for SMS Alarms.
|
* Use the separate OpenSeizureDetector Dialler app to generate a phone call alarm to the numbers selected for SMS Alarms.
|
||||||
*/
|
*/
|
||||||
Log.v(TAG,"sendPhoneAlarm() - sending broadcast intent");
|
Log.v(TAG, "sendPhoneAlarm() - sending broadcast intent");
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction("uk.org.openseizuredetector.dialler.ALARM");
|
intent.setAction("uk.org.openseizuredetector.dialler.ALARM");
|
||||||
intent.putExtra("NUMBERS",mSMSNumbers);
|
intent.putExtra("NUMBERS", mSMSNumbers);
|
||||||
sendBroadcast(intent);
|
sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1330,6 +1334,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
*/
|
*/
|
||||||
public class SmsTimer extends CountDownTimer implements SdLocationReceiver {
|
public class SmsTimer extends CountDownTimer implements SdLocationReceiver {
|
||||||
public long mTimeLeft = -1;
|
public long mTimeLeft = -1;
|
||||||
|
|
||||||
public SmsTimer(long startTime, long interval) {
|
public SmsTimer(long startTime, long interval) {
|
||||||
super(startTime, interval);
|
super(startTime, interval);
|
||||||
}
|
}
|
||||||
@@ -1353,7 +1358,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
Time tnow = new Time(Time.getCurrentTimezone());
|
Time tnow = new Time(Time.getCurrentTimezone());
|
||||||
tnow.setToNow();
|
tnow.setToNow();
|
||||||
String dateStr = tnow.format("%H:%M:%S %d/%m/%Y");
|
String dateStr = tnow.format("%H:%M:%S %d/%m/%Y");
|
||||||
String shortUuidStr = mUuidStr.substring(mUuidStr.length()-6);
|
String shortUuidStr = mUuidStr.substring(mUuidStr.length() - 6);
|
||||||
|
|
||||||
// SmsManager sm = SmsManager.getDefault();
|
// SmsManager sm = SmsManager.getDefault();
|
||||||
for (int i = 0; i < mSMSNumbers.length; i++) {
|
for (int i = 0; i < mSMSNumbers.length; i++) {
|
||||||
@@ -1426,7 +1431,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
+ ";u=" + df.format(ll.getAccuracy()) + "'>here</a>";
|
+ ";u=" + df.format(ll.getAccuracy()) + "'>here</a>";
|
||||||
String googleUrl = "https://www.google.com/maps/place?q="
|
String googleUrl = "https://www.google.com/maps/place?q="
|
||||||
+ ll.getLatitude() + "%2C" + ll.getLongitude();
|
+ ll.getLatitude() + "%2C" + ll.getLongitude();
|
||||||
String shortUuidStr = mUuidStr.substring(mUuidStr.length()-6);
|
String shortUuidStr = mUuidStr.substring(mUuidStr.length() - 6);
|
||||||
|
|
||||||
String messageStr = mSMSMsgStr + " - " +
|
String messageStr = mSMSMsgStr + " - " +
|
||||||
dateStr + " - " + googleUrl + " " + shortUuidStr;
|
dateStr + " - " + googleUrl + " " + shortUuidStr;
|
||||||
@@ -1445,14 +1450,13 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Latch alarm in alarm state for a given period (mLatchAlarmPeriod seconds) after the alarm is raised.
|
* Latch alarm in alarm state for a given period (mLatchAlarmPeriod seconds) after the alarm is raised.
|
||||||
* This is to ensure multiple Alarm annunciations even if only a single Alarm signal is received.
|
* This is to ensure multiple Alarm annunciations even if only a single Alarm signal is received.
|
||||||
*/
|
*/
|
||||||
private class LatchAlarmTimer extends CountDownTimer {
|
private class LatchAlarmTimer extends CountDownTimer {
|
||||||
public LatchAlarmTimer(long startTime, long interval) {
|
public LatchAlarmTimer(long startTime, long interval) {
|
||||||
super(startTime, interval);
|
super(startTime, interval);
|
||||||
@@ -1475,9 +1479,9 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Temporary cancel audible alarms, for the period specified by the
|
* Temporary cancel audible alarms, for the period specified by the
|
||||||
* CancelAudiblePeriod setting.
|
* CancelAudiblePeriod setting.
|
||||||
*/
|
*/
|
||||||
private class CancelAudibleTimer extends CountDownTimer {
|
private class CancelAudibleTimer extends CountDownTimer {
|
||||||
public CancelAudibleTimer(long startTime, long interval) {
|
public CancelAudibleTimer(long startTime, long interval) {
|
||||||
super(startTime, interval);
|
super(startTime, interval);
|
||||||
@@ -1562,7 +1566,6 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the events timer.
|
* Start the events timer.
|
||||||
*/
|
*/
|
||||||
@@ -1576,7 +1579,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
mEventsTimer =
|
mEventsTimer =
|
||||||
// Run every 5 minutes (convert to ms.)
|
// Run every 10 sec (convert to ms.)
|
||||||
new CheckUnvalidatedEventsTimer(10 * 1000, 1000);
|
new CheckUnvalidatedEventsTimer(10 * 1000, 1000);
|
||||||
mEventsTimer.mIsRunning = true;
|
mEventsTimer.mIsRunning = true;
|
||||||
mEventsTimer.start();
|
mEventsTimer.start();
|
||||||
@@ -1604,6 +1607,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
private class CheckUnvalidatedEventsTimer extends CountDownTimer {
|
private class CheckUnvalidatedEventsTimer extends CountDownTimer {
|
||||||
long mFirstUnvalidatedEvent;
|
long mFirstUnvalidatedEvent;
|
||||||
public boolean mIsRunning = true;
|
public boolean mIsRunning = true;
|
||||||
|
|
||||||
public CheckUnvalidatedEventsTimer(long startTime, long interval) {
|
public CheckUnvalidatedEventsTimer(long startTime, long interval) {
|
||||||
super(startTime, interval);
|
super(startTime, interval);
|
||||||
}
|
}
|
||||||
@@ -1612,7 +1616,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
Log.v(TAG, "CheckUnvalidatedEventsTimer.onFinish()");
|
Log.v(TAG, "CheckUnvalidatedEventsTimer.onFinish()");
|
||||||
// Retrieve events from remote database
|
// Retrieve events from remote database
|
||||||
mLm.mWac.getEvents((JSONObject remoteEventsObj) -> {
|
if (mLm.mWac.getEvents((JSONObject remoteEventsObj) -> {
|
||||||
Log.v(TAG, "CheckUnvalidatedEventsTimer.onFinish.getEvents.Callback()");
|
Log.v(TAG, "CheckUnvalidatedEventsTimer.onFinish.getEvents.Callback()");
|
||||||
if (remoteEventsObj == null) {
|
if (remoteEventsObj == null) {
|
||||||
Log.e(TAG, "CheckUnvalidatedEventsTimer.onFinish() Callback: Error Retrieving events");
|
Log.e(TAG, "CheckUnvalidatedEventsTimer.onFinish() Callback: Error Retrieving events");
|
||||||
@@ -1631,9 +1635,9 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
//Log.v(TAG,"CheckUnvalidatedEventsTimer:setting mFirstUnvalidatedEvent to "+mFirstUnvalidatedEvent);
|
//Log.v(TAG,"CheckUnvalidatedEventsTimer:setting mFirstUnvalidatedEvent to "+mFirstUnvalidatedEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.v(TAG,"CheckUnvalidatedEventsTimer.onFinish.callback - mFirstUnvalidatedEvent = "+
|
Log.v(TAG, "CheckUnvalidatedEventsTimer.onFinish.callback - mFirstUnvalidatedEvent = " +
|
||||||
mFirstUnvalidatedEvent);
|
mFirstUnvalidatedEvent);
|
||||||
if (mFirstUnvalidatedEvent >=0) {
|
if (mFirstUnvalidatedEvent >= 0) {
|
||||||
showEventNotification(mFirstUnvalidatedEvent);
|
showEventNotification(mFirstUnvalidatedEvent);
|
||||||
} else {
|
} else {
|
||||||
mNM.cancel(EVENT_NOTIFICATION_ID);
|
mNM.cancel(EVENT_NOTIFICATION_ID);
|
||||||
@@ -1643,14 +1647,21 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
//mUtil.showToast("Error Parsing remoteEventsObj - this should not happen!!!");
|
//mUtil.showToast("Error Parsing remoteEventsObj - this should not happen!!!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})) {
|
||||||
|
Log.v(TAG,"CheckUnvalidatedEventsTimer() - requested events");
|
||||||
|
} else {
|
||||||
|
Log.v(TAG,"CheckUnvalidatedEventsTimer() - Not Logged In");
|
||||||
|
mNM.cancel(EVENT_NOTIFICATION_ID);
|
||||||
|
}
|
||||||
if (mIsRunning) {
|
if (mIsRunning) {
|
||||||
// Restart this timer.
|
// Restart this timer.
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onTick(long msRemaining) { }
|
@Override
|
||||||
|
public void onTick(long msRemaining) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a notification to tell the user that we have unvalidated events.
|
* Show a notification to tell the user that we have unvalidated events.
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ public class WebApiConnection {
|
|||||||
mUtil = new OsdUtil(mContext, new Handler());
|
mUtil = new OsdUtil(mContext, new Handler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
Log.i(TAG,"stop()");
|
||||||
|
mQueue.stop();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to authenticate with the web API using user name uname and password passwd. Calls function callback with either
|
* Attempt to authenticate with the web API using user name uname and password passwd. Calls function callback with either
|
||||||
* the authentication token on success or null on failure.
|
* the authentication token on success or null on failure.
|
||||||
|
|||||||
Reference in New Issue
Block a user