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
|
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.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.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.
|
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"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:versionCode="139"
|
android:versionCode="139"
|
||||||
android:versionName="4.2.6a">
|
android:versionName="4.2.6b">
|
||||||
<!-- android:allowBackup="false" -->
|
<!-- android:allowBackup="false" -->
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private Intent sdServerIntent;
|
private Intent sdServerIntent;
|
||||||
|
|
||||||
final Handler serverStatusHandler = new Handler();
|
final Handler serverStatusHandler = new Handler();
|
||||||
|
final Handler mHandler = new Handler();
|
||||||
Messenger messenger = new Messenger(new ResponseHandler());
|
Messenger messenger = new Messenger(new ResponseHandler());
|
||||||
Timer mUiTimer;
|
Timer mUiTimer;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -275,22 +276,27 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
mConnection.mSdServer.acceptAlarm();
|
mConnection.mSdServer.acceptAlarm();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_start_stop:
|
case R.id.action_exit:
|
||||||
// Respond to the start/stop server menu item.
|
// Respond to the start/stop server menu item.
|
||||||
Log.i(TAG, "action_sart_stop");
|
Log.i(TAG, "action_exit: Stopping Server");
|
||||||
if (mConnection.mBound) {
|
|
||||||
Log.i(TAG, "Stopping Server");
|
|
||||||
mUtil.unbindFromServer(getApplicationContext(), mConnection);
|
mUtil.unbindFromServer(getApplicationContext(), mConnection);
|
||||||
stopServer();
|
stopServer();
|
||||||
// we exit the activity when the server is stopped to make it consistent with MainActivity2
|
// 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();
|
finish();
|
||||||
} else {
|
return true;
|
||||||
Log.i(TAG, "Starting Server");
|
case R.id.action_start_stop:
|
||||||
startServer();
|
Log.i(TAG, "action_start_stop: restarting server");
|
||||||
// and bind to it so we can see its data
|
mUtil.showToast("Stopping Background Service....");
|
||||||
Log.i(TAG, "Binding to Server");
|
mUtil.stopServer();
|
||||||
mUtil.bindToServer(getApplicationContext(), mConnection);
|
// 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;
|
return true;
|
||||||
/* fault beep test does not work with fault timer, so disable test option.
|
/* fault beep test does not work with fault timer, so disable test option.
|
||||||
case R.id.action_test_fault_beep:
|
case R.id.action_test_fault_beep:
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ 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();
|
||||||
|
private Handler mHandler = new Handler();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -65,8 +66,7 @@ public class MainActivity2 extends AppCompatActivity {
|
|||||||
mConnection = new SdServiceConnection(getApplicationContext());
|
mConnection = new SdServiceConnection(getApplicationContext());
|
||||||
mUtil.writeToSysLogFile("MainActivity2.onCreate()");
|
mUtil.writeToSysLogFile("MainActivity2.onCreate()");
|
||||||
mContext = this;
|
mContext = this;
|
||||||
|
mHandler = new Handler();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,24 +194,27 @@ public class MainActivity2 extends AppCompatActivity {
|
|||||||
mConnection.mSdServer.acceptAlarm();
|
mConnection.mSdServer.acceptAlarm();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_start_stop:
|
case R.id.action_exit:
|
||||||
// Respond to the start/stop server menu item.
|
// Respond to the start/stop server menu item.
|
||||||
Log.i(TAG, "action_start_stop");
|
Log.i(TAG, "action_exit: Stopping Server");
|
||||||
if (mConnection.mBound) {
|
|
||||||
Log.i(TAG, "Stopping Server");
|
|
||||||
mUtil.unbindFromServer(getApplicationContext(), mConnection);
|
mUtil.unbindFromServer(getApplicationContext(), mConnection);
|
||||||
stopServer();
|
stopServer();
|
||||||
// We exit this activity as a crude way of forcing the fragments to disconnect from the server
|
// 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.
|
// 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.
|
// FIXME - tell the threads to unbind from the serer before calling stopServer as an alternative.
|
||||||
finish();
|
finish();
|
||||||
} else {
|
return true;
|
||||||
Log.i(TAG, "Starting Server");
|
case R.id.action_start_stop:
|
||||||
startServer();
|
Log.i(TAG, "action_start_stop: restarting server");
|
||||||
// and bind to it so we can see its data
|
mUtil.showToast("Stopping Background Service....");
|
||||||
Log.i(TAG, "Binding to Server");
|
mUtil.stopServer();
|
||||||
mUtil.bindToServer(getApplicationContext(), mConnection);
|
// 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;
|
return true;
|
||||||
case R.id.action_test_alarm_beep:
|
case R.id.action_test_alarm_beep:
|
||||||
Log.i(TAG, "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");
|
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")) {
|
if (s.equals("DataSource")) {
|
||||||
Log.i(TAG, "onSharedPreferenceChanged(): Data Source Changed - Restarting start-up activity to check permissions");
|
Log.i(TAG, "onSharedPreferenceChanged(): Data Source Changed - Restarting start-up activity to check permissions");
|
||||||
mUtil.showToast("Restarting OpenSeizureDetector");
|
mUtil.showToast("Restarting OpenSeizureDetector");
|
||||||
@@ -176,25 +177,27 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
return;
|
||||||
|
} else {
|
||||||
// For all other preference changes we just restart SdServer so it is not as alarming for the user!
|
// 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("Setting " + s + " Changed - restarting server");
|
||||||
mUtil.showToast("Restarting OpenSeizureDetector");
|
mUtil.showToast("Stopping Background Service...");
|
||||||
mPrefChanged = true;
|
mPrefChanged = true;
|
||||||
mUtil.stopServer();
|
mUtil.stopServer();
|
||||||
// Wait 1 second to give the server chance to shutdown, then re-start it
|
// Wait 1 second 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() {
|
||||||
|
mUtil.showToast("Re-Starting Background Service...");
|
||||||
mUtil.startServer();
|
mUtil.startServer();
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
if (s.equals("DataSource") || s.equals("advancedMode")) {
|
if (s.equals("advancedMode")) {
|
||||||
Log.i(TAG, "Re-starting PrefActivity to refresh list");
|
Log.i(TAG, "Re-starting PrefActivity to refresh list");
|
||||||
startActivity(getIntent());
|
startActivity(getIntent());
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -124,6 +124,14 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
private String mBleDeviceAddr;
|
private String mBleDeviceAddr;
|
||||||
private String mBleDeviceName;
|
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
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -221,10 +229,12 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
if (mUtil.isServerRunning()) {
|
if (mUtil.isServerRunning()) {
|
||||||
|
mMode = MODE_SHUTDOWN_SERVER;
|
||||||
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 {
|
||||||
|
mMode = MODE_START_SERVER;
|
||||||
Log.i(TAG, "onStart() - server not running - isServerRunning=" + mUtil.isServerRunning());
|
Log.i(TAG, "onStart() - server not running - isServerRunning=" + mUtil.isServerRunning());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,13 +385,27 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allOk) {
|
if (allOk) {
|
||||||
|
tv = (TextView) findViewById(R.id.textItem1);
|
||||||
|
pb = (ProgressBar) findViewById(R.id.progressBar1);
|
||||||
|
|
||||||
if (!mUtil.isServerRunning()) {
|
if (!mUtil.isServerRunning()) {
|
||||||
mUtil.writeToSysLogFile("StartupActivity.onStart() - starting server - isServerRunning=" + mUtil.isServerRunning());
|
mUtil.writeToSysLogFile("StartupActivity.onStart() - starting server - isServerRunning=" + mUtil.isServerRunning());
|
||||||
Log.i(TAG, "onStart() - starting server -isServerRunning=" + mUtil.isServerRunning());
|
Log.i(TAG, "onStart() - starting server -isServerRunning=" + mUtil.isServerRunning());
|
||||||
mUtil.startServer();
|
mUtil.startServer();
|
||||||
mBindInProgress = false;
|
mBindInProgress = false;
|
||||||
allOk = 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 {
|
} 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) {
|
if (mBindInProgress) {
|
||||||
Log.i(TAG,"Waiting to bind to server");
|
Log.i(TAG,"Waiting to bind to server");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -12,6 +12,11 @@
|
|||||||
android:id="@+id/action_start_stop"
|
android:id="@+id/action_start_stop"
|
||||||
android:icon="@drawable/stop_server"
|
android:icon="@drawable/stop_server"
|
||||||
app:showAsAction="never|withText"
|
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" />
|
android:title="@string/start_stop_server" />
|
||||||
</group>
|
</group>
|
||||||
<group android:id="@+id/grp3">
|
<group android:id="@+id/grp3">
|
||||||
|
|||||||
@@ -574,4 +574,5 @@
|
|||||||
<string name="BTPermissionWarning">Bluetooth Permissions Not Granted</string>
|
<string name="BTPermissionWarning">Bluetooth Permissions Not Granted</string>
|
||||||
<string name="BTpermissions_required">Bluetooth Permissions Required</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="BT_permissions_rationale">Bluetooth permissions are required to communicate with the bluetooth (BLE) data source</string>
|
||||||
|
<string name="restart_server">Restart Server</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user