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 #ifndef OHOS_ROSEN_WINDOW_SCENE_FOLD_SCREEN_CONTROLLER_H
16 #define OHOS_ROSEN_WINDOW_SCENE_FOLD_SCREEN_CONTROLLER_H
17 
18 #include <refbase.h>
19 
20 #include "common/include/task_scheduler.h"
21 #include "fold_screen_controller/fold_screen_policy.h"
22 #include "fold_screen_controller/fold_screen_state_machine.h"
23 #include "fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.h"
24 #include "fold_screen_info.h"
25 
26 namespace OHOS::Rosen {
27 enum class DisplayDeviceType :uint32_t {
28     DISPLAY_DEVICE_UNKNOWN = 0,
29     SINGLE_DISPLAY_DEVICE,
30     DOUBLE_DISPLAY_DEVICE,
31     SINGLE_DISPLAY_POCKET_DEVICE,
32 };
33 
34 class FoldScreenController : public RefBase {
35 public:
36     FoldScreenController(std::recursive_mutex& displayInfoMutex,
37         std::shared_ptr<TaskScheduler> screenPowerTaskScheduler);
38     virtual ~FoldScreenController();
39 
40     void BootAnimationFinishPowerInit();
41     void SetDisplayMode(const FoldDisplayMode displayMode);
42     void RecoverDisplayMode();
43     FoldDisplayMode GetDisplayMode();
44     bool IsFoldable();
45     FoldStatus GetFoldStatus();
46     bool GetTentMode();
47     void SetFoldStatus(FoldStatus foldStatus);
48     void OnTentModeChanged(bool isTentMode);
49     sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion();
50     ScreenId GetCurrentScreenId();
51     void LockDisplayStatus(bool locked);
52     void SetOnBootAnimation(bool onBootAnimation);
53     void UpdateForPhyScreenPropertyChange();
54     void ExitCoordination();
55     void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command);
56     /*
57      *    Avoid fold to expand process queues public interface
58      */
59     bool GetModeChangeRunningStatus();
60     void SetdisplayModeChangeStatus(bool status);
61     bool GetdisplayModeRunningStatus();
62     FoldDisplayMode GetLastCacheDisplayMode();
63 private:
64     sptr<FoldScreenPolicy> GetFoldScreenPolicy(DisplayDeviceType productType);
65     sptr<FoldScreenPolicy> foldScreenPolicy_;
66     sptr<SensorFoldStateManager> sensorFoldStateManager_;
67     std::recursive_mutex& displayInfoMutex_;
68     std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
69 };
70 } // namespace OHOS::Rosen
71 #endif //OHOS_ROSEN_WINDOW_SCENE_FOLD_SCREEN_CONTROLLER_H