Add gnss capability - Accumulated Delta Range in AIDL HAL (hardware/interfaces)

Test: on Cuttlefish
Change-Id: I12307e21b1c574d76f3c0a834e8eb75f1b23e7a3
Bug: 260002331
This commit is contained in:
Zhanghao Wen
2022-11-17 13:51:25 -08:00
parent 9e68defd2d
commit 28a8edfeb2
5 changed files with 65 additions and 5 deletions

View File

@@ -61,6 +61,7 @@ interface IGnssCallback {
const int CAPABILITY_CORRELATION_VECTOR = 4096;
const int CAPABILITY_SATELLITE_PVT = 8192;
const int CAPABILITY_MEASUREMENT_CORRECTIONS_FOR_DRIVING = 16384;
const int CAPABILITY_ACCUMULATED_DELTA_RANGE = 32768;
@Backing(type="int") @VintfStability
enum GnssStatusValue {
NONE = 0,

View File

@@ -82,6 +82,9 @@ interface IGnssCallback {
/** Capability bit mask indicating that GNSS supports measurement corrections for driving */
const int CAPABILITY_MEASUREMENT_CORRECTIONS_FOR_DRIVING = 1 << 14;
/** Capability bit mask indicating that GNSS supports accumulated delta range */
const int CAPABILITY_ACCUMULATED_DELTA_RANGE = 1 << 15;
/**
* Callback to inform framework of the GNSS HAL implementation's capabilities.
*

View File

@@ -60,7 +60,8 @@ ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback)
IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST |
IGnssCallback::CAPABILITY_SATELLITE_PVT |
IGnssCallback::CAPABILITY_CORRELATION_VECTOR |
IGnssCallback::CAPABILITY_ANTENNA_INFO);
IGnssCallback::CAPABILITY_ANTENNA_INFO |
IGnssCallback::CAPABILITY_ACCUMULATED_DELTA_RANGE);
auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities);
if (!status.isOk()) {
ALOGE("%s: Unable to invoke callback.gnssSetCapabilitiesCb", __func__);

View File

@@ -1505,10 +1505,11 @@ TEST_P(GnssHalTest, TestGnssMeasurementIntervals_LocationOnAfterMeasurement) {
}
/*
* TestGnssMeasurementSetCallback
* 1. Start measurement with 20s interval. Expect the first measurement received in 10s.
* TestGnssMeasurementSetCallback:
* This test ensures setCallback() can be called consecutively without close().
* 1. Start measurement with 20s interval and wait for 1 measurement.
* 2. Start measurement with 1s interval and wait for 5 measurements.
* 3. Verify the received measurement intervals have expected mean and stddev.
* Verify the measurements were received at 1Hz.
*/
TEST_P(GnssHalTest, TestGnssMeasurementSetCallback) {
if (aidl_gnss_hal_->getInterfaceVersion() <= 2) {
@@ -1581,3 +1582,57 @@ TEST_P(GnssHalTest, TestGnssMeasurementIsFullTracking) {
status = iGnssMeasurement->close();
ASSERT_TRUE(status.isOk());
}
/*
* TestAccumulatedDeltaRange:
* 1. Gets the GnssMeasurementExtension and verifies that it returns a non-null extension.
* 2. Start measurement with 1s interval and wait for up to 15 measurements.
* 3. Verify at least one measurement has a valid AccumulatedDeltaRange state.
*/
TEST_P(GnssHalTest, TestAccumulatedDeltaRange) {
if (aidl_gnss_hal_->getInterfaceVersion() <= 2) {
return;
}
if ((aidl_gnss_cb_->last_capabilities_ & IGnssCallback::CAPABILITY_ACCUMULATED_DELTA_RANGE) ==
0) {
return;
}
ALOGD("TestAccumulatedDeltaRange");
auto callback = sp<GnssMeasurementCallbackAidl>::make();
sp<IGnssMeasurementInterface> iGnssMeasurement;
auto status = aidl_gnss_hal_->getExtensionGnssMeasurement(&iGnssMeasurement);
IGnssMeasurementInterface::Options options;
options.intervalMs = 1000;
options.enableFullTracking = true;
status = iGnssMeasurement->setCallbackWithOptions(callback, options);
ASSERT_TRUE(status.isOk());
ASSERT_TRUE(iGnssMeasurement != nullptr);
bool accumulatedDeltaRangeFound = false;
const int kNumMeasurementEvents = 15;
// setCallback at 1s interval and wait for 15 measurements
for (int i = 0; i < kNumMeasurementEvents; i++) {
GnssData lastGnssData;
ASSERT_TRUE(callback->gnss_data_cbq_.retrieve(lastGnssData, 10));
EXPECT_EQ(callback->gnss_data_cbq_.calledCount(), i + 1);
ASSERT_TRUE(lastGnssData.measurements.size() > 0);
// Validity check GnssData fields
checkGnssMeasurementClockFields(lastGnssData);
for (const auto& measurement : lastGnssData.measurements) {
if ((measurement.accumulatedDeltaRangeState & measurement.ADR_STATE_VALID) > 0) {
accumulatedDeltaRangeFound = true;
break;
}
}
if (accumulatedDeltaRangeFound) break;
}
ASSERT_TRUE(accumulatedDeltaRangeFound);
status = iGnssMeasurement->close();
ASSERT_TRUE(status.isOk());
}

View File

@@ -170,7 +170,7 @@ GnssData Utils::getMockMeasurement(const bool enableCorrVecOutputs, const bool e
.agcLevelDb = 2.3,
.pseudorangeRateMps = -484.13739013671875,
.pseudorangeRateUncertaintyMps = 1.0379999876022339,
.accumulatedDeltaRangeState = GnssMeasurement::ADR_STATE_UNKNOWN,
.accumulatedDeltaRangeState = GnssMeasurement::ADR_STATE_VALID,
.accumulatedDeltaRangeM = 1.52,
.accumulatedDeltaRangeUncertaintyM = 2.43,
.multipathIndicator = aidl::android::hardware::gnss::GnssMultipathIndicator::UNKNOWN,