• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 OHOS_ROSEN_DISPLAY_MANAGER_LITE_PROXY_H
17 #define OHOS_ROSEN_DISPLAY_MANAGER_LITE_PROXY_H
18 
19 #include <iremote_broker.h>
20 #include <iremote_proxy.h>
21 #include "cutout_info.h"
22 #include "display_info.h"
23 #include "dm_common.h"
24 #include "window_manager_hilog.h"
25 #include "zidl/idisplay_manager_agent.h"
26 
27 namespace OHOS::Rosen {
28 class DisplayManagerLiteProxy : public IRemoteBroker {
29 public:
30 #ifdef SCENE_BOARD_ENABLED
31     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IScreenSessionManager");
32 #else
33     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Rosen.IDisplayManager"); // generated by IDisplayManager.idl
34 #endif
35 
DisplayManagerLiteProxy(const sptr<IRemoteObject> & impl)36     explicit DisplayManagerLiteProxy(const sptr<IRemoteObject>& impl) : remoteObject(impl) {}
37 
AsObject()38     sptr<IRemoteObject> AsObject() override
39     {
40         return remoteObject;
41     }
42 
43     DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
44         DisplayManagerAgentType type);
45     DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
46         DisplayManagerAgentType type);
47 
48     FoldDisplayMode GetFoldDisplayMode();
49     void SetFoldDisplayMode(const FoldDisplayMode displayMode);
50     void SetFoldDisplayModeAsync(const FoldDisplayMode displayMode);
51     bool IsFoldable();
52     FoldStatus GetFoldStatus();
53     sptr<DisplayInfo> GetDefaultDisplayInfo();
54     sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId);
55     sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId);
56     VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId);
57     /*
58      * used by powermgr
59      */
60     bool WakeUpBegin(PowerStateChangeReason reason);
61     bool WakeUpEnd();
62     bool SuspendBegin(PowerStateChangeReason reason);
63     bool SuspendEnd();
64     ScreenId GetInternalScreenId();
65     bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason);
66     bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason);
67     bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason);
68     ScreenPowerState GetScreenPower(ScreenId dmsScreenId);
69     ScreenPowerState GetScreenPower();
70     bool SetDisplayState(DisplayState state);
71     DisplayState GetDisplayState(DisplayId displayId);
72     bool TryToCancelScreenOff();
73     bool SetScreenBrightness(uint64_t screenId, uint32_t level);
74     uint32_t GetScreenBrightness(uint64_t screenId);
75     std::vector<DisplayId> GetAllDisplayIds();
76     DMError GetPhysicalScreenIds(std::vector<ScreenId>& screenIds);
77     DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos);
78     DMError SetSystemKeyboardStatus(bool isTpKeyboardOn = false);
79     sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId);
80     bool GetKeyboardState();
81     bool SynchronizePowerStatus(ScreenPowerState state);
82 private:
83     static inline DMError ConvertToDMError(ErrCode errCode, int32_t dmError);
Remote()84     sptr<IRemoteObject> Remote()
85     {
86         return remoteObject;
87     }
88     sptr<IRemoteObject> remoteObject = nullptr;
89 
90 #ifndef SCENE_BOARD_ENABLED
91     // generated by IDisplayManager.idl
92     enum class IDisplayManagerIpcCode {
93         COMMAND_GET_DEFAULT_DISPLAY_INFO = MIN_TRANSACTION_ID,
94         COMMAND_GET_DISPLAY_INFO_BY_ID,
95         COMMAND_GET_VISIBLE_AREA_DISPLAY_INFO_BY_ID,
96         COMMAND_GET_DISPLAY_INFO_BY_SCREEN,
97         COMMAND_CREATE_VIRTUAL_SCREEN,
98         COMMAND_CREATE_VIRTUAL_SCREEN_IN_VIRTUALSCREENOPTION_IN_IREMOTEOBJECT_OUT_UNSIGNED_LONG_IN_IBUFFERPRODUCER,
99         COMMAND_DESTROY_VIRTUAL_SCREEN,
100         COMMAND_SET_VIRTUAL_SCREEN_SURFACE,
101         COMMAND_SET_ORIENTATION,
102         COMMAND_GET_DISPLAY_SNAPSHOT,
103         COMMAND_GET_SCREEN_SUPPORTED_COLOR_GAMUTS,
104         COMMAND_GET_SCREEN_COLOR_GAMUT,
105         COMMAND_SET_SCREEN_COLOR_GAMUT,
106         COMMAND_GET_SCREEN_GAMUT_MAP,
107         COMMAND_SET_SCREEN_GAMUT_MAP,
108         COMMAND_SET_SCREEN_COLOR_TRANSFORM,
109         COMMAND_REGISTER_DISPLAY_MANAGER_AGENT,
110         COMMAND_UNREGISTER_DISPLAY_MANAGER_AGENT,
111         COMMAND_WAKE_UP_BEGIN,
112         COMMAND_WAKE_UP_END,
113         COMMAND_SUSPEND_BEGIN,
114         COMMAND_SUSPEND_END,
115         COMMAND_SET_SCREEN_POWER_FOR_ALL,
116         COMMAND_SET_SPECIFIED_SCREEN_POWER,
117         COMMAND_GET_SCREEN_POWER,
118         COMMAND_SET_DISPLAY_STATE,
119         COMMAND_GET_DISPLAY_STATE,
120         COMMAND_TRY_TO_CANCEL_SCREEN_OFF,
121         COMMAND_GET_ALL_DISPLAY_IDS,
122         COMMAND_GET_CUTOUT_INFO,
123         COMMAND_ADD_SURFACE_NODE_TO_DISPLAY,
124         COMMAND_REMOVE_SURFACE_NODE_FROM_DISPLAY,
125         COMMAND_HAS_PRIVATE_WINDOW,
126         COMMAND_NOTIFY_DISPLAY_EVENT,
127         COMMAND_SET_FREEZE,
128         COMMAND_MAKE_MIRROR,
129         COMMAND_STOP_MIRROR,
130         COMMAND_GET_SCREEN_INFO_BY_ID,
131         COMMAND_GET_SCREEN_GROUP_INFO_BY_ID,
132         COMMAND_GET_ALL_SCREEN_INFOS,
133         COMMAND_MAKE_EXPAND,
134         COMMAND_STOP_EXPAND,
135         COMMAND_REMOVE_VIRTUAL_SCREEN_FROM_GROUP,
136         COMMAND_SET_SCREEN_ACTIVE_MODE,
137         COMMAND_SET_VIRTUAL_PIXEL_RATIO,
138         COMMAND_SET_RESOLUTION,
139         COMMAND_GET_DENSITY_IN_CUR_RESOLUTION,
140         COMMAND_IS_SCREEN_ROTATION_LOCKED,
141         COMMAND_SET_SCREEN_ROTATION_LOCKED,
142         COMMAND_SET_SCREEN_ROTATION_LOCKED_FROM_JS,
143         COMMAND_GET_ALL_DISPLAY_PHYSICAL_RESOLUTION,
144         COMMAND_SET_SCREEN_BRIGHTNESS,
145         COMMAND_GET_SCREEN_BRIGHTNESS,
146     };
147 
148     // generated by IDisplayManagerLite.idl
149     static constexpr int VECTOR_MAX_SIZE = 102400;
150 
151     ErrCode RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent, uint32_t type,
152         int32_t& dmError);
153     ErrCode UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent, uint32_t type,
154     int32_t& dmError);
155     ErrCode GetDefaultDisplayInfo(sptr<DisplayInfo>& displayInfo);
156     ErrCode GetDisplayInfoById(uint64_t displayId, sptr<DisplayInfo>& displayInfo);
157     ErrCode GetCutoutInfo(uint64_t displayId, sptr<CutoutInfo>& cutoutInfo);
158     ErrCode WakeUpBegin(uint32_t reason, bool& isSucc);
159     ErrCode WakeUpEnd(bool& isSucc);
160     ErrCode SuspendBegin(uint32_t reason, bool& isSucc);
161     ErrCode SuspendEnd(bool& isSucc);
162     ErrCode SetSpecifiedScreenPower(uint64_t screenId, uint32_t screenPowerState, uint32_t reason, bool& isSucc);
163     ErrCode SetScreenPowerForAll(uint32_t screenPowerState, uint32_t reason, bool& isSucc);
164     ErrCode GetScreenPower(uint64_t dmsScreenId, uint32_t& screenPowerState);
165     ErrCode SetDisplayState(uint32_t displayState, bool& isSucc);
166     ErrCode GetDisplayState(uint64_t displayId, uint32_t& displayState);
167     ErrCode TryToCancelScreenOff(bool& isSucc);
168     ErrCode GetAllDisplayIds(std::vector<uint64_t>& displayIds);
169     ErrCode GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos, int32_t& dmError);
170     ErrCode GetScreenInfoById(uint64_t screenId, sptr<ScreenInfo>& screenInfo);
171     ErrCode SetScreenBrightness(uint64_t screenId, uint32_t level, bool& isSucc);
172     ErrCode GetScreenBrightness(uint64_t screenId, uint32_t& level);
173 #endif
174 };
175 } // namespace OHOS::Rosen
176 
177 #endif // OHOS_ROSEN_DISPLAY_MANAGER_LITE_PROXY_H
178