aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-10-11 23:04:41 +0200
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-10-11 23:04:41 +0200
commitde2c1511892c198ca363e61b0dbb81276de30b72 (patch)
tree6486cc37072c3cca41a575b6ec24782b750d2a28 /src
parenta77f4923dc64d502da4089c3c4c555b06b3bf03a (diff)
parentb45e9c31bd9812359b21b285a0867c435644155b (diff)
downloadBlueGPS-de2c1511892c198ca363e61b0dbb81276de30b72.zip
BlueGPS-de2c1511892c198ca363e61b0dbb81276de30b72.tar.gz
BlueGPS-de2c1511892c198ca363e61b0dbb81276de30b72.tar.bz2
merging refs/heads/BlueGPS4Droid_1.0 into HEAD
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')
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
index 41cc8c4..92c5c3e 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
@@ -43,9 +43,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.content.Intent;
import android.location.LocationManager;
import android.location.GpsStatus.NmeaListener;
+import android.preference.PreferenceManager;
+import android.provider.Settings;
import android.os.SystemClock;
import android.util.Log;
@@ -100,6 +104,7 @@ public class BlueetoothGpsManager {
private ScheduledExecutorService connectionAndReadingPool;
private List<NmeaListener> nmeaListeners = Collections.synchronizedList(new LinkedList<NmeaListener>());
private LocationManager locationManager;
+ private SharedPreferences sharedPreferences;
private ConnectedGps connectedGps;
private Notification connectionProblemNotification;
private Notification serviceStoppedNotification;
@@ -116,6 +121,7 @@ public class BlueetoothGpsManager {
this.nbRetriesRemaining = 1+maxRetries;
this.appContext = callingService.getApplicationContext();
locationManager = (LocationManager)callingService.getSystemService(Context.LOCATION_SERVICE);
+ sharedPreferences = PreferenceManager.getDefaultSharedPreferences(callingService);
notificationManager = (NotificationManager)callingService.getSystemService(Context.NOTIFICATION_SERVICE);
parser.setLocationManager(locationManager);
@@ -134,10 +140,7 @@ public class BlueetoothGpsManager {
appContext.getString(R.string.service_closed_because_connection_problem_notification_title),
appContext.getString(R.string.service_closed_because_connection_problem_notification),
restartPendingIntent);
-
-
}
-
/**
* @return true if the bluetooth GPS is enabled
*/
@@ -149,14 +152,20 @@ public class BlueetoothGpsManager {
notificationManager.cancel(R.string.service_closed_because_connection_problem_notification_title);
if (! enabled){
final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
- if (bluetoothAdapter == null) {
- // Device does not support Bluetooth
- Log.e("BT test", "Device does not support Bluetooth");
- } else if (!bluetoothAdapter.isEnabled()) {
+ if (bluetoothAdapter == null) {
+ // Device does not support Bluetooth
+ Log.e("BT test", "Device does not support Bluetooth");
+ } else if (!bluetoothAdapter.isEnabled()) {
// Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
// startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
- Log.e("BT test", "Bluetooth is not enabled");
- } else {
+ 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 {
final BluetoothDevice gpsDevice = bluetoothAdapter.getRemoteDevice(gpsDeviceAddress);
if (gpsDevice == null){
Log.e("BT test", "GPS device not found");