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_WINDOW_SCENE_SINGLE_DISPLAY_FOLD_POLICY_H 17 #define OHOS_ROSEN_WINDOW_SCENE_SINGLE_DISPLAY_FOLD_POLICY_H 18 19 #include <refbase.h> 20 21 #include "common/include/task_scheduler.h" 22 #include "fold_screen_controller/fold_screen_policy.h" 23 #include "fold_screen_info.h" 24 #include "session/screen/include/screen_session.h" 25 26 namespace OHOS::Rosen { 27 class SingleDisplayFoldPolicy : public FoldScreenPolicy { 28 public: 29 SingleDisplayFoldPolicy(std::recursive_mutex& displayInfoMutex, 30 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler); 31 ~SingleDisplayFoldPolicy() = default; 32 void ChangeScreenDisplayMode(FoldDisplayMode displayMode, 33 DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT) override; 34 void SendSensorResult(FoldStatus foldStatus) override; 35 sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() override; 36 FoldCreaseRegion GetLiveCreaseRegion() override; 37 void LockDisplayStatus(bool locked) override; 38 void SetOnBootAnimation(bool onBootAnimation) override; 39 void UpdateForPhyScreenPropertyChange() override; ExitCoordination()40 void ExitCoordination() override {}; AddOrRemoveDisplayNodeToTree(ScreenId screenId,int32_t command)41 void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command) override {}; 42 FoldDisplayMode GetModeMatchStatus() override; 43 void SetIsClearingBootAnimation(bool isClearingBootAnimation) override; 44 void GetAllCreaseRegion(std::vector<FoldCreaseRegionItem>& foldCreaseRegionItems) const override; 45 private: 46 void ChangeScreenDisplayModeToMain(sptr<ScreenSession> screenSession, 47 DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT); 48 void ChangeScreenDisplayModeToFull(sptr<ScreenSession> screenSession, 49 DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT); 50 void ChangeScreenDisplayModeToMainWhenFoldScreenOn(sptr<ScreenSession> screenSession); 51 void ChangeScreenDisplayModeToMainWhenFoldScreenOff(sptr<ScreenSession> screenSession); 52 void ChangeScreenDisplayModeToFullWhenFoldScreenOn(sptr<ScreenSession> screenSession); 53 void ChangeScreenDisplayModeToFullWhenFoldScreenOff(sptr<ScreenSession> screenSession, 54 DisplayModeChangeReason reason); 55 void ChangeScreenDisplayModeToMainOnBootAnimation(sptr<ScreenSession> screenSession); 56 void ChangeScreenDisplayModeToFullOnBootAnimation(sptr<ScreenSession> screenSession); 57 void ChangeScreenDisplayModePower(ScreenId screenId, ScreenPowerStatus screenPowerStatus); 58 void RecoverWhenBootAnimationExit(); 59 void ReportFoldDisplayModeChange(FoldDisplayMode displayMode); 60 void ReportFoldStatusChangeBegin(int32_t offScreen, int32_t onScreen); 61 void SendPropertyChangeResult(sptr<ScreenSession> screenSession, ScreenId screenId, 62 ScreenPropertyChangeReason reason); 63 void SetdisplayModeChangeStatus(bool status, bool isOnBootAnimation = false) override; 64 void ChangeScreenDisplayModeInner(FoldDisplayMode displayMode, DisplayModeChangeReason reason); 65 FoldCreaseRegion GetFoldCreaseRegion(bool isVertical) const; 66 void GetFoldCreaseRect(bool isVertical, const std::vector<int32_t>& foldRect, 67 std::vector<DMRect>& foldCreaseRect) const; 68 std::recursive_mutex& displayInfoMutex_; 69 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_; 70 }; 71 } // namespace OHOS::Rosen 72 #endif //OHOS_ROSEN_WINDOW_SCENE_SINGLE_DISPLAY_FOLD_POLICY_H