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

Commit a495ba26 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Add support for GPS privacy lock. DO NOT MERGE



Change-Id: I370f6fe9995236d31c119a563847dbbd31457e3d
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 7d39f981
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -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;

// data written to by GPS callbacks
@@ -226,11 +227,23 @@ static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject o
    if (sGpsNiInterface)
        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);

    return true;
}

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);
@@ -474,10 +487,9 @@ static void android_location_GpsLocationProvider_send_ni_response(JNIEnv* env, j
{
    if (!sGpsNiInterface)
        sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE);
   if (sGpsNiInterface) {
    if (sGpsNiInterface)
        sGpsNiInterface->respond(notifId, response);
}
}

static JNINativeMethod sMethods[] = {
     /* name, signature, funcPtr */