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 26 namespace OHOS { 27 namespace Accessibility { 28 class AccessibilityDisplayManager { 29 DECLARE_SINGLETON(AccessibilityDisplayManager) 30 public: 31 const sptr<Rosen::Display> GetDisplay(uint64_t id); 32 std::vector<sptr<Rosen::Display>> GetDisplays(); 33 const sptr<Rosen::Display> GetDefaultDisplay(); 34 uint64_t GetDefaultDisplayId(); 35 int32_t GetDefaultDisplayDpi(); 36 sptr<Rosen::Display> GetDefaultDisplaySync(); 37 int32_t GetWidth(); 38 int32_t GetHeight(); 39 OHOS::Rosen::DisplayOrientation GetOrientation(); 40 bool IsFoldable(); 41 Rosen::FoldDisplayMode GetFoldDisplayMode(); 42 Rosen::FoldStatus GetFoldStatus(); 43 void SetDisplayScale(const uint64_t screenId, float scaleX, float scaleY, float pivotX, float pivotY); 44 45 void RegisterDisplayListener(const std::shared_ptr<AppExecFwk::EventHandler> &handler); 46 void UnregisterDisplayListener(); 47 48 private: 49 class DisplayListener : public Rosen::DisplayManager::IDisplayListener { 50 public: DisplayListener()51 explicit DisplayListener() {} 52 ~DisplayListener() = default; 53 OnCreate(Rosen::DisplayId dId)54 virtual void OnCreate(Rosen::DisplayId dId) override {} OnDestroy(Rosen::DisplayId dId)55 virtual void OnDestroy(Rosen::DisplayId dId) override {} OnChange(Rosen::DisplayId dId)56 virtual void OnChange(Rosen::DisplayId dId) override {} 57 }; 58 59 sptr<DisplayListener> listener_ = nullptr; 60 std::shared_ptr<AppExecFwk::EventHandler> handler_ = nullptr; 61 }; 62 } // namespace Accessibility 63 } // namespace OHOS 64 #endif // ACCESSIBILITY_DISPLAY_MANAGER_H