aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/broeuschmeul/android/gps/bluetooth
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-10-11 21:53:24 +0200
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-10-11 21:53:24 +0200
commitb45e9c31bd9812359b21b285a0867c435644155b (patch)
tree91c63627d1c33158a4d8d56c38ac9d205a769ad7 /src/org/broeuschmeul/android/gps/bluetooth
parent42a675e9c5d0f89486d8bd99df00f3b6ce2cab4d (diff)
downloadBlueGPS-b45e9c31bd9812359b21b285a0867c435644155b.zip
BlueGPS-b45e9c31bd9812359b21b285a0867c435644155b.tar.gz
BlueGPS-b45e9c31bd9812359b21b285a0867c435644155b.tar.bz2
add verifications before starting connection
Verify that: - bluetooth is on - Mock Location is enabled - internal GPS is enabled (wont be used but has to be enabled...)
Diffstat (limited to 'src/org/broeuschmeul/android/gps/bluetooth')
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
index 04d7001..e114b45 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
@@ -41,10 +41,13 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
+import android.content.SharedPreferences;
import android.location.Criteria;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.location.GpsStatus.NmeaListener;
+import android.preference.PreferenceManager;
+import android.provider.Settings;
import android.util.Log;
import android.util.PrintStreamPrinter;
@@ -126,6 +129,7 @@ public class BlueetoothGpsManager {
private ExecutorService notificationPool;
private List<NmeaListener> nmeaListeners = Collections.synchronizedList(new LinkedList<NmeaListener>());
private LocationManager locationManager;
+ private SharedPreferences sharedPreferences;
// private boolean mockGpsEnabled = true;
// private String mockLocationProvider = LocationManager.GPS_PROVIDER;
private ConnectedThread connectedThread;
@@ -136,6 +140,7 @@ public class BlueetoothGpsManager {
this.gpsDeviceAddress = deviceAddress;
this.callingService = callingService;
locationManager = (LocationManager)callingService.getSystemService(Context.LOCATION_SERVICE);
+ sharedPreferences = PreferenceManager.getDefaultSharedPreferences(callingService);
parser.setLocationManager(locationManager);
}
@@ -157,6 +162,12 @@ public class BlueetoothGpsManager {
// Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
// startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
Log.e("BT test", "Bluetooth is not enabled");
+ } else if (Settings.Secure.getInt(callingService.getContentResolver(),Settings.Secure.ALLOW_MOCK_LOCATION, 0)==0){
+ Log.e("BT test", "Mock location provider OFF");
+ } else if ( (! locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
+ // && (sharedPreferences.getBoolean(BluetoothGpsProviderService.PREF_REPLACE_STD_GPS, true))
+ ) {
+ Log.e("BT test", "GPS location provider OFF");
} else {
BluetoothDevice gpsDevice = bluetoothAdapter.getRemoteDevice(gpsDeviceAddress);
if (gpsDevice == null){