1 /* 2 * Copyright (c) 2021-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 DISPLAYMGR_SCREEN_ACTION_H 17 #define DISPLAYMGR_SCREEN_ACTION_H 18 19 #include <cstdint> 20 #include <functional> 21 #include <memory> 22 #include <mutex> 23 #include <vector> 24 25 #include "dm_common.h" 26 #include "display_manager_lite.h" 27 #include "display_power_info.h" 28 29 namespace OHOS { 30 namespace DisplayPowerMgr { 31 class ScreenAction { 32 public: 33 ScreenAction(uint32_t displayId); 34 ~ScreenAction() = default; 35 36 static uint32_t GetDefaultDisplayId(); 37 static std::vector<uint32_t> GetAllDisplayId(); 38 39 uint32_t GetDisplayId(); 40 DisplayState GetDisplayState(); 41 void WriteHiSysEvent(DisplayState state, int32_t beginTimeMs); 42 bool SetDisplayState(DisplayState state, const std::function<void(DisplayState)>& callback); 43 bool SetDisplayPower(DisplayState state, uint32_t reason); 44 uint32_t GetBrightness(); 45 bool SetBrightness(uint32_t value); 46 void SetCoordinated(bool coordinated); 47 bool EnableSkipSetDisplayState(uint32_t reason); 48 49 private: 50 static constexpr uint32_t DEFAULT_DISPLAY_ID = 0; 51 std::mutex mutexBrightness_; 52 uint32_t brightness_ {102}; 53 uint32_t displayId_ {DEFAULT_DISPLAY_ID}; 54 bool coordinated_ {false}; 55 Rosen::PowerStateChangeReason ParseSpecialReason(uint32_t reason); 56 Rosen::DisplayState ParseDisplayState(DisplayState state); 57 }; 58 } // namespace DisplayPowerMgr 59 } // namespace OHOS 60 #endif // DISPLAYMGR_SCREEN_ACTION_H 61