OSDN Git Service

Add Bluetooth HAL definition
authorMyles Watson <mylesgw@google.com>
Mon, 12 Sep 2016 17:58:42 +0000 (10:58 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Thu, 13 Oct 2016 22:32:38 +0000 (22:32 +0000)
Test: compiles
Bug: 31972505
Change-Id: I7608b0814c9ca697b21c9e115cfcd81ab1364892

Android.bp
bluetooth/1.0/Android.bp [new file with mode: 0644]
bluetooth/1.0/Android.mk [new file with mode: 0644]
bluetooth/1.0/IBluetoothHci.hal [new file with mode: 0644]
bluetooth/1.0/IBluetoothHciCallbacks.hal [new file with mode: 0644]
bluetooth/1.0/types.hal [new file with mode: 0644]

index 5d7c8b8..2350c5f 100644 (file)
@@ -1,6 +1,7 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
     "benchmarks/msgq/1.0",
+    "bluetooth/1.0",
     "nfc/1.0",
     "nfc/1.0/default",
     "radio/1.0",
diff --git a/bluetooth/1.0/Android.bp b/bluetooth/1.0/Android.bp
new file mode 100644 (file)
index 0000000..c5f898d
--- /dev/null
@@ -0,0 +1,54 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.bluetooth@1.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.bluetooth@1.0",
+    srcs: [
+        "types.hal",
+        "IBluetoothHci.hal",
+        "IBluetoothHciCallbacks.hal",
+    ],
+    out: [
+        "android/hardware/bluetooth/1.0/types.cpp",
+        "android/hardware/bluetooth/1.0/BluetoothHciAll.cpp",
+        "android/hardware/bluetooth/1.0/BluetoothHciCallbacksAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.bluetooth@1.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.bluetooth@1.0",
+    srcs: [
+        "types.hal",
+        "IBluetoothHci.hal",
+        "IBluetoothHciCallbacks.hal",
+    ],
+    out: [
+        "android/hardware/bluetooth/1.0/types.h",
+        "android/hardware/bluetooth/1.0/IBluetoothHci.h",
+        "android/hardware/bluetooth/1.0/IHwBluetoothHci.h",
+        "android/hardware/bluetooth/1.0/BnBluetoothHci.h",
+        "android/hardware/bluetooth/1.0/BpBluetoothHci.h",
+        "android/hardware/bluetooth/1.0/BsBluetoothHci.h",
+        "android/hardware/bluetooth/1.0/IBluetoothHciCallbacks.h",
+        "android/hardware/bluetooth/1.0/IHwBluetoothHciCallbacks.h",
+        "android/hardware/bluetooth/1.0/BnBluetoothHciCallbacks.h",
+        "android/hardware/bluetooth/1.0/BpBluetoothHciCallbacks.h",
+        "android/hardware/bluetooth/1.0/BsBluetoothHciCallbacks.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.bluetooth@1.0",
+    generated_sources: ["android.hardware.bluetooth@1.0_genc++"],
+    generated_headers: ["android.hardware.bluetooth@1.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.bluetooth@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+    ],
+}
diff --git a/bluetooth/1.0/Android.mk b/bluetooth/1.0/Android.mk
new file mode 100644 (file)
index 0000000..7100765
--- /dev/null
@@ -0,0 +1,144 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.bluetooth@1.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build types.hal (Status)
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/Status.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.bluetooth@1.0::types.Status
+
+$(GEN): $(LOCAL_PATH)/types.hal
+       $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IBluetoothHci.hal
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/IBluetoothHci.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBluetoothHci.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+$(GEN): $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.bluetooth@1.0::IBluetoothHci
+
+$(GEN): $(LOCAL_PATH)/IBluetoothHci.hal
+       $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IBluetoothHciCallbacks.hal
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/IBluetoothHciCallbacks.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.bluetooth@1.0::IBluetoothHciCallbacks
+
+$(GEN): $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+       $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.bluetooth@1.0-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build types.hal (Status)
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/Status.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.bluetooth@1.0::types.Status
+
+$(GEN): $(LOCAL_PATH)/types.hal
+       $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IBluetoothHci.hal
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/IBluetoothHci.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBluetoothHci.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+$(GEN): $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.bluetooth@1.0::IBluetoothHci
+
+$(GEN): $(LOCAL_PATH)/IBluetoothHci.hal
+       $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IBluetoothHciCallbacks.hal
+#
+GEN := $(intermediates)/android/hardware/bluetooth/1.0/IBluetoothHciCallbacks.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.bluetooth@1.0::IBluetoothHciCallbacks
+
+$(GEN): $(LOCAL_PATH)/IBluetoothHciCallbacks.hal
+       $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/bluetooth/1.0/IBluetoothHci.hal b/bluetooth/1.0/IBluetoothHci.hal
new file mode 100644 (file)
index 0000000..10cf914
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016 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.bluetooth@1.0;
+
+import IBluetoothHciCallbacks;
+
+/*
+ * The Host Controller Interface (HCI) is the layer defined by the Bluetooth
+ * specification between the software that runs on the host and the Bluetooth
+ * controller chip. This boundary is the natural choice for a Hardware
+ * Abstraction Layer (HAL). Dealing only in HCI packets and events simplifies
+ * the stack and abstracts away power management, initialization, and other
+ * implementation-specific details related to the hardware.
+ */
+
+interface IBluetoothHci {
+    /**
+     * Initialize the underlying HCI interface.
+     *
+     * This method should be used to initialize any hardware interfaces
+     * required to communicate with the Bluetooth hardware in the
+     * device.
+     *
+     * @param callback implements IBluetoothHciCallbacks which will
+     *    receive callbacks when incoming HCI packets are received
+     *    from the controller to be sent to the host.
+     * @return status result of the initialization
+     */
+    initialize(IBluetoothHciCallbacks callback) generates (Status status);
+
+    /**
+     * Send an HCI command (as specified in the Bluetooth Specification
+     * V4.2, Vol 2, Part 5, Section 5.4.1) to the Bluetooth controller.
+     * Commands must be executed in order.
+     *
+     * @param command is the HCI command to be sent
+     */
+    sendHciCommand(HciPacket command);
+
+    /**
+     * Send an HCI ACL data packet (as specified in the Bluetooth Specification
+     * V4.2, Vol 2, Part 5, Section 5.4.2) to the Bluetooth controller.
+     * Packets must be processed in order.
+     * @param data HCI data packet to be sent
+     */
+    sendAclData(HciPacket data);
+
+    /**
+     * Send an SCO data packet (as specified in the Bluetooth Specification
+     * V4.2, Vol 2, Part 5, Section 5.4.3) to the Bluetooth controller.
+     * Packets must be processed in order.
+     * @param data HCI data packet to be sent
+     */
+    sendScoData(HciPacket data);
+
+    /**
+     * Close the HCI interface
+     */
+    close();
+};
diff --git a/bluetooth/1.0/IBluetoothHciCallbacks.hal b/bluetooth/1.0/IBluetoothHciCallbacks.hal
new file mode 100644 (file)
index 0000000..afaab6c
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2016 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.bluetooth@1.0;
+
+/* The interface from the Bluetooth Controller to the stack. */
+interface IBluetoothHciCallbacks {
+    /**
+     * This function is invoked when an HCI event is received from the
+     * Bluetooth controller to be forwarded to the Bluetooth stack.
+     * @param event is the HCI event to be sent to the Bluetooth stack.
+     */
+    oneway hciEventReceived(HciPacket event);
+
+    /**
+     * Send an ACL data packet form the controller to the host.
+     * @param data the ACL HCI packet to be passed to the host stack
+     */
+    oneway aclDataReceived(HciPacket data);
+
+    /**
+     * Send a SCO data packet form the controller to the host.
+     * @param data the SCO HCI packet to be passed to the host stack
+     */
+    oneway scoDataReceived(HciPacket data);
+};
diff --git a/bluetooth/1.0/types.hal b/bluetooth/1.0/types.hal
new file mode 100644 (file)
index 0000000..5f5570a
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2016 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.bluetooth@1.0;
+
+enum Status : int32_t {
+  SUCCESS,
+  TRANSPORT_ERROR,
+  INITIALIZATION_ERROR,
+  UNKNOWN
+};
+
+/**
+ * HCI packets are transmitted as a vector of type uint8_t.
+ */
+typedef vec<uint8_t> HciPacket;