diff options
author | Herbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com> | 2010-10-24 21:47:42 +0200 |
---|---|---|
committer | Herbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com> | 2010-10-24 21:47:42 +0200 |
commit | c36454f4313b1514603ae91f284542885ebe38f1 (patch) | |
tree | 06d0c3fb181c4681c5b4357392d06404ec0b67ef /src/org/broeuschmeul/android/gps/bluetooth | |
parent | de2c1511892c198ca363e61b0dbb81276de30b72 (diff) | |
download | BlueGPS-c36454f4313b1514603ae91f284542885ebe38f1.zip BlueGPS-c36454f4313b1514603ae91f284542885ebe38f1.tar.gz BlueGPS-c36454f4313b1514603ae91f284542885ebe38f1.tar.bz2 |
autodisable when needed
When Bluetooth, Mock Location or GPS are not enabled, the service
cannot be started correctly and so it will auto-disable itself.
Diffstat (limited to 'src/org/broeuschmeul/android/gps/bluetooth')
-rw-r--r-- | src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java | 2 | ||||
-rw-r--r-- | src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java index 92c5c3e..bca3ca5 100644 --- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java +++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java @@ -162,7 +162,7 @@ public class BlueetoothGpsManager { } 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))
+ && (sharedPreferences.getBoolean(BluetoothGpsProviderService.PREF_REPLACE_STD_GPS, true))
) {
Log.e("BT test", "GPS location provider OFF");
} else {
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java index ef2410d..22b6a0c 100644 --- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java +++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java @@ -104,16 +104,18 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener mockProvider = sharedPreferences.getString(PREF_MOCK_GPS_NAME, getString(R.string.defaultMockGpsName));
}
gpsManager = new BlueetoothGpsManager(this, deviceAddress, maxConRetries);
- gpsManager.enableMockLocationProvider(mockProvider);
boolean enabled = gpsManager.enable();
if (sharedPreferences.getBoolean(PREF_START_GPS_PROVIDER, false) != enabled){
edit.putBoolean(PREF_START_GPS_PROVIDER,enabled);
edit.commit();
}
if (enabled) {
+ gpsManager.enableMockLocationProvider(mockProvider);
startForeground(R.string.foreground_gps_provider_started_notification, notification);
toast.setText(this.getString(R.string.msg_gps_provider_started));
toast.show();
+ } else {
+ stopSelf();
}
} else {
stopSelf();
|