blob: db0c5bc3df4cedd05ca1f6483ce79fa54cd128ec [file] [log] [blame]
Arthur Ishiguro46c2bd02020-10-06 11:05:17 -07001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include "Contexthub.h"
17
18#include <vector>
19
20namespace android {
21namespace hardware {
22namespace contexthub {
23namespace V1_2 {
24namespace implementation {
25
Anthony Stange100aa5e2020-12-17 14:20:02 -050026using ::android::hardware::contexthub::V1_0::Result;
27using ::android::hardware::contexthub::V1_X::implementation::IContextHubCallbackWrapperV1_0;
28using ::android::hardware::contexthub::V1_X::implementation::IContextHubCallbackWrapperV1_2;
29
30Return<Result> Contexthub::registerCallback(uint32_t hubId,
31 const sp<V1_0::IContexthubCallback>& cb) {
32 if (hubId == kMockHubId) {
33 mCallback = new IContextHubCallbackWrapperV1_0(cb);
34 return Result::OK;
35 }
36 return Result::BAD_PARAMS;
Anthony Stange6c77c352020-12-16 12:50:08 -050037}
38
Anthony Stange100aa5e2020-12-17 14:20:02 -050039Return<Result> Contexthub::queryApps(uint32_t hubId) {
40 if (hubId == kMockHubId && mCallback != nullptr) {
41 std::vector<V1_2::HubAppInfo> nanoapps;
42 mCallback->handleAppsInfo(nanoapps);
43 return Result::OK;
44 }
45 return Result::BAD_PARAMS;
46}
47
48Return<Result> Contexthub::registerCallback_1_2(uint32_t hubId,
49 const sp<V1_2::IContexthubCallback>& cb) {
50 if (hubId == kMockHubId) {
51 mCallback = new IContextHubCallbackWrapperV1_2(cb);
52 return Result::OK;
53 }
54 return Result::BAD_PARAMS;
55}
56
57// We don't expose any nanoapps, therefore all nanoapp-related API calls return with BAD_PARAMS
Anthony Stange6c77c352020-12-16 12:50:08 -050058Return<Result> Contexthub::sendMessageToHub_1_2(uint32_t /* hubId */,
59 const ContextHubMsg& /* msg */) {
Anthony Stange100aa5e2020-12-17 14:20:02 -050060 return Result::BAD_PARAMS;
Anthony Stange6c77c352020-12-16 12:50:08 -050061}
62
Arthur Ishiguro46c2bd02020-10-06 11:05:17 -070063Return<void> Contexthub::onSettingChanged(SettingV1_1 /*setting*/, SettingValue /*newValue*/) {
64 return Void();
65}
66
67Return<void> Contexthub::onSettingChanged_1_2(Setting /*setting*/, SettingValue /*newValue*/) {
68 return Void();
69}
70
71} // namespace implementation
72} // namespace V1_2
73} // namespace contexthub
74} // namespace hardware
75} // namespace android