aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2011-04-28 09:08:34 +0200
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2011-04-28 09:08:34 +0200
commit22aecf56439e4d60e83f4718a3fb3ec80ed3e4df (patch)
treeaa670fc95d00149a742b815f3392a7665005e391 /src
parent37fecb578d9b825678c20623593cb52bb0b3c020 (diff)
downloadBlueGPS-22aecf56439e4d60e83f4718a3fb3ec80ed3e4df.zip
BlueGPS-22aecf56439e4d60e83f4718a3fb3ec80ed3e4df.tar.gz
BlueGPS-22aecf56439e4d60e83f4718a3fb3ec80ed3e4df.tar.bz2
use the optional preference value to force auto-activation of the chosen location provider
Diffstat (limited to 'src')
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java19
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java1
-rw-r--r--src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java5
3 files changed, 22 insertions, 3 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
index b233168..3d2d0a8 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
@@ -456,11 +456,28 @@ public class BlueetoothGpsManager {
* @see NmeaParser#enableMockLocationProvider(java.lang.String)
* @param gpsName the name of the Location Provider to use for the bluetooth GPS
+ * @param force true if we want to force auto-activation of the mock location provider (and bypass user preference).
+ */
+ public void enableMockLocationProvider(String gpsName, boolean force){
+ if (parser != null){
+ Log.d(LOG_TAG, "enabling mock locations provider: "+gpsName);
+ parser.enableMockLocationProvider(gpsName, force);
+ }
+ }
+
+ /**
+ * Enables the Mock GPS Location Provider used for the bluetooth GPS.
+ * In fact, it delegates to the NMEA parser.
+ *
+ * @see NmeaParser#enableMockLocationProvider(java.lang.String)
+
+ * @param gpsName the name of the Location Provider to use for the bluetooth GPS
*/
public void enableMockLocationProvider(String gpsName){
if (parser != null){
Log.d(LOG_TAG, "enabling mock locations provider: "+gpsName);
- parser.enableMockLocationProvider(gpsName);
+ boolean force = sharedPreferences.getBoolean(BluetoothGpsProviderService.PREF_FORCE_ENABLE_PROVIDER, false);
+ parser.enableMockLocationProvider(gpsName, false);
}
}
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
index 49e0f34..a0ef34c 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_START_GPS_PROVIDER = "startGps";
public static final String PREF_GPS_LOCATION_PROVIDER = "gpsLocationProviderKey";
public static final String PREF_REPLACE_STD_GPS = "replaceStdtGps";
+ public static final String PREF_FORCE_ENABLE_PROVIDER = "forceEnableProvider";
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";
diff --git a/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java b/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
index 792a6ba..fb9e906 100644
--- a/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
+++ b/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
@@ -73,7 +73,7 @@ public class NmeaParser {
this.lm = lm;
}
- public void enableMockLocationProvider(String gpsName){
+ public void enableMockLocationProvider(String gpsName, boolean force){
try {
LocationProvider prov;
if (gpsName != null && gpsName != "" ){
@@ -87,7 +87,8 @@ public class NmeaParser {
Log.v(LOG_TAG, "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
}
lm.addTestProvider(mockLocationProvider, false, true,false, false, true, true, true, Criteria.POWER_MEDIUM, Criteria.ACCURACY_FINE);
- if ((prov == null)
+ if ( force
+ || (prov == null)
// || (! LocationManager.GPS_PROVIDER.equals(mockLocationProvider))
){
Log.d(LOG_TAG, "enabling Mock provider: "+mockLocationProvider);