Arthur Ishiguro | 46c2bd0 | 2020-10-06 11:05:17 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | namespace android { |
| 21 | namespace hardware { |
| 22 | namespace contexthub { |
| 23 | namespace V1_2 { |
| 24 | namespace implementation { |
| 25 | |
Anthony Stange | c3c59b3 | 2021-02-10 15:42:10 +0000 | [diff] [blame] | 26 | using ::android::hardware::hidl_string; |
Anthony Stange | 100aa5e | 2020-12-17 14:20:02 -0500 | [diff] [blame] | 27 | using ::android::hardware::contexthub::V1_0::Result; |
| 28 | using ::android::hardware::contexthub::V1_X::implementation::IContextHubCallbackWrapperV1_0; |
| 29 | using ::android::hardware::contexthub::V1_X::implementation::IContextHubCallbackWrapperV1_2; |
| 30 | |
Anthony Stange | c3c59b3 | 2021-02-10 15:42:10 +0000 | [diff] [blame] | 31 | Return<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 Stange | 100aa5e | 2020-12-17 14:20:02 -0500 | [diff] [blame] | 56 | Return<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 Stange | 6c77c35 | 2020-12-16 12:50:08 -0500 | [diff] [blame] | 63 | } |
| 64 | |
Anthony Stange | 100aa5e | 2020-12-17 14:20:02 -0500 | [diff] [blame] | 65 | Return<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 | |
| 74 | Return<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 Ishiguro | 46c2bd0 | 2020-10-06 11:05:17 -0700 | [diff] [blame] | 83 | Return<void> Contexthub::onSettingChanged(SettingV1_1 /*setting*/, SettingValue /*newValue*/) { |
| 84 | return Void(); |
| 85 | } |
| 86 | |
| 87 | Return<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 |