aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java300
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java59
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java18
3 files changed, 195 insertions, 182 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
index 4deba63..0c9f455 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
@@ -21,6 +21,8 @@
package org.broeuschmeul.android.gps.bluetooth.provider;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -36,6 +38,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import org.broeuschmeul.android.gps.internal.provider.R;
import org.broeuschmeul.android.gps.nmea.util.NmeaParser;
import org.broeuschmeul.android.gps.sirf.util.SirfUtils;
@@ -43,9 +46,9 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothSocket;
+//import android.bluetooth.BluetoothAdapter;
+//import android.bluetooth.BluetoothDevice;
+//import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.Intent;
@@ -81,7 +84,7 @@ public class BlueetoothGpsManager {
/**
* GPS bluetooth socket used for communication.
*/
- private final BluetoothSocket socket;
+ private final File gpsDev ;
/**
* GPS InputStream from which we read data.
*/
@@ -89,34 +92,34 @@ public class BlueetoothGpsManager {
/**
* GPS output stream to which we send data (SIRF III binary commands).
*/
- private final OutputStream out;
+ //private final OutputStream out;
/**
* GPS output stream to which we send data (SIRF III NMEA commands).
*/
- private final PrintStream out2;
+ //private final PrintStream out2;
/**
* A boolean which indicates if the GPS is ready to receive data.
* In fact we consider that the GPS is ready when it begins to sends data...
*/
private boolean ready = false;
- public ConnectedGps(BluetoothSocket socket) {
- this.socket = socket;
+ public ConnectedGps(File gpsDev) {
+ this.gpsDev = gpsDev;
InputStream tmpIn = null;
- OutputStream tmpOut = null;
- PrintStream tmpOut2 = null;
+ //OutputStream tmpOut = null;
+ //PrintStream tmpOut2 = null;
try {
- tmpIn = socket.getInputStream();
- tmpOut = socket.getOutputStream();
- if (tmpOut != null){
- tmpOut2 = new PrintStream(tmpOut, false, "US-ASCII");
- }
+ tmpIn = new FileInputStream(gpsDev);
+ //tmpOut = new FileOutputStream(gpsDev);
+ //if (tmpOut != null){
+ // tmpOut2 = new PrintStream(tmpOut, false, "US-ASCII");
+ //}
} catch (IOException e) {
Log.e(LOG_TAG, "error while getting socket streams", e);
}
in = tmpIn;
- out = tmpOut;
- out2 = tmpOut2;
+ //out = tmpOut;
+ //out2 = tmpOut2;
}
public boolean isReady(){
@@ -156,38 +159,38 @@ public class BlueetoothGpsManager {
* Write to the connected OutStream.
* @param buffer The bytes to write
*/
- public void write(byte[] buffer) {
- try {
- do {
- Thread.sleep(100);
- } while ((enabled) && (! ready));
- if ((enabled) && (ready)){
- out.write(buffer);
- out.flush();
- }
- } catch (IOException e) {
- Log.e(LOG_TAG, "Exception during write", e);
- } catch (InterruptedException e) {
- Log.e(LOG_TAG, "Exception during write", e);
- }
- }
+// public void write(byte[] buffer) {
+// try {
+// do {
+// Thread.sleep(100);
+// } while ((enabled) && (! ready));
+// if ((enabled) && (ready)){
+// out.write(buffer);
+// out.flush();
+// }
+// } catch (IOException e) {
+// Log.e(LOG_TAG, "Exception during write", e);
+// } catch (InterruptedException e) {
+// Log.e(LOG_TAG, "Exception during write", e);
+// }
+// }
/**
* Write to the connected OutStream.
* @param buffer The data to write
*/
- public void write(String buffer) {
- try {
- do {
- Thread.sleep(100);
- } while ((enabled) && (! ready));
- if ((enabled) && (ready)){
- out2.print(buffer);
- out2.flush();
- }
- } catch (InterruptedException e) {
- Log.e(LOG_TAG, "Exception during write", e);
- }
- }
+// public void write(String buffer) {
+// try {
+// do {
+// Thread.sleep(100);
+// } while ((enabled) && (! ready));
+// if ((enabled) && (ready)){
+// out2.print(buffer);
+// out2.flush();
+// }
+// } catch (InterruptedException e) {
+// Log.e(LOG_TAG, "Exception during write", e);
+// }
+// }
public void close(){
ready = false;
@@ -197,26 +200,27 @@ public class BlueetoothGpsManager {
} catch (IOException e) {
Log.e(LOG_TAG, "error while closing GPS NMEA output stream", e);
} finally {
- try {
- Log.d(LOG_TAG, "closing Bluetooth GPS input streams");
- out2.close();
- out.close();
- } catch (IOException e) {
- Log.e(LOG_TAG, "error while closing GPS input streams", e);
- } finally {
- try {
- Log.d(LOG_TAG, "closing Bluetooth GPS socket");
- socket.close();
- } catch (IOException e) {
- Log.e(LOG_TAG, "error while closing GPS socket", e);
- }
- }
+// try {
+// Log.d(LOG_TAG, "closing Bluetooth GPS input streams");
+// out2.close();
+// out.close();
+// } catch (IOException e) {
+// Log.e(LOG_TAG, "error while closing GPS input streams", e);
+// } finally {
+// try {
+// Log.d(LOG_TAG, "closing Bluetooth GPS socket");
+// socket.close();
+// } catch (IOException e) {
+// Log.e(LOG_TAG, "error while closing GPS socket", e);
+// }
+// }
}
}
}
private Service callingService;
- private BluetoothSocket gpsSocket;
+// private BluetoothSocket gpsSocket;
+ private File gpsDev ;
private String gpsDeviceAddress;
private NmeaParser parser = new NmeaParser(10f);
private boolean enabled = false;
@@ -294,17 +298,18 @@ public class BlueetoothGpsManager {
notificationManager.cancel(R.string.service_closed_because_connection_problem_notification_title);
if (! enabled){
Log.d(LOG_TAG, "enabling Bluetooth GPS manager");
- final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
- if (bluetoothAdapter == null) {
- // Device does not support Bluetooth
- Log.e(LOG_TAG, "Device does not support Bluetooth");
- disable(R.string.msg_bluetooth_unsupported);
- } else if (!bluetoothAdapter.isEnabled()) {
- // Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
- // startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
- Log.e(LOG_TAG, "Bluetooth is not enabled");
- disable(R.string.msg_bluetooth_disabled);
- } else if (Settings.Secure.getInt(callingService.getContentResolver(),Settings.Secure.ALLOW_MOCK_LOCATION, 0)==0){
+// final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+// if (bluetoothAdapter == null) {
+// // Device does not support Bluetooth
+// Log.e(LOG_TAG, "Device does not support Bluetooth");
+// disable(R.string.msg_bluetooth_unsupported);
+// } else if (!bluetoothAdapter.isEnabled()) {
+// // Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+// // startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
+// Log.e(LOG_TAG, "Bluetooth is not enabled");
+// disable(R.string.msg_bluetooth_disabled);
+// } else
+ if (Settings.Secure.getInt(callingService.getContentResolver(),Settings.Secure.ALLOW_MOCK_LOCATION, 0)==0){
Log.e(LOG_TAG, "Mock location provider OFF");
disable(R.string.msg_mock_location_disabled);
// } else if ( (! locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
@@ -313,19 +318,21 @@ public class BlueetoothGpsManager {
// Log.e(LOG_TAG, "GPS location provider OFF");
// disable(R.string.msg_gps_provider_disabled);
} else {
- final BluetoothDevice gpsDevice = bluetoothAdapter.getRemoteDevice(gpsDeviceAddress);
+// final BluetoothDevice gpsDevice = bluetoothAdapter.getRemoteDevice(gpsDeviceAddress);
+ final String gpsDevice = gpsDeviceAddress;
if (gpsDevice == null){
Log.e(LOG_TAG, "GPS device not found");
disable(R.string.msg_bluetooth_gps_unavaible);
} else {
- Log.e(LOG_TAG, "current device: "+gpsDevice.getName() + " -- " + gpsDevice.getAddress());
- try {
- gpsSocket = gpsDevice.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
- } catch (IOException e) {
- Log.e(LOG_TAG, "Error during connection", e);
- gpsSocket = null;
- }
- if (gpsSocket == null){
+ Log.e(LOG_TAG, "current device: "+gpsDevice );
+// try {
+// gpsSocket = gpsDevice.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
+ gpsDev = new File(gpsDeviceAddress);
+// } catch (IOException e) {
+// Log.e(LOG_TAG, "Error during connection", e);
+// gpsDev = null;
+// }
+ if (gpsDev == null){
Log.e(LOG_TAG, "Error while establishing connection: no socket");
disable(R.string.msg_bluetooth_gps_unavaible);
} else {
@@ -334,36 +341,37 @@ public class BlueetoothGpsManager {
public void run() {
try {
connected = false;
- Log.v(LOG_TAG, "current device: "+gpsDevice.getName() + " -- " + gpsDevice.getAddress());
- if ((bluetoothAdapter.isEnabled()) && (nbRetriesRemaining > 0 )){
- try {
+ Log.v(LOG_TAG, "current device: "+gpsDevice);
+ if (/*(bluetoothAdapter.isEnabled()) && */(nbRetriesRemaining > 0 )){
+// try {
if (connectedGps != null){
connectedGps.close();
}
- if ((gpsSocket != null) && ((connectedGps == null) || (connectedGps.socket != gpsSocket))){
- Log.d(LOG_TAG, "trying to close old socket");
- gpsSocket.close();
- }
- } catch (IOException e) {
- Log.e(LOG_TAG, "Error during disconnection", e);
- }
- try {
- gpsSocket = gpsDevice.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
- } catch (IOException e) {
- Log.e(LOG_TAG, "Error during connection", e);
- gpsSocket = null;
- }
- if (gpsSocket == null){
- Log.e(LOG_TAG, "Error while establishing connection: no socket");
+// if ((gpsDev != null) && ((connectedGps == null) || (connectedGps.gpsDev != gpsDev))){
+// Log.d(LOG_TAG, "trying to close old socket");
+// gpsSocket.close();
+// }
+// } catch (IOException e) {
+// Log.e(LOG_TAG, "Error during disconnection", e);
+// }
+// try {
+// gpsSocket = gpsDevice.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
+ gpsDev = new File(gpsDeviceAddress);
+// } catch (IOException e) {
+// Log.e(LOG_TAG, "Error during connection", e);
+// gpsDev = null;
+// }
+ if (gpsDev == null){
+ Log.e(LOG_TAG, "Error while establishing connection: no device");
disable(R.string.msg_bluetooth_gps_unavaible);
} else {
// Cancel discovery because it will slow down the connection
- bluetoothAdapter.cancelDiscovery();
+// bluetoothAdapter.cancelDiscovery();
// we increment the number of connection tries
// Connect the device through the socket. This will block
// until it succeeds or throws an exception
Log.v(LOG_TAG, "connecting to socket");
- gpsSocket.connect();
+// gpsDev.connect();
Log.d(LOG_TAG, "connected to socket");
connected = true;
// reset eventual disabling cause
@@ -372,17 +380,17 @@ public class BlueetoothGpsManager {
nbRetriesRemaining = 1+maxConnectionRetries ;
notificationManager.cancel(R.string.connection_problem_notification_title);
Log.v(LOG_TAG, "starting socket reading task");
- connectedGps = new ConnectedGps(gpsSocket);
+ connectedGps = new ConnectedGps(gpsDev);
connectionAndReadingPool.execute(connectedGps);
Log.v(LOG_TAG, "socket reading thread started");
}
// } else if (! bluetoothAdapter.isEnabled()) {
// setDisableReason(R.string.msg_bluetooth_disabled);
}
- } catch (IOException connectException) {
- // Unable to connect
- Log.e(LOG_TAG, "error while connecting to socket", connectException);
- // disable(R.string.msg_bluetooth_gps_unavaible);
+// } catch (IOException connectException) {
+// // Unable to connect
+// Log.e(LOG_TAG, "error while connecting to socket", connectException);
+// // disable(R.string.msg_bluetooth_gps_unavaible);
} finally {
nbRetriesRemaining--;
if (! connected) {
@@ -494,14 +502,14 @@ public class BlueetoothGpsManager {
if (connectedGps != null){
connectedGps.close();
}
- if ((gpsSocket != null) && ((connectedGps == null) || (connectedGps.socket != gpsSocket))){
- try {
- Log.d(LOG_TAG, "closing Bluetooth GPS socket");
- gpsSocket.close();
- } catch (IOException closeException) {
- Log.e(LOG_TAG, "error while closing socket", closeException);
- }
- }
+// if ((gpsDev != null) && ((connectedGps == null) || (connectedGps.gpsDev != gpsDev))){
+// try {
+// Log.d(LOG_TAG, "closing Bluetooth GPS socket");
+// gpsDev.close();
+// } catch (IOException closeException) {
+// Log.e(LOG_TAG, "error while closing socket", closeException);
+// }
+// }
}
}
};
@@ -672,22 +680,22 @@ public class BlueetoothGpsManager {
* @param command the complete NMEA sentence (i.e. $....*XY where XY is the checksum).
*/
public void sendPackagedNmeaCommand(final String command){
- Log.d(LOG_TAG, "sending NMEA sentence: "+command);
- if (isEnabled()){
- notificationPool.execute( new Runnable() {
- @Override
- public void run() {
- while ((enabled) && ((!connected) || (connectedGps == null) || (!connectedGps.isReady()))){
- Log.v(LOG_TAG, "writing thread is not ready");
- SystemClock.sleep(500);
- }
- if (isEnabled() && (connectedGps != null)){
- connectedGps.write(command);
- Log.d(LOG_TAG, "sent NMEA sentence: "+command);
- }
- }
- });
- }
+ Log.e(LOG_TAG, "Disabled .... sending NMEA sentence: "+command);
+// if (isEnabled()){
+// notificationPool.execute( new Runnable() {
+// @Override
+// public void run() {
+// while ((enabled) && ((!connected) || (connectedGps == null) || (!connectedGps.isReady()))){
+// Log.v(LOG_TAG, "writing thread is not ready");
+// SystemClock.sleep(500);
+// }
+// if (isEnabled() && (connectedGps != null)){
+// connectedGps.write(command);
+// Log.d(LOG_TAG, "sent NMEA sentence: "+command);
+// }
+// }
+// });
+// }
}
/**
@@ -697,23 +705,23 @@ public class BlueetoothGpsManager {
* (i.e. with the <em>Start Sequence</em>, <em>Payload Length</em>, <em>Payload</em>, <em>Message Checksum</em> and <em>End Sequence</em>).
*/
public void sendPackagedSirfCommand(final String commandHexa){
- Log.d(LOG_TAG, "sending SIRF sentence: "+commandHexa);
- if (isEnabled()){
- final byte[] command = SirfUtils.genSirfCommand(commandHexa);
- notificationPool.execute( new Runnable() {
- @Override
- public void run() {
- while ((enabled) && ((!connected) || (connectedGps == null) || (!connectedGps.isReady()))){
- Log.v(LOG_TAG, "writing thread is not ready");
- SystemClock.sleep(500);
- }
- if (isEnabled() && (connectedGps != null)){
- connectedGps.write(command);
- Log.d(LOG_TAG, "sent SIRF sentence: "+commandHexa);
- }
- }
- });
- }
+ Log.d(LOG_TAG, "Disabled sending SIRF sentence: "+commandHexa);
+// if (isEnabled()){
+// final byte[] command = SirfUtils.genSirfCommand(commandHexa);
+// notificationPool.execute( new Runnable() {
+// @Override
+// public void run() {
+// while ((enabled) && ((!connected) || (connectedGps == null) || (!connectedGps.isReady()))){
+// Log.v(LOG_TAG, "writing thread is not ready");
+// SystemClock.sleep(500);
+// }
+// if (isEnabled() && (connectedGps != null)){
+// connectedGps.write(command);
+// Log.d(LOG_TAG, "sent SIRF sentence: "+commandHexa);
+// }
+// }
+// });
+// }
}
/**
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
index 885148c..c483815 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
@@ -23,14 +23,17 @@ package org.broeuschmeul.android.gps.bluetooth.provider;
import java.util.HashSet;
import java.util.Set;
+import org.broeuschmeul.android.gps.internal.provider.R;
+
import android.app.AlertDialog;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
+//import android.bluetooth.BluetoothAdapter;
+//import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
+import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
@@ -55,7 +58,7 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer
private static final String LOG_TAG = "BlueGPS";
private SharedPreferences sharedPref ;
- private BluetoothAdapter bluetoothAdapter = null;
+// private BluetoothAdapter bluetoothAdapter = null;
/** Called when the activity is first created. */
@Override
@@ -64,7 +67,7 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer
addPreferencesFromResource(R.xml.pref);
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
sharedPref.registerOnSharedPreferenceChangeListener(this);
- bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+// bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Preference pref = findPreference(BluetoothGpsProviderService.PREF_ABOUT);
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
@@ -86,12 +89,12 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer
private void updateDevicePreferenceSummary(){
// update bluetooth device summary
- String deviceName = "";
- ListPreference prefDevices = (ListPreference)findPreference(BluetoothGpsProviderService.PREF_BLUETOOTH_DEVICE);
- String deviceAddress = sharedPref.getString(BluetoothGpsProviderService.PREF_BLUETOOTH_DEVICE, null);
- if (BluetoothAdapter.checkBluetoothAddress(deviceAddress)){
- deviceName = bluetoothAdapter.getRemoteDevice(deviceAddress).getName();
- }
+// String deviceName = "";
+ EditTextPreference prefDevices = (EditTextPreference)findPreference(BluetoothGpsProviderService.PREF_BLUETOOTH_DEVICE);
+ String deviceName = sharedPref.getString(BluetoothGpsProviderService.PREF_BLUETOOTH_DEVICE, getString(R.string.defaultGpsDevice));
+// if (BluetoothAdapter.checkBluetoothAddress(deviceAddress)){
+// deviceName = bluetoothAdapter.getRemoteDevice(deviceAddress).getName();
+// }
prefDevices.setSummary(getString(R.string.pref_bluetooth_device_summary, deviceName));
}
@@ -99,24 +102,24 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer
// update bluetooth device summary
updateDevicePreferenceSummary();
// update bluetooth device list
- ListPreference prefDevices = (ListPreference)findPreference(BluetoothGpsProviderService.PREF_BLUETOOTH_DEVICE);
- Set<BluetoothDevice> pairedDevices = new HashSet<BluetoothDevice>();
- if (bluetoothAdapter != null){
- pairedDevices = bluetoothAdapter.getBondedDevices();
- }
- String[] entryValues = new String[pairedDevices.size()];
- String[] entries = new String[pairedDevices.size()];
- int i = 0;
- // Loop through paired devices
- for (BluetoothDevice device : pairedDevices) {
- // Add the name and address to the ListPreference enties and entyValues
- Log.v(LOG_TAG, "device: "+device.getName() + " -- " + device.getAddress());
- entryValues[i] = device.getAddress();
- entries[i] = device.getName();
- i++;
- }
- prefDevices.setEntryValues(entryValues);
- prefDevices.setEntries(entries);
+// ListPreference prefDevices = (ListPreference)findPreference(BluetoothGpsProviderService.PREF_BLUETOOTH_DEVICE);
+// Set<BluetoothDevice> pairedDevices = new HashSet<BluetoothDevice>();
+// if (bluetoothAdapter != null){
+// pairedDevices = bluetoothAdapter.getBondedDevices();
+// }
+// String[] entryValues = new String[pairedDevices.size()];
+// String[] entries = new String[pairedDevices.size()];
+// int i = 0;
+// // Loop through paired devices
+// for (BluetoothDevice device : pairedDevices) {
+// // Add the name and address to the ListPreference enties and entyValues
+// Log.v(LOG_TAG, "device: "+device.getName() + " -- " + device.getAddress());
+// entryValues[i] = device.getAddress();
+// entries[i] = device.getName();
+// i++;
+// }
+// prefDevices.setEntryValues(entryValues);
+// prefDevices.setEntries(entries);
Preference pref = (Preference)findPreference(BluetoothGpsProviderService.PREF_TRACK_RECORDING);
pref.setEnabled(sharedPref.getBoolean(BluetoothGpsProviderService.PREF_START_GPS_PROVIDER, false));
pref = (Preference)findPreference(BluetoothGpsProviderService.PREF_MOCK_GPS_NAME);
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
index 1290344..2b0ed3b 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
@@ -31,10 +31,12 @@ import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
+import org.broeuschmeul.android.gps.internal.provider.R;
+
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
-import android.bluetooth.BluetoothAdapter;
+//import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
@@ -56,11 +58,11 @@ import android.widget.Toast;
*/
public class BluetoothGpsProviderService extends Service implements NmeaListener, LocationListener {
- public static final String ACTION_START_TRACK_RECORDING = "org.broeuschmeul.android.gps.bluetooth.tracker.nmea.intent.action.START_TRACK_RECORDING";
- public static final String ACTION_STOP_TRACK_RECORDING = "org.broeuschmeul.android.gps.bluetooth.tracker.nmea.intent.action.STOP_TRACK_RECORDING";
- public static final String ACTION_START_GPS_PROVIDER = "org.broeuschmeul.android.gps.bluetooth.provider.nmea.intent.action.START_GPS_PROVIDER";
- public static final String ACTION_STOP_GPS_PROVIDER = "org.broeuschmeul.android.gps.bluetooth.provider.nmea.intent.action.STOP_GPS_PROVIDER";
- public static final String ACTION_CONFIGURE_SIRF_GPS = "org.broeuschmeul.android.gps.bluetooth.provider.nmea.intent.action.CONFIGURE_SIRF_GPS";
+ public static final String ACTION_START_TRACK_RECORDING = "org.broeuschmeul.android.gps.internal.tracker.nmea.intent.action.START_TRACK_RECORDING";
+ public static final String ACTION_STOP_TRACK_RECORDING = "org.broeuschmeul.android.gps.internal.tracker.nmea.intent.action.STOP_TRACK_RECORDING";
+ public static final String ACTION_START_GPS_PROVIDER = "org.broeuschmeul.android.gps.internal.provider.nmea.intent.action.START_GPS_PROVIDER";
+ public static final String ACTION_STOP_GPS_PROVIDER = "org.broeuschmeul.android.gps.internal.provider.nmea.intent.action.STOP_GPS_PROVIDER";
+ public static final String ACTION_CONFIGURE_SIRF_GPS = "org.broeuschmeul.android.gps.internal.provider.nmea.intent.action.CONFIGURE_SIRF_GPS";
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";
@@ -107,14 +109,14 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
// super.onStart(intent, startId);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor edit = sharedPreferences.edit();
- String deviceAddress = sharedPreferences.getString(PREF_BLUETOOTH_DEVICE, null);
+ String deviceAddress = sharedPreferences.getString(PREF_BLUETOOTH_DEVICE, getString(R.string.defaultGpsDevice));
int maxConRetries = Integer.parseInt(sharedPreferences.getString(PREF_CONNECTION_RETRIES, this.getString(R.string.defaultConnectionRetries)));
if (Config.LOGD){
Log.d(LOG_TAG, "prefs device addr: "+deviceAddress);
}
if (ACTION_START_GPS_PROVIDER.equals(intent.getAction())){
if (gpsManager == null){
- if (BluetoothAdapter.checkBluetoothAddress(deviceAddress)){
+ if (true /*|| BluetoothAdapter.checkBluetoothAddress(deviceAddress)*/){
String mockProvider = LocationManager.GPS_PROVIDER;
if (! sharedPreferences.getBoolean(PREF_REPLACE_STD_GPS, true)){
mockProvider = sharedPreferences.getString(PREF_MOCK_GPS_NAME, getString(R.string.defaultMockGpsName));