Add MeasurementCorrections AIDL HAL (hardware/interfaces)
Bug: 208728105
Test: atest VtsHalGnssTargetTest
Change-Id: I2192670951a517bd229535a083997cc9bab31287
diff --git a/gnss/aidl/vts/Android.bp b/gnss/aidl/vts/Android.bp
index b23a646..4244ab3 100644
--- a/gnss/aidl/vts/Android.bp
+++ b/gnss/aidl/vts/Android.bp
@@ -39,6 +39,7 @@
"GnssNavigationMessageCallback.cpp",
"GnssPowerIndicationCallback.cpp",
"GnssVisibilityControlCallback.cpp",
+ "MeasurementCorrectionsCallback.cpp",
"VtsHalGnssTargetTest.cpp",
],
shared_libs: [
diff --git a/gnss/aidl/vts/MeasurementCorrectionsCallback.cpp b/gnss/aidl/vts/MeasurementCorrectionsCallback.cpp
new file mode 100644
index 0000000..db1f7a6
--- /dev/null
+++ b/gnss/aidl/vts/MeasurementCorrectionsCallback.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "MeasurementCorrectionsCallback"
+
+#include "MeasurementCorrectionsCallback.h"
+#include <log/log.h>
+
+android::binder::Status MeasurementCorrectionsCallback::setCapabilitiesCb(const int capabilities) {
+ ALOGI("Capabilities received %d", capabilities);
+ capabilities_cbq_.store(capabilities);
+ return android::binder::Status::ok();
+}
diff --git a/gnss/aidl/vts/MeasurementCorrectionsCallback.h b/gnss/aidl/vts/MeasurementCorrectionsCallback.h
new file mode 100644
index 0000000..27e5b3c
--- /dev/null
+++ b/gnss/aidl/vts/MeasurementCorrectionsCallback.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <android/hardware/gnss/measurement_corrections/BnMeasurementCorrectionsCallback.h>
+#include "GnssCallbackEventQueue.h"
+
+class MeasurementCorrectionsCallback
+ : public android::hardware::gnss::measurement_corrections::BnMeasurementCorrectionsCallback {
+ public:
+ MeasurementCorrectionsCallback() : capabilities_cbq_("capabilities"){};
+ ~MeasurementCorrectionsCallback(){};
+ android::binder::Status setCapabilitiesCb(const int capabilities) override;
+
+ android::hardware::gnss::common::GnssCallbackEventQueue<int> capabilities_cbq_;
+ int last_capabilities_;
+};
diff --git a/gnss/aidl/vts/gnss_hal_test_cases.cpp b/gnss/aidl/vts/gnss_hal_test_cases.cpp
index f5f0aa4..6e363f9 100644
--- a/gnss/aidl/vts/gnss_hal_test_cases.cpp
+++ b/gnss/aidl/vts/gnss_hal_test_cases.cpp
@@ -25,6 +25,7 @@
#include <android/hardware/gnss/IGnssMeasurementInterface.h>
#include <android/hardware/gnss/IGnssPowerIndication.h>
#include <android/hardware/gnss/IGnssPsds.h>
+#include <android/hardware/gnss/measurement_corrections/IMeasurementCorrectionsInterface.h>
#include <android/hardware/gnss/visibility_control/IGnssVisibilityControl.h>
#include <cutils/properties.h>
#include "AGnssCallbackAidl.h"
@@ -35,6 +36,8 @@
#include "GnssNavigationMessageCallback.h"
#include "GnssPowerIndicationCallback.h"
#include "GnssVisibilityControlCallback.h"
+#include "MeasurementCorrectionsCallback.h"
+#include "Utils.h"
#include "gnss_hal_test.h"
using android::sp;
@@ -62,6 +65,8 @@
using android::hardware::gnss::IGnssPsds;
using android::hardware::gnss::PsdsType;
using android::hardware::gnss::SatellitePvt;
+using android::hardware::gnss::common::Utils;
+using android::hardware::gnss::measurement_corrections::IMeasurementCorrectionsInterface;
using android::hardware::gnss::visibility_control::IGnssVisibilityControl;
using GnssConstellationTypeV2_0 = android::hardware::gnss::V2_0::GnssConstellationType;
@@ -909,7 +914,6 @@
}
/*
- * TestAGnssExtension:
* TestGnssVisibilityControlExtension:
* 1. Gets the IGnssVisibilityControl extension.
* 2. Sets GnssVisibilityControlCallback
@@ -1095,3 +1099,43 @@
iGnssAntennaInfo->close();
}
+
+/*
+ * TestGnssMeasurementCorrections:
+ * If measurement corrections capability is supported, verifies that the measurement corrections
+ * capabilities are reported and the mandatory LOS_SATS or the EXCESS_PATH_LENGTH
+ * capability flag is set.
+ */
+TEST_P(GnssHalTest, TestGnssMeasurementCorrections) {
+ if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
+ return;
+ }
+ if (!(aidl_gnss_cb_->last_capabilities_ &
+ (int)GnssCallbackAidl::CAPABILITY_MEASUREMENT_CORRECTIONS)) {
+ return;
+ }
+
+ sp<IMeasurementCorrectionsInterface> iMeasurementCorrectionsAidl;
+ auto status = aidl_gnss_hal_->getExtensionMeasurementCorrections(&iMeasurementCorrectionsAidl);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_TRUE(iMeasurementCorrectionsAidl != nullptr);
+
+ // Setup measurement corrections callback.
+ auto gnssMeasurementCorrectionsCallback = sp<MeasurementCorrectionsCallback>::make();
+ status = iMeasurementCorrectionsAidl->setCallback(gnssMeasurementCorrectionsCallback);
+ ASSERT_TRUE(status.isOk());
+
+ const int kTimeoutSec = 5;
+ EXPECT_TRUE(gnssMeasurementCorrectionsCallback->capabilities_cbq_.retrieve(
+ gnssMeasurementCorrectionsCallback->last_capabilities_, kTimeoutSec));
+ ASSERT_TRUE(gnssMeasurementCorrectionsCallback->capabilities_cbq_.calledCount() > 0);
+
+ ASSERT_TRUE((gnssMeasurementCorrectionsCallback->last_capabilities_ &
+ (MeasurementCorrectionsCallback::CAPABILITY_LOS_SATS |
+ MeasurementCorrectionsCallback::CAPABILITY_EXCESS_PATH_LENGTH)) != 0);
+
+ // Set a mock MeasurementCorrections.
+ status = iMeasurementCorrectionsAidl->setCorrections(
+ Utils::getMockMeasurementCorrections_aidl());
+ ASSERT_TRUE(status.isOk());
+}