Merge branch '206-add-send-false-alarm-alert-function' into beta

This commit is contained in:
Graham Jones
2025-02-09 19:31:08 +00:00
7 changed files with 71 additions and 3 deletions

View File

@@ -3,7 +3,9 @@
V4.2.11 - Updated permissions handling to support Android 14 (needed to publish on Play Store)
- added a crude 'flap' detector into OSD Algorithm
- Added setting to change the delay before SMS alert is sent (Issue #202)
- Reduced the frequency of checking if we have unvalided events on the data sharing server to reduce data usage.
- Added 'Send False Alarm notification Menu Option (Issue #206)'
- Reduced the frequency of checking if we have unvalided events on the data sharing server to reduce data usage (Issue #201).
- Improvements to Data Sharing Screen (Issue #199)
V4.2.10 - fixed (infrequent) crash when opening data sharing page (#195), and crash if log manager fails to start (#196)
V4.2.9 - fixed crash when using Polish translation.
V4.2.8 -

View File

@@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="149"
android:versionName="4.2.11d">
android:versionName="4.2.11e">
<!-- android:allowBackup="false" -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

View File

@@ -237,6 +237,12 @@ public class MainActivity2 extends AppCompatActivity {
mConnection.mSdServer.sendSMSAlarm();
}
return true;
case R.id.action_send_false_alarm_sms:
Log.i(TAG, "action_send_false_alarm_sms");
if (mConnection.mBound) {
mConnection.mSdServer.sendFalseAlarmSMS();
}
return true;
case R.id.action_authenticate_api:
Log.i(TAG, "action_autheticate_api");

View File

@@ -127,6 +127,7 @@ public class SdServer extends Service implements SdDataReceiver {
private boolean mSMSAlarm = false;
private String[] mSMSNumbers;
private String mSMSMsgStr = "default SMS Message";
private String mSMSFalseAlarmMsgStr = "default SMS False Alarm Message";
public Time mSMSTime = null; // last time we sent an SMS Alarm (limited to one per minute)
public SmsTimer mSmsTimer = null; // Timer to wait for specified time before sending an alert to give the user chance to cancel it.
public int mSmsTimerSecs = 10; // Time delay in seconds before sending SMS alert.
@@ -961,6 +962,48 @@ public class SdServer extends Service implements SdDataReceiver {
}
}
/**
* Sends SMS Alarms to the telephone numbers specified in mSMSNumbers[]
* Attempts to find a better location, and sends a second SMS after location search
* complete (onLocationReceived()).
*/
public void sendFalseAlarmSMS() {
AlertDialog ad;
if (mSMSAlarm) {
if (!mCancelAudible) {
Log.i(TAG, "sendFalseAlarmsSMS() - Sending to " + mSMSNumbers.length + " Numbers");
mUtil.writeToSysLogFile("SdServer.sendFalseAlarmsSMS()");
Time tnow = new Time(Time.getCurrentTimezone());
tnow.setToNow();
String dateStr = tnow.format("%H:%M:%S %d/%m/%Y");
String shortUuidStr = mUuidStr.substring(mUuidStr.length() - 6);
// SmsManager sm = SmsManager.getDefault();
for (int i = 0; i < mSMSNumbers.length; i++) {
Log.i(TAG, "sendFalseAlarmsSMS() - Sending to " + mSMSNumbers[i]);
//sendSMS(new String(mSMSNumbers[i]), mSMSFalseAlarmMsgStr + " - " + dateStr + " " + shortUuidStr);
try {
SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage(mSMSNumbers[i], null, mSMSFalseAlarmMsgStr + " - " + dateStr + " " + shortUuidStr,
null, null);
} catch (Exception e) {
Log.e(TAG, "sendFalseAlarmsSMS - Failed to send SMS Message");
mUtil.showToast(getString(R.string.failed_to_send_sms));
}
}
} else {
Log.i(TAG, "sendFalseAlarmSMS() - Cancel Audible Active - not sending SMS");
mUtil.showToast(getString(R.string.cancel_audible_not_sending_sms));
}
} else {
Log.i(TAG, "sendFalseAlarmSMS() - SMS Alarms Disabled - not doing anything!");
mUtil.showToast(getString(R.string.sms_alarms_disabled));
}
}
/**
* smsCanelClickListener - onClickListener for the SMS cancel dialog box. If the
@@ -1264,11 +1307,14 @@ public class SdServer extends Service implements SdDataReceiver {
mUtil.writeToSysLogFile("updatePrefs() - mSMSAlarm = " + mSMSAlarm);
String SMSNumberStr = SP.getString("SMSNumbers", "");
mSMSNumbers = SMSNumberStr.split(",");
mSMSMsgStr = SP.getString("SMSMsg", "Seizure Detected!!!");
Log.v(TAG, "updatePrefs() - SMSNumberStr = " + SMSNumberStr);
mUtil.writeToSysLogFile("updatePrefs() - SMSNumberStr = " + SMSNumberStr);
Log.v(TAG, "updatePrefs() - mSMSNumbers = " + mSMSNumbers);
mUtil.writeToSysLogFile("updatePrefs() - mSMSNumbers = " + mSMSNumbers);
mSMSMsgStr = SP.getString("SMSMsg", "Seizure Detected!!!");
Log.v(TAG, "updatePrefs() - SMSMsgStr = " + mSMSMsgStr);
mSMSFalseAlarmMsgStr = SP.getString("SMSFalseAlarmMsg", "False Alarm, Sorry!");
Log.v(TAG, "updatePrefs() - SMSFalseAlarmMsgStr = " + mSMSFalseAlarmMsgStr);
String smsDelayPeriodStr = SP.getString("SMSDelayPeriod","10");
mSmsTimerSecs = Integer.parseInt(smsDelayPeriodStr);

View File

@@ -73,6 +73,11 @@
android:icon="@drawable/stop_server"
app:showAsAction="never|withText"
android:title="@string/test_sms_alarm_notification" />
<item
android:id="@+id/action_send_false_alarm_sms"
android:icon="@drawable/stop_server"
app:showAsAction="never|withText"
android:title="@string/send_false_alarm_sms_menu_text" />
</group>
<group android:id="@+id/grp5">
<!--<item

View File

@@ -583,4 +583,8 @@
<string name="activity_permissions_rationale">Permission required to analyse your movements to detect seizure activity.</string>
<string name="sms_delay_sec">SMS Delay (sec)</string>
<string name="sms_delay_sec_desc">The number of seconds to delay between an alarm initiating and an SMS message being sent (default=10)</string>
<string name="send_false_alarm_sms_menu_text">Send False Alarm SMS</string>
<string name="DefaultSMSFalseAlarmMsgText">False Alarm, Sorry!</string>
<string name="sms_false_alarm_message_summary">Text of \'False Alarm\' SMS message</string>
<string name="sms_false_alarm_message_title">SMS False Alarm Message</string>
</resources>

View File

@@ -66,6 +66,11 @@
android:key="SMSMsg"
android:summary="@string/sms_message_summary"
android:title="@string/sms_message_title" />
<EditTextPreference
android:defaultValue="@string/DefaultSMSFalseAlarmMsgText"
android:key="SMSFalseAlarmMsg"
android:summary="@string/sms_false_alarm_message_summary"
android:title="@string/sms_false_alarm_message_title" />
</PreferenceCategory>
<!--
<PreferenceCategory android:title="Phone Call Alarm Settings">