1 /* 2 * Copyright (c) 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_IPC_SERVICE_H 17 #define OHOS_ROSEN_DISPLAY_MANAGER_IPC_SERVICE_H 18 19 #include <errors.h> 20 #include <system_ability.h> 21 #include <system_ability_definition.h> 22 #include "display_manager_service.h" 23 #include "display_manager_stub.h" 24 25 namespace OHOS::Rosen { 26 class DisplayManagerIpcService : public SystemAbility, public DisplayManagerStub { 27 DECLARE_SYSTEM_ABILITY(DisplayManagerIpcService); 28 WM_DECLARE_SINGLE_INSTANCE_BASE(DisplayManagerIpcService); 29 30 protected: 31 void OnStart() override; 32 void OnStop() override; 33 34 public: 35 int Dump(int fd, const std::vector<std::u16string>& args) override; 36 37 ErrCode GetDefaultDisplayInfo( 38 sptr<DisplayInfo>& displayInfo) override; 39 40 ErrCode GetDisplayInfoById( 41 uint64_t displayId, 42 sptr<DisplayInfo>& displayInfo) override; 43 44 ErrCode GetVisibleAreaDisplayInfoById( 45 uint64_t displayId, 46 sptr<DisplayInfo>& displayInfo) override; 47 48 ErrCode GetDisplayInfoByScreen( 49 uint64_t screenId, 50 sptr<DisplayInfo>& displayInfo) override; 51 52 ErrCode CreateVirtualScreen( 53 const DmVirtualScreenOption& virtualOption, 54 const sptr<IRemoteObject>& displayManagerAgent, 55 uint64_t& screenId) override; 56 57 ErrCode CreateVirtualScreen( 58 const DmVirtualScreenOption& virtualOption, 59 const sptr<IRemoteObject>& displayManagerAgent, 60 uint64_t& screenId, 61 const sptr<IBufferProducer>& surface) override; 62 63 ErrCode DestroyVirtualScreen( 64 uint64_t screenId, 65 int32_t& dmError) override; 66 67 ErrCode SetVirtualScreenSurface( 68 uint64_t screenId, 69 const sptr<IBufferProducer>& surface, 70 int32_t& dmError) override; 71 72 ErrCode SetOrientation( 73 uint64_t screenId, 74 uint32_t orientation, 75 int32_t& dmError) override; 76 77 ErrCode GetDisplaySnapshot( 78 uint64_t displayId, 79 int32_t& errorCode, 80 bool isUseDma, 81 bool isCaptureFullOfScreen, 82 std::shared_ptr<PixelMap>& pixelMap) override; 83 84 ErrCode GetScreenSupportedColorGamuts( 85 uint64_t screenId, 86 std::vector<uint32_t>& colorGamuts, 87 int32_t& dmError) override; 88 89 ErrCode GetScreenColorGamut( 90 uint64_t screenId, 91 uint32_t& colorGamut, 92 int32_t& dmError) override; 93 94 ErrCode SetScreenColorGamut( 95 uint64_t screenId, 96 int32_t colorGamutIdx, 97 int32_t& dmError) override; 98 99 ErrCode GetScreenGamutMap( 100 uint64_t screenId, 101 uint32_t& gamutMap, 102 int32_t& dmError) override; 103 104 ErrCode SetScreenGamutMap( 105 uint64_t screenId, 106 uint32_t gamutMap, 107 int32_t& dmError) override; 108 109 ErrCode SetScreenColorTransform( 110 uint64_t screenId) override; 111 112 ErrCode RegisterDisplayManagerAgent( 113 const sptr<IDisplayManagerAgent>& displayManagerAgent, 114 uint32_t type, 115 int32_t& dmError) override; 116 117 ErrCode UnregisterDisplayManagerAgent( 118 const sptr<IDisplayManagerAgent>& displayManagerAgent, 119 uint32_t type, 120 int32_t& dmError) override; 121 122 ErrCode WakeUpBegin( 123 uint32_t reason, 124 bool& isSucc) override; 125 126 ErrCode WakeUpEnd( 127 bool& isSucc) override; 128 129 ErrCode SuspendBegin( 130 uint32_t reason, 131 bool& isSucc) override; 132 133 ErrCode SuspendEnd( 134 bool& isSucc) override; 135 136 ErrCode SetScreenPowerForAll( 137 uint32_t screenPowerState, 138 uint32_t reason, 139 bool& isSucc) override; 140 141 ErrCode SetSpecifiedScreenPower( 142 uint64_t screenId, 143 uint32_t screenPowerState, 144 uint32_t reason, 145 bool& isSucc) override; 146 147 ErrCode GetScreenPower( 148 uint64_t dmsScreenId, 149 uint32_t& screenPowerState) override; 150 151 ErrCode SetDisplayState( 152 uint32_t displayState, 153 bool& isSucc) override; 154 155 ErrCode GetDisplayState( 156 uint64_t displayId, 157 uint32_t& displayState) override; 158 159 ErrCode TryToCancelScreenOff( 160 bool& isSucc) override; 161 162 ErrCode GetAllDisplayIds( 163 std::vector<uint64_t>& displayIds) override; 164 165 ErrCode GetCutoutInfo( 166 uint64_t displayId, 167 sptr<CutoutInfo>& cutoutInfo) override; 168 169 ErrCode AddSurfaceNodeToDisplay( 170 uint64_t displayId, 171 const std::shared_ptr<DmRsSurfaceNode>& dmRsSurfaceNode, 172 int32_t& dmError) override; 173 174 ErrCode RemoveSurfaceNodeFromDisplay( 175 uint64_t displayId, 176 const std::shared_ptr<DmRsSurfaceNode>& dmRsSurfaceNode, 177 int32_t& dmError) override; 178 179 ErrCode HasPrivateWindow( 180 uint64_t displayId, 181 bool& hasPrivateWindow, 182 int32_t& dmError) override; 183 184 ErrCode NotifyDisplayEvent( 185 uint32_t displayEvent) override; 186 187 ErrCode SetFreeze( 188 const std::vector<uint64_t>& displayIds, 189 bool isFreeze, 190 bool& isSucc) override; 191 192 ErrCode MakeMirror( 193 uint64_t mainScreenId, 194 const std::vector<uint64_t>& mirrorScreenId, 195 uint64_t& screenGroupId, 196 int32_t& dmError) override; 197 198 ErrCode StopMirror( 199 const std::vector<uint64_t>& mirrorScreenIds, 200 int32_t& dmError) override; 201 202 ErrCode GetScreenInfoById( 203 uint64_t screenId, 204 sptr<ScreenInfo>& screenInfo) override; 205 206 ErrCode GetScreenGroupInfoById( 207 uint64_t screenId, 208 sptr<ScreenGroupInfo>& screenGroupInfo) override; 209 210 ErrCode GetAllScreenInfos( 211 std::vector<sptr<ScreenInfo>>& screenInfos, 212 int32_t& dmError) override; 213 214 ErrCode MakeExpand( 215 const std::vector<uint64_t>& screenId, 216 const std::vector<Point>& startPoint, 217 uint64_t& screenGroupId, 218 int32_t& dmError) override; 219 220 ErrCode StopExpand( 221 const std::vector<uint64_t>& expandScreenIds, 222 int32_t& dmError) override; 223 224 ErrCode RemoveVirtualScreenFromGroup( 225 const std::vector<uint64_t>& screens) override; 226 227 ErrCode SetScreenActiveMode( 228 uint64_t screenId, 229 uint32_t modeId, 230 int32_t& dmError) override; 231 232 ErrCode SetVirtualPixelRatio( 233 uint64_t screenId, 234 float virtualPixelRatio, 235 int32_t& dmError) override; 236 237 ErrCode SetResolution( 238 uint64_t screenId, 239 uint32_t width, 240 uint32_t height, 241 float virtualPixelRatio, 242 int32_t& dmError) override; 243 244 ErrCode GetDensityInCurResolution( 245 uint64_t screenId, 246 float& virtualPixelRatio, 247 int32_t& dmError) override; 248 249 ErrCode IsScreenRotationLocked( 250 bool& isLocked, 251 int32_t& dmError) override; 252 253 ErrCode SetScreenRotationLocked( 254 bool isLocked, 255 int32_t& dmError) override; 256 257 ErrCode SetScreenRotationLockedFromJs( 258 bool isLocked, 259 int32_t& dmError) override; 260 261 ErrCode GetAllDisplayPhysicalResolution( 262 std::vector<DisplayPhysicalResolution>& displayPhysicalResolutions) override; 263 264 ErrCode SetScreenBrightness( 265 uint64_t screenId, 266 uint32_t level, 267 bool& isSucc) override; 268 269 ErrCode GetScreenBrightness( 270 uint64_t screenId, 271 uint32_t& level) override; 272 273 ErrCode SetVirtualScreenAsDefault( 274 uint64_t screenId, 275 bool& isSucc) override; 276 277 private: 278 DisplayManagerIpcService(); 279 280 static inline SingletonDelegator<DisplayManagerIpcService> delegator_; 281 DisplayManagerService& displayManagerService_; 282 }; 283 } // namespace OHOS::Rosen 284 #endif // OHOS_ROSEN_DISPLAY_MANAGER_IPC_SERVICE_H 285