• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     ScreenId GetCurrentScreenId();
54     void LockDisplayStatus(bool locked);
55     void SetOnBootAnimation(bool onBootAnimation);
56     void UpdateForPhyScreenPropertyChange();
57     void ExitCoordination();
58     Drawing::Rect GetScreenSnapshotRect();
59     void SetMainScreenRegion(DMRect& mainScreenRegion);
60     bool GetCameraMode();
61     /*
62      *    Avoid fold to expand process queues public interface
63      */
64     bool GetModeChangeRunningStatus();
65     void SetdisplayModeChangeStatus(bool status);
66     bool GetdisplayModeRunningStatus();
67     FoldDisplayMode GetLastCacheDisplayMode();
68     void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command);
69 private:
70     sptr<FoldScreenPolicy> GetFoldScreenPolicy(DisplayDeviceType productType);
71     sptr<FoldScreenPolicy> foldScreenPolicy_;
72     sptr<SensorFoldStateManager> sensorFoldStateManager_;
73     std::recursive_mutex& displayInfoMutex_;
74     std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
75 };
76 } // namespace OHOS::Rosen
77 #endif //OHOS_ROSEN_WINDOW_SCENE_FOLD_SCREEN_CONTROLLER_H