aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2011-05-14 14:56:58 +0200
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2011-05-14 15:11:45 +0200
commit32b8a3337978a59b1a4cbc1f70cc294e96dcbe58 (patch)
treeef530d785e5570dee35c255a837121a9f9064d39
parent607f9abfb96d7d421caf91c665cf801849b20bd6 (diff)
downloadBlueGPS-32b8a3337978a59b1a4cbc1f70cc294e96dcbe58.zip
BlueGPS-32b8a3337978a59b1a4cbc1f70cc294e96dcbe58.tar.gz
BlueGPS-32b8a3337978a59b1a4cbc1f70cc294e96dcbe58.tar.bz2
First rebuild for cupcake using backport-android-bluetooth.
Use backport-android-bluetooth (http://code.google.com/p/backport-android-bluetooth/) in order use bluetooth API introduced with Eclair.
-rw-r--r--.classpath1
-rw-r--r--.project2
-rw-r--r--AndroidManifest.xml65
-rw-r--r--default.properties2
-rw-r--r--lib/backport-android-bluetooth2.jarbin0 -> 87513 bytes
-rw-r--r--src/backport_android_bluetooth.properties8
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java8
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java4
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java79
-rw-r--r--src/org/broeuschmeul/android/gps/nmea/util/NmeaListener.java12
10 files changed, 161 insertions, 20 deletions
diff --git a/.classpath b/.classpath
index 6e9239f..8c3593d 100644
--- a/.classpath
+++ b/.classpath
@@ -3,5 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="lib" path="lib/backport-android-bluetooth2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/.project b/.project
index 3b27c42..5b798e0 100644
--- a/.project
+++ b/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>AndroidBluetoothGpsProvider</name>
+ <name>AndroidBlueGps4Cupcake</name>
<comment></comment>
<projects>
</projects>
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d306f52..81400f3 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -55,7 +55,69 @@
</intent-filter>
</service>
- </application>
+ <!-- begin backport.android.bluetooth -->
+
+ <activity android:name="backport.android.bluetooth.RequestEnableActivity"
+ android:label="Bluetooth Permission Request" android:noHistory="true"
+ android:theme="@android:style/Theme.Translucent.NoTitleBar"
+ android:configChanges="orientation|keyboardHidden">
+ <intent-filter>
+
+ <!-- ${your package name}.action.REQUEST_ENABLE -->
+ <action android:name="org.broeuschmeul.android.gps.bluetooth.provider.action.REQUEST_ENABLE" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
+
+ <activity android:name="backport.android.bluetooth.RequestDiscoverableActivity"
+ android:label="Bluetooth Permission Request" android:noHistory="true"
+ android:theme="@android:style/Theme.Translucent.NoTitleBar"
+ android:configChanges="orientation|keyboardHidden">
+ <intent-filter>
+
+ <!-- ${your package name}.action.REQUEST_DISCOVERABLE -->
+ <action android:name="org.broeuschmeul.android.gps.bluetooth.provider.action.REQUEST_DISCOVERABLE" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
+
+ <receiver android:name="backport.android.bluetooth.BluetoothIntentRedirector">
+ <intent-filter>
+ <action android:name="android.bluetooth.intent.action.DISCOVERY_COMPLETED" />
+ <action android:name="android.bluetooth.intent.action.DISCOVERY_STARTED" />
+ <action android:name="android.bluetooth.intent.action.NAME_CHANGED" />
+ <action android:name="android.bluetooth.intent.action.SCAN_MODE_CHANGED" />
+ <action android:name="android.bluetooth.intent.action.BLUETOOTH_STATE_CHANGED" />
+ <action android:name="android.bluetooth.intent.action.REMOTE_DEVICE_CONNECTED" />
+ <action android:name="android.bluetooth.intent.action.REMOTE_DEVICE_DISCONNECTED" />
+ <action android:name="android.bluetooth.intent.action.REMOTE_DEVICE_DISCONNECT_REQUESTED" />
+ <action android:name="android.bluetooth.intent.action.BOND_STATE_CHANGED" />
+ <action android:name="android.bluetooth.intent.action.PAIRING_REQUEST" />
+ <action android:name="android.bluetooth.intent.action.PAIRING_CANCEL" />
+ <action android:name="android.bluetooth.intent.action.REMOTE_DEVICE_CLASS_UPDATED" />
+ <action android:name="android.bluetooth.intent.action.REMOTE_DEVICE_FOUND" />
+ <action android:name="android.bluetooth.intent.action.REMOTE_NAME_UPDATED" />
+ </intent-filter>
+ </receiver>
+
+ <!-- end backport.android.bluetooth -->
+
+ </application>
+
+ <!-- begin backport.android.bluetooth -->
+
+ <uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
+ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission>
+
+ <!-- ${your package name}.PERMISSION -->
+ <uses-permission android:name="org.broeuschmeul.android.gps.bluetooth.provider.PERMISSION"></uses-permission>
+
+ <!-- begin backport.android.bluetooth -->
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@@ -63,5 +125,4 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
- <uses-sdk android:targetSdkVersion="5" android:minSdkVersion="5" />
</manifest>
diff --git a/default.properties b/default.properties
index dbf05f2..4513a1e 100644
--- a/default.properties
+++ b/default.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-5
+target=android-3
diff --git a/lib/backport-android-bluetooth2.jar b/lib/backport-android-bluetooth2.jar
new file mode 100644
index 0000000..367dca1
--- /dev/null
+++ b/lib/backport-android-bluetooth2.jar
Binary files differ
diff --git a/src/backport_android_bluetooth.properties b/src/backport_android_bluetooth.properties
new file mode 100644
index 0000000..72845a9
--- /dev/null
+++ b/src/backport_android_bluetooth.properties
@@ -0,0 +1,8 @@
+#permission_name = ${your package name).PERMISSION_BLUETOOTH
+permission_name = org.broeuschmeul.android.gps.bluetooth.provider.PERMISSION_BLUETOOTH
+
+#request_enable = ${your package name}.action.REQUEST_ENABLE
+request_enable = org.broeuschmeul.android.gps.bluetooth.provider.action.REQUEST_ENABLE
+
+#request_discoverable = ${your package name}.action.REQUEST_DISCOVERABLE
+request_discoverable = org.broeuschmeul.android.gps.bluetooth.provider.action.REQUEST_DISCOVERABLE \ No newline at end of file
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
index 4deba63..d8cf9a0 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
@@ -36,6 +36,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import org.broeuschmeul.android.gps.nmea.util.NmeaListener;
import org.broeuschmeul.android.gps.nmea.util.NmeaParser;
import org.broeuschmeul.android.gps.sirf.util.SirfUtils;
@@ -43,14 +44,13 @@ 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 backport.android.bluetooth.BluetoothAdapter;
+import backport.android.bluetooth.BluetoothDevice;
+import backport.android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.content.SharedPreferences;
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;
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
index 885148c..1112ceb 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
@@ -24,8 +24,8 @@ import java.util.HashSet;
import java.util.Set;
import android.app.AlertDialog;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
+import backport.android.bluetooth.BluetoothAdapter;
+import backport.android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
index 1290344..3570053 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
@@ -31,16 +31,19 @@ import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
+import org.broeuschmeul.android.gps.nmea.util.NmeaListener;
+
import android.app.Notification;
+import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
-import android.bluetooth.BluetoothAdapter;
+import backport.android.bluetooth.BluetoothAdapter;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
-import android.location.GpsStatus.NmeaListener;
import android.os.Bundle;
import android.os.IBinder;
import android.preference.PreferenceManager;
@@ -90,6 +93,7 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
public static final String PREF_SIRF_ENABLE_NMEA = "enableNMEA";
public static final String PREF_SIRF_ENABLE_STATIC_NAVIGATION = "enableStaticNavigation";
+ private NotificationManager notificationManager = null;
private BlueetoothGpsManager gpsManager = null;
private PrintWriter writer;
private File trackFile;
@@ -99,6 +103,7 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
@Override
public void onCreate() {
super.onCreate();
+ NotificationManager notificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
toast = Toast.makeText(getApplicationContext(), "NMEA track recording... on", Toast.LENGTH_SHORT);
}
@@ -195,6 +200,58 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
}
}
+ /**
+ * The notification id used to signal that this service runs in the foreground.
+ *
+ * @see #startForeground(int, Notification)
+ * @see #stopForeground(boolean)
+ */
+ private int notificationId = R.string.foreground_gps_provider_started_notification;
+
+
+ private NotificationManager getNotificationManager(){
+ if (notificationManager == null){
+ notificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
+ }
+ return notificationManager;
+ }
+
+ /**
+ * Compatibility (see API 5) method used to run this service in the foreground,
+ * supplying the ongoing notification to be shown to the user while in this state.
+ *
+ * @param id The identifier for this notification as per NotificationManager.notify(int, Notification)
+ * @param notification The Notification to be displayed.
+ *
+ * @see #stopForeground(boolean)
+ */
+ private final void startForeground (int id, Notification notification){
+ NotificationManager notificationManager = this.getNotificationManager();
+ setForeground(true);
+ if (notificationManager != null){
+ notificationManager.notify(notificationId = id, notification);
+ }
+ }
+
+ /**
+ * Compatibility (see API 5) method used to remove this service from foreground state,
+ * allowing it to be killed if more memory is needed.
+ * This method should be called with value false, when the service is destroyed.
+ *
+ * @param removeNotification If true, the notification previously provided
+ * to startForeground(int, Notification) will be removed.
+ * Otherwise it will remain until a later call removes it (or the service is destroyed).
+ *
+ * @see #startForeground(int, Notification)
+ */
+ private final void stopForeground (boolean removeNotification){
+ NotificationManager notificationManager = this.getNotificationManager();
+ if (removeNotification && (notificationManager != null)){
+ notificationManager.cancel(notificationId);
+ }
+ setForeground(false);
+ }
+
private void enableSirfConfig(Bundle extras){
if (extras.containsKey(PREF_SIRF_ENABLE_GGA)){
enableNmeaGGA(extras.getBoolean(PREF_SIRF_ENABLE_GGA, true));
@@ -380,14 +437,15 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
}
}
- /* (non-Javadoc)
- * @see android.app.Service#onStartCommand(android.content.Intent, int, int)
- */
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- onStart(intent, startId);
- return Service.START_NOT_STICKY;
- }
+// This method has been introduced in Eclair
+// /* (non-Javadoc)
+// * @see android.app.Service#onStartCommand(android.content.Intent, int, int)
+// */
+// @Override
+// public int onStartCommand(Intent intent, int flags, int startId) {
+// onStart(intent, startId);
+// return Service.START_NOT_STICKY;
+// }
@Override
public void onDestroy() {
@@ -416,6 +474,7 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener
edit.putBoolean(PREF_START_GPS_PROVIDER,false);
edit.commit();
}
+ stopForeground(true);
super.onDestroy();
}
diff --git a/src/org/broeuschmeul/android/gps/nmea/util/NmeaListener.java b/src/org/broeuschmeul/android/gps/nmea/util/NmeaListener.java
new file mode 100644
index 0000000..f36a312
--- /dev/null
+++ b/src/org/broeuschmeul/android/gps/nmea/util/NmeaListener.java
@@ -0,0 +1,12 @@
+/**
+ *
+ */
+package org.broeuschmeul.android.gps.nmea.util;
+
+/**
+ * @author Herbert von Broeuschmeul
+ *
+ */
+public interface NmeaListener {
+ abstract void onNmeaReceived(long timestamp, String nmea);
+}