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
|
||||
============================================
|
||||
|
||||
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.
|
||||
|
||||
V3.0.0 - 15feb2019
|
||||
|
||||
BIN
app/release/app-release-3.0.2.apk
Normal file
BIN
app/release/app-release-3.0.2.apk
Normal file
Binary file not shown.
@@ -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"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="uk.org.openseizuredetector"
|
||||
android:versionCode="50"
|
||||
android:versionName="3.0.1"
|
||||
android:versionCode="51"
|
||||
android:versionName="3.0.2"
|
||||
>
|
||||
<!--android:allowBackup="false"-->
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Timer;
|
||||
@@ -49,9 +50,18 @@ public class LocationFinder implements LocationListener
|
||||
// Acquire a reference to the system Location Manager
|
||||
mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
|
||||
// Register with the Location Manager to receive location updates using both network and GPS
|
||||
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
|
||||
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
|
||||
try {
|
||||
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.schedule(new TimerTask() {
|
||||
@Override
|
||||
|
||||
@@ -501,6 +501,15 @@ public class OsdUtil implements ActivityCompat.OnRequestPermissionsResultCallbac
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode,
|
||||
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
|
||||
public void onResume() {
|
||||
|
||||
@@ -386,27 +386,42 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
||||
Log.v(TAG, "showNotification() - alarmLevel="+alarmLevel);
|
||||
int iconId;
|
||||
String titleStr;
|
||||
Uri soundUri = null;
|
||||
switch (alarmLevel) {
|
||||
case 0:
|
||||
iconId = R.drawable.star_of_life_24x24;
|
||||
titleStr = "OK";
|
||||
soundUri = null;
|
||||
break;
|
||||
case 1:
|
||||
iconId = R.drawable.star_of_life_yellow_24x24;
|
||||
titleStr = "WARNING";
|
||||
if (mAudibleWarning)
|
||||
soundUri = Uri.parse("android.resource://" + getPackageName() + "/raw/warning");
|
||||
break;
|
||||
case 2:
|
||||
iconId = R.drawable.star_of_life_red_24x24;
|
||||
titleStr = "ALARM";
|
||||
if (mAudibleAlarm)
|
||||
soundUri = Uri.parse("android.resource://" + getPackageName() + "/raw/alarm");
|
||||
break;
|
||||
case -1:
|
||||
iconId = R.drawable.star_of_life_fault_24x24;
|
||||
titleStr = "FAULT";
|
||||
if (mAudibleFaultWarning)
|
||||
soundUri = Uri.parse("android.resource://" + getPackageName() + "/raw/fault");
|
||||
break;
|
||||
default:
|
||||
iconId = R.drawable.star_of_life_24x24;
|
||||
soundUri = null;
|
||||
titleStr = "OK";
|
||||
}
|
||||
|
||||
if (mCancelAudible) {
|
||||
Log.v(TAG,"ShowNotification - Not beeping because mCancelAudible set");
|
||||
soundUri = null;
|
||||
}
|
||||
|
||||
Intent i = new Intent(getApplicationContext(), MainActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
PendingIntent contentIntent =
|
||||
@@ -427,7 +442,12 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
||||
.setContentText(smsStr)
|
||||
.setOnlyAlertOnce(true)
|
||||
.build();
|
||||
|
||||
if (mMp3Alarm) {
|
||||
if (soundUri != null) {
|
||||
Log.v(TAG, "showNotification - setting Notification Sound to "+soundUri.toString());
|
||||
mNotificationBuilder.setSound(soundUri);
|
||||
}
|
||||
}
|
||||
mNM.notify(NOTIFICATION_ID, mNotification);
|
||||
} else {
|
||||
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 {
|
||||
if (mAudibleFaultWarning) {
|
||||
if (mMp3Alarm) {
|
||||
Log.v(TAG, "making MP3 alarm beep");
|
||||
// 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());
|
||||
Log.v(TAG, "Not making MP3 fault beep - handled by notification");
|
||||
} else {
|
||||
beep(10);
|
||||
}
|
||||
@@ -675,16 +686,7 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
||||
} else {
|
||||
if (mAudibleAlarm) {
|
||||
if (mMp3Alarm) {
|
||||
Log.v(TAG, "making MP3 alarm beep");
|
||||
// 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());
|
||||
Log.v(TAG, "Not making MP3 alarm beep - handled by ShowNotification");
|
||||
} else {
|
||||
beep(3000);
|
||||
}
|
||||
@@ -705,16 +707,7 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
||||
} else {
|
||||
if (mAudibleWarning) {
|
||||
if (mMp3Alarm) {
|
||||
Log.v(TAG, "making MP3 alarm beep");
|
||||
// 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());
|
||||
Log.v(TAG, "not making MP3 alarm beep - handled by showNotification");
|
||||
} else {
|
||||
beep(100);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user