blob: 19cc2628d73f20f01fc33455d88092ef74b5a38c [file] [log] [blame]
Brian Duddiea7bf0d22020-02-14 14:24:39 -08001/*
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_1 {
24namespace implementation {
25
26using ::android::hardware::contexthub::V1_0::ContextHub;
27using ::android::hardware::contexthub::V1_0::HubAppInfo;
28using ::android::hardware::contexthub::V1_0::Result;
29
30namespace {
31
32constexpr uint32_t kMockHubId = 0;
33
34} // anonymous namespace
35
36Return<void> Contexthub::getHubs(getHubs_cb _hidl_cb) {
37 ContextHub hub = {};
38 hub.name = "Mock Context Hub";
39 hub.vendor = "AOSP";
40 hub.toolchain = "n/a";
41 hub.platformVersion = 1;
42 hub.toolchainVersion = 1;
43 hub.hubId = kMockHubId;
44 hub.peakMips = 1;
45 hub.peakPowerDrawMw = 1;
46 hub.maxSupportedMsgLen = 4096;
47 hub.chrePlatformId = UINT64_C(0x476f6f6754000000);
48 hub.chreApiMajorVersion = 1;
49 hub.chreApiMinorVersion = 4;
50
51 // Report a single mock hub
52 std::vector<ContextHub> hubs;
53 hubs.push_back(hub);
54
55 _hidl_cb(hubs);
56 return Void();
57}
58
59Return<Result> Contexthub::registerCallback(uint32_t hubId, const sp<IContexthubCallback>& cb) {
60 if (hubId == kMockHubId) {
61 mCallback = cb;
62 return Result::OK;
63 }
64 return Result::BAD_PARAMS;
65}
66
67// We don't expose any nanoapps, therefore all nanoapp-related API calls return with BAD_PARAMS
68Return<Result> Contexthub::sendMessageToHub(uint32_t /*hubId*/, const ContextHubMsg& /*msg*/) {
69 return Result::BAD_PARAMS;
70}
71
72Return<Result> Contexthub::loadNanoApp(uint32_t /*hubId*/, const NanoAppBinary& /*appBinary*/,
73 uint32_t /*transactionId*/) {
74 return Result::BAD_PARAMS;
75}
76
77Return<Result> Contexthub::unloadNanoApp(uint32_t /*hubId*/, uint64_t /*appId*/,
78 uint32_t /*transactionId*/) {
79 return Result::BAD_PARAMS;
80}
81
82Return<Result> Contexthub::enableNanoApp(uint32_t /*hubId*/, uint64_t /*appId*/,
83 uint32_t /*transactionId*/) {
84 return Result::BAD_PARAMS;
85}
86
87Return<Result> Contexthub::disableNanoApp(uint32_t /*hubId*/, uint64_t /*appId*/,
88 uint32_t /*transactionId*/) {
89 return Result::BAD_PARAMS;
90}
91
92Return<Result> Contexthub::queryApps(uint32_t hubId) {
93 if (hubId == kMockHubId && mCallback != nullptr) {
94 std::vector<HubAppInfo> nanoapps;
95 mCallback->handleAppsInfo(nanoapps);
96 return Result::OK;
97 }
98 return Result::BAD_PARAMS;
99}
100
101Return<void> Contexthub::onSettingChanged(Setting /*setting*/, SettingValue /*newValue*/) {
102 return Void();
103}
104
105} // namespace implementation
106} // namespace V1_1
107} // namespace contexthub
108} // namespace hardware
109} // namespace android