sanders: gps: update to LA.UM.7.6.r1-02000-89xx.0 tag

This commit is contained in:
therootlord
2018-09-12 13:45:48 -03:00
parent 8a6b5c05e7
commit 0a41b9dc1a
150 changed files with 4794 additions and 4130 deletions

View File

@@ -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

View File

@@ -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,14 +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;
int mBatchSize;
LocationCapabilitiesMask mLocationCapabilitiesMask;
};
} // namespace implementation
} // namespace V1_0
} // namespace V1_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -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

View File

@@ -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

View File

@@ -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,
@@ -81,8 +86,10 @@ void GnssAPIClient::gnssUpdateCallbacks(const sp<IGnssCallback>& gpsCb,
{
LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
mMutex.lock();
mGnssCbIface = gpsCb;
mGnssNiCbIface = niCb;
mMutex.unlock();
LocationCallbacks locationCallbacks;
memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
@@ -158,6 +165,10 @@ bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode,
mLocationOptions.size = sizeof(LocationOptions);
mLocationOptions.minInterval = minIntervalMs;
mLocationOptions.minDistance = preferredAccuracyMeters;
if (IGnss::GnssPositionRecurrence::RECURRENCE_SINGLE == recurrence) {
mLocationOptions.minInterval =
std::numeric_limits<decltype(mLocationOptions.minInterval)>::max();
}
if (mode == IGnss::GnssPositionMode::STANDALONE)
mLocationOptions.mode = GNSS_SUPL_MODE_STANDALONE;
else if (mode == IGnss::GnssPositionMode::MS_BASED)
@@ -278,7 +289,10 @@ void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
LOC_LOGD("%s]: (%02x)", __FUNCTION__, capabilitiesMask);
mLocationCapabilitiesMask = capabilitiesMask;
mLocationCapabilitiesCached = true;
sp<IGnssCallback> gnssCbIface = mGnssCbIface;
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
mMutex.unlock();
if (gnssCbIface != nullptr) {
uint32_t data = 0;
@@ -322,7 +336,9 @@ void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
void GnssAPIClient::onTrackingCb(Location location)
{
LOC_LOGD("%s]: (flags: %02x)", __FUNCTION__, location.flags);
sp<IGnssCallback> gnssCbIface = mGnssCbIface;
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
mMutex.unlock();
if (gnssCbIface != nullptr) {
GnssLocation gnssLocation;
@@ -338,7 +354,9 @@ void GnssAPIClient::onTrackingCb(Location location)
void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification)
{
LOC_LOGD("%s]: (id: %d)", __FUNCTION__, id);
sp<IGnssNiCallback> gnssNiCbIface = mGnssNiCbIface;
mMutex.lock();
auto gnssNiCbIface(mGnssNiCbIface);
mMutex.unlock();
if (gnssNiCbIface == nullptr) {
LOC_LOGE("%s]: mGnssNiCbIface is nullptr", __FUNCTION__);
@@ -411,7 +429,9 @@ void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotificatio
void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification)
{
LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, gnssSvNotification.count);
sp<IGnssCallback> gnssCbIface = mGnssCbIface;
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
mMutex.unlock();
if (gnssCbIface != nullptr) {
IGnssCallback::GnssSvStatus svStatus;
@@ -426,13 +446,15 @@ void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification)
void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
{
sp<IGnssCallback> gnssCbIface = mGnssCbIface;
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
mMutex.unlock();
if (gnssCbIface != nullptr) {
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());
@@ -443,7 +465,9 @@ void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
void GnssAPIClient::onStartTrackingCb(LocationError error)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
sp<IGnssCallback> gnssCbIface = mGnssCbIface;
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
mMutex.unlock();
if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) {
auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON);
@@ -462,7 +486,9 @@ void GnssAPIClient::onStartTrackingCb(LocationError error)
void GnssAPIClient::onStopTrackingCb(LocationError error)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
sp<IGnssCallback> gnssCbIface = mGnssCbIface;
mMutex.lock();
auto gnssCbIface(mGnssCbIface);
mMutex.unlock();
if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) {
auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END);
@@ -482,10 +508,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)) {
LOC_LOGW("%s]: Too many satellites %zd. Clamps to %d.",
__FUNCTION__, out.numSvs, GnssMax::SVS_COUNT);
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, 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];
@@ -505,7 +531,7 @@ static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvSta
}
} // namespace implementation
} // namespace V1_0
} // namespace V1_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -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,15 +31,16 @@
#define GNSS_API_CLINET_H
#include <android/hardware/gnss/1.0/IGnss.h>
#include <android/hardware/gnss/1.0/IGnssCallback.h>
#include <mutex>
#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,9 +90,9 @@ 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;
@@ -100,7 +101,7 @@ private:
};
} // namespace implementation
} // namespace V1_0
} // namespace V1_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -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,38 @@ 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 convertGnssLocation(const GnssLocation& in, Location& out)
{
memset(&out, 0, sizeof(out));
if (in.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG)
out.flags |= LOCATION_HAS_LAT_LONG_BIT;
if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE)
out.flags |= LOCATION_HAS_ALTITUDE_BIT;
if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED)
out.flags |= LOCATION_HAS_SPEED_BIT;
if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING)
out.flags |= LOCATION_HAS_BEARING_BIT;
if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY)
out.flags |= LOCATION_HAS_ACCURACY_BIT;
if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY)
out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT;
if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY)
out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT;
if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY)
out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT;
out.latitude = in.latitudeDegrees;
out.longitude = in.longitudeDegrees;
out.altitude = in.altitudeMeters;
out.speed = in.speedMetersPerSec;
out.bearing = in.bearingDegrees;
out.accuracy = in.horizontalAccuracyMeters;
out.verticalAccuracy = in.verticalAccuracyMeters;
out.speedAccuracy = in.speedAccuracyMetersPerSecond;
out.bearingAccuracy = in.bearingAccuracyDegrees;
out.timestamp = static_cast<uint64_t>(in.timestamp);
}
void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out)
@@ -147,7 +182,7 @@ void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEph
}
} // namespace implementation
} // namespace V1_0
} // namespace V1_1
} // namespace gnss
} // namespace hardware
} // namespace android

