1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MULTIMODAL_INPUT_CONNECT_MANAGER_H 17 #define MULTIMODAL_INPUT_CONNECT_MANAGER_H 18 19 #include <memory> 20 #include <map> 21 #include <set> 22 #include <string> 23 24 #include "i_multimodal_input_connect.h" 25 26 namespace OHOS { 27 namespace MMI { 28 class MultimodalInputConnectManager : public std::enable_shared_from_this<MultimodalInputConnectManager> { 29 public: 30 virtual ~MultimodalInputConnectManager() = default; 31 static std::shared_ptr<MultimodalInputConnectManager> GetInstance(); 32 int32_t AllocSocketPair(const int32_t moduleType); 33 int32_t GetClientSocketFdOfAllocedSocketPair() const; 34 int32_t AddInputEventFilter(sptr<IEventFilter> filter); 35 private: 36 MultimodalInputConnectManager() = default; 37 MultimodalInputConnectManager(const MultimodalInputConnectManager &manager) = delete; 38 MultimodalInputConnectManager& operator=(const MultimodalInputConnectManager &manager) = delete; 39 MultimodalInputConnectManager(const MultimodalInputConnectManager &&manager) = delete; 40 MultimodalInputConnectManager& operator=(const MultimodalInputConnectManager &&manager) = delete; 41 42 bool ConnectMultimodalInputService(); 43 void OnDeath(); 44 void Clean(); 45 void NotifyDeath(); 46 sptr<IMultimodalInputConnect> multimodalInputConnectService_ = nullptr; 47 sptr<IRemoteObject::DeathRecipient> multimodalInputConnectRecipient_ = nullptr; 48 std::mutex lock_; 49 int32_t socketFd_ = IMultimodalInputConnect::INVALID_SOCKET_FD; 50 }; 51 } // namespace MMI 52 } // namespace OHOS 53 54 #endif // MULTIMODAL_INPUT_CONNECT_MANAGER_H