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_FOLD_SCREEN_CONTROLLER_H 17 #define OHOS_ROSEN_WINDOW_SCENE_FOLD_SCREEN_CONTROLLER_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_controller/fold_screen_state_machine.h" 24 #include "fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.h" 25 #include "fold_screen_info.h" 26 27 namespace OHOS::Rosen { 28 enum class DisplayDeviceType :uint32_t { 29 DISPLAY_DEVICE_UNKNOWN = 0, 30 SINGLE_DISPLAY_DEVICE, 31 DOUBLE_DISPLAY_DEVICE, 32 SINGLE_DISPLAY_POCKET_DEVICE, 33 SECONDARY_DISPLAY_DEVICE, 34 }; 35 36 class FoldScreenController : public RefBase { 37 public: 38 FoldScreenController(std::recursive_mutex& displayInfoMutex, 39 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler); 40 virtual ~FoldScreenController(); 41 42 void BootAnimationFinishPowerInit(); 43 void SetDisplayMode(const FoldDisplayMode displayMode); 44 void RecoverDisplayMode(); 45 FoldDisplayMode GetDisplayMode(); 46 bool IsFoldable(); 47 FoldStatus GetFoldStatus(); 48 bool GetTentMode(); 49 FoldDisplayMode GetModeMatchStatus(); 50 void SetFoldStatus(FoldStatus foldStatus); 51 void OnTentModeChanged(int tentType, int32_t hall = -1); 52 sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion(); 53 FoldCreaseRegion GetLiveCreaseRegion() const; 54 ScreenId GetCurrentScreenId(); 55 void LockDisplayStatus(bool locked); 56 void SetOnBootAnimation(bool onBootAnimation); 57 void UpdateForPhyScreenPropertyChange(); 58 void ExitCoordination(); 59 Drawing::Rect GetScreenSnapshotRect(); 60 void SetMainScreenRegion(DMRect& mainScreenRegion); 61 std::chrono::steady_clock::time_point GetStartTimePoint(); 62 bool GetIsFirstFrameCommitReported(); 63 void SetIsFirstFrameCommitReported(bool isFirstFrameCommitReported); 64 /* 65 * Avoid fold to expand process queues public interface 66 */ 67 bool GetModeChangeRunningStatus(); 68 void SetdisplayModeChangeStatus(bool status); 69 bool GetdisplayModeRunningStatus(); 70 FoldDisplayMode GetLastCacheDisplayMode(); 71 void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command); 72 void SetIsClearingBootAnimation(bool isClearingBootAnimation); 73 nlohmann::ordered_json GetFoldCreaseRegionJson(); 74 private: 75 sptr<FoldScreenPolicy> GetFoldScreenPolicy(DisplayDeviceType productType); 76 sptr<FoldScreenPolicy> foldScreenPolicy_; 77 sptr<SensorFoldStateManager> sensorFoldStateManager_; 78 std::recursive_mutex& displayInfoMutex_; 79 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_; 80 std::vector<FoldCreaseRegionItem> foldCreaseRegionItems_; 81 }; 82 } // namespace OHOS::Rosen 83 #endif //OHOS_ROSEN_WINDOW_SCENE_FOLD_SCREEN_CONTROLLER_H