First go at generating broadcasts to request openseizuredetector Dialler to generate phone call alerts.
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="71"
|
||||
android:versionName="3.2.1">
|
||||
android:versionCode="72"
|
||||
android:versionName="3.5.0">
|
||||
<!-- android:allowBackup="false" -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
|
||||
@@ -238,6 +238,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
mConnection.mSdServer.sendSMSAlarm();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_test_phone_alarm:
|
||||
Log.i(TAG, "action_test_phone_alarm");
|
||||
if (mConnection.mBound) {
|
||||
mConnection.mSdServer.sendPhoneAlarm();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_export:
|
||||
Log.i(TAG, "action_export");
|
||||
try {
|
||||
|
||||
@@ -442,7 +442,7 @@ public class OsdUtil implements ActivityCompat.OnRequestPermissionsResultCallbac
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isPackageInstalled(String packagename) {
|
||||
public boolean isPackageInstalled(String packagename) {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
try {
|
||||
pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
|
||||
|
||||
@@ -115,6 +115,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
private boolean mAudibleWarning = false;
|
||||
private boolean mAudibleFaultWarning = false;
|
||||
private boolean mMp3Alarm = false;
|
||||
private boolean mPhoneAlarm = false;
|
||||
private boolean mSMSAlarm = false;
|
||||
private String[] mSMSNumbers;
|
||||
private String mSMSMsgStr = "default SMS Message";
|
||||
@@ -457,6 +458,9 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
} else {
|
||||
smsStr = getString(R.string.sms_location_alarm_disabled);
|
||||
}
|
||||
if (mPhoneAlarm) {
|
||||
smsStr = "Phone Call Alarm Active";
|
||||
}
|
||||
if (mNotificationBuilder != null) {
|
||||
mNotification = mNotificationBuilder.setContentIntent(contentIntent)
|
||||
.setSmallIcon(iconId)
|
||||
@@ -565,6 +569,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
- mSMSTime.toMillis(false))
|
||||
> 60000) {
|
||||
sendSMSAlarm();
|
||||
sendPhoneAlarm();
|
||||
mSMSTime = tnow;
|
||||
} else {
|
||||
mUtil.showToast("SMS Alarm already sent - not re-sending");
|
||||
@@ -794,6 +799,18 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
Log.i(TAG, "sendSMSAlarm() - SMS Alarms Disabled - not doing anything!");
|
||||
mUtil.showToast(getString(R.string.sms_alarm_disabled));
|
||||
}
|
||||
if (mPhoneAlarm) {
|
||||
if (!mCancelAudible) {
|
||||
Log.i(TAG, "sendSMSAlarm() - Sending Phone Alarm Broadcast");
|
||||
sendPhoneAlarm();
|
||||
} else {
|
||||
Log.i(TAG, "sendSMSAlarm() - Cancel Audible Active - not making Phone Call");
|
||||
mUtil.showToast(getString(R.string.cancel_audible_not_sending_sms));
|
||||
}
|
||||
} else {
|
||||
Log.i(TAG, "sendSMSAlarm() - Phone Alarms Disabled - not doing anything!");
|
||||
mUtil.showToast(getString(R.string.phone_alarm_disabled));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1068,6 +1085,8 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
|
||||
mSMSAlarm = SP.getBoolean("SMSAlarm", false);
|
||||
Log.v(TAG, "updatePrefs() - mSMSAlarm = " + mSMSAlarm);
|
||||
mPhoneAlarm = SP.getBoolean("PhoneCallAlarm", false);
|
||||
Log.v(TAG, "updatePrefs() - mSMSAlarm = " + mSMSAlarm);
|
||||
String SMSNumberStr = SP.getString("SMSNumbers", "");
|
||||
mSMSNumbers = SMSNumberStr.split(",");
|
||||
mSMSMsgStr = SP.getString("SMSMsg", "Seizure Detected!!!");
|
||||
@@ -1153,7 +1172,16 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void sendPhoneAlarm() {
|
||||
/**
|
||||
* 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");
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("uk.org.openseizuredetector.dialler.ALARM");
|
||||
intent.putExtra("NUMBERS",mSMSNumbers);
|
||||
sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -37,6 +37,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannedString;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -225,11 +226,13 @@ public class StartupActivity extends Activity {
|
||||
TextView tv;
|
||||
ProgressBar pb;
|
||||
boolean smsAlarmsActive = true;
|
||||
boolean phoneAlarmsActive = true;
|
||||
|
||||
Log.v(TAG,"serverStatusRunnable()");
|
||||
SharedPreferences SP = PreferenceManager
|
||||
.getDefaultSharedPreferences(getBaseContext());
|
||||
smsAlarmsActive = SP.getBoolean("SMSAlarm", false);
|
||||
phoneAlarmsActive = SP.getBoolean("PhoneCallAlarm", false);
|
||||
|
||||
// Settings ok
|
||||
tv = (TextView) findViewById(R.id.textItem1);
|
||||
@@ -258,6 +261,16 @@ public class StartupActivity extends Activity {
|
||||
mUtil.requestPermissions(StartupActivity.this);
|
||||
}
|
||||
|
||||
// If phone alarms are selected, we need to have the uk.org.openseizuredetector.dialler package installed to do the actual dialling.
|
||||
if (phoneAlarmsActive && !mUtil.isPackageInstalled("uk.org.openseizuredetector.dialler")) {
|
||||
tv.setText(getText(R.string.DiallerNotInstalledWarning));
|
||||
tv.setBackgroundColor(alarmColour);
|
||||
tv.setTextColor(alarmTextColour);
|
||||
pb.setIndeterminateDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
pb.setProgressDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
// Are we Bound to the Service
|
||||
tv = (TextView) findViewById(R.id.textItem2);
|
||||
pb = (ProgressBar) findViewById(R.id.progressBar2);
|
||||
|
||||
@@ -46,6 +46,12 @@
|
||||
android:showAsAction="never|withText"
|
||||
android:title="@string/test_sms_alarm_notification" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_test_phone_alarm"
|
||||
android:icon="@drawable/stop_server"
|
||||
android:showAsAction="never|withText"
|
||||
android:title="@string/test_phone_alarm_notification" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_logmanager"
|
||||
android:icon="@drawable/ic_action_settings"
|
||||
|
||||
@@ -139,5 +139,8 @@
|
||||
<string name="send_sms_last_location">Send SMS - last location is </string>
|
||||
<string name="failed_to_send_sms">ERROR: FAILED TO SEND SMS MESSAGE</string>
|
||||
<string name="sms_alarms_disabled">SMS Alarms Disabled - not doing anything!</string>
|
||||
<string name="phone_alarm_disabled">Phone Alarm Disabled</string>
|
||||
<string name="test_phone_alarm_notification">Test Phone Alarm</string>
|
||||
<string name="DiallerNotInstalledWarning"><a href="https://github.com/OpenSeizureDetector/Dialler/tree/master/app/release/app-release.apk">OpenSeizureDetector Dialer App</a> Not installed - Required for Phone Call Alerts.</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -62,6 +62,14 @@
|
||||
android:title="SMS Message" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="Phone Call Alarm Settings">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="PhoneCallAlarm"
|
||||
android:summary="Dial the Carer(s) phone number(s) as well as sending SMS alerts. It requests an external application (OpenSeizureDetector Dialler) to make the phone calls to the same numbers as are set for SMS alerts above"
|
||||
android:title="Enable Phone Call Alarm" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="Alarm Logging">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
|
||||
Reference in New Issue
Block a user