aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/broeuschmeul/android/gps/bluetooth
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-10-12 00:10:42 +0200
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-10-12 00:10:42 +0200
commit78f84170eaf3328526cb3f12559c18eba3167e05 (patch)
tree9f8ab9d5d5bbcc55e6bdd1fa7cdcde5794e6e00d /src/org/broeuschmeul/android/gps/bluetooth
parent2358dc14d7cffac55ec297f335a433f9a73df146 (diff)
parentb45e9c31bd9812359b21b285a0867c435644155b (diff)
downloadBlueGPS-78f84170eaf3328526cb3f12559c18eba3167e05.zip
BlueGPS-78f84170eaf3328526cb3f12559c18eba3167e05.tar.gz
BlueGPS-78f84170eaf3328526cb3f12559c18eba3167e05.tar.bz2
Merge branch 'BlueGPS4Droid_1.0'
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.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
index c1ad6bc..1bf766c 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
@@ -47,9 +47,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;
@@ -156,6 +160,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;
@@ -172,6 +177,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);
@@ -193,7 +199,6 @@ public class BlueetoothGpsManager {
}
-
/**
* @return true if the bluetooth GPS is enabled
*/
@@ -205,13 +210,19 @@ 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");
+ 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){