View File

@@ -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,18 @@
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 convertGnssLocation(const V1_0::GnssLocation& in, Location& 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

View File

@@ -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,12 +68,32 @@ 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);
mMutex.lock();
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);
@@ -82,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);
@@ -113,13 +139,31 @@ void MeasurementAPIClient::measurementClose() {
void MeasurementAPIClient::onGnssMeasurementsCb(
GnssMeasurementsNotification gnssMeasurementsNotification)
{
LOC_LOGD("%s]: (count: %zu active: %zu)",
LOC_LOGD("%s]: (count: %zu active: %d)",
__FUNCTION__, gnssMeasurementsNotification.count, mTracking);
if (mTracking) {
if (mGnssMeasurementCbIface != nullptr) {
mMutex.lock();
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_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 = mGnssMeasurementCbIface->GnssMeasurementCb(gnssData);
auto r = gnssMeasurementCbIface->GnssMeasurementCb(gnssData);
if (!r.isOk()) {
LOC_LOGE("%s] Error from GnssMeasurementCb description=%s",
__func__, r.description().c_str());
@@ -129,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)
@@ -236,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)) {
LOC_LOGW("%s]: Too many measurement %zd. Clamps to %d.",
__FUNCTION__, out.measurementCount, GnssMax::SVS_COUNT);
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, 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]);
@@ -250,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

View File

@@ -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,19 +30,18 @@
#ifndef MEASUREMENT_API_CLINET_H
#define MEASUREMENT_API_CLINET_H
#include <android/hardware/gnss/1.0/IGnssMeasurement.h>
#include <android/hardware/gnss/1.0/IGnssMeasurementCallback.h>
#include <mutex>
#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