summaryrefslogtreecommitdiffstats
path: root/location/java/com
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2009-08-06 09:26:02 -0400
committerMike Lockwood <lockwood@android.com>2009-08-06 15:05:07 -0400
commitb16e7800be4f879135f239f1f8f586f3712df01e (patch)
treed3c41d32ac4341d66d9e042612237c13ab49e879 /location/java/com
parentd4f09592f721e6358fdadbdf363f034f842f860d (diff)
downloadframeworks_base-b16e7800be4f879135f239f1f8f586f3712df01e.zip
frameworks_base-b16e7800be4f879135f239f1f8f586f3712df01e.tar.gz
frameworks_base-b16e7800be4f879135f239f1f8f586f3712df01e.tar.bz2
gps: Add GpsStatus.NmeaListener interface for receiving NMEA sentences.
NMEA sentences are passed from the GPS engine to the GpsLocationProvider. They are then sent via the IGpsStatusListener binder interface to clients using the same path as the other GPS status information. Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'location/java/com')
-rwxr-xr-xlocation/java/com/android/internal/location/GpsLocationProvider.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java
index aaac192..bdef01f 100755
--- a/location/java/com/android/internal/location/GpsLocationProvider.java
+++ b/location/java/com/android/internal/location/GpsLocationProvider.java
@@ -1014,6 +1014,32 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
}
+ /**
+ * called from native code to report NMEA data received
+ */
+ private void reportNmea(int index, long timestamp) {
+ synchronized(mListeners) {
+ int size = mListeners.size();
+ if (size > 0) {
+ // don't bother creating the String if we have no listeners
+ int length = native_read_nmea(index, mNmeaBuffer, mNmeaBuffer.length);
+ String nmea = new String(mNmeaBuffer, 0, length);
+
+ for (int i = 0; i < size; i++) {
+ Listener listener = mListeners.get(i);
+ try {
+ listener.mListener.onNmeaReceived(timestamp, nmea);
+ } catch (RemoteException e) {
+ Log.w(TAG, "RemoteException in reportNmea");
+ mListeners.remove(listener);
+ // adjust for size of list changing
+ size--;
+ }
+ }
+ }
+ }
+ }
+
private void xtraDownloadRequest() {
if (Config.LOGD) Log.d(TAG, "xtraDownloadRequest");
if (mNetworkThread != null) {
@@ -1194,6 +1220,8 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
private float mSvAzimuths[] = new float[MAX_SVS];
private int mSvMasks[] = new int[3];
private int mSvCount;
+ // preallocated to avoid memory allocation in reportNmea()
+ private byte[] mNmeaBuffer = new byte[120];
static { class_init_native(); }
private static native void class_init_native();
@@ -1211,6 +1239,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
// mask[0] is ephemeris mask and mask[1] is almanac mask
private native int native_read_sv_status(int[] svs, float[] snrs,
float[] elevations, float[] azimuths, int[] masks);
+ private native int native_read_nmea(int index, byte[] buffer, int bufferSize);
private native void native_inject_location(double latitude, double longitude, float accuracy);
// XTRA Support