GnssStatus for GnssMeasurement-only VTS test

Update VTS test case: GnssStatus should be reported when only
measurement is registered.

Test: atest VtsHalGnssTargetTest
Bug: 274653052
Change-Id: I53c741d2cee7a4c36ad0a2744ccb8b3e917b7996
This commit is contained in:
Zhanghao 2023-03-21 05:41:55 +00:00
parent 534c5eeea3
commit d32f378405
10 changed files with 66 additions and 7 deletions

View file

@ -214,9 +214,12 @@ interface IGnssCallback {
/**
* Callback for the HAL to pass a vector of GnssSvInfo back to the client.
*
* If GnssMeasurement is registered, the SvStatus report interval is the same as the measurement
* interval, i.e., the interval the measurement engine runs at. If GnssMeasurement is not
* registered, the SvStatus interval is the same as the location interval.
* If only GnssMeasurement is registered, the SvStatus reporting interval must be
* the same as the measurement interval, i.e., the interval the measurement
* engine runs at. If only location is registered, the SvStatus interval must
* be the same as the location interval. If both GnssMeasurement and location
* are registered, then the SvStatus interval is the same as the lesser interval
* between the two.
*
* @param svInfo SV status information from HAL.
*/

View file

@ -325,6 +325,7 @@ ScopedAStatus Gnss::getExtensionGnssMeasurement(
ALOGD("getExtensionGnssMeasurement");
if (mGnssMeasurementInterface == nullptr) {
mGnssMeasurementInterface = SharedRefBase::make<GnssMeasurementInterface>();
mGnssMeasurementInterface->setGnssInterface(static_cast<std::shared_ptr<Gnss>>(this));
}
*iGnssMeasurement = mGnssMeasurementInterface;
return ScopedAStatus::ok();

View file

@ -84,13 +84,13 @@ class Gnss : public BnGnss {
IMeasurementCorrectionsInterface>* iMeasurementCorrections)
override;
void reportSvStatus() const;
std::shared_ptr<GnssConfiguration> mGnssConfiguration;
std::shared_ptr<GnssPowerIndication> mGnssPowerIndication;
std::shared_ptr<GnssMeasurementInterface> mGnssMeasurementInterface;
private:
void reportLocation(const GnssLocation&) const;
void reportSvStatus() const;
void reportSvStatus(const std::vector<IGnssCallback::GnssSvInfo>& svInfoList) const;
std::vector<IGnssCallback::GnssSvInfo> filterBlocklistedSatellites(
std::vector<IGnssCallback::GnssSvInfo> gnssSvInfoList) const;

View file

@ -20,6 +20,7 @@
#include <aidl/android/hardware/gnss/BnGnss.h>
#include <log/log.h>
#include "DeviceFileReader.h"
#include "Gnss.h"
#include "GnssRawMeasurementParser.h"
#include "GnssReplayUtils.h"
#include "Utils.h"
@ -126,6 +127,9 @@ void GnssMeasurementInterface::start(const bool enableCorrVecOutputs,
auto measurement =
Utils::getMockMeasurement(enableCorrVecOutputs, enableFullTracking);
this->reportMeasurement(measurement);
if (!mLocationEnabled) {
mGnss->reportSvStatus();
}
}
intervalMs =
(mLocationEnabled) ? std::min(mLocationIntervalMs, mIntervalMs) : mIntervalMs;
@ -164,6 +168,10 @@ void GnssMeasurementInterface::setLocationEnabled(const bool enabled) {
mLocationEnabled = enabled;
}
void GnssMeasurementInterface::setGnssInterface(const std::shared_ptr<Gnss>& gnss) {
mGnss = gnss;
}
void GnssMeasurementInterface::waitForStoppingThreads() {
for (auto& future : mFutures) {
ALOGD("Stopping previous thread.");

View file

@ -25,6 +25,7 @@
#include "Utils.h"
namespace aidl::android::hardware::gnss {
class Gnss;
struct GnssMeasurementInterface : public BnGnssMeasurementInterface {
public:
@ -39,6 +40,7 @@ struct GnssMeasurementInterface : public BnGnssMeasurementInterface {
const Options& options) override;
void setLocationInterval(const int intervalMs);
void setLocationEnabled(const bool enabled);
void setGnssInterface(const std::shared_ptr<Gnss>& gnss);
private:
void start(const bool enableCorrVecOutputs, const bool enableFullTracking);
@ -59,6 +61,8 @@ struct GnssMeasurementInterface : public BnGnssMeasurementInterface {
// Synchronization lock for sCallback
mutable std::mutex mMutex;
std::shared_ptr<Gnss> mGnss;
};
} // namespace aidl::android::hardware::gnss

View file

@ -18,6 +18,7 @@
#include "GnssCallbackAidl.h"
#include <log/log.h>
#include <utils/SystemClock.h>
using android::binder::Status;
using android::hardware::gnss::GnssLocation;
@ -53,6 +54,7 @@ Status GnssCallbackAidl::gnssStatusCb(const GnssStatusValue /* status */) {
Status GnssCallbackAidl::gnssSvStatusCb(const std::vector<GnssSvInfo>& svInfoList) {
ALOGI("gnssSvStatusCb. Size = %d", (int)svInfoList.size());
sv_info_list_cbq_.store(svInfoList);
sv_info_list_timestamps_millis_cbq_.store(::android::elapsedRealtime());
return Status::ok();
}

View file

@ -29,6 +29,7 @@ class GnssCallbackAidl : public android::hardware::gnss::BnGnssCallback {
info_cbq_("system_info"),
location_cbq_("location"),
sv_info_list_cbq_("sv_info"),
sv_info_list_timestamps_millis_cbq_("sv_info_timestamps"),
nmea_cbq_("nmea"){};
~GnssCallbackAidl(){};
@ -64,6 +65,8 @@ class GnssCallbackAidl : public android::hardware::gnss::BnGnssCallback {
android::hardware::gnss::common::GnssCallbackEventQueue<
std::vector<android::hardware::gnss::IGnssCallback::GnssSvInfo>>
sv_info_list_cbq_;
android::hardware::gnss::common::GnssCallbackEventQueue<long>
sv_info_list_timestamps_millis_cbq_;
android::hardware::gnss::common::GnssCallbackEventQueue<std::pair<int64_t, std::string>>
nmea_cbq_;
};

View file

@ -478,6 +478,30 @@ void GnssHalTest::collectMeasurementIntervals(const sp<GnssMeasurementCallbackAi
}
}
void GnssHalTest::collectSvInfoListTimestamps(const int numMeasurementEvents,
const int timeoutSeconds,
std::vector<int>& deltasMs) {
aidl_gnss_cb_->sv_info_list_timestamps_millis_cbq_.reset();
aidl_gnss_cb_->sv_info_list_cbq_.reset();
auto status = aidl_gnss_hal_->startSvStatus();
EXPECT_TRUE(status.isOk());
ASSERT_TRUE(aidl_gnss_cb_->sv_info_list_timestamps_millis_cbq_.size() ==
aidl_gnss_cb_->sv_info_list_cbq_.size());
long lastElapsedRealtimeMillis = 0;
for (int i = 0; i < numMeasurementEvents; i++) {
long timeStamp;
ASSERT_TRUE(aidl_gnss_cb_->sv_info_list_timestamps_millis_cbq_.retrieve(timeStamp,
timeoutSeconds));
if (lastElapsedRealtimeMillis != 0) {
deltasMs.push_back(timeStamp - lastElapsedRealtimeMillis);
}
lastElapsedRealtimeMillis = timeStamp;
}
status = aidl_gnss_hal_->stopSvStatus();
EXPECT_TRUE(status.isOk());
}
void GnssHalTest::checkGnssDataFields(const sp<GnssMeasurementCallbackAidl>& callback,
const int numMeasurementEvents, const int timeoutSeconds,
const bool isFullTracking) {

View file

@ -101,6 +101,8 @@ class GnssHalTest : public android::hardware::gnss::common::GnssHalTestTemplate<
void collectMeasurementIntervals(const sp<GnssMeasurementCallbackAidl>& callback,
const int numMeasurementEvents, const int timeoutSeconds,
std::vector<int>& deltaMs);
void collectSvInfoListTimestamps(const int numMeasurementEvents, const int timeoutSeconds,
std::vector<int>& deltasMs);
void checkGnssDataFields(const sp<GnssMeasurementCallbackAidl>& callback,
const int numMeasurementEvents, const int timeoutSeconds,
const bool isFullTracking);

View file

@ -1407,6 +1407,7 @@ TEST_P(GnssHalTest, TestStopSvStatusAndNmea) {
* TestGnssMeasurementIntervals_WithoutLocation:
* 1. Start measurement at intervals
* 2. Verify measurement are received at expected intervals
* 3. Verify status are reported at expected intervals
*/
TEST_P(GnssHalTest, TestGnssMeasurementIntervals_WithoutLocation) {
if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
@ -1426,13 +1427,24 @@ TEST_P(GnssHalTest, TestGnssMeasurementIntervals_WithoutLocation) {
auto callback = sp<GnssMeasurementCallbackAidl>::make();
startMeasurementWithInterval(intervals[i], iGnssMeasurement, callback);
std::vector<int> deltas;
collectMeasurementIntervals(callback, numEvents[i], /* timeoutSeconds= */ 10, deltas);
std::vector<int> measurementDeltas;
std::vector<int> svInfoListTimestampsDeltas;
collectMeasurementIntervals(callback, numEvents[i], /* timeoutSeconds= */ 10,
measurementDeltas);
if (aidl_gnss_hal_->getInterfaceVersion() >= 3) {
collectSvInfoListTimestamps(numEvents[i], /* timeoutSeconds= */ 10,
svInfoListTimestampsDeltas);
}
status = iGnssMeasurement->close();
ASSERT_TRUE(status.isOk());
assertMeanAndStdev(intervals[i], deltas);
assertMeanAndStdev(intervals[i], measurementDeltas);
if (aidl_gnss_hal_->getInterfaceVersion() >= 3) {
assertMeanAndStdev(intervals[i], svInfoListTimestampsDeltas);
EXPECT_TRUE(aidl_gnss_cb_->sv_info_list_cbq_.size() > 0);
}
}
}