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

Commit b8c235e0 authored by Anil Admal's avatar Anil Admal
Browse files

Revert "Revert "Update GNSS Batching to use new GnssLocation with elapsed realtime (framework)""

This reverts commit 2f13c07c.

Reason for revert: It appears that the build includes ag/6721678 but not ag/6762021 even though they both were submitted together. Hence the build errors.

Change-Id: I5342f358ca2fb7a92591608d45920f515db2e20d
parent 2f13c07c
Loading
Loading
Loading
Loading
+60 −28
Original line number Original line Diff line number Diff line
@@ -117,8 +117,6 @@ using android::hardware::hidl_death_recipient;
using android::hardware::gnss::V1_0::GnssConstellationType;
using android::hardware::gnss::V1_0::GnssConstellationType;
using android::hardware::gnss::V1_0::GnssLocationFlags;
using android::hardware::gnss::V1_0::GnssLocationFlags;
using android::hardware::gnss::V1_0::IAGnssRilCallback;
using android::hardware::gnss::V1_0::IAGnssRilCallback;
using android::hardware::gnss::V1_0::IGnssBatching;
using android::hardware::gnss::V1_0::IGnssBatchingCallback;
using android::hardware::gnss::V1_0::IGnssGeofenceCallback;
using android::hardware::gnss::V1_0::IGnssGeofenceCallback;
using android::hardware::gnss::V1_0::IGnssGeofencing;
using android::hardware::gnss::V1_0::IGnssGeofencing;
using android::hardware::gnss::V1_0::IGnssNavigationMessage;
using android::hardware::gnss::V1_0::IGnssNavigationMessage;
@@ -160,6 +158,10 @@ using IAGnss_V1_0 = android::hardware::gnss::V1_0::IAGnss;
using IAGnss_V2_0 = android::hardware::gnss::V2_0::IAGnss;
using IAGnss_V2_0 = android::hardware::gnss::V2_0::IAGnss;
using IAGnssCallback_V1_0 = android::hardware::gnss::V1_0::IAGnssCallback;
using IAGnssCallback_V1_0 = android::hardware::gnss::V1_0::IAGnssCallback;
using IAGnssCallback_V2_0 = android::hardware::gnss::V2_0::IAGnssCallback;
using IAGnssCallback_V2_0 = android::hardware::gnss::V2_0::IAGnssCallback;
using IGnssBatching_V1_0 = android::hardware::gnss::V1_0::IGnssBatching;
using IGnssBatching_V2_0 = android::hardware::gnss::V2_0::IGnssBatching;
using IGnssBatchingCallback_V1_0 = android::hardware::gnss::V1_0::IGnssBatchingCallback;
using IGnssBatchingCallback_V2_0 = android::hardware::gnss::V2_0::IGnssBatchingCallback;


using android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections;
using android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections;
using android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
using android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
@@ -192,7 +194,8 @@ sp<IAGnssRil_V2_0> agnssRilIface_V2_0 = nullptr;
sp<IGnssGeofencing> gnssGeofencingIface = nullptr;
sp<IGnssGeofencing> gnssGeofencingIface = nullptr;
sp<IAGnss_V1_0> agnssIface = nullptr;
sp<IAGnss_V1_0> agnssIface = nullptr;
sp<IAGnss_V2_0> agnssIface_V2_0 = nullptr;
sp<IAGnss_V2_0> agnssIface_V2_0 = nullptr;
sp<IGnssBatching> gnssBatchingIface = nullptr;
sp<IGnssBatching_V1_0> gnssBatchingIface = nullptr;
sp<IGnssBatching_V2_0> gnssBatchingIface_V2_0 = nullptr;
sp<IGnssDebug_V1_0> gnssDebugIface = nullptr;
sp<IGnssDebug_V1_0> gnssDebugIface = nullptr;
sp<IGnssDebug_V2_0> gnssDebugIface_V2_0 = nullptr;
sp<IGnssDebug_V2_0> gnssDebugIface_V2_0 = nullptr;
sp<IGnssConfiguration_V1_0> gnssConfigurationIface = nullptr;
sp<IGnssConfiguration_V1_0> gnssConfigurationIface = nullptr;
@@ -1445,20 +1448,15 @@ Return<void> AGnssRilCallback::requestRefLocCb() {
    return Void();
    return Void();
}
}


/*
struct GnssBatchingCallbackUtil {
 * GnssBatchingCallback interface implements the callback methods
    template<class T>
 * required by the IGnssBatching interface.
    static Return<void> gnssLocationBatchCbImpl(const hidl_vec<T>& locations);
 */
private:
struct GnssBatchingCallback : public IGnssBatchingCallback {
    GnssBatchingCallbackUtil() = delete;
    /*
    * Methods from ::android::hardware::gps::V1_0::IGnssBatchingCallback
    * follow.
    */
    Return<void> gnssLocationBatchCb(const hidl_vec<GnssLocation_V1_0>& locations) override;
};
};


