summaryrefslogtreecommitdiffstats
path: root/gnss
diff options
context:
space:
mode:
authorAnil Admal <aadmal@google.com>2018-11-14 09:35:14 -0800
committerAnil Admal <aadmal@google.com>2018-12-21 15:28:35 -0800
commit3a405c590564eb3efaae127434a8b5313f0dab72 (patch)
treedf649a3732326c3ff8f76b374dac5f6eea004ab7 /gnss
parent93838fd7b23d96930485c8263319b5fe1604c117 (diff)
downloadandroid_hardware_interfaces-3a405c590564eb3efaae127434a8b5313f0dab72.tar.gz
android_hardware_interfaces-3a405c590564eb3efaae127434a8b5313f0dab72.tar.bz2
android_hardware_interfaces-3a405c590564eb3efaae127434a8b5313f0dab72.zip
Extend IAGnss.hal to address requestRouteToHost deprecation
The framework networking component method requestRouteToHost() in class ConnectivityManager used to support the IAGnss.hal interface is deprecated. This requires changes to the IAGnss.hal interface to pass network handle to the GNSS HAL implementation in order to setup SUPL connections. Bug: 25876485 Test: atest VtsHalGnssV2_0TargetTest on cuttlefish Change-Id: If0ecd480879da37508f710620975a198e674f3df
Diffstat (limited to 'gnss')
-rw-r--r--gnss/2.0/Android.bp2
-rw-r--r--gnss/2.0/IAGnss.hal83
-rw-r--r--gnss/2.0/IAGnssCallback.hal53
-rw-r--r--gnss/2.0/IGnss.hal13
-rw-r--r--gnss/2.0/default/AGnss.cpp60
-rw-r--r--gnss/2.0/default/AGnss.h55
-rw-r--r--gnss/2.0/default/Android.bp1
-rw-r--r--gnss/2.0/default/Gnss.cpp7
-rw-r--r--gnss/2.0/default/Gnss.h3
-rw-r--r--gnss/2.0/vts/functional/gnss_hal_test_cases.cpp49
10 files changed, 320 insertions, 6 deletions
diff --git a/gnss/2.0/Android.bp b/gnss/2.0/Android.bp
index 6972e4065..200671ec4 100644
--- a/gnss/2.0/Android.bp
+++ b/gnss/2.0/Android.bp
@@ -8,6 +8,8 @@ hidl_interface {
},
srcs: [
"types.hal",
+ "IAGnss.hal",
+ "IAGnssCallback.hal",
"IAGnssRil.hal",
"IGnss.hal",
"IGnssCallback.hal",
diff --git a/gnss/2.0/IAGnss.hal b/gnss/2.0/IAGnss.hal
new file mode 100644
index 000000000..d4e7d2fec
--- /dev/null
+++ b/gnss/2.0/IAGnss.hal
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+package android.hardware.gnss@2.0;
+
+import IAGnssCallback;
+
+/**
+ * Extended interface for Assisted GNSS support.
+ */
+interface IAGnss {
+ enum ApnIpType : uint8_t {
+ INVALID = 0,
+ IPV4 = 1,
+ IPV6 = 2,
+ IPV4V6 = 3
+ };
+
+ /**
+ * Opens the AGNSS interface and provides the callback routines to the
+ * implementation of this interface.
+ *
+ * @param callback Handle to the AGNSS status callback interface.
+ */
+ setCallback(IAGnssCallback callback);
+
+ /**
+ * Notifies that the AGNSS data connection has been closed.
+ *
+ * @return success True if the operation is successful.
+ */
+ dataConnClosed() generates (bool success);
+
+ /**
+ * Notifies that a data connection is not available for AGNSS.
+ *
+ * @return success True if the operation is successful.
+ */
+ dataConnFailed() generates (bool success);
+
+ /**
+ * Sets the hostname and port for the AGNSS server.
+ *
+ * @param type Specifies if SUPL or C2K.
+ * @param hostname Hostname of the AGNSS server.
+ * @param port Port number associated with the server.
+ *
+ * @return success True if the operation is successful.
+ */
+ setServer(AGnssType type, string hostname, int32_t port)
+ generates (bool success);
+
+ /**
+ * Notifies GNSS that a data connection is available and sets the network handle,
+ * name of the APN, and its IP type to be used for SUPL connections.
+ *
+ * The HAL implementation must use the network handle to set the network for the
+ * SUPL connection sockets using the android_setsocknetwork function. This will ensure
+ * that there is a network path to the SUPL server. The network handle can also be used
+ * to get the IP address of SUPL FQDN using the android_getaddrinfofornetwork() function.
+ *
+ * @param networkHandle Handle representing the network for use with the NDK API.
+ * @param apn Access Point Name (follows regular APN naming convention).
+ * @param apnIpType Specifies IP type of APN.
+ *
+ * @return success True if the operation is successful.
+ */
+ dataConnOpen(net_handle_t networkHandle, string apn, ApnIpType apnIpType)
+ generates (bool success);
+}; \ No newline at end of file
diff --git a/gnss/2.0/IAGnssCallback.hal b/gnss/2.0/IAGnssCallback.hal
new file mode 100644
index 000000000..896be1802
--- /dev/null
+++ b/gnss/2.0/IAGnssCallback.hal
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+package android.hardware.gnss@2.0;
+
+/** Callback structure for the AGNSS interface. */
+interface IAGnssCallback {
+ /** AGNSS service type **/
+ enum AGnssType : uint8_t {
+ SUPL = 1,
+ C2K = 2,
+ SUPL_EIMS = 3,
+ SUPL_IMS = 4,
+ };
+
+ enum AGnssStatusValue : uint8_t {
+ /** GNSS requests data connection for AGNSS. */
+ REQUEST_AGNSS_DATA_CONN = 1,
+ /** GNSS releases the AGNSS data connection. */
+ RELEASE_AGNSS_DATA_CONN = 2,
+ /** AGNSS data connection initiated */
+ AGNSS_DATA_CONNECTED = 3,
+ /** AGNSS data connection completed */
+ AGNSS_DATA_CONN_DONE = 4,
+ /** AGNSS data connection failed */
+ AGNSS_DATA_CONN_FAILED = 5
+ };
+
+ /**
+ * Callback with AGNSS status information.
+ *
+ * The GNSS HAL implementation must use this method to request the framework to setup
+ * network connection for the specified AGNSS service and to update the connection
+ * status so that the framework can release the resources.
+ *
+ * @param type Type of AGNSS service.
+ * @parama status Status of the data connection.
+ */
+ agnssStatusCb(AGnssType type, AGnssStatusValue status);
+}; \ No newline at end of file
diff --git a/gnss/2.0/IGnss.hal b/gnss/2.0/IGnss.hal
index 0799a6079..fb8b04027 100644
--- a/gnss/2.0/IGnss.hal
+++ b/gnss/2.0/IGnss.hal
@@ -21,6 +21,7 @@ import @1.1::IGnss;
import IGnssCallback;
import IGnssMeasurement;
+import IAGnss;
import IAGnssRil;
/** Represents the standard GNSS (Global Navigation Satellite System) interface. */
@@ -36,6 +37,16 @@ interface IGnss extends @1.1::IGnss {
setCallback_2_0(IGnssCallback callback) generates (bool success);
/**
+ * This method returns the IAGnss Interface.
+ *
+ * The getExtensionAGnss() must return nullptr as the @1.0::IAGnss interface is
+ * deprecated.
+ *
+ * @return aGnssIface Handle to the IAGnss interface.
+ */
+ getExtensionAGnss_2_0() generates (IAGnss aGnssIface);
+
+ /**
* This method returns the IAGnssRil Interface.
*
* @return aGnssRilIface Handle to the IAGnssRil interface.
@@ -59,4 +70,4 @@ interface IGnss extends @1.1::IGnss {
*/
getExtensionMeasurementCorrections()
generates (IMeasurementCorrections measurementCorrectionsIface);
-}; \ No newline at end of file
+};
diff --git a/gnss/2.0/default/AGnss.cpp b/gnss/2.0/default/AGnss.cpp
new file mode 100644
index 000000000..c8e8bf17a
--- /dev/null
+++ b/gnss/2.0/default/AGnss.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 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 "AGnss"
+
+#include "AGnss.h"
+#include <log/log.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V2_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::gnss::V2_0::IAGnss follow.
+Return<void> AGnss::setCallback(const sp<V2_0::IAGnssCallback>&) {
+ // TODO implement
+ return Void();
+}
+
+Return<bool> AGnss::dataConnClosed() {
+ // TODO implement
+ return bool{};
+}
+
+Return<bool> AGnss::dataConnFailed() {
+ // TODO implement
+ return bool{};
+}
+
+Return<bool> AGnss::setServer(V2_0::IAGnssCallback::AGnssType type, const hidl_string& hostname,
+ int32_t port) {
+ ALOGD("setServer: type: %s, hostname: %s, port: %d", toString(type).c_str(), hostname.c_str(),
+ port);
+ return true;
+}
+
+Return<bool> AGnss::dataConnOpen(uint64_t, const hidl_string&, V2_0::IAGnss::ApnIpType) {
+ // TODO implement
+ return bool{};
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/2.0/default/AGnss.h b/gnss/2.0/default/AGnss.h
new file mode 100644
index 000000000..244a2c6fe
--- /dev/null
+++ b/gnss/2.0/default/AGnss.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#ifndef ANDROID_HARDWARE_GNSS_V2_0_AGNSS_H
+#define ANDROID_HARDWARE_GNSS_V2_0_AGNSS_H
+
+#include <android/hardware/gnss/2.0/IAGnss.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V2_0 {
+namespace implementation {
+
+using ::android::sp;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+struct AGnss : public IAGnss {
+ // Methods from ::android::hardware::gnss::V2_0::IAGnss follow.
+ Return<void> setCallback(const sp<V2_0::IAGnssCallback>& callback) override;
+ Return<bool> dataConnClosed() override;
+ Return<bool> dataConnFailed() override;
+ Return<bool> setServer(V2_0::IAGnssCallback::AGnssType type, const hidl_string& hostname,
+ int32_t port) override;
+ Return<bool> dataConnOpen(uint64_t networkHandle, const hidl_string& apn,
+ V2_0::IAGnss::ApnIpType apnIpType) override;
+};
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_GNSS_V2_0_AGNSS_H \ No newline at end of file
diff --git a/gnss/2.0/default/Android.bp b/gnss/2.0/default/Android.bp
index dcdebe8ff..9119ee480 100644
--- a/gnss/2.0/default/Android.bp
+++ b/gnss/2.0/default/Android.bp
@@ -21,6 +21,7 @@ cc_binary {
vendor: true,
vintf_fragments: ["android.hardware.gnss@2.0-service.xml"],
srcs: [
+ "AGnss.cpp",
"AGnssRil.cpp",
"Gnss.cpp",
"GnssMeasurement.cpp",
diff --git a/gnss/2.0/default/Gnss.cpp b/gnss/2.0/default/Gnss.cpp
index 886a3a8d7..bde904f5d 100644
--- a/gnss/2.0/default/Gnss.cpp
+++ b/gnss/2.0/default/Gnss.cpp
@@ -18,9 +18,12 @@
#include "Gnss.h"
#include <log/log.h>
+#include "AGnss.h"
#include "AGnssRil.h"
#include "GnssMeasurement.h"
+using ::android::hardware::Status;
+
namespace android {
namespace hardware {
namespace gnss {
@@ -178,6 +181,10 @@ Return<bool> Gnss::injectBestLocation(const V1_0::GnssLocation&) {
}
// Methods from V2_0::IGnss follow.
+Return<sp<V2_0::IAGnss>> Gnss::getExtensionAGnss_2_0() {
+ return new AGnss{};
+}
+
Return<sp<V2_0::IAGnssRil>> Gnss::getExtensionAGnssRil_2_0() {
return new AGnssRil{};
}
diff --git a/gnss/2.0/default/Gnss.h b/gnss/2.0/default/Gnss.h
index cd69a937c..47792cfa8 100644
--- a/gnss/2.0/default/Gnss.h
+++ b/gnss/2.0/default/Gnss.h
@@ -72,6 +72,7 @@ struct Gnss : public IGnss {
Return<bool> injectBestLocation(const V1_0::GnssLocation& location) override;
// Methods from V2_0::IGnss follow.
+ Return<sp<V2_0::IAGnss>> getExtensionAGnss_2_0() override;
Return<sp<V2_0::IAGnssRil>> getExtensionAGnssRil_2_0() override;
Return<sp<V2_0::IGnssMeasurement>> getExtensionGnssMeasurement_2_0() override;
Return<bool> setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) override;
@@ -89,4 +90,4 @@ struct Gnss : public IGnss {
} // namespace hardware
} // namespace android
-#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSS_H \ No newline at end of file
+#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
diff --git a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
index c1f1393db..ef232c949 100644
--- a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
+++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
@@ -25,6 +25,10 @@ using IAGnssRil_2_0 = android::hardware::gnss::V2_0::IAGnssRil;
using IGnssMeasurement_2_0 = android::hardware::gnss::V2_0::IGnssMeasurement;
using IGnssMeasurement_1_1 = android::hardware::gnss::V1_1::IGnssMeasurement;
using IGnssMeasurement_1_0 = android::hardware::gnss::V1_0::IGnssMeasurement;
+using IAGnssRil_2_0 = android::hardware::gnss::V2_0::IAGnssRil;
+using IAGnss_2_0 = android::hardware::gnss::V2_0::IAGnss;
+using IAGnss_1_0 = android::hardware::gnss::V1_0::IAGnss;
+using IAGnssCallback_2_0 = android::hardware::gnss::V2_0::IAGnssCallback;
/*
* SetupTeardownCreateCleanup:
@@ -60,7 +64,9 @@ TEST_F(GnssHalTest, TestGnssMeasurementCallback) {
* Gets the AGnssRilExtension and verifies that it returns an actual extension.
*
* The GNSS HAL 2.0 implementation must support @2.0::IAGnssRil interface due to the deprecation
- * of framework network API methods needed to support the @1::IAGnssRil interface.
+ * of framework network API methods needed to support the @1.0::IAGnssRil interface.
+ *
+ * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launced with Q or later.
*/
TEST_F(GnssHalTest, TestAGnssRilExtension) {
auto agnssRil = gnss_hal_->getExtensionAGnssRil_2_0();
@@ -71,8 +77,8 @@ TEST_F(GnssHalTest, TestAGnssRilExtension) {
/*
* TestAGnssRilUpdateNetworkState_2_0:
- * 1. Update GNSS HAL that a network has connected.
- * 2. Update GNSS HAL that network has disconnected.
+ * 1. Updates GNSS HAL that a network has connected.
+ * 2. Updates GNSS HAL that network has disconnected.
*/
TEST_F(GnssHalTest, TestAGnssRilUpdateNetworkState_2_0) {
auto agnssRil = gnss_hal_->getExtensionAGnssRil_2_0();
@@ -80,7 +86,7 @@ TEST_F(GnssHalTest, TestAGnssRilUpdateNetworkState_2_0) {
sp<IAGnssRil_2_0> iAGnssRil = agnssRil;
ASSERT_NE(iAGnssRil, nullptr);
- // Update GNSS HAL that a network is connected.
+ // Update GNSS HAL that a network has connected.
IAGnssRil_2_0::NetworkAttributes networkAttributes = {
.networkHandle = static_cast<uint64_t>(7700664333),
.isConnected = true,
@@ -133,3 +139,38 @@ TEST_F(GnssHalTest, TestGnssMeasurementCodeType) {
iGnssMeasurement->close();
}
+
+/*
+ * TestAGnssExtension:
+ * Gets the AGnssExtension and verifies that it supports @2.0::IAGnss interface by invoking
+ * a method.
+ *
+ * The GNSS HAL 2.0 implementation must support @2.0::IAGnss interface due to the deprecation
+ * of framework network API methods needed to support the @1.0::IAGnss interface.
+ *
+ * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launced with Q or later.
+ */
+TEST_F(GnssHalTest, TestAGnssExtension) {
+ // Verify IAGnss 2.0 is supported.
+ auto agnss = gnss_hal_->getExtensionAGnss_2_0();
+ ASSERT_TRUE(agnss.isOk());
+ sp<IAGnss_2_0> iAGnss = agnss;
+ ASSERT_NE(iAGnss, nullptr);
+
+ // Set SUPL server host/port
+ auto result = iAGnss->setServer(IAGnssCallback_2_0::AGnssType::SUPL, "supl.google.com", 7275);
+ ASSERT_TRUE(result.isOk());
+ EXPECT_TRUE(result);
+}
+
+/*
+ * TestAGnssExtension_1_0_Deprecation:
+ * Gets the @1.0::IAGnss extension and verifies that it is a nullptr.
+ *
+ * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launced with Q or later.
+ */
+TEST_F(GnssHalTest, TestAGnssExtension_1_0_Deprecation) {
+ // Verify IAGnss 1.0 is not supported.
+ auto agnss_1_0 = gnss_hal_->getExtensionAGnss();
+ ASSERT_TRUE(!agnss_1_0.isOk() || ((sp<IAGnss_1_0>)agnss_1_0) == nullptr);
+}