Added FOREGROUND_SERVICE permission, which seems to be needed for Android 9 or it crashes with a 'Permission Denied' error.
This commit is contained in:
@@ -40,6 +40,7 @@ import org.json.JSONArray;
|
||||
|
||||
public class SdData implements Parcelable {
|
||||
private final static String TAG = "SdData";
|
||||
private final static int N_RAW_DATA = 500; // 5 seconds at 100 Hz.
|
||||
/* Analysis settings */
|
||||
public boolean haveSettings = false; // flag to say if we have received settings or not.
|
||||
public boolean haveData = false; // flag to say we have received data.
|
||||
@@ -67,6 +68,7 @@ public class SdData implements Parcelable {
|
||||
public boolean mHRAlarmActive = false;
|
||||
public double mHRThreshMin = 40.0;
|
||||
public double mHRTreshMax = 150.0;
|
||||
public int rawData[];
|
||||
|
||||
/* Analysis results */
|
||||
public Time dataTime = null;
|
||||
@@ -88,6 +90,7 @@ public class SdData implements Parcelable {
|
||||
|
||||
public SdData() {
|
||||
simpleSpec = new int[10];
|
||||
rawData = new int[N_RAW_DATA];
|
||||
dataTime = new Time(Time.getCurrentTimezone());
|
||||
}
|
||||
|
||||
@@ -118,6 +121,7 @@ public class SdData implements Parcelable {
|
||||
alarmPhrase = jo.optString("alarmPhrase");
|
||||
alarmThresh = jo.optInt("alarmThresh");
|
||||
alarmRatioThresh = jo.optInt("alarmRatioThresh");
|
||||
mHR = jo.optDouble("hr");
|
||||
JSONArray specArr = jo.optJSONArray("simpleSpec");
|
||||
for (int i = 0; i < specArr.length(); i++) {
|
||||
simpleSpec[i] = specArr.optInt(i);
|
||||
@@ -131,12 +135,12 @@ public class SdData implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toDataString();
|
||||
return toDataString(false);
|
||||
}
|
||||
|
||||
public String toDataString() {
|
||||
public String toDataString(boolean includeRawData) {
|
||||
String retval;
|
||||
retval = "SdData.toDataString() Output";
|
||||
try {
|
||||
@@ -166,12 +170,18 @@ public class SdData implements Parcelable {
|
||||
jsonObj.put("alarmFreqMax",alarmFreqMax);
|
||||
jsonObj.put("alarmThresh", alarmThresh);
|
||||
jsonObj.put("alarmRatioThresh", alarmRatioThresh);
|
||||
jsonObj.put("hr",mHR);
|
||||
JSONArray arr = new JSONArray();
|
||||
for (int i = 0; i < simpleSpec.length; i++) {
|
||||
arr.put(simpleSpec[i]);
|
||||
}
|
||||
|
||||
jsonObj.put("simpleSpec", arr);
|
||||
if (includeRawData) {
|
||||
JSONArray rawArr = new JSONArray();
|
||||
for (int i = 0; i< rawData.length;i++) {
|
||||
rawArr.put(rawData[i]);
|
||||
}
|
||||
}
|
||||
|
||||
retval = jsonObj.toString();
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -441,11 +441,15 @@ public class SdDataSourcePebble extends SdDataSource {
|
||||
Log.v(TAG, "numSamples = " + numSamples);
|
||||
byte[] rawDataBytes = data.getBytes(KEY_RAW_DATA);
|
||||
for (int i = 0; i < rawDataBytes.length - 4; i += 4) { // 4 bytes per sample
|
||||
int x = (rawDataBytes[i]);
|
||||
int b0 = rawDataBytes[i];
|
||||
int b1 = rawDataBytes[i+1] & 0xff;
|
||||
int b2 = rawDataBytes[i+2] & 0xff;
|
||||
int b3 = rawDataBytes[i+3] & 0xff;
|
||||
int x = (b3 | b2 << 8 | b1 << 16 | b0 << 24);
|
||||
//int y = (rawDataBytes[i+2] & 0xff) | (rawDataBytes[i+3] << 8);
|
||||
//int z = (rawDataBytes[i+4] & 0xff) | (rawDataBytes[i+5] << 8);
|
||||
//Log.v(TAG,"x="+x+", y="+y+", z="+z);
|
||||
Log.v(TAG,"x="+x);
|
||||
Log.v(TAG,"b0="+b0+", b1="+b1+", b2="+b2+", b3="+b3+", x="+x);
|
||||
if (nRawData < MAX_RAW_DATA) {
|
||||
rawData[nRawData] = (int)Math.sqrt(x);
|
||||
} else {
|
||||
|
||||
@@ -492,6 +492,7 @@ public class StartupActivity extends Activity {
|
||||
+ "\n- Added support for an experimental Gramin based seizure detector with Heart Rate alarm "
|
||||
+ "\n Fixed problem with app not restarting properly when settings were changed"
|
||||
+ "\n- Explicitly asks for SMS permission, and displays warning in notification if SMS alarms are active"
|
||||
+ "\n Added FOREGROUND_SERVICE permission, which seems to be necessary for Android V9."
|
||||
+ "\n "
|
||||
+ "\n PLEASE NOTE - THIS IS A BETA TEST VERSION SO MAY NOT WORK!"
|
||||
+ "\n ."
|
||||
@@ -528,6 +529,7 @@ public class StartupActivity extends Activity {
|
||||
+ "\n- Added support for an experimental Gramin based seizure detector with Heart Rate alarm "
|
||||
+ "\n- Fixed problem with app not restarting properly when settings were changed"
|
||||
+ "\n- Explicitly asks for SMS permission, and displays warning in notification if SMS alarms are active"
|
||||
+ "\n Added FOREGROUND_SERVICE permission, which seems to be necessary for Android V9."
|
||||
+ "\n "
|
||||
+ "\n PLEASE NOTE - THIS IS A BETA TEST VERSION SO MAY NOT WORK!"
|
||||
+ "\n "
|
||||
|
||||
Reference in New Issue
Block a user