summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorSaurabh Srivastava <ssrivast@codeaurora.org>2018-04-08 23:35:14 +0530
committerSaurabh Srivastava <ssrivast@codeaurora.org>2018-06-03 22:43:58 +0530
commit98edc19bea3cf5787e5af903c8408dede420be58 (patch)
tree0702ae0f5d03195e8748e47a93c412feb8391bb9 /android
parent66c682f7d977846215b6d3607a5a43ad21c9c8b9 (diff)
downloadgps-98edc19bea3cf5787e5af903c8408dede420be58.tar.gz
FR 48850 - Device based hybrid ODCPI
Adding support for sending ODCPI request to framework via IGnss interface. Change-Id: I97ab4f00505705fedc266998602499fd344baf31 CRs-Fixed: 2217664
Diffstat (limited to 'android')
-rw-r--r--android/Gnss.cpp37
-rw-r--r--android/Gnss.h4
-rw-r--r--android/location_api/LocationUtil.cpp83
-rw-r--r--android/location_api/LocationUtil.h1
4 files changed, 107 insertions, 18 deletions
diff --git a/android/Gnss.cpp b/android/Gnss.cpp
index 3659823..5cec786 100644
--- a/android/Gnss.cpp
+++ b/android/Gnss.cpp
@@ -25,6 +25,8 @@
#include <dlfcn.h>
#include <cutils/properties.h>
#include "Gnss.h"
+#include <LocationUtil.h>
+
typedef void* (getLocationInterface)();
#define IMAGES_INFO_FILE "/sys/devices/soc0/images"
@@ -372,6 +374,14 @@ Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
ENTRY_LOG_CALLFLOW();
callback->gnssNameCb(getVersionString());
+ mGnssCbIface_1_1 = callback;
+ GnssInterface* gnssInterface = getGnssInterface();
+ if (nullptr != gnssInterface) {
+ OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
+ odcpiRequestCb(odcpiRequest);
+ };
+ gnssInterface->odcpiInit(cb);
+ }
return setCallback(callback);
}
@@ -407,11 +417,36 @@ Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() {
return mGnssConfig;
}
-Return<bool> Gnss::injectBestLocation(const GnssLocation&) {
+Return<bool> Gnss::injectBestLocation(const GnssLocation& gnssLocation) {
ENTRY_LOG_CALLFLOW();
+ GnssInterface* gnssInterface = getGnssInterface();
+ if (nullptr != gnssInterface) {
+ Location location = {};
+ convertGnssLocation(gnssLocation, location);
+ gnssInterface->odcpiInject(location);
+ }
return true;
}
+void Gnss::odcpiRequestCb(const OdcpiRequestInfo& request) {
+ ENTRY_LOG_CALLFLOW();
+ if (mGnssCbIface_1_1 != nullptr) {
+ // For emergency mode, request DBH (Device based hybrid) location
+ // Mark Independent from GNSS flag to false.
+ if (ODCPI_REQUEST_TYPE_START == request.type) {
+ if (request.isEmergencyMode) {
+ mGnssCbIface_1_1->gnssRequestLocationCb(false);
+ } else {
+ mGnssCbIface_1_1->gnssRequestLocationCb(true);
+ }
+ } else {
+ LOC_LOGv("Unsupported ODCPI request type: %d", request.type);
+ }
+ } else {
+ LOC_LOGe("ODCPI request not supported.");
+ }
+}
+
IGnss* HIDL_FETCH_IGnss(const char* hal) {
ENTRY_LOG_CALLFLOW();
IGnss* iface = nullptr;
diff --git a/android/Gnss.h b/android/Gnss.h
index c562b1f..4c0c8b0 100644
--- a/android/Gnss.h
+++ b/android/Gnss.h
@@ -111,6 +111,9 @@ struct Gnss : public IGnss {
Return<bool> updateConfiguration(GnssConfig& gnssConfig);
GnssInterface* getGnssInterface();
+ // Callback for ODCPI request
+ void odcpiRequestCb(const OdcpiRequestInfo& request);
+
private:
struct GnssDeathRecipient : hidl_death_recipient {
GnssDeathRecipient(sp<Gnss> gnss) : mGnss(gnss) {
@@ -134,6 +137,7 @@ struct Gnss : public IGnss {
GnssAPIClient* mApi = nullptr;
sp<V1_0::IGnssCallback> mGnssCbIface = nullptr;
+ sp<V1_1::IGnssCallback> mGnssCbIface_1_1 = nullptr;
sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
GnssConfig mPendingConfig;
GnssInterface* mGnssInterface = nullptr;
diff --git a/android/location_api/LocationUtil.cpp b/android/location_api/LocationUtil.cpp
index 7f3a74b..f1d051c 100644
--- a/android/location_api/LocationUtil.cpp
+++ b/android/location_api/LocationUtil.cpp
@@ -42,34 +42,83 @@ using ::android::hardware::gnss::V1_0::GnssLocationFlags;
void convertGnssLocation(Location& in, GnssLocation& out)
{
memset(&out, 0, sizeof(GnssLocation));
- if (in.flags & LOCATION_HAS_LAT_LONG_BIT)
+ if (in.flags & LOCATION_HAS_LAT_LONG_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_LAT_LONG;
- if (in.flags & LOCATION_HAS_ALTITUDE_BIT)
+ out.latitudeDegrees = in.latitude;
+ out.longitudeDegrees = in.longitude;
+ }
+ if (in.flags & LOCATION_HAS_ALTITUDE_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_ALTITUDE;
- if (in.flags & LOCATION_HAS_SPEED_BIT)
+ out.altitudeMeters = in.altitude;
+ }
+ if (in.flags & LOCATION_HAS_SPEED_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED;
- if (in.flags & LOCATION_HAS_BEARING_BIT)
+ out.speedMetersPerSec = in.speed;
+ }
+ if (in.flags & LOCATION_HAS_BEARING_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING;
- if (in.flags & LOCATION_HAS_ACCURACY_BIT)
+ out.bearingDegrees = in.bearing;
+ }
+ if (in.flags & LOCATION_HAS_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_HORIZONTAL_ACCURACY;
- if (in.flags & LOCATION_HAS_VERTICAL_ACCURACY_BIT)
+ out.horizontalAccuracyMeters = in.accuracy;
+ }
+ if (in.flags & LOCATION_HAS_VERTICAL_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_VERTICAL_ACCURACY;
- if (in.flags & LOCATION_HAS_SPEED_ACCURACY_BIT)
+ out.verticalAccuracyMeters = in.verticalAccuracy;
+ }
+ if (in.flags & LOCATION_HAS_SPEED_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED_ACCURACY;
- if (in.flags & LOCATION_HAS_BEARING_ACCURACY_BIT)
+ out.speedAccuracyMetersPerSecond = in.speedAccuracy;
+ }
+ if (in.flags & LOCATION_HAS_BEARING_ACCURACY_BIT) {
out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING_ACCURACY;
- out.latitudeDegrees = in.latitude;
- out.longitudeDegrees = in.longitude;
- out.altitudeMeters = in.altitude;
- out.speedMetersPerSec = in.speed;
- out.bearingDegrees = in.bearing;
- out.horizontalAccuracyMeters = in.accuracy;
- out.verticalAccuracyMeters = in.verticalAccuracy;
- out.speedAccuracyMetersPerSecond = in.speedAccuracy;
- out.bearingAccuracyDegrees = in.bearingAccuracy;
+ out.bearingAccuracyDegrees = in.bearingAccuracy;
+ }
+
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;
+ out.latitude = in.latitudeDegrees;
+ out.longitude = in.longitudeDegrees;
+ }
+ if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE) {
+ out.flags |= LOCATION_HAS_ALTITUDE_BIT;
+ out.altitude = in.altitudeMeters;
+ }
+ if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED) {
+ out.flags |= LOCATION_HAS_SPEED_BIT;
+ out.speed = in.speedMetersPerSec;
+ }
+ if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
+ out.flags |= LOCATION_HAS_BEARING_BIT;
+ out.bearing = in.bearingDegrees;
+ }
+ if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY) {
+ out.flags |= LOCATION_HAS_ACCURACY_BIT;
+ out.accuracy = in.horizontalAccuracyMeters;
+ }
+ if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) {
+ out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT;
+ out.verticalAccuracy = in.verticalAccuracyMeters;
+ }
+ if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) {
+ out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT;
+ out.speedAccuracy = in.speedAccuracyMetersPerSecond;
+ }
+ if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) {
+ out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT;
+ out.bearingAccuracy = in.bearingAccuracyDegrees;
+ }
+
+ out.timestamp = static_cast<uint64_t>(in.timestamp);
+}
+
void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out)
{
switch(in) {
diff --git a/android/location_api/LocationUtil.h b/android/location_api/LocationUtil.h
index acc0eab..63f4f6f 100644
--- a/android/location_api/LocationUtil.h
+++ b/android/location_api/LocationUtil.h
@@ -41,6 +41,7 @@ namespace V1_1 {
namespace implementation {
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);