diff options
author | Yuchen He <yuchenhe@google.com> | 2021-06-10 17:10:15 -0700 |
---|---|---|
committer | Hao Chen <chenhaosjtuacm@google.com> | 2022-02-18 18:03:12 -0800 |
commit | 95276a229b6abfe8111e6b92b9ca8f3043ec0515 (patch) | |
tree | 7d837b1c607e0c09bc0d66376f34dbca432472d3 /gnss/aidl/default/GnssMeasurementInterface.cpp | |
parent | 6f876987a6746e7462789ae1975415fdda70d584 (diff) |
Refactor and reuse some read device file logic
Add skeleton on HAL for Gnss raw measurement injection
Bug: 190757198
Test: manual test
Merged-In: I9b58043d5ed321aa71ff4f23031df251ae89c407
Change-Id: I9b58043d5ed321aa71ff4f23031df251ae89c407
Diffstat (limited to 'gnss/aidl/default/GnssMeasurementInterface.cpp')
-rw-r--r-- | gnss/aidl/default/GnssMeasurementInterface.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/gnss/aidl/default/GnssMeasurementInterface.cpp b/gnss/aidl/default/GnssMeasurementInterface.cpp index fcc1f986cc..0e489c59e4 100644 --- a/gnss/aidl/default/GnssMeasurementInterface.cpp +++ b/gnss/aidl/default/GnssMeasurementInterface.cpp @@ -19,11 +19,13 @@ #include "GnssMeasurementInterface.h" #include <aidl/android/hardware/gnss/BnGnss.h> #include <log/log.h> +#include "GnssReplayUtils.h" #include "Utils.h" namespace aidl::android::hardware::gnss { using Utils = ::android::hardware::gnss::common::Utils; +using ReplayUtils = ::android::hardware::gnss::common::ReplayUtils; std::shared_ptr<IGnssMeasurementCallback> GnssMeasurementInterface::sCallback = nullptr; @@ -63,9 +65,22 @@ void GnssMeasurementInterface::start(const bool enableCorrVecOutputs) { mIsActive = true; mThread = std::thread([this, enableCorrVecOutputs]() { while (mIsActive == true) { - auto measurement = Utils::getMockMeasurement(enableCorrVecOutputs); - this->reportMeasurement(measurement); - + std::string rawMeasurementStr = ""; + if (ReplayUtils::hasGnssDeviceFile() && + ReplayUtils::isGnssRawMeasurement( + rawMeasurementStr = ReplayUtils::getDataFromDeviceFile( + std::string( + ::android::hardware::gnss::common::CMD_GET_RAWMEASUREMENT), + mMinIntervalMillis))) { + // TODO: implement rawMeasurementStr parser and report measurement. + ALOGD("rawMeasurementStr(size: %zu) from device file: %s", rawMeasurementStr.size(), + rawMeasurementStr.c_str()); + auto measurement = Utils::getMockMeasurement(enableCorrVecOutputs); + this->reportMeasurement(measurement); + } else { + auto measurement = Utils::getMockMeasurement(enableCorrVecOutputs); + this->reportMeasurement(measurement); + } std::this_thread::sleep_for(std::chrono::milliseconds(mMinIntervalMillis)); } }); |