diff options
Diffstat (limited to 'gnss/1.1/default/Gnss.cpp')
| -rw-r--r-- | gnss/1.1/default/Gnss.cpp | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/gnss/1.1/default/Gnss.cpp b/gnss/1.1/default/Gnss.cpp index bbf1cd31de..4abe707d4a 100644 --- a/gnss/1.1/default/Gnss.cpp +++ b/gnss/1.1/default/Gnss.cpp @@ -4,9 +4,9 @@ #include <log/log.h> #include "Gnss.h" -#include "GnssConstants.h" #include "GnssDebug.h" #include "GnssMeasurement.h" +#include "Utils.h" namespace android { namespace hardware { @@ -14,6 +14,7 @@ namespace gnss { namespace V1_1 { namespace implementation { +using ::android::hardware::gnss::common::Utils; using GnssSvFlags = IGnssCallback::GnssSvFlags; const uint32_t MIN_INTERVAL_MILLIS = 100; @@ -43,7 +44,7 @@ Return<bool> Gnss::start() { auto svStatus = this->getMockSvStatus(); this->reportSvStatus(svStatus); - auto location = this->getMockLocation(); + auto location = Utils::getMockLocation(); this->reportLocation(location); std::this_thread::sleep_for(std::chrono::milliseconds(mMinIntervalMs)); @@ -193,44 +194,17 @@ Return<bool> Gnss::injectBestLocation(const GnssLocation&) { return true; } -Return<GnssLocation> Gnss::getMockLocation() const { - GnssLocation location = {.gnssLocationFlags = 0xFF, - .latitudeDegrees = kMockLatitudeDegrees, - .longitudeDegrees = kMockLongitudeDegrees, - .altitudeMeters = kMockAltitudeMeters, - .speedMetersPerSec = kMockSpeedMetersPerSec, - .bearingDegrees = kMockBearingDegrees, - .horizontalAccuracyMeters = kMockHorizontalAccuracyMeters, - .verticalAccuracyMeters = kMockVerticalAccuracyMeters, - .speedAccuracyMetersPerSecond = kMockSpeedAccuracyMetersPerSecond, - .bearingAccuracyDegrees = kMockBearingAccuracyDegrees, - .timestamp = kMockTimestamp}; - return location; -} - -Return<GnssSvInfo> Gnss::getSvInfo(int16_t svid, GnssConstellationType type, float cN0DbHz, - float elevationDegrees, float azimuthDegrees) const { - GnssSvInfo svInfo = {.svid = svid, - .constellation = type, - .cN0Dbhz = cN0DbHz, - .elevationDegrees = elevationDegrees, - .azimuthDegrees = azimuthDegrees, - .svFlag = GnssSvFlags::USED_IN_FIX | GnssSvFlags::HAS_EPHEMERIS_DATA | - GnssSvFlags::HAS_ALMANAC_DATA}; - return svInfo; -} - Return<GnssSvStatus> Gnss::getMockSvStatus() const { std::unique_lock<std::recursive_mutex> lock(mGnssConfiguration->getMutex()); GnssSvInfo mockGnssSvInfoList[] = { - getSvInfo(3, GnssConstellationType::GPS, 32.5, 59.1, 166.5), - getSvInfo(5, GnssConstellationType::GPS, 27.0, 29.0, 56.5), - getSvInfo(17, GnssConstellationType::GPS, 30.5, 71.0, 77.0), - getSvInfo(26, GnssConstellationType::GPS, 24.1, 28.0, 253.0), - getSvInfo(5, GnssConstellationType::GLONASS, 20.5, 11.5, 116.0), - getSvInfo(17, GnssConstellationType::GLONASS, 21.5, 28.5, 186.0), - getSvInfo(18, GnssConstellationType::GLONASS, 28.3, 38.8, 69.0), - getSvInfo(10, GnssConstellationType::GLONASS, 25.0, 66.0, 247.0)}; + Utils::getSvInfo(3, GnssConstellationType::GPS, 32.5, 59.1, 166.5), + Utils::getSvInfo(5, GnssConstellationType::GPS, 27.0, 29.0, 56.5), + Utils::getSvInfo(17, GnssConstellationType::GPS, 30.5, 71.0, 77.0), + Utils::getSvInfo(26, GnssConstellationType::GPS, 24.1, 28.0, 253.0), + Utils::getSvInfo(5, GnssConstellationType::GLONASS, 20.5, 11.5, 116.0), + Utils::getSvInfo(17, GnssConstellationType::GLONASS, 21.5, 28.5, 186.0), + Utils::getSvInfo(18, GnssConstellationType::GLONASS, 28.3, 38.8, 69.0), + Utils::getSvInfo(10, GnssConstellationType::GLONASS, 25.0, 66.0, 247.0)}; GnssSvStatus svStatus = {.numSvs = sizeof(mockGnssSvInfoList) / sizeof(GnssSvInfo)}; for (uint32_t i = 0; i < svStatus.numSvs; i++) { |
