Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb40aae2 authored by Eddie Ho's avatar Eddie Ho Committed by Mike Lockwood
Browse files

GPS: Fix race condition reporting NMEA data.



Change-Id: I80997e2686d9c08d7d2def094f9922e83cf41013
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent f163f7f0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -370,14 +370,14 @@ static jint android_location_GpsLocationProvider_read_sv_status(JNIEnv* env, job

static jint android_location_GpsLocationProvider_read_nmea(JNIEnv* env, jobject obj, jint index, jbyteArray nmeaArray, jint buffer_size)
{
    // this should only be called from within a call to reportStatus, so we don't need to lock here
    // this should only be called from within a call to reportNmea, so we don't need to lock here

    jbyte* nmea = env->GetByteArrayElements(nmeaArray, 0);

    int length = strlen(sNmeaBuffer[index].nmea);
    int length = strlen(sNmeaBufferCopy[index].nmea);
    if (length > buffer_size)
        length = buffer_size;
    memcpy(nmea, sNmeaBuffer[index].nmea, length);
    memcpy(nmea, sNmeaBufferCopy[index].nmea, length);

    env->ReleaseByteArrayElements(nmeaArray, nmea, 0);
    return length;