diff options
Diffstat (limited to 'android/location_api')
-rw-r--r-- | android/location_api/BatchingAPIClient.cpp | 13 | ||||
-rw-r--r-- | android/location_api/BatchingAPIClient.h | 14 | ||||
-rw-r--r-- | android/location_api/GeofenceAPIClient.cpp | 10 | ||||
-rw-r--r-- | android/location_api/GeofenceAPIClient.h | 10 | ||||
-rw-r--r-- | android/location_api/GnssAPIClient.cpp | 25 | ||||
-rw-r--r-- | android/location_api/GnssAPIClient.h | 32 | ||||
-rw-r--r-- | android/location_api/LocationUtil.cpp | 12 | ||||
-rw-r--r-- | android/location_api/LocationUtil.h | 10 | ||||
-rw-r--r-- | android/location_api/MeasurementAPIClient.cpp | 74 | ||||
-rw-r--r-- | android/location_api/MeasurementAPIClient.h | 20 |
10 files changed, 143 insertions, 77 deletions
diff --git a/android/location_api/BatchingAPIClient.cpp b/android/location_api/BatchingAPIClient.cpp index 43fed5c..82a803f 100644 --- a/android/location_api/BatchingAPIClient.cpp +++ b/android/location_api/BatchingAPIClient.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -42,9 +42,13 @@ namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { namespace implementation { +using ::android::hardware::gnss::V1_0::IGnssBatching; +using ::android::hardware::gnss::V1_0::IGnssBatchingCallback; +using ::android::hardware::gnss::V1_0::GnssLocation; + static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out, LocationCapabilitiesMask mask); @@ -153,7 +157,8 @@ void BatchingAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMa mLocationCapabilitiesMask = capabilitiesMask; } -void BatchingAPIClient::onBatchingCb(size_t count, Location* location, BatchingOptions /*batchOptions*/) +void BatchingAPIClient::onBatchingCb(size_t count, Location* location, + BatchingOptions /*batchOptions*/) { LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, count); if (mGnssBatchingCbIface != nullptr && count > 0) { @@ -185,7 +190,7 @@ static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions } } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/android/location_api/BatchingAPIClient.h b/android/location_api/BatchingAPIClient.h index 61e2077..64d47a0 100644 --- a/android/location_api/BatchingAPIClient.h +++ b/android/location_api/BatchingAPIClient.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,17 +39,17 @@ namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { namespace implementation { class BatchingAPIClient : public LocationAPIClientBase { public: - BatchingAPIClient(const sp<IGnssBatchingCallback>& callback); + BatchingAPIClient(const sp<V1_0::IGnssBatchingCallback>& callback); ~BatchingAPIClient(); int getBatchSize(); - int startSession(const IGnssBatching::Options& options); - int updateSessionOptions(const IGnssBatching::Options& options); + int startSession(const V1_0::IGnssBatching::Options& options); + int updateSessionOptions(const V1_0::IGnssBatching::Options& options); int stopSession(); void getBatchedLocation(int last_n_locations); void flushBatchedLocations(); @@ -61,13 +61,13 @@ public: void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final; private: - sp<IGnssBatchingCallback> mGnssBatchingCbIface; + sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface; uint32_t mDefaultId; LocationCapabilitiesMask mLocationCapabilitiesMask; }; } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/android/location_api/GeofenceAPIClient.cpp b/android/location_api/GeofenceAPIClient.cpp index 6167177..93d175e 100644 --- a/android/location_api/GeofenceAPIClient.cpp +++ b/android/location_api/GeofenceAPIClient.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,9 +39,11 @@ namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { namespace implementation { +using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback; +using ::android::hardware::gnss::V1_0::GnssLocation; GeofenceAPIClient::GeofenceAPIClient(const sp<IGnssGeofenceCallback>& callback) : LocationAPIClientBase(), @@ -158,7 +160,7 @@ void GeofenceAPIClient::onGeofenceBreachCb(GeofenceBreachNotification geofenceBr auto r = mGnssGeofencingCbIface->gnssGeofenceTransitionCb( geofenceBreachNotification.ids[i], gnssLocation, transition, - static_cast<GnssUtcTime>(geofenceBreachNotification.timestamp)); + static_cast<V1_0::GnssUtcTime>(geofenceBreachNotification.timestamp)); if (!r.isOk()) { LOC_LOGE("%s] Error from gnssGeofenceTransitionCb description=%s", __func__, r.description().c_str()); @@ -267,7 +269,7 @@ void GeofenceAPIClient::onResumeGeofencesCb(size_t count, LocationError* errors, } } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/android/location_api/GeofenceAPIClient.h b/android/location_api/GeofenceAPIClient.h index f779bcb..c74a59a 100644 --- a/android/location_api/GeofenceAPIClient.h +++ b/android/location_api/GeofenceAPIClient.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -37,7 +37,7 @@ namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { namespace implementation { using ::android::sp; @@ -45,7 +45,7 @@ using ::android::sp; class GeofenceAPIClient : public LocationAPIClientBase { public: - GeofenceAPIClient(const sp<IGnssGeofenceCallback>& callback); + GeofenceAPIClient(const sp<V1_0::IGnssGeofenceCallback>& callback); virtual ~GeofenceAPIClient() = default; void geofenceAdd(uint32_t geofence_id, double latitude, double longitude, @@ -65,11 +65,11 @@ public: void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final; private: - sp<IGnssGeofenceCallback> mGnssGeofencingCbIface; + sp<V1_0::IGnssGeofenceCallback> mGnssGeofencingCbIface; }; } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/android/location_api/GnssAPIClient.cpp b/android/location_api/GnssAPIClient.cpp index fac5d0b..4fcc868 100644 --- a/android/location_api/GnssAPIClient.cpp +++ b/android/location_api/GnssAPIClient.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -40,9 +40,14 @@ namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { namespace implementation { +using ::android::hardware::gnss::V1_0::IGnss; +using ::android::hardware::gnss::V1_0::IGnssCallback; +using ::android::hardware::gnss::V1_0::IGnssNiCallback; +using ::android::hardware::gnss::V1_0::GnssLocation; + static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvStatus& out); GnssAPIClient::GnssAPIClient(const sp<IGnssCallback>& gpsCb, @@ -414,11 +419,7 @@ void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotificatio notificationGnss.notificationIdEncoding = IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2; - auto r = gnssNiCbIface->niNotifyCb(notificationGnss); - if (!r.isOk()) { - LOC_LOGE("%s] Error from niNotifyCb description=%s", - __func__, r.description().c_str()); - } + gnssNiCbIface->niNotifyCb(notificationGnss); } void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification) @@ -449,7 +450,7 @@ void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) android::hardware::hidl_string nmeaString; nmeaString.setToExternal(gnssNmeaNotification.nmea, gnssNmeaNotification.length); auto r = gnssCbIface->gnssNmeaCb( - static_cast<GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString); + static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString); if (!r.isOk()) { LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%zu description=%s", __func__, gnssNmeaNotification.nmea, gnssNmeaNotification.length, r.description().c_str()); @@ -503,10 +504,10 @@ static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvSta { memset(&out, 0, sizeof(IGnssCallback::GnssSvStatus)); out.numSvs = in.count; - if (out.numSvs > static_cast<uint32_t>(GnssMax::SVS_COUNT)) { + if (out.numSvs > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) { LOC_LOGW("%s]: Too many satellites %u. Clamps to %d.", - __FUNCTION__, out.numSvs, GnssMax::SVS_COUNT); - out.numSvs = static_cast<uint32_t>(GnssMax::SVS_COUNT); + __FUNCTION__, out.numSvs, V1_0::GnssMax::SVS_COUNT); + out.numSvs = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT); } for (size_t i = 0; i < out.numSvs; i++) { IGnssCallback::GnssSvInfo& info = out.gnssSvList[i]; @@ -526,7 +527,7 @@ static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvSta } } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/android/location_api/GnssAPIClient.h b/android/location_api/GnssAPIClient.h index b5cffb1..1589f39 100644 --- a/android/location_api/GnssAPIClient.h +++ b/android/location_api/GnssAPIClient.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,16 +30,17 @@ #ifndef GNSS_API_CLINET_H #define GNSS_API_CLINET_H + #include <mutex> -#include <android/hardware/gnss/1.0/IGnss.h> -#include <android/hardware/gnss/1.0/IGnssCallback.h> +#include <android/hardware/gnss/1.1/IGnss.h> +#include <android/hardware/gnss/1.1/IGnssCallback.h> #include <android/hardware/gnss/1.0/IGnssNiCallback.h> #include <LocationAPIClientBase.h> namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { namespace implementation { using ::android::sp; @@ -47,28 +48,28 @@ using ::android::sp; class GnssAPIClient : public LocationAPIClientBase { public: - GnssAPIClient(const sp<IGnssCallback>& gpsCb, - const sp<IGnssNiCallback>& niCb); + GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb, + const sp<V1_0::IGnssNiCallback>& niCb); virtual ~GnssAPIClient(); GnssAPIClient(const GnssAPIClient&) = delete; GnssAPIClient& operator=(const GnssAPIClient&) = delete; // for GpsInterface - void gnssUpdateCallbacks(const sp<IGnssCallback>& gpsCb, - const sp<IGnssNiCallback>& niCb); + void gnssUpdateCallbacks(const sp<V1_0::IGnssCallback>& gpsCb, + const sp<V1_0::IGnssNiCallback>& niCb); bool gnssStart(); bool gnssStop(); - bool gnssSetPositionMode(IGnss::GnssPositionMode mode, - IGnss::GnssPositionRecurrence recurrence, + bool gnssSetPositionMode(V1_0::IGnss::GnssPositionMode mode, + V1_0::IGnss::GnssPositionRecurrence recurrence, uint32_t minIntervalMs, uint32_t preferredAccuracyMeters, uint32_t preferredTimeMs); // for GpsNiInterface - void gnssNiRespond(int32_t notifId, IGnssNiCallback::GnssUserResponseType userResponse); + void gnssNiRespond(int32_t notifId, V1_0::IGnssNiCallback::GnssUserResponseType userResponse); // these apis using LocationAPIControlClient - void gnssDeleteAidingData(IGnss::GnssAidingData aidingDataFlags); + void gnssDeleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags); void gnssEnable(LocationTechnologyType techType); void gnssDisable(); void gnssConfigurationUpdate(const GnssConfig& gnssConfig); @@ -89,17 +90,18 @@ public: void onStopTrackingCb(LocationError error) final; private: - sp<IGnssCallback> mGnssCbIface; - sp<IGnssNiCallback> mGnssNiCbIface; + sp<V1_0::IGnssCallback> mGnssCbIface; + sp<V1_0::IGnssNiCallback> mGnssNiCbIface; std::mutex mMutex; LocationAPIControlClient* mControlClient; LocationCapabilitiesMask mLocationCapabilitiesMask; bool mLocationCapabilitiesCached; + LocationOptions mLocationOptions; }; } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/android/location_api/LocationUtil.cpp b/android/location_api/LocationUtil.cpp index 311c0b2..7f3a74b 100644 --- a/android/location_api/LocationUtil.cpp +++ b/android/location_api/LocationUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -32,9 +32,13 @@ namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { namespace implementation { +using ::android::hardware::gnss::V1_0::GnssLocation; +using ::android::hardware::gnss::V1_0::GnssConstellationType; +using ::android::hardware::gnss::V1_0::GnssLocationFlags; + void convertGnssLocation(Location& in, GnssLocation& out) { memset(&out, 0, sizeof(GnssLocation)); @@ -63,7 +67,7 @@ void convertGnssLocation(Location& in, GnssLocation& out) out.verticalAccuracyMeters = in.verticalAccuracy; out.speedAccuracyMetersPerSecond = in.speedAccuracy; out.bearingAccuracyDegrees = in.bearingAccuracy; - out.timestamp = static_cast<GnssUtcTime>(in.timestamp); + out.timestamp = static_cast<V1_0::GnssUtcTime>(in.timestamp); } void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out) @@ -147,7 +151,7 @@ void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEph } } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/android/location_api/LocationUtil.h b/android/location_api/LocationUtil.h index 44d5e02..acc0eab 100644 --- a/android/location_api/LocationUtil.h +++ b/android/location_api/LocationUtil.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -37,17 +37,17 @@ namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { namespace implementation { -void convertGnssLocation(Location& in, GnssLocation& out); -void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out); +void convertGnssLocation(Location& in, V1_0::GnssLocation& out); +void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out); void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out); void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out); void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out); } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/android/location_api/MeasurementAPIClient.cpp b/android/location_api/MeasurementAPIClient.cpp index fcdd693..f1a5d01 100644 --- a/android/location_api/MeasurementAPIClient.cpp +++ b/android/location_api/MeasurementAPIClient.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,17 +39,23 @@ namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { namespace implementation { +using ::android::hardware::gnss::V1_0::IGnssMeasurement; +using ::android::hardware::gnss::V1_1::IGnssMeasurementCallback; + static void convertGnssData(GnssMeasurementsNotification& in, + V1_0::IGnssMeasurementCallback::GnssData& out); +static void convertGnssData_1_1(GnssMeasurementsNotification& in, IGnssMeasurementCallback::GnssData& out); static void convertGnssMeasurement(GnssMeasurementsData& in, - IGnssMeasurementCallback::GnssMeasurement& out); + V1_0::IGnssMeasurementCallback::GnssMeasurement& out); static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out); MeasurementAPIClient::MeasurementAPIClient() : mGnssMeasurementCbIface(nullptr), + mGnssMeasurementCbIface_1_1(nullptr), mTracking(false) { LOC_LOGD("%s]: ()", __FUNCTION__); @@ -62,7 +68,7 @@ MeasurementAPIClient::~MeasurementAPIClient() // for GpsInterface Return<IGnssMeasurement::GnssMeasurementStatus> -MeasurementAPIClient::measurementSetCallback(const sp<IGnssMeasurementCallback>& callback) +MeasurementAPIClient::measurementSetCallback(const sp<V1_0::IGnssMeasurementCallback>& callback) { LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback); @@ -70,6 +76,24 @@ MeasurementAPIClient::measurementSetCallback(const sp<IGnssMeasurementCallback>& mGnssMeasurementCbIface = callback; mMutex.unlock(); + return startTracking(); +} + +Return<IGnssMeasurement::GnssMeasurementStatus> +MeasurementAPIClient::measurementSetCallback_1_1(const sp<IGnssMeasurementCallback>& callback) +{ + LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback); + + mMutex.lock(); + mGnssMeasurementCbIface_1_1 = callback; + mMutex.unlock(); + + return startTracking(); +} + +Return<IGnssMeasurement::GnssMeasurementStatus> +MeasurementAPIClient::startTracking() +{ LocationCallbacks locationCallbacks; memset(&locationCallbacks, 0, sizeof(LocationCallbacks)); locationCallbacks.size = sizeof(LocationCallbacks); @@ -84,7 +108,7 @@ MeasurementAPIClient::measurementSetCallback(const sp<IGnssMeasurementCallback>& locationCallbacks.gnssNmeaCb = nullptr; locationCallbacks.gnssMeasurementsCb = nullptr; - if (mGnssMeasurementCbIface != nullptr) { + if (mGnssMeasurementCbIface_1_1 != nullptr || mGnssMeasurementCbIface != nullptr) { locationCallbacks.gnssMeasurementsCb = [this](GnssMeasurementsNotification gnssMeasurementsNotification) { onGnssMeasurementsCb(gnssMeasurementsNotification); @@ -119,11 +143,25 @@ void MeasurementAPIClient::onGnssMeasurementsCb( __FUNCTION__, gnssMeasurementsNotification.count, mTracking); if (mTracking) { mMutex.lock(); - auto gnssMeasurementCbIface(mGnssMeasurementCbIface); + sp<V1_0::IGnssMeasurementCallback> gnssMeasurementCbIface = nullptr; + sp<IGnssMeasurementCallback> gnssMeasurementCbIface_1_1 = nullptr; + if (mGnssMeasurementCbIface_1_1 != nullptr) { + gnssMeasurementCbIface_1_1 = mGnssMeasurementCbIface_1_1; + } else if (mGnssMeasurementCbIface != nullptr) { + gnssMeasurementCbIface = mGnssMeasurementCbIface; + } mMutex.unlock(); - if (gnssMeasurementCbIface != nullptr) { + if (gnssMeasurementCbIface_1_1 != nullptr) { IGnssMeasurementCallback::GnssData gnssData; + convertGnssData_1_1(gnssMeasurementsNotification, gnssData); + auto r = gnssMeasurementCbIface_1_1->gnssMeasurementCb(gnssData); + if (!r.isOk()) { + LOC_LOGE("%s] Error from gnssMeasurementCb description=%s", + __func__, r.description().c_str()); + } + } else if (gnssMeasurementCbIface != nullptr) { + V1_0::IGnssMeasurementCallback::GnssData gnssData; convertGnssData(gnssMeasurementsNotification, gnssData); auto r = gnssMeasurementCbIface->GnssMeasurementCb(gnssData); if (!r.isOk()) { @@ -135,7 +173,7 @@ void MeasurementAPIClient::onGnssMeasurementsCb( } static void convertGnssMeasurement(GnssMeasurementsData& in, - IGnssMeasurementCallback::GnssMeasurement& out) + V1_0::IGnssMeasurementCallback::GnssMeasurement& out) { memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssMeasurement)); if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT) @@ -242,13 +280,13 @@ static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback } static void convertGnssData(GnssMeasurementsNotification& in, - IGnssMeasurementCallback::GnssData& out) + V1_0::IGnssMeasurementCallback::GnssData& out) { out.measurementCount = in.count; - if (out.measurementCount > static_cast<uint32_t>(GnssMax::SVS_COUNT)) { + if (out.measurementCount > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) { LOC_LOGW("%s]: Too many measurement %u. Clamps to %d.", - __FUNCTION__, out.measurementCount, GnssMax::SVS_COUNT); - out.measurementCount = static_cast<uint32_t>(GnssMax::SVS_COUNT); + __FUNCTION__, out.measurementCount, V1_0::GnssMax::SVS_COUNT); + out.measurementCount = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT); } for (size_t i = 0; i < out.measurementCount; i++) { convertGnssMeasurement(in.measurements[i], out.measurements[i]); @@ -256,8 +294,18 @@ static void convertGnssData(GnssMeasurementsNotification& in, convertGnssClock(in.clock, out.clock); } +static void convertGnssData_1_1(GnssMeasurementsNotification& in, + IGnssMeasurementCallback::GnssData& out) +{ + out.measurements.resize(in.count); + for (size_t i = 0; i < in.count; i++) { + convertGnssMeasurement(in.measurements[i], out.measurements[i].v1_0); + } + convertGnssClock(in.clock, out.clock); +} + } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android diff --git a/android/location_api/MeasurementAPIClient.h b/android/location_api/MeasurementAPIClient.h index 8de1326..117ad54 100644 --- a/android/location_api/MeasurementAPIClient.h +++ b/android/location_api/MeasurementAPIClient.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -31,18 +31,17 @@ #define MEASUREMENT_API_CLINET_H #include <mutex> -#include <android/hardware/gnss/1.0/IGnssMeasurement.h> -#include <android/hardware/gnss/1.0/IGnssMeasurementCallback.h> +#include <android/hardware/gnss/1.1/IGnssMeasurement.h> +#include <android/hardware/gnss/1.1/IGnssMeasurementCallback.h> #include <LocationAPIClientBase.h> #include <hidl/Status.h> namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { namespace implementation { -using ::android::hardware::gnss::V1_0::IGnssMeasurement; using ::android::sp; class MeasurementAPIClient : public LocationAPIClientBase @@ -54,21 +53,26 @@ public: MeasurementAPIClient& operator=(const MeasurementAPIClient&) = delete; // for GpsMeasurementInterface - Return<IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback( + Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback( + const sp<V1_0::IGnssMeasurementCallback>& callback); + Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback_1_1( const sp<IGnssMeasurementCallback>& callback); void measurementClose(); + Return<IGnssMeasurement::GnssMeasurementStatus> startTracking(); // callbacks we are interested in void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final; private: - sp<IGnssMeasurementCallback> mGnssMeasurementCbIface; std::mutex mMutex; + sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface; + sp<IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1; + bool mTracking; }; } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android |