Return<void> GnssBatchingCallback::gnssLocationBatchCb(
template<class T>
    const hidl_vec<GnssLocation_V1_0>& locations) {
Return<void> GnssBatchingCallbackUtil::gnssLocationBatchCbImpl(const hidl_vec<T>& locations) {
    JNIEnv* env = getJniEnv();
    JNIEnv* env = getJniEnv();


    jobjectArray jLocations = env->NewObjectArray(locations.size(),
    jobjectArray jLocations = env->NewObjectArray(locations.size(),
@@ -1478,6 +1476,28 @@ Return<void> GnssBatchingCallback::gnssLocationBatchCb(
    return Void();
    return Void();
}
}


/*
 * GnssBatchingCallback_V1_0 class implements the callback methods required by the
 * IGnssBatching 1.0 interface.
 */
struct GnssBatchingCallback_V1_0 : public IGnssBatchingCallback_V1_0 {
    /** Methods from ::android::hardware::gps::V1_0::IGnssBatchingCallback follow. */
    Return<void> gnssLocationBatchCb(const hidl_vec<GnssLocation_V1_0>& locations) override {
        return GnssBatchingCallbackUtil::gnssLocationBatchCbImpl(locations);
    }
};

/*
 * GnssBatchingCallback_V2_0 class implements the callback methods required by the
 * IGnssBatching 2.0 interface.
 */
struct GnssBatchingCallback_V2_0 : public IGnssBatchingCallback_V2_0 {
    /** Methods from ::android::hardware::gps::V2_0::IGnssBatchingCallback follow. */
    Return<void> gnssLocationBatchCb(const hidl_vec<GnssLocation_V2_0>& locations) override {
        return GnssBatchingCallbackUtil::gnssLocationBatchCbImpl(locations);
    }
};

static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env, jclass clazz) {
static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env, jclass clazz) {
    gnssHal_V2_0 = IGnss_V2_0::getService();
    gnssHal_V2_0 = IGnss_V2_0::getService();
    if (gnssHal_V2_0 != nullptr) {
    if (gnssHal_V2_0 != nullptr) {
@@ -1753,11 +1773,22 @@ static void android_location_GnssLocationProvider_init_once(JNIEnv* env, jclass
        gnssGeofencingIface = gnssGeofencing;
        gnssGeofencingIface = gnssGeofencing;
    }
    }


    auto gnssBatching = gnssHal->getExtensionGnssBatching();
    // If IGnssBatching.hal@2.0 is not supported, use IGnssBatching.hal@1.0
    if (!gnssBatching.isOk()) {
    if (gnssHal_V2_0 != nullptr) {
        ALOGD("Unable to get a handle to gnssBatching");
        auto gnssBatching_V2_0 = gnssHal_V2_0->getExtensionGnssBatching_2_0();
        if (!gnssBatching_V2_0.isOk()) {
            ALOGD("Unable to get a handle to GnssBatching_V2_0");
        } else {
        } else {
        gnssBatchingIface = gnssBatching;
            gnssBatchingIface_V2_0 = gnssBatching_V2_0;
        }
    }
    if (gnssBatchingIface_V2_0 == nullptr ) {
        auto gnssBatching_V1_0 = gnssHal->getExtensionGnssBatching();
        if (!gnssBatching_V1_0.isOk()) {
            ALOGD("Unable to get a handle to GnssBatching");
        } else {
            gnssBatchingIface = gnssBatching_V1_0;
        }
    }
    }


    if (gnssHal_V2_0 != nullptr) {
    if (gnssHal_V2_0 != nullptr) {
@@ -2123,8 +2154,6 @@ struct AGnssDispatcher {


private:
private:
    AGnssDispatcher() = delete;
    AGnssDispatcher() = delete;
    AGnssDispatcher(const AGnssDispatcher&) = delete;
    AGnssDispatcher& operator=(const AGnssDispatcher&) = delete;
};
};


void AGnssDispatcher::dataConnOpen(sp<IAGnss_V1_0> agnssIface, JNIEnv* env, jstring apn,
void AGnssDispatcher::dataConnOpen(sp<IAGnss_V1_0> agnssIface, JNIEnv* env, jstring apn,
@@ -2848,12 +2877,15 @@ static jint android_location_GnssBatchingProvider_get_batch_size(JNIEnv*, jclass
}
}


static jboolean android_location_GnssBatchingProvider_init_batching(JNIEnv*, jclass) {
static jboolean android_location_GnssBatchingProvider_init_batching(JNIEnv*, jclass) {
    if (gnssBatchingIface == nullptr) {
    if (gnssBatchingIface_V2_0 != nullptr) {
        sp<IGnssBatchingCallback_V2_0> gnssBatchingCbIface_V2_0 = new GnssBatchingCallback_V2_0();
        return static_cast<jboolean>(gnssBatchingIface_V2_0->init_2_0(gnssBatchingCbIface_V2_0));
    } else if (gnssBatchingIface != nullptr) {
        sp<IGnssBatchingCallback_V1_0> gnssBatchingCbIface_V1_0 = new GnssBatchingCallback_V1_0();
        return static_cast<jboolean>(gnssBatchingIface->init(gnssBatchingCbIface_V1_0));
    } else {
        return JNI_FALSE; // batching not supported
        return JNI_FALSE; // batching not supported
    }
    }
    sp<IGnssBatchingCallback> gnssBatchingCbIface = new GnssBatchingCallback();

    return static_cast<jboolean>(gnssBatchingIface->init(gnssBatchingCbIface));
}
}


static void android_location_GnssBatchingProvider_cleanup_batching(JNIEnv*, jclass) {
static void android_location_GnssBatchingProvider_cleanup_batching(JNIEnv*, jclass) {
@@ -2869,10 +2901,10 @@ static jboolean android_location_GnssBatchingProvider_start_batch(JNIEnv*, jclas
        return JNI_FALSE; // batching not supported
        return JNI_FALSE; // batching not supported
    }
    }


    IGnssBatching::Options options;
    IGnssBatching_V1_0::Options options;
    options.periodNanos = periodNanos;
    options.periodNanos = periodNanos;
    if (wakeOnFifoFull) {
    if (wakeOnFifoFull) {
        options.flags = static_cast<uint8_t>(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL);
        options.flags = static_cast<uint8_t>(IGnssBatching_V1_0::Flag::WAKEUP_ON_FIFO_FULL);
    } else {
    } else {
        options.flags = 0;
        options.flags = 0;
    }
    }