Add GnssVisibilityControl AIDL HAL (hardware/interfaces)
Bug: 208728105
Test: atest VtsHalGnssTargetTest
Change-Id: Ie42793a4d0ddf9c9b62c6dff2dc7a34797702e7f
diff --git a/gnss/aidl/vts/Android.bp b/gnss/aidl/vts/Android.bp
index 041d579..d532fad 100644
--- a/gnss/aidl/vts/Android.bp
+++ b/gnss/aidl/vts/Android.bp
@@ -37,6 +37,7 @@
"GnssMeasurementCallbackAidl.cpp",
"GnssNavigationMessageCallback.cpp",
"GnssPowerIndicationCallback.cpp",
+ "GnssVisibilityControlCallback.cpp",
"VtsHalGnssTargetTest.cpp",
],
shared_libs: [
@@ -49,6 +50,7 @@
static_libs: [
"android.hardware.gnss-V2-cpp",
"android.hardware.gnss@common-vts-lib",
+ "android.hardware.gnss.visibility_control-V1-cpp",
],
test_suites: [
"general-tests",
diff --git a/gnss/aidl/vts/GnssVisibilityControlCallback.cpp b/gnss/aidl/vts/GnssVisibilityControlCallback.cpp
new file mode 100644
index 0000000..aa27af1
--- /dev/null
+++ b/gnss/aidl/vts/GnssVisibilityControlCallback.cpp
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+#include "GnssVisibilityControlCallback.h"
+#include <log/log.h>
+
+android::binder::Status GnssVisibilityControlCallback::nfwNotifyCb(const NfwNotification&) {
+ // To implement
+ return android::binder::Status::ok();
+}
+
+android::binder::Status GnssVisibilityControlCallback::isInEmergencySession(bool*) {
+ // To implement
+ return android::binder::Status::ok();
+}
diff --git a/gnss/aidl/vts/GnssVisibilityControlCallback.h b/gnss/aidl/vts/GnssVisibilityControlCallback.h
new file mode 100644
index 0000000..fbacde7
--- /dev/null
+++ b/gnss/aidl/vts/GnssVisibilityControlCallback.h
@@ -0,0 +1,30 @@
+/*
+ * 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/visibility_control/BnGnssVisibilityControlCallback.h>
+
+class GnssVisibilityControlCallback
+ : public android::hardware::gnss::visibility_control::BnGnssVisibilityControlCallback {
+ public:
+ GnssVisibilityControlCallback(){};
+ ~GnssVisibilityControlCallback(){};
+ android::binder::Status nfwNotifyCb(
+ const android::hardware::gnss::visibility_control::IGnssVisibilityControlCallback::
+ NfwNotification& notification) override;
+ android::binder::Status isInEmergencySession(bool* _aidl_return) override;
+};
diff --git a/gnss/aidl/vts/gnss_hal_test_cases.cpp b/gnss/aidl/vts/gnss_hal_test_cases.cpp
index 36be631..90b643c 100644
--- a/gnss/aidl/vts/gnss_hal_test_cases.cpp
+++ b/gnss/aidl/vts/gnss_hal_test_cases.cpp
@@ -24,6 +24,7 @@
#include <android/hardware/gnss/IGnssMeasurementInterface.h>
#include <android/hardware/gnss/IGnssPowerIndication.h>
#include <android/hardware/gnss/IGnssPsds.h>
+#include <android/hardware/gnss/visibility_control/IGnssVisibilityControl.h>
#include <cutils/properties.h>
#include "AGnssCallbackAidl.h"
#include "GnssBatchingCallback.h"
@@ -31,6 +32,7 @@
#include "GnssMeasurementCallbackAidl.h"
#include "GnssNavigationMessageCallback.h"
#include "GnssPowerIndicationCallback.h"
+#include "GnssVisibilityControlCallback.h"
#include "gnss_hal_test.h"
using android::sp;
@@ -55,6 +57,7 @@
using android::hardware::gnss::IGnssPsds;
using android::hardware::gnss::PsdsType;
using android::hardware::gnss::SatellitePvt;
+using android::hardware::gnss::visibility_control::IGnssVisibilityControl;
using GnssConstellationTypeAidl = android::hardware::gnss::GnssConstellationType;
@@ -876,3 +879,27 @@
data.time.frequencyUncertaintyNsPerSec <= 2.0e5); // 200 ppm
}
}
+
+/*
+ * TestAGnssExtension:
+ * TestGnssVisibilityControlExtension:
+ * 1. Gets the IGnssVisibilityControl extension.
+ * 2. Sets GnssVisibilityControlCallback
+ * 3. Sets proxy apps
+ */
+TEST_P(GnssHalTest, TestGnssVisibilityControlExtension) {
+ if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
+ return;
+ }
+ sp<IGnssVisibilityControl> iGnssVisibilityControl;
+ auto status = aidl_gnss_hal_->getExtensionGnssVisibilityControl(&iGnssVisibilityControl);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_TRUE(iGnssVisibilityControl != nullptr);
+ auto gnssVisibilityControlCallback = sp<GnssVisibilityControlCallback>::make();
+ status = iGnssVisibilityControl->setCallback(gnssVisibilityControlCallback);
+ ASSERT_TRUE(status.isOk());
+
+ std::vector<String16> proxyApps{String16("com.example.ims"), String16("com.example.mdt")};
+ status = iGnssVisibilityControl->enableNfwLocationAccess(proxyApps);
+ ASSERT_TRUE(status.isOk());
+}