V3.0.2 - Fixed problem with incorrect re-start when first accepting SMS permissions.
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
OpenSeizureDetector Android App - Change Log
|
OpenSeizureDetector Android App - Change Log
|
||||||
============================================
|
============================================
|
||||||
|
|
||||||
V3.0.1 - 21feb201
|
V3.0.2 - 27feb2019
|
||||||
|
- Corrected issue with app not re-starting properly when run-time permissions changed
|
||||||
|
(e.g. send_sms permission)
|
||||||
|
- Fixed crash when using MP3 alarms (issue with new android notification system)
|
||||||
|
V3.0.1 - 21feb2019
|
||||||
- Simplified data log output to CSV format for easier processing, and had it log every update rather than one point per minute.
|
- Simplified data log output to CSV format for easier processing, and had it log every update rather than one point per minute.
|
||||||
|
|
||||||
V3.0.0 - 15feb2019
|
V3.0.0 - 15feb2019
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":50,"versionName":"3.0.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":51,"versionName":"3.0.2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="uk.org.openseizuredetector"
|
package="uk.org.openseizuredetector"
|
||||||
android:versionCode="50"
|
android:versionCode="51"
|
||||||
android:versionName="3.0.1"
|
android:versionName="3.0.2"
|
||||||
>
|
>
|
||||||
<!--android:allowBackup="false"-->
|
<!--android:allowBackup="false"-->
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.location.LocationListener;
|
|||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
@@ -49,9 +50,18 @@ public class LocationFinder implements LocationListener
|
|||||||
// Acquire a reference to the system Location Manager
|
// Acquire a reference to the system Location Manager
|
||||||
mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
|
mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
|
||||||
// Register with the Location Manager to receive location updates using both network and GPS
|
// Register with the Location Manager to receive location updates using both network and GPS
|
||||||
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
|
try {
|
||||||
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
|
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
||||||
|
0, 0, this, Looper.getMainLooper());
|
||||||
|
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
|
||||||
|
0, 0, this, Looper.getMainLooper());
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.e(TAG, "LocationFinder - Failed to get Location - Security Exception");
|
||||||
|
mUtil.writeToSysLogFile("LocationFinder - Failed to get Location - Security Exception");
|
||||||
|
Log.e(TAG, e.toString());
|
||||||
|
mUtil.showToast("Failed to get Location for SMS Message - Permissions Denied?");
|
||||||
|
|
||||||
|
}
|
||||||
mTimeoutTimer = new Timer();
|
mTimeoutTimer = new Timer();
|
||||||
mTimeoutTimer.schedule(new TimerTask() {
|
mTimeoutTimer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -501,6 +501,15 @@ public class OsdUtil implements ActivityCompat.OnRequestPermissionsResultCallbac
|
|||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode,
|
public void onRequestPermissionsResult(int requestCode,
|
||||||
String permissions[], int[] grantResults) {
|
String permissions[], int[] grantResults) {
|
||||||
Log.i(TAG,"onequestPermissionsResult - Permission" + permissions + " = " + grantResults);
|
Log.i(TAG,"onRequestPermissionsResult - Permission" + permissions + " = " + grantResults);
|
||||||
|
showToast("Permissions Changed - restarting server");
|
||||||
|
stopServer();
|
||||||
|
// Wait 0.1 second to give the server chance to shutdown, then re-start it
|
||||||
|
mHandler.postDelayed(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
startServer();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,20 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode,
|
||||||
|
String permissions[], int[] grantResults) {
|
||||||
|
Log.i(TAG,"onRequestPermissionsResult - Permission" + permissions + " = " + grantResults);
|
||||||
|
mUtil.showToast("Permissions Changed - restarting server");
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
|
|||||||
@@ -386,27 +386,42 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
Log.v(TAG, "showNotification() - alarmLevel="+alarmLevel);
|
Log.v(TAG, "showNotification() - alarmLevel="+alarmLevel);
|
||||||
int iconId;
|
int iconId;
|
||||||
String titleStr;
|
String titleStr;
|
||||||
|
Uri soundUri = null;
|
||||||
switch (alarmLevel) {
|
switch (alarmLevel) {
|
||||||
case 0:
|
case 0:
|
||||||
iconId = R.drawable.star_of_life_24x24;
|
iconId = R.drawable.star_of_life_24x24;
|
||||||
titleStr = "OK";
|
titleStr = "OK";
|
||||||
|
soundUri = null;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
iconId = R.drawable.star_of_life_yellow_24x24;
|
iconId = R.drawable.star_of_life_yellow_24x24;
|
||||||
titleStr = "WARNING";
|
titleStr = "WARNING";
|
||||||
|
if (mAudibleWarning)
|
||||||
|
soundUri = Uri.parse("android.resource://" + getPackageName() + "/raw/warning");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
iconId = R.drawable.star_of_life_red_24x24;
|
iconId = R.drawable.star_of_life_red_24x24;
|
||||||
titleStr = "ALARM";
|
titleStr = "ALARM";
|
||||||
|
if (mAudibleAlarm)
|
||||||
|
soundUri = Uri.parse("android.resource://" + getPackageName() + "/raw/alarm");
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
iconId = R.drawable.star_of_life_fault_24x24;
|
iconId = R.drawable.star_of_life_fault_24x24;
|
||||||
titleStr = "FAULT";
|
titleStr = "FAULT";
|
||||||
|
if (mAudibleFaultWarning)
|
||||||
|
soundUri = Uri.parse("android.resource://" + getPackageName() + "/raw/fault");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
iconId = R.drawable.star_of_life_24x24;
|
iconId = R.drawable.star_of_life_24x24;
|
||||||
|
soundUri = null;
|
||||||
titleStr = "OK";
|
titleStr = "OK";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mCancelAudible) {
|
||||||
|
Log.v(TAG,"ShowNotification - Not beeping because mCancelAudible set");
|
||||||
|
soundUri = null;
|
||||||
|
}
|
||||||
|
|
||||||
Intent i = new Intent(getApplicationContext(), MainActivity.class);
|
Intent i = new Intent(getApplicationContext(), MainActivity.class);
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
PendingIntent contentIntent =
|
PendingIntent contentIntent =
|
||||||
@@ -427,7 +442,12 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
.setContentText(smsStr)
|
.setContentText(smsStr)
|
||||||
.setOnlyAlertOnce(true)
|
.setOnlyAlertOnce(true)
|
||||||
.build();
|
.build();
|
||||||
|
if (mMp3Alarm) {
|
||||||
|
if (soundUri != null) {
|
||||||
|
Log.v(TAG, "showNotification - setting Notification Sound to "+soundUri.toString());
|
||||||
|
mNotificationBuilder.setSound(soundUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
mNM.notify(NOTIFICATION_ID, mNotification);
|
mNM.notify(NOTIFICATION_ID, mNotification);
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "showNotification() - notification builder is null, so not showing notification.");
|
Log.i(TAG, "showNotification() - notification builder is null, so not showing notification.");
|
||||||
@@ -638,16 +658,7 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
} else {
|
} else {
|
||||||
if (mAudibleFaultWarning) {
|
if (mAudibleFaultWarning) {
|
||||||
if (mMp3Alarm) {
|
if (mMp3Alarm) {
|
||||||
Log.v(TAG, "making MP3 alarm beep");
|
Log.v(TAG, "Not making MP3 fault beep - handled by notification");
|
||||||
// From https://stackoverflow.com/questions/4441334/how-to-play-an-android-notification-sound
|
|
||||||
// This plays an audio file as a notification, using the notification sound channel.
|
|
||||||
NotificationManager notificationManager =
|
|
||||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
Uri soundUri = Uri.parse("android.resource://" + getPackageName() + "/raw/fault");
|
|
||||||
NotificationCompat.Builder mBuilder =
|
|
||||||
new NotificationCompat.Builder(getApplicationContext())
|
|
||||||
.setSound(soundUri); //This sets the sound to play
|
|
||||||
notificationManager.notify(0, mBuilder.build());
|
|
||||||
} else {
|
} else {
|
||||||
beep(10);
|
beep(10);
|
||||||
}
|
}
|
||||||
@@ -675,16 +686,7 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
} else {
|
} else {
|
||||||
if (mAudibleAlarm) {
|
if (mAudibleAlarm) {
|
||||||
if (mMp3Alarm) {
|
if (mMp3Alarm) {
|
||||||
Log.v(TAG, "making MP3 alarm beep");
|
Log.v(TAG, "Not making MP3 alarm beep - handled by ShowNotification");
|
||||||
// From https://stackoverflow.com/questions/4441334/how-to-play-an-android-notification-sound
|
|
||||||
// This plays an audio file as a notification, using the notification sound channel.
|
|
||||||
NotificationManager notificationManager =
|
|
||||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
Uri soundUri = Uri.parse("android.resource://" + getPackageName() + "/raw/alarm");
|
|
||||||
NotificationCompat.Builder mBuilder =
|
|
||||||
new NotificationCompat.Builder(getApplicationContext())
|
|
||||||
.setSound(soundUri); //This sets the sound to play
|
|
||||||
notificationManager.notify(0, mBuilder.build());
|
|
||||||
} else {
|
} else {
|
||||||
beep(3000);
|
beep(3000);
|
||||||
}
|
}
|
||||||
@@ -705,16 +707,7 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
} else {
|
} else {
|
||||||
if (mAudibleWarning) {
|
if (mAudibleWarning) {
|
||||||
if (mMp3Alarm) {
|
if (mMp3Alarm) {
|
||||||
Log.v(TAG, "making MP3 alarm beep");
|
Log.v(TAG, "not making MP3 alarm beep - handled by showNotification");
|
||||||
// From https://stackoverflow.com/questions/4441334/how-to-play-an-android-notification-sound
|
|
||||||
// This plays an audio file as a notification, using the notification sound channel.
|
|
||||||
NotificationManager notificationManager =
|
|
||||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
Uri soundUri = Uri.parse("android.resource://" + getPackageName() + "/raw/warning");
|
|
||||||
NotificationCompat.Builder mBuilder =
|
|
||||||
new NotificationCompat.Builder(getApplicationContext())
|
|
||||||
.setSound(soundUri); //This sets the sound to play
|
|
||||||
notificationManager.notify(0, mBuilder.build());
|
|
||||||
} else {
|
} else {
|
||||||
beep(100);
|
beep(100);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user