From 274ea0a7c46101e716fadcc2c7579b98538ce247 Mon Sep 17 00:00:00 2001 From: Yu-Han Yang Date: Wed, 9 Sep 2020 17:25:02 -0700 Subject: [PATCH] Add GNSS AIDL interfaces (hardware/interfaces) Bug: 159467682 Test: atest VtsHalGnssTargetTest Change-Id: I75c5599f2e0698f833e2d36ac53d460f4f0c3bb4 --- .../compatibility_matrix.current.xml | 7 ++ gnss/aidl/Android.bp | 32 ++++++++ gnss/aidl/OWNERS | 4 + .../current/android/hardware/gnss/IGnss.aidl | 22 ++++++ .../android/hardware/gnss/IGnssPsds.aidl | 23 ++++++ .../hardware/gnss/IGnssPsdsCallback.aidl | 22 ++++++ .../android/hardware/gnss/PsdsType.aidl | 24 ++++++ gnss/aidl/android/hardware/gnss/IGnss.aidl | 33 ++++++++ .../aidl/android/hardware/gnss/IGnssPsds.aidl | 49 ++++++++++++ .../hardware/gnss/IGnssPsdsCallback.aidl | 37 +++++++++ gnss/aidl/android/hardware/gnss/PsdsType.aidl | 42 ++++++++++ gnss/aidl/default/Android.bp | 38 +++++++++ gnss/aidl/default/Gnss.cpp | 31 ++++++++ gnss/aidl/default/Gnss.h | 28 +++++++ gnss/aidl/default/GnssPsds.cpp | 43 +++++++++++ gnss/aidl/default/GnssPsds.h | 38 +++++++++ gnss/aidl/default/gnss-default.rc | 4 + gnss/aidl/default/gnss-default.xml | 9 +++ gnss/aidl/default/service.cpp | 35 +++++++++ gnss/aidl/vts/Android.bp | 31 ++++++++ gnss/aidl/vts/VtsHalGnssTargetTest.cpp | 77 +++++++++++++++++++ 21 files changed, 629 insertions(+) create mode 100644 gnss/aidl/Android.bp create mode 100644 gnss/aidl/OWNERS create mode 100644 gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl create mode 100644 gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssPsds.aidl create mode 100644 gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssPsdsCallback.aidl create mode 100644 gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/PsdsType.aidl create mode 100644 gnss/aidl/android/hardware/gnss/IGnss.aidl create mode 100644 gnss/aidl/android/hardware/gnss/IGnssPsds.aidl create mode 100644 gnss/aidl/android/hardware/gnss/IGnssPsdsCallback.aidl create mode 100644 gnss/aidl/android/hardware/gnss/PsdsType.aidl create mode 100644 gnss/aidl/default/Android.bp create mode 100644 gnss/aidl/default/Gnss.cpp create mode 100644 gnss/aidl/default/Gnss.h create mode 100644 gnss/aidl/default/GnssPsds.cpp create mode 100644 gnss/aidl/default/GnssPsds.h create mode 100644 gnss/aidl/default/gnss-default.rc create mode 100644 gnss/aidl/default/gnss-default.xml create mode 100644 gnss/aidl/default/service.cpp create mode 100644 gnss/aidl/vts/Android.bp create mode 100644 gnss/aidl/vts/VtsHalGnssTargetTest.cpp diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml index bb26bd3543..9400543e7f 100644 --- a/compatibility_matrices/compatibility_matrix.current.xml +++ b/compatibility_matrices/compatibility_matrix.current.xml @@ -220,6 +220,13 @@ default + + android.hardware.gnss + + IGnss + default + + android.hardware.graphics.allocator diff --git a/gnss/aidl/Android.bp b/gnss/aidl/Android.bp new file mode 100644 index 0000000000..c503190802 --- /dev/null +++ b/gnss/aidl/Android.bp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 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. + */ + +aidl_interface { + name: "android.hardware.gnss", + vendor_available: true, + srcs: ["android/hardware/gnss/*.aidl"], + stability: "vintf", + backend: { + java: { + platform_apis: true, + }, + ndk: { + vndk: { + enabled: true, + }, + }, + }, +} diff --git a/gnss/aidl/OWNERS b/gnss/aidl/OWNERS new file mode 100644 index 0000000000..b7b4a2e902 --- /dev/null +++ b/gnss/aidl/OWNERS @@ -0,0 +1,4 @@ +gomo@google.com +smalkos@google.com +wyattriley@google.com +yuhany@google.com diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl new file mode 100644 index 0000000000..33377ca906 --- /dev/null +++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL interface (or parcelable). Do not try to +// edit this file. It looks like you are doing that because you have modified +// an AIDL interface in a backward-incompatible way, e.g., deleting a function +// from an interface or a field from a parcelable and it broke the build. That +// breakage is intended. +// +// You must not make a backward incompatible changes to the AIDL files built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.gnss; +@VintfStability +interface IGnss { + android.hardware.gnss.IGnssPsds getExtensionPsds(); +} diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssPsds.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssPsds.aidl new file mode 100644 index 0000000000..352a694f0b --- /dev/null +++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssPsds.aidl @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL interface (or parcelable). Do not try to +// edit this file. It looks like you are doing that because you have modified +// an AIDL interface in a backward-incompatible way, e.g., deleting a function +// from an interface or a field from a parcelable and it broke the build. That +// breakage is intended. +// +// You must not make a backward incompatible changes to the AIDL files built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.gnss; +@VintfStability +interface IGnssPsds { + boolean injectPsdsData(in android.hardware.gnss.PsdsType psdsType, in byte[] psdsData); + boolean setCallback(in android.hardware.gnss.IGnssPsdsCallback callback); +} diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssPsdsCallback.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssPsdsCallback.aidl new file mode 100644 index 0000000000..8413d2cc77 --- /dev/null +++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssPsdsCallback.aidl @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL interface (or parcelable). Do not try to +// edit this file. It looks like you are doing that because you have modified +// an AIDL interface in a backward-incompatible way, e.g., deleting a function +// from an interface or a field from a parcelable and it broke the build. That +// breakage is intended. +// +// You must not make a backward incompatible changes to the AIDL files built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.gnss; +@VintfStability +interface IGnssPsdsCallback { + void downloadRequestCb(in android.hardware.gnss.PsdsType psdsType); +} diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/PsdsType.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/PsdsType.aidl new file mode 100644 index 0000000000..9d1984e292 --- /dev/null +++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/PsdsType.aidl @@ -0,0 +1,24 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL interface (or parcelable). Do not try to +// edit this file. It looks like you are doing that because you have modified +// an AIDL interface in a backward-incompatible way, e.g., deleting a function +// from an interface or a field from a parcelable and it broke the build. That +// breakage is intended. +// +// You must not make a backward incompatible changes to the AIDL files built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.gnss; +@Backing(type="int") @VintfStability +enum PsdsType { + LONG_TERM = 1, + NORMAL = 2, + REALTIME = 3, +} diff --git a/gnss/aidl/android/hardware/gnss/IGnss.aidl b/gnss/aidl/android/hardware/gnss/IGnss.aidl new file mode 100644 index 0000000000..1da254c7ef --- /dev/null +++ b/gnss/aidl/android/hardware/gnss/IGnss.aidl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 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; + +import android.hardware.gnss.IGnssPsds; + +/** + * Represents the standard GNSS (Global Navigation Satellite System) interface. + */ +@VintfStability +interface IGnss { + + /** + * This method returns the IGnssPsds interface. + * + * @return Handle to the IGnssPsds interface. + */ + IGnssPsds getExtensionPsds(); +} \ No newline at end of file diff --git a/gnss/aidl/android/hardware/gnss/IGnssPsds.aidl b/gnss/aidl/android/hardware/gnss/IGnssPsds.aidl new file mode 100644 index 0000000000..6f53d6faac --- /dev/null +++ b/gnss/aidl/android/hardware/gnss/IGnssPsds.aidl @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2020 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; + +import android.hardware.gnss.IGnssPsdsCallback; +import android.hardware.gnss.PsdsType; + +/** + * This interface is used by the GNSS HAL to request the framework to download Predicted Satellite + * Data Service data. + */ +@VintfStability +interface IGnssPsds { + + /** + * Inject the downloaded PSDS data into the GNSS receiver. + * + * @param psdsType Type of PSDS data. + * @param psdsData GNSS PSDS data. Framework must not parse the data since the data format is + * opaque to framework. + * + * @return True if the operation is successful. + */ + boolean injectPsdsData(in PsdsType psdsType, in byte[] psdsData); + + /** + * Opens the PSDS interface and provides the callback routines to the implementation of this + * interface. + * + * @param callback Handle to the IGnssPsdsCallback interface. + * + * @return True if the operation is successful. + */ + boolean setCallback(in IGnssPsdsCallback callback); +} \ No newline at end of file diff --git a/gnss/aidl/android/hardware/gnss/IGnssPsdsCallback.aidl b/gnss/aidl/android/hardware/gnss/IGnssPsdsCallback.aidl new file mode 100644 index 0000000000..72b693b4a3 --- /dev/null +++ b/gnss/aidl/android/hardware/gnss/IGnssPsdsCallback.aidl @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 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; + +import android.hardware.gnss.PsdsType; + +/** + * This interface is used by the GNSS HAL to request download data from Predicted Satellite Data + * Service (PSDS). + */ +@VintfStability +interface IGnssPsdsCallback { + + /** + * Callback to request the client to download PSDS data from one of the URLs defined in the + * framework specified by psdsType. The URLs must be specified via properties on the vendor + * partitions. E.g., LONGTERM_PSDS_SERVER_1, NORMAL_PSDS_SERVER, or REALTIME_PSDS_SERVER. The + * client must download PSDS data and inject it by calling injectPsdsData(). + * + * @param psdsType Type of PSDS data. + */ + void downloadRequestCb(in PsdsType psdsType); +} \ No newline at end of file diff --git a/gnss/aidl/android/hardware/gnss/PsdsType.aidl b/gnss/aidl/android/hardware/gnss/PsdsType.aidl new file mode 100644 index 0000000000..d4fec77ade --- /dev/null +++ b/gnss/aidl/android/hardware/gnss/PsdsType.aidl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 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; + +/** The type of PSDS data. */ +@VintfStability +@Backing(type="int") +enum PsdsType { + + /** + * Long-Term type PSDS data, which lasts for many hours to several days and often provides + * satellite orbit and clock accuracy of 2 - 20 meters. + */ + LONG_TERM = 1, + + /** + * Normal type PSDS data, which is similar to broadcast ephemeris in longevity - lasting for + * hours and providings satellite orbit and clock accuracy of 1 - 2 meters. + */ + NORMAL = 2, + + /** + * Real-Time type PSDS data, which lasts for minutes and provides brief satellite status + * information such as temporary malfunction, but does not include satellite orbit or clock + * information. + */ + REALTIME = 3, +} diff --git a/gnss/aidl/default/Android.bp b/gnss/aidl/default/Android.bp new file mode 100644 index 0000000000..8c4ee405aa --- /dev/null +++ b/gnss/aidl/default/Android.bp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 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. + */ + +cc_binary { + name: "android.hardware.gnss-service.example", + relative_install_path: "hw", + init_rc: ["gnss-default.rc"], + vintf_fragments: ["gnss-default.xml"], + vendor: true, + cflags: [ + "-Wall", + "-Wextra", + ], + shared_libs: [ + "libbase", + "libbinder_ndk", + "liblog", + "android.hardware.gnss-ndk_platform", + ], + srcs: [ + "Gnss.cpp", + "GnssPsds.cpp", + "service.cpp", + ], +} diff --git a/gnss/aidl/default/Gnss.cpp b/gnss/aidl/default/Gnss.cpp new file mode 100644 index 0000000000..2a359244ef --- /dev/null +++ b/gnss/aidl/default/Gnss.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 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 "GnssAidl" + +#include "Gnss.h" +#include +#include "GnssPsds.h" + +namespace aidl::android::hardware::gnss { + +ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr* iGnssPsds) { + ALOGD("Gnss::getExtensionPsds"); + *iGnssPsds = SharedRefBase::make(); + return ndk::ScopedAStatus::ok(); +} + +} // namespace aidl::android::hardware::gnss diff --git a/gnss/aidl/default/Gnss.h b/gnss/aidl/default/Gnss.h new file mode 100644 index 0000000000..9864e9d98c --- /dev/null +++ b/gnss/aidl/default/Gnss.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 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 +#include + +namespace aidl::android::hardware::gnss { + +class Gnss : public BnGnss { + ndk::ScopedAStatus getExtensionPsds(std::shared_ptr* iGnssPsds) override; +}; + +} // namespace aidl::android::hardware::gnss diff --git a/gnss/aidl/default/GnssPsds.cpp b/gnss/aidl/default/GnssPsds.cpp new file mode 100644 index 0000000000..c354217ebe --- /dev/null +++ b/gnss/aidl/default/GnssPsds.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2020 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 "GnssPsdsAidl" + +#include "GnssPsds.h" + +#include + +namespace aidl::android::hardware::gnss { + +std::shared_ptr GnssPsds::sCallback = nullptr; + +ndk::ScopedAStatus GnssPsds::setCallback(const std::shared_ptr& callback, + bool* success) { + ALOGD("setCallback"); + std::unique_lock lock(mMutex); + sCallback = callback; + *success = true; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus GnssPsds::injectPsdsData(PsdsType psdsType, const std::vector& psdsData, + bool* success) { + ALOGD("injectPsdsData. psdsType: %d, psdsData: %d bytes", static_cast(psdsType), + static_cast(psdsData.size())); + *success = (psdsData.size() > 0); + return ndk::ScopedAStatus::ok(); +} +} // namespace aidl::android::hardware::gnss diff --git a/gnss/aidl/default/GnssPsds.h b/gnss/aidl/default/GnssPsds.h new file mode 100644 index 0000000000..fc65bc15db --- /dev/null +++ b/gnss/aidl/default/GnssPsds.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 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 + +namespace aidl::android::hardware::gnss { + +struct GnssPsds : public BnGnssPsds { + public: + ndk::ScopedAStatus setCallback(const std::shared_ptr& callback, + bool* success) override; + ndk::ScopedAStatus injectPsdsData(PsdsType psdsType, const std::vector& psdsData, + bool* success) override; + + private: + // Guarded by mMutex + static std::shared_ptr sCallback; + + // Synchronization lock for sCallback + mutable std::mutex mMutex; +}; + +} // namespace aidl::android::hardware::gnss diff --git a/gnss/aidl/default/gnss-default.rc b/gnss/aidl/default/gnss-default.rc new file mode 100644 index 0000000000..fe179c34f0 --- /dev/null +++ b/gnss/aidl/default/gnss-default.rc @@ -0,0 +1,4 @@ +service vendor.gnss-default /vendor/bin/hw/android.hardware.gnss-service.example + class hal + user nobody + group nobody diff --git a/gnss/aidl/default/gnss-default.xml b/gnss/aidl/default/gnss-default.xml new file mode 100644 index 0000000000..2b06cd28de --- /dev/null +++ b/gnss/aidl/default/gnss-default.xml @@ -0,0 +1,9 @@ + + + android.hardware.gnss + + IGnss + default + + + diff --git a/gnss/aidl/default/service.cpp b/gnss/aidl/default/service.cpp new file mode 100644 index 0000000000..c79a2718c5 --- /dev/null +++ b/gnss/aidl/default/service.cpp @@ -0,0 +1,35 @@ +/* + * Copyright 2020, 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 "Gnss.h" + +#include +#include +#include + +using aidl::android::hardware::gnss::Gnss; + +int main() { + ABinderProcess_setThreadPoolMaxThreadCount(0); + std::shared_ptr vib = ndk::SharedRefBase::make(); + + const std::string instance = std::string() + Gnss::descriptor + "/default"; + binder_status_t status = AServiceManager_addService(vib->asBinder().get(), instance.c_str()); + CHECK(status == STATUS_OK); + + ABinderProcess_joinThreadPool(); + return EXIT_FAILURE; // should not reach +} diff --git a/gnss/aidl/vts/Android.bp b/gnss/aidl/vts/Android.bp new file mode 100644 index 0000000000..e57b421768 --- /dev/null +++ b/gnss/aidl/vts/Android.bp @@ -0,0 +1,31 @@ +// Copyright (C) 2020 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. + +cc_test { + name: "VtsHalGnssTargetTest", + defaults: [ + "VtsHalTargetTestDefaults", + "use_libaidlvintf_gtest_helper_static", + ], + srcs: ["VtsHalGnssTargetTest.cpp"], + shared_libs: [ + "libbinder", + ], + static_libs: [ + "android.hardware.gnss-cpp", + ], + test_suites: [ + "vts", + ], +} diff --git a/gnss/aidl/vts/VtsHalGnssTargetTest.cpp b/gnss/aidl/vts/VtsHalGnssTargetTest.cpp new file mode 100644 index 0000000000..e7ffc05156 --- /dev/null +++ b/gnss/aidl/vts/VtsHalGnssTargetTest.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2020 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 +#include + +#include +#include +#include +#include + +using android::ProcessState; +using android::sp; +using android::String16; +using android::binder::Status; +using android::hardware::gnss::IGnss; +using android::hardware::gnss::IGnssPsds; +using android::hardware::gnss::PsdsType; + +class GnssAidlHalTest : public testing::TestWithParam { + public: + virtual void SetUp() override { + gnss_hal_ = android::waitForDeclaredService(String16(GetParam().c_str())); + ASSERT_NE(gnss_hal_, nullptr); + } + + sp gnss_hal_; +}; + +/* + * SetupTeardownCreateCleanup: + * Requests the gnss HAL then calls cleanup + * + * Empty test fixture to verify basic Setup & Teardown + */ +TEST_P(GnssAidlHalTest, SetupTeardownCreateCleanup) {} + +/* + * TestPsdsExtension: + * 1. Gets the PsdsExtension and verifies that it returns a non-null extension. + * 2. Injects empty PSDS data and verifies that it returns false. + */ +TEST_P(GnssAidlHalTest, TestPsdsExtension) { + sp iGnssPsds; + auto status = gnss_hal_->getExtensionPsds(&iGnssPsds); + ASSERT_TRUE(status.isOk()); + ASSERT_TRUE(iGnssPsds != nullptr); + + bool success; + status = iGnssPsds->injectPsdsData(PsdsType::LONG_TERM, std::vector(), &success); + ASSERT_TRUE(status.isOk()); + ASSERT_FALSE(success); +} + +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GnssAidlHalTest); +INSTANTIATE_TEST_SUITE_P(, GnssAidlHalTest, + testing::ValuesIn(android::getAidlHalInstanceNames(IGnss::descriptor)), + android::PrintInstanceNameToString); + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ProcessState::self()->setThreadPoolMaxThreadCount(1); + ProcessState::self()->startThreadPool(); + return RUN_ALL_TESTS(); +} \ No newline at end of file