Applied Android Studio code formatting to all java files

This commit is contained in:
Graham Jones
2024-01-19 20:53:18 +00:00
parent d8b3582291
commit cfe612933f
40 changed files with 497 additions and 514 deletions

View File

@@ -66,8 +66,8 @@ public class AuthenticateActivity extends AppCompatActivity {
logoutBtn.setOnClickListener(onLogout); logoutBtn.setOnClickListener(onLogout);
// Components required only for osdapi backend // Components required only for osdapi backend
if (LogManager.USE_FIREBASE_BACKEND) { } if (LogManager.USE_FIREBASE_BACKEND) {
else { } else {
mConnection = new SdServiceConnection(getApplicationContext()); mConnection = new SdServiceConnection(getApplicationContext());
Button registerBtn = (Button) findViewById(R.id.RegisterBtn); Button registerBtn = (Button) findViewById(R.id.RegisterBtn);
@@ -84,7 +84,7 @@ public class AuthenticateActivity extends AppCompatActivity {
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Log.v(TAG,"aboutDataSharingBtn.onClick()"); Log.v(TAG, "aboutDataSharingBtn.onClick()");
String url = OsdUtil.DATA_SHARING_URL; String url = OsdUtil.DATA_SHARING_URL;
Intent i = new Intent(Intent.ACTION_VIEW); Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url)); i.setData(Uri.parse(url));
@@ -97,7 +97,7 @@ public class AuthenticateActivity extends AppCompatActivity {
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Log.v(TAG,"privacyPolicyBtn.onClick()"); Log.v(TAG, "privacyPolicyBtn.onClick()");
String url = OsdUtil.PRIVACY_POLICY_URL; String url = OsdUtil.PRIVACY_POLICY_URL;
Intent i = new Intent(Intent.ACTION_VIEW); Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url)); i.setData(Uri.parse(url));
@@ -150,14 +150,13 @@ public class AuthenticateActivity extends AppCompatActivity {
} }
private void initialiseServiceConnection() { private void initialiseServiceConnection() {
Log.v(TAG,"initialiseServiceConnection()"); Log.v(TAG, "initialiseServiceConnection()");
mLm = mConnection.mSdServer.mLm; mLm = mConnection.mSdServer.mLm;
mWac = mConnection.mSdServer.mLm.mWac; mWac = mConnection.mSdServer.mLm.mWac;
updateUi(); updateUi();
} }
// Called after the Firebase Auth UI has completed // Called after the Firebase Auth UI has completed
private ActivityResultLauncher<Intent> signInLauncher = registerForActivityResult( private ActivityResultLauncher<Intent> signInLauncher = registerForActivityResult(
new FirebaseAuthUIActivityResultContract(), new FirebaseAuthUIActivityResultContract(),
@@ -170,13 +169,13 @@ public class AuthenticateActivity extends AppCompatActivity {
private void updateUi() { private void updateUi() {
Log.v(TAG,"updateUi()"); Log.v(TAG, "updateUi()");
LinearLayout loginLl = (LinearLayout) findViewById(R.id.login_ui); LinearLayout loginLl = (LinearLayout) findViewById(R.id.login_ui);
LinearLayout osdApiLoginLl = (LinearLayout) findViewById(R.id.login_osdapi_ui); LinearLayout osdApiLoginLl = (LinearLayout) findViewById(R.id.login_osdapi_ui);
LinearLayout logoutLl = (LinearLayout) findViewById(R.id.logout_ui); LinearLayout logoutLl = (LinearLayout) findViewById(R.id.logout_ui);
if (mWac == null) { if (mWac == null) {
Log.i(TAG,"mWac is null - not updating UI"); Log.i(TAG, "mWac is null - not updating UI");
return; return;
} }
@@ -204,7 +203,7 @@ public class AuthenticateActivity extends AppCompatActivity {
} }
}); });
} else { } else {
Log.v(TAG,"updateUi() - not logged in.."); Log.v(TAG, "updateUi() - not logged in..");
loginLl.setVisibility(View.VISIBLE); loginLl.setVisibility(View.VISIBLE);
logoutLl.setVisibility(View.GONE); logoutLl.setVisibility(View.GONE);
if (!LogManager.USE_FIREBASE_BACKEND) { if (!LogManager.USE_FIREBASE_BACKEND) {
@@ -252,19 +251,19 @@ public class AuthenticateActivity extends AppCompatActivity {
// FIXME - make this work with Google Authentication like we do for Firebase. // FIXME - make this work with Google Authentication like we do for Firebase.
String uname = mUnameEt.getText().toString(); String uname = mUnameEt.getText().toString();
String passwd = mPasswdEt.getText().toString(); String passwd = mPasswdEt.getText().toString();
Log.v(TAG,"onOK() - uname="+uname+", passwd="+passwd); Log.v(TAG, "onOK() - uname=" + uname + ", passwd=" + passwd);
mWac.authenticate(uname, passwd, new WebApiConnection.StringCallback() { mWac.authenticate(uname, passwd, new WebApiConnection.StringCallback() {
@Override @Override
public void accept(String retVal) { public void accept(String retVal) {
if (retVal != null) { if (retVal != null) {
Log.d(TAG,"Authentication Success - token is "+retVal); Log.d(TAG, "Authentication Success - token is " + retVal);
mUtil.showToast("Login Successful"); mUtil.showToast("Login Successful");
saveAuthToken(retVal); saveAuthToken(retVal);
updateUi(); updateUi();
} else { } else {
Log.e(TAG,"onOk: Authentication failure for "+uname+", "+passwd); Log.e(TAG, "onOk: Authentication failure for " + uname + ", " + passwd);
mUtil.showToast("ERROR: Authentication Failed - Please Try Again"); mUtil.showToast("ERROR: Authentication Failed - Please Try Again");
mUtil.writeToSysLogFile("AuthActivity - Authorisation failed for "+uname+", "+passwd); mUtil.writeToSysLogFile("AuthActivity - Authorisation failed for " + uname + ", " + passwd);
} }
} }
}); });
@@ -273,29 +272,29 @@ public class AuthenticateActivity extends AppCompatActivity {
}; };
View.OnClickListener onLogout = new View.OnClickListener() { View.OnClickListener onLogout = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Log.v(TAG, "onLogout"); Log.v(TAG, "onLogout");
if (LogManager.USE_FIREBASE_BACKEND) { if (LogManager.USE_FIREBASE_BACKEND) {
AuthUI.getInstance() AuthUI.getInstance()
.signOut(getApplicationContext()) .signOut(getApplicationContext())
.addOnCompleteListener(new OnCompleteListener<Void>() { .addOnCompleteListener(new OnCompleteListener<Void>() {
public void onComplete(@NonNull Task<Void> task) { public void onComplete(@NonNull Task<Void> task) {
// user is now signed out // user is now signed out
updateUi(); updateUi();
} }
}); });
} else {
if (mWac != null) {
mWac.logout();
saveAuthToken(null);
} else { } else {
if (mWac != null) { Log.e(TAG, "logout() - mWac is null - not doing anything");
mWac.logout();
saveAuthToken(null);
} else {
Log.e(TAG,"logout() - mWac is null - not doing anything");
}
} }
updateUi();
} }
}; updateUi();
}
};
View.OnClickListener onRegister = View.OnClickListener onRegister =
new View.OnClickListener() { new View.OnClickListener() {

View File

@@ -292,7 +292,7 @@ public class BLEScanActivity extends ListActivity {
try { try {
mBluetoothLeScanner.startScan(mLeScanCallback); mBluetoothLeScanner.startScan(mLeScanCallback);
} catch (SecurityException e) { } catch (SecurityException e) {
Log.e(TAG,"startScan - SecurityException while starting scan"); Log.e(TAG, "startScan - SecurityException while starting scan");
Toast toast = Toast.makeText(this, "ERROR Starting Scan - Security Exception", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(this, "ERROR Starting Scan - Security Exception", Toast.LENGTH_SHORT);
toast.show(); toast.show();
@@ -304,7 +304,7 @@ public class BLEScanActivity extends ListActivity {
try { try {
mBluetoothLeScanner.stopScan(mLeScanCallback); mBluetoothLeScanner.stopScan(mLeScanCallback);
} catch (SecurityException e) { } catch (SecurityException e) {
Log.e(TAG,"stopScan - SecurityException while stopping scan"); Log.e(TAG, "stopScan - SecurityException while stopping scan");
Toast toast = Toast.makeText(this, "ERROR Stopping Scan - Security Exception", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(this, "ERROR Stopping Scan - Security Exception", Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
@@ -360,7 +360,7 @@ public class BLEScanActivity extends ListActivity {
try { try {
Log.v(TAG, "addDevice - " + device.getName()); Log.v(TAG, "addDevice - " + device.getName());
} catch (SecurityException e) { } catch (SecurityException e) {
Log.e(TAG,"addDevice() - security exception getting device name"); Log.e(TAG, "addDevice() - security exception getting device name");
} }
mLeDevices.add(device); mLeDevices.add(device);
} }
@@ -425,7 +425,7 @@ public class BLEScanActivity extends ListActivity {
try { try {
Log.v(TAG, "ScanCallback - " + result.getDevice().getName()); Log.v(TAG, "ScanCallback - " + result.getDevice().getName());
} catch (SecurityException e) { } catch (SecurityException e) {
Log.e(TAG,"ScanCallback - security exception getting device name"); Log.e(TAG, "ScanCallback - security exception getting device name");
} }
mLeDeviceListAdapter.addDevice(result.getDevice()); mLeDeviceListAdapter.addDevice(result.getDevice());
mLeDeviceListAdapter.notifyDataSetChanged(); mLeDeviceListAdapter.notifyDataSetChanged();

View File

@@ -46,8 +46,8 @@ public class BootBroadcastReceiver extends BroadcastReceiver {
Log.v(TAG, "onReceive()"); Log.v(TAG, "onReceive()");
SharedPreferences SP = PreferenceManager SharedPreferences SP = PreferenceManager
.getDefaultSharedPreferences(context); .getDefaultSharedPreferences(context);
boolean autoStart = SP.getBoolean("AutoStart",false); boolean autoStart = SP.getBoolean("AutoStart", false);
Log.v(TAG,"onReceive() - autoStart = "+autoStart); Log.v(TAG, "onReceive() - autoStart = " + autoStart);
if (autoStart && Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (autoStart && Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent startUpIntent = new Intent(context, StartupActivity.class); Intent startUpIntent = new Intent(context, StartupActivity.class);
startUpIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startUpIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

View File

@@ -6,9 +6,9 @@ import java.util.ArrayList;
public class CircBuf { public class CircBuf {
/* /*
* A circular buffer used to calculate rolling averages * A circular buffer used to calculate rolling averages
* Based loosely on https://gist.github.com/hardik-vala/dc2d19fa7c5108536fbbff96b4fcf105 * Based loosely on https://gist.github.com/hardik-vala/dc2d19fa7c5108536fbbff96b4fcf105
*/ */
private final static String TAG = "CircBuf"; private final static String TAG = "CircBuf";
private double[] mBuff; private double[] mBuff;
@@ -35,7 +35,7 @@ public class CircBuf {
/** /**
* Add value val to the circular buffer. * Add value val to the circular buffer.
*/ */
Log.d(TAG,"add() - before: mHead="+mHead+", mTail="+mTail); Log.d(TAG, "add() - before: mHead=" + mHead + ", mTail=" + mTail);
//System.out.println(TAG+" add() - before: mHead="+mHead+", mTail="+mTail); //System.out.println(TAG+" add() - before: mHead="+mHead+", mTail="+mTail);
if (mIsFull) if (mIsFull)
mHead = (mHead + 1) % mBuffLen; mHead = (mHead + 1) % mBuffLen;
@@ -44,7 +44,7 @@ public class CircBuf {
mTail = (mTail + 1) % mBuffLen; mTail = (mTail + 1) % mBuffLen;
if (mTail == mHead) if (mTail == mHead)
mIsFull = true; mIsFull = true;
Log.d(TAG,"add() - after: mHead="+mHead+", mTail="+mTail); Log.d(TAG, "add() - after: mHead=" + mHead + ", mTail=" + mTail);
//System.out.println(TAG+" add() - before: mHead="+mHead+", mTail="+mTail); //System.out.println(TAG+" add() - before: mHead="+mHead+", mTail="+mTail);
} }
@@ -60,7 +60,7 @@ public class CircBuf {
if (mHead > mTail) { if (mHead > mTail) {
numElements = (mTail + mBuffLen) - mHead; numElements = (mTail + mBuffLen) - mHead;
} else { } else {
numElements = mTail-mHead; numElements = mTail - mHead;
} }
} }
return numElements; return numElements;
@@ -68,11 +68,12 @@ public class CircBuf {
/** /**
* Returns a double array of buffer items in order of their insertion time * Returns a double array of buffer items in order of their insertion time
*
* @return double[] of buffer items * @return double[] of buffer items
*/ */
public double[] getVals () { public double[] getVals() {
int numElements = getNumVals(); int numElements = getNumVals();
System.out.println(TAG+" getVals() - numElements=" + numElements); System.out.println(TAG + " getVals() - numElements=" + numElements);
double[] retArr = new double[numElements]; double[] retArr = new double[numElements];
for (int i = 0; i < numElements; i++) { for (int i = 0; i < numElements; i++) {
retArr[i] = mBuff[(mHead + i) % mBuffLen]; retArr[i] = mBuff[(mHead + i) % mBuffLen];
@@ -89,18 +90,18 @@ public class CircBuf {
int hrCount = 0; int hrCount = 0;
double valArr[] = getVals(); double valArr[] = getVals();
double retVal; double retVal;
for (int n=0; n<valArr.length; n++) { for (int n = 0; n < valArr.length; n++) {
if (valArr[n] != mErrVal) { if (valArr[n] != mErrVal) {
hrSum += valArr[n]; hrSum += valArr[n];
hrCount++; hrCount++;
} }
} }
if (hrCount>0) { if (hrCount > 0) {
retVal = hrSum / hrCount; retVal = hrSum / hrCount;
} else { } else {
retVal = -1; retVal = -1;
} }
return(retVal); return (retVal);
} }
} }

View File

@@ -3,7 +3,9 @@ package uk.org.openseizuredetector;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@@ -205,7 +207,7 @@ public class EditEventActivity extends AppCompatActivity {
int alarmStateVal = Integer.parseInt(alarmStateStr); int alarmStateVal = Integer.parseInt(alarmStateStr);
alarmStateStr = mUtil.alarmStatusToString(alarmStateVal); alarmStateStr = mUtil.alarmStatusToString(alarmStateVal);
} catch (Exception e) { } catch (Exception e) {
Log.v(TAG,"updateUi: alarmState does not parse to int so displaying it as string: " +alarmStateStr); Log.v(TAG, "updateUi: alarmState does not parse to int so displaying it as string: " + alarmStateStr);
} }
tv.setText(alarmStateStr); tv.setText(alarmStateStr);
tv = (TextView) findViewById(R.id.eventNotsTv); tv = (TextView) findViewById(R.id.eventNotsTv);
@@ -219,7 +221,7 @@ public class EditEventActivity extends AppCompatActivity {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
tv.setText(dateFormat.format(dataTime)); tv.setText(dateFormat.format(dataTime));
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG,"updateUI: Error Parsing dataDate "+e.getLocalizedMessage()); Log.e(TAG, "updateUI: Error Parsing dataDate " + e.getLocalizedMessage());
tv.setText("---"); tv.setText("---");
} }
@@ -234,9 +236,9 @@ public class EditEventActivity extends AppCompatActivity {
} }
// Populate the event sub-types radio button list. // Populate the event sub-types radio button list.
Log.v(TAG,"updateUi() - meventsubtypeshashmap="+mEventSubTypesHashMap+", mEventSubtypesListChanged="+mEventSubTypesListChanged); Log.v(TAG, "updateUi() - meventsubtypeshashmap=" + mEventSubTypesHashMap + ", mEventSubtypesListChanged=" + mEventSubTypesListChanged);
if (mEventSubTypesHashMap != null && mEventSubTypesListChanged) { if (mEventSubTypesHashMap != null && mEventSubTypesListChanged) {
Log.v(TAG,"UpdateUi() - populating event sub types list"); Log.v(TAG, "UpdateUi() - populating event sub types list");
if (mEventObj.getString("type") != null) { if (mEventObj.getString("type") != null) {
// based on https://androidexample.com/create-a-simple-listview // based on https://androidexample.com/create-a-simple-listview
ArrayList<String> subtypesArrayList = mEventSubTypesHashMap.get(mEventObj.getString("type")); ArrayList<String> subtypesArrayList = mEventSubTypesHashMap.get(mEventObj.getString("type"));
@@ -265,11 +267,10 @@ public class EditEventActivity extends AppCompatActivity {
} }
} catch (JSONException e) { } catch (JSONException e) {
Log.e(TAG,"Error Parsing mEventObj: "+e.getMessage()); Log.e(TAG, "Error Parsing mEventObj: " + e.getMessage());
} }
} // updateUi() } // updateUi()
View.OnClickListener onCancel = View.OnClickListener onCancel =
@@ -287,14 +288,14 @@ public class EditEventActivity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
//m_status=true; //m_status=true;
TextView tv = (TextView)findViewById(R.id.eventNotsTv); TextView tv = (TextView) findViewById(R.id.eventNotsTv);
try { try {
mEventObj.put("desc",tv.getText()); mEventObj.put("desc", tv.getText());
mEventObj.put("id",mEventId); // Add event Id to event object manually because firestore does not include it by default. mEventObj.put("id", mEventId); // Add event Id to event object manually because firestore does not include it by default.
} catch (JSONException e) { } catch (JSONException e) {
Log.e(TAG,"Error writing mEventObj: "+e.getMessage()); Log.e(TAG, "Error writing mEventObj: " + e.getMessage());
} }
Log.v(TAG, "onOK() - eventObj="+mEventObj.toString()); Log.v(TAG, "onOK() - eventObj=" + mEventObj.toString());
try { try {
mWac.updateEvent(mEventObj, new WebApiConnection.JSONObjectCallback() { mWac.updateEvent(mEventObj, new WebApiConnection.JSONObjectCallback() {
@@ -314,7 +315,7 @@ public class EditEventActivity extends AppCompatActivity {
} }
}); });
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG,"onOK() - ERROR: "+e.getMessage()+" : " +e.toString()); Log.e(TAG, "onOK() - ERROR: " + e.getMessage() + " : " + e.toString());
e.printStackTrace(); e.printStackTrace();
mUtil.showToast("Error Updating Event"); mUtil.showToast("Error Updating Event");
updateUi(); updateUi();
@@ -327,16 +328,16 @@ public class EditEventActivity extends AppCompatActivity {
new RadioGroup.OnCheckedChangeListener() { new RadioGroup.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(RadioGroup group, int checkedId) { public void onCheckedChanged(RadioGroup group, int checkedId) {
Log.v(TAG,"onEventTypeChange() - id="+checkedId); Log.v(TAG, "onEventTypeChange() - id=" + checkedId);
RadioButton b = (RadioButton)findViewById(group.getCheckedRadioButtonId()); RadioButton b = (RadioButton) findViewById(group.getCheckedRadioButtonId());
String selectedEventType = b.getText().toString(); String selectedEventType = b.getText().toString();
try { try {
mEventObj.put("type", selectedEventType); mEventObj.put("type", selectedEventType);
} catch (JSONException e) { } catch (JSONException e) {
Log.e(TAG,"Error setting mEventObj.type: "+e.getMessage()); Log.e(TAG, "Error setting mEventObj.type: " + e.getMessage());
} }
mEventSubTypesListChanged = true; mEventSubTypesListChanged = true;
Log.v(TAG,"onEventTypeChange() - mEventSubTypesListChanged="+mEventSubTypesListChanged); Log.v(TAG, "onEventTypeChange() - mEventSubTypesListChanged=" + mEventSubTypesListChanged);
updateUi(); updateUi();
} }
}; };
@@ -344,13 +345,13 @@ public class EditEventActivity extends AppCompatActivity {
new RadioGroup.OnCheckedChangeListener() { new RadioGroup.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(RadioGroup group, int checkedId) { public void onCheckedChanged(RadioGroup group, int checkedId) {
Log.v(TAG,"onEventSubTypeChange() - id="+checkedId); Log.v(TAG, "onEventSubTypeChange() - id=" + checkedId);
RadioButton b = (RadioButton)findViewById(group.getCheckedRadioButtonId()); RadioButton b = (RadioButton) findViewById(group.getCheckedRadioButtonId());
String selectedEventSubType = b.getText().toString(); String selectedEventSubType = b.getText().toString();
try { try {
mEventObj.put("subType", selectedEventSubType); mEventObj.put("subType", selectedEventSubType);
} catch (JSONException e) { } catch (JSONException e) {
Log.e(TAG,"Error setting mEventObj.type: "+e.getMessage()); Log.e(TAG, "Error setting mEventObj.type: " + e.getMessage());
} }
updateUi(); updateUi();
} }

View File

@@ -226,14 +226,14 @@ public class ExportDataActivity extends AppCompatActivity
public void hideProgressBar() { public void hideProgressBar() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
ProgressBar pb = (ProgressBar) findViewById(R.id.exportPb); ProgressBar pb = (ProgressBar) findViewById(R.id.exportPb);
pb.setIndeterminate(true); pb.setIndeterminate(true);
pb.setVisibility(View.INVISIBLE); pb.setVisibility(View.INVISIBLE);
mExportBtn.setEnabled(true); mExportBtn.setEnabled(true);
mExportBtn.setVisibility(View.VISIBLE); mExportBtn.setVisibility(View.VISIBLE);
} }
}); });
} }
@@ -265,8 +265,8 @@ public class ExportDataActivity extends AppCompatActivity
// Perform operations on the document using its URI. // Perform operations on the document using its URI.
//mUtil.showToast("URI="+uri.toString()); //mUtil.showToast("URI="+uri.toString());
Log.v(TAG, "onActivityResult() - exporting to file " + uri.toString()); Log.v(TAG, "onActivityResult() - exporting to file " + uri.toString());
mLm.exportToCsvFile(mEndDate, mDuration,uri, (boolean b)-> { mLm.exportToCsvFile(mEndDate, mDuration, uri, (boolean b) -> {
Log.v(TAG,"onActivityResult callback"); Log.v(TAG, "onActivityResult callback");
hideProgressBar(); hideProgressBar();
}); });

View File

@@ -9,6 +9,7 @@ import android.widget.TextView;
public class FragmentDataSharing extends FragmentOsdBaseClass { public class FragmentDataSharing extends FragmentOsdBaseClass {
String TAG = "FragmentDataSharing"; String TAG = "FragmentDataSharing";
public FragmentDataSharing() { public FragmentDataSharing() {
// Required empty public constructor // Required empty public constructor
} }
@@ -28,9 +29,9 @@ public class FragmentDataSharing extends FragmentOsdBaseClass {
@Override @Override
protected void updateUi() { protected void updateUi() {
Log.d(TAG,"updateUi()"); Log.d(TAG, "updateUi()");
TextView tv; TextView tv;
tv = (TextView)mRootView.findViewById(R.id.fragment_data_sharing_tv1); tv = (TextView) mRootView.findViewById(R.id.fragment_data_sharing_tv1);
if (mConnection.mBound) { if (mConnection.mBound) {
tv.setText("Bound to Server"); tv.setText("Bound to Server");
} else { } else {

View File

@@ -52,7 +52,7 @@ public class FragmentHrAlg extends FragmentOsdBaseClass {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
lineDataSet = new LineDataSet(new ArrayList<Entry>(),"Heart rate history" ); lineDataSet = new LineDataSet(new ArrayList<Entry>(), "Heart rate history");
//lineDataSet.setColors(ColorTemplate.JOYFUL_COLORS); //lineDataSet.setColors(ColorTemplate.JOYFUL_COLORS);
lineDataSet.setValueTextColor(Color.BLACK); lineDataSet.setValueTextColor(Color.BLACK);
lineDataSet.setValueTextSize(18f); lineDataSet.setValueTextSize(18f);
@@ -99,6 +99,7 @@ public class FragmentHrAlg extends FragmentOsdBaseClass {
yAxis2.setDrawGridLines(false); yAxis2.setDrawGridLines(false);
yAxis2.setEnabled(false); yAxis2.setEnabled(false);
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@@ -118,9 +119,9 @@ public class FragmentHrAlg extends FragmentOsdBaseClass {
tvCurrent = mRootView.findViewById(R.id.textView2); tvCurrent = mRootView.findViewById(R.id.textView2);
if (Objects.nonNull(tvCurrent)) { if (Objects.nonNull(tvCurrent)) {
if (Objects.nonNull(tvHr)) if (Objects.nonNull(tvHr))
tvHr.setText( String.valueOf((short)mConnection.mSdServer.mSdData.mHR)); tvHr.setText(String.valueOf((short) mConnection.mSdServer.mSdData.mHR));
if (Objects.nonNull(tvAvgAHr)) if (Objects.nonNull(tvAvgAHr))
tvAvgAHr.setText( String.valueOf((short)mConnection.mSdServer.mSdData tvAvgAHr.setText(String.valueOf((short) mConnection.mSdServer.mSdData
.mAdaptiveHrAverage)); .mAdaptiveHrAverage));
tvCurrent.setText(new StringBuilder() tvCurrent.setText(new StringBuilder()
.append("\nResult of checks: Adaptive Hr Alarm Standing: ") .append("\nResult of checks: Adaptive Hr Alarm Standing: ")
@@ -137,16 +138,16 @@ public class FragmentHrAlg extends FragmentOsdBaseClass {
int nHistArr = hrHist.getNumVals(); int nHistArr = hrHist.getNumVals();
double hrHistArr[] = hrHist.getVals(); // This gives us a simple vector of hr values to plot. double hrHistArr[] = hrHist.getVals(); // This gives us a simple vector of hr values to plot.
if (Objects.nonNull(hrHist) && nHistArr > 0) { if (Objects.nonNull(hrHist) && nHistArr > 0) {
Log.v(TAG, "hrHist.getNumVals="+nHistArr); Log.v(TAG, "hrHist.getNumVals=" + nHistArr);
lineDataSet.clear(); lineDataSet.clear();
String xVals[] = new String[nHistArr]; String xVals[] = new String[nHistArr];
for (int i = 0; i<nHistArr; i++) { for (int i = 0; i < nHistArr; i++) {
//Log.d(TAG,"i="+i+", HR="+hrHistArr[i]); //Log.d(TAG,"i="+i+", HR="+hrHistArr[i]);
xVals[i] = String.valueOf(i); xVals[i] = String.valueOf(i);
lineDataSet.addEntry(new Entry((float)hrHistArr[i], i)); lineDataSet.addEntry(new Entry((float) hrHistArr[i], i));
} }
Log.d(TAG,"xVals="+ Arrays.toString(xVals)+ ", lneDataSet="+lineDataSet.toSimpleString()); Log.d(TAG, "xVals=" + Arrays.toString(xVals) + ", lneDataSet=" + lineDataSet.toSimpleString());
lineDataSet.setColors(new int[] {0xffff0000}); lineDataSet.setColors(new int[]{0xffff0000});
LineData hrHistLineData = new LineData(xVals, lineDataSet); LineData hrHistLineData = new LineData(xVals, lineDataSet);
@@ -154,7 +155,7 @@ public class FragmentHrAlg extends FragmentOsdBaseClass {
mLineChart.getData().notifyDataChanged(); mLineChart.getData().notifyDataChanged();
mLineChart.notifyDataSetChanged(); mLineChart.notifyDataSetChanged();
mLineChart.refreshDrawableState(); mLineChart.refreshDrawableState();
float xSpan = (nHistArr * 5.0f)/60.0f; // time in minutes assuming one point every 5 seconds. float xSpan = (nHistArr * 5.0f) / 60.0f; // time in minutes assuming one point every 5 seconds.
mLineChart.setDescription(getString(R.string.heart_rate_history_bpm) mLineChart.setDescription(getString(R.string.heart_rate_history_bpm)
+ String.format("%.1f", xSpan) + String.format("%.1f", xSpan)
+ " " + getString(R.string.minutes)); + " " + getString(R.string.minutes));

View File

@@ -9,6 +9,7 @@ import android.widget.TextView;
public class FragmentMlAlg extends FragmentOsdBaseClass { public class FragmentMlAlg extends FragmentOsdBaseClass {
String TAG = "FragmentMlAlg"; String TAG = "FragmentMlAlg";
public FragmentMlAlg() { public FragmentMlAlg() {
// Required empty public constructor // Required empty public constructor
} }
@@ -28,9 +29,9 @@ public class FragmentMlAlg extends FragmentOsdBaseClass {
@Override @Override
protected void updateUi() { protected void updateUi() {
Log.d(TAG,"updateUi()"); Log.d(TAG, "updateUi()");
TextView tv; TextView tv;
tv = (TextView)mRootView.findViewById(R.id.fragment_ml_alg_tv1); tv = (TextView) mRootView.findViewById(R.id.fragment_ml_alg_tv1);
if (mConnection.mBound) { if (mConnection.mBound) {
tv.setText("Bound to Server"); tv.setText("Bound to Server");
} else { } else {

View File

@@ -23,6 +23,7 @@ import java.util.ArrayList;
public class FragmentOsdAlg extends FragmentOsdBaseClass { public class FragmentOsdAlg extends FragmentOsdBaseClass {
String TAG = "FragmentOsdAlg"; String TAG = "FragmentOsdAlg";
public FragmentOsdAlg() { public FragmentOsdAlg() {
// Required empty public constructor // Required empty public constructor
} }
@@ -71,7 +72,7 @@ public class FragmentOsdAlg extends FragmentOsdBaseClass {
} else } else
specRatio = 0; specRatio = 0;
((TextView)mRootView.findViewById(R.id.powerTv)).setText(getString(R.string.PowerEquals) + mConnection.mSdServer.mSdData.roiPower + ((TextView) mRootView.findViewById(R.id.powerTv)).setText(getString(R.string.PowerEquals) + mConnection.mSdServer.mSdData.roiPower +
" (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmThresh + ")"); " (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmThresh + ")");
ProgressBar pb; ProgressBar pb;
@@ -86,7 +87,7 @@ public class FragmentOsdAlg extends FragmentOsdBaseClass {
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red); pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red);
pb.setProgressDrawable(pbDrawable); pb.setProgressDrawable(pbDrawable);
((TextView)mRootView.findViewById(R.id.spectrumTv)).setText(getString(R.string.SpectrumRatioEquals) + specRatio + ((TextView) mRootView.findViewById(R.id.spectrumTv)).setText(getString(R.string.SpectrumRatioEquals) + specRatio +
" (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmRatioThresh + ")"); " (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmRatioThresh + ")");
pb = ((ProgressBar) mRootView.findViewById(R.id.spectrumProgressBar)); pb = ((ProgressBar) mRootView.findViewById(R.id.spectrumProgressBar));

View File

@@ -34,7 +34,6 @@ public class FragmentOsdBaseClass extends Fragment {
protected int alarmTextColour = Color.BLACK; protected int alarmTextColour = Color.BLACK;
public FragmentOsdBaseClass() { public FragmentOsdBaseClass() {
// Required empty public constructor // Required empty public constructor
} }
@@ -44,7 +43,7 @@ public class FragmentOsdBaseClass extends Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Log.i(TAG,"onCreate()"); Log.i(TAG, "onCreate()");
mContext = getContext(); mContext = getContext();
mUtil = new OsdUtil(mContext, updateUiHandler); mUtil = new OsdUtil(mContext, updateUiHandler);
mConnection = new SdServiceConnection(mContext); mConnection = new SdServiceConnection(mContext);
@@ -109,7 +108,7 @@ public class FragmentOsdBaseClass extends Fragment {
* update the user interface views... * update the user interface views...
*/ */
private void updateUiOnUiThread() { private void updateUiOnUiThread() {
updateUiHandler.post(new Runnable(){ updateUiHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
updateUi(); updateUi();
@@ -121,9 +120,9 @@ public class FragmentOsdBaseClass extends Fragment {
* The subclasses should override this to draw their own UI. * The subclasses should override this to draw their own UI.
*/ */
protected void updateUi() { protected void updateUi() {
Log.d(TAG,"updateUi()"); Log.d(TAG, "updateUi()");
TextView tv; TextView tv;
tv = (TextView)mRootView.findViewById(R.id.fragment_sddata_viewer_tv1); tv = (TextView) mRootView.findViewById(R.id.fragment_sddata_viewer_tv1);
if (mConnection.mBound) { if (mConnection.mBound) {
tv.setText("Bound to Server"); tv.setText("Bound to Server");
} else { } else {

View File

@@ -13,6 +13,7 @@ import androidx.appcompat.widget.LinearLayoutCompat;
public class FragmentSystem extends FragmentOsdBaseClass { public class FragmentSystem extends FragmentOsdBaseClass {
String TAG = "FragmentSystem"; String TAG = "FragmentSystem";
public FragmentSystem() { public FragmentSystem() {
// Required empty public constructor // Required empty public constructor
} }
@@ -51,13 +52,12 @@ public class FragmentSystem extends FragmentOsdBaseClass {
} }
@Override @Override
protected void updateUi() { protected void updateUi() {
//Log.d(TAG,"updateUi()"); //Log.d(TAG,"updateUi()");
TextView tv; TextView tv;
tv = (TextView)mRootView.findViewById(R.id.fragment_bound_to_server_tv); tv = (TextView) mRootView.findViewById(R.id.fragment_bound_to_server_tv);
if (mConnection.mBound) { if (mConnection.mBound) {
tv.setText("Bound to Server"); tv.setText("Bound to Server");
tv.setTextColor(okTextColour); tv.setTextColor(okTextColour);
@@ -66,7 +66,7 @@ public class FragmentSystem extends FragmentOsdBaseClass {
tv.setTextColor(warnTextColour); tv.setTextColor(warnTextColour);
return; return;
} }
LinearLayoutCompat ll = (LinearLayoutCompat)mRootView.findViewById(R.id.fragment_ll); LinearLayoutCompat ll = (LinearLayoutCompat) mRootView.findViewById(R.id.fragment_ll);
if (mUtil.isServerRunning()) { if (mUtil.isServerRunning()) {
ll.setBackgroundColor(okColour); ll.setBackgroundColor(okColour);
@@ -174,8 +174,8 @@ public class FragmentSystem extends FragmentOsdBaseClass {
} }
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "UpdateUi: Exception - "); Log.e(TAG, "UpdateUi: Exception - ");
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

View File

@@ -9,6 +9,7 @@ import android.widget.TextView;
public class FragmentWebServer extends FragmentOsdBaseClass { public class FragmentWebServer extends FragmentOsdBaseClass {
String TAG = "FragmentWebServer"; String TAG = "FragmentWebServer";
public FragmentWebServer() { public FragmentWebServer() {
// Required empty public constructor // Required empty public constructor
} }
@@ -28,9 +29,9 @@ public class FragmentWebServer extends FragmentOsdBaseClass {
@Override @Override
protected void updateUi() { protected void updateUi() {
Log.d(TAG,"updateUi()"); Log.d(TAG, "updateUi()");
TextView tv; TextView tv;
tv = (TextView)mRootView.findViewById(R.id.fragment_web_server_tv1); tv = (TextView) mRootView.findViewById(R.id.fragment_web_server_tv1);
if (mConnection.mBound) { if (mConnection.mBound) {
tv.setText("Bound to Server"); tv.setText("Bound to Server");
} else { } else {

View File

@@ -1,5 +1,6 @@
package uk.org.openseizuredetector; package uk.org.openseizuredetector;
// Defines the servies and characteristics we need to subscribe to. // Defines the servies and characteristics we need to subscribe to.
import java.util.HashMap; import java.util.HashMap;
public class GattAttributes { public class GattAttributes {

View File

@@ -2,6 +2,7 @@ package uk.org.openseizuredetector;
/** /**
*
*/ */
import android.content.Context; import android.content.Context;
@@ -21,8 +22,7 @@ interface SdLocationReceiver {
} }
public class LocationFinder implements LocationListener public class LocationFinder implements LocationListener {
{
SdLocationReceiver mSdLocationReceiver = null; SdLocationReceiver mSdLocationReceiver = null;
Location mLastLocation = null; Location mLastLocation = null;
OsdUtil mUtil; OsdUtil mUtil;
@@ -33,7 +33,7 @@ public class LocationFinder implements LocationListener
LocationListener mLocationListener; LocationListener mLocationListener;
int mTimeoutPeriod = 60; // Location search timeout period in seconds. int mTimeoutPeriod = 60; // Location search timeout period in seconds.
String TAG="LocationFinder"; String TAG = "LocationFinder";
LocationFinder(Context context) { LocationFinder(Context context) {
mHandler = new Handler(); mHandler = new Handler();
@@ -56,7 +56,6 @@ public class LocationFinder implements LocationListener
} }
public Location getLastLocation() { public Location getLastLocation() {
return mLastLocation; return mLastLocation;
} }
@@ -82,7 +81,7 @@ public class LocationFinder implements LocationListener
mTimeoutTimer.schedule(new TimerTask() { mTimeoutTimer.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
Log.v(TAG,"mTimeOutTimer expired - returning last location"); Log.v(TAG, "mTimeOutTimer expired - returning last location");
//mUtil.showToast("mTimeOutTimer expired - returning last location"); //mUtil.showToast("mTimeOutTimer expired - returning last location");
mLocationManager.removeUpdates(mLocationListener); mLocationManager.removeUpdates(mLocationListener);
mSdLocationReceiver.onSdLocationReceived(mLastLocation); mSdLocationReceiver.onSdLocationReceived(mLastLocation);
@@ -93,7 +92,7 @@ public class LocationFinder implements LocationListener
@Override @Override
public void onLocationChanged(Location location) { public void onLocationChanged(Location location) {
Log.v(TAG,"onLocationChanged - "+location.toString()); Log.v(TAG, "onLocationChanged - " + location.toString());
// if we do not have a last location, this is the best we have! // if we do not have a last location, this is the best we have!
if (mLastLocation == null) { if (mLastLocation == null) {

View File

@@ -498,7 +498,7 @@ public class LogManager {
* @param endDate end date of period to export (Date type) * @param endDate end date of period to export (Date type)
* @param duration duration in hours of period to export (double) * @param duration duration in hours of period to export (double)
* @param uri uri of file to save. * @param uri uri of file to save.
* @param callback function to be called on completion of the task (returns true on success, false on error) * @param callback function to be called on completion of the task (returns true on success, false on error)
*/ */
public void exportToCsvFile(Date endDate, double duration, Uri uri, BooleanCallback callback) { public void exportToCsvFile(Date endDate, double duration, Uri uri, BooleanCallback callback) {
Log.v(TAG, "exportToCsvFile(): uri=" + uri.toString()); Log.v(TAG, "exportToCsvFile(): uri=" + uri.toString());
@@ -510,8 +510,6 @@ public class LogManager {
} }
/** /**
* Return an array list of objects representing the events in the database by calling the specified callback function. * Return an array list of objects representing the events in the database by calling the specified callback function.
* *
@@ -807,7 +805,7 @@ public class LogManager {
ExportDataTask(Date endDate, double duration, Uri uri, BooleanCallback callback) { ExportDataTask(Date endDate, double duration, Uri uri, BooleanCallback callback) {
Log.i(TAG,"ExportDataTask constructor()"); Log.i(TAG, "ExportDataTask constructor()");
this.mCallback = callback; this.mCallback = callback;
mEndDate = endDate; mEndDate = endDate;
mDuration = duration; mDuration = duration;
@@ -882,7 +880,7 @@ public class LogManager {
@Override @Override
protected void onPostExecute(final Boolean result) { protected void onPostExecute(final Boolean result) {
Log.i(TAG,"ExportDataTask.onPostExecute() - notifying callback function of result: "+result); Log.i(TAG, "ExportDataTask.onPostExecute() - notifying callback function of result: " + result);
mCallback.accept(result); mCallback.accept(result);
} }
@@ -923,12 +921,12 @@ public class LogManager {
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, "exportToFile() - ERROR Writing File: " + e.toString()); Log.e(TAG, "exportToFile() - ERROR Writing File: " + e.toString());
mUtil.showToast("ERROR WRITING FILE"); mUtil.showToast("ERROR WRITING FILE");
return(-1); return (-1);
} }
} }
Log.d(TAG, "writeDatapointsToFile() - data written to file ok"); Log.d(TAG, "writeDatapointsToFile() - data written to file ok");
mUtil.showToast(mContext.getString(R.string.data_exported_ok)+ " "+nRec); mUtil.showToast(mContext.getString(R.string.data_exported_ok) + " " + nRec);
return nRec; return nRec;
} catch (JSONException | NullPointerException e) { } catch (JSONException | NullPointerException e) {
@@ -936,7 +934,7 @@ public class LogManager {
dataObj = null; dataObj = null;
mUtil.showToast(mContext.getString(R.string.error_exporting_data)); mUtil.showToast(mContext.getString(R.string.error_exporting_data));
Log.e(TAG, "exportToFile() - JSONException: " + e.toString()); Log.e(TAG, "exportToFile() - JSONException: " + e.toString());
return(-1); return (-1);
} }
} }

View File

@@ -652,16 +652,16 @@ public class MainActivity extends AppCompatActivity {
//if (mConnection.mSdServer.mSdData.mHRAlarmActive) { //if (mConnection.mSdServer.mSdData.mHRAlarmActive) {
if (mConnection.mSdServer.mSdData.mO2Sat > 0) { if (mConnection.mSdServer.mSdData.mO2Sat > 0) {
tv.setText(getString(R.string.HR_Equals) + " " + Math.round(mConnection.mSdServer.mSdData.mHR) + " bpm\n" tv.setText(getString(R.string.HR_Equals) + " " + Math.round(mConnection.mSdServer.mSdData.mHR) + " bpm\n"
+"(av = " + "(av = "
+Math.round(mConnection.mSdServer.mSdData.mAdaptiveHrAverage)+", " + Math.round(mConnection.mSdServer.mSdData.mAdaptiveHrAverage) + ", "
+Math.round(mConnection.mSdServer.mSdData.mAverageHrAverage)+" bpm)\n" + Math.round(mConnection.mSdServer.mSdData.mAverageHrAverage) + " bpm)\n"
+ getString(R.string.SpO2)+" = " + Math.round(mConnection.mSdServer.mSdData.mO2Sat) + "%"); + getString(R.string.SpO2) + " = " + Math.round(mConnection.mSdServer.mSdData.mO2Sat) + "%");
} else { } else {
tv.setText(getString(R.string.HR_Equals) + " " + Math.round(mConnection.mSdServer.mSdData.mHR) + " bpm\n" tv.setText(getString(R.string.HR_Equals) + " " + Math.round(mConnection.mSdServer.mSdData.mHR) + " bpm\n"
+"(av = " + "(av = "
+Math.round(mConnection.mSdServer.mSdData.mAdaptiveHrAverage)+", " + Math.round(mConnection.mSdServer.mSdData.mAdaptiveHrAverage) + ", "
+Math.round(mConnection.mSdServer.mSdData.mAverageHrAverage)+" bpm)\n" + Math.round(mConnection.mSdServer.mSdData.mAverageHrAverage) + " bpm)\n"
+ getString(R.string.SpO2)+" = ---%"); + getString(R.string.SpO2) + " = ---%");
} }
if (mConnection.mSdServer.mSdData.mHRAlarmStanding if (mConnection.mSdServer.mSdData.mHRAlarmStanding
|| mConnection.mSdServer.mSdData.mAdaptiveHrAlarmStanding || mConnection.mSdServer.mSdData.mAdaptiveHrAlarmStanding
@@ -821,7 +821,7 @@ public class MainActivity extends AppCompatActivity {
" (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmThresh + ")"); " (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmThresh + ")");
((TextView) findViewById(R.id.spectrumTv)).setText(getString(R.string.SpectrumRatioEquals) + specRatio + ((TextView) findViewById(R.id.spectrumTv)).setText(getString(R.string.SpectrumRatioEquals) + specRatio +
" (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmRatioThresh + ")"); " (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmRatioThresh + ")");
((TextView) findViewById(R.id.pSeizureTv)).setText(getString(R.string.seizure_probability)+" = " + pSeizurePc + "%"); ((TextView) findViewById(R.id.pSeizureTv)).setText(getString(R.string.seizure_probability) + " = " + pSeizurePc + "%");
ProgressBar pb; ProgressBar pb;
Drawable pbDrawable; Drawable pbDrawable;

View File

@@ -45,36 +45,37 @@ public class MainActivity2 extends AppCompatActivity {
private OsdUtil mUtil; private OsdUtil mUtil;
private SdServiceConnection mConnection; private SdServiceConnection mConnection;
final Handler serverStatusHandler = new Handler(); final Handler serverStatusHandler = new Handler();
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2); setContentView(R.layout.activity_main2);
Log.i(TAG, "onCreate()"); Log.i(TAG, "onCreate()");
// Set our custom uncaught exception handler to report issues. // Set our custom uncaught exception handler to report issues.
//Thread.setDefaultUncaughtExceptionHandler(new OsdUncaughtExceptionHandler(MainActivity.this)); //Thread.setDefaultUncaughtExceptionHandler(new OsdUncaughtExceptionHandler(MainActivity.this));
new UCEHandler.Builder(this) new UCEHandler.Builder(this)
.addCommaSeparatedEmailAddresses("crashreports@openseizuredetector.org.uk,") .addCommaSeparatedEmailAddresses("crashreports@openseizuredetector.org.uk,")
.build(); .build();
//int i = 5/0; // Force exception to test handler. //int i = 5/0; // Force exception to test handler.
mUtil = new OsdUtil(getApplicationContext(), serverStatusHandler); mUtil = new OsdUtil(getApplicationContext(), serverStatusHandler);
mConnection = new SdServiceConnection(getApplicationContext()); mConnection = new SdServiceConnection(getApplicationContext());
mUtil.writeToSysLogFile("MainActivity2.onCreate()"); mUtil.writeToSysLogFile("MainActivity2.onCreate()");
mContext = this; mContext = this;
/** /**
if (savedInstanceState == null) { if (savedInstanceState == null) {
// Instantiate a ViewPager2 and a PagerAdapter. // Instantiate a ViewPager2 and a PagerAdapter.
mFragmentPager = findViewById(R.id.fragment_pager); mFragmentPager = findViewById(R.id.fragment_pager);
mFragmentStateAdapter = new ScreenSlideFragmentPagerAdapter(this); mFragmentStateAdapter = new ScreenSlideFragmentPagerAdapter(this);
mFragmentPager.setAdapter(mFragmentStateAdapter); mFragmentPager.setAdapter(mFragmentStateAdapter);
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
.setReorderingAllowed(true) .setReorderingAllowed(true)
.add(R.id.fragment_common_container_view, FragmentCommon.class, null) .add(R.id.fragment_common_container_view, FragmentCommon.class, null)
.commit(); .commit();
} }
*/ */
} }
@@ -127,8 +128,6 @@ public class MainActivity2 extends AppCompatActivity {
} }
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
@@ -151,7 +150,6 @@ public class MainActivity2 extends AppCompatActivity {
} }
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (Objects.isNull(mFragmentPager) || mFragmentPager.getCurrentItem() == 0) { if (Objects.isNull(mFragmentPager) || mFragmentPager.getCurrentItem() == 0) {
@@ -278,21 +276,20 @@ public class MainActivity2 extends AppCompatActivity {
} }
/** /**
* A simple pager adapter that represents 5 ScreenSlidePageFragment objects, in * A simple pager adapter that represents 5 ScreenSlidePageFragment objects, in
* sequence. * sequence.
*/ */
private class ScreenSlideFragmentPagerAdapter extends FragmentStateAdapter { private class ScreenSlideFragmentPagerAdapter extends FragmentStateAdapter {
private String TAG = "ScreenSlideFragmentPagerAdapter"; private String TAG = "ScreenSlideFragmentPagerAdapter";
public ScreenSlideFragmentPagerAdapter(FragmentActivity fa) { public ScreenSlideFragmentPagerAdapter(FragmentActivity fa) {
super(fa); super(fa);
} }
@Override @Override
public Fragment createFragment(int position) { public Fragment createFragment(int position) {
switch(position) { switch (position) {
case 0: case 0:
return new FragmentOsdAlg(); return new FragmentOsdAlg();
case 1: case 1:
@@ -305,7 +302,7 @@ public class MainActivity2 extends AppCompatActivity {
return new FragmentDataSharing(); return new FragmentDataSharing();
default: default:
Log.e(TAG,"createFragment() - invalid Position "+position); Log.e(TAG, "createFragment() - invalid Position " + position);
return null; return null;
} }
} }
@@ -329,7 +326,6 @@ public class MainActivity2 extends AppCompatActivity {
} }
private void showAbout() { private void showAbout() {
mUtil.writeToSysLogFile("MainActivity.showAbout()"); mUtil.writeToSysLogFile("MainActivity.showAbout()");
View aboutView = getLayoutInflater().inflate(R.layout.about_layout, null, false); View aboutView = getLayoutInflater().inflate(R.layout.about_layout, null, false);

View File

@@ -35,7 +35,7 @@ public class MlModelManager {
public boolean mModelReady = false; public boolean mModelReady = false;
private final String mUrlBase = "https://openseizuredetector.org.uk/static/MLmodels/"; private final String mUrlBase = "https://openseizuredetector.org.uk/static/MLmodels/";
private final String mModelIndexFname = "MLmodels.json"; private final String mModelIndexFname = "MLmodels.json";
RequestQueue mQueue; RequestQueue mQueue;
public interface JSONObjectCallback { public interface JSONObjectCallback {
public void accept(JSONObject retValObj); public void accept(JSONObject retValObj);
@@ -43,7 +43,7 @@ public class MlModelManager {
public MlModelManager(Context context) { public MlModelManager(Context context) {
Log.i(TAG,"MlModelManager Constructor"); Log.i(TAG, "MlModelManager Constructor");
mContext = context; mContext = context;
mUtil = new OsdUtil(mContext, new Handler()); mUtil = new OsdUtil(mContext, new Handler());
mQueue = Volley.newRequestQueue(mContext); mQueue = Volley.newRequestQueue(mContext);
@@ -55,7 +55,6 @@ public class MlModelManager {
} }
/** /**
* Retrieve the file containing the list of available ML models from the server. * Retrieve the file containing the list of available ML models from the server.
* Calls the specified callback function, passing a JSONObject as a parameter when the data has been received and parsed. * Calls the specified callback function, passing a JSONObject as a parameter when the data has been received and parsed.

View File

@@ -160,8 +160,8 @@ public class OsdUncaughtExceptionHandler implements Thread.UncaughtExceptionHand
}); });
builder.setMessage("Please report the " + builder.setMessage("Please report the " +
"problem by email using the button below so we can fix it.\n" + "problem by email using the button below so we can fix it.\n" +
"You can review the information being sent in the next screen:"+ "You can review the information being sent in the next screen:" +
"\n"+errorContent.toString()); "\n" + errorContent.toString());
Dialog dialog = builder.create(); Dialog dialog = builder.create();
//dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialog.show(); dialog.show();

View File

@@ -325,13 +325,13 @@ public class OsdUtil {
* *
* @param msgStr * @param msgStr
*/ */
public void writeToSysLogFile(String msgStr,String logType) { public void writeToSysLogFile(String msgStr, String logType) {
writeLogEntryToLocalDb(msgStr,logType); writeLogEntryToLocalDb(msgStr, logType);
}
public void writeToSysLogFile(String msgStr) {
writeLogEntryToLocalDb(msgStr,"v");
} }
public void writeToSysLogFile(String msgStr) {
writeLogEntryToLocalDb(msgStr, "v");
}
/** /**
@@ -403,12 +403,11 @@ public class OsdUtil {
public File[] getDataFilesList() { public File[] getDataFilesList() {
File[] files = getDataStorageDir().listFiles(); File[] files = getDataStorageDir().listFiles();
Log.d("Files", "Size: "+ files.length); Log.d("Files", "Size: " + files.length);
for (int i = 0; i < files.length; i++) for (int i = 0; i < files.length; i++) {
{
Log.d("Files", "FileName:" + files[i].getName()); Log.d("Files", "FileName:" + files[i].getName());
} }
return(files); return (files);
} }
/* Checks if external storage is available for read and write */ /* Checks if external storage is available for read and write */
@@ -459,6 +458,7 @@ public class OsdUtil {
* It first attempts to parse it as a long integer, in which case it is assumed to * It first attempts to parse it as a long integer, in which case it is assumed to
* be a unix timestamp. * be a unix timestamp.
* If that fails it attempts to parse it as yyyy-MM-dd'T'HH:mm:ss'Z' format. * If that fails it attempts to parse it as yyyy-MM-dd'T'HH:mm:ss'Z' format.
*
* @param dateStr String reprenting a date * @param dateStr String reprenting a date
* @return Date object or null if parsing fails. * @return Date object or null if parsing fails.
*/ */
@@ -468,7 +468,7 @@ public class OsdUtil {
Long tstamp = Long.parseLong(dateStr); Long tstamp = Long.parseLong(dateStr);
dataTime = new Date(tstamp); dataTime = new Date(tstamp);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Log.v(TAG, "remoteEventsAdapter.getView: Error Parsing dataDate as Long: " + e.getLocalizedMessage()+" trying as string"); Log.v(TAG, "remoteEventsAdapter.getView: Error Parsing dataDate as Long: " + e.getLocalizedMessage() + " trying as string");
try { try {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
dataTime = dateFormat.parse(dateStr); dataTime = dateFormat.parse(dateStr);
@@ -477,7 +477,7 @@ public class OsdUtil {
dataTime = null; dataTime = null;
} }
} }
return(dataTime); return (dataTime);
} }
@@ -503,20 +503,20 @@ public class OsdUtil {
break; break;
} }
return(retVal); return (retVal);
} }
private static boolean openDb() { private static boolean openDb() {
Log.d(TAG, "openDb"); Log.d(TAG, "openDb");
try { try {
if (mSysLogDb == null) { if (mSysLogDb == null) {
Log.i(TAG,"openDb: mSysLogDb is null - initialising"); Log.i(TAG, "openDb: mSysLogDb is null - initialising");
mSysLogDb = new OsdSysLogHelper(mContext).getWritableDatabase(); mSysLogDb = new OsdSysLogHelper(mContext).getWritableDatabase();
} else { } else {
Log.i(TAG,"openDb: mSysLogDb has been initialised already so not doing anything"); Log.i(TAG, "openDb: mSysLogDb has been initialised already so not doing anything");
} }
if (!checkTableExists(mSysLogDb, mSysLogTableName)) { if (!checkTableExists(mSysLogDb, mSysLogTableName)) {
Log.e(TAG, "ERROR - Table "+mSysLogTableName+" does not exist"); Log.e(TAG, "ERROR - Table " + mSysLogTableName + " does not exist");
return false; return false;
} else { } else {
Log.d(TAG, "table " + mSysLogTableName + " exists ok"); Log.d(TAG, "table " + mSysLogTableName + " exists ok");
@@ -565,7 +565,7 @@ public class OsdUtil {
+ 0 + 0
+ ")"; + ")";
mSysLogDb.execSQL(SQLStr); mSysLogDb.execSQL(SQLStr);
Log.v(TAG, "syslog entry written to database: "+logText); Log.v(TAG, "syslog entry written to database: " + logText);
pruneSysLogDb(); pruneSysLogDb();
} catch (SQLException e) { } catch (SQLException e) {
@@ -612,7 +612,6 @@ public class OsdUtil {
/** /**
* Executes the sqlite query (=SELECT statement) * Executes the sqlite query (=SELECT statement)
* Use as new SelectQueryTask(xxx,xxx,xx,xxxx).execute() * Use as new SelectQueryTask(xxx,xxx,xx,xxxx).execute()
*
*/ */
static private class SelectQueryTask extends AsyncTask<Void, Void, Cursor> { static private class SelectQueryTask extends AsyncTask<Void, Void, Cursor> {
// Based on https://stackoverflow.com/a/21120199/2104584 // Based on https://stackoverflow.com/a/21120199/2104584
@@ -669,7 +668,6 @@ public class OsdUtil {
} }
/** /**
* pruneSysLogDb() removes data that is older than 7 days * pruneSysLogDb() removes data that is older than 7 days
*/ */
@@ -728,13 +726,13 @@ public class OsdUtil {
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// This database is only a cache for online data, so its upgrade policy is // This database is only a cache for online data, so its upgrade policy is
// to simply to discard the data and start over // to simply to discard the data and start over
Log.i(TAG,"onUpgrade()"); Log.i(TAG, "onUpgrade()");
db.execSQL("Drop table if exists " + mSysLogTableName + ";"); db.execSQL("Drop table if exists " + mSysLogTableName + ";");
onCreate(db); onCreate(db);
} }
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.i(TAG,"onDowngrade()"); Log.i(TAG, "onDowngrade()");
onUpgrade(db, oldVersion, newVersion); onUpgrade(db, oldVersion, newVersion);
} }
} }

View File

@@ -152,7 +152,7 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
Intent i; Intent i;
i = new Intent(this, StartupActivity.class); i = new Intent(this, StartupActivity.class);
startActivity(i); startActivity(i);
Log.i(TAG,"onSharedPreferenceChanged() - finishing PrefActivity"); Log.i(TAG, "onSharedPreferenceChanged() - finishing PrefActivity");
finish(); finish();
return; return;
} else { } else {
@@ -218,7 +218,7 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
mUtil.writeToSysLogFile("PrefActvity.onStop()"); mUtil.writeToSysLogFile("PrefActvity.onStop()");
Log.i(TAG,"onStop()"); Log.i(TAG, "onStop()");
} }
/** /**

View File

@@ -9,7 +9,9 @@ import android.os.Bundle;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.webkit.WebSettings; import android.webkit.WebSettings;
@@ -114,7 +116,7 @@ public class RemoteDbActivity extends AppCompatActivity {
private HashMap<String, String> getAuthHeaders() { private HashMap<String, String> getAuthHeaders() {
HashMap<String, String> headersMap = new HashMap<>(); HashMap<String, String> headersMap = new HashMap<>();
String authToken = getAuthToken(); String authToken = getAuthToken();
headersMap.put("Authorization", "Token "+authToken); headersMap.put("Authorization", "Token " + authToken);
return (headersMap); return (headersMap);
} }
@@ -125,7 +127,7 @@ public class RemoteDbActivity extends AppCompatActivity {
} }
private void updateUi() { private void updateUi() {
Log.v(TAG,"updateUi()"); Log.v(TAG, "updateUi()");
TextView tv; TextView tv;
Button btn; Button btn;
// Local Database Information // Local Database Information
@@ -137,10 +139,9 @@ public class RemoteDbActivity extends AppCompatActivity {
//tv.setText(String.format("%d",datapointsCount)); //tv.setText(String.format("%d",datapointsCount));
// Remote Database Information // Remote Database Information
tv = (TextView)findViewById(R.id.authStatusTv); tv = (TextView) findViewById(R.id.authStatusTv);
btn = (Button)findViewById(R.id.auth_button); btn = (Button) findViewById(R.id.auth_button);
if (mLm != null) { if (mLm != null) {
if (mLm.mWac.isLoggedIn()) { if (mLm.mWac.isLoggedIn()) {
tv.setText("Authenticated"); tv.setText("Authenticated");
@@ -158,7 +159,7 @@ public class RemoteDbActivity extends AppCompatActivity {
public void onClick(View view) { public void onClick(View view) {
Log.v(TAG, "onAuth"); Log.v(TAG, "onAuth");
Intent i; Intent i;
i =new Intent(mContext, AuthenticateActivity.class); i = new Intent(mContext, AuthenticateActivity.class);
startActivity(i); startActivity(i);
} }
}; };

View File

@@ -209,24 +209,23 @@ public class ReportSeizureActivity extends AppCompatActivity {
} }
private void updateUi() { private void updateUi() {
//Log.v(TAG,"updateUi()"); //Log.v(TAG,"updateUi()");
TextView tv; TextView tv;
Button btn; Button btn;
RadioButton b; RadioButton b;
tv = (TextView)findViewById(R.id.date_day_tv); tv = (TextView) findViewById(R.id.date_day_tv);
tv.setText(String.format("%02d",mDay)); tv.setText(String.format("%02d", mDay));
tv = (TextView)findViewById(R.id.date_mon_tv); tv = (TextView) findViewById(R.id.date_mon_tv);
tv.setText(String.format("%02d",mMonth+1)); // Month counted from zero tv.setText(String.format("%02d", mMonth + 1)); // Month counted from zero
tv = (TextView)findViewById(R.id.date_year_tv); tv = (TextView) findViewById(R.id.date_year_tv);
tv.setText(String.format("%04d",mYear)); tv.setText(String.format("%04d", mYear));
tv = (TextView)findViewById(R.id.time_hh_tv); tv = (TextView) findViewById(R.id.time_hh_tv);
tv.setText(String.format("%02d",mHour)); tv.setText(String.format("%02d", mHour));
tv = (TextView)findViewById(R.id.time_mm_tv); tv = (TextView) findViewById(R.id.time_mm_tv);
tv.setText(String.format("%02d",mMinute)); tv.setText(String.format("%02d", mMinute));
tv = (TextView)findViewById(R.id.msg_tv); tv = (TextView) findViewById(R.id.msg_tv);
tv.setText(mMsg); tv.setText(mMsg);
// Populate event type button group if necessary // Populate event type button group if necessary
@@ -250,12 +249,12 @@ public class ReportSeizureActivity extends AppCompatActivity {
if (b != null) { if (b != null) {
seizureTypeStr = b.getText().toString(); seizureTypeStr = b.getText().toString();
} }
Log.i(TAG,"updateUi - SeizureType="+seizureTypeStr); Log.i(TAG, "updateUi - SeizureType=" + seizureTypeStr);
// Populate the event sub-types radio button list. // Populate the event sub-types radio button list.
Log.v(TAG,"updateUi() - meventsubtypeshashmap="+mEventSubTypesHashMap+", mEventSubtypesListChanged="+mEventSubTypesListChanged); Log.v(TAG, "updateUi() - meventsubtypeshashmap=" + mEventSubTypesHashMap + ", mEventSubtypesListChanged=" + mEventSubTypesListChanged);
if (mEventSubTypesHashMap != null && mRedrawEventSubTypesList) { if (mEventSubTypesHashMap != null && mRedrawEventSubTypesList) {
Log.v(TAG,"UpdateUi() - populating event sub types list"); Log.v(TAG, "UpdateUi() - populating event sub types list");
if (seizureTypeStr != null) { if (seizureTypeStr != null) {
// based on https://androidexample.com/create-a-simple-listview // based on https://androidexample.com/create-a-simple-listview
ArrayList<String> subtypesArrayList = mEventSubTypesHashMap.get(seizureTypeStr); ArrayList<String> subtypesArrayList = mEventSubTypesHashMap.get(seizureTypeStr);
@@ -281,8 +280,8 @@ public class ReportSeizureActivity extends AppCompatActivity {
String notesStr = null; String notesStr = null;
Log.v(TAG, "onOk"); Log.v(TAG, "onOk");
//SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateStr=String.format("%4d-%02d-%02d %02d:%02d:30",mYear,mMonth+1,mDay, mHour, mMinute); String dateStr = String.format("%4d-%02d-%02d %02d:%02d:30", mYear, mMonth + 1, mDay, mHour, mMinute);
Log.v(TAG, "onOk() - dateSTr="+dateStr); Log.v(TAG, "onOk() - dateSTr=" + dateStr);
// Read seizure type from radio buttons // Read seizure type from radio buttons
int checkedRadioButtonId = mEventTypeRg.getCheckedRadioButtonId(); int checkedRadioButtonId = mEventTypeRg.getCheckedRadioButtonId();
@@ -290,19 +289,19 @@ public class ReportSeizureActivity extends AppCompatActivity {
if (b != null) { if (b != null) {
seizureTypeStr = b.getText().toString(); seizureTypeStr = b.getText().toString();
} }
Log.i(TAG,"onOk() - SeizureType="+seizureTypeStr); Log.i(TAG, "onOk() - SeizureType=" + seizureTypeStr);
checkedRadioButtonId = mEventSubTypeRg.getCheckedRadioButtonId(); checkedRadioButtonId = mEventSubTypeRg.getCheckedRadioButtonId();
b = (RadioButton) findViewById(checkedRadioButtonId); b = (RadioButton) findViewById(checkedRadioButtonId);
if (b != null) { if (b != null) {
seizureSubTypeStr = b.getText().toString(); seizureSubTypeStr = b.getText().toString();
} }
Log.i(TAG,"onOk() - SeizureSubType="+seizureSubTypeStr); Log.i(TAG, "onOk() - SeizureSubType=" + seizureSubTypeStr);
TextView tv = (TextView)findViewById(R.id.eventNotesTv); TextView tv = (TextView) findViewById(R.id.eventNotesTv);
notesStr = tv.getText().toString(); notesStr = tv.getText().toString();
mLm.createLocalEvent(dateStr,5,seizureTypeStr, seizureSubTypeStr, notesStr, mLm.createLocalEvent(dateStr, 5, seizureTypeStr, seizureSubTypeStr, notesStr,
mConnection.mSdServer.mSdData.toSettingsJSON()); mConnection.mSdServer.mSdData.toSettingsJSON());
mUtil.showToast("Seizure Event Created"); mUtil.showToast("Seizure Event Created");
finish(); finish();

View File

@@ -36,7 +36,7 @@ public class SdAlgHr {
mAdaptiveHrBuff = new CircBuf(mAdaptiveHrAlarmWindowDp, -1.0); mAdaptiveHrBuff = new CircBuf(mAdaptiveHrAlarmWindowDp, -1.0);
mAverageHrBuff = new CircBuf(mAverageHrAlarmWindowDp, -1.0); mAverageHrBuff = new CircBuf(mAverageHrAlarmWindowDp, -1.0);
// FIXME - this is a hard coded 3 hour period (at 5 second intervals) // FIXME - this is a hard coded 3 hour period (at 5 second intervals)
mHrHist = new CircBuf((int)(3 * 3600 / 5), -1); mHrHist = new CircBuf((int) (3 * 3600 / 5), -1);
} }
public void close() { public void close() {
@@ -72,34 +72,33 @@ public class SdAlgHr {
mSimpleHrAlarmActive = SP.getBoolean("HRAlarmActive", false); mSimpleHrAlarmActive = SP.getBoolean("HRAlarmActive", false);
mSimpleHrAlarmThreshMin = readDoublePref(SP, "HRThreshMin", "20"); mSimpleHrAlarmThreshMin = readDoublePref(SP, "HRThreshMin", "20");
mSimpleHrAlarmThreshMax = readDoublePref(SP, "HRThreshMax", "150"); mSimpleHrAlarmThreshMax = readDoublePref(SP, "HRThreshMax", "150");
Log.d(TAG,"updatePrefs(): mSimpleHrAlarmActive="+mSimpleHrAlarmActive); Log.d(TAG, "updatePrefs(): mSimpleHrAlarmActive=" + mSimpleHrAlarmActive);
Log.d(TAG,"updatePrefs(): mSimpleHrAlarmThreshMin="+mSimpleHrAlarmThreshMin); Log.d(TAG, "updatePrefs(): mSimpleHrAlarmThreshMin=" + mSimpleHrAlarmThreshMin);
Log.d(TAG,"updatePrefs(): mSimpleHrAlarmThreshMax="+mSimpleHrAlarmThreshMax); Log.d(TAG, "updatePrefs(): mSimpleHrAlarmThreshMax=" + mSimpleHrAlarmThreshMax);
mAdaptiveHrAlarmActive = SP.getBoolean("HRAdaptiveAlarmActive", false); mAdaptiveHrAlarmActive = SP.getBoolean("HRAdaptiveAlarmActive", false);
mAdaptiveHrAlarmWindowSecs = readDoublePref(SP, "HRAdaptiveAlarmWindowSecs", "30"); mAdaptiveHrAlarmWindowSecs = readDoublePref(SP, "HRAdaptiveAlarmWindowSecs", "30");
mAdaptiveHrAlarmWindowDp = (int)Math.round(mAdaptiveHrAlarmWindowSecs/5.0); mAdaptiveHrAlarmWindowDp = (int) Math.round(mAdaptiveHrAlarmWindowSecs / 5.0);
mAdaptiveHrAlarmThresh = readDoublePref(SP, "HRAdaptiveAlarmThresh", "20"); mAdaptiveHrAlarmThresh = readDoublePref(SP, "HRAdaptiveAlarmThresh", "20");
Log.d(TAG,"updatePrefs(): mAdaptiveHrAlarmActive="+mAdaptiveHrAlarmActive); Log.d(TAG, "updatePrefs(): mAdaptiveHrAlarmActive=" + mAdaptiveHrAlarmActive);
Log.d(TAG,"updatePrefs(): mAdaptiveHrWindowSecs="+mAdaptiveHrAlarmWindowSecs); Log.d(TAG, "updatePrefs(): mAdaptiveHrWindowSecs=" + mAdaptiveHrAlarmWindowSecs);
Log.d(TAG,"updatePrefs(): mAdaptiveHrWindowDp="+mAdaptiveHrAlarmWindowDp); Log.d(TAG, "updatePrefs(): mAdaptiveHrWindowDp=" + mAdaptiveHrAlarmWindowDp);
Log.d(TAG,"updatePrefs(): mAdaptiveHrAlarmThresh="+mAdaptiveHrAlarmThresh); Log.d(TAG, "updatePrefs(): mAdaptiveHrAlarmThresh=" + mAdaptiveHrAlarmThresh);
mAverageHrAlarmActive = SP.getBoolean("HRAverageAlarmActive", false); mAverageHrAlarmActive = SP.getBoolean("HRAverageAlarmActive", false);
mAverageHrAlarmWindowSecs = readDoublePref(SP, "HRAverageAlarmWindowSecs", "120"); mAverageHrAlarmWindowSecs = readDoublePref(SP, "HRAverageAlarmWindowSecs", "120");
mAverageHrAlarmWindowDp = (int)Math.round(mAverageHrAlarmWindowSecs/5.0); mAverageHrAlarmWindowDp = (int) Math.round(mAverageHrAlarmWindowSecs / 5.0);
mAverageHrAlarmThreshMin = readDoublePref(SP, "HRAverageAlarmThreshMin", "40"); mAverageHrAlarmThreshMin = readDoublePref(SP, "HRAverageAlarmThreshMin", "40");
mAverageHrAlarmThreshMax = readDoublePref(SP, "HRAverageAlarmThreshMax", "120"); mAverageHrAlarmThreshMax = readDoublePref(SP, "HRAverageAlarmThreshMax", "120");
Log.d(TAG,"updatePrefs(): mAverageHrAlarmActive="+mAverageHrAlarmActive); Log.d(TAG, "updatePrefs(): mAverageHrAlarmActive=" + mAverageHrAlarmActive);
Log.d(TAG,"updatePrefs(): mAverageHrAlarmWindowSecs="+mAverageHrAlarmWindowSecs); Log.d(TAG, "updatePrefs(): mAverageHrAlarmWindowSecs=" + mAverageHrAlarmWindowSecs);
Log.d(TAG,"updatePrefs(): mAverageHrAlarmWindowDp="+mAverageHrAlarmWindowDp); Log.d(TAG, "updatePrefs(): mAverageHrAlarmWindowDp=" + mAverageHrAlarmWindowDp);
Log.d(TAG,"updatePrefs(): mAverageHrAlarmThreshMin="+mAverageHrAlarmThreshMin); Log.d(TAG, "updatePrefs(): mAverageHrAlarmThreshMin=" + mAverageHrAlarmThreshMin);
Log.d(TAG,"updatePrefs(): mAverageHrAlarmThreshMax="+mAverageHrAlarmThreshMax); Log.d(TAG, "updatePrefs(): mAverageHrAlarmThreshMax=" + mAverageHrAlarmThreshMax);
} }
private boolean checkSimpleHr(double hrVal) { private boolean checkSimpleHr(double hrVal) {
/** /**
* Check heart rate value against simple thresholds * Check heart rate value against simple thresholds
@@ -107,15 +106,16 @@ public class SdAlgHr {
boolean retVal = false; boolean retVal = false;
if (mSimpleHrAlarmActive) { if (mSimpleHrAlarmActive) {
if ((hrVal > mSimpleHrAlarmThreshMax) if ((hrVal > mSimpleHrAlarmThreshMax)
|| (hrVal <mSimpleHrAlarmThreshMin)) { || (hrVal < mSimpleHrAlarmThreshMin)) {
retVal = true; retVal = true;
} }
} }
return(retVal); return (retVal);
} }
/** /**
* Returns the average heart rate being used by the Adaptive heart rate algorithm * Returns the average heart rate being used by the Adaptive heart rate algorithm
*
* @return Average Heart reate in bpm. * @return Average Heart reate in bpm.
*/ */
public double getAdaptiveHrAverage() { public double getAdaptiveHrAverage() {
@@ -130,10 +130,13 @@ public class SdAlgHr {
return mAdaptiveHrBuff; return mAdaptiveHrBuff;
} }
public CircBuf getHrHistBuff() { return mHrHist; } public CircBuf getHrHistBuff() {
return mHrHist;
}
/** /**
* Returns the average heart rate being used by the Average heart rate algorithm * Returns the average heart rate being used by the Average heart rate algorithm
*
* @return Average Heart rate in bpm. * @return Average Heart rate in bpm.
*/ */
public double getAverageHrAverage() { public double getAverageHrAverage() {
@@ -156,9 +159,9 @@ public class SdAlgHr {
if (hrVal > hrThreshMax) { if (hrVal > hrThreshMax) {
retVal = true; retVal = true;
} }
Log.d(TAG, "checkAdaptiveHr() - hrVal="+hrVal+", avHr="+avHr+", thresholds=("+hrThreshMin+", "+hrThreshMax+"): Alarm="+retVal); Log.d(TAG, "checkAdaptiveHr() - hrVal=" + hrVal + ", avHr=" + avHr + ", thresholds=(" + hrThreshMin + ", " + hrThreshMax + "): Alarm=" + retVal);
return(retVal); return (retVal);
} }
private boolean checkAverageHr(double hrVal) { private boolean checkAverageHr(double hrVal) {
@@ -172,12 +175,11 @@ public class SdAlgHr {
if (avHr > mAverageHrAlarmThreshMax) { if (avHr > mAverageHrAlarmThreshMax) {
retVal = true; retVal = true;
} }
Log.d(TAG, "checkAverageHr() - hrVal="+hrVal+", avHr="+avHr+", thresholds=("+mAverageHrAlarmThreshMin+", "+mAverageHrAlarmThreshMin+"): Alarm="+retVal); Log.d(TAG, "checkAverageHr() - hrVal=" + hrVal + ", avHr=" + avHr + ", thresholds=(" + mAverageHrAlarmThreshMin + ", " + mAverageHrAlarmThreshMin + "): Alarm=" + retVal);
return(retVal); return (retVal);
} }
public ArrayList<Boolean> checkHr(double hrVal) { public ArrayList<Boolean> checkHr(double hrVal) {
/** /**
* Checks the current Heart Rate reading hrVal against the * Checks the current Heart Rate reading hrVal against the
@@ -185,7 +187,7 @@ public class SdAlgHr {
* and returns an ArrayList of the alarm status of each algorithm in the above order. * and returns an ArrayList of the alarm status of each algorithm in the above order.
* true=ALARM, false=OK. * true=ALARM, false=OK.
*/ */
Log.v(TAG, "checkHr("+hrVal+")"); Log.v(TAG, "checkHr(" + hrVal + ")");
mAdaptiveHrBuff.add(hrVal); mAdaptiveHrBuff.add(hrVal);
mAverageHrBuff.add(hrVal); mAverageHrBuff.add(hrVal);
mHrHist.add(hrVal); mHrHist.add(hrVal);
@@ -193,7 +195,7 @@ public class SdAlgHr {
retVal.add(checkSimpleHr(hrVal)); retVal.add(checkSimpleHr(hrVal));
retVal.add(checkAdaptiveHr(hrVal)); retVal.add(checkAdaptiveHr(hrVal));
retVal.add(checkAverageHr(hrVal)); retVal.add(checkAverageHr(hrVal));
return(retVal); return (retVal);
} }
} }

View File

@@ -99,6 +99,7 @@ public class SdAlgNn {
* getPseizureFmt1 - calculate probability of sdData representing seizure-like movement * getPseizureFmt1 - calculate probability of sdData representing seizure-like movement
* using a model with input format #1, which is a simple vector of 125 accelerometer vector * using a model with input format #1, which is a simple vector of 125 accelerometer vector
* magnitude readings. * magnitude readings.
*
* @param sdData - seizure detector data as input to the model * @param sdData - seizure detector data as input to the model
* @return probability of data representing seizure-like movement. * @return probability of data representing seizure-like movement.
*/ */
@@ -125,7 +126,7 @@ public class SdAlgNn {
double stdDev; double stdDev;
stdDev = calcRawDataStd(sdData); stdDev = calcRawDataStd(sdData);
if (stdDev < mSdThresh) { if (stdDev < mSdThresh) {
Log.d(TAG, "getPseizure - acceleration stdev below movement threshold: std="+stdDev+", thresh="+mSdThresh); Log.d(TAG, "getPseizure - acceleration stdev below movement threshold: std=" + stdDev + ", thresh=" + mSdThresh);
return (0); return (0);
} }
@@ -135,11 +136,11 @@ public class SdAlgNn {
pSeizure = getPseizureFmt1(sdData); pSeizure = getPseizureFmt1(sdData);
break; break;
default: default:
Log.e(TAG,"getPSeizure - invalid model ID "+mModelId); Log.e(TAG, "getPSeizure - invalid model ID " + mModelId);
pSeizure = 0; pSeizure = 0;
} }
return(pSeizure); return (pSeizure);
} }
private double calcRawDataStd(SdData sdData) { private double calcRawDataStd(SdData sdData) {

View File

@@ -182,7 +182,7 @@ public class SdData implements Parcelable {
try { try {
mO2Sat = jo.optDouble("o2Sat"); mO2Sat = jo.optDouble("o2Sat");
} catch (Exception e) { } catch (Exception e) {
Log.w(TAG,"Error parsing o2Sat value"); Log.w(TAG, "Error parsing o2Sat value");
mO2Sat = -1; mO2Sat = -1;
} }
haveData = true; haveData = true;
@@ -249,7 +249,7 @@ public class SdData implements Parcelable {
jsonObj.put("rawData3D", raw3DArr); jsonObj.put("rawData3D", raw3DArr);
retval = jsonObj.toString(); retval = jsonObj.toString();
Log.v(TAG,"retval rawData="+retval); Log.v(TAG, "retval rawData=" + retval);
} catch (Exception ex) { } catch (Exception ex) {
Log.v(TAG, "Error Creating Data Object - " + ex.toString()); Log.v(TAG, "Error Creating Data Object - " + ex.toString());
retval = "Error Creating Data Object - " + ex.toString(); retval = "Error Creating Data Object - " + ex.toString();
@@ -302,7 +302,7 @@ public class SdData implements Parcelable {
jsonObj.put("o2SatAlarmStanding", mO2SatAlarmStanding); jsonObj.put("o2SatAlarmStanding", mO2SatAlarmStanding);
jsonObj.put("o2SatThreshMin", mO2SatThreshMin); jsonObj.put("o2SatThreshMin", mO2SatThreshMin);
jsonObj.put("dataSourceName", dataSourceName); jsonObj.put("dataSourceName", dataSourceName);
Log.v(TAG,"phoneAppVersion="+phoneAppVersion); Log.v(TAG, "phoneAppVersion=" + phoneAppVersion);
jsonObj.put("phoneAppVersion", phoneAppVersion); jsonObj.put("phoneAppVersion", phoneAppVersion);
jsonObj.put("watchPartNo", watchPartNo); jsonObj.put("watchPartNo", watchPartNo);
jsonObj.put("watchSdName", watchSdName); jsonObj.put("watchSdName", watchSdName);

View File

@@ -154,7 +154,6 @@ public abstract class SdDataSource {
} }
// Start timer to check status of watch regularly. // Start timer to check status of watch regularly.
mDataStatusTime = new Time(Time.getCurrentTimezone()); mDataStatusTime = new Time(Time.getCurrentTimezone());
// use a timer to check the status of the pebble app on the same frequency // use a timer to check the status of the pebble app on the same frequency
@@ -342,7 +341,7 @@ public abstract class SdDataSource {
} }
} catch (JSONException e) { } catch (JSONException e) {
// If we get an error, just set rawData3D to zero // If we get an error, just set rawData3D to zero
Log.i(TAG,"updateFromJSON - error parsing 3D data - setting it to zero"); Log.i(TAG, "updateFromJSON - error parsing 3D data - setting it to zero");
for (i = 0; i < mSdData.rawData3D.length; i++) { for (i = 0; i < mSdData.rawData3D.length; i++) {
mSdData.rawData3D[i] = 0.; mSdData.rawData3D[i] = 0.;
} }
@@ -449,7 +448,7 @@ public abstract class SdDataSource {
mSampleFreq = 25; mSampleFreq = 25;
double freqRes = 1.0 * mSampleFreq / mSdData.mNsamp; double freqRes = 1.0 * mSampleFreq / mSdData.mNsamp;
Log.v(TAG, "doAnalysis(): mSampleFreq=" + mSampleFreq + " mNSamp=" + mSdData.mNsamp + ": freqRes=" + freqRes); Log.v(TAG, "doAnalysis(): mSampleFreq=" + mSampleFreq + " mNSamp=" + mSdData.mNsamp + ": freqRes=" + freqRes);
Log.v(TAG,"doAnalysis(): rawData=" + Arrays.toString(mSdData.rawData)); Log.v(TAG, "doAnalysis(): rawData=" + Arrays.toString(mSdData.rawData));
// Set the frequency bounds for the analysis in fft output bin numbers. // Set the frequency bounds for the analysis in fft output bin numbers.
nMin = (int) (mAlarmFreqMin / freqRes); nMin = (int) (mAlarmFreqMin / freqRes);
nMax = (int) (mAlarmFreqMax / freqRes); nMax = (int) (mAlarmFreqMax / freqRes);
@@ -526,11 +525,11 @@ public abstract class SdDataSource {
Log.e(TAG, "doAnalysis - Exception during Analysis"); Log.e(TAG, "doAnalysis - Exception during Analysis");
mUtil.writeToSysLogFile("doAnalysis - Exception during analysis - " + e.toString()); mUtil.writeToSysLogFile("doAnalysis - Exception during analysis - " + e.toString());
mUtil.writeToSysLogFile("doAnalysis: Exception at Line Number: " + e.getCause().getStackTrace()[0].getLineNumber() + ", " + e.getCause().getStackTrace()[0].toString()); mUtil.writeToSysLogFile("doAnalysis: Exception at Line Number: " + e.getCause().getStackTrace()[0].getLineNumber() + ", " + e.getCause().getStackTrace()[0].toString());
mUtil.writeToSysLogFile("doAnalysis: mSdData.mNsamp="+mSdData.mNsamp); mUtil.writeToSysLogFile("doAnalysis: mSdData.mNsamp=" + mSdData.mNsamp);
mUtil.writeToSysLogFile("doAnalysis: alarmFreqMin="+mAlarmFreqMin+" nMin="+nMin); mUtil.writeToSysLogFile("doAnalysis: alarmFreqMin=" + mAlarmFreqMin + " nMin=" + nMin);
mUtil.writeToSysLogFile("doAnalysis: alarmFreqMax="+mAlarmFreqMax+" nMax="+nMax); mUtil.writeToSysLogFile("doAnalysis: alarmFreqMax=" + mAlarmFreqMax + " nMax=" + nMax);
mUtil.writeToSysLogFile("doAnalysis: nFreqCutoff.="+nFreqCutoff); mUtil.writeToSysLogFile("doAnalysis: nFreqCutoff.=" + nFreqCutoff);
mUtil.writeToSysLogFile("doAnalysis: fft.length="+fft.length); mUtil.writeToSysLogFile("doAnalysis: fft.length=" + fft.length);
mWatchAppRunningCheck = false; mWatchAppRunningCheck = false;
} }
@@ -547,7 +546,7 @@ public abstract class SdDataSource {
o2SatCheck(); o2SatCheck();
fallCheck(); fallCheck();
muteCheck(); muteCheck();
Log.v(TAG,"after fallCheck, mSdData.fallAlarmStanding="+mSdData.fallAlarmStanding); Log.v(TAG, "after fallCheck, mSdData.fallAlarmStanding=" + mSdData.fallAlarmStanding);
mSdDataReceiver.onSdDataReceived(mSdData); // and tell SdServer we have received data. mSdDataReceiver.onSdDataReceived(mSdData); // and tell SdServer we have received data.
} }
@@ -564,20 +563,20 @@ public abstract class SdDataSource {
// Avoid potential divide by zero issue // Avoid potential divide by zero issue
if (mSdData.specPower == 0) if (mSdData.specPower == 0)
mSdData.specPower = 1; mSdData.specPower = 1;
Log.v(TAG, "alarmCheck() - roiPower="+mSdData.roiPower+" specPower="+ mSdData.specPower+" ratio="+10*mSdData.roiPower/ mSdData.specPower); Log.v(TAG, "alarmCheck() - roiPower=" + mSdData.roiPower + " specPower=" + mSdData.specPower + " ratio=" + 10 * mSdData.roiPower / mSdData.specPower);
if (mSdData.mOsdAlarmActive) { if (mSdData.mOsdAlarmActive) {
// Is the current set of data representing an alarm state? // Is the current set of data representing an alarm state?
if ((mSdData.roiPower > mAlarmThresh) && ((10 * mSdData.roiPower / mSdData.specPower) > mAlarmRatioThresh)) { if ((mSdData.roiPower > mAlarmThresh) && ((10 * mSdData.roiPower / mSdData.specPower) > mAlarmRatioThresh)) {
inAlarm = true; inAlarm = true;
mSdData.alarmCause = mSdData.alarmCause+"OsdAlg "; mSdData.alarmCause = mSdData.alarmCause + "OsdAlg ";
} }
} }
if (mSdData.mCnnAlarmActive) { if (mSdData.mCnnAlarmActive) {
if (mSdData.mPseizure > 0.5) { if (mSdData.mPseizure > 0.5) {
inAlarm = true; inAlarm = true;
mSdData.alarmCause = mSdData.alarmCause+"CnnAlg "; mSdData.alarmCause = mSdData.alarmCause + "CnnAlg ";
} }
} }
@@ -646,7 +645,7 @@ public abstract class SdDataSource {
mSdData.mHRAlarmStanding = true; mSdData.mHRAlarmStanding = true;
mSdData.mAdaptiveHrAlarmStanding = false; mSdData.mAdaptiveHrAlarmStanding = false;
mSdData.mAverageHrAlarmStanding = false; mSdData.mAverageHrAlarmStanding = false;
mSdData.alarmCause = mSdData.alarmCause+"HrNull "; mSdData.alarmCause = mSdData.alarmCause + "HrNull ";
} else { } else {
Log.i(TAG, "Heart Rate Fault (HR<0)"); Log.i(TAG, "Heart Rate Fault (HR<0)");
@@ -659,13 +658,13 @@ public abstract class SdDataSource {
mSdData.mHRFaultStanding = false; mSdData.mHRFaultStanding = false;
mSdData.mHRAlarmStanding = checkResults.get(0); mSdData.mHRAlarmStanding = checkResults.get(0);
if (mSdData.mHRAlarmStanding) if (mSdData.mHRAlarmStanding)
mSdData.alarmCause = mSdData.alarmCause+"HR "; mSdData.alarmCause = mSdData.alarmCause + "HR ";
mSdData.mAdaptiveHrAlarmStanding = checkResults.get(1); mSdData.mAdaptiveHrAlarmStanding = checkResults.get(1);
if (mSdData.mAdaptiveHrAlarmStanding) if (mSdData.mAdaptiveHrAlarmStanding)
mSdData.alarmCause = mSdData.alarmCause+"HR_ADAPT "; mSdData.alarmCause = mSdData.alarmCause + "HR_ADAPT ";
mSdData.mAverageHrAlarmStanding = checkResults.get(2); mSdData.mAverageHrAlarmStanding = checkResults.get(2);
if (mSdData.mAverageHrAlarmStanding) if (mSdData.mAverageHrAlarmStanding)
mSdData.alarmCause = mSdData.alarmCause+"HR_AVG "; mSdData.alarmCause = mSdData.alarmCause + "HR_AVG ";
// Show an ALARM state if any of the HR alarms is standing. // Show an ALARM state if any of the HR alarms is standing.
if (mSdData.mHRAlarmStanding | mSdData.mAdaptiveHrAlarmStanding | mSdData.mAverageHrAlarmStanding) { if (mSdData.mHRAlarmStanding | mSdData.mAdaptiveHrAlarmStanding | mSdData.mAverageHrAlarmStanding) {
mSdData.alarmState = 2; mSdData.alarmState = 2;
@@ -693,17 +692,17 @@ public abstract class SdDataSource {
Log.i(TAG, "Oxygen Saturation Null - Alarming"); Log.i(TAG, "Oxygen Saturation Null - Alarming");
mSdData.mO2SatFaultStanding = false; mSdData.mO2SatFaultStanding = false;
mSdData.mO2SatAlarmStanding = true; mSdData.mO2SatAlarmStanding = true;
mSdData.alarmCause = mSdData.alarmCause+"O2_NULL "; mSdData.alarmCause = mSdData.alarmCause + "O2_NULL ";
} else { } else {
Log.i(TAG, "Oxygen Saturation Fault (O2Sat<0)"); Log.i(TAG, "Oxygen Saturation Fault (O2Sat<0)");
mSdData.mO2SatFaultStanding = true; mSdData.mO2SatFaultStanding = true;
mSdData.mO2SatAlarmStanding = false; mSdData.mO2SatAlarmStanding = false;
} }
} else if (mSdData.mO2Sat < mSdData.mO2SatThreshMin) { } else if (mSdData.mO2Sat < mSdData.mO2SatThreshMin) {
Log.i(TAG, "Oxygen Saturation Abnormal - " + mSdData.mO2Sat + " %"); Log.i(TAG, "Oxygen Saturation Abnormal - " + mSdData.mO2Sat + " %");
mSdData.mO2SatFaultStanding = false; mSdData.mO2SatFaultStanding = false;
mSdData.mO2SatAlarmStanding = true; mSdData.mO2SatAlarmStanding = true;
mSdData.alarmCause = mSdData.alarmCause+"O2SAT "; mSdData.alarmCause = mSdData.alarmCause + "O2SAT ";
} else { } else {
mSdData.mO2SatFaultStanding = false; mSdData.mO2SatFaultStanding = false;
mSdData.mO2SatAlarmStanding = false; mSdData.mO2SatAlarmStanding = false;
@@ -740,12 +739,12 @@ public abstract class SdDataSource {
if (mSdData.rawData[i + j] < minAcc) minAcc = mSdData.rawData[i + j]; if (mSdData.rawData[i + j] < minAcc) minAcc = mSdData.rawData[i + j];
if (mSdData.rawData[i + j] > maxAcc) maxAcc = mSdData.rawData[i + j]; if (mSdData.rawData[i + j] > maxAcc) maxAcc = mSdData.rawData[i + j];
} }
Log.d(TAG, "check_fall() - minAcc=" + minAcc +" (mFallThreshMin="+mFallThreshMin+ "), maxAcc=" + maxAcc+" (mFallThreshMax="+mFallThreshMax+")") ; Log.d(TAG, "check_fall() - minAcc=" + minAcc + " (mFallThreshMin=" + mFallThreshMin + "), maxAcc=" + maxAcc + " (mFallThreshMax=" + mFallThreshMax + ")");
if ((minAcc < mFallThreshMin) && (maxAcc > mFallThreshMax)) { if ((minAcc < mFallThreshMin) && (maxAcc > mFallThreshMax)) {
Log.d(TAG, "check_fall() ****FALL DETECTED***** minAcc=" + minAcc + ", maxAcc=" + maxAcc); Log.d(TAG, "check_fall() ****FALL DETECTED***** minAcc=" + minAcc + ", maxAcc=" + maxAcc);
Log.d(TAG, "check_fall() - ****FALL DETECTED****"); Log.d(TAG, "check_fall() - ****FALL DETECTED****");
mSdData.fallAlarmStanding = true; mSdData.fallAlarmStanding = true;
mSdData.alarmCause = mSdData.alarmCause+"FALL "; mSdData.alarmCause = mSdData.alarmCause + "FALL ";
return; return;
} }
if (mMute != 0) { if (mMute != 0) {
@@ -825,13 +824,14 @@ public abstract class SdDataSource {
// Check we have seen a fidget within the required period, or else assume a fault because watch is not being worn // Check we have seen a fidget within the required period, or else assume a fault because watch is not being worn
if (mFidgetDetectorEnabled) { if (mFidgetDetectorEnabled) {
if (mLastFidget == null) mLastFidget = tnow; // Initialise last fidget time on startup. if (mLastFidget == null)
mLastFidget = tnow; // Initialise last fidget time on startup.
double accStd = calcRawDataStd(mSdData); double accStd = calcRawDataStd(mSdData);
if (accStd > mFidgetThreshold) { if (accStd > mFidgetThreshold) {
mLastFidget = tnow; mLastFidget = tnow;
} else { } else {
Log.d(TAG,"onStatus() - Fidget Detector - low movement - is watch being worn?"); Log.d(TAG, "onStatus() - Fidget Detector - low movement - is watch being worn?");
tdiff = (tnow.toMillis(false) - mLastFidget.toMillis(false)); tdiff = (tnow.toMillis(false) - mLastFidget.toMillis(false));
if (tdiff > (mFidgetPeriod) * 60 * 1000) { if (tdiff > (mFidgetPeriod) * 60 * 1000) {
Log.e(TAG, "onStatus() - Fidget Not Detected - is watch being worn?"); Log.e(TAG, "onStatus() - Fidget Not Detected - is watch being worn?");
@@ -878,7 +878,7 @@ public abstract class SdDataSource {
mSdData.mHrFrozenFaultStanding = false; mSdData.mHrFrozenFaultStanding = false;
} else { } else {
tdiff = (tnow.toMillis(false) - mHrStatusTime.toMillis(false)); tdiff = (tnow.toMillis(false) - mHrStatusTime.toMillis(false));
if (tdiff > mHrFrozenPeriod *1000.) { if (tdiff > mHrFrozenPeriod * 1000.) {
mSdData.mHrFrozenFaultStanding = true; mSdData.mHrFrozenFaultStanding = true;
} else { } else {
mSdData.mHrFrozenFaultStanding = false; mSdData.mHrFrozenFaultStanding = false;
@@ -889,7 +889,7 @@ public abstract class SdDataSource {
void nnAnalysis() { void nnAnalysis() {
//Check the current set of data using the neural network model to look for alarms. //Check the current set of data using the neural network model to look for alarms.
Log.d(TAG,"nnAnalysis"); Log.d(TAG, "nnAnalysis");
if (mSdData.mCnnAlarmActive) { if (mSdData.mCnnAlarmActive) {
float pSeizure = mSdAlgNn.getPseizure(mSdData); float pSeizure = mSdAlgNn.getPseizure(mSdData);
Log.d(TAG, "nnAnalysis - nnResult=" + pSeizure); Log.d(TAG, "nnAnalysis - nnResult=" + pSeizure);
@@ -904,9 +904,9 @@ public abstract class SdDataSource {
* Read a preference value, and return it as a double. * Read a preference value, and return it as a double.
* FIXME - this should be in osdUtil so other classes can use it. * FIXME - this should be in osdUtil so other classes can use it.
* *
* @param SP - Shared Preferences object * @param SP - Shared Preferences object
* @param prefName - name of preference to read. * @param prefName - name of preference to read.
* @param defVal - default value if it is not stored. * @param defVal - default value if it is not stored.
* @return double value of the stored specified preference, or the default value. * @return double value of the stored specified preference, or the default value.
*/ */
private double readDoublePref(SharedPreferences SP, String prefName, String defVal) { private double readDoublePref(SharedPreferences SP, String prefName, String defVal) {
@@ -937,10 +937,10 @@ public abstract class SdDataSource {
String appRestartTimeoutStr = SP.getString("AppRestartTimeout", "10"); String appRestartTimeoutStr = SP.getString("AppRestartTimeout", "10");
mAppRestartTimeout = Integer.parseInt(appRestartTimeoutStr); mAppRestartTimeout = Integer.parseInt(appRestartTimeoutStr);
Log.v(TAG, "updatePrefs() - mAppRestartTimeout = " + mAppRestartTimeout); Log.v(TAG, "updatePrefs() - mAppRestartTimeout = " + mAppRestartTimeout);
mUtil.writeToSysLogFile( "updatePrefs() - mAppRestartTimeout = " + mAppRestartTimeout); mUtil.writeToSysLogFile("updatePrefs() - mAppRestartTimeout = " + mAppRestartTimeout);
} catch (Exception ex) { } catch (Exception ex) {
Log.v(TAG, "updatePrefs() - Problem with AppRestartTimeout preference!"); Log.v(TAG, "updatePrefs() - Problem with AppRestartTimeout preference!");
mUtil.writeToSysLogFile( "updatePrefs() - Problem with AppRestartTimeout preference!"); mUtil.writeToSysLogFile("updatePrefs() - Problem with AppRestartTimeout preference!");
Toast toast = Toast.makeText(mContext, "Problem Parsing AppRestartTimeout Preference", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(mContext, "Problem Parsing AppRestartTimeout Preference", Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
@@ -950,10 +950,10 @@ public abstract class SdDataSource {
String faultTimerPeriodStr = SP.getString("FaultTimerPeriod", "30"); String faultTimerPeriodStr = SP.getString("FaultTimerPeriod", "30");
mFaultTimerPeriod = Integer.parseInt(faultTimerPeriodStr); mFaultTimerPeriod = Integer.parseInt(faultTimerPeriodStr);
Log.v(TAG, "updatePrefs() - mFaultTimerPeriod = " + mFaultTimerPeriod); Log.v(TAG, "updatePrefs() - mFaultTimerPeriod = " + mFaultTimerPeriod);
mUtil.writeToSysLogFile( "updatePrefs() - mFaultTimerPeriod = " + mFaultTimerPeriod); mUtil.writeToSysLogFile("updatePrefs() - mFaultTimerPeriod = " + mFaultTimerPeriod);
} catch (Exception ex) { } catch (Exception ex) {
Log.v(TAG, "updatePrefs() - Problem with FaultTimerPeriod preference!"); Log.v(TAG, "updatePrefs() - Problem with FaultTimerPeriod preference!");
mUtil.writeToSysLogFile( "updatePrefs() - Problem with FaultTimerPeriod preference!"); mUtil.writeToSysLogFile("updatePrefs() - Problem with FaultTimerPeriod preference!");
Toast toast = Toast.makeText(mContext, "Problem Parsing FaultTimerPeriod Preference", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(mContext, "Problem Parsing FaultTimerPeriod Preference", Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
@@ -964,7 +964,7 @@ public abstract class SdDataSource {
mFidgetPeriod = readDoublePref(SP, "FidgetDetectorPeriod", "20"); // minutes mFidgetPeriod = readDoublePref(SP, "FidgetDetectorPeriod", "20"); // minutes
Log.v(TAG, "updatePrefs() - mFidgetPeriod = " + mFidgetPeriod); Log.v(TAG, "updatePrefs() - mFidgetPeriod = " + mFidgetPeriod);
mFidgetThreshold = readDoublePref(SP, "FidgetDetectorThreshold", "0.6 "); mFidgetThreshold = readDoublePref(SP, "FidgetDetectorThreshold", "0.6 ");
Log.d(TAG,"updatePrefs(): mFidgetThreshold="+mFidgetThreshold); Log.d(TAG, "updatePrefs(): mFidgetThreshold=" + mFidgetThreshold);
} catch (Exception ex) { } catch (Exception ex) {
Log.v(TAG, "updatePrefs() - Problem with FidgetDetector preferences!"); Log.v(TAG, "updatePrefs() - Problem with FidgetDetector preferences!");
@@ -978,57 +978,57 @@ public abstract class SdDataSource {
prefStr = SP.getString("BLE_Device_Addr", "SET_FROM_XML"); prefStr = SP.getString("BLE_Device_Addr", "SET_FROM_XML");
mBleDeviceAddr = prefStr; mBleDeviceAddr = prefStr;
Log.v(TAG, "mBLEDeviceAddr=" + mBleDeviceAddr); Log.v(TAG, "mBLEDeviceAddr=" + mBleDeviceAddr);
mUtil.writeToSysLogFile( "mBLEDeviceAddr=" + mBleDeviceAddr); mUtil.writeToSysLogFile("mBLEDeviceAddr=" + mBleDeviceAddr);
prefStr = SP.getString("BLE_Device_Name", "SET_FROM_XML"); prefStr = SP.getString("BLE_Device_Name", "SET_FROM_XML");
mBleDeviceName = prefStr; mBleDeviceName = prefStr;
Log.v(TAG, "mBLEDeviceName=" + mBleDeviceName); Log.v(TAG, "mBLEDeviceName=" + mBleDeviceName);
mUtil.writeToSysLogFile( "mBLEDeviceName=" + mBleDeviceName); mUtil.writeToSysLogFile("mBLEDeviceName=" + mBleDeviceName);
prefStr = SP.getString("PebbleDebug", "SET_FROM_XML"); prefStr = SP.getString("PebbleDebug", "SET_FROM_XML");
if (prefStr != null) { if (prefStr != null) {
mDebug = (short) Integer.parseInt(prefStr); mDebug = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() Debug = " + mDebug); Log.v(TAG, "updatePrefs() Debug = " + mDebug);
mUtil.writeToSysLogFile( "updatePrefs() Debug = " + mDebug); mUtil.writeToSysLogFile("updatePrefs() Debug = " + mDebug);
prefStr = SP.getString("PebbleDisplaySpectrum", "SET_FROM_XML"); prefStr = SP.getString("PebbleDisplaySpectrum", "SET_FROM_XML");
mDisplaySpectrum = (short) Integer.parseInt(prefStr); mDisplaySpectrum = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() DisplaySpectrum = " + mDisplaySpectrum); Log.v(TAG, "updatePrefs() DisplaySpectrum = " + mDisplaySpectrum);
mUtil.writeToSysLogFile( "updatePrefs() DisplaySpectrum = " + mDisplaySpectrum); mUtil.writeToSysLogFile("updatePrefs() DisplaySpectrum = " + mDisplaySpectrum);
prefStr = SP.getString("PebbleUpdatePeriod", "SET_FROM_XML"); prefStr = SP.getString("PebbleUpdatePeriod", "SET_FROM_XML");
mDataUpdatePeriod = (short) Integer.parseInt(prefStr); mDataUpdatePeriod = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() DataUpdatePeriod = " + mDataUpdatePeriod); Log.v(TAG, "updatePrefs() DataUpdatePeriod = " + mDataUpdatePeriod);
mUtil.writeToSysLogFile( "updatePrefs() DataUpdatePeriod = " + mDataUpdatePeriod); mUtil.writeToSysLogFile("updatePrefs() DataUpdatePeriod = " + mDataUpdatePeriod);
prefStr = SP.getString("MutePeriod", "SET_FROM_XML"); prefStr = SP.getString("MutePeriod", "SET_FROM_XML");
mMutePeriod = (short) Integer.parseInt(prefStr); mMutePeriod = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() MutePeriod = " + mMutePeriod); Log.v(TAG, "updatePrefs() MutePeriod = " + mMutePeriod);
mUtil.writeToSysLogFile( "updatePrefs() MutePeriod = " + mMutePeriod); mUtil.writeToSysLogFile("updatePrefs() MutePeriod = " + mMutePeriod);
prefStr = SP.getString("ManAlarmPeriod", "SET_FROM_XML"); prefStr = SP.getString("ManAlarmPeriod", "SET_FROM_XML");
mManAlarmPeriod = (short) Integer.parseInt(prefStr); mManAlarmPeriod = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() ManAlarmPeriod = " + mManAlarmPeriod); Log.v(TAG, "updatePrefs() ManAlarmPeriod = " + mManAlarmPeriod);
mUtil.writeToSysLogFile( "updatePrefs() ManAlarmPeriod = " + mManAlarmPeriod); mUtil.writeToSysLogFile("updatePrefs() ManAlarmPeriod = " + mManAlarmPeriod);
prefStr = SP.getString("PebbleSdMode", "SET_FROM_XML"); prefStr = SP.getString("PebbleSdMode", "SET_FROM_XML");
mPebbleSdMode = (short) Integer.parseInt(prefStr); mPebbleSdMode = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() PebbleSdMode = " + mPebbleSdMode); Log.v(TAG, "updatePrefs() PebbleSdMode = " + mPebbleSdMode);
mUtil.writeToSysLogFile( "updatePrefs() PebbleSdMode = " + mPebbleSdMode); mUtil.writeToSysLogFile("updatePrefs() PebbleSdMode = " + mPebbleSdMode);
prefStr = SP.getString("SampleFreq", "SET_FROM_XML"); prefStr = SP.getString("SampleFreq", "SET_FROM_XML");
mSampleFreq = (short) Integer.parseInt(prefStr); mSampleFreq = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() SampleFreq = " + mSampleFreq); Log.v(TAG, "updatePrefs() SampleFreq = " + mSampleFreq);
mUtil.writeToSysLogFile( "updatePrefs() SampleFreq = " + mSampleFreq); mUtil.writeToSysLogFile("updatePrefs() SampleFreq = " + mSampleFreq);
prefStr = SP.getString("SamplePeriod", "SET_FROM_XML"); prefStr = SP.getString("SamplePeriod", "SET_FROM_XML");
mSamplePeriod = (short) Integer.parseInt(prefStr); mSamplePeriod = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() AnalysisPeriod = " + mSamplePeriod); Log.v(TAG, "updatePrefs() AnalysisPeriod = " + mSamplePeriod);
mUtil.writeToSysLogFile( "updatePrefs() AnalysisPeriod = " + mSamplePeriod); mUtil.writeToSysLogFile("updatePrefs() AnalysisPeriod = " + mSamplePeriod);
prefStr = SP.getString("AlarmFreqMin", "SET_FROM_XML"); prefStr = SP.getString("AlarmFreqMin", "SET_FROM_XML");
mAlarmFreqMin = (short) Integer.parseInt(prefStr); mAlarmFreqMin = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() AlarmFreqMin = " + mAlarmFreqMin); Log.v(TAG, "updatePrefs() AlarmFreqMin = " + mAlarmFreqMin);
mUtil.writeToSysLogFile( "updatePrefs() AlarmFreqMin = " + mAlarmFreqMin); mUtil.writeToSysLogFile("updatePrefs() AlarmFreqMin = " + mAlarmFreqMin);
prefStr = SP.getString("AlarmFreqMax", "SET_FROM_XML"); prefStr = SP.getString("AlarmFreqMax", "SET_FROM_XML");
mAlarmFreqMax = (short) Integer.parseInt(prefStr); mAlarmFreqMax = (short) Integer.parseInt(prefStr);
@@ -1038,58 +1038,58 @@ public abstract class SdDataSource {
prefStr = SP.getString("WarnTime", "SET_FROM_XML"); prefStr = SP.getString("WarnTime", "SET_FROM_XML");
mWarnTime = (short) Integer.parseInt(prefStr); mWarnTime = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() WarnTime = " + mWarnTime); Log.v(TAG, "updatePrefs() WarnTime = " + mWarnTime);
mUtil.writeToSysLogFile( "updatePrefs() WarnTime = " + mWarnTime); mUtil.writeToSysLogFile("updatePrefs() WarnTime = " + mWarnTime);
prefStr = SP.getString("AlarmTime", "SET_FROM_XML"); prefStr = SP.getString("AlarmTime", "SET_FROM_XML");
mAlarmTime = (short) Integer.parseInt(prefStr); mAlarmTime = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() AlarmTime = " + mAlarmTime); Log.v(TAG, "updatePrefs() AlarmTime = " + mAlarmTime);
mUtil.writeToSysLogFile( "updatePrefs() AlarmTime = " + mAlarmTime); mUtil.writeToSysLogFile("updatePrefs() AlarmTime = " + mAlarmTime);
prefStr = SP.getString("AlarmThresh", "SET_FROM_XML"); prefStr = SP.getString("AlarmThresh", "SET_FROM_XML");
mAlarmThresh = (short) Integer.parseInt(prefStr); mAlarmThresh = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() AlarmThresh = " + mAlarmThresh); Log.v(TAG, "updatePrefs() AlarmThresh = " + mAlarmThresh);
mUtil.writeToSysLogFile( "updatePrefs() AlarmThresh = " + mAlarmThresh); mUtil.writeToSysLogFile("updatePrefs() AlarmThresh = " + mAlarmThresh);
prefStr = SP.getString("AlarmRatioThresh", "SET_FROM_XML"); prefStr = SP.getString("AlarmRatioThresh", "SET_FROM_XML");
mAlarmRatioThresh = (short) Integer.parseInt(prefStr); mAlarmRatioThresh = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() AlarmRatioThresh = " + mAlarmRatioThresh); Log.v(TAG, "updatePrefs() AlarmRatioThresh = " + mAlarmRatioThresh);
mUtil.writeToSysLogFile( "updatePrefs() AlarmRatioThresh = " + mAlarmRatioThresh); mUtil.writeToSysLogFile("updatePrefs() AlarmRatioThresh = " + mAlarmRatioThresh);
mFallActive = SP.getBoolean("FallActive", false); mFallActive = SP.getBoolean("FallActive", false);
Log.v(TAG, "updatePrefs() FallActive = " + mFallActive); Log.v(TAG, "updatePrefs() FallActive = " + mFallActive);
mUtil.writeToSysLogFile( "updatePrefs() FallActive = " + mFallActive); mUtil.writeToSysLogFile("updatePrefs() FallActive = " + mFallActive);
prefStr = SP.getString("FallThreshMin", "SET_FROM_XML"); prefStr = SP.getString("FallThreshMin", "SET_FROM_XML");
mFallThreshMin = (short) Integer.parseInt(prefStr); mFallThreshMin = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() FallThreshMin = " + mFallThreshMin); Log.v(TAG, "updatePrefs() FallThreshMin = " + mFallThreshMin);
mUtil.writeToSysLogFile( "updatePrefs() FallThreshMin = " + mFallThreshMin); mUtil.writeToSysLogFile("updatePrefs() FallThreshMin = " + mFallThreshMin);
prefStr = SP.getString("FallThreshMax", "SET_FROM_XML"); prefStr = SP.getString("FallThreshMax", "SET_FROM_XML");
mFallThreshMax = (short) Integer.parseInt(prefStr); mFallThreshMax = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() FallThreshMax = " + mFallThreshMax); Log.v(TAG, "updatePrefs() FallThreshMax = " + mFallThreshMax);
mUtil.writeToSysLogFile( "updatePrefs() FallThreshMax = " + mFallThreshMax); mUtil.writeToSysLogFile("updatePrefs() FallThreshMax = " + mFallThreshMax);
prefStr = SP.getString("FallWindow", "SET_FROM_XML"); prefStr = SP.getString("FallWindow", "SET_FROM_XML");
mFallWindow = (short) Integer.parseInt(prefStr); mFallWindow = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() FallWindow = " + mFallWindow); Log.v(TAG, "updatePrefs() FallWindow = " + mFallWindow);
mUtil.writeToSysLogFile( "updatePrefs() FallWindow = " + mFallWindow); mUtil.writeToSysLogFile("updatePrefs() FallWindow = " + mFallWindow);
mSdData.mOsdAlarmActive = SP.getBoolean("OsdAlarmActive", false); mSdData.mOsdAlarmActive = SP.getBoolean("OsdAlarmActive", false);
Log.v(TAG, "updatePrefs() OsdAlarmActive = " + mSdData.mOsdAlarmActive); Log.v(TAG, "updatePrefs() OsdAlarmActive = " + mSdData.mOsdAlarmActive);
mUtil.writeToSysLogFile( "updatePrefs() OsdAlarmActive = " + mSdData.mOsdAlarmActive); mUtil.writeToSysLogFile("updatePrefs() OsdAlarmActive = " + mSdData.mOsdAlarmActive);
mSdData.mCnnAlarmActive = SP.getBoolean("CnnAlarmActive", false); mSdData.mCnnAlarmActive = SP.getBoolean("CnnAlarmActive", false);
Log.v(TAG, "updatePrefs() CnnAlarmActive = " + mSdData.mCnnAlarmActive); Log.v(TAG, "updatePrefs() CnnAlarmActive = " + mSdData.mCnnAlarmActive);
mUtil.writeToSysLogFile( "updatePrefs() CnnAlarmActive = " + mSdData.mCnnAlarmActive); mUtil.writeToSysLogFile("updatePrefs() CnnAlarmActive = " + mSdData.mCnnAlarmActive);
mSdData.mHRAlarmActive = SP.getBoolean("HRAlarmActive", false); mSdData.mHRAlarmActive = SP.getBoolean("HRAlarmActive", false);
Log.v(TAG, "updatePrefs() HRAlarmActive = " + mSdData.mHRAlarmActive); Log.v(TAG, "updatePrefs() HRAlarmActive = " + mSdData.mHRAlarmActive);
mUtil.writeToSysLogFile( "updatePrefs() HRAlarmActive = " + mSdData.mHRAlarmActive); mUtil.writeToSysLogFile("updatePrefs() HRAlarmActive = " + mSdData.mHRAlarmActive);
mSdData.mHRNullAsAlarm = SP.getBoolean("HRNullAsAlarm", false); mSdData.mHRNullAsAlarm = SP.getBoolean("HRNullAsAlarm", false);
Log.v(TAG, "updatePrefs() HRNullAsAlarm = " + mSdData.mHRNullAsAlarm); Log.v(TAG, "updatePrefs() HRNullAsAlarm = " + mSdData.mHRNullAsAlarm);
mUtil.writeToSysLogFile( "updatePrefs() HRNullAsAlarm = " + mSdData.mHRNullAsAlarm); mUtil.writeToSysLogFile("updatePrefs() HRNullAsAlarm = " + mSdData.mHRNullAsAlarm);
mHrFrozenAlarm = SP.getBoolean("HrFrozenAlarm", true); mHrFrozenAlarm = SP.getBoolean("HrFrozenAlarm", true);
Log.v(TAG, "updatePrefs() - mHrFrozenAlarm = " + mHrFrozenAlarm); Log.v(TAG, "updatePrefs() - mHrFrozenAlarm = " + mHrFrozenAlarm);
@@ -1098,42 +1098,42 @@ public abstract class SdDataSource {
prefStr = SP.getString("HRThreshMin", "SET_FROM_XML"); prefStr = SP.getString("HRThreshMin", "SET_FROM_XML");
mSdData.mHRThreshMin = (short) Integer.parseInt(prefStr); mSdData.mHRThreshMin = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() HRThreshMin = " + mSdData.mHRThreshMin); Log.v(TAG, "updatePrefs() HRThreshMin = " + mSdData.mHRThreshMin);
mUtil.writeToSysLogFile( "updatePrefs() HRThreshMin = " + mSdData.mHRThreshMin); mUtil.writeToSysLogFile("updatePrefs() HRThreshMin = " + mSdData.mHRThreshMin);
prefStr = SP.getString("HRThreshMax", "SET_FROM_XML"); prefStr = SP.getString("HRThreshMax", "SET_FROM_XML");
mSdData.mHRThreshMax = (short) Integer.parseInt(prefStr); mSdData.mHRThreshMax = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() HRThreshMax = " + mSdData.mHRThreshMax); Log.v(TAG, "updatePrefs() HRThreshMax = " + mSdData.mHRThreshMax);
mUtil.writeToSysLogFile( "updatePrefs() HRThreshMax = " + mSdData.mHRThreshMax); mUtil.writeToSysLogFile("updatePrefs() HRThreshMax = " + mSdData.mHRThreshMax);
mSdData.mAdaptiveHrAlarmActive = SP.getBoolean("HRAdaptiveAlarmActive", false); mSdData.mAdaptiveHrAlarmActive = SP.getBoolean("HRAdaptiveAlarmActive", false);
mSdData.mAdaptiveHrAlarmWindowSecs = readDoublePref(SP, "HRAdaptiveAlarmWindowSecs", "30"); mSdData.mAdaptiveHrAlarmWindowSecs = readDoublePref(SP, "HRAdaptiveAlarmWindowSecs", "30");
mSdData.mAdaptiveHrAlarmThresh = readDoublePref(SP, "HRAdaptiveAlarmThresh", "20"); mSdData.mAdaptiveHrAlarmThresh = readDoublePref(SP, "HRAdaptiveAlarmThresh", "20");
Log.d(TAG,"updatePrefs(): mAdaptiveHrAlarmActive="+mSdData.mAdaptiveHrAlarmActive); Log.d(TAG, "updatePrefs(): mAdaptiveHrAlarmActive=" + mSdData.mAdaptiveHrAlarmActive);
Log.d(TAG,"updatePrefs(): mAdaptiveHrWindowSecs="+mSdData.mAdaptiveHrAlarmWindowSecs); Log.d(TAG, "updatePrefs(): mAdaptiveHrWindowSecs=" + mSdData.mAdaptiveHrAlarmWindowSecs);
Log.d(TAG,"updatePrefs(): mAdaptiveHrAlarmThresh="+mSdData.mAdaptiveHrAlarmThresh); Log.d(TAG, "updatePrefs(): mAdaptiveHrAlarmThresh=" + mSdData.mAdaptiveHrAlarmThresh);
mSdData.mAverageHrAlarmActive = SP.getBoolean("HRAverageAlarmActive", false); mSdData.mAverageHrAlarmActive = SP.getBoolean("HRAverageAlarmActive", false);
mSdData.mAverageHrAlarmWindowSecs = readDoublePref(SP, "HRAverageAlarmWindowSecs", "120"); mSdData.mAverageHrAlarmWindowSecs = readDoublePref(SP, "HRAverageAlarmWindowSecs", "120");
mSdData.mAverageHrAlarmThreshMin = readDoublePref(SP, "HRAverageAlarmThreshMin", "40"); mSdData.mAverageHrAlarmThreshMin = readDoublePref(SP, "HRAverageAlarmThreshMin", "40");
mSdData.mAverageHrAlarmThreshMax = readDoublePref(SP, "HRAverageAlarmThreshMax", "120"); mSdData.mAverageHrAlarmThreshMax = readDoublePref(SP, "HRAverageAlarmThreshMax", "120");
Log.d(TAG,"updatePrefs(): mAverageHrAlarmActive="+mSdData.mAverageHrAlarmActive); Log.d(TAG, "updatePrefs(): mAverageHrAlarmActive=" + mSdData.mAverageHrAlarmActive);
Log.d(TAG,"updatePrefs(): mAverageHrAlarmWindowSecs="+mSdData.mAverageHrAlarmWindowSecs); Log.d(TAG, "updatePrefs(): mAverageHrAlarmWindowSecs=" + mSdData.mAverageHrAlarmWindowSecs);
Log.d(TAG,"updatePrefs(): mAverageHrAlarmThreshMin="+mSdData.mAverageHrAlarmThreshMin); Log.d(TAG, "updatePrefs(): mAverageHrAlarmThreshMin=" + mSdData.mAverageHrAlarmThreshMin);
Log.d(TAG,"updatePrefs(): mAverageHrAlarmThreshMax="+mSdData.mAverageHrAlarmThreshMax); Log.d(TAG, "updatePrefs(): mAverageHrAlarmThreshMax=" + mSdData.mAverageHrAlarmThreshMax);
mSdData.mO2SatAlarmActive = SP.getBoolean("O2SatAlarmActive", false); mSdData.mO2SatAlarmActive = SP.getBoolean("O2SatAlarmActive", false);
Log.v(TAG, "updatePrefs() O2SatAlarmActive = " + mSdData.mO2SatAlarmActive); Log.v(TAG, "updatePrefs() O2SatAlarmActive = " + mSdData.mO2SatAlarmActive);
mUtil.writeToSysLogFile( "updatePrefs() O2SatAlarmActive = " + mSdData.mO2SatAlarmActive); mUtil.writeToSysLogFile("updatePrefs() O2SatAlarmActive = " + mSdData.mO2SatAlarmActive);
mSdData.mO2SatNullAsAlarm = SP.getBoolean("O2SatNullAsAlarm", false); mSdData.mO2SatNullAsAlarm = SP.getBoolean("O2SatNullAsAlarm", false);
Log.v(TAG, "updatePrefs() O2SatNullAsAlarm = " + mSdData.mO2SatNullAsAlarm); Log.v(TAG, "updatePrefs() O2SatNullAsAlarm = " + mSdData.mO2SatNullAsAlarm);
mUtil.writeToSysLogFile( "updatePrefs() O2SatNullAsAlarm = " + mSdData.mO2SatNullAsAlarm); mUtil.writeToSysLogFile("updatePrefs() O2SatNullAsAlarm = " + mSdData.mO2SatNullAsAlarm);
prefStr = SP.getString("O2SatThreshMin", "SET_FROM_XML"); prefStr = SP.getString("O2SatThreshMin", "SET_FROM_XML");
mSdData.mO2SatThreshMin = (short) Integer.parseInt(prefStr); mSdData.mO2SatThreshMin = (short) Integer.parseInt(prefStr);
Log.v(TAG, "updatePrefs() O2SatThreshMin = " + mSdData.mO2SatThreshMin); Log.v(TAG, "updatePrefs() O2SatThreshMin = " + mSdData.mO2SatThreshMin);
mUtil.writeToSysLogFile( "updatePrefs() O2SatThreshMin = " + mSdData.mO2SatThreshMin); mUtil.writeToSysLogFile("updatePrefs() O2SatThreshMin = " + mSdData.mO2SatThreshMin);
} else { } else {
Log.v(TAG, "updatePrefs() - prefStr is null - WHY????"); Log.v(TAG, "updatePrefs() - prefStr is null - WHY????");

File diff suppressed because one or more lines are too long

View File

@@ -101,8 +101,8 @@ public class SdDataSourceBLE extends SdDataSource {
public static String CHAR_OSD_BATT_DATA = "000085e9-0002-1000-8000-00805f9b34fb"; public static String CHAR_OSD_BATT_DATA = "000085e9-0002-1000-8000-00805f9b34fb";
public static String CHAR_OSD_WATCH_ID = "000085e9-0003-1000-8000-00805f9b34fb"; public static String CHAR_OSD_WATCH_ID = "000085e9-0003-1000-8000-00805f9b34fb";
public static String CHAR_OSD_WATCH_FW = "000085e9-0004-1000-8000-00805f9b34fb"; public static String CHAR_OSD_WATCH_FW = "000085e9-0004-1000-8000-00805f9b34fb";
public static String CHAR_OSD_ACC_FMT= "000085e9-0005-1000-8000-00805f9b34fb"; public static String CHAR_OSD_ACC_FMT = "000085e9-0005-1000-8000-00805f9b34fb";
// Valid values are 0: 8 bit vector magnitude scaled so 1g=44 // Valid values are 0: 8 bit vector magnitude scaled so 1g=44
public final static int ACC_FMT_8BIT = 0; public final static int ACC_FMT_8BIT = 0;
public final static int ACC_FMT_16BIT = 1; public final static int ACC_FMT_16BIT = 1;
@@ -245,13 +245,13 @@ public class SdDataSourceBLE extends SdDataSource {
mSdData.watchConnected = false; mSdData.watchConnected = false;
Log.i(TAG, "onConnectionStateChange(): Disconnected from GATT server"); Log.i(TAG, "onConnectionStateChange(): Disconnected from GATT server");
/**Log.i(TAG, "onConnectionStateChange(): Disconnected from GATT server - reconnecting after delay..."); /**Log.i(TAG, "onConnectionStateChange(): Disconnected from GATT server - reconnecting after delay...");
bleDisconnect(); // Tidy up connections bleDisconnect(); // Tidy up connections
// Wait 2 seconds to give the server chance to shutdown, then re-start it // Wait 2 seconds to give the server chance to shutdown, then re-start it
mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() {
public void run() { public void run() {
bleConnect(); bleConnect();
} }
}, 2000); }, 2000);
*/ */
} }
} }
@@ -319,7 +319,7 @@ public class SdDataSourceBLE extends SdDataSource {
Log.v(TAG, "Battery Data Service Service Discovered"); Log.v(TAG, "Battery Data Service Service Discovered");
for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
String charUuidStr = gattCharacteristic.getUuid().toString(); String charUuidStr = gattCharacteristic.getUuid().toString();
Log.v(TAG,"batt char="+charUuidStr); Log.v(TAG, "batt char=" + charUuidStr);
if (charUuidStr.equals(CHAR_BATT_DATA)) { if (charUuidStr.equals(CHAR_BATT_DATA)) {
Log.v(TAG, "Subscribing to Battery Data Change Notifications"); Log.v(TAG, "Subscribing to Battery Data Change Notifications");
setCharacteristicNotification(gattCharacteristic, true); setCharacteristicNotification(gattCharacteristic, true);
@@ -352,14 +352,14 @@ public class SdDataSourceBLE extends SdDataSource {
* of a given characteristic. * of a given characteristic.
* Because only one BLE operation can be taking place at a time, it may fail, in which case * Because only one BLE operation can be taking place at a time, it may fail, in which case
* the read is re-tried after a 100ms delay. * the read is re-tried after a 100ms delay.
* @param gattCharacteristic - the characteristic to be read. * @param gattCharacteristic - the characteristic to be read.
*/ */
private void executeReadCharacteristic(BluetoothGattCharacteristic gattCharacteristic) { private void executeReadCharacteristic(BluetoothGattCharacteristic gattCharacteristic) {
boolean retVal = mBluetoothGatt.readCharacteristic(gattCharacteristic); boolean retVal = mBluetoothGatt.readCharacteristic(gattCharacteristic);
if (retVal) { if (retVal) {
Log.d(TAG,"executeReadCharacteristic - read initiated successfully"); Log.d(TAG, "executeReadCharacteristic - read initiated successfully");
} else { } else {
Log.d(TAG,"executeReadCharacteristic - read initiation failed - waiting, then re-trying"); Log.d(TAG, "executeReadCharacteristic - read initiation failed - waiting, then re-trying");
mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() {
public void run() { public void run() {
Log.w(TAG, "Executing delayed read of characteristic"); Log.w(TAG, "Executing delayed read of characteristic");
@@ -368,6 +368,7 @@ public class SdDataSourceBLE extends SdDataSource {
}, 100); }, 100);
} }
} }
private boolean permissionsOK() { private boolean permissionsOK() {
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling // TODO: Consider calling
@@ -377,7 +378,7 @@ public class SdDataSourceBLE extends SdDataSource {
// int[] grantResults) // int[] grantResults)
// to handle the case where the user grants the permission. See the documentation // to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details. // for ActivityCompat#requestPermissions for more details.
Log.e(TAG,"permissionsOK() - Bluetooth Permmission Not Granted"); Log.e(TAG, "permissionsOK() - Bluetooth Permmission Not Granted");
mUtil.showToast("ERROR - Bluetooth Permission not Granted"); mUtil.showToast("ERROR - Bluetooth Permission not Granted");
return (false); return (false);
} else { } else {
@@ -392,7 +393,7 @@ public class SdDataSourceBLE extends SdDataSource {
* If the data is acceleration data, we add it to a buffer - it is analysed once the buffer is full. * If the data is acceleration data, we add it to a buffer - it is analysed once the buffer is full.
* Heart rate data is written directly to sdData to be used in future analysis. * Heart rate data is written directly to sdData to be used in future analysis.
*/ */
Log.v(TAG,"onDataReceived: Characteristic="+characteristic.getUuid().toString()); Log.v(TAG, "onDataReceived: Characteristic=" + characteristic.getUuid().toString());
if (characteristic.getUuid().toString().equals(CHAR_HEART_RATE_MEASUREMENT)) { if (characteristic.getUuid().toString().equals(CHAR_HEART_RATE_MEASUREMENT)) {
int flag = characteristic.getProperties(); int flag = characteristic.getProperties();
//Log.d(TAG,"onDataReceived() - flag = "+flag); //Log.d(TAG,"onDataReceived() - flag = "+flag);
@@ -413,17 +414,16 @@ public class SdDataSourceBLE extends SdDataSource {
mSdData.mHR = (double) heartRate; mSdData.mHR = (double) heartRate;
} }
Log.d(TAG, String.format("onDataReceived(): CHAR_HEART_RATE_MEASUREMENT: %d", heartRate)); Log.d(TAG, String.format("onDataReceived(): CHAR_HEART_RATE_MEASUREMENT: %d", heartRate));
} } else if (characteristic.getUuid().toString().equals(CHAR_OSD_ACC_DATA)
else if (characteristic.getUuid().toString().equals(CHAR_OSD_ACC_DATA)
|| characteristic.getUuid().toString().equals(CHAR_INFINITIME_ACC_DATA)) { || characteristic.getUuid().toString().equals(CHAR_INFINITIME_ACC_DATA)) {
//Log.v(TAG,"Received OSD ACC DATA"+characteristic.getValue()); //Log.v(TAG,"Received OSD ACC DATA"+characteristic.getValue());
byte[] rawDataBytes = characteristic.getValue(); byte[] rawDataBytes = characteristic.getValue();
short[] newAccVals = parseDataToAccVals(rawDataBytes); short[] newAccVals = parseDataToAccVals(rawDataBytes);
Log.v(TAG, "onDataReceived(): CHAR_OSD_ACC_DATA: numSamples = " + rawDataBytes.length+" nRawData="+nRawData); Log.v(TAG, "onDataReceived(): CHAR_OSD_ACC_DATA: numSamples = " + rawDataBytes.length + " nRawData=" + nRawData);
//Log.v(TAG, "onDataReceived() - rawDataBytes="+ Arrays.toString(rawDataBytes)); //Log.v(TAG, "onDataReceived() - rawDataBytes="+ Arrays.toString(rawDataBytes));
//Log.v(TAG, "onDataReceived() - newAccVals="+Arrays.toString(newAccVals)); //Log.v(TAG, "onDataReceived() - newAccVals="+Arrays.toString(newAccVals));
for (int i = 0; i < newAccVals.length;i++) { for (int i = 0; i < newAccVals.length; i++) {
if (nRawData < MAX_RAW_DATA ) { if (nRawData < MAX_RAW_DATA) {
switch (mAccFmt) { switch (mAccFmt) {
case ACC_FMT_8BIT: case ACC_FMT_8BIT:
case ACC_FMT_16BIT: case ACC_FMT_16BIT:
@@ -433,7 +433,7 @@ public class SdDataSourceBLE extends SdDataSource {
case ACC_FMT_3D: case ACC_FMT_3D:
// 3d data is x1,y1,z1, x2,y2,z2 ... xn,yn,zn // 3d data is x1,y1,z1, x2,y2,z2 ... xn,yn,zn
// We only do this every third value, then process x, y and z simultaneously. // We only do this every third value, then process x, y and z simultaneously.
if (i+2 < newAccVals.length) { if (i + 2 < newAccVals.length) {
if (i % 3 == 0) { if (i % 3 == 0) {
short x, y, z; short x, y, z;
x = newAccVals[i]; x = newAccVals[i];
@@ -450,8 +450,8 @@ public class SdDataSourceBLE extends SdDataSource {
} }
break; break;
default: default:
Log.e(TAG,"INVALID ACCELERATION FORMAT"+mAccFmt); Log.e(TAG, "INVALID ACCELERATION FORMAT" + mAccFmt);
mUtil.showToast("INVALID ACCELERATION FORMAT "+mAccFmt); mUtil.showToast("INVALID ACCELERATION FORMAT " + mAccFmt);
} }
} else { } else {
@@ -459,9 +459,9 @@ public class SdDataSourceBLE extends SdDataSource {
mSdData.watchAppRunning = true; mSdData.watchAppRunning = true;
for (i = 0; i < rawData.length; i++) { for (i = 0; i < rawData.length; i++) {
mSdData.rawData[i] = rawData[i]; mSdData.rawData[i] = rawData[i];
mSdData.rawData3D[i*3] = rawData3d[i*3]; mSdData.rawData3D[i * 3] = rawData3d[i * 3];
mSdData.rawData3D[i*3 +1] = rawData3d[i*3 +1]; mSdData.rawData3D[i * 3 + 1] = rawData3d[i * 3 + 1];
mSdData.rawData3D[i*3 +2] = rawData3d[i*3 +2]; mSdData.rawData3D[i * 3 + 2] = rawData3d[i * 3 + 2];
//Log.v(TAG,"onDataReceived() i="+i+", "+rawData[i]); //Log.v(TAG,"onDataReceived() i="+i+", "+rawData[i]);
} }
mSdData.mNsamp = rawData.length; mSdData.mNsamp = rawData.length;
@@ -473,37 +473,31 @@ public class SdDataSourceBLE extends SdDataSource {
nRawData = 0; nRawData = 0;
} }
} }
} } else if (characteristic.getUuid().toString().equals(CHAR_OSD_BATT_DATA)) {
else if (characteristic.getUuid().toString().equals(CHAR_OSD_BATT_DATA)) {
byte batteryPc = characteristic.getValue()[0]; byte batteryPc = characteristic.getValue()[0];
mSdData.batteryPc = batteryPc; mSdData.batteryPc = batteryPc;
Log.v(TAG,"onDataReceived(): CHAR_OSD_BATT_DATA: " + String.format("%d", batteryPc)); Log.v(TAG, "onDataReceived(): CHAR_OSD_BATT_DATA: " + String.format("%d", batteryPc));
mSdData.haveSettings = true; mSdData.haveSettings = true;
} } else if (characteristic.getUuid().toString().equals(CHAR_BATT_DATA)) {
else if (characteristic.getUuid().toString().equals(CHAR_BATT_DATA)) {
byte batteryPc = characteristic.getValue()[0]; byte batteryPc = characteristic.getValue()[0];
mSdData.batteryPc = batteryPc; mSdData.batteryPc = batteryPc;
Log.v(TAG,"onDataReceived(): CHAR_BATT_DATA: " + String.format("%d", batteryPc)); Log.v(TAG, "onDataReceived(): CHAR_BATT_DATA: " + String.format("%d", batteryPc));
mSdData.haveSettings = true; mSdData.haveSettings = true;
} } else if (characteristic.getUuid().toString().equals(CHAR_OSD_WATCH_ID)) {
else if (characteristic.getUuid().toString().equals(CHAR_OSD_WATCH_ID)) {
byte[] rawDataBytes = characteristic.getValue(); byte[] rawDataBytes = characteristic.getValue();
String watchId = new String(rawDataBytes, StandardCharsets.UTF_8); String watchId = new String(rawDataBytes, StandardCharsets.UTF_8);
Log.v(TAG,"Received Watch ID: "+watchId); Log.v(TAG, "Received Watch ID: " + watchId);
mSdData.watchSdName = watchId; mSdData.watchSdName = watchId;
} } else if (characteristic.getUuid().toString().equals(CHAR_OSD_WATCH_FW)) {
else if (characteristic.getUuid().toString().equals(CHAR_OSD_WATCH_FW)) {
byte[] rawDataBytes = characteristic.getValue(); byte[] rawDataBytes = characteristic.getValue();
String watchFwVer = new String(rawDataBytes, StandardCharsets.UTF_8); String watchFwVer = new String(rawDataBytes, StandardCharsets.UTF_8);
Log.v(TAG,"Received Watch Firmware Version: "+watchFwVer); Log.v(TAG, "Received Watch Firmware Version: " + watchFwVer);
mSdData.watchSdVersion = watchFwVer; mSdData.watchSdVersion = watchFwVer;
} } else if (characteristic.getUuid().toString().equals(CHAR_OSD_ACC_FMT)) {
else if (characteristic.getUuid().toString().equals(CHAR_OSD_ACC_FMT)) {
mAccFmt = characteristic.getValue()[0]; mAccFmt = characteristic.getValue()[0];
Log.v(TAG,"Received Acceleration format code: "+mAccFmt); Log.v(TAG, "Received Acceleration format code: " + mAccFmt);
} } else {
else { Log.v(TAG, "Unrecognised Characteristic Updated " +
Log.v(TAG,"Unrecognised Characteristic Updated "+
characteristic.getUuid().toString()); characteristic.getUuid().toString());
} }
} }
@@ -513,14 +507,14 @@ public class SdDataSourceBLE extends SdDataSource {
switch (mAccFmt) { switch (mAccFmt) {
case ACC_FMT_8BIT: case ACC_FMT_8BIT:
retArr = new short[rawDataBytes.length]; retArr = new short[rawDataBytes.length];
for (int i = 0; i < rawDataBytes.length;i++) { for (int i = 0; i < rawDataBytes.length; i++) {
retArr[i] = (short) (1000 * rawDataBytes[i] / 64); // Scale to mg retArr[i] = (short) (1000 * rawDataBytes[i] / 64); // Scale to mg
} }
break; break;
case ACC_FMT_16BIT: case ACC_FMT_16BIT:
case ACC_FMT_3D: case ACC_FMT_3D:
// from https://stackoverflow.com/questions/5625573/byte-array-to-short-array-and-back-again-in-java // from https://stackoverflow.com/questions/5625573/byte-array-to-short-array-and-back-again-in-java
retArr = new short[rawDataBytes.length/2]; retArr = new short[rawDataBytes.length / 2];
// to turn bytes to shorts as either big endian or little endian. // to turn bytes to shorts as either big endian or little endian.
ByteBuffer.wrap(rawDataBytes) ByteBuffer.wrap(rawDataBytes)
.order(ByteOrder.LITTLE_ENDIAN) .order(ByteOrder.LITTLE_ENDIAN)
@@ -528,17 +522,18 @@ public class SdDataSourceBLE extends SdDataSource {
.get(retArr); .get(retArr);
break; break;
default: default:
Log.e(TAG,"INVALID ACCELERATION FORMAT"+mAccFmt); Log.e(TAG, "INVALID ACCELERATION FORMAT" + mAccFmt);
mUtil.showToast("INVALID ACCELERATION FORMAT "+mAccFmt); mUtil.showToast("INVALID ACCELERATION FORMAT " + mAccFmt);
retArr = new short[0]; retArr = new short[0];
} }
return(retArr); return (retArr);
} }
@Override @Override
public void onCharacteristicRead(BluetoothGatt gatt, public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic, BluetoothGattCharacteristic characteristic,
int status) { int status) {
Log.v(TAG,"onCharacteristicRead"); Log.v(TAG, "onCharacteristicRead");
if (status == BluetoothGatt.GATT_SUCCESS) { if (status == BluetoothGatt.GATT_SUCCESS) {
onDataReceived(characteristic); onDataReceived(characteristic);
} }
@@ -553,7 +548,7 @@ public class SdDataSourceBLE extends SdDataSource {
@Override @Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
Log.v(TAG,"onDescriptorWrite(): Characteristic " + descriptor.getUuid() + " changed"); Log.v(TAG, "onDescriptorWrite(): Characteristic " + descriptor.getUuid() + " changed");
waitForDescriptorWrite = false; waitForDescriptorWrite = false;
} }
}; };

View File

@@ -38,17 +38,18 @@ public class SdDataSourceNetwork extends SdDataSource {
mName = "Network"; mName = "Network";
} }
@Override public void start() { @Override
public void start() {
// Update preferences. // Update preferences.
Log.v(TAG,"start(): calling updatePrefs()"); Log.v(TAG, "start(): calling updatePrefs()");
mUtil.writeToSysLogFile("SdDataSourceNetwork().start()"); mUtil.writeToSysLogFile("SdDataSourceNetwork().start()");
updatePrefs(); updatePrefs();
// Start timer to retrieve seizure detector data regularly. // Start timer to retrieve seizure detector data regularly.
mStatusTime = new Time(Time.getCurrentTimezone()); mStatusTime = new Time(Time.getCurrentTimezone());
mStatusTime.setToNow(); mStatusTime.setToNow();
if (mDataUpdateTimer ==null) { if (mDataUpdateTimer == null) {
Log.v(TAG,"start(): starting data update timer"); Log.v(TAG, "start(): starting data update timer");
mDataUpdateTimer = new Timer(); mDataUpdateTimer = new Timer();
mDataUpdateTimer.schedule(new TimerTask() { mDataUpdateTimer.schedule(new TimerTask() {
@Override @Override
@@ -57,17 +58,18 @@ public class SdDataSourceNetwork extends SdDataSource {
} }
}, 0, mDataUpdatePeriod); }, 0, mDataUpdatePeriod);
} else { } else {
Log.v(TAG,"start(): data update timer already running."); Log.v(TAG, "start(): data update timer already running.");
} }
} }
@Override public void stop() { @Override
public void stop() {
mUtil.writeToSysLogFile("SdDataSourceNetwork().stop()"); mUtil.writeToSysLogFile("SdDataSourceNetwork().stop()");
// Stop the data update timer // Stop the data update timer
if (mDataUpdateTimer !=null) { if (mDataUpdateTimer != null) {
Log.v(TAG,"stop(): cancelling status timer"); Log.v(TAG, "stop(): cancelling status timer");
mDataUpdateTimer.cancel(); mDataUpdateTimer.cancel();
mDataUpdateTimer.purge(); mDataUpdateTimer.purge();
mDataUpdateTimer = null; mDataUpdateTimer = null;
@@ -76,7 +78,6 @@ public class SdDataSourceNetwork extends SdDataSource {
} }
/** /**
* updatePrefs() - update basic settings from the SharedPreferences * updatePrefs() - update basic settings from the SharedPreferences
* - defined in res/xml/prefs.xml * - defined in res/xml/prefs.xml
@@ -86,21 +87,21 @@ public class SdDataSourceNetwork extends SdDataSource {
mUtil.writeToSysLogFile("SdDataSourceNetwork().updatePrefs()"); mUtil.writeToSysLogFile("SdDataSourceNetwork().updatePrefs()");
SharedPreferences SP = PreferenceManager SharedPreferences SP = PreferenceManager
.getDefaultSharedPreferences(mContext); .getDefaultSharedPreferences(mContext);
mServerIP = SP.getString("ServerIP","192.168.1.175"); mServerIP = SP.getString("ServerIP", "192.168.1.175");
Log.v(TAG,"updatePrefs() - mServerIP = "+mServerIP); Log.v(TAG, "updatePrefs() - mServerIP = " + mServerIP);
try { try {
String dataUpdatePeriodStr = SP.getString("DataUpdatePeriod","2000"); String dataUpdatePeriodStr = SP.getString("DataUpdatePeriod", "2000");
mDataUpdatePeriod = Integer.parseInt(dataUpdatePeriodStr); mDataUpdatePeriod = Integer.parseInt(dataUpdatePeriodStr);
Log.v(TAG,"updatePrefs() - mDataUpdatePeriod = "+mDataUpdatePeriod); Log.v(TAG, "updatePrefs() - mDataUpdatePeriod = " + mDataUpdatePeriod);
String connectTimeoutPeriodStr = SP.getString("ConnectTimeoutPeriod","5000"); String connectTimeoutPeriodStr = SP.getString("ConnectTimeoutPeriod", "5000");
mConnnectTimeoutPeriod = Integer.parseInt(connectTimeoutPeriodStr); mConnnectTimeoutPeriod = Integer.parseInt(connectTimeoutPeriodStr);
Log.v(TAG,"updatePrefs() - mConnectTimeoutPeriod = "+mConnnectTimeoutPeriod); Log.v(TAG, "updatePrefs() - mConnectTimeoutPeriod = " + mConnnectTimeoutPeriod);
String readTimeoutPeriodStr = SP.getString("ReadTimeoutPeriod","5000"); String readTimeoutPeriodStr = SP.getString("ReadTimeoutPeriod", "5000");
mReadTimeoutPeriod = Integer.parseInt(readTimeoutPeriodStr); mReadTimeoutPeriod = Integer.parseInt(readTimeoutPeriodStr);
Log.v(TAG,"updatePrefs() - mReadTimeoutPeriod = "+mReadTimeoutPeriod); Log.v(TAG, "updatePrefs() - mReadTimeoutPeriod = " + mReadTimeoutPeriod);
} catch (Exception ex) { } catch (Exception ex) {
Log.v(TAG,"updatePrefs() - Problem parsing preferences!"); Log.v(TAG, "updatePrefs() - Problem parsing preferences!");
mUtil.writeToSysLogFile("SdDataSourceNetwork().updatePrefs() - " +ex.toString()); mUtil.writeToSysLogFile("SdDataSourceNetwork().updatePrefs() - " + ex.toString());
showToast("Problem Parsing Preferences - Something won't work"); showToast("Problem Parsing Preferences - Something won't work");
} }
} }
@@ -117,6 +118,7 @@ public class SdDataSourceNetwork extends SdDataSource {
private class DownloadSdDataTask extends AsyncTask<String, Void, SdData> { private class DownloadSdDataTask extends AsyncTask<String, Void, SdData> {
private SdData sdData; private SdData sdData;
@Override @Override
protected SdData doInBackground(String... urls) { protected SdData doInBackground(String... urls) {
// params comes from the execute() call: params[0] is the url. // params comes from the execute() call: params[0] is the url.
@@ -124,23 +126,23 @@ public class SdDataSourceNetwork extends SdDataSource {
try { try {
String result = downloadUrl(urls[0]); String result = downloadUrl(urls[0]);
if (result.startsWith("Unable to retrieve web page")) { if (result.startsWith("Unable to retrieve web page")) {
Log.v(TAG,"doInBackground() - Unable to retrieve data"); Log.v(TAG, "doInBackground() - Unable to retrieve data");
sdData.serverOK = false; sdData.serverOK = false;
sdData.watchConnected = false; sdData.watchConnected = false;
sdData.watchAppRunning = false; sdData.watchAppRunning = false;
sdData.alarmState = ALARM_STATE_NETFAULT; sdData.alarmState = ALARM_STATE_NETFAULT;
sdData.alarmPhrase = "Warning - No Connection to Server"; sdData.alarmPhrase = "Warning - No Connection to Server";
Log.v(TAG,"doInBackground(): No Connection to Server - sdData = "+sdData.toString()); Log.v(TAG, "doInBackground(): No Connection to Server - sdData = " + sdData.toString());
} else { } else {
Log.v(TAG,"doInBackground - result = "+result); Log.v(TAG, "doInBackground - result = " + result);
sdData.fromJSON(result); sdData.fromJSON(result);
// Populate mSdData using the received data. // Populate mSdData using the received data.
sdData.serverOK = true; sdData.serverOK = true;
if (sdData.batteryPc>0) { if (sdData.batteryPc > 0) {
sdData.haveSettings = true; sdData.haveSettings = true;
} }
mStatusTime.setToNow(); mStatusTime.setToNow();
Log.v(TAG,"doInBackground(): sdData = "+sdData.toString()); Log.v(TAG, "doInBackground(): sdData = " + sdData.toString());
} }
return (sdData); return (sdData);
@@ -150,14 +152,15 @@ public class SdDataSourceNetwork extends SdDataSource {
sdData.watchAppRunning = false; sdData.watchAppRunning = false;
sdData.alarmState = ALARM_STATE_NETFAULT; sdData.alarmState = ALARM_STATE_NETFAULT;
sdData.alarmPhrase = "Warning - No Connection to Server"; sdData.alarmPhrase = "Warning - No Connection to Server";
Log.v(TAG,"doInBackground(): IOException - "+e.toString()); Log.v(TAG, "doInBackground(): IOException - " + e.toString());
return sdData; return sdData;
} }
} }
// onPostExecute displays the results of the AsyncTask. // onPostExecute displays the results of the AsyncTask.
@Override @Override
protected void onPostExecute(SdData sdData) { protected void onPostExecute(SdData sdData) {
Log.v(TAG,"onPostExecute() - sdData = "+sdData.toString()); Log.v(TAG, "onPostExecute() - sdData = " + sdData.toString());
mSdDataReceiver.onSdDataReceived(sdData); mSdDataReceiver.onSdDataReceived(sdData);
} }
} }
@@ -178,24 +181,24 @@ public class SdDataSourceNetwork extends SdDataSource {
try { try {
String result = downloadUrl(urls[0]); String result = downloadUrl(urls[0]);
if (result.startsWith("Unable to retrieve web page")) { if (result.startsWith("Unable to retrieve web page")) {
Log.v(TAG,"doInBackground() - Error accepting alarm"); Log.v(TAG, "doInBackground() - Error accepting alarm");
} else { } else {
Log.v(TAG,"doInBackground(): Alarm Accepted"); Log.v(TAG, "doInBackground(): Alarm Accepted");
} }
} catch (IOException e) { } catch (IOException e) {
Log.v(TAG,"doInBackground(): IOException - "+e.toString()); Log.v(TAG, "doInBackground(): IOException - " + e.toString());
} }
return "Done"; return "Done";
} }
// onPostExecute displays the results of the AsyncTask. // onPostExecute displays the results of the AsyncTask.
@Override @Override
protected void onPostExecute(String s) { protected void onPostExecute(String s) {
Log.v(TAG,"onPostExecute() - s="+s); Log.v(TAG, "onPostExecute() - s=" + s);
} }
} }
// Given a URL, establishes an HttpUrlConnection and retrieves // Given a URL, establishes an HttpUrlConnection and retrieves
// the web page content as a InputStream, which it returns as // the web page content as a InputStream, which it returns as
// a string. // a string.
@@ -241,6 +244,4 @@ public class SdDataSourceNetwork extends SdDataSource {
} }
} }

View File

@@ -45,7 +45,6 @@ import java.util.TimerTask;
import java.util.UUID; import java.util.UUID;
/** /**
* Abstract class for a seizure detector data source. Subclasses include a pebble smart watch data source and a * Abstract class for a seizure detector data source. Subclasses include a pebble smart watch data source and a
* network data source. * network data source.
@@ -166,7 +165,7 @@ public class SdDataSourcePebble extends SdDataSource {
// use a timer to check the status of the pebble app on the same frequency // use a timer to check the status of the pebble app on the same frequency
// as we get app data. // as we get app data.
if (mStatusTimer == null) { if (mStatusTimer == null) {
Log.v(TAG, "start(): starting status timer with period "+mDataUpdatePeriod*1000 + " ms"); Log.v(TAG, "start(): starting status timer with period " + mDataUpdatePeriod * 1000 + " ms");
mUtil.writeToSysLogFile("SdDataSourcePebble.start() - starting status timer"); mUtil.writeToSysLogFile("SdDataSourcePebble.start() - starting status timer");
mStatusTimer = new Timer(); mStatusTimer = new Timer();
mStatusTimer.schedule(new TimerTask() { mStatusTimer.schedule(new TimerTask() {
@@ -185,7 +184,7 @@ public class SdDataSourcePebble extends SdDataSource {
getPebbleSdSettings(); getPebbleSdSettings();
if (mSettingsTimer == null) { if (mSettingsTimer == null) {
Log.v(TAG, "start(): starting settings timer"); Log.v(TAG, "start(): starting settings timer");
mUtil.writeToSysLogFile("SdDataSourcePebble.start() - starting settings timer with period "+1000*mSettingsPeriod); mUtil.writeToSysLogFile("SdDataSourcePebble.start() - starting settings timer with period " + 1000 * mSettingsPeriod);
mSettingsTimer = new Timer(); mSettingsTimer = new Timer();
mSettingsTimer.schedule(new TimerTask() { mSettingsTimer.schedule(new TimerTask() {
@Override @Override
@@ -230,7 +229,7 @@ public class SdDataSourcePebble extends SdDataSource {
} catch (Exception e) { } catch (Exception e) {
Log.v(TAG, "Error in stop() - " + e.toString()); Log.v(TAG, "Error in stop() - " + e.toString());
mUtil.writeToSysLogFile("SdDataSourcePebble.stop() - error - "+e.toString()); mUtil.writeToSysLogFile("SdDataSourcePebble.stop() - error - " + e.toString());
} }
} }
@@ -343,8 +342,8 @@ public class SdDataSourcePebble extends SdDataSource {
Log.v(TAG, "updatePrefs() FallWindow = " + mFallWindow); Log.v(TAG, "updatePrefs() FallWindow = " + mFallWindow);
} catch (Exception ex) { } catch (Exception ex) {
Log.v(TAG, "updatePrefs() - Problem parsing preferences! - prefStr="+prefStr); Log.v(TAG, "updatePrefs() - Problem parsing preferences! - prefStr=" + prefStr);
mUtil.writeToSysLogFile("SdDataSourcePebble.updatePrefs() - ERROR "+ex.toString()); mUtil.writeToSysLogFile("SdDataSourcePebble.updatePrefs() - ERROR " + ex.toString());
Toast toast = Toast.makeText(mContext, "Problem Parsing Preferences - Something won't work - Please go back to Settings and correct it!", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(mContext, "Problem Parsing Preferences - Something won't work - Please go back to Settings and correct it!", Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
@@ -437,16 +436,16 @@ public class SdDataSourcePebble extends SdDataSource {
byte[] rawDataBytes = data.getBytes(KEY_RAW_DATA); byte[] rawDataBytes = data.getBytes(KEY_RAW_DATA);
for (int i = 0; i < rawDataBytes.length - 4; i += 4) { // 4 bytes per sample for (int i = 0; i < rawDataBytes.length - 4; i += 4) { // 4 bytes per sample
int b0 = rawDataBytes[i]; int b0 = rawDataBytes[i];
int b1 = rawDataBytes[i+1] & 0xff; int b1 = rawDataBytes[i + 1] & 0xff;
int b2 = rawDataBytes[i+2] & 0xff; int b2 = rawDataBytes[i + 2] & 0xff;
int b3 = rawDataBytes[i+3] & 0xff; int b3 = rawDataBytes[i + 3] & 0xff;
int x = (b3 | b2 << 8 | b1 << 16 | b0 << 24); int x = (b3 | b2 << 8 | b1 << 16 | b0 << 24);
//int y = (rawDataBytes[i+2] & 0xff) | (rawDataBytes[i+3] << 8); //int y = (rawDataBytes[i+2] & 0xff) | (rawDataBytes[i+3] << 8);
//int z = (rawDataBytes[i+4] & 0xff) | (rawDataBytes[i+5] << 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+", y="+y+", z="+z);
Log.v(TAG,"b0="+b0+", b1="+b1+", b2="+b2+", b3="+b3+", x="+x); Log.v(TAG, "b0=" + b0 + ", b1=" + b1 + ", b2=" + b2 + ", b3=" + b3 + ", x=" + x);
if (nRawData < MAX_RAW_DATA) { if (nRawData < MAX_RAW_DATA) {
rawData[nRawData] = (int)Math.sqrt(x); rawData[nRawData] = (int) Math.sqrt(x);
} else { } else {
Log.i(TAG, "WARNING - rawData Buffer Full"); Log.i(TAG, "WARNING - rawData Buffer Full");
} }
@@ -461,7 +460,7 @@ public class SdDataSourcePebble extends SdDataSource {
// } else { // } else {
// Log.i(TAG, "WARNING - rawData Buffer Full"); // Log.i(TAG, "WARNING - rawData Buffer Full");
// } // }
// } // }
} }
} }
@@ -498,7 +497,7 @@ public class SdDataSourcePebble extends SdDataSource {
// first close the watch app if it is running. // first close the watch app if it is running.
PebbleKit.closeAppOnPebble(mContext, SD_UUID); PebbleKit.closeAppOnPebble(mContext, SD_UUID);
Log.v(TAG, "startWatchApp() - starting watch app after 5 seconds delay..."); Log.v(TAG, "startWatchApp() - starting watch app after 5 seconds delay...");
// Wait 5 seconds then start the app. // Wait 5 seconds then start the app.
Timer appStartTimer = new Timer(); Timer appStartTimer = new Timer();
appStartTimer.schedule(new TimerTask() { appStartTimer.schedule(new TimerTask() {
@Override @Override
@@ -727,7 +726,7 @@ public class SdDataSourcePebble extends SdDataSource {
* ignored! * ignored!
*/ */
private void analyseRawData() { private void analyseRawData() {
Log.v(TAG,"analyserawData()"); Log.v(TAG, "analyserawData()");
//DoubleFFT_1D fft = new DoubleFFT_1D(MAX_RAW_DATA); //DoubleFFT_1D fft = new DoubleFFT_1D(MAX_RAW_DATA);
//fft.realForward(rawData); //fft.realForward(rawData);
// FIXME - rawData should really be a circular buffer. // FIXME - rawData should really be a circular buffer.
@@ -774,7 +773,6 @@ public class SdDataSourcePebble extends SdDataSource {
} }
} }

View File

@@ -79,7 +79,7 @@ public class SdDataSourcePhone extends SdDataSource implements SensorEventListen
mUtil.writeToSysLogFile("SdDataSourcePhone.start()"); mUtil.writeToSysLogFile("SdDataSourcePhone.start()");
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mSensor , SensorManager.SENSOR_DELAY_GAME); mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_GAME);
super.start(); super.start();
} }
@@ -95,22 +95,19 @@ public class SdDataSourcePhone extends SdDataSource implements SensorEventListen
} }
@Override @Override
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
// we initially start in mMode=0, which calculates the sample frequency returned by the sensor, then enters mMode=1, which is normal operation. // we initially start in mMode=0, which calculates the sample frequency returned by the sensor, then enters mMode=1, which is normal operation.
if (mMode == 0) { if (mMode == 0) {
if (mStartEvent==null) { if (mStartEvent == null) {
Log.v(TAG,"onSensorChanged(): mMode=0 - Starting Sample Rate Check - mNSamp = "+mSdData.mNsamp); Log.v(TAG, "onSensorChanged(): mMode=0 - Starting Sample Rate Check - mNSamp = " + mSdData.mNsamp);
Log.v(TAG,"onSensorChanged(): saving initial event data"); Log.v(TAG, "onSensorChanged(): saving initial event data");
mStartEvent = event; mStartEvent = event;
mStartTs = event.timestamp; mStartTs = event.timestamp;
mSdData.mNsamp = 0; mSdData.mNsamp = 0;
} else { } else {
mSdData.mNsamp ++; mSdData.mNsamp++;
} }
Log.v(TAG, "onSensorChanged - mMode=" + mMode + " mNSamp=" + mSdData.mNsamp); Log.v(TAG, "onSensorChanged - mMode=" + mMode + " mNSamp=" + mSdData.mNsamp);
if (mSdData.mNsamp >= mSdData.rawData.length) { if (mSdData.mNsamp >= mSdData.rawData.length) {
@@ -179,12 +176,10 @@ public class SdDataSourcePhone extends SdDataSource implements SensorEventListen
@Override @Override
public void onAccuracyChanged(Sensor sensor, int accuracy) { public void onAccuracyChanged(Sensor sensor, int accuracy) {
Log.v(TAG,"onAccuracyChanged()"); Log.v(TAG, "onAccuracyChanged()");
} }
} }

View File

@@ -260,7 +260,7 @@ public class SdServer extends Service implements SdDataReceiver {
Log.v(TAG, "onStartCommand() - calling updatePrefs()"); Log.v(TAG, "onStartCommand() - calling updatePrefs()");
updatePrefs(); updatePrefs();
Log.v(TAG, "onStartCommand: Datasource =" + mSdDataSourceName + ", phoneAppVersion="+mUtil.getAppVersionName()); Log.v(TAG, "onStartCommand: Datasource =" + mSdDataSourceName + ", phoneAppVersion=" + mUtil.getAppVersionName());
mSdData.dataSourceName = mSdDataSourceName; mSdData.dataSourceName = mSdDataSourceName;
mSdData.phoneAppVersion = mUtil.getAppVersionName(); mSdData.phoneAppVersion = mUtil.getAppVersionName();
switch (mSdDataSourceName) { switch (mSdDataSourceName) {
@@ -278,7 +278,7 @@ public class SdServer extends Service implements SdDataReceiver {
Log.v(TAG, "Selecting Network DataSource"); Log.v(TAG, "Selecting Network DataSource");
mUtil.writeToSysLogFile("SdServer.onStartCommand() - creating SdDataSourceNetwork"); mUtil.writeToSysLogFile("SdServer.onStartCommand() - creating SdDataSourceNetwork");
mSdDataSource = new SdDataSourceNetwork(this.getApplicationContext(), mHandler, this); mSdDataSource = new SdDataSourceNetwork(this.getApplicationContext(), mHandler, this);
Log.i(TAG,"Disabling remote logging when using network data source"); Log.i(TAG, "Disabling remote logging when using network data source");
mLogDataRemote = false; mLogDataRemote = false;
break; break;
case "Garmin": case "Garmin":
@@ -306,7 +306,7 @@ public class SdServer extends Service implements SdDataReceiver {
// Create our log manager. // Create our log manager.
mLm = new LogManager(this, mLogDataRemote, mLogDataRemoteMobile, mAuthToken, mEventDuration, mLm = new LogManager(this, mLogDataRemote, mLogDataRemoteMobile, mAuthToken, mEventDuration,
mRemoteLogPeriod, mLogNDA ,mAutoPruneDb, mDataRetentionPeriod, mSdData); mRemoteLogPeriod, mLogNDA, mAutoPruneDb, mDataRetentionPeriod, mSdData);
if (mSMSAlarm) { if (mSMSAlarm) {
Log.v(TAG, "Creating LocationFinder"); Log.v(TAG, "Creating LocationFinder");
@@ -316,7 +316,6 @@ public class SdServer extends Service implements SdDataReceiver {
mSdDataSource.start(); mSdDataSource.start();
// Record last time we sent an SMS so we can limit rate of SMS // Record last time we sent an SMS so we can limit rate of SMS
// sending to one per minute. We set it to one minute ago (60000 milliseconds) // sending to one per minute. We set it to one minute ago (60000 milliseconds)
mSMSTime = new Time(Time.getCurrentTimezone()); mSMSTime = new Time(Time.getCurrentTimezone());
@@ -478,7 +477,7 @@ public class SdServer extends Service implements SdDataReceiver {
Uri soundUri = null; Uri soundUri = null;
if ((alarmLevel == mCurrentNotificationAlarmLevel) && (isNotificationShown(NOTIFICATION_ID))) { if ((alarmLevel == mCurrentNotificationAlarmLevel) && (isNotificationShown(NOTIFICATION_ID))) {
Log.v(TAG,"showNotification - notification already shown at specified alarm level - not doing anything"); Log.v(TAG, "showNotification - notification already shown at specified alarm level - not doing anything");
return; return;
} }
Log.v(TAG, "showNotification() - alarmLevel=" + alarmLevel); Log.v(TAG, "showNotification() - alarmLevel=" + alarmLevel);
@@ -586,7 +585,7 @@ public class SdServer extends Service implements SdDataReceiver {
} }
} else { } else {
mUtil.showToast("OpenSeizureDetector: showMainActvity Failed to Display Activity"); mUtil.showToast("OpenSeizureDetector: showMainActvity Failed to Display Activity");
Log.e(TAG,"OpenSeizureDetector: showMainActvity Failed to Display Activity"); Log.e(TAG, "OpenSeizureDetector: showMainActvity Failed to Display Activity");
} }
} }
@@ -1345,7 +1344,7 @@ public class SdServer extends Service implements SdDataReceiver {
Log.i(TAG, "SmsTimer.onFinish() - Last Location is Null so sending first SMS without location."); Log.i(TAG, "SmsTimer.onFinish() - Last Location is Null so sending first SMS without location.");
} }
} else { } else {
Log.e(TAG,"SmsTimer.onFinish - mLocationFinder is null - this should not happen!"); Log.e(TAG, "SmsTimer.onFinish - mLocationFinder is null - this should not happen!");
mUtil.showToast(getString(R.string.mLocationFinder_is_null_msg)); mUtil.showToast(getString(R.string.mLocationFinder_is_null_msg));
} }
Log.i(TAG, "SmsTimer.onFinish() - Sending to " + mSMSNumbers.length + " Numbers"); Log.i(TAG, "SmsTimer.onFinish() - Sending to " + mSMSNumbers.length + " Numbers");
@@ -1373,7 +1372,6 @@ public class SdServer extends Service implements SdDataReceiver {
/** /**
* onSdLocationReceived - called with the best estimate location after mLocationReceiver times out. * onSdLocationReceived - called with the best estimate location after mLocationReceiver times out.
*
*/ */
private void sendSMS(String phoneNo, String msgStr) { private void sendSMS(String phoneNo, String msgStr) {
Log.i(TAG, "sendSMS() - Sending to " + phoneNo); Log.i(TAG, "sendSMS() - Sending to " + phoneNo);
@@ -1618,11 +1616,11 @@ public class SdServer extends Service implements SdDataReceiver {
Log.v(TAG, "checkEvents() - haveUnvalidatedEvent = " + Log.v(TAG, "checkEvents() - haveUnvalidatedEvent = " +
haveUnvalidatedEvent); haveUnvalidatedEvent);
if (haveUnvalidatedEvent) { if (haveUnvalidatedEvent) {
Log.v(TAG,"checkEvents() - showing event notification and cancelling datashare notification."); Log.v(TAG, "checkEvents() - showing event notification and cancelling datashare notification.");
showEventNotification(); showEventNotification();
mNM.cancel(DATASHARE_NOTIFICATION_ID); mNM.cancel(DATASHARE_NOTIFICATION_ID);
} else { } else {
Log.v(TAG,"checkEvents() - cancelling event and datashare notifications"); Log.v(TAG, "checkEvents() - cancelling event and datashare notifications");
mNM.cancel(EVENT_NOTIFICATION_ID); mNM.cancel(EVENT_NOTIFICATION_ID);
mNM.cancel(DATASHARE_NOTIFICATION_ID); mNM.cancel(DATASHARE_NOTIFICATION_ID);
} }
@@ -1678,7 +1676,7 @@ public class SdServer extends Service implements SdDataReceiver {
Uri soundUri = null; Uri soundUri = null;
if (isNotificationShown(EVENT_NOTIFICATION_ID)) { if (isNotificationShown(EVENT_NOTIFICATION_ID)) {
Log.v(TAG,"showEventNotification() - notification is already shown, so not doing anything"); Log.v(TAG, "showEventNotification() - notification is already shown, so not doing anything");
return; return;
} }
@@ -1727,7 +1725,7 @@ public class SdServer extends Service implements SdDataReceiver {
Uri soundUri = null; Uri soundUri = null;
if (isNotificationShown(DATASHARE_NOTIFICATION_ID)) { if (isNotificationShown(DATASHARE_NOTIFICATION_ID)) {
Log.v(TAG,"showDataShareNotification() - notification is already shown, so not doing anything"); Log.v(TAG, "showDataShareNotification() - notification is already shown, so not doing anything");
return; return;
} }
@@ -1781,6 +1779,7 @@ public class SdServer extends Service implements SdDataReceiver {
/** /**
* isNotificationShown - returns true if the specified notificationID is shown, otherwise returns false. * isNotificationShown - returns true if the specified notificationID is shown, otherwise returns false.
*
* @param notificationId - Notification ID to check * @param notificationId - Notification ID to check
* @return true if the specified notification is displayed, otherwise false. * @return true if the specified notification is displayed, otherwise false.
*/ */
@@ -1789,10 +1788,10 @@ public class SdServer extends Service implements SdDataReceiver {
StatusBarNotification[] notifications = mNotificationManager.getActiveNotifications(); StatusBarNotification[] notifications = mNotificationManager.getActiveNotifications();
for (StatusBarNotification notification : notifications) { for (StatusBarNotification notification : notifications) {
if (notification.getId() == notificationId) { if (notification.getId() == notificationId) {
return(true); return (true);
} }
} }
return(false); return (false);
} }
} }

View File

@@ -31,7 +31,6 @@ import android.os.IBinder;
import android.util.Log; import android.util.Log;
/** /**
* Defines callbacks for service binding, passed to bindService() * Defines callbacks for service binding, passed to bindService()
*/ */
@@ -68,11 +67,12 @@ public class SdServiceConnection implements ServiceConnection {
/** /**
* Check if the service has received seizure detector data. * Check if the service has received seizure detector data.
*
* @return true if data has been received. * @return true if data has been received.
*/ */
public boolean hasSdData() { public boolean hasSdData() {
if (mSdServer!=null) { if (mSdServer != null) {
if (mSdServer.mSdData!=null) { if (mSdServer.mSdData != null) {
return mSdServer.mSdData.haveData; return mSdServer.mSdData.haveData;
} }
} }
@@ -81,11 +81,12 @@ public class SdServiceConnection implements ServiceConnection {
/** /**
* Check if the service has received seizure detector settings. * Check if the service has received seizure detector settings.
*
* @return true if settings have been received. * @return true if settings have been received.
*/ */
public boolean hasSdSettings() { public boolean hasSdSettings() {
if (mSdServer!=null) { if (mSdServer != null) {
if (mSdServer.mSdData!=null) { if (mSdServer.mSdData != null) {
if (mSdServer.mSdData.haveSettings) { if (mSdServer.mSdData.haveSettings) {
return true; return true;
} }
@@ -96,11 +97,12 @@ public class SdServiceConnection implements ServiceConnection {
/** /**
* Check if the pebble watch is connected to the server device via bluetooth. * Check if the pebble watch is connected to the server device via bluetooth.
*
* @return true if watch connected. * @return true if watch connected.
*/ */
public boolean watchConnected() { public boolean watchConnected() {
if (mSdServer!=null) { if (mSdServer != null) {
if (mSdServer.mSdData!=null) { if (mSdServer.mSdData != null) {
if (mSdServer.mSdData.watchConnected) { if (mSdServer.mSdData.watchConnected) {
return true; return true;
} }
@@ -111,11 +113,12 @@ public class SdServiceConnection implements ServiceConnection {
/** /**
* Check if the openseizuredetector pebble watch app is running.. * Check if the openseizuredetector pebble watch app is running..
*
* @return true if watch app running. * @return true if watch app running.
*/ */
public boolean pebbleAppRunning() { public boolean pebbleAppRunning() {
if (mSdServer!=null) { if (mSdServer != null) {
if (mSdServer.mSdData!=null) { if (mSdServer.mSdData != null) {
if (mSdServer.mSdData.watchAppRunning) { if (mSdServer.mSdData.watchAppRunning) {
return true; return true;
} }

View File

@@ -114,7 +114,7 @@ public class SdWebServer extends NanoHTTPD {
answer = mSdServer.mSdDataSource.updateFromJSON(files.get("postData")); answer = mSdServer.mSdDataSource.updateFromJSON(files.get("postData"));
} }
} else { } else {
Log.i(TAG,"Web server received data, but datasource is not set to 'Garmin' - Ignoring"); Log.i(TAG, "Web server received data, but datasource is not set to 'Garmin' - Ignoring");
mUtil.showToast("Web server received data, but datasource is not set to 'Garmin' - Ignoring"); mUtil.showToast("Web server received data, but datasource is not set to 'Garmin' - Ignoring");
} }
break; break;
@@ -152,10 +152,10 @@ public class SdWebServer extends NanoHTTPD {
Log.v(TAG, " files=" + files.toString()); Log.v(TAG, " files=" + files.toString());
// Send the data to the SdDataSource so the app can pick it up. // Send the data to the SdDataSource so the app can pick it up.
if (parameters != null) { if (parameters != null) {
Log.v(TAG,"passing parameters to data source"); Log.v(TAG, "passing parameters to data source");
answer = mSdServer.mSdDataSource.updateFromJSON(parameters.get("dataObj").toString()); answer = mSdServer.mSdDataSource.updateFromJSON(parameters.get("dataObj").toString());
} else { } else {
Log.v(TAG,"Passing postData to data source"); Log.v(TAG, "Passing postData to data source");
answer = mSdServer.mSdDataSource.updateFromJSON(files.get("postData")); answer = mSdServer.mSdDataSource.updateFromJSON(files.get("postData"));
} }
//mSdServer.mSdDataSource.updateFromJSON(parameters.toString()); //mSdServer.mSdDataSource.updateFromJSON(parameters.toString());
@@ -209,12 +209,12 @@ public class SdWebServer extends NanoHTTPD {
} else { } else {
Log.v(TAG, "WebServer.serve() - Unknown uri -" + Log.v(TAG, "WebServer.serve() - Unknown uri -" +
uri); uri);
answer = "{'msg' : 'Unknown URI: "+uri+"'}"; answer = "{'msg' : 'Unknown URI: " + uri + "'}";
} }
} }
res = new NanoHTTPD.Response(answer); res = new NanoHTTPD.Response(answer);
res.setMimeType(responseMimeType); res.setMimeType(responseMimeType);
Log.v(TAG,"WebServer.serve() - returning "+res.getData()+", mime="+res.getMimeType()+", status="+res.getStatus()); Log.v(TAG, "WebServer.serve() - returning " + res.getData() + ", mime=" + res.getMimeType() + ", status=" + res.getStatus());
return (res); return (res);
} }
@@ -248,13 +248,13 @@ public class SdWebServer extends NanoHTTPD {
try { try {
JSONObject jsonObj = new JSONObject(); JSONObject jsonObj = new JSONObject();
File[] fileList = mUtil.getDataFilesList(); File[] fileList = mUtil.getDataFilesList();
Log.v(TAG, "serveLogFile(): fileList=" + fileList.toString()+", length="+fileList.length); Log.v(TAG, "serveLogFile(): fileList=" + fileList.toString() + ", length=" + fileList.length);
JSONArray arr = new JSONArray(); JSONArray arr = new JSONArray();
for (int i = 0; i < fileList.length; i++) { for (int i = 0; i < fileList.length; i++) {
Log.v(TAG, "serveLogFile(): file[" + i + "]=" + fileList[i]); Log.v(TAG, "serveLogFile(): file[" + i + "]=" + fileList[i]);
arr.put(fileList[i].getName()); arr.put(fileList[i].getName());
} }
jsonObj.put("logFileList", arr); jsonObj.put("logFileList", arr);
res = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, res = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK,
"text/html", jsonObj.toString()); "text/html", jsonObj.toString());
} catch (Exception ex) { } catch (Exception ex) {

View File

@@ -113,8 +113,6 @@ public class StartupActivity extends AppCompatActivity {
}; };
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -205,17 +203,17 @@ public class StartupActivity extends AppCompatActivity {
if (mUtil.isServerRunning()) { if (mUtil.isServerRunning()) {
Log.i(TAG, "onStart() - server running - stopping it - isServerRunning="+mUtil.isServerRunning()); Log.i(TAG, "onStart() - server running - stopping it - isServerRunning=" + mUtil.isServerRunning());
mUtil.writeToSysLogFile("StartupActivity.onStart() - server already running - stopping it."); mUtil.writeToSysLogFile("StartupActivity.onStart() - server already running - stopping it.");
mUtil.stopServer(); mUtil.stopServer();
} else { } else {
Log.i(TAG, "onStart() - server not running - isServerRunning="+mUtil.isServerRunning()); Log.i(TAG, "onStart() - server not running - isServerRunning=" + mUtil.isServerRunning());
} }
// Wait 0.1 second to give the server chance to shutdown in case we have just shut it down below, then start it // Wait 0.1 second to give the server chance to shutdown in case we have just shut it down below, then start it
mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() {
public void run() { public void run() {
mUtil.writeToSysLogFile("StartupActivity.onStart() - starting server after delay - isServerRunning="+mUtil.isServerRunning()); mUtil.writeToSysLogFile("StartupActivity.onStart() - starting server after delay - isServerRunning=" + mUtil.isServerRunning());
Log.i(TAG, "onStart() - starting server after delay -isServerRunning="+mUtil.isServerRunning()); Log.i(TAG, "onStart() - starting server after delay -isServerRunning=" + mUtil.isServerRunning());
mUtil.startServer(); mUtil.startServer();
// Bind to the service. // Bind to the service.
Log.i(TAG, "onStart() - binding to server"); Log.i(TAG, "onStart() - binding to server");
@@ -232,7 +230,7 @@ public class StartupActivity extends AppCompatActivity {
} else { } else {
boolean preventBatteryOptWarning = SP.getBoolean("PreventBatteryOptWarning", false); boolean preventBatteryOptWarning = SP.getBoolean("PreventBatteryOptWarning", false);
if (preventBatteryOptWarning) { if (preventBatteryOptWarning) {
Log.i(TAG,"PreventBatteryOptWarning is true, so not displaying battery optimisation dialog"); Log.i(TAG, "PreventBatteryOptWarning is true, so not displaying battery optimisation dialog");
} else { } else {
Log.e(TAG, "Power Management Problem - not ignoring Battery Optimisations"); Log.e(TAG, "Power Management Problem - not ignoring Battery Optimisations");
//mUtil.showToast("WARNING - Phone is Optimising OpenSeizureDetector Battery Usage - this is likely to prevent it working correctly when running on battery!"); //mUtil.showToast("WARNING - Phone is Optimising OpenSeizureDetector Battery Usage - this is likely to prevent it working correctly when running on battery!");
@@ -302,7 +300,7 @@ public class StartupActivity extends AppCompatActivity {
pb = (ProgressBar) findViewById(R.id.progressBar1); pb = (ProgressBar) findViewById(R.id.progressBar1);
if (arePermissionsOK()) { if (arePermissionsOK()) {
if (smsAlarmsActive && !areSMSPermissions1OK()) { if (smsAlarmsActive && !areSMSPermissions1OK()) {
Log.i(TAG,"SMS permissions NOT OK"); Log.i(TAG, "SMS permissions NOT OK");
tv.setText(getString(R.string.SmsPermissionWarning)); tv.setText(getString(R.string.SmsPermissionWarning));
tv.setBackgroundColor(alarmColour); tv.setBackgroundColor(alarmColour);
tv.setTextColor(alarmTextColour); tv.setTextColor(alarmTextColour);
@@ -311,14 +309,14 @@ public class StartupActivity extends AppCompatActivity {
requestSMSPermissions(); requestSMSPermissions();
allOk = false; allOk = false;
} else if (smsAlarmsActive && !areLocationPermissions1OK()) { } else if (smsAlarmsActive && !areLocationPermissions1OK()) {
Log.i(TAG,"Location permissions NOT OK"); Log.i(TAG, "Location permissions NOT OK");
tv.setText(getString(R.string.SmsPermissionWarning)); tv.setText(getString(R.string.SmsPermissionWarning));
tv.setBackgroundColor(alarmColour); tv.setBackgroundColor(alarmColour);
tv.setTextColor(alarmTextColour); tv.setTextColor(alarmTextColour);
requestLocationPermissions1(); requestLocationPermissions1();
allOk = false; allOk = false;
} else if (smsAlarmsActive && !areLocationPermissions2OK()) { } else if (smsAlarmsActive && !areLocationPermissions2OK()) {
Log.i(TAG,"Location permissions2 NOT OK"); Log.i(TAG, "Location permissions2 NOT OK");
tv.setText(getString(R.string.SmsPermissionWarning)); tv.setText(getString(R.string.SmsPermissionWarning));
tv.setBackgroundColor(alarmColour); tv.setBackgroundColor(alarmColour);
tv.setTextColor(alarmTextColour); tv.setTextColor(alarmTextColour);
@@ -479,10 +477,10 @@ public class StartupActivity extends AppCompatActivity {
} }
} }
/** /**
* checkFirstRun - checks to see if this is the first run of the app after installation or upgrade. * checkFirstRun - checks to see if this is the first run of the app after installation or upgrade.
* if it is, the relevant dialog message is displayed. If not, the routine just exists so start-up can continue. * if it is, the relevant dialog message is displayed. If not, the routine just exists so start-up can continue.
*/ */
public void checkFirstRun() { public void checkFirstRun() {
String storedVersionName = ""; String storedVersionName = "";
String versionName; String versionName;
@@ -640,7 +638,7 @@ public class StartupActivity extends AppCompatActivity {
for (int i = 0; i < SMS_PERMISSIONS_1.length; i++) { for (int i = 0; i < SMS_PERMISSIONS_1.length; i++) {
if (ContextCompat.checkSelfPermission(this, SMS_PERMISSIONS_1[i]) if (ContextCompat.checkSelfPermission(this, SMS_PERMISSIONS_1[i])
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
Log.i(TAG, "areSMSPermissions1OK: "+SMS_PERMISSIONS_1[i] + " Permission Not Granted"); Log.i(TAG, "areSMSPermissions1OK: " + SMS_PERMISSIONS_1[i] + " Permission Not Granted");
allOk = false; allOk = false;
} }
} }
@@ -663,7 +661,7 @@ public class StartupActivity extends AppCompatActivity {
public boolean areLocationPermissions2OK() { public boolean areLocationPermissions2OK() {
boolean allOk = true; boolean allOk = true;
Log.v(TAG, "areSMSPermissions2OK() - SDK="+android.os.Build.VERSION.SDK_INT); Log.v(TAG, "areSMSPermissions2OK() - SDK=" + android.os.Build.VERSION.SDK_INT);
if (android.os.Build.VERSION.SDK_INT < 29) { if (android.os.Build.VERSION.SDK_INT < 29) {
Log.d(TAG, "areLocationPermission2OK() - SDK <29 (Android 10) so permission not required"); Log.d(TAG, "areLocationPermission2OK() - SDK <29 (Android 10) so permission not required");
allOk = true; allOk = true;
@@ -712,7 +710,7 @@ public class StartupActivity extends AppCompatActivity {
.setPositiveButton(getString(R.string.okBtnTxt), new DialogInterface.OnClickListener() { .setPositiveButton(getString(R.string.okBtnTxt), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
dialog.cancel(); dialog.cancel();
Log.i(TAG,"requestSMSPermissions(): Launching ActivityCompat.requestPermissions()"); Log.i(TAG, "requestSMSPermissions(): Launching ActivityCompat.requestPermissions()");
ActivityCompat.requestPermissions(StartupActivity.this, ActivityCompat.requestPermissions(StartupActivity.this,
SMS_PERMISSIONS_1, SMS_PERMISSIONS_1,
45); 45);
@@ -749,9 +747,9 @@ public class StartupActivity extends AppCompatActivity {
} }
}) })
.setNegativeButton(getString(R.string.cancelBtnTxt), new DialogInterface.OnClickListener() { .setNegativeButton(getString(R.string.cancelBtnTxt), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
dialog.cancel(); dialog.cancel();
} }
}) })
.create().show(); .create().show();
} }
@@ -773,7 +771,7 @@ public class StartupActivity extends AppCompatActivity {
.setPositiveButton(getString(R.string.okBtnTxt), new DialogInterface.OnClickListener() { .setPositiveButton(getString(R.string.okBtnTxt), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
dialog.cancel(); dialog.cancel();
Log.i(TAG,"requestSMSPermissions(): Launching ActivityCompat.requestPermissions()"); Log.i(TAG, "requestSMSPermissions(): Launching ActivityCompat.requestPermissions()");
ActivityCompat.requestPermissions(StartupActivity.this, ActivityCompat.requestPermissions(StartupActivity.this,
LOCATION_PERMISSIONS_2, LOCATION_PERMISSIONS_2,
44); 44);

View File

@@ -139,19 +139,20 @@ public abstract class WebApiConnection {
/** /**
* Mark all of the events with IDs contained in eventList as the specified type and subtype. * Mark all of the events with IDs contained in eventList as the specified type and subtype.
* @param eventList list of String IDs of the events to mark as unknown. *
* @param eventList list of String IDs of the events to mark as unknown.
* @param typeStr * @param typeStr
* @param subTypeStr * @param subTypeStr
* @return true if request sent successfully or false. * @return true if request sent successfully or false.
*/ */
private boolean markEventsAsTypeSubType(ArrayList<String>eventList, String typeStr, String subTypeStr) { private boolean markEventsAsTypeSubType(ArrayList<String> eventList, String typeStr, String subTypeStr) {
if (eventList.size()>0) { if (eventList.size() > 0) {
Log.i(TAG,"markEventsAsTypeSubtype - eventList.size()="+eventList.size()); Log.i(TAG, "markEventsAsTypeSubtype - eventList.size()=" + eventList.size());
Log.i(TAG,"markEventsAsSypeSubtype - eventList(0) = "+eventList.get(0)); Log.i(TAG, "markEventsAsSypeSubtype - eventList(0) = " + eventList.get(0));
getEvent(eventList.get(0), new WebApiConnection.JSONObjectCallback() { getEvent(eventList.get(0), new WebApiConnection.JSONObjectCallback() {
@Override @Override
public void accept(JSONObject eventObj) { public void accept(JSONObject eventObj) {
Log.v(TAG, "markEventsAsTypeSubtype.getEvent.callback: "+eventObj); Log.v(TAG, "markEventsAsTypeSubtype.getEvent.callback: " + eventObj);
if (eventObj != null) { if (eventObj != null) {
Log.v(TAG, "markEventsAsTypeSubtype.getEvent.callback: eventObj=" + eventObj.toString()); Log.v(TAG, "markEventsAsTypeSubtype.getEvent.callback: eventObj=" + eventObj.toString());
try { try {
@@ -161,7 +162,7 @@ public abstract class WebApiConnection {
if (notesStr == null) notesStr = new String(""); if (notesStr == null) notesStr = new String("");
notesStr = notesStr + " bulk type/subtype set"; notesStr = notesStr + " bulk type/subtype set";
eventObj.put("desc", notesStr); eventObj.put("desc", notesStr);
updateEvent(eventObj,new WebApiConnection.JSONObjectCallback() { updateEvent(eventObj, new WebApiConnection.JSONObjectCallback() {
@Override @Override
public void accept(JSONObject eventObj) { public void accept(JSONObject eventObj) {
if (eventObj != null) { if (eventObj != null) {
@@ -176,7 +177,7 @@ public abstract class WebApiConnection {
} }
}); });
} catch (JSONException e) { } catch (JSONException e) {
Log.e(TAG,"markEventsAsTypeSubtype.getEvent.callback: Error editing eventObj"); Log.e(TAG, "markEventsAsTypeSubtype.getEvent.callback: Error editing eventObj");
mUtil.showToast("markEventsAsTypeSubtype.getEvent.callback: Error editing eventObj"); mUtil.showToast("markEventsAsTypeSubtype.getEvent.callback: Error editing eventObj");
} }
} else { } else {
@@ -186,11 +187,11 @@ public abstract class WebApiConnection {
} }
}); });
} else { } else {
Log.i(TAG,"markEventsAsTypeSubtype(): No more events to Modify"); Log.i(TAG, "markEventsAsTypeSubtype(): No more events to Modify");
mUtil.showToast("No more unvalidated events to modify."); mUtil.showToast("No more unvalidated events to modify.");
} }
return(true); return (true);
} }
/** /**
@@ -240,6 +241,7 @@ public abstract class WebApiConnection {
markUnverifiedEventsAsTypeSubtype("Unknown", ""); markUnverifiedEventsAsTypeSubtype("Unknown", "");
return true; return true;
} }
public boolean markUnverifiedEventsAsFalseAlarm() { public boolean markUnverifiedEventsAsFalseAlarm() {
markUnverifiedEventsAsTypeSubtype("False Alarm", ""); markUnverifiedEventsAsTypeSubtype("False Alarm", "");
return true; return true;

View File

@@ -95,7 +95,7 @@ public class WebApiConnection_firebase extends WebApiConnection {
} else { } else {
try { try {
JSONObject retObj = new JSONObject(); JSONObject retObj = new JSONObject();
retObj.put("id",auth.getCurrentUser().getUid()); retObj.put("id", auth.getCurrentUser().getUid());
retObj.put("username", auth.getCurrentUser().getDisplayName()); retObj.put("username", auth.getCurrentUser().getDisplayName());
retObj.put("email", auth.getCurrentUser().getEmail()); retObj.put("email", auth.getCurrentUser().getEmail());
callback.accept(retObj); callback.accept(retObj);
@@ -121,7 +121,7 @@ public class WebApiConnection_firebase extends WebApiConnection {
// passes the newly created documentId to function callback on successful completion, or null on error. // passes the newly created documentId to function callback on successful completion, or null on error.
public boolean createEvent(final int osdAlarmState, final Date eventDate, final String type, final String subType, public boolean createEvent(final int osdAlarmState, final Date eventDate, final String type, final String subType,
final String eventDesc, final String dataJSON, StringCallback callback) { final String eventDesc, final String dataJSON, StringCallback callback) {
// FIXME - save type, subtype, eventDesc and dataJSON // FIXME - save type, subtype, eventDesc and dataJSON
Log.v(TAG, "createEvent()"); Log.v(TAG, "createEvent()");
String userId = null; String userId = null;
@@ -424,7 +424,7 @@ public class WebApiConnection_firebase extends WebApiConnection {
} }
public boolean getCnnModelInfo(JSONObjectCallback callback) { public boolean getCnnModelInfo(JSONObjectCallback callback) {
Log.w(TAG,"getCnnModelInfo() - FIXME - not implemented yet!"); Log.w(TAG, "getCnnModelInfo() - FIXME - not implemented yet!");
return false; return false;
} }

View File

@@ -41,7 +41,7 @@ public class WebApiConnection_osdapi extends WebApiConnection {
public void close() { public void close() {
super.close(); super.close();
Log.i(TAG,"stop()"); Log.i(TAG, "stop()");
mQueue.stop(); mQueue.stop();
} }
@@ -110,8 +110,6 @@ public class WebApiConnection_osdapi extends WebApiConnection {
} }
public boolean isLoggedIn() { public boolean isLoggedIn() {
String authToken = getStoredToken(); String authToken = getStoredToken();
Log.v(TAG, "isLoggedIn(): token=" + authToken); Log.v(TAG, "isLoggedIn(): token=" + authToken);
@@ -119,7 +117,7 @@ public class WebApiConnection_osdapi extends WebApiConnection {
Log.v(TAG, "isLogged in - not logged in"); Log.v(TAG, "isLogged in - not logged in");
return (false); return (false);
} else { } else {
Log.v(TAG,"isLoggedIn - logged in ok"); Log.v(TAG, "isLoggedIn - logged in ok");
return (true); return (true);
} }
@@ -315,7 +313,7 @@ public class WebApiConnection_osdapi extends WebApiConnection {
} else { } else {
Log.e(TAG, "getEvents(): Error: - request returned null networkResponse"); Log.e(TAG, "getEvents(): Error: - request returned null networkResponse");
} }
} else{ } else {
Log.e(TAG, "getEvents(): Error: - request returned null response"); Log.e(TAG, "getEvents(): Error: - request returned null response");
} }
callback.accept(null); callback.accept(null);
@@ -517,6 +515,7 @@ public class WebApiConnection_osdapi extends WebApiConnection {
/** /**
* Retieve the user profile of the authenticated user from the server, and return it to the callback function. * Retieve the user profile of the authenticated user from the server, and return it to the callback function.
*
* @param callback - function to be called with a JSONObject as a parameter that contains the user profile data. * @param callback - function to be called with a JSONObject as a parameter that contains the user profile data.
* @return true if request sent successfully, or else false. * @return true if request sent successfully, or else false.
*/ */
@@ -572,8 +571,6 @@ public class WebApiConnection_osdapi extends WebApiConnection {
} }
/** /**
* Retrieve the file containing the standard event types from the server. * Retrieve the file containing the standard event types from the server.
* Calls the specified callback function, passing a JSONObject as a parameter when the data has been received and parsed. * Calls the specified callback function, passing a JSONObject as a parameter when the data has been received and parsed.
@@ -680,11 +677,10 @@ public class WebApiConnection_osdapi extends WebApiConnection {
} }
/** /**
* Retrieve a trivial file from the server to check we have a good server connection. * Retrieve a trivial file from the server to check we have a good server connection.
* sets mServerConnectionOk. * sets mServerConnectionOk.
*
* @return true if request sent successfully or else false. * @return true if request sent successfully or else false.
*/ */
public boolean checkServerConnection() { public boolean checkServerConnection() {
@@ -714,7 +710,7 @@ public class WebApiConnection_osdapi extends WebApiConnection {
} }
public boolean getCnnModelInfo(JSONObjectCallback callback) { public boolean getCnnModelInfo(JSONObjectCallback callback) {
Log.w(TAG,"getCnnModelInfo() - FIXME - not implemented yet!"); Log.w(TAG, "getCnnModelInfo() - FIXME - not implemented yet!");
return false; return false;
} }