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_DUAL_DISPLAY_POLICY_H
16 #define OHOS_ROSEN_WINDOW_SCENE_DUAL_DISPLAY_POLICY_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_info.h"
23 #include "session/screen/include/screen_session.h"
24 
25 namespace OHOS::Rosen {
26 class DualDisplayFoldPolicy : public FoldScreenPolicy {
27 public:
28     DualDisplayFoldPolicy(std::recursive_mutex& displayInfoMutex,
29         std::shared_ptr<TaskScheduler> screenPowerTaskScheduler);
30     ~DualDisplayFoldPolicy() = default;
31     void ChangeScreenDisplayMode(FoldDisplayMode displayMode,
32         DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT) override;
33     void SendSensorResult(FoldStatus foldStatus) override;
34     sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() override;
35     void LockDisplayStatus(bool locked) override;
36     void SetOnBootAnimation(bool onBootAnimation) override;
37     void UpdateForPhyScreenPropertyChange() override;
38     void ExitCoordination() override;
39     void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command) override;
40     FoldDisplayMode GetModeMatchStatus() override;
41 
42 private:
43     bool CheckDisplayMode(FoldDisplayMode displayMode);
44     void ChangeScreenDisplayModeInner(sptr<ScreenSession> screenSession, ScreenId offScreenId, ScreenId onScreenId);
45     void ChangeScreenDisplayModeOnBootAnimation(sptr<ScreenSession> screenSession, ScreenId screenId);
46     void ChangeScreenDisplayModeToCoordination();
47     void RecoverWhenBootAnimationExit();
48     void ReportFoldDisplayModeChange(FoldDisplayMode displayMode);
49     void ReportFoldStatusChangeBegin(int32_t offScreen, int32_t onScreen);
50     void SetdisplayModeChangeStatus(bool status, bool isOnBootAnimation = false) override;
51     ScreenId GetScreenIdByDisplayMode(FoldDisplayMode displayMode);
52     std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
53 };
54 } // namespace OHOS::Rosen
55 #endif //OHOS_ROSEN_WINDOW_SCENE_DUAL_DISPLAY_DEVICE_POLICY_H