Merge changes from topic "contexthub_hal_update" into sc-dev am: a3a64b1ee0
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/13543522
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I1104514ea26b219160796a3ed9cf948ba493c1d4
diff --git a/contexthub/1.2/IContexthub.hal b/contexthub/1.2/IContexthub.hal
index 3488b74..4bb9361 100644
--- a/contexthub/1.2/IContexthub.hal
+++ b/contexthub/1.2/IContexthub.hal
@@ -16,6 +16,7 @@
package android.hardware.contexthub@1.2;
+import @1.0::ContextHub;
import @1.0::Result;
import @1.1::IContexthub;
import @1.1::SettingValue;
@@ -23,6 +24,17 @@
interface IContexthub extends @1.1::IContexthub {
/**
+ * Enumerate all available context hubs on the system.
+ *
+ * @return hubs list of hubs on this system.
+ * @return supportedPermissions list of Android permissions all hubs
+ * support for nanoapps to enforce host
+ * endpoints are granted in order to
+ * communicate with them.
+ */
+ getHubs_1_2() generates (vec<ContextHub> hubs, vec<string> supportedPermissions);
+
+ /**
* 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
diff --git a/contexthub/1.2/IContexthubCallback.hal b/contexthub/1.2/IContexthubCallback.hal
index 0236160..1a40512 100644
--- a/contexthub/1.2/IContexthubCallback.hal
+++ b/contexthub/1.2/IContexthubCallback.hal
@@ -24,10 +24,18 @@
* 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 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.
*/
- handleClientMsg_1_2(ContextHubMsg msg);
+ handleClientMsg_1_2(ContextHubMsg msg, vec<string> msgContentPerms);
/**
* This callback is passed by the Contexthub service to the HAL
diff --git a/contexthub/1.2/default/Contexthub.cpp b/contexthub/1.2/default/Contexthub.cpp
index db0c5bc..601eccd 100644
--- a/contexthub/1.2/default/Contexthub.cpp
+++ b/contexthub/1.2/default/Contexthub.cpp
@@ -23,10 +23,36 @@
namespace V1_2 {
namespace implementation {
+using ::android::hardware::hidl_string;
using ::android::hardware::contexthub::V1_0::Result;
using ::android::hardware::contexthub::V1_X::implementation::IContextHubCallbackWrapperV1_0;
using ::android::hardware::contexthub::V1_X::implementation::IContextHubCallbackWrapperV1_2;
+Return<void> Contexthub::getHubs_1_2(getHubs_1_2_cb _hidl_cb) {
+ ::android::hardware::contexthub::V1_0::ContextHub hub = {};
+ hub.name = "Mock Context Hub";
+ hub.vendor = "AOSP";
+ hub.toolchain = "n/a";
+ hub.platformVersion = 1;
+ hub.toolchainVersion = 1;
+ hub.hubId = kMockHubId;
+ hub.peakMips = 1;
+ hub.peakPowerDrawMw = 1;
+ hub.maxSupportedMsgLen = 4096;
+ hub.chrePlatformId = UINT64_C(0x476f6f6754000000);
+ hub.chreApiMajorVersion = 1;
+ hub.chreApiMinorVersion = 4;
+
+ // Report a single mock hub
+ std::vector<::android::hardware::contexthub::V1_0::ContextHub> hubs;
+ hubs.push_back(hub);
+
+ std::vector<hidl_string> hubPermissionList;
+
+ _hidl_cb(hubs, hubPermissionList);
+ return Void();
+}
+
Return<Result> Contexthub::registerCallback(uint32_t hubId,
const sp<V1_0::IContexthubCallback>& cb) {
if (hubId == kMockHubId) {
diff --git a/contexthub/1.2/default/Contexthub.h b/contexthub/1.2/default/Contexthub.h
index 8b89824..32b862d 100644
--- a/contexthub/1.2/default/Contexthub.h
+++ b/contexthub/1.2/default/Contexthub.h
@@ -35,6 +35,7 @@
using Result = ::android::hardware::contexthub::V1_0::Result;
using SettingValue = ::android::hardware::contexthub::V1_1::SettingValue;
using SettingV1_1 = ::android::hardware::contexthub::V1_1::Setting;
+ using getHubs_1_2_cb = ::android::hardware::contexthub::V1_2::IContexthub::getHubs_1_2_cb;
public:
// Methods from V1_0::IContexthub
@@ -47,6 +48,8 @@
Return<void> onSettingChanged(SettingV1_1 setting, SettingValue newValue) override;
// Methods from V1_2::IContexthub
+ Return<void> getHubs_1_2(getHubs_1_2_cb _hidl_cb) override;
+
Return<void> onSettingChanged_1_2(Setting setting, SettingValue newValue) override;
Return<Result> registerCallback_1_2(uint32_t hubId,
diff --git a/contexthub/common/default/1.X/utils/IContextHubCallbackWrapper.h b/contexthub/common/default/1.X/utils/IContextHubCallbackWrapper.h
index df78438..d8cc37b 100644
--- a/contexthub/common/default/1.X/utils/IContextHubCallbackWrapper.h
+++ b/contexthub/common/default/1.X/utils/IContextHubCallbackWrapper.h
@@ -54,7 +54,8 @@
*/
class IContextHubCallbackWrapperBase : public VirtualLightRefBase {
public:
- virtual Return<void> handleClientMsg(V1_2::ContextHubMsg msg) = 0;
+ virtual Return<void> handleClientMsg(V1_2::ContextHubMsg msg,
+ hidl_vec<hidl_string> msgContentPerms) = 0;
virtual Return<void> handleTxnResult(uint32_t txnId, V1_0::TransactionResult result) = 0;
@@ -70,7 +71,8 @@
public:
ContextHubCallbackWrapper(sp<T> callback) : mCallback(callback){};
- virtual Return<void> handleClientMsg(V1_2::ContextHubMsg msg) override {
+ virtual Return<void> handleClientMsg(V1_2::ContextHubMsg msg,
+ hidl_vec<hidl_string> /* msgContentPerms */) override {
return mCallback->handleClientMsg(convertToOldMsg(msg));
}
@@ -105,8 +107,9 @@
IContextHubCallbackWrapperV1_2(sp<V1_2::IContexthubCallback> callback)
: ContextHubCallbackWrapper(callback){};
- Return<void> handleClientMsg(V1_2::ContextHubMsg msg) override {
- return mCallback->handleClientMsg_1_2(msg);
+ Return<void> handleClientMsg(V1_2::ContextHubMsg msg,
+ hidl_vec<hidl_string> msgContentPerms) override {
+ return mCallback->handleClientMsg_1_2(msg, msgContentPerms);
}
Return<void> handleAppsInfo(hidl_vec<V1_2::HubAppInfo> appInfo) override {