From a3ba63dc8ae1691211f1d6a029751a2086aa3fc6 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Fri, 26 Mar 2010 15:10:29 -0400 Subject: [PATCH] Add support for GPS privacy lock. DO NOT MERGE Change-Id: Ieb55794453f86fb7100c9010a0729839990eb9f7 Signed-off-by: Mike Lockwood --- .../android_location_GpsLocationProvider.cpp | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/core/jni/android_location_GpsLocationProvider.cpp b/core/jni/android_location_GpsLocationProvider.cpp index a3be309a504f6..f60fe6da070a3 100755 --- a/core/jni/android_location_GpsLocationProvider.cpp +++ b/core/jni/android_location_GpsLocationProvider.cpp @@ -41,6 +41,7 @@ static jmethodID method_reportNiNotification; static const GpsInterface* sGpsInterface = NULL; static const GpsXtraInterface* sGpsXtraInterface = NULL; static const AGpsInterface* sAGpsInterface = NULL; +static const GpsPrivacyInterface* sGpsPrivacyInterface = NULL; static const GpsNiInterface* sGpsNiInterface = NULL; static const GpsDebugInterface* sGpsDebugInterface = NULL; @@ -223,9 +224,15 @@ static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject o sAGpsInterface->init(&sAGpsCallbacks); if (!sGpsNiInterface) - sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE); + sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE); if (sGpsNiInterface) - sGpsNiInterface->init(&sGpsNiCallbacks); + sGpsNiInterface->init(&sGpsNiCallbacks); + + // Clear privacy lock while enabled + if (!sGpsPrivacyInterface) + sGpsPrivacyInterface = (const GpsPrivacyInterface*)sGpsInterface->get_extension(GPS_PRIVACY_INTERFACE); + if (sGpsPrivacyInterface) + sGpsPrivacyInterface->set_privacy_lock(0); if (!sGpsDebugInterface) sGpsDebugInterface = (const GpsDebugInterface*)sGpsInterface->get_extension(GPS_DEBUG_INTERFACE); @@ -235,6 +242,12 @@ static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject o static void android_location_GpsLocationProvider_disable(JNIEnv* env, jobject obj) { + // Enable privacy lock while disabled + if (!sGpsPrivacyInterface) + sGpsPrivacyInterface = (const GpsPrivacyInterface*)sGpsInterface->get_extension(GPS_PRIVACY_INTERFACE); + if (sGpsPrivacyInterface) + sGpsPrivacyInterface->set_privacy_lock(1); + pthread_mutex_lock(&sEventMutex); sPendingCallbacks |= kDisableRequest; pthread_cond_signal(&sEventCond); @@ -476,12 +489,10 @@ static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jo static void android_location_GpsLocationProvider_send_ni_response(JNIEnv* env, jobject obj, jint notifId, jint response) { - if (!sGpsNiInterface) { + if (!sGpsNiInterface) sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE); - } - if (sGpsNiInterface) { + if (sGpsNiInterface) sGpsNiInterface->respond(notifId, response); - } } static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* env, jobject obj)