aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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 61177a6..7092c32 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
@@ -471,11 +471,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 0dec608..1290344 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 9bce5f6..ae8534e 100644
--- a/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
+++ b/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
@@ -75,7 +75,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 != "" ){
@@ -89,7 +89,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);