1 /* 2 * Copyright (c) 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 DISPLAYMGR_DISPLAY_EVENT_HANDLER_H 17 #define DISPLAYMGR_DISPLAY_EVENT_HANDLER_H 18 19 #include <cstdint> 20 #include <functional> 21 #include <map> 22 #include <memory> 23 #include <event_handler.h> 24 #include <event_runner.h> 25 #include <refbase.h> 26 #include "inner_event.h" 27 28 namespace OHOS { 29 namespace DisplayPowerMgr { 30 class DisplayPowerMgrService; 31 class DisplayEventHandler : public AppExecFwk::EventHandler { 32 public: 33 typedef std::function<void(int64_t)> EventCallback; 34 enum Event { 35 EVENT_CANCEL_BOOST_BRIGHTNESS, 36 EVENT_SET_SETTING_BRIGHTNESS, 37 }; 38 DisplayEventHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner, 39 const wptr<DisplayPowerMgrService>& parent); 40 ~DisplayEventHandler() = default; 41 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event) override; 42 void EmplaceCallBack(DisplayEventHandler::Event event, EventCallback& callback); 43 44 private: 45 wptr<DisplayPowerMgrService> parent_; 46 std::map<uint32_t, EventCallback> eventCallbackMap_; 47 }; 48 } // namespace DisplayPowerMgr 49 } // namespace OHOS 50 #endif // DISPLAYMGR_DISPLAY_EVENT_HANDLER_H