* Copyright (c) 2024-2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ROSEN_DISPLAY_MANAGER_LITE_PROXY_H
#define OHOS_ROSEN_DISPLAY_MANAGER_LITE_PROXY_H
#include <iremote_broker.h>
#include <iremote_proxy.h>
#include "cutout_info.h"
#include "display_info.h"
#include "dm_common.h"
#include "fold_screen_info.h"
#include "window_manager_hilog.h"
#include "zidl/idisplay_manager_agent.h"
namespace OHOS::Rosen {
class DisplayManagerLiteProxy : public IRemoteBroker {
public:
#ifdef SCENE_BOARD_ENABLED
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IScreenSessionManager");
#else
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Rosen.IDisplayManager");
#endif
explicit DisplayManagerLiteProxy(const sptr<IRemoteObject>& impl) : remoteObject(impl) {}
sptr<IRemoteObject> AsObject() override
{
return remoteObject;
}
DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type);
DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type);
DMError RegisterDisplayAttributeAgent(const std::vector<std::string>& attributes,
const sptr<IDisplayManagerAgent>& displayManagerAgent);
DMError UnregisterDisplayAttribute(const std::vector<std::string>& attributes,
const sptr<IDisplayManagerAgent>& displayManagerAgent);
FoldDisplayMode GetFoldDisplayMode();
void SetFoldDisplayMode(const FoldDisplayMode displayMode);
bool IsFoldable();
FoldStatus GetFoldStatus();
sptr<DisplayInfo> GetDefaultDisplayInfo(int32_t userId = CONCURRENT_USER_ID_DEFAULT);
sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId);
sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId);
VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId);
* used by powermgr
*/
bool WakeUpBegin(PowerStateChangeReason reason);
bool WakeUpEnd();
bool SuspendBegin(PowerStateChangeReason reason);
bool SuspendEnd();
DMError SetScreenSwitchState(ScreenClosedState screenClosedState, bool isScreenOn);
ScreenId GetInternalScreenId();
bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason);
bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason);
bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason);
ScreenPowerState GetScreenPower(ScreenId dmsScreenId);
ScreenPowerState GetScreenPower();
void SyncScreenPowerState(ScreenPowerState state);
bool SetDisplayState(DisplayState state);
DisplayState GetDisplayState(DisplayId displayId);
bool TryToCancelScreenOff();
bool SetScreenBrightness(const DmsScreenBrightnessData& brightnessData);
virtual bool RegisterClientDeathListener(sptr<IRemoteObject> reverseDeathObject);
uint32_t GetScreenBrightness(uint64_t screenId);
std::vector<DisplayId> GetAllDisplayIds(int32_t userId = CONCURRENT_USER_ID_DEFAULT);
DMError GetPhysicalScreenIds(std::vector<ScreenId>& screenIds);
DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos);
DMError SetSystemKeyboardStatus(bool isTpKeyboardOn = false);
DMError IsOnboardDisplay(DisplayId displayId, bool& isOnboardDisplay);
sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId);
bool GetKeyboardState();
bool SynchronizePowerStatus(ScreenPowerState state);
DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio);
sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion();
void NotifyBootAnimationFinished();
private:
static inline DMError ConvertToDMError(ErrCode errCode, int32_t dmError);
sptr<IRemoteObject> Remote()
{
return remoteObject;
}
sptr<IRemoteObject> remoteObject = nullptr;
static constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerLiteProxy"};
#ifndef SCENE_BOARD_ENABLED
enum class IDisplayManagerIpcCode {
COMMAND_GET_DEFAULT_DISPLAY_INFO = MIN_TRANSACTION_ID,
COMMAND_GET_DISPLAY_INFO_BY_ID,
COMMAND_GET_VISIBLE_AREA_DISPLAY_INFO_BY_ID,
COMMAND_GET_DISPLAY_INFO_BY_SCREEN,
COMMAND_CREATE_VIRTUAL_SCREEN,
COMMAND_CREATE_VIRTUAL_SCREEN_IN_VIRTUALSCREENOPTION_IN_IREMOTEOBJECT_OUT_UNSIGNED_LONG_IN_IBUFFERPRODUCER,
COMMAND_DESTROY_VIRTUAL_SCREEN,
COMMAND_SET_VIRTUAL_SCREEN_SURFACE,
COMMAND_SET_ORIENTATION,
COMMAND_GET_DISPLAY_SNAPSHOT,
COMMAND_GET_SCREEN_SUPPORTED_COLOR_GAMUTS,
COMMAND_GET_SCREEN_COLOR_GAMUT,
COMMAND_SET_SCREEN_COLOR_GAMUT,
COMMAND_GET_SCREEN_GAMUT_MAP,
COMMAND_SET_SCREEN_GAMUT_MAP,
COMMAND_SET_SCREEN_COLOR_TRANSFORM,
COMMAND_REGISTER_DISPLAY_MANAGER_AGENT,
COMMAND_UNREGISTER_DISPLAY_MANAGER_AGENT,
COMMAND_WAKE_UP_BEGIN,
COMMAND_WAKE_UP_END,
COMMAND_SUSPEND_BEGIN,
COMMAND_SUSPEND_END,
COMMAND_SET_SCREEN_POWER_FOR_ALL,
COMMAND_SET_SPECIFIED_SCREEN_POWER,
COMMAND_GET_SCREEN_POWER,
COMMAND_SET_DISPLAY_STATE,
COMMAND_GET_DISPLAY_STATE,
COMMAND_TRY_TO_CANCEL_SCREEN_OFF,
COMMAND_GET_ALL_DISPLAY_IDS,
COMMAND_GET_CUTOUT_INFO,
COMMAND_ADD_SURFACE_NODE_TO_DISPLAY,
COMMAND_REMOVE_SURFACE_NODE_FROM_DISPLAY,
COMMAND_HAS_PRIVATE_WINDOW,
COMMAND_NOTIFY_DISPLAY_EVENT,
COMMAND_SET_FREEZE,
COMMAND_MAKE_MIRROR,
COMMAND_STOP_MIRROR,
COMMAND_GET_SCREEN_INFO_BY_ID,
COMMAND_GET_SCREEN_GROUP_INFO_BY_ID,
COMMAND_GET_ALL_SCREEN_INFOS,
COMMAND_MAKE_EXPAND,
COMMAND_STOP_EXPAND,
COMMAND_REMOVE_VIRTUAL_SCREEN_FROM_GROUP,
COMMAND_SET_SCREEN_ACTIVE_MODE,
COMMAND_SET_VIRTUAL_PIXEL_RATIO,
COMMAND_SET_RESOLUTION,
COMMAND_GET_DENSITY_IN_CUR_RESOLUTION,
COMMAND_IS_SCREEN_ROTATION_LOCKED,
COMMAND_SET_SCREEN_ROTATION_LOCKED,
COMMAND_SET_SCREEN_ROTATION_LOCKED_FROM_JS,
COMMAND_GET_ALL_DISPLAY_PHYSICAL_RESOLUTION,
COMMAND_SET_SCREEN_BRIGHTNESS,
COMMAND_GET_SCREEN_BRIGHTNESS,
};
static constexpr int VECTOR_MAX_SIZE = 102400;
ErrCode RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent, uint32_t type,
int32_t& dmError);
ErrCode UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent, uint32_t type,
int32_t& dmError);
ErrCode GetDefaultDisplayInfo(sptr<DisplayInfo>& displayInfo);
ErrCode GetDisplayInfoById(uint64_t displayId, sptr<DisplayInfo>& displayInfo);
ErrCode GetCutoutInfo(uint64_t displayId, sptr<CutoutInfo>& cutoutInfo);
ErrCode WakeUpBegin(uint32_t reason, bool& isSucc);
ErrCode WakeUpEnd(bool& isSucc);
ErrCode SuspendBegin(uint32_t reason, bool& isSucc);
ErrCode SuspendEnd(bool& isSucc);
ErrCode SetSpecifiedScreenPower(uint64_t screenId, uint32_t screenPowerState, uint32_t reason, bool& isSucc);
ErrCode SetScreenPowerForAll(uint32_t screenPowerState, uint32_t reason, bool& isSucc);
ErrCode GetScreenPower(uint64_t dmsScreenId, uint32_t& screenPowerState);
ErrCode SetDisplayState(uint32_t displayState, bool& isSucc);
ErrCode GetDisplayState(uint64_t displayId, uint32_t& displayState);
ErrCode TryToCancelScreenOff(bool& isSucc);
ErrCode GetAllDisplayIds(std::vector<uint64_t>& displayIds);
ErrCode GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos, int32_t& dmError);
ErrCode GetScreenInfoById(uint64_t screenId, sptr<ScreenInfo>& screenInfo);
ErrCode SetScreenBrightness(const DmsScreenBrightnessData& brightnessData, bool& isSucc);
ErrCode GetScreenBrightness(uint64_t screenId, uint32_t& level);
#endif
};
}
#endif