blob: 00f74afa1b7d9e90437ff579aabf12a73817b0f8 [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
17#ifndef ANDROID_HARDWARE_CONTEXTHUB_V1_X_CONTEXTHUB_H
18#define ANDROID_HARDWARE_CONTEXTHUB_V1_X_CONTEXTHUB_H
19
20#include <android/hardware/contexthub/1.0/IContexthub.h>
21#include <android/hardware/contexthub/1.0/types.h>
22#include <hidl/Status.h>
23
24namespace android {
25namespace hardware {
26namespace contexthub {
27namespace V1_X {
28namespace implementation {
29
30template <class IContextHubInterface>
31struct ContextHub : public IContextHubInterface {
32 using ContextHubMsg = ::android::hardware::contexthub::V1_0::ContextHubMsg;
33 using HubAppInfo = ::android::hardware::contexthub::V1_0::HubAppInfo;
34 using IContexthubCallback = ::android::hardware::contexthub::V1_0::IContexthubCallback;
35 using NanoAppBinary = ::android::hardware::contexthub::V1_0::NanoAppBinary;
36 using Result = ::android::hardware::contexthub::V1_0::Result;
37 using getHubs_cb = ::android::hardware::contexthub::V1_0::IContexthub::getHubs_cb;
38
39 public:
40 Return<void> getHubs(getHubs_cb _hidl_cb) override {
41 ::android::hardware::contexthub::V1_0::ContextHub hub = {};
42 hub.name = "Mock Context Hub";
43 hub.vendor = "AOSP";
44 hub.toolchain = "n/a";
45 hub.platformVersion = 1;
46 hub.toolchainVersion = 1;
47 hub.hubId = kMockHubId;
48 hub.peakMips = 1;
49 hub.peakPowerDrawMw = 1;
50 hub.maxSupportedMsgLen = 4096;
51 hub.chrePlatformId = UINT64_C(0x476f6f6754000000);
52 hub.chreApiMajorVersion = 1;
53 hub.chreApiMinorVersion = 4;
54
55 // Report a single mock hub
56 std::vector<::android::hardware::contexthub::V1_0::ContextHub> hubs;
57 hubs.push_back(hub);
58
59 _hidl_cb(hubs);
60 return Void();
61 }
62
Arthur Ishiguro46c2bd02020-10-06 11:05:17 -070063 // We don't expose any nanoapps, therefore all nanoapp-related API calls return with BAD_PARAMS
64 Return<Result> sendMessageToHub(uint32_t /*hubId*/, const ContextHubMsg& /*msg*/) override {
65 return Result::BAD_PARAMS;
66 }
67
68 Return<Result> loadNanoApp(uint32_t /*hubId*/, const NanoAppBinary& /*appBinary*/,
69 uint32_t /*transactionId*/) override {
70 return Result::BAD_PARAMS;
71 }
72
73 Return<Result> unloadNanoApp(uint32_t /*hubId*/, uint64_t /*appId*/,
74 uint32_t /*transactionId*/) override {
75 return Result::BAD_PARAMS;
76 }
77
78 Return<Result> enableNanoApp(uint32_t /*hubId*/, uint64_t /*appId*/,
79 uint32_t /*transactionId*/) override {
80 return Result::BAD_PARAMS;
81 }
82
83 Return<Result> disableNanoApp(uint32_t /*hubId*/, uint64_t /*appId*/,
84 uint32_t /*transactionId*/) override {
85 return Result::BAD_PARAMS;
86 }
87
Anthony Stange100aa5e2020-12-17 14:20:02 -050088 protected:
Arthur Ishiguro46c2bd02020-10-06 11:05:17 -070089 static constexpr uint32_t kMockHubId = 0;
Arthur Ishiguro46c2bd02020-10-06 11:05:17 -070090};
91
92} // namespace implementation
93} // namespace V1_X
94} // namespace contexthub
95} // namespace hardware
96} // namespace android
97
98#endif // ANDROID_HARDWARE_CONTEXTHUB_V1_X_CONTEXTHUB_H