Add new contexthub HAL 1.2 methods to default impl
Bug: 166846988
Test: Run VTS against default HAL
Change-Id: I158a49e54f340a2ba25f79894d6ec465070326f8
diff --git a/contexthub/1.1/default/Contexthub.cpp b/contexthub/1.1/default/Contexthub.cpp
index e7fde84..2d4fbae 100644
--- a/contexthub/1.1/default/Contexthub.cpp
+++ b/contexthub/1.1/default/Contexthub.cpp
@@ -23,10 +23,29 @@
namespace V1_1 {
namespace implementation {
+using ::android::hardware::contexthub::V1_0::Result;
+
Return<void> Contexthub::onSettingChanged(Setting /*setting*/, SettingValue /*newValue*/) {
return Void();
}
+Return<Result> Contexthub::registerCallback(uint32_t hubId, const sp<IContexthubCallback>& cb) {
+ if (hubId == kMockHubId) {
+ mCallback = cb;
+ return Result::OK;
+ }
+ return Result::BAD_PARAMS;
+}
+
+Return<Result> Contexthub::queryApps(uint32_t hubId) {
+ if (hubId == kMockHubId && mCallback != nullptr) {
+ std::vector<HubAppInfo> nanoapps;
+ mCallback->handleAppsInfo(nanoapps);
+ return Result::OK;
+ }
+ return Result::BAD_PARAMS;
+}
+
} // namespace implementation
} // namespace V1_1
} // namespace contexthub
diff --git a/contexthub/1.1/default/Contexthub.h b/contexthub/1.1/default/Contexthub.h
index 1468fcf..648749e 100644
--- a/contexthub/1.1/default/Contexthub.h
+++ b/contexthub/1.1/default/Contexthub.h
@@ -27,9 +27,19 @@
class Contexthub
: public ::android::hardware::contexthub::V1_X::implementation::ContextHub<IContexthub> {
+ using Result = ::android::hardware::contexthub::V1_0::Result;
+
public:
+ // Methods from V1_0::IContexthub
+ Return<Result> registerCallback(uint32_t hubId, const sp<IContexthubCallback>& cb) override;
+
+ Return<Result> queryApps(uint32_t hubId) override;
+
// Methods from V1_1::IContexthub
Return<void> onSettingChanged(Setting setting, SettingValue newValue) override;
+
+ private:
+ sp<IContexthubCallback> mCallback;
};
} // namespace implementation