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

Commit 8f5a8001 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Add wake lock utility functions for the GPS HAL.



Change-Id: I9071f31badee9628126c91cd4ce55acf41ee186f
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 5c14f2d0
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "jni.h"
#include "hardware/hardware.h"
#include "hardware/gps.h"
#include "hardware_legacy/power.h"
#include "utils/Log.h"
#include "utils/misc.h"

@@ -51,6 +52,8 @@ static GpsSvStatus sGpsSvStatus;
static AGpsStatus   sAGpsStatus;
static GpsNiNotification  sGpsNiNotification;

#define WAKE_LOCK_NAME  "GPS"

// buffer for NMEA data
#define NMEA_SENTENCE_LENGTH    100
#define NMEA_SENTENCE_COUNT     40
@@ -141,6 +144,16 @@ static void nmea_callback(GpsUtcTime timestamp, const char* nmea, int length)
    pthread_mutex_unlock(&sEventMutex);
}

static void acquire_wakelock_callback()
{
    acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME);
}

static void release_wakelock_callback()
{
    release_wake_lock(WAKE_LOCK_NAME);
}

static void agps_status_callback(AGpsStatus* agps_status)
{
    pthread_mutex_lock(&sEventMutex);
@@ -153,10 +166,13 @@ static void agps_status_callback(AGpsStatus* agps_status)
}

GpsCallbacks sGpsCallbacks = {
    sizeof(GpsCallbacks),
    location_callback,
    status_callback,
    sv_status_callback,
    nmea_callback
    nmea_callback,
    acquire_wakelock_callback,
    release_wakelock_callback,
};

static void