• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 ACCESSIBILITY_DISPLAY_MANAGER_H
17 #define ACCESSIBILITY_DISPLAY_MANAGER_H
18 
19 #include <memory>
20 #include "display_manager.h"
21 #include "display_info.h"
22 #include "dm_common.h"
23 #include "event_handler.h"
24 #include "singleton.h"
25 #include "magnification_manager.h"
26 
27 namespace OHOS {
28 namespace Accessibility {
29 class AccessibilityDisplayManager {
30     DECLARE_SINGLETON(AccessibilityDisplayManager)
31 public:
32     const sptr<Rosen::Display> GetDisplay(uint64_t id);
33     std::vector<sptr<Rosen::Display>> GetDisplays();
34     const sptr<Rosen::Display> GetDefaultDisplay();
35     uint64_t GetDefaultDisplayId();
36     int32_t GetDefaultDisplayDpi();
37     sptr<Rosen::Display> GetDefaultDisplaySync();
38     int32_t GetWidth();
39     int32_t GetHeight();
40     OHOS::Rosen::DisplayOrientation GetOrientation();
41     bool IsFoldable();
42     Rosen::FoldDisplayMode GetFoldDisplayMode();
43     Rosen::FoldStatus GetFoldStatus();
44     void SetDisplayScale(const uint64_t screenId, float scaleX, float scaleY, float pivotX, float pivotY);
45 
46     void RegisterDisplayListener(const std::shared_ptr<MagnificationManager> &manager);
47     void UnregisterDisplayListener();
48     RotationType GetRotationType(Rosen::DisplayOrientation prev, Rosen::DisplayOrientation curr);
49 private:
50     class DisplayListener : public Rosen::DisplayManager::IDisplayListener {
51     public:
DisplayListener(const std::shared_ptr<MagnificationManager> & manager)52         explicit DisplayListener(const std::shared_ptr<MagnificationManager> &manager)
53             : manager_(manager) {}
54         ~DisplayListener() = default;
55 
OnCreate(Rosen::DisplayId dId)56         virtual void OnCreate(Rosen::DisplayId dId) override {}
OnDestroy(Rosen::DisplayId dId)57         virtual void OnDestroy(Rosen::DisplayId dId) override {}
58         virtual void OnChange(Rosen::DisplayId dId) override;
59 
60         void OnChangeForWideFold(OHOS::Rosen::DisplayOrientation currentOrientation,
61             OHOS::Rosen::FoldDisplayMode currentMode);
62         void OnChangeForBigFold(OHOS::Rosen::DisplayOrientation currentOrientation,
63             OHOS::Rosen::FoldDisplayMode currentMode);
64         void OnChangeDefault(OHOS::Rosen::DisplayOrientation currentOrientation);
65         OHOS::Rosen::DisplayOrientation orientation_ = OHOS::Rosen::DisplayOrientation::UNKNOWN;
66         OHOS::Rosen::FoldDisplayMode displayMode_ = Rosen::FoldDisplayMode::UNKNOWN;
67     private:
68         std::shared_ptr<MagnificationManager> manager_ = nullptr;
69     };
70 
71     sptr<DisplayListener> listener_ = nullptr;
72     std::shared_ptr<AppExecFwk::EventHandler> handler_ = nullptr;
73 };
74 } // namespace Accessibility
75 } // namespace OHOS
76 #endif // ACCESSIBILITY_DISPLAY_MANAGER_H