aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-10-26 02:49:21 +0200
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-10-26 02:49:21 +0200
commita3b73fd4921983fda49f0efa485a894e1c87c5ba (patch)
tree869c81339915fed1728a03139774cb9f3d3b4c9a /src
parent8180e8a7646b11e8665ae68ad373007496acee6e (diff)
downloadBlueGPS-a3b73fd4921983fda49f0efa485a894e1c87c5ba.zip
BlueGPS-a3b73fd4921983fda49f0efa485a894e1c87c5ba.tar.gz
BlueGPS-a3b73fd4921983fda49f0efa485a894e1c87c5ba.tar.bz2
add notifications when service cannot be started
* add notification when service cannot be started
Diffstat (limited to 'src')
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java24
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java2
2 files changed, 19 insertions, 7 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
index ff94ac6..5f1860b 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
@@ -228,16 +228,20 @@ public class BlueetoothGpsManager {
gpsSocket.connect();
// connection obtained so reset the number of connection try
connected = true;
+ // reset eventual disabling cause
+// setDisableReason(0);
nbRetriesRemaining = 1+maxConnectionRetries ;
notificationManager.cancel(R.string.connection_problem_notification_title);
connectedGps = new ConnectedGps(gpsSocket);
connectionAndReadingPool.execute(connectedGps);
}
+// } else if (! bluetoothAdapter.isEnabled()) {
+// setDisableReason(R.string.msg_bluetooth_disabled);
}
} catch (IOException connectException) {
// Unable to connect
Log.e("BT test", "error while connecting to socket", connectException);
- disable(R.string.msg_bluetooth_gps_unavaible);
+ // disable(R.string.msg_bluetooth_gps_unavaible);
} finally {
nbRetriesRemaining--;
if (! connected) {
@@ -271,10 +275,10 @@ public class BlueetoothGpsManager {
connectionProblemNotification.number = 1 + maxConnectionRetries - nbRetriesRemaining;
notificationManager.notify(R.string.connection_problem_notification_title, connectionProblemNotification);
} else {
- notificationManager.cancel(R.string.connection_problem_notification_title);
- serviceStoppedNotification.when = System.currentTimeMillis();
- notificationManager.notify(R.string.service_closed_because_connection_problem_notification_title, serviceStoppedNotification);
- disable();
+// notificationManager.cancel(R.string.connection_problem_notification_title);
+// serviceStoppedNotification.when = System.currentTimeMillis();
+// notificationManager.notify(R.string.service_closed_because_connection_problem_notification_title, serviceStoppedNotification);
+ disable(R.string.msg_two_many_connection_problems);
}
}
}
@@ -285,6 +289,15 @@ public class BlueetoothGpsManager {
}
public synchronized void disable() {
+ notificationManager.cancel(R.string.connection_problem_notification_title);
+ if (getDisableReason() != 0){
+ serviceStoppedNotification.when = System.currentTimeMillis();
+ serviceStoppedNotification.setLatestEventInfo(appContext,
+ appContext.getString(R.string.service_closed_because_connection_problem_notification_title),
+ appContext.getString(R.string.service_closed_because_connection_problem_notification, appContext.getString(getDisableReason())),
+ serviceStoppedNotification.contentIntent);
+ notificationManager.notify(R.string.service_closed_because_connection_problem_notification_title, serviceStoppedNotification);
+ }
if (enabled){
enabled = false;
if (gpsSocket != null){
@@ -298,7 +311,6 @@ public class BlueetoothGpsManager {
disableMockLocationProvider();
notificationPool.shutdown();
connectionAndReadingPool.shutdown();
- notificationManager.cancel(R.string.connection_problem_notification_title);
callingService.stopSelf();
}
}
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
index 1b5c238..5146d1d 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
@@ -181,7 +181,7 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
gpsManager = null;
if (manager != null){
if (manager.getDisableReason() != 0){
- toast.setText(manager.getDisableReason());
+ toast.setText(getString(R.string.msg_gps_provider_stopped_by_problem, getString(manager.getDisableReason())));
toast.show();
} else {
toast.setText(R.string.msg_gps_provider_stopped);