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_SINGLE_DISPLAY_DEVICE_POLICY_H
16 #define OHOS_ROSEN_WINDOW_SCENE_SINGLE_DISPLAY_DEVICE_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 SingleDisplayFoldPolicy : public FoldScreenPolicy {
27 public:
28     SingleDisplayFoldPolicy(std::recursive_mutex& displayInfoMutex,
29         std::shared_ptr<TaskScheduler> screenPowerTaskScheduler);
30     ~SingleDisplayFoldPolicy() = 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;
ExitCoordination()38     void ExitCoordination() override {};
AddOrRemoveDisplayNodeToTree(ScreenId screenId,int32_t command)39     void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command) override {};
40     FoldDisplayMode GetModeMatchStatus() override;
41 private:
42     void ChangeScreenDisplayModeToMain(sptr<ScreenSession> screenSession,
43         DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT);
44     void ChangeScreenDisplayModeToFull(sptr<ScreenSession> screenSession,
45         DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT);
46     void ChangeScreenDisplayModeToMainWhenFoldScreenOn(sptr<ScreenSession> screenSession);
47     void ChangeScreenDisplayModeToMainWhenFoldScreenOff(sptr<ScreenSession> screenSession);
48     void ChangeScreenDisplayModeToFullWhenFoldScreenOn(sptr<ScreenSession> screenSession);
49     void ChangeScreenDisplayModeToFullWhenFoldScreenOff(sptr<ScreenSession> screenSession,
50         DisplayModeChangeReason reason);
51     void ChangeScreenDisplayModeToMainOnBootAnimation(sptr<ScreenSession> screenSession);
52     void ChangeScreenDisplayModeToFullOnBootAnimation(sptr<ScreenSession> screenSession);
53     void ChangeScreenDisplayModePower(ScreenId screenId, ScreenPowerStatus screenPowerStatus);
54     void RecoverWhenBootAnimationExit();
55     void ReportFoldDisplayModeChange(FoldDisplayMode displayMode);
56     void ReportFoldStatusChangeBegin(int32_t offScreen, int32_t onScreen);
57     void SendPropertyChangeResult(sptr<ScreenSession> screenSession, ScreenId screenId,
58         ScreenPropertyChangeReason reason);
59     void SetdisplayModeChangeStatus(bool status, bool isOnBootAnimation = false) override;
60     std::recursive_mutex& displayInfoMutex_;
61     std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_;
62 };
63 } // namespace OHOS::Rosen
64 #endif //OHOS_ROSEN_WINDOW_SCENE_SINGLE_DISPLAY_DEVICE_POLICY_H