1 /* 2 * Copyright (C) 2021 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 #pragma once 18 19 #include <aidl/android/hardware/contexthub/BnContextHub.h> 20 21 #include <unordered_set> 22 #include <vector> 23 24 namespace aidl { 25 namespace android { 26 namespace hardware { 27 namespace contexthub { 28 29 class ContextHub : public BnContextHub { 30 ::ndk::ScopedAStatus getContextHubs(std::vector<ContextHubInfo>* out_contextHubInfos) override; 31 ::ndk::ScopedAStatus loadNanoapp(int32_t in_contextHubId, const NanoappBinary& in_appBinary, 32 int32_t in_transactionId) override; 33 ::ndk::ScopedAStatus unloadNanoapp(int32_t in_contextHubId, int64_t in_appId, 34 int32_t in_transactionId) override; 35 ::ndk::ScopedAStatus disableNanoapp(int32_t in_contextHubId, int64_t in_appId, 36 int32_t in_transactionId) override; 37 ::ndk::ScopedAStatus enableNanoapp(int32_t in_contextHubId, int64_t in_appId, 38 int32_t in_transactionId) override; 39 ::ndk::ScopedAStatus onSettingChanged(Setting in_setting, bool in_enabled) override; 40 ::ndk::ScopedAStatus queryNanoapps(int32_t in_contextHubId) override; 41 ::ndk::ScopedAStatus getPreloadedNanoappIds( 42 int32_t in_contextHubId, std::vector<int64_t>* out_preloadedNanoappIds) override; 43 ::ndk::ScopedAStatus registerCallback( 44 int32_t in_contextHubId, const std::shared_ptr<IContextHubCallback>& in_cb) override; 45 ::ndk::ScopedAStatus sendMessageToHub(int32_t in_contextHubId, 46 const ContextHubMessage& in_message) override; 47 ::ndk::ScopedAStatus setTestMode(bool enable) override; 48 ::ndk::ScopedAStatus onHostEndpointConnected(const HostEndpointInfo& in_info) override; 49 50 ::ndk::ScopedAStatus onHostEndpointDisconnected(char16_t in_hostEndpointId) override; 51 ::ndk::ScopedAStatus onNanSessionStateChanged(const NanSessionStateUpdate& in_update) override; 52 ::ndk::ScopedAStatus sendMessageDeliveryStatusToHub( 53 int32_t in_contextHubId, 54 const MessageDeliveryStatus& in_messageDeliveryStatus) override; 55 56 private: 57 static constexpr uint32_t kMockHubId = 0; 58 std::shared_ptr<IContextHubCallback> mCallback; 59 60 std::unordered_set<char16_t> mConnectedHostEndpoints; 61 }; 62 63 } // namespace contexthub 64 } // namespace hardware 65 } // namespace android 66 } // namespace aidl 67