Add wake lock utility functions for the GPS HAL.
Change-Id: I9071f31badee9628126c91cd4ce55acf41ee186f
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/services/jni/com_android_server_location_GpsLocationProvider.cpp b/services/jni/com_android_server_location_GpsLocationProvider.cpp
index 7a74fd4..20c8924 100755
--- a/services/jni/com_android_server_location_GpsLocationProvider.cpp
+++ b/services/jni/com_android_server_location_GpsLocationProvider.cpp
@@ -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 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 @@
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 @@
}
GpsCallbacks sGpsCallbacks = {
+ sizeof(GpsCallbacks),
location_callback,
status_callback,
sv_status_callback,
- nmea_callback
+ nmea_callback,
+ acquire_wakelock_callback,
+ release_wakelock_callback,
};
static void