Fixed notificaton problems on Android 13, tidied up start-up sequence. Added a 'restart' menu option.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
OpenSeizureDetector Android App - Change Log
|
||||
============================================
|
||||
|
||||
V4.2.6 - Fixed problem with notifications in Android 13
|
||||
- Improved start-up checks for permissions
|
||||
- Improved system re-start after changing settings (but still not perfect!)
|
||||
V4.2.5 - Set BLE device time if the characteristic is available.
|
||||
V4.2.4 - Added checks and a FAULT condition for Bluetooth errors in Bluetooth Data Source
|
||||
V4.2.3 - Uses 3d accelerometer data to calculate magnitude if vector magnitude is not sent from data source.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:versionCode="139"
|
||||
android:versionName="4.2.6a">
|
||||
android:versionName="4.2.6b">
|
||||
<!-- android:allowBackup="false" -->
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
|
||||
@@ -86,6 +86,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private Intent sdServerIntent;
|
||||
|
||||
final Handler serverStatusHandler = new Handler();
|
||||
final Handler mHandler = new Handler();
|
||||
Messenger messenger = new Messenger(new ResponseHandler());
|
||||
Timer mUiTimer;
|
||||
private Context mContext;
|
||||
@@ -275,22 +276,27 @@ public class MainActivity extends AppCompatActivity {
|
||||
mConnection.mSdServer.acceptAlarm();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_start_stop:
|
||||
case R.id.action_exit:
|
||||
// Respond to the start/stop server menu item.
|
||||
Log.i(TAG, "action_sart_stop");
|
||||
if (mConnection.mBound) {
|
||||
Log.i(TAG, "Stopping Server");
|
||||
mUtil.unbindFromServer(getApplicationContext(), mConnection);
|
||||
stopServer();
|
||||
// we exit the activity when the server is stopped to make it consistent with MainActivity2
|
||||
finish();
|
||||
} else {
|
||||
Log.i(TAG, "Starting Server");
|
||||
startServer();
|
||||
// and bind to it so we can see its data
|
||||
Log.i(TAG, "Binding to Server");
|
||||
mUtil.bindToServer(getApplicationContext(), mConnection);
|
||||
}
|
||||
Log.i(TAG, "action_exit: Stopping Server");
|
||||
mUtil.unbindFromServer(getApplicationContext(), mConnection);
|
||||
stopServer();
|
||||
// We exit this activity as a crude way of forcing the fragments to disconnect from the server
|
||||
// so that the server exits properly - otherwise we end up with multiple threads running.
|
||||
// FIXME - tell the threads to unbind from the serer before calling stopServer as an alternative.
|
||||
finish();
|
||||
return true;
|
||||
case R.id.action_start_stop:
|
||||
Log.i(TAG, "action_start_stop: restarting server");
|
||||
mUtil.showToast("Stopping Background Service....");
|
||||
mUtil.stopServer();
|
||||
// Wait 1 second to give the server chance to shutdown, then re-start it
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mUtil.showToast("Re-Starting Background Service...");
|
||||
mUtil.startServer();
|
||||
}
|
||||
}, 1000);
|
||||
return true;
|
||||
/* fault beep test does not work with fault timer, so disable test option.
|
||||
case R.id.action_test_fault_beep:
|
||||
|
||||
@@ -46,6 +46,7 @@ public class MainActivity2 extends AppCompatActivity {
|
||||
private OsdUtil mUtil;
|
||||
private SdServiceConnection mConnection;
|
||||
final Handler serverStatusHandler = new Handler();
|
||||
private Handler mHandler = new Handler();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -65,8 +66,7 @@ public class MainActivity2 extends AppCompatActivity {
|
||||
mConnection = new SdServiceConnection(getApplicationContext());
|
||||
mUtil.writeToSysLogFile("MainActivity2.onCreate()");
|
||||
mContext = this;
|
||||
|
||||
|
||||
mHandler = new Handler();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,24 +194,27 @@ public class MainActivity2 extends AppCompatActivity {
|
||||
mConnection.mSdServer.acceptAlarm();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_start_stop:
|
||||
case R.id.action_exit:
|
||||
// Respond to the start/stop server menu item.
|
||||
Log.i(TAG, "action_start_stop");
|
||||
if (mConnection.mBound) {
|
||||
Log.i(TAG, "Stopping Server");
|
||||
mUtil.unbindFromServer(getApplicationContext(), mConnection);
|
||||
stopServer();
|
||||
// We exit this activity as a crude way of forcing the fragments to disconnect from the server
|
||||
// so that the server exits properly - otherwise we end up with multiple threads running.
|
||||
// FIXME - tell the threads to unbind from the serer before calling stopServer as an alternative.
|
||||
finish();
|
||||
} else {
|
||||
Log.i(TAG, "Starting Server");
|
||||
startServer();
|
||||
// and bind to it so we can see its data
|
||||
Log.i(TAG, "Binding to Server");
|
||||
mUtil.bindToServer(getApplicationContext(), mConnection);
|
||||
}
|
||||
Log.i(TAG, "action_exit: Stopping Server");
|
||||
mUtil.unbindFromServer(getApplicationContext(), mConnection);
|
||||
stopServer();
|
||||
// We exit this activity as a crude way of forcing the fragments to disconnect from the server
|
||||
// so that the server exits properly - otherwise we end up with multiple threads running.
|
||||
// FIXME - tell the threads to unbind from the serer before calling stopServer as an alternative.
|
||||
finish();
|
||||
return true;
|
||||
case R.id.action_start_stop:
|
||||
Log.i(TAG, "action_start_stop: restarting server");
|
||||
mUtil.showToast("Stopping Background Service....");
|
||||
mUtil.stopServer();
|
||||
// Wait 1 second to give the server chance to shutdown, then re-start it
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mUtil.showToast("Re-Starting Background Service...");
|
||||
mUtil.startServer();
|
||||
}
|
||||
}, 1000);
|
||||
return true;
|
||||
case R.id.action_test_alarm_beep:
|
||||
Log.i(TAG, "action_test_alarm_beep");
|
||||
|
||||
@@ -160,6 +160,7 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
|
||||
Log.i(TAG, "OnSharedPreferenceChanged(): SMS Alarm disabled so do not need permissions");
|
||||
}
|
||||
}
|
||||
// If we have changed the data source, re-start the whole system
|
||||
if (s.equals("DataSource")) {
|
||||
Log.i(TAG, "onSharedPreferenceChanged(): Data Source Changed - Restarting start-up activity to check permissions");
|
||||
mUtil.showToast("Restarting OpenSeizureDetector");
|
||||
@@ -176,25 +177,27 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
|
||||
return;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
// For all other preference changes we just restart SdServer so it is not as alarming for the user!
|
||||
//mUtil.showToast("Setting " + s + " Changed - restarting server");
|
||||
mUtil.showToast("Restarting OpenSeizureDetector");
|
||||
mPrefChanged = true;
|
||||
mUtil.stopServer();
|
||||
// Wait 1 second to give the server chance to shutdown, then re-start it
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mUtil.startServer();
|
||||
return;
|
||||
} else {
|
||||
// For all other preference changes we just restart SdServer so it is not as alarming for the user!
|
||||
//mUtil.showToast("Setting " + s + " Changed - restarting server");
|
||||
mUtil.showToast("Stopping Background Service...");
|
||||
mPrefChanged = true;
|
||||
mUtil.stopServer();
|
||||
// Wait 1 second to give the server chance to shutdown, then re-start it
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mUtil.showToast("Re-Starting Background Service...");
|
||||
mUtil.startServer();
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
if (s.equals("advancedMode")) {
|
||||
Log.i(TAG, "Re-starting PrefActivity to refresh list");
|
||||
startActivity(getIntent());
|
||||
finish();
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
if (s.equals("DataSource") || s.equals("advancedMode")) {
|
||||
Log.i(TAG, "Re-starting PrefActivity to refresh list");
|
||||
startActivity(getIntent());
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -124,6 +124,14 @@ public class StartupActivity extends AppCompatActivity {
|
||||
private String mBleDeviceAddr;
|
||||
private String mBleDeviceName;
|
||||
|
||||
private final int MODE_INIT = 0;
|
||||
private final int MODE_SHUTDOWN_SERVER = 1;
|
||||
private final int MODE_START_SERVER = 2;
|
||||
private final int MODE_CONNECT_SERVER = 3;
|
||||
private final int MODE_WATCH_RUNNING = 4;
|
||||
private final int MODE_SD_DATA_OK = 5;
|
||||
private int mMode = MODE_INIT;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -221,10 +229,12 @@ public class StartupActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
if (mUtil.isServerRunning()) {
|
||||
mMode = MODE_SHUTDOWN_SERVER;
|
||||
Log.i(TAG, "onStart() - server running - stopping it - isServerRunning=" + mUtil.isServerRunning());
|
||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - server already running - stopping it.");
|
||||
mUtil.stopServer();
|
||||
} else {
|
||||
mMode = MODE_START_SERVER;
|
||||
Log.i(TAG, "onStart() - server not running - isServerRunning=" + mUtil.isServerRunning());
|
||||
}
|
||||
|
||||
@@ -375,13 +385,27 @@ public class StartupActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
if (allOk) {
|
||||
tv = (TextView) findViewById(R.id.textItem1);
|
||||
pb = (ProgressBar) findViewById(R.id.progressBar1);
|
||||
|
||||
if (!mUtil.isServerRunning()) {
|
||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - starting server - isServerRunning=" + mUtil.isServerRunning());
|
||||
Log.i(TAG, "onStart() - starting server -isServerRunning=" + mUtil.isServerRunning());
|
||||
mUtil.startServer();
|
||||
mBindInProgress = false;
|
||||
allOk = false;
|
||||
tv.setText("Starting Server");
|
||||
tv.setBackgroundColor(alarmColour);
|
||||
tv.setTextColor(alarmTextColour);
|
||||
pb.setIndeterminateDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
pb.setProgressDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
mMode = MODE_START_SERVER;
|
||||
} else {
|
||||
tv.setText(getString(R.string.ServerRunningOK));
|
||||
tv.setBackgroundColor(okColour);
|
||||
tv.setTextColor(okTextColour);
|
||||
pb.setIndeterminateDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
pb.setProgressDrawable(getResources().getDrawable(R.drawable.start_server));
|
||||
if (mBindInProgress) {
|
||||
Log.i(TAG,"Waiting to bind to server");
|
||||
} else {
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
android:id="@+id/action_start_stop"
|
||||
android:icon="@drawable/stop_server"
|
||||
app:showAsAction="never|withText"
|
||||
android:title="@string/restart_server" />
|
||||
<item
|
||||
android:id="@+id/action_exit"
|
||||
android:icon="@drawable/stop_server"
|
||||
app:showAsAction="never|withText"
|
||||
android:title="@string/start_stop_server" />
|
||||
</group>
|
||||
<group android:id="@+id/grp3">
|
||||
|
||||
@@ -574,4 +574,5 @@
|
||||
<string name="BTPermissionWarning">Bluetooth Permissions Not Granted</string>
|
||||
<string name="BTpermissions_required">Bluetooth Permissions Required</string>
|
||||
<string name="BT_permissions_rationale">Bluetooth permissions are required to communicate with the bluetooth (BLE) data source</string>
|
||||
<string name="restart_server">Restart Server</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user