• 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 "event_handler.h"
22 #include "singleton.h"
23 
24 namespace OHOS {
25 namespace Accessibility {
26 class AccessibilityDisplayManager {
27     DECLARE_SINGLETON(AccessibilityDisplayManager)
28 public:
29     const sptr<Rosen::Display> GetDisplay(uint64_t id);
30     std::vector<sptr<Rosen::Display>> GetDisplays();
31     const sptr<Rosen::Display> GetDefaultDisplay();
32     uint64_t GetDefaultDisplayId();
33 
34     void RegisterDisplayListener(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
35     void UnregisterDisplayListener();
36 
37 private:
38     class DisplayListener : public Rosen::DisplayManager::IDisplayListener {
39     public:
DisplayListener()40         explicit DisplayListener() {}
41         ~DisplayListener() = default;
42 
OnCreate(Rosen::DisplayId dId)43         virtual void OnCreate(Rosen::DisplayId dId) override {}
OnDestroy(Rosen::DisplayId dId)44         virtual void OnDestroy(Rosen::DisplayId dId) override {}
OnChange(Rosen::DisplayId dId)45         virtual void OnChange(Rosen::DisplayId dId) override {}
46     };
47 
48     sptr<DisplayListener> listener_ = nullptr;
49     std::shared_ptr<AppExecFwk::EventHandler> handler_ = nullptr;
50 };
51 } // namespace Accessibility
52 } // namespace OHOS
53 #endif // ACCESSIBILITY_DISPLAY_MANAGER_H