Merge "Replace network type with network capabilities in IAgnssRil.hal"
diff --git a/gnss/2.0/Android.bp b/gnss/2.0/Android.bp
index 6a06bf4..6972e40 100644
--- a/gnss/2.0/Android.bp
+++ b/gnss/2.0/Android.bp
@@ -7,6 +7,8 @@
enabled: true,
},
srcs: [
+ "types.hal",
+ "IAGnssRil.hal",
"IGnss.hal",
"IGnssCallback.hal",
"IGnssMeasurement.hal",
@@ -18,6 +20,8 @@
"android.hardware.gnss@1.1",
"android.hidl.base@1.0",
],
+ types: [
+ ],
gen_java: true,
gen_java_constants: true,
}
diff --git a/gnss/2.0/IAGnssRil.hal b/gnss/2.0/IAGnssRil.hal
new file mode 100644
index 0000000..00a2e79
--- /dev/null
+++ b/gnss/2.0/IAGnssRil.hal
@@ -0,0 +1,71 @@
+/*
+ * 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 @1.0::IAGnssRil;
+
+/**
+ * Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface
+ * Layer interface allows the GNSS chipset to request radio interface layer
+ * information from Android platform. Examples of such information are reference
+ * location, unique subscriber ID, phone number string and network availability changes.
+ */
+interface IAGnssRil extends @1.0::IAGnssRil {
+ /** Flags to indicate capabilities of the network */
+ enum NetworkCapability : uint16_t {
+ /** Network is not metered. */
+ NOT_METERED = 1 << 0,
+ /** Network is not roaming. */
+ NOT_ROAMING = 1 << 1
+ };
+
+ /** Represents network connection status and capabilities. */
+ struct NetworkAttributes {
+ /** Network handle of the network for use with the NDK API. */
+ net_handle_t networkHandle;
+
+ /**
+ * True indicates that network connectivity exists and it is possible to
+ * establish connections and pass data. If false, only the networkHandle field
+ * is populated to indicate that this network has just disconnected.
+ */
+ bool isConnected;
+
+ /** A set of flags indicating the capabilities of this network. */
+ bitfield<NetworkCapability> capabilities;
+
+ /**
+ * Telephony preferred Access Point Name to use for carrier data connection when
+ * connected to a cellular network. Empty string, otherwise.
+ */
+ string apn;
+ };
+
+ /**
+ * Notifies GNSS of network status changes.
+ *
+ * The framework calls this method to update the GNSS HAL implementation of network
+ * state changes. The methods updateNetworkState() and updateNetworkAvailability
+ * in @1.0::IAGnssRil are deprecated and are not called by the framework.
+ *
+ * @param attributes Updated network attributes.
+ *
+ * @return success True if all parameters were valid and the operation was
+ * successful.
+ */
+ updateNetworkState_2_0(NetworkAttributes attributes) generates (bool success);
+};
diff --git a/gnss/2.0/IGnss.hal b/gnss/2.0/IGnss.hal
index 55621e5..0799a60 100644
--- a/gnss/2.0/IGnss.hal
+++ b/gnss/2.0/IGnss.hal
@@ -21,6 +21,7 @@
import IGnssCallback;
import IGnssMeasurement;
+import IAGnssRil;
/** Represents the standard GNSS (Global Navigation Satellite System) interface. */
interface IGnss extends @1.1::IGnss {
@@ -35,6 +36,13 @@
setCallback_2_0(IGnssCallback callback) generates (bool success);
/**
+ * This method returns the IAGnssRil Interface.
+ *
+ * @return aGnssRilIface Handle to the IAGnssRil interface.
+ */
+ getExtensionAGnssRil_2_0() generates (IAGnssRil aGnssRilIface);
+
+ /**
* This method returns the IGnssMeasurement interface.
*
* Exactly one of getExtensionGnssMeasurement_1_1() and getExtensionGnssMeasurement_2_0() must
diff --git a/gnss/2.0/default/AGnssRil.cpp b/gnss/2.0/default/AGnssRil.cpp
new file mode 100644
index 0000000..eae2169
--- /dev/null
+++ b/gnss/2.0/default/AGnssRil.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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 "AGnssRil"
+
+#include "AGnssRil.h"
+#include <log/log.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V2_0 {
+namespace implementation {
+
+// Methods from V1_0::IAGnssRil follow.
+Return<void> AGnssRil::setCallback(const sp<V1_0::IAGnssRilCallback>&) {
+ // TODO implement
+ return Void();
+}
+
+Return<void> AGnssRil::setRefLocation(const V1_0::IAGnssRil::AGnssRefLocation&) {
+ // TODO implement
+ return Void();
+}
+
+Return<bool> AGnssRil::setSetId(V1_0::IAGnssRil::SetIDType, const hidl_string&) {
+ // TODO implement
+ return bool{};
+}
+
+Return<bool> AGnssRil::updateNetworkState(bool, V1_0::IAGnssRil::NetworkType, bool) {
+ // TODO implement
+ return bool{};
+}
+
+Return<bool> AGnssRil::updateNetworkAvailability(bool, const hidl_string&) {
+ // TODO implement
+ return bool{};
+}
+
+// Methods from ::android::hardware::gnss::V2_0::IAGnssRil follow.
+Return<bool> AGnssRil::updateNetworkState_2_0(
+ const V2_0::IAGnssRil::NetworkAttributes& attributes) {
+ ALOGD("updateNetworkState_2_0 networkAttributes: %s", toString(attributes).c_str());
+ return true;
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/2.0/default/AGnssRil.h b/gnss/2.0/default/AGnssRil.h
new file mode 100644
index 0000000..0f822f8
--- /dev/null
+++ b/gnss/2.0/default/AGnssRil.h
@@ -0,0 +1,58 @@
+/*
+ * 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_AGNSSRIL_H
+#define ANDROID_HARDWARE_GNSS_V2_0_AGNSSRIL_H
+
+#include <android/hardware/gnss/2.0/IAGnssRil.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 AGnssRil : public IAGnssRil {
+ // Methods from ::android::hardware::gnss::V1_0::IAGnssRil follow.
+ Return<void> setCallback(const sp<V1_0::IAGnssRilCallback>& callback) override;
+ Return<void> setRefLocation(const V1_0::IAGnssRil::AGnssRefLocation& agnssReflocation) override;
+ Return<bool> setSetId(V1_0::IAGnssRil::SetIDType type, const hidl_string& setid) override;
+ Return<bool> updateNetworkState(bool connected, V1_0::IAGnssRil::NetworkType type,
+ bool roaming) override;
+ Return<bool> updateNetworkAvailability(bool available, const hidl_string& apn) override;
+
+ // Methods from ::android::hardware::gnss::V2_0::IAGnssRil follow.
+ Return<bool> updateNetworkState_2_0(
+ const V2_0::IAGnssRil::NetworkAttributes& attributes) override;
+};
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_GNSS_V2_0_AGNSSRIL_H
\ No newline at end of file
diff --git a/gnss/2.0/default/Android.bp b/gnss/2.0/default/Android.bp
index bec8260..cdaa33e 100644
--- a/gnss/2.0/default/Android.bp
+++ b/gnss/2.0/default/Android.bp
@@ -20,6 +20,7 @@
relative_install_path: "hw",
vendor: true,
srcs: [
+ "AGnssRil.cpp",
"Gnss.cpp",
"GnssMeasurement.cpp",
"service.cpp"
diff --git a/gnss/2.0/default/Gnss.cpp b/gnss/2.0/default/Gnss.cpp
index e21fb17..7f1ef9b 100644
--- a/gnss/2.0/default/Gnss.cpp
+++ b/gnss/2.0/default/Gnss.cpp
@@ -18,6 +18,7 @@
#include "Gnss.h"
#include <log/log.h>
+#include "AGnssRil.h"
namespace android {
namespace hardware {
@@ -176,6 +177,10 @@
}
// Methods from V2_0::IGnss follow.
+Return<sp<V2_0::IAGnssRil>> Gnss::getExtensionAGnssRil_2_0() {
+ return new AGnssRil{};
+}
+
Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() {
// TODO implement
return sp<V2_0::IGnssMeasurement>{};
diff --git a/gnss/2.0/default/Gnss.h b/gnss/2.0/default/Gnss.h
index 7f14513..cd69a93 100644
--- a/gnss/2.0/default/Gnss.h
+++ b/gnss/2.0/default/Gnss.h
@@ -72,6 +72,7 @@
Return<bool> injectBestLocation(const V1_0::GnssLocation& location) override;
// Methods from V2_0::IGnss follow.
+ 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;
Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
diff --git a/gnss/2.0/types.hal b/gnss/2.0/types.hal
new file mode 100644
index 0000000..97c178f
--- /dev/null
+++ b/gnss/2.0/types.hal
@@ -0,0 +1,20 @@
+/*
+ * 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;
+
+/** Network handle type. */
+typedef uint64_t net_handle_t;
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 12a15e8..478a4b2 100644
--- a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
+++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
@@ -23,6 +23,7 @@
using IGnssMeasurement_2_0 = android::hardware::gnss::V2_0::IGnssMeasurement;
using IGnssMeasurement_1_1 = android::hardware::gnss::V1_1::IGnssMeasurement;
+using IAGnssRil_2_0 = android::hardware::gnss::V2_0::IAGnssRil;
/*
* SetupTeardownCreateCleanup:
@@ -47,3 +48,45 @@
ASSERT_TRUE((iGnssMeas_1_1 != nullptr) != (iGnssMeas_2_0 != nullptr));
}
}
+
+/*
+ * TestAGnssRilExtension:
+ * 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.
+ */
+TEST_F(GnssHalTest, TestAGnssRilExtension) {
+ auto agnssRil = gnss_hal_->getExtensionAGnssRil_2_0();
+ ASSERT_TRUE(agnssRil.isOk());
+ sp<IAGnssRil_2_0> iAGnssRil = agnssRil;
+ ASSERT_NE(iAGnssRil, nullptr);
+}
+
+/*
+ * TestAGnssRilUpdateNetworkState_2_0:
+ * 1. Update GNSS HAL that a network has connected.
+ * 2. Update GNSS HAL that network has disconnected.
+ */
+TEST_F(GnssHalTest, TestAGnssRilUpdateNetworkState_2_0) {
+ auto agnssRil = gnss_hal_->getExtensionAGnssRil_2_0();
+ ASSERT_TRUE(agnssRil.isOk());
+ sp<IAGnssRil_2_0> iAGnssRil = agnssRil;
+ ASSERT_NE(iAGnssRil, nullptr);
+
+ // Update GNSS HAL that a network is connected.
+ IAGnssRil_2_0::NetworkAttributes networkAttributes = {
+ .networkHandle = static_cast<uint64_t>(7700664333),
+ .isConnected = true,
+ .capabilities = static_cast<uint16_t>(IAGnssRil_2_0::NetworkCapability::NOT_ROAMING),
+ .apn = "dummy-apn"};
+ auto result = iAGnssRil->updateNetworkState_2_0(networkAttributes);
+ ASSERT_TRUE(result.isOk());
+ EXPECT_TRUE(result);
+
+ // Update GNSS HAL that network has disconnected.
+ networkAttributes.isConnected = false;
+ result = iAGnssRil->updateNetworkState_2_0(networkAttributes);
+ ASSERT_TRUE(result.isOk());
+ EXPECT_TRUE(result);
+}