Update Contexthub HAL 1.2
Update Contexthub HAL 1.2 to support passing permissions information
about host apps and nanoapps to the HAL and contexthub framework.
Bug: 166846988
Test: hidl-gen && Run VTS against default HAL
Change-Id: I483cb066b3228c4a80bab8f12f8bfee2610c9e6b
diff --git a/contexthub/1.2/Android.bp b/contexthub/1.2/Android.bp
index e819482..9722a97 100644
--- a/contexthub/1.2/Android.bp
+++ b/contexthub/1.2/Android.bp
@@ -6,6 +6,7 @@
srcs: [
"types.hal",
"IContexthub.hal",
+ "IContexthubCallback.hal",
],
interfaces: [
"android.hardware.contexthub@1.0",
diff --git a/contexthub/1.2/IContexthub.hal b/contexthub/1.2/IContexthub.hal
index 819fc1d..3488b74 100644
--- a/contexthub/1.2/IContexthub.hal
+++ b/contexthub/1.2/IContexthub.hal
@@ -16,11 +16,41 @@
package android.hardware.contexthub@1.2;
+import @1.0::Result;
import @1.1::IContexthub;
import @1.1::SettingValue;
+import IContexthubCallback;
interface IContexthub extends @1.1::IContexthub {
/**
+ * Register a callback for the HAL implementation to send asynchronous
+ * messages to the service from a context hub. There can be a maximum of
+ * one callback registered with the HAL. A call to this function when a
+ * callback has already been registered must override the previous
+ * registration.
+ *
+ * @param hubId identifier for the hub
+ * @param callback an implementation of the IContextHubCallbacks
+ *
+ * @return result OK on success
+ * BAD_VALUE if parameters are not valid
+ *
+ */
+ registerCallback_1_2(uint32_t hubId, IContexthubCallback cb) generates (Result result);
+
+ /**
+ * Send a message to a hub
+ *
+ * @param hubId identifier for hub to send message to
+ * @param msg message to be sent
+ *
+ * @return result OK if successful, error code otherwise
+ * BAD_VALUE if parameters are not valid
+ * TRANSACTION_FAILED if message send failed
+ */
+ sendMessageToHub_1_2(uint32_t hubId, ContextHubMsg msg) generates (Result result);
+
+ /**
* Notification sent by the framework to indicate that the user
* has changed a setting.
*
diff --git a/contexthub/1.2/IContexthubCallback.hal b/contexthub/1.2/IContexthubCallback.hal
new file mode 100644
index 0000000..0236160
--- /dev/null
+++ b/contexthub/1.2/IContexthubCallback.hal
@@ -0,0 +1,45 @@
+/*
+ * 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.contexthub@1.2;
+
+import @1.0::IContexthubCallback;
+
+interface IContexthubCallback extends @1.0::IContexthubCallback {
+ /**
+ * 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
+ *
+ */
+ handleClientMsg_1_2(ContextHubMsg msg);
+
+ /**
+ * 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.
+ */
+ handleAppsInfo_1_2(vec<HubAppInfo> appInfo);
+};
diff --git a/contexthub/1.2/types.hal b/contexthub/1.2/types.hal
index 38f9f7a..e6c8acc 100644
--- a/contexthub/1.2/types.hal
+++ b/contexthub/1.2/types.hal
@@ -16,6 +16,8 @@
package android.hardware.contexthub@1.2;
+import @1.0::ContextHubMsg;
+import @1.0::HubAppInfo;
import @1.1::Setting;
/**
@@ -32,3 +34,36 @@
WIFI_AVAILABLE,
AIRPLANE_MODE,
};
+
+struct ContextHubMsg {
+ @1.0::ContextHubMsg msg_1_0;
+
+ /**
+ * The list of Android permissions that the sender of this message has at
+ * the time the message was sent.
+ *
+ * The HAL MUST drop messages to nanoapps if this list of permissions is not
+ * a superset of those of the receiving nanoapp(s).
+ *
+ * The framework MUST drop messages to host apps that don't have a superset
+ * of the permissions that the sending nanoapp is using.
+ */
+ vec<string> permissions;
+};
+
+struct HubAppInfo {
+ @1.0::HubAppInfo info_1_0;
+
+ /**
+ * 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 list to
+ * audio data, it would require adding android.permission.RECORD_AUDIO to
+ * this list.
+ */
+ vec<string> permissions;
+};