1 /* 2 * Copyright (c) 2023 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 OHOS_ROSEN_SESSION_DISPLAY_POWER_CONTROLLER_H 17 #define OHOS_ROSEN_SESSION_DISPLAY_POWER_CONTROLLER_H 18 19 #include <map> 20 #include <mutex> 21 #include <refbase.h> 22 #include "display.h" 23 #include "display_change_listener.h" 24 #include "dm_common.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 class SessionDisplayPowerController : public RefBase { 29 using SessionDisplayStateChangeListener = std::function<void(DisplayId, sptr<DisplayInfo>, 30 const std::map<DisplayId, sptr<DisplayInfo>>&, DisplayStateChangeType)>; 31 public: SessionDisplayPowerController(SessionDisplayStateChangeListener listener)32 SessionDisplayPowerController(SessionDisplayStateChangeListener listener) 33 : displayStateChangeListener_(listener) 34 { 35 } 36 virtual ~SessionDisplayPowerController() = default; 37 38 bool SuspendBegin(PowerStateChangeReason reason); 39 bool SetDisplayState(DisplayState state); 40 DisplayState GetDisplayState(DisplayId displayId); 41 void NotifyDisplayEvent(DisplayEvent event); 42 43 private: 44 DisplayState displayState_ { DisplayState::UNKNOWN }; 45 SessionDisplayStateChangeListener displayStateChangeListener_; 46 }; 47 } 48 } 49 #endif // OHOS_ROSEN_DISPLAY_POWER_CONTROLLER_H