Merge "uwb(hal): Refactor HAL to support multiple UWB chips"
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
index 229ef7c..9553ffc 100644
--- 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
@@ -36,8 +36,6 @@
 package android.hardware.uwb;
 @VintfStability
 interface IUwb {
-  void close();
-  void coreInit();
-  void open(in android.hardware.uwb.IUwbClientCallback clientCallback);
-  int write(in byte[] data);
+  List<String> getChips();
+  android.hardware.uwb.IUwbChip getChip(String name);
 }
diff --git a/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwbChip.aidl b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwbChip.aidl
new file mode 100644
index 0000000..7074753
--- /dev/null
+++ b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwbChip.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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 IUwbChip {
+  String getName();
+  void open(in android.hardware.uwb.IUwbClientCallback clientCallback);
+  void close();
+  void coreInit();
+  int getSupportedVendorUciVersion();
+  int sendUciMessage(in byte[] data);
+}
diff --git a/uwb/aidl/android/hardware/uwb/IUwb.aidl b/uwb/aidl/android/hardware/uwb/IUwb.aidl
index 5d888bc..fda726c 100755
--- a/uwb/aidl/android/hardware/uwb/IUwb.aidl
+++ b/uwb/aidl/android/hardware/uwb/IUwb.aidl
@@ -18,8 +18,7 @@
 
 package android.hardware.uwb;
 
-import android.hardware.uwb.IUwbClientCallback;
-import android.hardware.uwb.UwbStatus;
+import android.hardware.uwb.IUwbChip;
 
 /**
  * HAL Interface for UWB (Ultrawideband) subsystem.
@@ -28,38 +27,14 @@
 @VintfStability
 interface IUwb {
     /**
-     * Close the UWB Subsystem. Should free all resources.
-     *
+     * Returns list of IUwbChip instance names representing each UWB chip on the device.
      */
-    void close();
+    List<String> getChips();
 
     /**
-     * Perform UWB Subsystem initialization by applying all vendor configuration.
+     * Returns IUwbChip instance corresponding to the name.
      *
+     * @param Unique identifier of the chip.
      */
-    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);
+    IUwbChip getChip(String name);
 }
diff --git a/uwb/aidl/android/hardware/uwb/IUwbChip.aidl b/uwb/aidl/android/hardware/uwb/IUwbChip.aidl
new file mode 100755
index 0000000..5f1a59e
--- /dev/null
+++ b/uwb/aidl/android/hardware/uwb/IUwbChip.aidl
@@ -0,0 +1,72 @@
+/*
+ * 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;
+
+/**
+ * Controls a UWB chip on the device. On some devices, there could be multiple UWB chips.
+ */
+@VintfStability
+interface IUwbChip {
+    /**
+     * Get unique idenitifer for the chip.
+     */
+    String getName();
+
+    /**
+     * 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);
+
+    /**
+     * Close the UWB Subsystem. Should free all resources.
+     */
+    void close();
+
+    /**
+     * Perform UWB Subsystem initialization by applying all vendor configuration.
+     */
+    void coreInit();
+
+     /**
+      * Supported version of vendor UCI specification.
+      */
+    int getSupportedVendorUciVersion();
+
+    /**
+     * 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 sendUciMessage(in byte[] data);
+}
diff --git a/uwb/aidl/android/hardware/uwb/IUwbClientCallback.aidl b/uwb/aidl/android/hardware/uwb/IUwbClientCallback.aidl
index 32c36a8..75853cd 100755
--- a/uwb/aidl/android/hardware/uwb/IUwbClientCallback.aidl
+++ b/uwb/aidl/android/hardware/uwb/IUwbClientCallback.aidl
@@ -25,7 +25,8 @@
 oneway interface IUwbClientCallback {
     /**
      * The callback passed in from the UWB stack that the HAL
-     * can use to pass incomming data to the stack.
+     * can use to pass incoming data to the stack.  These include UCI
+     * responses and notifications from the UWB subsystem.
      *
      * WIP doc link: https://groups.firaconsortium.org/wg/Technical/document/folder/127.
      * TODO(b/196004116): Link to the published specification.