HAL implementation for UWB HAL
Bug: 195308730
Test: Compiles
Change-Id: Idae467bc435394a840cdec7dce30d0016c790a21
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index 7620d36..72cb2bc 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -655,6 +655,14 @@
<instance>default</instance>
</interface>
</hal>
+ <hal format="aidl" optional="true">
+ <name>android.hardware.uwb</name>
+ <version>1</version>
+ <interface>
+ <name>IUwb</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
<hal format="hidl" optional="true">
<name>android.hardware.wifi.hostapd</name>
<version>1.0-3</version>
diff --git a/uwb/aidl/Android.bp b/uwb/aidl/Android.bp
new file mode 100755
index 0000000..e3b081b
--- /dev/null
+++ b/uwb/aidl/Android.bp
@@ -0,0 +1,27 @@
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+// TODO(b/195992901): Add VTS tests.
+// TODO(b/195992658): Add cuttlefish implementation.
+aidl_interface {
+ name: "android.hardware.uwb",
+ vendor_available: true,
+ srcs: ["android/hardware/uwb/*.aidl"],
+ stability: "vintf",
+ backend: {
+ java: {
+ sdk_version: "module_current",
+ },
+ ndk: {
+ vndk: {
+ enabled: true,
+ },
+ },
+ },
+}
diff --git a/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwb.aidl b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwb.aidl
new file mode 100644
index 0000000..229ef7c
--- /dev/null
+++ b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwb.aidl
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Copyright 2021 NXP.
+ *
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file 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.uwb;
+@VintfStability
+interface IUwb {
+ void close();
+ void coreInit();
+ void open(in android.hardware.uwb.IUwbClientCallback clientCallback);
+ int write(in byte[] data);
+}
diff --git a/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwbClientCallback.aidl b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwbClientCallback.aidl
new file mode 100644
index 0000000..aac8e96
--- /dev/null
+++ b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwbClientCallback.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Copyright 2021 NXP.
+ *
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file 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.uwb;
+@VintfStability
+interface IUwbClientCallback {
+ oneway void onUciMessage(in byte[] data);
+ oneway void onHalEvent(in android.hardware.uwb.UwbEvent event, in android.hardware.uwb.UwbStatus status);
+}
diff --git a/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/UwbEvent.aidl b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/UwbEvent.aidl
new file mode 100644
index 0000000..6b30d8c
--- /dev/null
+++ b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/UwbEvent.aidl
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Copyright 2021 NXP.
+ *
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file 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.uwb;
+@Backing(type="int") @VintfStability
+enum UwbEvent {
+ OPEN_CPLT = 0,
+ CLOSE_CPLT = 1,
+ POST_INIT_CPLT = 2,
+ ERROR = 3,
+}
diff --git a/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/UwbStatus.aidl b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/UwbStatus.aidl
new file mode 100644
index 0000000..88d766a
--- /dev/null
+++ b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/UwbStatus.aidl
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Copyright 2021 NXP.
+ *
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file 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.uwb;
+@Backing(type="int") @VintfStability
+enum UwbStatus {
+ OK = 0,
+ FAILED = 1,
+ ERR_TRANSPORT = 2,
+ ERR_CMD_TIMEOUT = 3,
+ REFUSED = 4,
+}
diff --git a/uwb/aidl/android/hardware/uwb/IUwb.aidl b/uwb/aidl/android/hardware/uwb/IUwb.aidl
new file mode 100755
index 0000000..5d888bc
--- /dev/null
+++ b/uwb/aidl/android/hardware/uwb/IUwb.aidl
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Copyright 2021 NXP.
+ *
+ * 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.uwb;
+
+import android.hardware.uwb.IUwbClientCallback;
+import android.hardware.uwb.UwbStatus;
+
+/**
+ * HAL Interface for UWB (Ultrawideband) subsystem.
+ * https://en.wikipedia.org/wiki/Ultra-wideband.
+ */
+@VintfStability
+interface IUwb {
+ /**
+ * Close the UWB Subsystem. Should free all resources.
+ *
+ */
+ void close();
+
+ /**
+ * Perform UWB Subsystem initialization by applying all vendor configuration.
+ *
+ */
+ void coreInit();
+
+ /**
+ * Performs the UWB HAL initialization and power on UWB Subsystem. If open completes
+ * successfully, then UWB Subsystem is ready to accept UCI message through write() API
+ *
+ * @param clientCallback Client callback instance.
+ */
+ void open(in IUwbClientCallback clientCallback);
+
+ /**
+ * Write the UCI message to the UWB Subsystem.
+ * The UCI message format is as per UCI protocol and it is
+ * defined in "FiRa Consortium - UCI Generic Specification_v1.0" specification at FiRa
+ * consortium.
+ * WIP doc link: https://groups.firaconsortium.org/wg/Technical/document/folder/127.
+ * TODO(b/196004116): Link to the published specification.
+ *
+ * This method may queue writes and return immediately, or it may block until data is written.
+ * Implementation must guarantee that writes are executed in order.
+ *
+ * @param data UCI packet to write.
+ * @return number of bytes written to the UWB Subsystem
+ */
+ int write(in byte[] data);
+}
diff --git a/uwb/aidl/android/hardware/uwb/IUwbClientCallback.aidl b/uwb/aidl/android/hardware/uwb/IUwbClientCallback.aidl
new file mode 100755
index 0000000..32c36a8
--- /dev/null
+++ b/uwb/aidl/android/hardware/uwb/IUwbClientCallback.aidl
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Copyright 2021 NXP.
+ *
+ * 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.uwb;
+
+import android.hardware.uwb.UwbEvent;
+import android.hardware.uwb.UwbStatus;
+
+@VintfStability
+oneway interface IUwbClientCallback {
+ /**
+ * The callback passed in from the UWB stack that the HAL
+ * can use to pass incomming data to the stack.
+ *
+ * WIP doc link: https://groups.firaconsortium.org/wg/Technical/document/folder/127.
+ * TODO(b/196004116): Link to the published specification.
+ *
+ * @param data UCI packet sent.
+ */
+ void onUciMessage(in byte[] data);
+
+ /**
+ * The callback passed in from the UWB stack that the HAL
+ * can use to pass events back to the stack.
+ *
+ * @param event Asynchronous event type.
+ * @param status Associated status.
+ */
+ void onHalEvent(in UwbEvent event, in UwbStatus status);
+}
diff --git a/uwb/aidl/android/hardware/uwb/UwbEvent.aidl b/uwb/aidl/android/hardware/uwb/UwbEvent.aidl
new file mode 100755
index 0000000..3457836
--- /dev/null
+++ b/uwb/aidl/android/hardware/uwb/UwbEvent.aidl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Copyright 2021 NXP.
+ *
+ * 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.uwb;
+
+/**
+ * Asynchronous events sent from the UWB subsystem.
+ */
+@VintfStability
+@Backing(type="int")
+enum UwbEvent {
+ /** Open request processing completed. */
+ OPEN_CPLT = 0,
+ /** Close request processing completed. */
+ CLOSE_CPLT = 1,
+ /** Post initialization processing completed. */
+ POST_INIT_CPLT = 2,
+ /** Fatal error encountered. */
+ ERROR = 3,
+}
diff --git a/uwb/aidl/android/hardware/uwb/UwbStatus.aidl b/uwb/aidl/android/hardware/uwb/UwbStatus.aidl
new file mode 100755
index 0000000..d568c5b
--- /dev/null
+++ b/uwb/aidl/android/hardware/uwb/UwbStatus.aidl
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Copyright 2021 NXP.
+ *
+ * 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.uwb;
+
+@VintfStability
+@Backing(type="int")
+enum UwbStatus {
+ OK = 0,
+ FAILED = 1,
+ ERR_TRANSPORT = 2,
+ ERR_CMD_TIMEOUT = 3,
+ REFUSED = 4,
+}