Creates Context Hub AIDL
Bug: 194285834
Test: TreeHugger
Change-Id: Icc1e126816e2f8a11a9ef964d6889955d7827180
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index 72cb2bc..62067bf 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -194,6 +194,13 @@
<instance>default</instance>
</interface>
</hal>
+ <hal format="aidl" optional="true">
+ <name>android.hardware.contexthub</name>
+ <interface>
+ <name>IContextHub</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
<hal format="hidl" optional="true">
<name>android.hardware.contexthub</name>
<version>1.2</version>
diff --git a/contexthub/aidl/Android.bp b/contexthub/aidl/Android.bp
new file mode 100644
index 0000000..2086508
--- /dev/null
+++ b/contexthub/aidl/Android.bp
@@ -0,0 +1,28 @@
+// Copyright 2021 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.contexthub",
+ vendor_available: true,
+ srcs: ["android/hardware/contexthub/*.aidl"],
+ stability: "vintf",
+ backend: {
+ java: {
+ sdk_version: "module_current",
+ },
+ ndk: {
+ apps_enabled: false,
+ },
+ },
+}
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/AsyncEventType.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/AsyncEventType.aidl
new file mode 100644
index 0000000..8e0ff89
--- /dev/null
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/AsyncEventType.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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.contexthub;
+@Backing(type="int") @VintfStability
+enum AsyncEventType {
+ RESTARTED = 1,
+}
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/ContextHubInfo.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/ContextHubInfo.aidl
new file mode 100644
index 0000000..e573556
--- /dev/null
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/ContextHubInfo.aidl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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.contexthub;
+@VintfStability
+parcelable ContextHubInfo {
+ String name;
+ String vendor;
+ String toolchain;
+ int id;
+ float peakMips;
+ int maxSupportedMessageLengthBytes;
+ long chrePlatformId;
+ byte chreApiMajorVersion;
+ byte chreApiMinorVersion;
+ char chrePatchVersion;
+ String[] supportedPermissions;
+}
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/ContextHubMessage.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/ContextHubMessage.aidl
new file mode 100644
index 0000000..e38c251
--- /dev/null
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/ContextHubMessage.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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.contexthub;
+@VintfStability
+parcelable ContextHubMessage {
+ long nanoappId;
+ char hostEndPoint;
+ int messageType;
+ byte[] messageBody;
+ String[] permissions;
+}
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl
new file mode 100644
index 0000000..cb31c84
--- /dev/null
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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.contexthub;
+@VintfStability
+interface IContextHub {
+ List<android.hardware.contexthub.ContextHubInfo> getContextHubs();
+ boolean loadNanoapp(in int contextHubId, in android.hardware.contexthub.NanoappBinary appBinary, in int transactionId);
+ boolean unloadNanoapp(in int contextHubId, in long appId, in int transactionId);
+ boolean disableNanoapp(in int contextHubId, in long appId, in int transactionId);
+ boolean enableNanoapp(in int contextHubId, in long appId, in int transactionId);
+ void onSettingChanged(in android.hardware.contexthub.Setting setting, in boolean enabled);
+ boolean queryNanoapps(in int contextHubId);
+ boolean registerCallback(in int contextHubId, in android.hardware.contexthub.IContextHubCallback cb);
+ boolean sendMessageToHub(in int contextHubId, in android.hardware.contexthub.ContextHubMessage message);
+}
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl
new file mode 100644
index 0000000..f81f7cf
--- /dev/null
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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.contexthub;
+@VintfStability
+interface IContextHubCallback {
+ void handleNanoappInfo(in android.hardware.contexthub.NanoappInfo[] appInfo);
+ void handleContextHubMessage(in android.hardware.contexthub.ContextHubMessage msg, in String[] msgContentPerms);
+ void handleContextHubAsyncEvent(in android.hardware.contexthub.AsyncEventType evt);
+ void handleTransactionResult(in int transactionId, in boolean success);
+}
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/NanoappBinary.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/NanoappBinary.aidl
new file mode 100644
index 0000000..d53b28f
--- /dev/null
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/NanoappBinary.aidl
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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.contexthub;
+@VintfStability
+parcelable NanoappBinary {
+ long nanoappId;
+ int nanoappVersion;
+ int flags;
+ byte targetChreApiMajorVersion;
+ byte targetChreApiMinorVersion;
+ byte[] customBinary;
+ const int FLAG_SIGNED = 1;
+ const int FLAG_ENCRYPTED = 2;
+ const int FLAG_TCM_CAPABLE = 4;
+}
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/NanoappInfo.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/NanoappInfo.aidl
new file mode 100644
index 0000000..ea7825a
--- /dev/null
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/NanoappInfo.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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.contexthub;
+@VintfStability
+parcelable NanoappInfo {
+ long nanoappId;
+ int nanoappVersion;
+ boolean enabled;
+ String[] permissions;
+}
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/Setting.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/Setting.aidl
new file mode 100644
index 0000000..41bc9ae
--- /dev/null
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/Setting.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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.contexthub;
+@Backing(type="byte") @VintfStability
+enum Setting {
+ LOCATION = 1,
+ WIFI_MAIN = 2,
+ WIFI_SCANNING = 3,
+ AIRPLANE_MODE = 4,
+ MICROPHONE = 5,
+}
diff --git a/contexthub/aidl/android/hardware/contexthub/AsyncEventType.aidl b/contexthub/aidl/android/hardware/contexthub/AsyncEventType.aidl
new file mode 100644
index 0000000..d884c9c
--- /dev/null
+++ b/contexthub/aidl/android/hardware/contexthub/AsyncEventType.aidl
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 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.contexthub;
+
+@VintfStability
+@Backing(type="int")
+enum AsyncEventType {
+ /** An event where the Context Hub has restarted (e.g. due to a crash). */
+ RESTARTED = 1,
+}
diff --git a/contexthub/aidl/android/hardware/contexthub/ContextHubInfo.aidl b/contexthub/aidl/android/hardware/contexthub/ContextHubInfo.aidl
new file mode 100644
index 0000000..c0fa702
--- /dev/null
+++ b/contexthub/aidl/android/hardware/contexthub/ContextHubInfo.aidl
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2021 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.contexthub;
+
+@VintfStability
+parcelable ContextHubInfo {
+ /** Descriptive name of the Context Hub */
+ String name;
+
+ /** The vendor e.g. "Google" */
+ String vendor;
+
+ /** Toolchain that describes the binary architecture eg: "gcc ARM" */
+ String toolchain;
+
+ /** A unique ID for this Context Hub */
+ int id;
+
+ /** Peak MIPs this platform can deliver */
+ float peakMips;
+
+ /** The maximum length in bytes of the message that can be sent to the Context Hub. */
+ int maxSupportedMessageLengthBytes;
+
+ /**
+ * Machine-readable CHRE platform ID, returned to nanoapps in the CHRE API
+ * function call chreGetPlatformId(). This field pairs with
+ * chreApiMajorVersion, chreApiMinorVersion, and chrePatchVersion to fully
+ * specify the CHRE implementation version. See also the CHRE API header
+ * file chre/version.h.
+ */
+ long chrePlatformId;
+
+ /**
+ * The version of the CHRE implementation returned to nanoApps in the CHRE
+ * API function call chreGetVersion(). The major and minor version specify
+ * the implemented version of the CHRE API, while the patch version
+ * describes the implementation version within the scope of the platform
+ * ID. See also the CHRE API header file chre/version.h.
+ */
+ byte chreApiMajorVersion;
+ byte chreApiMinorVersion;
+ char chrePatchVersion;
+
+ /**
+ * A list of Android permissions this Context Hub support for nanoapps to enforce host endpoints
+ * are granted in order to communicate with them.
+ */
+ String[] supportedPermissions;
+}
diff --git a/contexthub/aidl/android/hardware/contexthub/ContextHubMessage.aidl b/contexthub/aidl/android/hardware/contexthub/ContextHubMessage.aidl
new file mode 100644
index 0000000..867da2f
--- /dev/null
+++ b/contexthub/aidl/android/hardware/contexthub/ContextHubMessage.aidl
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2021 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.contexthub;
+
+@VintfStability
+parcelable ContextHubMessage {
+ /** The unique identifier of the nanoapp. */
+ long nanoappId;
+
+ /**
+ * The identifier of the host client that is sending/receiving this message.
+ *
+ * There are two reserved values of the host endpoint that has a specific meaning:
+ * 1) BROADCAST = 0xFFFF: see CHRE_HOST_ENDPOINT_BROADCAST in
+ * system/chre/chre_api/include/chre_api/chre/event.h for details.
+ * 2) UNSPECIFIED = 0xFFFE: see CHRE_HOST_ENDPOINT_UNSPECIFIED in
+ * system/chre/chre_api/include/chre_api/chre/event.h for details.
+ */
+ char hostEndPoint;
+
+ /** The type of this message */
+ int messageType;
+
+ /** The payload containing the message */
+ byte[] messageBody;
+
+ /**
+ * The list of Android permissions held by the sending nanoapp at the time
+ * the message was sent.
+ *
+ * The framework MUST drop messages to host apps that don't have a superset
+ * of the permissions that the sending nanoapp is using.
+ */
+ String[] permissions;
+}
diff --git a/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl b/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl
new file mode 100644
index 0000000..e820cbf
--- /dev/null
+++ b/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2021 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.contexthub;
+
+import android.hardware.contexthub.ContextHubInfo;
+import android.hardware.contexthub.ContextHubMessage;
+import android.hardware.contexthub.IContextHubCallback;
+import android.hardware.contexthub.NanoappBinary;
+import android.hardware.contexthub.Setting;
+
+@VintfStability
+interface IContextHub {
+ /**
+ * Enumerates all available Context Hubs.
+ *
+ * @return A list of ContextHubInfo describing all Context Hubs.
+ */
+ List<ContextHubInfo> getContextHubs();
+
+ /**
+ * Loads a nanoapp, and invokes the nanoapp's initialization "start()" entrypoint.
+ *
+ * The return value of this method only indicates that the request has been accepted.
+ * If true is returned, the Context Hub must handle an asynchronous result using the
+ * the handleTransactionResult() callback.
+ *
+ * Depending on the implementation, nanoapp loaded via this API may or may
+ * not persist across reboots of the hub. If they do persist, the
+ * implementation must initially place nanoapp in the disabled state upon a
+ * reboot, and not start them until a call is made to enableNanoapp(). In
+ * this case, the app must also be unloaded upon a factory reset of the
+ * device.
+ *
+ * Loading a nanoapp must not take more than 30 seconds.
+ *
+ * @param contextHubId The identifier of the Context Hub
+ * @param appBinary The nanoapp binary with header
+ * @param transactionId The transaction ID associated with this request
+ *
+ * @return The return code
+ */
+ boolean loadNanoapp(in int contextHubId, in NanoappBinary appBinary, in int transactionId);
+
+ /**
+ * Invokes the nanoapp's deinitialization "end()" entrypoint, and unloads the nanoapp.
+ *
+ * The return value of this method only indicates that the request has been accepted.
+ * If true is returned, the Context Hub must handle an asynchronous result using the
+ * the handleTransactionResult() callback.
+ *
+ * Unloading a nanoapp must not take more than 5 seconds.
+ *
+ * @param contextHubId The identifier of the Context Hub
+ * @param appId The unique ID of the nanoapp
+ * @param transactionId The transaction ID associated with this request
+ *
+ * @return The return code
+ */
+ boolean unloadNanoapp(in int contextHubId, in long appId, in int transactionId);
+
+ /**
+ * Disables a nanoapp by invoking the nanoapp's "end()" entrypoint, but does not unload the
+ * nanoapp.
+ *
+ * The return value of this method only indicates that the request has been accepted.
+ * If true is returned, the Context Hub must handle an asynchronous result using the
+ * the handleTransactionResult() callback.
+ *
+ * Disabling a nanoapp must not take more than 5 seconds.
+ *
+ * @param contextHubId The identifier of the Context Hub
+ * @param appId The unique ID of the nanoapp
+ * @param transactionId The transaction ID associated with this request
+ *
+ * @return The return code
+ */
+ boolean disableNanoapp(in int contextHubId, in long appId, in int transactionId);
+
+ /**
+ * Enables a nanoapp by invoking the nanoapp's initialization "start()" entrypoint.
+ *
+ * The return value of this method only indicates that the request has been accepted.
+ * If true is returned, the Context Hub must handle an asynchronous result using the
+ * the handleTransactionResult() callback.
+ *
+ * Enabling a nanoapp must not take more than 5 seconds.
+ *
+ * @param contextHubId The identifier of the Context Hub
+ * @param appId appIdentifier returned by the HAL
+ * @param message message to be sent
+ *
+ * @return true on success
+ */
+ boolean enableNanoapp(in int contextHubId, in long appId, in int transactionId);
+
+ /**
+ * Notification sent by the framework to indicate that the user has changed a setting.
+ *
+ * @param setting User setting that has been modified
+ * @param enabled true if the setting has been enabled, false otherwise
+ */
+ void onSettingChanged(in Setting setting, in boolean enabled);
+
+ /**
+ * Queries for a list of loaded nanoapps on a Context Hub.
+ *
+ * If this method succeeds, the result of the query must be delivered through the
+ * handleNanoappInfo() callback.
+ *
+ * @param contextHubId The identifier of the Context Hub
+ *
+ * @return true on success
+ */
+ boolean queryNanoapps(in int contextHubId);
+
+ /**
+ * Register a callback for the HAL implementation to send asynchronous messages to the service
+ * from a Context hub. There can only be one callback registered for a single Context Hub ID.
+ *
+ * A call to this function when a callback has already been registered must override the
+ * previous registration.
+ *
+ * @param contextHubId The identifier of the Context Hub
+ * @param callback an implementation of the IContextHubCallbacks
+ *
+ * @return true on success
+ *
+ */
+ boolean registerCallback(in int contextHubId, in IContextHubCallback cb);
+
+ /**
+ * Sends a message targeted to a nanoapp to the Context Hub.
+ *
+ * @param contextHubId The identifier of the Context Hub
+ * @param message The message to be sent
+ *
+ * @return true on success
+ */
+ boolean sendMessageToHub(in int contextHubId, in ContextHubMessage message);
+}
diff --git a/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl b/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl
new file mode 100644
index 0000000..e385d48
--- /dev/null
+++ b/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2021 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.contexthub;
+
+import android.hardware.contexthub.AsyncEventType;
+import android.hardware.contexthub.ContextHubMessage;
+import android.hardware.contexthub.NanoappInfo;
+
+@VintfStability
+interface IContextHubCallback {
+ /**
+ * This callback is passed by the Contexthub service to the HAL
+ * implementation to allow the HAL to send information about the
+ * currently loaded and active nanoapps on the hub.
+ *
+ * @param appInfo vector of HubAppinfo structure for each nanoApp
+ * on the hub that can be enabled, disabled and
+ * unloaded by the service. Any nanoApps that cannot
+ * be controlled by the service must not be reported.
+ * All nanoApps that can be controlled by the service
+ * must be reported.
+ */
+ void handleNanoappInfo(in NanoappInfo[] appInfo);
+
+ /**
+ * This callback is passed by the Contexthub service to the HAL
+ * implementation to allow the HAL to send asynchronous messages back
+ * to the service and registered clients of the ContextHub service.
+ *
+ * @param msg message that should be delivered to host app
+ * clients
+ * @param msgContentPerms list of Android permissions that cover the
+ * contents of the message being sent from the app.
+ * This is different from the permissions stored
+ * inside of ContextHubMsg in that these must be a
+ * subset of those permissions and are meant to
+ * assist in properly attributing the message
+ * contents when delivering to a ContextHub service
+ * client.
+ */
+ void handleContextHubMessage(in ContextHubMessage msg, in String[] msgContentPerms);
+
+ /**
+ * This callback is passed by the Contexthub service to the HAL
+ * implementation to allow the HAL to send an asynchronous event
+ * to the ContextHub service.
+ *
+ * @param evt event being sent from the contexthub
+ *
+ */
+ void handleContextHubAsyncEvent(in AsyncEventType evt);
+
+ /**
+ * This callback is passed by the Contexthub service to the HAL
+ * implementation to allow the HAL to send the response for a
+ * transaction.
+ *
+ * @param transactionId The ID of the transaction associated with this callback
+ * @param success true if the transaction succeeded, false otherwise
+ *
+ */
+ void handleTransactionResult(in int transactionId, in boolean success);
+}
diff --git a/contexthub/aidl/android/hardware/contexthub/NanoappBinary.aidl b/contexthub/aidl/android/hardware/contexthub/NanoappBinary.aidl
new file mode 100644
index 0000000..c677ca6
--- /dev/null
+++ b/contexthub/aidl/android/hardware/contexthub/NanoappBinary.aidl
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 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.contexthub;
+
+@VintfStability
+parcelable NanoappBinary {
+ /** Indicates that the nanoapp is securely signed (e.g. for production) */
+ const int FLAG_SIGNED = 1 << 0;
+ const int FLAG_ENCRYPTED = 1 << 1;
+ /** Indicates that the nanoapp can run on a Context Hub's TCM memory region */
+ const int FLAG_TCM_CAPABLE = 1 << 2;
+
+ /**
+ * The unique identifier of the nanoapp for the entire system. See chreNanoappInfo in
+ * system/chre/chre_api/include/chre_api/chre/event.h for the convention for choosing
+ * this ID.
+ */
+ long nanoappId;
+
+ /** The version of the nanoapp. */
+ int nanoappVersion;
+
+ /** The nanoapp flags, comprised of the bitmasks defined in FLAG_* constants above. */
+ int flags;
+
+ /**
+ * The version of the CHRE API that this nanoapp was compiled against. See
+ * the CHRE API header file chre/version.h for more information. The hub
+ * implementation must use this to confirm compatibility before loading
+ * this nanoapp.
+ */
+ byte targetChreApiMajorVersion;
+ byte targetChreApiMinorVersion;
+
+ /**
+ * Implementation-specific binary nanoapp data. This does not include the
+ * common nanoapp header that contains the app ID, etc., as this data is
+ * explicitly passed through the other fields in this struct.
+ */
+ byte[] customBinary;
+}
diff --git a/contexthub/aidl/android/hardware/contexthub/NanoappInfo.aidl b/contexthub/aidl/android/hardware/contexthub/NanoappInfo.aidl
new file mode 100644
index 0000000..9991dc8
--- /dev/null
+++ b/contexthub/aidl/android/hardware/contexthub/NanoappInfo.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2021 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.contexthub;
+
+@VintfStability
+parcelable NanoappInfo {
+ /** The unique identifier of the nanoapp. */
+ long nanoappId;
+
+ /** The version of the nanoapp */
+ int nanoappVersion;
+
+ /** True if this nanoapp is in a running state, false otherwise */
+ boolean enabled;
+
+ /**
+ * The list of Android permissions used by this nanoapp. This list MUST
+ * correspond to the permissions required for an equivalent Android app to
+ * sample similar signals through the Android framework.
+ *
+ * For example, if a nanoapp used location-based signals, the permissions
+ * list MUST contains android.permission.ACCESS_FINE_LOCATION and
+ * android.permission.ACCESS_BACKGROUND_LOCATION. If it were to also use
+ * audio data, it would require adding android.permission.RECORD_AUDIO to
+ * this list.
+ */
+ String[] permissions;
+}
diff --git a/contexthub/aidl/android/hardware/contexthub/Setting.aidl b/contexthub/aidl/android/hardware/contexthub/Setting.aidl
new file mode 100644
index 0000000..f2e55db
--- /dev/null
+++ b/contexthub/aidl/android/hardware/contexthub/Setting.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2021 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.contexthub;
+
+/**
+ * Used to indicate the type of user setting that has changed.
+ */
+@VintfStability
+@Backing(type="byte")
+enum Setting {
+ LOCATION = 1,
+ /**
+ * The main WiFi toggle in the Android settings for WiFi connectivity.
+ */
+ WIFI_MAIN,
+ /**
+ * The "Wi-Fi scanning" setting for location scans.
+ */
+ WIFI_SCANNING,
+ AIRPLANE_MODE,
+ /**
+ * Indicates if the microphone access is available for CHRE. Microphone
+ * access is disabled if the user has turned off the microphone as a
+ * privacy setting, in which case audio data cannot be used and propagated
+ * by CHRE.
+ */
+ MICROPHONE,
+}
diff --git a/contexthub/aidl/default/Android.bp b/contexthub/aidl/default/Android.bp
new file mode 100644
index 0000000..269057a
--- /dev/null
+++ b/contexthub/aidl/default/Android.bp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2021 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 {
+ // 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"],
+}
+
+cc_library_static {
+ name: "libcontexthubexampleimpl",
+ vendor: true,
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "android.hardware.contexthub-V1-ndk",
+ ],
+ export_include_dirs: ["include"],
+ srcs: [
+ "ContextHub.cpp",
+ ],
+ visibility: [
+ ":__subpackages__",
+ "//hardware/interfaces/tests/extension/contexthub:__subpackages__",
+ ],
+}
+
+cc_binary {
+ name: "android.hardware.contexthub-service.example",
+ relative_install_path: "hw",
+ init_rc: ["contexthub-default.rc"],
+ vintf_fragments: ["contexthub-default.xml"],
+ vendor: true,
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "android.hardware.contexthub-V1-ndk",
+ ],
+ static_libs: [
+ "libcontexthubexampleimpl",
+ ],
+ srcs: ["main.cpp"],
+}
diff --git a/contexthub/aidl/default/ContextHub.cpp b/contexthub/aidl/default/ContextHub.cpp
new file mode 100644
index 0000000..1b56608
--- /dev/null
+++ b/contexthub/aidl/default/ContextHub.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2021 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 "contexthub-impl/ContextHub.h"
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace contexthub {
+
+// TODO(b/194285834): Implement AIDL HAL
+
+::ndk::ScopedAStatus ContextHub::getContextHubs(
+ std::vector<ContextHubInfo>* /* out_contextHubInfos */) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus ContextHub::loadNanoapp(int32_t /* in_contextHubId */,
+ const NanoappBinary& /* in_appBinary */,
+ int32_t /* in_transactionId */,
+ bool* /* _aidl_return */) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus ContextHub::unloadNanoapp(int32_t /* in_contextHubId */,
+ int64_t /* in_appId */,
+ int32_t /* in_transactionId */,
+ bool* /* _aidl_return */) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus ContextHub::disableNanoapp(int32_t /* in_contextHubId */,
+ int64_t /* in_appId */,
+ int32_t /* in_transactionId */,
+ bool* /* _aidl_return */) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus ContextHub::enableNanoapp(int32_t /* in_contextHubId */,
+ int64_t /* in_appId */,
+ int32_t /* in_transactionId */,
+ bool* /* _aidl_return */) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus ContextHub::onSettingChanged(Setting /* in_setting */, bool /*in_enabled */) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus ContextHub::queryNanoapps(int32_t /* in_contextHubId */,
+ bool* /* _aidl_return */) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus ContextHub::registerCallback(
+ int32_t /* in_contextHubId */, const std::shared_ptr<IContextHubCallback>& /* in_cb */,
+ bool* /* _aidl_return */) {
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus ContextHub::sendMessageToHub(int32_t /* in_contextHubId */,
+ const ContextHubMessage& /* in_message */,
+ bool* /* _aidl_return */) {
+ return ndk::ScopedAStatus::ok();
+}
+
+} // namespace contexthub
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/contexthub/aidl/default/contexthub-default.rc b/contexthub/aidl/default/contexthub-default.rc
new file mode 100644
index 0000000..a6a6d2a
--- /dev/null
+++ b/contexthub/aidl/default/contexthub-default.rc
@@ -0,0 +1,4 @@
+service vendor.contexthub-default /vendor/bin/hw/android.hardware.contexthub-service.example
+ class hal
+ user context_hub
+ group context_hub
diff --git a/contexthub/aidl/default/contexthub-default.xml b/contexthub/aidl/default/contexthub-default.xml
new file mode 100644
index 0000000..e383c50
--- /dev/null
+++ b/contexthub/aidl/default/contexthub-default.xml
@@ -0,0 +1,7 @@
+<manifest version="1.0" type="device">
+ <hal format="aidl">
+ <name>android.hardware.contexthub</name>
+ <version>1</version>
+ <fqname>IContextHub/default</fqname>
+ </hal>
+</manifest>
diff --git a/contexthub/aidl/default/include/contexthub-impl/ContextHub.h b/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
new file mode 100644
index 0000000..980cee5
--- /dev/null
+++ b/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2021 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 <aidl/android/hardware/contexthub/BnContextHub.h>
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace contexthub {
+
+class ContextHub : public BnContextHub {
+ ::ndk::ScopedAStatus getContextHubs(std::vector<ContextHubInfo>* out_contextHubInfos) override;
+ ::ndk::ScopedAStatus loadNanoapp(int32_t in_contextHubId, const NanoappBinary& in_appBinary,
+ int32_t in_transactionId, bool* _aidl_return) override;
+ ::ndk::ScopedAStatus unloadNanoapp(int32_t in_contextHubId, int64_t in_appId,
+ int32_t in_transactionId, bool* _aidl_return) override;
+ ::ndk::ScopedAStatus disableNanoapp(int32_t in_contextHubId, int64_t in_appId,
+ int32_t in_transactionId, bool* _aidl_return) override;
+ ::ndk::ScopedAStatus enableNanoapp(int32_t in_contextHubId, int64_t in_appId,
+ int32_t in_transactionId, bool* _aidl_return) override;
+ ::ndk::ScopedAStatus onSettingChanged(Setting in_setting, bool in_enabled) override;
+ ::ndk::ScopedAStatus queryNanoapps(int32_t in_contextHubId, bool* _aidl_return) override;
+ ::ndk::ScopedAStatus registerCallback(int32_t in_contextHubId,
+ const std::shared_ptr<IContextHubCallback>& in_cb,
+ bool* _aidl_return) override;
+ ::ndk::ScopedAStatus sendMessageToHub(int32_t in_contextHubId,
+ const ContextHubMessage& in_message,
+ bool* _aidl_return) override;
+};
+
+} // namespace contexthub
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/contexthub/aidl/default/main.cpp b/contexthub/aidl/default/main.cpp
new file mode 100644
index 0000000..dc9035f
--- /dev/null
+++ b/contexthub/aidl/default/main.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 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 "contexthub-impl/ContextHub.h"
+
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+
+using aidl::android::hardware::contexthub::ContextHub;
+
+int main() {
+ ABinderProcess_setThreadPoolMaxThreadCount(0);
+
+ // Make a default contexthub service
+ auto vib = ndk::SharedRefBase::make<ContextHub>();
+ const std::string vibName = std::string() + ContextHub::descriptor + "/default";
+ binder_status_t status = AServiceManager_addService(vib->asBinder().get(), vibName.c_str());
+ CHECK(status == STATUS_OK);
+
+ ABinderProcess_joinThreadPool();
+ return EXIT_FAILURE; // should not reach
+}