aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--res/values-fr/strings.xml12
-rw-r--r--res/values/strings.xml12
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java24
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java2
4 files changed, 33 insertions, 17 deletions
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index fc46e65..4d558df 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -47,10 +47,12 @@
<string name="msg_gps_provider_started">GPS Bluetooth... démarré</string>
<string name="msg_gps_provider_stopped">GPS Bluetooth... arrêté</string>
<string name="msg_gps_provider_already_started">GPS Bluetooth... déjà démarré</string>
- <string name="msg_gps_provider_disabled">Oups ! Le GPS est désactivé</string>
- <string name="msg_bluetooth_unsupported">Oups ! Bluetooth non disponible</string>
- <string name="msg_bluetooth_disabled">Oups ! Bluetooth désactivé</string>
- <string name="msg_mock_location_disabled">Oups ! Postitions fictives non autorisées</string>
+ <string name="msg_gps_provider_stopped_by_problem">"Oups ! %s"</string>
+ <string name="msg_two_many_connection_problems">Problèmes de connexion</string>
+ <string name="msg_gps_provider_disabled">Le GPS est désactivé</string>
+ <string name="msg_bluetooth_unsupported">Bluetooth non disponible</string>
+ <string name="msg_bluetooth_disabled">Bluetooth désactivé</string>
+ <string name="msg_mock_location_disabled">Postitions fictives non autorisées</string>
<string name="msg_bluetooth_gps_unavaible">Impossible de se connecter au GPS</string>
<string name="msg_nmea_recording_started">Enregistrement des traces NMEA... démarré</string>
<string name="msg_nmea_recording_stopped">Enregistrement des traces NMEA... arrêté</string>
@@ -64,5 +66,5 @@
<item quantity="other">"Encore %d essais avant fermeture"</item>
</plurals>
<string name="service_closed_because_connection_problem_notification_title">BlueGps arrêté</string>
- <string name="service_closed_because_connection_problem_notification">Motif : problèmes de connexion</string>
+ <string name="service_closed_because_connection_problem_notification">"Motif : %s"</string>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cc9c0d6..410ea35 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -50,10 +50,12 @@
<string name="msg_gps_provider_started">Bluetooth GPS... started</string>
<string name="msg_gps_provider_stopped">Bluetooth GPS... stopped</string>
<string name="msg_gps_provider_already_started">Bluetooth GPS... is already on</string>
- <string name="msg_gps_provider_disabled">Cannot start: GPS is disabled</string>
- <string name="msg_bluetooth_unsupported">Cannot start: Bluetooth is not supported</string>
- <string name="msg_bluetooth_disabled">Cannot start: Bluetooth is disabled</string>
- <string name="msg_mock_location_disabled">Cannot start: Mock location is disabled</string>
+ <string name="msg_gps_provider_stopped_by_problem">"Cannot start: %s"</string>
+ <string name="msg_two_many_connection_problems">Too many connection problems</string>
+ <string name="msg_gps_provider_disabled">GPS is disabled</string>
+ <string name="msg_bluetooth_unsupported">Bluetooth is not supported</string>
+ <string name="msg_bluetooth_disabled">Bluetooth is disabled</string>
+ <string name="msg_mock_location_disabled">Mock location is disabled</string>
<string name="msg_bluetooth_gps_unavaible">Cannot connect to bluetooth GPS</string>
<string name="msg_nmea_recording_started">GPS NMEA recording... started</string>
<string name="msg_nmea_recording_stopped">GPS NMEA recording... stopped</string>
@@ -67,5 +69,5 @@
<item quantity="other">Will retry %d more times before closing</item>
</plurals>
<string name="service_closed_because_connection_problem_notification_title">BlueGps stopped</string>
- <string name="service_closed_because_connection_problem_notification">Reason: too many connection problems</string>
+ <string name="service_closed_because_connection_problem_notification">"Reason: %"</string>
</resources>
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);