1 /* 2 * Copyright (c) 2023-2024 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 DINPUT_SOURCE_MANAGER_EVENT_HANDLER_H 17 #define DINPUT_SOURCE_MANAGER_EVENT_HANDLER_H 18 19 #include <cstring> 20 #include <mutex> 21 #include <set> 22 23 #include <unistd.h> 24 #include <sys/types.h> 25 26 #include "event_handler.h" 27 #include "ipublisher_listener.h" 28 #include "publisher_listener_stub.h" 29 #include "singleton.h" 30 31 #include "constants_dinput.h" 32 #include "dinput_context.h" 33 #include "dinput_source_manager_callback.h" 34 #include "dinput_source_trans_callback.h" 35 #include "distributed_input_source_manager.h" 36 37 namespace OHOS { 38 namespace DistributedHardware { 39 namespace DistributedInput { 40 class DistributedInputSourceManager; 41 class DInputSourceManagerEventHandler : public AppExecFwk::EventHandler { 42 public: 43 DInputSourceManagerEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner, 44 DistributedInputSourceManager *manager); 45 ~DInputSourceManagerEventHandler() override; 46 47 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; 48 private: 49 void NotifyRegisterCallback(const AppExecFwk::InnerEvent::Pointer &event); 50 void NotifyUnregisterCallback(const AppExecFwk::InnerEvent::Pointer &event); 51 void NotifyPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event); 52 void NotifyUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event); 53 void NotifyStartCallback(const AppExecFwk::InnerEvent::Pointer &event); 54 void NotifyStopCallback(const AppExecFwk::InnerEvent::Pointer &event); 55 void NotifyStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event); 56 void NotifyStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event); 57 void NotifyKeyStateCallback(const AppExecFwk::InnerEvent::Pointer &event); 58 void NotifyStartServerCallback(const AppExecFwk::InnerEvent::Pointer &event); 59 void NotifyRelayPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event); 60 void NotifyRelayUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event); 61 void NotifyRelayStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event); 62 void NotifyRelayStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event); 63 void NotifyRelayStartTypeCallback(const AppExecFwk::InnerEvent::Pointer &event); 64 void NotifyRelayStopTypeCallback(const AppExecFwk::InnerEvent::Pointer &event); 65 void NotifyRelayPrepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event); 66 void NotifyRelayUnprepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event); 67 void ProcessEventInner(const AppExecFwk::InnerEvent::Pointer &event); 68 69 DistributedInputSourceManager *sourceManagerObj_; 70 }; 71 } // namespace DistributedInput 72 } // namespace DistributedHardware 73 } // namespace OHOS 74 75 #endif // DINPUT_SOURCE_MANAGER_EVENT_HANDLER_H