blob: 57145fc64f3bbdf0834c2369673afd825fe86d10 [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 Stangec3c59b32021-02-10 15:42:10 +000026using ::android::hardware::hidl_string;
Anthony Stange100aa5e2020-12-17 14:20:02 -050027using ::android::hardware::contexthub::V1_0::Result;
28using ::android::hardware::contexthub::V1_X::implementation::IContextHubCallbackWrapperV1_0;
29using ::android::hardware::contexthub::V1_X::implementation::IContextHubCallbackWrapperV1_2;
30
Anthony Stangec3c59b32021-02-10 15:42:10 +000031Return<void> Contexthub::getHubs_1_2(getHubs_1_2_cb _hidl_cb) {
32 ::android::hardware::contexthub::V1_0::ContextHub hub = {};
33 hub.name = "Mock Context Hub";
34 hub.vendor = "AOSP";
35 hub.toolchain = "n/a";
36 hub.platformVersion = 1;
37 hub.toolchainVersion = 1;
38 hub.hubId = kMockHubId;
39 hub.peakMips = 1;
40 hub.peakPowerDrawMw = 1;
41 hub.maxSupportedMsgLen = 4096;
42 hub.chrePlatformId = UINT64_C(0x476f6f6754000000);
43 hub.chreApiMajorVersion = 1;
44 hub.chreApiMinorVersion = 4;
45
46 // Report a single mock hub
47 std::vector<::android::hardware::contexthub::V1_0::ContextHub> hubs;
48 hubs.push_back(hub);
49
50 std::vector<hidl_string> hubPermissionList;
51
52 _hidl_cb(hubs, hubPermissionList);
53 return Void();
54}
55
Anthony Stange100aa5e2020-12-17 14:20:02 -050056Return<Result> Contexthub::registerCallback(uint32_t hubId,
57 const sp<V1_0::IContexthubCallback>& cb) {
58 if (hubId == kMockHubId) {
59 mCallback = new IContextHubCallbackWrapperV1_0(cb);
60 return Result::OK;
61 }
62 return Result::BAD_PARAMS;
Anthony Stange6c77c352020-12-16 12:50:08 -050063}
64
Anthony Stange100aa5e2020-12-17 14:20:02 -050065Return<Result> Contexthub::queryApps(uint32_t hubId) {
66 if (hubId == kMockHubId && mCallback != nullptr) {
67 std::vector<V1_2::HubAppInfo> nanoapps;
68 mCallback->handleAppsInfo(nanoapps);
69 return Result::OK;
70 }
71 return Result::BAD_PARAMS;
72}
73
74Return<Result> Contexthub::registerCallback_1_2(uint32_t hubId,
75 const sp<V1_2::IContexthubCallback>& cb) {
76 if (hubId == kMockHubId) {
77 mCallback = new IContextHubCallbackWrapperV1_2(cb);
78 return Result::OK;
79 }
80 return Result::BAD_PARAMS;
81}
82
Arthur Ishiguro46c2bd02020-10-06 11:05:17 -070083Return<void> Contexthub::onSettingChanged(SettingV1_1 /*setting*/, SettingValue /*newValue*/) {
84 return Void();
85}
86
87Return<void> Contexthub::onSettingChanged_1_2(Setting /*setting*/, SettingValue /*newValue*/) {
88 return Void();
89}
90
91} // namespace implementation
92} // namespace V1_2
93} // namespace contexthub
94} // namespace hardware
95} // namespace android