aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-09-29 22:42:22 +0200
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-09-29 22:42:22 +0200
commit7d0114859db915e18e46858cf6ae3a1535c64d8d (patch)
treef153f07dd6fc3429fac81391751ca01239de55f3 /src
parenta623b51cd0f1ae235ffa2f246f10e0b85b16f334 (diff)
downloadBlueGPS-7d0114859db915e18e46858cf6ae3a1535c64d8d.zip
BlueGPS-7d0114859db915e18e46858cf6ae3a1535c64d8d.tar.gz
BlueGPS-7d0114859db915e18e46858cf6ae3a1535c64d8d.tar.bz2
add preference settings for connection retries
Diffstat (limited to 'src')
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java11
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java5
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java4
3 files changed, 15 insertions, 5 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
index df08bde..2229e6a 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
@@ -106,10 +106,12 @@ public class BlueetoothGpsManager {
private Notification serviceStoppedNotification;
private Context appContext;
private NotificationManager notificationManager;
+ private int maxConnectionRetries;
- public BlueetoothGpsManager(Service callingService, String deviceAddress) {
+ public BlueetoothGpsManager(Service callingService, String deviceAddress, int maxRetries) {
this.gpsDeviceAddress = deviceAddress;
this.callingService = callingService;
+ this.maxConnectionRetries = maxRetries;
this.appContext = callingService.getApplicationContext();
locationManager = (LocationManager)callingService.getSystemService(Context.LOCATION_SERVICE);
notificationManager = (NotificationManager)callingService.getSystemService(Context.NOTIFICATION_SERVICE);
@@ -126,7 +128,10 @@ public class BlueetoothGpsManager {
serviceStoppedNotification.icon=R.drawable.icon;
Intent restartIntent = new Intent(BluetoothGpsProviderService.ACTION_START_GPS_PROVIDER);
PendingIntent restartPendingIntent = PendingIntent.getService(appContext, 0, restartIntent, PendingIntent.FLAG_CANCEL_CURRENT);
- serviceStoppedNotification.setLatestEventInfo(appContext, appContext.getString(R.string.service_closed_because_connection_problem_notification_title), appContext.getString(R.string.service_closed_because_connection_problem_notification_title), restartPendingIntent);
+ serviceStoppedNotification.setLatestEventInfo(appContext,
+ appContext.getString(R.string.service_closed_because_connection_problem_notification_title),
+ appContext.getString(R.string.service_closed_because_connection_problem_notification),
+ restartPendingIntent);
}
@@ -217,7 +222,7 @@ public class BlueetoothGpsManager {
}
// if bluetooth has bean disabled or
// if two much tries consider that we are enable to connect. So close everything and get out
- if ((!bluetoothAdapter.isEnabled()) || (connectionTry >= 5 )){
+ if ((!bluetoothAdapter.isEnabled()) || (connectionTry >= maxConnectionRetries )){
notificationManager.cancel(R.string.connection_problem_notification_title);
serviceStoppedNotification.when = System.currentTimeMillis();
notificationManager.notify(R.string.service_closed_because_connection_problem_notification_title, serviceStoppedNotification);
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
index 85d63ef..b3349b4 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
@@ -100,6 +100,9 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer
pref = (Preference)findPreference(BluetoothGpsProviderService.PREF_MOCK_GPS_NAME);
String mockProvider = sharedPref.getString(BluetoothGpsProviderService.PREF_MOCK_GPS_NAME, getString(R.string.defaultMockGpsName));
pref.setSummary(getString(R.string.pref_mock_gps_name_summary,mockProvider));
+ pref = (Preference)findPreference(BluetoothGpsProviderService.PREF_CONNECTION_RETRIES);
+ String maxConnRetries = sharedPref.getString(BluetoothGpsProviderService.PREF_CONNECTION_RETRIES, getString(R.string.defaultConnectionRetries));
+ pref.setSummary(getString(R.string.pref_connection_retries_summary,maxConnRetries));
pref = (Preference)findPreference(BluetoothGpsProviderService.PREF_GPS_LOCATION_PROVIDER);
if (sharedPref.getBoolean(BluetoothGpsProviderService.PREF_REPLACE_STD_GPS, true)){
String s = getString(R.string.pref_gps_location_provider_summary);
@@ -154,7 +157,7 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer
}
} else if (BluetoothGpsProviderService.PREF_BLUETOOTH_DEVICE.equals(key)){
updateDevicePreferenceSummary();
- }
+ }
this.updateDevicePreferenceList();
}
} \ No newline at end of file
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
index 8e13ef9..ef2410d 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
@@ -64,6 +64,7 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
public static final String PREF_GPS_LOCATION_PROVIDER = "gpsLocationProviderKey";
public static final String PREF_REPLACE_STD_GPS = "replaceStdtGps";
public static final String PREF_MOCK_GPS_NAME = "mockGpsName";
+ public static final String PREF_CONNECTION_RETRIES = "connectionRetries";
public static final String PREF_TRACK_RECORDING = "trackRecording";
public static final String PREF_TRACK_FILE_DIR = "trackFileDirectory";
public static final String PREF_TRACK_FILE_PREFIX = "trackFilePrefix";
@@ -87,6 +88,7 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor edit = sharedPreferences.edit();
String deviceAddress = sharedPreferences.getString(PREF_BLUETOOTH_DEVICE, null);
+ int maxConRetries = Integer.parseInt(sharedPreferences.getString(PREF_CONNECTION_RETRIES, this.getString(R.string.defaultConnectionRetries)));
if (Config.LOGD){
Log.d(BluetoothGpsProviderService.class.getName(), "prefs device addr: "+deviceAddress);
}
@@ -101,7 +103,7 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
if (! sharedPreferences.getBoolean(PREF_REPLACE_STD_GPS, true)){
mockProvider = sharedPreferences.getString(PREF_MOCK_GPS_NAME, getString(R.string.defaultMockGpsName));
}
- gpsManager = new BlueetoothGpsManager(this, deviceAddress);
+ gpsManager = new BlueetoothGpsManager(this, deviceAddress, maxConRetries);
gpsManager.enableMockLocationProvider(mockProvider);
boolean enabled = gpsManager.enable();
if (sharedPreferences.getBoolean(PREF_START_GPS_PROVIDER, false) != enabled){