mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 15:00:12 +00:00
errorcode fix
Signed-off-by: ac__fancheyu <liuyangyang58@huawei.com> Change-Id: Ibc6876d7a38645649203484e7c384c708ed6c3cc
This commit is contained in:
parent
7d5bfbe894
commit
4db09c47a3
@ -30,9 +30,9 @@
|
||||
namespace OHOS::Rosen {
|
||||
class BaseAdapter {
|
||||
public:
|
||||
virtual bool RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
virtual DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type);
|
||||
virtual bool UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
virtual DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type);
|
||||
virtual void Clear();
|
||||
protected:
|
||||
@ -82,17 +82,17 @@ public:
|
||||
virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);
|
||||
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason);
|
||||
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId);
|
||||
virtual bool SetOrientation(ScreenId screenId, Orientation orientation);
|
||||
virtual DMError SetOrientation(ScreenId screenId, Orientation orientation);
|
||||
virtual sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId);
|
||||
virtual std::vector<sptr<ScreenInfo>> GetAllScreenInfos();
|
||||
virtual ScreenId MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId);
|
||||
virtual ScreenId MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint);
|
||||
virtual DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos);
|
||||
virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId, ScreenId& screenGroupId);
|
||||
virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint, ScreenId& screenGroupId);
|
||||
virtual void RemoveVirtualScreenFromGroup(std::vector<ScreenId>);
|
||||
virtual bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId);
|
||||
virtual DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId);
|
||||
virtual sptr<ScreenInfo> GetScreenInfo(ScreenId screenId);
|
||||
virtual bool SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio);
|
||||
virtual void SetScreenRotationLocked(bool isLocked);
|
||||
virtual bool IsScreenRotationLocked();
|
||||
virtual DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio);
|
||||
virtual DMError SetScreenRotationLocked(bool isLocked);
|
||||
virtual DMError IsScreenRotationLocked(bool& isLocked);
|
||||
|
||||
// colorspace, gamut
|
||||
virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts);
|
||||
|
@ -44,13 +44,13 @@ public:
|
||||
sptr<Display> GetDefaultDisplaySync();
|
||||
sptr<Display> GetDisplayById(DisplayId displayId);
|
||||
DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow);
|
||||
bool RegisterDisplayListener(sptr<IDisplayListener> listener);
|
||||
bool UnregisterDisplayListener(sptr<IDisplayListener> listener);
|
||||
DMError RegisterDisplayListener(sptr<IDisplayListener> listener);
|
||||
DMError UnregisterDisplayListener(sptr<IDisplayListener> listener);
|
||||
bool SetDisplayState(DisplayState state, DisplayStateCallback callback);
|
||||
bool RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener);
|
||||
bool UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener);
|
||||
bool RegisterScreenshotListener(sptr<IScreenshotListener> listener);
|
||||
bool UnregisterScreenshotListener(sptr<IScreenshotListener> listener);
|
||||
DMError RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener);
|
||||
DMError UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener);
|
||||
DMError RegisterScreenshotListener(sptr<IScreenshotListener> listener);
|
||||
DMError UnregisterScreenshotListener(sptr<IScreenshotListener> listener);
|
||||
sptr<Display> GetDisplayByScreenId(ScreenId screenId);
|
||||
void OnRemoteDied();
|
||||
private:
|
||||
@ -243,22 +243,22 @@ void DisplayManager::Impl::ClearDisplayStateCallback()
|
||||
void DisplayManager::Impl::Clear()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
bool res = true;
|
||||
DMError res = DMError::DM_OK;
|
||||
if (displayManagerListener_ != nullptr) {
|
||||
res = SingletonContainer::Get<DisplayManagerAdapter>().UnregisterDisplayManagerAgent(
|
||||
displayManagerListener_, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER);
|
||||
}
|
||||
displayManagerListener_ = nullptr;
|
||||
if (!res) {
|
||||
if (res != DMError::DM_OK) {
|
||||
WLOGFW("UnregisterDisplayManagerAgent DISPLAY_EVENT_LISTENER failed !");
|
||||
}
|
||||
res = true;
|
||||
res = DMError::DM_OK;
|
||||
if (powerEventListenerAgent_ != nullptr) {
|
||||
res = SingletonContainer::Get<DisplayManagerAdapter>().UnregisterDisplayManagerAgent(
|
||||
powerEventListenerAgent_, DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER);
|
||||
}
|
||||
powerEventListenerAgent_ = nullptr;
|
||||
if (!res) {
|
||||
if (res != DMError::DM_OK) {
|
||||
WLOGFW("UnregisterDisplayManagerAgent DISPLAY_POWER_EVENT_LISTENER failed !");
|
||||
}
|
||||
ClearDisplayStateCallback();
|
||||
@ -479,17 +479,17 @@ DMError DisplayManager::Impl::HasPrivateWindow(DisplayId displayId, bool& hasPri
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().HasPrivateWindow(displayId, hasPrivateWindow);
|
||||
}
|
||||
|
||||
bool DisplayManager::Impl::RegisterDisplayListener(sptr<IDisplayListener> listener)
|
||||
DMError DisplayManager::Impl::RegisterDisplayListener(sptr<IDisplayListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
bool ret = true;
|
||||
DMError ret = DMError::DM_OK;
|
||||
if (displayManagerListener_ == nullptr) {
|
||||
displayManagerListener_ = new DisplayManagerListener(this);
|
||||
ret = SingletonContainer::Get<DisplayManagerAdapter>().RegisterDisplayManagerAgent(
|
||||
displayManagerListener_,
|
||||
DisplayManagerAgentType::DISPLAY_EVENT_LISTENER);
|
||||
}
|
||||
if (!ret) {
|
||||
if (ret != DMError::DM_OK) {
|
||||
WLOGFW("RegisterDisplayManagerAgent failed !");
|
||||
displayManagerListener_ = nullptr;
|
||||
} else {
|
||||
@ -498,25 +498,25 @@ bool DisplayManager::Impl::RegisterDisplayListener(sptr<IDisplayListener> listen
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DisplayManager::RegisterDisplayListener(sptr<IDisplayListener> listener)
|
||||
DMError DisplayManager::RegisterDisplayListener(sptr<IDisplayListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("RegisterDisplayListener listener is nullptr.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->RegisterDisplayListener(listener);
|
||||
}
|
||||
|
||||
bool DisplayManager::Impl::UnregisterDisplayListener(sptr<IDisplayListener> listener)
|
||||
DMError DisplayManager::Impl::UnregisterDisplayListener(sptr<IDisplayListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
auto iter = std::find(displayListeners_.begin(), displayListeners_.end(), listener);
|
||||
if (iter == displayListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
displayListeners_.erase(iter);
|
||||
bool ret = true;
|
||||
DMError ret = DMError::DM_OK;
|
||||
if (displayListeners_.empty() && displayManagerListener_ != nullptr) {
|
||||
ret = SingletonContainer::Get<DisplayManagerAdapter>().UnregisterDisplayManagerAgent(
|
||||
displayManagerListener_,
|
||||
@ -526,26 +526,26 @@ bool DisplayManager::Impl::UnregisterDisplayListener(sptr<IDisplayListener> list
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DisplayManager::UnregisterDisplayListener(sptr<IDisplayListener> listener)
|
||||
DMError DisplayManager::UnregisterDisplayListener(sptr<IDisplayListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("UnregisterDisplayListener listener is nullptr.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->UnregisterDisplayListener(listener);
|
||||
}
|
||||
|
||||
bool DisplayManager::Impl::RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
|
||||
DMError DisplayManager::Impl::RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
bool ret = true;
|
||||
DMError ret = DMError::DM_OK;
|
||||
if (powerEventListenerAgent_ == nullptr) {
|
||||
powerEventListenerAgent_ = new DisplayManagerAgent(this);
|
||||
ret = SingletonContainer::Get<DisplayManagerAdapter>().RegisterDisplayManagerAgent(
|
||||
powerEventListenerAgent_,
|
||||
DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER);
|
||||
}
|
||||
if (!ret) {
|
||||
if (ret != DMError::DM_OK) {
|
||||
WLOGFW("RegisterDisplayManagerAgent failed !");
|
||||
powerEventListenerAgent_ = nullptr;
|
||||
} else {
|
||||
@ -555,25 +555,25 @@ bool DisplayManager::Impl::RegisterDisplayPowerEventListener(sptr<IDisplayPowerE
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DisplayManager::RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
|
||||
DMError DisplayManager::RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener is nullptr");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->RegisterDisplayPowerEventListener(listener);
|
||||
}
|
||||
|
||||
bool DisplayManager::Impl::UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
|
||||
DMError DisplayManager::Impl::UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
auto iter = std::find(powerEventListeners_.begin(), powerEventListeners_.end(), listener);
|
||||
if (iter == powerEventListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
powerEventListeners_.erase(iter);
|
||||
bool ret = true;
|
||||
DMError ret = DMError::DM_OK;
|
||||
if (powerEventListeners_.empty() && powerEventListenerAgent_ != nullptr) {
|
||||
ret = SingletonContainer::Get<DisplayManagerAdapter>().UnregisterDisplayManagerAgent(
|
||||
powerEventListenerAgent_,
|
||||
@ -584,26 +584,26 @@ bool DisplayManager::Impl::UnregisterDisplayPowerEventListener(sptr<IDisplayPowe
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DisplayManager::UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
|
||||
DMError DisplayManager::UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener is nullptr");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->UnregisterDisplayPowerEventListener(listener);
|
||||
}
|
||||
|
||||
bool DisplayManager::Impl::RegisterScreenshotListener(sptr<IScreenshotListener> listener)
|
||||
DMError DisplayManager::Impl::RegisterScreenshotListener(sptr<IScreenshotListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
bool ret = true;
|
||||
DMError ret = DMError::DM_OK;
|
||||
if (screenshotListenerAgent_ == nullptr) {
|
||||
screenshotListenerAgent_ = new DisplayManagerScreenshotAgent(this);
|
||||
ret = SingletonContainer::Get<DisplayManagerAdapter>().RegisterDisplayManagerAgent(
|
||||
screenshotListenerAgent_,
|
||||
DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER);
|
||||
}
|
||||
if (!ret) {
|
||||
if (ret != DMError::DM_OK) {
|
||||
WLOGFW("RegisterDisplayManagerAgent failed !");
|
||||
screenshotListenerAgent_ = nullptr;
|
||||
} else {
|
||||
@ -612,25 +612,25 @@ bool DisplayManager::Impl::RegisterScreenshotListener(sptr<IScreenshotListener>
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DisplayManager::RegisterScreenshotListener(sptr<IScreenshotListener> listener)
|
||||
DMError DisplayManager::RegisterScreenshotListener(sptr<IScreenshotListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("RegisterScreenshotListener listener is nullptr.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->RegisterScreenshotListener(listener);
|
||||
}
|
||||
|
||||
bool DisplayManager::Impl::UnregisterScreenshotListener(sptr<IScreenshotListener> listener)
|
||||
DMError DisplayManager::Impl::UnregisterScreenshotListener(sptr<IScreenshotListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
auto iter = std::find(screenshotListeners_.begin(), screenshotListeners_.end(), listener);
|
||||
if (iter == screenshotListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
screenshotListeners_.erase(iter);
|
||||
bool ret = true;
|
||||
DMError ret = DMError::DM_OK;
|
||||
if (screenshotListeners_.empty() && screenshotListenerAgent_ != nullptr) {
|
||||
ret = SingletonContainer::Get<DisplayManagerAdapter>().UnregisterDisplayManagerAgent(
|
||||
screenshotListenerAgent_,
|
||||
@ -640,11 +640,11 @@ bool DisplayManager::Impl::UnregisterScreenshotListener(sptr<IScreenshotListener
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DisplayManager::UnregisterScreenshotListener(sptr<IScreenshotListener> listener)
|
||||
DMError DisplayManager::UnregisterScreenshotListener(sptr<IScreenshotListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("UnregisterScreenshotListener listener is nullptr.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->UnregisterScreenshotListener(listener);
|
||||
}
|
||||
@ -776,7 +776,7 @@ bool DisplayManager::Impl::SetDisplayState(DisplayState state, DisplayStateCallb
|
||||
displayStateAgent_ = new DisplayManagerAgent(this);
|
||||
ret = SingletonContainer::Get<DisplayManagerAdapter>().RegisterDisplayManagerAgent(
|
||||
displayStateAgent_,
|
||||
DisplayManagerAgentType::DISPLAY_STATE_LISTENER);
|
||||
DisplayManagerAgentType::DISPLAY_STATE_LISTENER) == DMError::DM_OK;
|
||||
}
|
||||
}
|
||||
ret = ret && SingletonContainer::Get<DisplayManagerAdapter>().SetDisplayState(state);
|
||||
|
@ -127,18 +127,18 @@ DMError ScreenManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<Su
|
||||
return displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface);
|
||||
}
|
||||
|
||||
void ScreenManagerAdapter::SetScreenRotationLocked(bool isLocked)
|
||||
DMError ScreenManagerAdapter::SetScreenRotationLocked(bool isLocked)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN();
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
WLOGFI("DisplayManagerAdapter::SetScreenRotationLocked");
|
||||
displayManagerServiceProxy_->SetScreenRotationLocked(isLocked);
|
||||
return displayManagerServiceProxy_->SetScreenRotationLocked(isLocked);
|
||||
}
|
||||
|
||||
bool ScreenManagerAdapter::IsScreenRotationLocked()
|
||||
DMError ScreenManagerAdapter::IsScreenRotationLocked(bool& isLocked)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(false);
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
WLOGFI("DisplayManagerAdapter::IsScreenRotationLocked");
|
||||
return displayManagerServiceProxy_->IsScreenRotationLocked();
|
||||
return displayManagerServiceProxy_->IsScreenRotationLocked(isLocked);
|
||||
}
|
||||
|
||||
bool ScreenManagerAdapter::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
|
||||
@ -153,25 +153,25 @@ ScreenPowerState ScreenManagerAdapter::GetScreenPower(ScreenId dmsScreenId)
|
||||
return displayManagerServiceProxy_->GetScreenPower(dmsScreenId);
|
||||
}
|
||||
|
||||
bool ScreenManagerAdapter::SetOrientation(ScreenId screenId, Orientation orientation)
|
||||
DMError ScreenManagerAdapter::SetOrientation(ScreenId screenId, Orientation orientation)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(false);
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
||||
return displayManagerServiceProxy_->SetOrientation(screenId, orientation);
|
||||
}
|
||||
|
||||
bool BaseAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError BaseAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(false);
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
||||
return displayManagerServiceProxy_->RegisterDisplayManagerAgent(displayManagerAgent, type);
|
||||
}
|
||||
|
||||
bool BaseAdapter::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError BaseAdapter::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(false);
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
||||
return displayManagerServiceProxy_->UnregisterDisplayManagerAgent(displayManagerAgent, type);
|
||||
}
|
||||
@ -301,11 +301,12 @@ void BaseAdapter::Clear()
|
||||
isProxyValid_ = false;
|
||||
}
|
||||
|
||||
ScreenId ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
|
||||
DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId,
|
||||
ScreenId& screenGroupId)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(SCREEN_ID_INVALID);
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
||||
return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId);
|
||||
return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId, screenGroupId);
|
||||
}
|
||||
|
||||
sptr<ScreenInfo> ScreenManagerAdapter::GetScreenInfo(ScreenId screenId)
|
||||
@ -367,18 +368,19 @@ sptr<ScreenGroupInfo> ScreenManagerAdapter::GetScreenGroupInfoById(ScreenId scre
|
||||
return displayManagerServiceProxy_->GetScreenGroupInfoById(screenId);
|
||||
}
|
||||
|
||||
std::vector<sptr<ScreenInfo>> ScreenManagerAdapter::GetAllScreenInfos()
|
||||
DMError ScreenManagerAdapter::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(std::vector<sptr<ScreenInfo>>());
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
||||
return displayManagerServiceProxy_->GetAllScreenInfos();
|
||||
return displayManagerServiceProxy_->GetAllScreenInfos(screenInfos);
|
||||
}
|
||||
|
||||
ScreenId ScreenManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
DMError ScreenManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint,
|
||||
ScreenId& screenGroupId)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(SCREEN_ID_INVALID);
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
||||
return displayManagerServiceProxy_->MakeExpand(screenId, startPoint);
|
||||
return displayManagerServiceProxy_->MakeExpand(screenId, startPoint, screenGroupId);
|
||||
}
|
||||
|
||||
void ScreenManagerAdapter::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)
|
||||
@ -388,16 +390,16 @@ void ScreenManagerAdapter::RemoveVirtualScreenFromGroup(std::vector<ScreenId> sc
|
||||
displayManagerServiceProxy_->RemoveVirtualScreenFromGroup(screens);
|
||||
}
|
||||
|
||||
bool ScreenManagerAdapter::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
DMError ScreenManagerAdapter::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(false);
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
||||
return displayManagerServiceProxy_->SetScreenActiveMode(screenId, modeId);
|
||||
}
|
||||
|
||||
bool ScreenManagerAdapter::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
|
||||
DMError ScreenManagerAdapter::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(false);
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
||||
return displayManagerServiceProxy_->SetVirtualPixelRatio(screenId, virtualPixelRatio);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ bool Screen::IsReal() const
|
||||
return pImpl_->GetScreenInfo()->GetType() == ScreenType::REAL;
|
||||
}
|
||||
|
||||
bool Screen::SetOrientation(Orientation orientation) const
|
||||
DMError Screen::SetOrientation(Orientation orientation) const
|
||||
{
|
||||
WLOGFD("set orientation %{public}u", orientation);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().SetOrientation(GetId(), orientation);
|
||||
@ -173,11 +173,11 @@ std::vector<sptr<SupportedScreenModes>> Screen::GetSupportedModes() const
|
||||
return pImpl_->GetScreenInfo()->GetModes();
|
||||
}
|
||||
|
||||
bool Screen::SetScreenActiveMode(uint32_t modeId)
|
||||
DMError Screen::SetScreenActiveMode(uint32_t modeId)
|
||||
{
|
||||
ScreenId screenId = GetId();
|
||||
if (modeId >= GetSupportedModes().size()) {
|
||||
return false;
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().SetScreenActiveMode(screenId, modeId);
|
||||
}
|
||||
@ -197,12 +197,12 @@ void Screen::UpdateScreenInfo() const
|
||||
UpdateScreenInfo(screenInfo);
|
||||
}
|
||||
|
||||
bool Screen::SetDensityDpi(uint32_t dpi) const
|
||||
DMError Screen::SetDensityDpi(uint32_t dpi) const
|
||||
{
|
||||
if (dpi > DOT_PER_INCH_MAXIMUM_VALUE || dpi < DOT_PER_INCH_MINIMUM_VALUE) {
|
||||
WLOGE("Invalid input dpi value, valid input range for DPI is %{public}u ~ %{public}u",
|
||||
DOT_PER_INCH_MINIMUM_VALUE, DOT_PER_INCH_MAXIMUM_VALUE);
|
||||
return false;
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
// Calculate display density, Density = Dpi / 160.
|
||||
float density = static_cast<float>(dpi) / 160; // 160 is the coefficient between density and dpi.
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "display_manager_adapter.h"
|
||||
#include "display_manager_agent_default.h"
|
||||
#include "permission.h"
|
||||
#include "singleton_delegator.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
@ -38,13 +39,13 @@ public:
|
||||
ScreenId CreateVirtualScreen(VirtualScreenOption option);
|
||||
sptr<Screen> GetScreen(ScreenId screenId);
|
||||
sptr<ScreenGroup> GetScreenGroup(ScreenId screenId);
|
||||
std::vector<sptr<Screen>> GetAllScreens();
|
||||
bool RegisterScreenListener(sptr<IScreenListener> listener);
|
||||
bool UnregisterScreenListener(sptr<IScreenListener> listener);
|
||||
bool RegisterScreenGroupListener(sptr<IScreenGroupListener> listener);
|
||||
bool UnregisterScreenGroupListener(sptr<IScreenGroupListener> listener);
|
||||
bool RegisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener);
|
||||
bool UnregisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener);
|
||||
DMError GetAllScreens(std::vector<sptr<Screen>>& screens);
|
||||
DMError RegisterScreenListener(sptr<IScreenListener> listener);
|
||||
DMError UnregisterScreenListener(sptr<IScreenListener> listener);
|
||||
DMError RegisterScreenGroupListener(sptr<IScreenGroupListener> listener);
|
||||
DMError UnregisterScreenGroupListener(sptr<IScreenGroupListener> listener);
|
||||
DMError RegisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener);
|
||||
DMError UnregisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener);
|
||||
void OnRemoteDied();
|
||||
|
||||
private:
|
||||
@ -53,8 +54,8 @@ private:
|
||||
void NotifyScreenChange(const sptr<ScreenInfo>& screenInfo);
|
||||
void NotifyScreenChange(const std::vector<sptr<ScreenInfo>>& screenInfos);
|
||||
bool UpdateScreenInfoLocked(sptr<ScreenInfo>);
|
||||
bool RegisterDisplayManagerAgent();
|
||||
bool UnregisterDisplayManagerAgent();
|
||||
DMError RegisterDisplayManagerAgent();
|
||||
DMError UnregisterDisplayManagerAgent();
|
||||
bool isAllListenersRemoved() const;
|
||||
|
||||
class ScreenManagerListener;
|
||||
@ -251,10 +252,10 @@ sptr<ScreenGroup> ScreenManager::GetScreenGroup(ScreenId screenId)
|
||||
return pImpl_->GetScreenGroup(screenId);
|
||||
}
|
||||
|
||||
std::vector<sptr<Screen>> ScreenManager::Impl::GetAllScreens()
|
||||
DMError ScreenManager::Impl::GetAllScreens(std::vector<sptr<Screen>>& screens)
|
||||
{
|
||||
auto screenInfos = SingletonContainer::Get<ScreenManagerAdapter>().GetAllScreenInfos();
|
||||
std::vector<sptr<Screen>> screens;
|
||||
std::vector<sptr<ScreenInfo>> screenInfos;
|
||||
DMError ret = SingletonContainer::Get<ScreenManagerAdapter>().GetAllScreenInfos(screenInfos);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (auto info: screenInfos) {
|
||||
if (UpdateScreenInfoLocked(info)) {
|
||||
@ -265,142 +266,146 @@ std::vector<sptr<Screen>> ScreenManager::Impl::GetAllScreens()
|
||||
for (auto screen: screens) {
|
||||
screenMap_.insert(std::make_pair(screen->GetId(), screen));
|
||||
}
|
||||
return screens;
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<sptr<Screen>> ScreenManager::GetAllScreens()
|
||||
DMError ScreenManager::GetAllScreens(std::vector<sptr<Screen>>& screens)
|
||||
{
|
||||
return pImpl_->GetAllScreens();
|
||||
return pImpl_->GetAllScreens(screens);
|
||||
}
|
||||
|
||||
bool ScreenManager::Impl::RegisterScreenListener(sptr<IScreenListener> listener)
|
||||
DMError ScreenManager::Impl::RegisterScreenListener(sptr<IScreenListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
bool regSucc = RegisterDisplayManagerAgent();
|
||||
if (regSucc) {
|
||||
DMError regSucc = RegisterDisplayManagerAgent();
|
||||
if (regSucc == DMError::DM_OK) {
|
||||
screenListeners_.insert(listener);
|
||||
}
|
||||
return regSucc;
|
||||
}
|
||||
|
||||
bool ScreenManager::RegisterScreenListener(sptr<IScreenListener> listener)
|
||||
DMError ScreenManager::RegisterScreenListener(sptr<IScreenListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("RegisterScreenListener listener is nullptr.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->RegisterScreenListener(listener);
|
||||
}
|
||||
|
||||
bool ScreenManager::Impl::UnregisterScreenListener(sptr<IScreenListener> listener)
|
||||
DMError ScreenManager::Impl::UnregisterScreenListener(sptr<IScreenListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("unregister display manager agent permission denied!");
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
auto iter = std::find(screenListeners_.begin(), screenListeners_.end(), listener);
|
||||
if (iter == screenListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
screenListeners_.erase(iter);
|
||||
return isAllListenersRemoved() ? UnregisterDisplayManagerAgent() : true;
|
||||
return isAllListenersRemoved() ? UnregisterDisplayManagerAgent() : DMError::DM_OK;
|
||||
}
|
||||
|
||||
bool ScreenManager::UnregisterScreenListener(sptr<IScreenListener> listener)
|
||||
DMError ScreenManager::UnregisterScreenListener(sptr<IScreenListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("UnregisterScreenListener listener is nullptr.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->UnregisterScreenListener(listener);
|
||||
}
|
||||
|
||||
bool ScreenManager::Impl::RegisterScreenGroupListener(sptr<IScreenGroupListener> listener)
|
||||
DMError ScreenManager::Impl::RegisterScreenGroupListener(sptr<IScreenGroupListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
bool regSucc = RegisterDisplayManagerAgent();
|
||||
if (regSucc) {
|
||||
DMError regSucc = RegisterDisplayManagerAgent();
|
||||
if (regSucc == DMError::DM_OK) {
|
||||
screenGroupListeners_.insert(listener);
|
||||
}
|
||||
return regSucc;
|
||||
}
|
||||
|
||||
bool ScreenManager::RegisterScreenGroupListener(sptr<IScreenGroupListener> listener)
|
||||
DMError ScreenManager::RegisterScreenGroupListener(sptr<IScreenGroupListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("RegisterScreenGroupListener listener is nullptr.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->RegisterScreenGroupListener(listener);
|
||||
}
|
||||
|
||||
bool ScreenManager::Impl::UnregisterScreenGroupListener(sptr<IScreenGroupListener> listener)
|
||||
DMError ScreenManager::Impl::UnregisterScreenGroupListener(sptr<IScreenGroupListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
auto iter = std::find(screenGroupListeners_.begin(), screenGroupListeners_.end(), listener);
|
||||
if (iter == screenGroupListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
screenGroupListeners_.erase(iter);
|
||||
return isAllListenersRemoved() ? UnregisterDisplayManagerAgent() : true;
|
||||
return isAllListenersRemoved() ? UnregisterDisplayManagerAgent() : DMError::DM_OK;
|
||||
}
|
||||
|
||||
bool ScreenManager::UnregisterScreenGroupListener(sptr<IScreenGroupListener> listener)
|
||||
DMError ScreenManager::UnregisterScreenGroupListener(sptr<IScreenGroupListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("UnregisterScreenGroupListener listener is nullptr.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->UnregisterScreenGroupListener(listener);
|
||||
}
|
||||
|
||||
bool ScreenManager::Impl::RegisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener)
|
||||
DMError ScreenManager::Impl::RegisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
bool regSucc = RegisterDisplayManagerAgent();
|
||||
if (regSucc) {
|
||||
DMError regSucc = RegisterDisplayManagerAgent();
|
||||
if (regSucc == DMError::DM_OK) {
|
||||
virtualScreenGroupListeners_.insert(listener);
|
||||
}
|
||||
return regSucc;
|
||||
}
|
||||
|
||||
bool ScreenManager::RegisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener)
|
||||
DMError ScreenManager::RegisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("RegisterVirtualScreenGroupListener listener is nullptr.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->RegisterVirtualScreenGroupListener(listener);
|
||||
}
|
||||
|
||||
bool ScreenManager::Impl::UnregisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener)
|
||||
DMError ScreenManager::Impl::UnregisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
auto iter = std::find(virtualScreenGroupListeners_.begin(), virtualScreenGroupListeners_.end(), listener);
|
||||
if (iter == virtualScreenGroupListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
virtualScreenGroupListeners_.erase(iter);
|
||||
return isAllListenersRemoved() ? UnregisterDisplayManagerAgent() : true;
|
||||
return isAllListenersRemoved() ? UnregisterDisplayManagerAgent() : DMError::DM_OK;
|
||||
}
|
||||
|
||||
bool ScreenManager::UnregisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener)
|
||||
DMError ScreenManager::UnregisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("UnregisterVirtualScreenGroupListener listener is nullptr.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return pImpl_->UnregisterVirtualScreenGroupListener(listener);
|
||||
}
|
||||
|
||||
bool ScreenManager::Impl::RegisterDisplayManagerAgent()
|
||||
DMError ScreenManager::Impl::RegisterDisplayManagerAgent()
|
||||
{
|
||||
bool regSucc = true;
|
||||
DMError regSucc = DMError::DM_OK;
|
||||
if (screenManagerListener_ == nullptr) {
|
||||
screenManagerListener_ = new ScreenManagerListener(this);
|
||||
regSucc = SingletonContainer::Get<ScreenManagerAdapter>().RegisterDisplayManagerAgent(
|
||||
screenManagerListener_, DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
|
||||
if (!regSucc) {
|
||||
if (regSucc != DMError::DM_OK) {
|
||||
screenManagerListener_ = nullptr;
|
||||
WLOGFW("RegisterDisplayManagerAgent failed !");
|
||||
}
|
||||
@ -408,29 +413,29 @@ bool ScreenManager::Impl::RegisterDisplayManagerAgent()
|
||||
return regSucc;
|
||||
}
|
||||
|
||||
bool ScreenManager::Impl::UnregisterDisplayManagerAgent()
|
||||
DMError ScreenManager::Impl::UnregisterDisplayManagerAgent()
|
||||
{
|
||||
bool unRegSucc = true;
|
||||
DMError unRegSucc = DMError::DM_OK;
|
||||
if (screenManagerListener_ != nullptr) {
|
||||
unRegSucc = SingletonContainer::Get<ScreenManagerAdapter>().UnregisterDisplayManagerAgent(
|
||||
screenManagerListener_, DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
|
||||
screenManagerListener_ = nullptr;
|
||||
if (!unRegSucc) {
|
||||
if (unRegSucc != DMError::DM_OK) {
|
||||
WLOGFW("UnregisterDisplayManagerAgent failed!");
|
||||
}
|
||||
}
|
||||
return unRegSucc;
|
||||
}
|
||||
|
||||
ScreenId ScreenManager::MakeExpand(const std::vector<ExpandOption>& options)
|
||||
DMError ScreenManager::MakeExpand(const std::vector<ExpandOption>& options, ScreenId& screenGroupId)
|
||||
{
|
||||
WLOGFI("Make expand");
|
||||
if (options.empty()) {
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
if (options.size() > MAX_SCREEN_SIZE) {
|
||||
WLOGFW("Make expand failed. The options size is bigger than %{public}u.", MAX_SCREEN_SIZE);
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
std::vector<ScreenId> screenIds;
|
||||
std::vector<Point> startPoints;
|
||||
@ -441,25 +446,26 @@ ScreenId ScreenManager::MakeExpand(const std::vector<ExpandOption>& options)
|
||||
screenIds.emplace_back(option.screenId_);
|
||||
startPoints.emplace_back(Point(option.startX_, option.startY_));
|
||||
}
|
||||
ScreenId group = SingletonContainer::Get<ScreenManagerAdapter>().MakeExpand(screenIds, startPoints);
|
||||
if (group == SCREEN_ID_INVALID) {
|
||||
DMError ret = SingletonContainer::Get<ScreenManagerAdapter>().MakeExpand(screenIds, startPoints, screenGroupId);
|
||||
if (screenGroupId == SCREEN_ID_INVALID) {
|
||||
WLOGFI("Make expand failed");
|
||||
}
|
||||
return group;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ScreenId ScreenManager::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
|
||||
DMError ScreenManager::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId, ScreenId& screenGroupId)
|
||||
{
|
||||
WLOGFI("Make mirror for screen: %{public}" PRIu64"", mainScreenId);
|
||||
if (mirrorScreenId.size() > MAX_SCREEN_SIZE) {
|
||||
WLOGFW("Make Mirror failed. The mirrorScreenId size is bigger than %{public}u.", MAX_SCREEN_SIZE);
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
ScreenId group = SingletonContainer::Get<ScreenManagerAdapter>().MakeMirror(mainScreenId, mirrorScreenId);
|
||||
if (group == SCREEN_ID_INVALID) {
|
||||
DMError ret = SingletonContainer::Get<ScreenManagerAdapter>().MakeMirror(mainScreenId, mirrorScreenId,
|
||||
screenGroupId);
|
||||
if (screenGroupId == SCREEN_ID_INVALID) {
|
||||
WLOGFI("create mirror failed");
|
||||
}
|
||||
return group;
|
||||
return ret;
|
||||
}
|
||||
|
||||
DMError ScreenManager::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)
|
||||
@ -514,13 +520,12 @@ ScreenPowerState ScreenManager::GetScreenPower(ScreenId dmsScreenId)
|
||||
|
||||
DMError ScreenManager::SetScreenRotationLocked(bool isLocked)
|
||||
{
|
||||
SingletonContainer::Get<ScreenManagerAdapter>().SetScreenRotationLocked(isLocked);
|
||||
return DMError::DM_OK;
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().SetScreenRotationLocked(isLocked);
|
||||
}
|
||||
|
||||
bool ScreenManager::IsScreenRotationLocked()
|
||||
DMError ScreenManager::IsScreenRotationLocked(bool& isLocked)
|
||||
{
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().IsScreenRotationLocked();
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().IsScreenRotationLocked(isLocked);
|
||||
}
|
||||
|
||||
void ScreenManager::Impl::NotifyScreenConnect(sptr<ScreenInfo> info)
|
||||
|
@ -95,14 +95,14 @@ HWTEST_F(DisplayChangeUnitTest, RegisterDisplayChangeListener01, Function | Smal
|
||||
{
|
||||
Mocker m;
|
||||
EXPECT_CALL(m.Mock(), RegisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER))
|
||||
.Times(1).WillOnce(Return(true));
|
||||
bool ret = DisplayManager::GetInstance().RegisterDisplayListener(listener_);
|
||||
ASSERT_EQ(true, ret);
|
||||
.Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
DMError ret = DisplayManager::GetInstance().RegisterDisplayListener(listener_);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
|
||||
EXPECT_CALL(m.Mock(), UnregisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER))
|
||||
.Times(1).WillOnce(Return(true));
|
||||
ret = DisplayManager::GetInstance().UnregisterDisplayListener(listener_);
|
||||
ASSERT_EQ(true, ret);
|
||||
.Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
ret = DisplayManager::GetInstance().UnregisterDisplayListener(listener_);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,13 +115,13 @@ HWTEST_F(DisplayChangeUnitTest, RegisterDisplayChangeListener02, Function | Smal
|
||||
Mocker m;
|
||||
EXPECT_CALL(m.Mock(), RegisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER))
|
||||
.Times(0);
|
||||
bool ret = DisplayManager::GetInstance().RegisterDisplayListener(nullptr);
|
||||
ASSERT_EQ(false, ret);
|
||||
DMError ret = DisplayManager::GetInstance().RegisterDisplayListener(nullptr);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
|
||||
EXPECT_CALL(m.Mock(), UnregisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER))
|
||||
.Times(0);
|
||||
ret = DisplayManager::GetInstance().UnregisterDisplayListener(nullptr);
|
||||
ASSERT_EQ(false, ret);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,14 +133,14 @@ HWTEST_F(DisplayChangeUnitTest, RegisterDisplayChangeListener03, Function | Smal
|
||||
{
|
||||
Mocker m;
|
||||
EXPECT_CALL(m.Mock(), RegisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER))
|
||||
.Times(1).WillOnce(Return(false));
|
||||
bool ret = DisplayManager::GetInstance().RegisterDisplayListener(listener_);
|
||||
ASSERT_EQ(false, ret);
|
||||
.Times(1).WillOnce(Return(DMError::DM_ERROR_NULLPTR));
|
||||
DMError ret = DisplayManager::GetInstance().RegisterDisplayListener(listener_);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
|
||||
EXPECT_CALL(m.Mock(), UnregisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER))
|
||||
.Times(0);
|
||||
ret = DisplayManager::GetInstance().UnregisterDisplayListener(listener_);
|
||||
ASSERT_EQ(false, ret);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
@ -151,8 +151,8 @@ HWTEST_F(DisplayManagerTest, Unfreeze03, Function | SmallTest | Level1)
|
||||
*/
|
||||
HWTEST_F(DisplayManagerTest, RegisterScreenshotListener01, Function | SmallTest | Level1)
|
||||
{
|
||||
bool ret = DisplayManager::GetInstance().RegisterScreenshotListener(nullptr);
|
||||
ASSERT_FALSE(ret);
|
||||
DMError ret = DisplayManager::GetInstance().RegisterScreenshotListener(nullptr);
|
||||
ASSERT_FALSE(DMError::DM_OK == ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,10 +163,10 @@ HWTEST_F(DisplayManagerTest, RegisterScreenshotListener01, Function | SmallTest
|
||||
HWTEST_F(DisplayManagerTest, RegisterScreenshotListener02, Function | SmallTest | Level1)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(false));
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_ERROR_NULLPTR));
|
||||
sptr<DisplayManager::IScreenshotListener> listener = new DmMockScreenshotListener();
|
||||
bool ret = DisplayManager::GetInstance().RegisterScreenshotListener(listener);
|
||||
ASSERT_FALSE(ret);
|
||||
DMError ret = DisplayManager::GetInstance().RegisterScreenshotListener(listener);
|
||||
ASSERT_FALSE(DMError::DM_OK == ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,8 +176,8 @@ HWTEST_F(DisplayManagerTest, RegisterScreenshotListener02, Function | SmallTest
|
||||
*/
|
||||
HWTEST_F(DisplayManagerTest, UnregisterScreenshotListener01, Function | SmallTest | Level1)
|
||||
{
|
||||
bool ret = DisplayManager::GetInstance().UnregisterScreenshotListener(nullptr);
|
||||
ASSERT_FALSE(ret);
|
||||
DMError ret = DisplayManager::GetInstance().UnregisterScreenshotListener(nullptr);
|
||||
ASSERT_FALSE(DMError::DM_OK == ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,7 +188,7 @@ HWTEST_F(DisplayManagerTest, UnregisterScreenshotListener01, Function | SmallTes
|
||||
HWTEST_F(DisplayManagerTest, OnDisplayCreate01, Function | SmallTest | Level1)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
sptr<DisplayManager::IDisplayListener> listener = new DmMockDisplayListener();
|
||||
DisplayManager::GetInstance().RegisterDisplayListener(listener);
|
||||
auto displayManagerListener = DisplayManager::GetInstance().pImpl_->displayManagerListener_;
|
||||
@ -213,7 +213,7 @@ HWTEST_F(DisplayManagerTest, OnDisplayCreate01, Function | SmallTest | Level1)
|
||||
HWTEST_F(DisplayManagerTest, OnDisplayDestroy, Function | SmallTest | Level1)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
sptr<DisplayManager::IDisplayListener> listener = new DmMockDisplayListener();
|
||||
DisplayManager::GetInstance().RegisterDisplayListener(listener);
|
||||
auto displayManagerListener = DisplayManager::GetInstance().pImpl_->displayManagerListener_;
|
||||
@ -233,7 +233,7 @@ HWTEST_F(DisplayManagerTest, OnDisplayDestroy, Function | SmallTest | Level1)
|
||||
HWTEST_F(DisplayManagerTest, OnDisplayChange, Function | SmallTest | Level1)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
sptr<DisplayManager::IDisplayListener> listener = new DmMockDisplayListener();
|
||||
DisplayManager::GetInstance().RegisterDisplayListener(listener);
|
||||
auto displayManagerListener = DisplayManager::GetInstance().pImpl_->displayManagerListener_;
|
||||
|
@ -77,14 +77,14 @@ HWTEST_F(DisplayPowerUnitTest, register_display_power_event_listener_001, Functi
|
||||
Mocker m;
|
||||
|
||||
EXPECT_CALL(m.Mock(), RegisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER))
|
||||
.Times(1).WillOnce(Return(true));
|
||||
bool ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(listener_);
|
||||
ASSERT_EQ(true, ret);
|
||||
.Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
DMError ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(listener_);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
|
||||
EXPECT_CALL(m.Mock(), UnregisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER))
|
||||
.Times(1).WillOnce(Return(true));
|
||||
ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener_);
|
||||
ASSERT_EQ(true, ret);
|
||||
.Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener_);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,13 +97,13 @@ HWTEST_F(DisplayPowerUnitTest, register_display_power_event_listener_002, Functi
|
||||
Mocker m;
|
||||
EXPECT_CALL(m.Mock(), RegisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER))
|
||||
.Times(0);
|
||||
bool ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(nullptr);
|
||||
ASSERT_EQ(false, ret);
|
||||
DMError ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(nullptr);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
|
||||
EXPECT_CALL(m.Mock(), UnregisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER))
|
||||
.Times(0);
|
||||
ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(nullptr);
|
||||
ASSERT_EQ(false, ret);
|
||||
ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(nullptr);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,14 +115,14 @@ HWTEST_F(DisplayPowerUnitTest, register_display_power_event_listener_003, Functi
|
||||
{
|
||||
Mocker m;
|
||||
EXPECT_CALL(m.Mock(), RegisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER))
|
||||
.Times(1).WillOnce(Return(false));
|
||||
bool ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(listener_);
|
||||
ASSERT_EQ(false, ret);
|
||||
.Times(1).WillOnce(Return(DMError::DM_ERROR_NULLPTR));
|
||||
DMError ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(listener_);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
|
||||
EXPECT_CALL(m.Mock(), UnregisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER))
|
||||
.Times(0);
|
||||
ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener_);
|
||||
ASSERT_EQ(false, ret);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,8 +135,8 @@ HWTEST_F(DisplayPowerUnitTest, unregister_display_power_event_listener_001, Func
|
||||
Mocker m;
|
||||
EXPECT_CALL(m.Mock(), UnregisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER))
|
||||
.Times(0);
|
||||
bool ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener_);
|
||||
ASSERT_EQ(false, ret);
|
||||
DMError ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener_);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,8 +149,8 @@ HWTEST_F(DisplayPowerUnitTest, unregister_display_power_event_listener_002, Func
|
||||
Mocker m;
|
||||
EXPECT_CALL(m.Mock(), UnregisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER))
|
||||
.Times(0);
|
||||
bool ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(nullptr);
|
||||
ASSERT_EQ(false, ret);
|
||||
DMError ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(nullptr);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -262,7 +262,7 @@ HWTEST_F(DisplayPowerUnitTest, set_display_state_001, Function | MediumTest | Le
|
||||
DisplayState stateToSet = (initialState_ == DisplayState::OFF ? DisplayState::ON : DisplayState::OFF);
|
||||
Mocker m;
|
||||
EXPECT_CALL(m.Mock(), RegisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_STATE_LISTENER))
|
||||
.Times(1).WillOnce(Return(true));
|
||||
.Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
EXPECT_CALL(m.Mock(), SetDisplayState(stateToSet)).Times(1).WillOnce(Return(true));
|
||||
DisplayStateCallback callback = [](DisplayState state) {};
|
||||
bool ret = DisplayManager::GetInstance().SetDisplayState(stateToSet, callback);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "mock_display_manager_adapter.h"
|
||||
#include "singleton_mocker.h"
|
||||
#include "screen_manager.cpp"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
@ -136,10 +137,11 @@ HWTEST_F(ScreenManagerTest, MakeExpand_001, Function | SmallTest | Level1)
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), CreateVirtualScreen(_, _)).Times(1).WillOnce(Return(virtualScreenId));
|
||||
EXPECT_CALL(m->Mock(), DestroyVirtualScreen(_)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
EXPECT_CALL(m->Mock(), MakeExpand(_, _)).Times(1).WillOnce(Return(0));
|
||||
EXPECT_CALL(m->Mock(), MakeExpand(_, _, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
ScreenId vScreenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
|
||||
std::vector<ExpandOption> options = {{validId, 0, 0}, {vScreenId, defaultWidth_, 0}};
|
||||
ScreenId expansionId = ScreenManager::GetInstance().MakeExpand(options);
|
||||
ScreenId expansionId;
|
||||
ScreenManager::GetInstance().MakeExpand(options, expansionId);
|
||||
ASSERT_EQ(expansionId, validId);
|
||||
DMError ret = ScreenManager::GetInstance().DestroyVirtualScreen(vScreenId);
|
||||
ASSERT_EQ(vScreenId, virtualScreenId);
|
||||
@ -155,7 +157,8 @@ HWTEST_F(ScreenManagerTest, MakeExpand_002, Function | SmallTest | Level1)
|
||||
{
|
||||
ScreenId invalidId = SCREEN_ID_INVALID;
|
||||
std::vector<ExpandOption> options = {};
|
||||
ScreenId expansionId = ScreenManager::GetInstance().MakeExpand(options);
|
||||
ScreenId expansionId = SCREEN_ID_INVALID;
|
||||
ScreenManager::GetInstance().MakeExpand(options, expansionId);
|
||||
ASSERT_EQ(expansionId, invalidId);
|
||||
}
|
||||
|
||||
@ -214,7 +217,7 @@ HWTEST_F(ScreenManagerTest, SetSurface02, Function | SmallTest | Level1)
|
||||
HWTEST_F(ScreenManagerTest, OnScreenConnect01, Function | SmallTest | Level1)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
sptr<ScreenManager::IScreenListener> listener = new DmMockScreenListener();
|
||||
ScreenManager::GetInstance().RegisterScreenListener(listener);
|
||||
auto screenManagerListener = ScreenManager::GetInstance().pImpl_->screenManagerListener_;
|
||||
@ -239,7 +242,7 @@ HWTEST_F(ScreenManagerTest, OnScreenConnect01, Function | SmallTest | Level1)
|
||||
HWTEST_F(ScreenManagerTest, OnScreenDisconnect01, Function | SmallTest | Level1)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
sptr<ScreenManager::IScreenListener> listener = new DmMockScreenListener();
|
||||
ScreenManager::GetInstance().RegisterScreenListener(listener);
|
||||
auto screenManagerListener = ScreenManager::GetInstance().pImpl_->screenManagerListener_;
|
||||
@ -259,7 +262,7 @@ HWTEST_F(ScreenManagerTest, OnScreenDisconnect01, Function | SmallTest | Level1)
|
||||
HWTEST_F(ScreenManagerTest, OnScreenChange01, Function | SmallTest | Level1)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
sptr<ScreenManager::IScreenListener> listener = new DmMockScreenListener();
|
||||
ScreenManager::GetInstance().RegisterScreenListener(listener);
|
||||
auto screenManagerListener = ScreenManager::GetInstance().pImpl_->screenManagerListener_;
|
||||
@ -280,7 +283,7 @@ HWTEST_F(ScreenManagerTest, OnScreenChange01, Function | SmallTest | Level1)
|
||||
HWTEST_F(ScreenManagerTest, OnScreenGroupChange01, Function | SmallTest | Level1)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
sptr<ScreenManager::IScreenListener> listener = new DmMockScreenListener();
|
||||
ScreenManager::GetInstance().RegisterScreenListener(listener);
|
||||
auto screenManagerListener = ScreenManager::GetInstance().pImpl_->screenManagerListener_;
|
||||
@ -344,12 +347,14 @@ HWTEST_F(ScreenManagerTest, IsScreenRotationLocked, Function | SmallTest | Level
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), IsScreenRotationLocked()).Times(1).WillOnce(Return(true));
|
||||
auto result = ScreenManager::GetInstance().IsScreenRotationLocked();
|
||||
ASSERT_EQ(true, result);
|
||||
EXPECT_CALL(m->Mock(), IsScreenRotationLocked()).Times(1).WillOnce(Return(false));
|
||||
result = ScreenManager::GetInstance().IsScreenRotationLocked();
|
||||
ASSERT_EQ(false, result);
|
||||
EXPECT_CALL(m->Mock(), IsScreenRotationLocked(_)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
bool result;
|
||||
DMError ret;
|
||||
ret = ScreenManager::GetInstance().IsScreenRotationLocked(result);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
EXPECT_CALL(m->Mock(), IsScreenRotationLocked(_)).Times(1).WillOnce(Return(DMError::DM_ERROR_NULLPTR));
|
||||
ret = ScreenManager::GetInstance().IsScreenRotationLocked(result);
|
||||
ASSERT_TRUE(DMError::DM_OK != ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -363,30 +368,30 @@ HWTEST_F(ScreenManagerTest, RegisterScreenGroupListener, Function | SmallTest |
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
auto& screenManager = ScreenManager::GetInstance();
|
||||
auto result = screenManager.RegisterScreenGroupListener(nullptr);
|
||||
ASSERT_EQ(false, result);
|
||||
ASSERT_TRUE(DMError::DM_OK != result);
|
||||
|
||||
sptr<ScreenManager::IScreenGroupListener> listener = new (std::nothrow)TestScreenGroupListener();
|
||||
if (screenManager.pImpl_->screenManagerListener_ == nullptr) {
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
}
|
||||
result = screenManager.RegisterScreenGroupListener(listener);
|
||||
ASSERT_EQ(true, result);
|
||||
ASSERT_EQ(DMError::DM_OK, result);
|
||||
|
||||
result = screenManager.UnregisterScreenGroupListener(nullptr);
|
||||
ASSERT_EQ(false, result);
|
||||
ASSERT_TRUE(DMError::DM_OK != result);
|
||||
|
||||
auto sizeScreen = screenManager.pImpl_->screenListeners_.size();
|
||||
auto sizeScreenGroup = screenManager.pImpl_->screenGroupListeners_.size();
|
||||
auto sizeVirtualScreen = screenManager.pImpl_->virtualScreenGroupListeners_.size();
|
||||
if (sizeScreenGroup > 1) {
|
||||
result = screenManager.UnregisterScreenGroupListener(listener);
|
||||
ASSERT_EQ(true, result);
|
||||
ASSERT_EQ(DMError::DM_OK, result);
|
||||
} else if (sizeScreenGroup == 1) {
|
||||
if (sizeScreen == 0 && sizeVirtualScreen == 0) {
|
||||
EXPECT_CALL(m->Mock(), UnregisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), UnregisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
}
|
||||
result = screenManager.UnregisterScreenGroupListener(listener);
|
||||
ASSERT_EQ(true, result);
|
||||
ASSERT_EQ(DMError::DM_OK, result);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -400,17 +405,17 @@ HWTEST_F(ScreenManagerTest, RegisterVirtualScreenGroupListener, Function | Small
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
auto& screenManager = ScreenManager::GetInstance();
|
||||
auto result = screenManager.RegisterVirtualScreenGroupListener(nullptr);
|
||||
ASSERT_EQ(false, result);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, result);
|
||||
|
||||
sptr<ScreenManager::IVirtualScreenGroupListener> listener = new (std::nothrow)TestIVirtualScreenGroupListener();
|
||||
if (screenManager.pImpl_->screenManagerListener_ == nullptr) {
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), RegisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
}
|
||||
result = screenManager.RegisterVirtualScreenGroupListener(listener);
|
||||
ASSERT_EQ(true, result);
|
||||
ASSERT_EQ(DMError::DM_OK, result);
|
||||
|
||||
result = screenManager.UnregisterVirtualScreenGroupListener(nullptr);
|
||||
ASSERT_EQ(false, result);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, result);
|
||||
|
||||
auto sizeScreen = screenManager.pImpl_->screenListeners_.size();
|
||||
auto sizeScreenGroup = screenManager.pImpl_->screenGroupListeners_.size();
|
||||
@ -418,13 +423,13 @@ HWTEST_F(ScreenManagerTest, RegisterVirtualScreenGroupListener, Function | Small
|
||||
|
||||
if (sizeVirtualScreen > 1) {
|
||||
result = screenManager.UnregisterVirtualScreenGroupListener(listener);
|
||||
ASSERT_EQ(true, result);
|
||||
ASSERT_EQ(DMError::DM_OK, result);
|
||||
} else if (sizeVirtualScreen == 1) {
|
||||
if (sizeScreen == 0 && sizeScreenGroup == 0) {
|
||||
EXPECT_CALL(m->Mock(), UnregisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
EXPECT_CALL(m->Mock(), UnregisterDisplayManagerAgent(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
}
|
||||
result = screenManager.UnregisterVirtualScreenGroupListener(listener);
|
||||
ASSERT_EQ(true, result);
|
||||
ASSERT_EQ(DMError::DM_OK, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,9 +91,9 @@ HWTEST_F(ScreenTest, SetScreenActiveMode01, Function | SmallTest | Level1)
|
||||
auto supportedModes = screen_->GetSupportedModes();
|
||||
ASSERT_GT(supportedModes.size(), 0);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), SetScreenActiveMode(_, _)).Times(1).WillOnce(Return(true));
|
||||
bool res = screen_->SetScreenActiveMode(supportedModes.size() - 1);
|
||||
ASSERT_EQ(true, res);
|
||||
EXPECT_CALL(m->Mock(), SetScreenActiveMode(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
DMError res = screen_->SetScreenActiveMode(supportedModes.size() - 1);
|
||||
ASSERT_EQ(DMError::DM_OK, res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,9 +106,9 @@ HWTEST_F(ScreenTest, SetScreenActiveMode02, Function | SmallTest | Level1)
|
||||
auto supportedModes = screen_->GetSupportedModes();
|
||||
ASSERT_GT(supportedModes.size(), 0);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), SetScreenActiveMode(_, _)).Times(1).WillOnce(Return(false));
|
||||
bool res = screen_->SetScreenActiveMode(supportedModes.size() - 1);
|
||||
ASSERT_EQ(false, res);
|
||||
EXPECT_CALL(m->Mock(), SetScreenActiveMode(_, _)).Times(1).WillOnce(Return(DMError::DM_ERROR_NULLPTR));
|
||||
DMError res = screen_->SetScreenActiveMode(supportedModes.size() - 1);
|
||||
ASSERT_TRUE(DMError::DM_OK != res);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,19 +62,19 @@ public:
|
||||
DMError DestroyVirtualScreen(ScreenId screenId);
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);
|
||||
void SetBuildInDefaultOrientation(Orientation orientation);
|
||||
bool SetOrientation(ScreenId screenId, Orientation orientation, bool isFromWindow);
|
||||
DMError SetOrientation(ScreenId screenId, Orientation orientation, bool isFromWindow);
|
||||
bool SetRotation(ScreenId screenId, Rotation rotationAfter, bool isFromWindow);
|
||||
|
||||
bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId);
|
||||
DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId);
|
||||
const std::shared_ptr<RSDisplayNode>& GetRSDisplayNodeByScreenId(ScreenId dmsScreenId) const;
|
||||
void UpdateRSTree(ScreenId dmsScreenId, ScreenId parentScreenId, std::shared_ptr<RSSurfaceNode>& surfaceNode,
|
||||
bool isAdd, bool isMultiDisplay);
|
||||
bool MakeMirror(ScreenId, std::vector<ScreenId> screens);
|
||||
DMError MakeMirror(ScreenId, std::vector<ScreenId> screens);
|
||||
bool MakeExpand(std::vector<ScreenId> screenIds, std::vector<Point> startPoints);
|
||||
void RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens);
|
||||
bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) const;
|
||||
ScreenPowerState GetScreenPower(ScreenId dmsScreenId) const;
|
||||
bool SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio);
|
||||
DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio);
|
||||
|
||||
// colorspace, gamut
|
||||
DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define OHOS_ROSEN_DISPLAY_MANAGER_AGENT_CONTROLLER_H
|
||||
|
||||
#include <mutex>
|
||||
#include "dm_common.h"
|
||||
#include "wm_single_instance.h"
|
||||
#include "client_agent_container.h"
|
||||
#include "zidl/display_manager_agent_interface.h"
|
||||
@ -26,9 +27,9 @@ namespace Rosen {
|
||||
class DisplayManagerAgentController {
|
||||
WM_DECLARE_SINGLE_INSTANCE_BASE(DisplayManagerAgentController)
|
||||
public:
|
||||
bool RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type);
|
||||
bool UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type);
|
||||
|
||||
bool NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatus status);
|
||||
|
@ -87,10 +87,10 @@ public:
|
||||
const sptr<IRemoteObject>& displayManagerAgent) = 0;
|
||||
virtual DMError DestroyVirtualScreen(ScreenId screenId) = 0;
|
||||
virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) = 0;
|
||||
virtual bool SetOrientation(ScreenId screenId, Orientation orientation) = 0;
|
||||
virtual DMError SetOrientation(ScreenId screenId, Orientation orientation) = 0;
|
||||
virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId) = 0;
|
||||
virtual void SetScreenRotationLocked(bool isLocked) = 0;
|
||||
virtual bool IsScreenRotationLocked() = 0;
|
||||
virtual DMError SetScreenRotationLocked(bool isLocked) = 0;
|
||||
virtual DMError IsScreenRotationLocked(bool& isLocked) = 0;
|
||||
|
||||
// colorspace, gamut
|
||||
virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts) = 0;
|
||||
@ -100,9 +100,9 @@ public:
|
||||
virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) = 0;
|
||||
virtual DMError SetScreenColorTransform(ScreenId screenId) = 0;
|
||||
|
||||
virtual bool RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
virtual DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type) = 0;
|
||||
virtual bool UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
virtual DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type) = 0;
|
||||
virtual bool WakeUpBegin(PowerStateChangeReason reason) = 0;
|
||||
virtual bool WakeUpEnd() = 0;
|
||||
@ -118,12 +118,14 @@ public:
|
||||
virtual bool SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze) = 0;
|
||||
virtual sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) = 0;
|
||||
virtual sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) = 0;
|
||||
virtual std::vector<sptr<ScreenInfo>> GetAllScreenInfos() = 0;
|
||||
virtual ScreenId MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId) = 0;
|
||||
virtual ScreenId MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint) = 0;
|
||||
virtual DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos) = 0;
|
||||
virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds,
|
||||
ScreenId& screenGroupId) = 0;
|
||||
virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoints,
|
||||
ScreenId& screenGroupId) = 0;
|
||||
virtual void RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens) = 0;
|
||||
virtual bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId) = 0;
|
||||
virtual bool SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) = 0;
|
||||
virtual DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) = 0;
|
||||
virtual DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) = 0;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
@ -40,10 +40,10 @@ public:
|
||||
const sptr<IRemoteObject>& displayManagerAgent) override;
|
||||
DMError DestroyVirtualScreen(ScreenId screenId) override;
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) override;
|
||||
bool SetOrientation(ScreenId screenId, Orientation orientation) override;
|
||||
DMError SetOrientation(ScreenId screenId, Orientation orientation) override;
|
||||
std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId) override;
|
||||
bool IsScreenRotationLocked() override;
|
||||
void SetScreenRotationLocked(bool isLocked) override;
|
||||
DMError IsScreenRotationLocked(bool& isLocked) override;
|
||||
DMError SetScreenRotationLocked(bool isLocked) override;
|
||||
|
||||
// colorspace, gamut
|
||||
DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts) override;
|
||||
@ -53,9 +53,9 @@ public:
|
||||
DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) override;
|
||||
DMError SetScreenColorTransform(ScreenId screenId) override;
|
||||
|
||||
bool RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type) override;
|
||||
bool UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type) override;
|
||||
bool WakeUpBegin(PowerStateChangeReason reason) override;
|
||||
bool WakeUpEnd() override;
|
||||
@ -69,14 +69,14 @@ public:
|
||||
sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) override;
|
||||
void NotifyDisplayEvent(DisplayEvent event) override;
|
||||
bool SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze) override;
|
||||
ScreenId MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId) override;
|
||||
DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId, ScreenId& screenGroupId) override;
|
||||
sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) override;
|
||||
sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) override;
|
||||
std::vector<sptr<ScreenInfo>> GetAllScreenInfos() override;
|
||||
ScreenId MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint) override;
|
||||
DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screens) override;
|
||||
DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint, ScreenId& screenGroupId) override;
|
||||
void RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens) override;
|
||||
bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId) override;
|
||||
bool SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) override;
|
||||
DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) override;
|
||||
DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<DisplayManagerProxy> delegator_;
|
||||
|
@ -51,15 +51,15 @@ public:
|
||||
const sptr<IRemoteObject>& displayManagerAgent) override;
|
||||
DMError DestroyVirtualScreen(ScreenId screenId) override;
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) override;
|
||||
bool IsScreenRotationLocked() override;
|
||||
void SetScreenRotationLocked(bool isLocked) override;
|
||||
DMError IsScreenRotationLocked(bool& isLocked) override;
|
||||
DMError SetScreenRotationLocked(bool isLocked) override;
|
||||
|
||||
sptr<DisplayInfo> GetDefaultDisplayInfo() override;
|
||||
sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) override;
|
||||
sptr<DisplayInfo> GetDisplayInfoByScreen(ScreenId screenId) override;
|
||||
sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) override;
|
||||
bool SetOrientation(ScreenId screenId, Orientation orientation) override;
|
||||
bool SetOrientationFromWindow(ScreenId screenId, Orientation orientation);
|
||||
DMError SetOrientation(ScreenId screenId, Orientation orientation) override;
|
||||
DMError SetOrientationFromWindow(ScreenId screenId, Orientation orientation);
|
||||
bool SetRotationFromWindow(ScreenId screenId, Rotation targetRotation);
|
||||
void SetGravitySensorSubscriptionEnabled();
|
||||
std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId) override;
|
||||
@ -73,9 +73,9 @@ public:
|
||||
DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) override;
|
||||
DMError SetScreenColorTransform(ScreenId screenId) override;
|
||||
|
||||
bool RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type) override;
|
||||
bool UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type) override;
|
||||
bool WakeUpBegin(PowerStateChangeReason reason) override;
|
||||
bool WakeUpEnd() override;
|
||||
@ -91,17 +91,18 @@ public:
|
||||
void NotifyDisplayEvent(DisplayEvent event) override;
|
||||
bool SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze) override;
|
||||
|
||||
ScreenId MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId) override;
|
||||
ScreenId MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint) override;
|
||||
DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds, ScreenId& screenGroupId) override;
|
||||
DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoints,
|
||||
ScreenId& screenGroupId) override;
|
||||
void RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens) override;
|
||||
sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) override;
|
||||
sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) override;
|
||||
ScreenId GetScreenGroupIdByScreenId(ScreenId screenId);
|
||||
std::vector<sptr<ScreenInfo>> GetAllScreenInfos() override;
|
||||
DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos) override;
|
||||
|
||||
std::vector<DisplayId> GetAllDisplayIds() override;
|
||||
bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId) override;
|
||||
bool SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) override;
|
||||
DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) override;
|
||||
DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) override;
|
||||
void RegisterDisplayChangeListener(sptr<IDisplayChangeListener> listener);
|
||||
void RegisterWindowInfoQueriedListener(const sptr<IWindowInfoQueriedListener>& listener);
|
||||
void RegisterRSScreenChangeListener(const sptr<IRSScreenChangeListener>& listener);
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
void UpdateRSTree(DisplayId displayId, DisplayId parentDisplayId, std::shared_ptr<RSSurfaceNode>& surfaceNode,
|
||||
bool isAdd, bool isMultiDisplay);
|
||||
void RegisterDisplayChangeListener(sptr<IDisplayChangeListener> listener);
|
||||
bool SetOrientationFromWindow(DisplayId displayId, Orientation orientation);
|
||||
DMError SetOrientationFromWindow(DisplayId displayId, Orientation orientation);
|
||||
bool SetRotationFromWindow(DisplayId displayId, Rotation targetRotation);
|
||||
void SetGravitySensorSubscriptionEnabled();
|
||||
void RegisterWindowInfoQueriedListener(const sptr<IWindowInfoQueriedListener>& listener);
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
static void Init();
|
||||
static void HandleSensorEventInput(DeviceRotation deviceRotation);
|
||||
static bool IsScreenRotationLocked();
|
||||
static void SetScreenRotationLocked(bool isLocked);
|
||||
static DMError SetScreenRotationLocked(bool isLocked);
|
||||
static void SetDefaultDeviceRotationOffset(uint32_t defaultDeviceRotationOffset);
|
||||
static void ProcessOrientationSwitch(Orientation orientation);
|
||||
|
||||
@ -73,7 +73,7 @@ private:
|
||||
static bool IsCurrentDisplayVertical();
|
||||
static bool IsCurrentDisplayHorizontal();
|
||||
static bool IsSensorRelatedOrientation(Orientation orientation);
|
||||
|
||||
|
||||
static void ProcessRotationMapping();
|
||||
static void ProcessSwitchToAutoRotationPortrait(DeviceRotation rotation);
|
||||
static void ProcessSwitchToAutoRotationLandscape(DeviceRotation rotation);
|
||||
|
@ -628,17 +628,17 @@ void AbstractScreenController::SetBuildInDefaultOrientation(Orientation orientat
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractScreenController::SetOrientation(ScreenId screenId, Orientation newOrientation, bool isFromWindow)
|
||||
DMError AbstractScreenController::SetOrientation(ScreenId screenId, Orientation newOrientation, bool isFromWindow)
|
||||
{
|
||||
WLOGD("set orientation. screen %{public}" PRIu64" orientation %{public}u", screenId, newOrientation);
|
||||
auto screen = GetAbstractScreen(screenId);
|
||||
if (screen == nullptr) {
|
||||
WLOGFE("fail to set orientation, cannot find screen %{public}" PRIu64"", screenId);
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
if (screen->isScreenGroup_) {
|
||||
WLOGE("cannot set orientation to the combination. screen: %{public}" PRIu64"", screenId);
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
if (isFromWindow) {
|
||||
if (newOrientation == Orientation::UNSPECIFIED) {
|
||||
@ -649,7 +649,7 @@ bool AbstractScreenController::SetOrientation(ScreenId screenId, Orientation new
|
||||
}
|
||||
if (screen->orientation_ == newOrientation) {
|
||||
WLOGFD("skip setting orientation. screen %{public}" PRIu64" orientation %{public}u", screenId, newOrientation);
|
||||
return true;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
if (isFromWindow) {
|
||||
ScreenRotationController::ProcessOrientationSwitch(newOrientation);
|
||||
@ -660,7 +660,7 @@ bool AbstractScreenController::SetOrientation(ScreenId screenId, Orientation new
|
||||
}
|
||||
if (!screen->SetOrientation(newOrientation)) {
|
||||
WLOGE("fail to set rotation, screen %{public}" PRIu64"", screenId);
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
// Notify rotation event to ScreenManager
|
||||
@ -669,7 +669,7 @@ bool AbstractScreenController::SetOrientation(ScreenId screenId, Orientation new
|
||||
if (abstractScreenCallback_ != nullptr) {
|
||||
abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::UPDATE_ORIENTATION);
|
||||
}
|
||||
return true;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
void AbstractScreenController::SetScreenRotateAnimation(
|
||||
@ -812,12 +812,12 @@ DMError AbstractScreenController::SetScreenColorTransform(ScreenId screenId)
|
||||
return screen->SetScreenColorTransform();
|
||||
}
|
||||
|
||||
bool AbstractScreenController::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
DMError AbstractScreenController::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
{
|
||||
WLOGI("SetScreenActiveMode: RsScreenId: %{public}" PRIu64", modeId: %{public}u", screenId, modeId);
|
||||
if (screenId == SCREEN_ID_INVALID) {
|
||||
WLOGFE("SetScreenActiveMode: invalid screenId");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
uint32_t usedModeId = 0;
|
||||
{
|
||||
@ -825,12 +825,12 @@ bool AbstractScreenController::SetScreenActiveMode(ScreenId screenId, uint32_t m
|
||||
auto screen = GetAbstractScreen(screenId);
|
||||
if (screen == nullptr) {
|
||||
WLOGFE("SetScreenActiveMode: Get AbstractScreen failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
ScreenId rsScreenId = SCREEN_ID_INVALID;
|
||||
if (!screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId)) {
|
||||
WLOGFE("SetScreenActiveMode: No corresponding rsId");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
rsInterface_.SetScreenActiveMode(rsScreenId, modeId);
|
||||
usedModeId = static_cast<uint32_t>(screen->activeIdx_);
|
||||
@ -845,7 +845,7 @@ bool AbstractScreenController::SetScreenActiveMode(ScreenId screenId, uint32_t m
|
||||
};
|
||||
controllerHandler_->PostTask(func, AppExecFwk::EventQueue::Priority::HIGH);
|
||||
}
|
||||
return true;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
void AbstractScreenController::ProcessScreenModeChanged(ScreenId dmsScreenId)
|
||||
@ -874,13 +874,13 @@ void AbstractScreenController::ProcessScreenModeChanged(ScreenId dmsScreenId)
|
||||
NotifyScreenChanged(absScreen->ConvertToScreenInfo(), ScreenChangeEvent::CHANGE_MODE);
|
||||
}
|
||||
|
||||
bool AbstractScreenController::MakeMirror(ScreenId screenId, std::vector<ScreenId> screens)
|
||||
DMError AbstractScreenController::MakeMirror(ScreenId screenId, std::vector<ScreenId> screens)
|
||||
{
|
||||
WLOGI("MakeMirror, screenId:%{public}" PRIu64"", screenId);
|
||||
sptr<AbstractScreen> screen = GetAbstractScreen(screenId);
|
||||
if (screen == nullptr || screen->type_ != ScreenType::REAL) {
|
||||
WLOGFE("screen is nullptr, or screenType is not real.");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
WLOGFI("GetAbstractScreenGroup start");
|
||||
auto group = GetAbstractScreenGroup(screen->groupDmsId_);
|
||||
@ -889,7 +889,7 @@ bool AbstractScreenController::MakeMirror(ScreenId screenId, std::vector<ScreenI
|
||||
group = AddToGroupLocked(screen);
|
||||
if (group == nullptr) {
|
||||
WLOGFE("group is nullptr");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
NotifyScreenGroupChanged(screen->ConvertToScreenInfo(), ScreenGroupChangeEvent::ADD_TO_GROUP);
|
||||
if (group != nullptr && abstractScreenCallback_ != nullptr) {
|
||||
@ -905,7 +905,7 @@ bool AbstractScreenController::MakeMirror(ScreenId screenId, std::vector<ScreenI
|
||||
group->mirrorScreenId_ = screen->dmsId_;
|
||||
ChangeScreenGroup(group, screens, startPoints, filterMirroredScreen, ScreenCombination::SCREEN_MIRROR);
|
||||
WLOGFI("MakeMirror success");
|
||||
return true;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
void AbstractScreenController::ChangeScreenGroup(sptr<AbstractScreenGroup> group, const std::vector<ScreenId>& screens,
|
||||
@ -1251,22 +1251,22 @@ ScreenPowerState AbstractScreenController::GetScreenPower(ScreenId dmsScreenId)
|
||||
return state;
|
||||
}
|
||||
|
||||
bool AbstractScreenController::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
|
||||
DMError AbstractScreenController::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
|
||||
{
|
||||
WLOGD("set virtual pixel ratio. screen %{public}" PRIu64" virtualPixelRatio %{public}f",
|
||||
screenId, virtualPixelRatio);
|
||||
auto screen = GetAbstractScreen(screenId);
|
||||
if (screen == nullptr) {
|
||||
WLOGFE("fail to set virtual pixel ratio, cannot find screen %{public}" PRIu64"", screenId);
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
if (screen->isScreenGroup_) {
|
||||
WLOGE("cannot set virtual pixel ratio to the combination. screen: %{public}" PRIu64"", screenId);
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
if (fabs(screen->virtualPixelRatio_ - virtualPixelRatio) < 1e-6) {
|
||||
WLOGE("The density is equivalent to the original value, no update operation is required, aborted.");
|
||||
return true;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
screen->SetVirtualPixelRatio(virtualPixelRatio);
|
||||
// Notify rotation event to AbstractDisplayController
|
||||
@ -1274,6 +1274,6 @@ bool AbstractScreenController::SetVirtualPixelRatio(ScreenId screenId, float vir
|
||||
abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_VIRTUAL_PIXEL_RATIO_CHANGED);
|
||||
}
|
||||
NotifyScreenChanged(screen->ConvertToScreenInfo(), ScreenChangeEvent::VIRTUAL_PIXEL_RATIO_CHANGED);
|
||||
return true;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -23,16 +23,18 @@ namespace {
|
||||
}
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerAgentController)
|
||||
|
||||
bool DisplayManagerAgentController::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError DisplayManagerAgentController::RegisterDisplayManagerAgent(
|
||||
const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
return dmAgentContainer_.RegisterAgent(displayManagerAgent, type);
|
||||
return dmAgentContainer_.RegisterAgent(displayManagerAgent, type) ? DMError::DM_OK :DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
bool DisplayManagerAgentController::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError DisplayManagerAgentController::UnregisterDisplayManagerAgent(
|
||||
const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
return dmAgentContainer_.UnregisterAgent(displayManagerAgent, type);
|
||||
return dmAgentContainer_.UnregisterAgent(displayManagerAgent, type) ? DMError::DM_OK :DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
bool DisplayManagerAgentController::NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatus status)
|
||||
|
@ -229,12 +229,12 @@ DMError DisplayManagerProxy::SetVirtualScreenSurface(ScreenId screenId, sptr<Sur
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::SetOrientation(ScreenId screenId, Orientation orientation)
|
||||
DMError DisplayManagerProxy::SetOrientation(ScreenId screenId, Orientation orientation)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("fail to set orientation: remote is null");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@ -242,22 +242,22 @@ bool DisplayManagerProxy::SetOrientation(ScreenId screenId, Orientation orientat
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("fail to set orientation: WriteInterfaceToken failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
|
||||
WLOGFW("fail to set orientation: Write screenId failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!data.WriteUint32(static_cast<uint32_t>(orientation))) {
|
||||
WLOGFW("fail to set orientation: Write orientation failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_ORIENTATION),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("fail to set orientation: SendRequest failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
std::shared_ptr<Media::PixelMap> DisplayManagerProxy::GetDisplaySnapshot(DisplayId displayId)
|
||||
@ -480,7 +480,7 @@ DMError DisplayManagerProxy::SetScreenColorTransform(ScreenId screenId)
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError DisplayManagerProxy::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -488,28 +488,28 @@ bool DisplayManagerProxy::RegisterDisplayManagerAgent(const sptr<IDisplayManager
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) {
|
||||
WLOGFE("Write IDisplayManagerAgent failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (!data.WriteUint32(static_cast<uint32_t>(type))) {
|
||||
WLOGFE("Write DisplayManagerAgent type failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError DisplayManagerProxy::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -517,25 +517,25 @@ bool DisplayManagerProxy::UnregisterDisplayManagerAgent(const sptr<IDisplayManag
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) {
|
||||
WLOGFE("Write IWindowManagerAgent failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (!data.WriteUint32(static_cast<uint32_t>(type))) {
|
||||
WLOGFE("Write DisplayManagerAgent type failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::WakeUpBegin(PowerStateChangeReason reason)
|
||||
@ -816,12 +816,13 @@ bool DisplayManagerProxy::SetFreeze(std::vector<DisplayId> displayIds, bool isFr
|
||||
return true;
|
||||
}
|
||||
|
||||
ScreenId DisplayManagerProxy::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
|
||||
DMError DisplayManagerProxy::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId,
|
||||
ScreenId& screenGroupId)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("create mirror fail: remote is null");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@ -829,20 +830,22 @@ ScreenId DisplayManagerProxy::MakeMirror(ScreenId mainScreenId, std::vector<Scre
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("create mirror fail: WriteInterfaceToken failed");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
bool res = data.WriteUint64(static_cast<uint64_t>(mainScreenId)) &&
|
||||
data.WriteUInt64Vector(mirrorScreenId);
|
||||
if (!res) {
|
||||
WLOGFE("create mirror fail: data write failed");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("create mirror fail: SendRequest failed");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return static_cast<ScreenId>(reply.ReadUint64());
|
||||
DMError ret = static_cast<DMError>(reply.ReadInt32());
|
||||
screenGroupId = static_cast<ScreenId>(reply.ReadUint64());
|
||||
return ret;
|
||||
}
|
||||
|
||||
sptr<ScreenInfo> DisplayManagerProxy::GetScreenInfoById(ScreenId screenId)
|
||||
@ -915,13 +918,12 @@ sptr<ScreenGroupInfo> DisplayManagerProxy::GetScreenGroupInfoById(ScreenId scree
|
||||
return info;
|
||||
}
|
||||
|
||||
std::vector<sptr<ScreenInfo>> DisplayManagerProxy::GetAllScreenInfos()
|
||||
DMError DisplayManagerProxy::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos)
|
||||
{
|
||||
std::vector<sptr<ScreenInfo>> screenInfos;
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("GetAllScreenInfos: remote is nullptr");
|
||||
return screenInfos;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@ -929,24 +931,25 @@ std::vector<sptr<ScreenInfo>> DisplayManagerProxy::GetAllScreenInfos()
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("GetAllScreenInfos: WriteInterfaceToken failed");
|
||||
return screenInfos;
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("GetAllScreenInfos: SendRequest failed");
|
||||
return screenInfos;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
DMError ret = static_cast<DMError>(reply.ReadInt32());
|
||||
MarshallingHelper::UnmarshallingVectorParcelableObj<ScreenInfo>(reply, screenInfos);
|
||||
return screenInfos;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ScreenId DisplayManagerProxy::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
DMError DisplayManagerProxy::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint,
|
||||
ScreenId& screenGroupId)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("MakeExpand: remote is null");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@ -954,24 +957,26 @@ ScreenId DisplayManagerProxy::MakeExpand(std::vector<ScreenId> screenId, std::ve
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("MakeExpand: WriteInterfaceToken failed");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (!data.WriteUInt64Vector(screenId)) {
|
||||
WLOGFE("MakeExpand: write screenId failed");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!MarshallingHelper::MarshallingVectorObj<Point>(data, startPoint, [](Parcel& parcel, const Point& point) {
|
||||
return parcel.WriteInt32(point.posX_) && parcel.WriteInt32(point.posY_);
|
||||
})) {
|
||||
WLOGFE("MakeExpand: write startPoint failed");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("MakeExpand: SendRequest failed");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return static_cast<ScreenId>(reply.ReadUint64());
|
||||
DMError ret = static_cast<DMError>(reply.ReadInt32());
|
||||
screenGroupId = static_cast<ScreenId>(reply.ReadUint64());
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DisplayManagerProxy::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)
|
||||
@ -1001,12 +1006,12 @@ void DisplayManagerProxy::RemoveVirtualScreenFromGroup(std::vector<ScreenId> scr
|
||||
}
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
DMError DisplayManagerProxy::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("SetScreenActiveMode: remote is null");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@ -1014,26 +1019,26 @@ bool DisplayManagerProxy::SetScreenActiveMode(ScreenId screenId, uint32_t modeId
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("SetScreenActiveMode: WriteInterfaceToken failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (!data.WriteUint64(screenId) || !data.WriteUint32(modeId)) {
|
||||
WLOGFE("SetScreenActiveMode: write screenId/modeId failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SetScreenActiveMode: SendRequest failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
|
||||
DMError DisplayManagerProxy::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("SetVirtualPixelRatio: remote is null");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@ -1041,49 +1046,50 @@ bool DisplayManagerProxy::SetVirtualPixelRatio(ScreenId screenId, float virtualP
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("SetVirtualPixelRatio: WriteInterfaceToken failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (!data.WriteUint64(screenId) || !data.WriteFloat(virtualPixelRatio)) {
|
||||
WLOGFE("SetVirtualPixelRatio: write screenId/modeId failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SetVirtualPixelRatio: SendRequest failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::IsScreenRotationLocked()
|
||||
DMError DisplayManagerProxy::IsScreenRotationLocked(bool& isLocked)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("IsScreenRotationLocked: remote is nullptr");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("IsScreenRotationLocked: WriteInterfaceToken failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("IsScreenRotationLocked: SendRequest failed");
|
||||
return false;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
bool isLocked = reply.ReadBool();
|
||||
return isLocked;
|
||||
DMError ret = static_cast<DMError>(reply.ReadInt32());
|
||||
isLocked = reply.ReadBool();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DisplayManagerProxy::SetScreenRotationLocked(bool isLocked)
|
||||
DMError DisplayManagerProxy::SetScreenRotationLocked(bool isLocked)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("SetScreenRotationLocked: remote is null");
|
||||
return;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@ -1091,16 +1097,17 @@ void DisplayManagerProxy::SetScreenRotationLocked(bool isLocked)
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("SetScreenRotationLocked: WriteInterfaceToken failed");
|
||||
return;
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (!data.WriteBool(isLocked)) {
|
||||
WLOGFE("SetScreenRotationLocked: write isLocked failed");
|
||||
return;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SetScreenRotationLocked: SendRequest failed");
|
||||
return;
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
@ -150,9 +150,9 @@ void DisplayManagerService::RegisterWindowInfoQueriedListener(const sptr<IWindow
|
||||
|
||||
DMError DisplayManagerService::HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("check has private window permission denied!");
|
||||
return DMError::DM_ERROR_INVALID_PERMISSION;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
std::vector<DisplayId> displayIds = GetAllDisplayIds();
|
||||
auto iter = std::find(displayIds.begin(), displayIds.end(), displayId);
|
||||
@ -237,9 +237,9 @@ ScreenId DisplayManagerService::CreateVirtualScreen(VirtualScreenOption option,
|
||||
|
||||
DMError DisplayManagerService::DestroyVirtualScreen(ScreenId screenId)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("destory virtual screen permission denied!");
|
||||
return DMError::DM_ERROR_INVALID_PERMISSION;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (!accessTokenIdMaps_.isExistAndRemove(screenId, IPCSkeleton::GetCallingTokenID())) {
|
||||
return DMError::DM_ERROR_INVALID_CALLING;
|
||||
@ -264,21 +264,21 @@ DMError DisplayManagerService::SetVirtualScreenSurface(ScreenId screenId, sptr<S
|
||||
return DMError::DM_ERROR_INVALID_CALLING;
|
||||
}
|
||||
|
||||
bool DisplayManagerService::SetOrientation(ScreenId screenId, Orientation orientation)
|
||||
DMError DisplayManagerService::SetOrientation(ScreenId screenId, Orientation orientation)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set orientation permission denied!");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (orientation < Orientation::UNSPECIFIED || orientation > Orientation::REVERSE_HORIZONTAL) {
|
||||
WLOGFE("SetOrientation::orientation: %{public}u", static_cast<uint32_t>(orientation));
|
||||
return false;
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetOrientation(%" PRIu64")", screenId);
|
||||
return abstractScreenController_->SetOrientation(screenId, orientation, false);
|
||||
}
|
||||
|
||||
bool DisplayManagerService::SetOrientationFromWindow(ScreenId screenId, Orientation orientation)
|
||||
DMError DisplayManagerService::SetOrientationFromWindow(ScreenId screenId, Orientation orientation)
|
||||
{
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetOrientationFromWindow(%" PRIu64")", screenId);
|
||||
return abstractScreenController_->SetOrientation(screenId, orientation, true);
|
||||
@ -358,30 +358,32 @@ void DisplayManagerService::OnStop()
|
||||
WLOGFI("ready to stop display service.");
|
||||
}
|
||||
|
||||
bool DisplayManagerService::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError DisplayManagerService::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
if (type == DisplayManagerAgentType::SCREEN_EVENT_LISTENER && !Permission::IsSystemCalling()) {
|
||||
if (type == DisplayManagerAgentType::SCREEN_EVENT_LISTENER && !Permission::IsSystemCalling()
|
||||
&& !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("register display manager agent permission denied!");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if ((displayManagerAgent == nullptr) || (displayManagerAgent->AsObject() == nullptr)) {
|
||||
WLOGFE("displayManagerAgent invalid");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return DisplayManagerAgentController::GetInstance().RegisterDisplayManagerAgent(displayManagerAgent, type);
|
||||
}
|
||||
|
||||
bool DisplayManagerService::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DMError DisplayManagerService::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
if (type == DisplayManagerAgentType::SCREEN_EVENT_LISTENER && !Permission::IsSystemCalling()) {
|
||||
if (type == DisplayManagerAgentType::SCREEN_EVENT_LISTENER && !Permission::IsSystemCalling()
|
||||
&& !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("unregister display manager agent permission denied!");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if ((displayManagerAgent == nullptr) || (displayManagerAgent->AsObject() == nullptr)) {
|
||||
WLOGFE("displayManagerAgent invalid");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return DisplayManagerAgentController::GetInstance().UnregisterDisplayManagerAgent(displayManagerAgent, type);
|
||||
}
|
||||
@ -485,7 +487,7 @@ void DisplayManagerService::NotifyDisplayEvent(DisplayEvent event)
|
||||
|
||||
bool DisplayManagerService::SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set freeze permission denied!");
|
||||
return false;
|
||||
}
|
||||
@ -493,11 +495,12 @@ bool DisplayManagerService::SetFreeze(std::vector<DisplayId> displayIds, bool is
|
||||
return true;
|
||||
}
|
||||
|
||||
ScreenId DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds)
|
||||
DMError DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds,
|
||||
ScreenId& screenGroupId)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("make mirror permission denied!");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
WLOGFI("MakeMirror. mainScreenId :%{public}" PRIu64"", mainScreenId);
|
||||
auto allMirrorScreenIds = abstractScreenController_->GetAllValidScreenIds(mirrorScreenIds);
|
||||
@ -509,18 +512,20 @@ ScreenId DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector<Sc
|
||||
if (mainScreen == nullptr || allMirrorScreenIds.empty()) {
|
||||
WLOGFI("create mirror fail. main screen :%{public}" PRIu64", screens' size:%{public}u",
|
||||
mainScreenId, static_cast<uint32_t>(allMirrorScreenIds.size()));
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:MakeMirror");
|
||||
if (!abstractScreenController_->MakeMirror(mainScreenId, allMirrorScreenIds)) {
|
||||
DMError ret = abstractScreenController_->MakeMirror(mainScreenId, allMirrorScreenIds);
|
||||
if (ret != DMError::DM_OK) {
|
||||
WLOGFE("make mirror failed.");
|
||||
return SCREEN_ID_INVALID;
|
||||
return ret;
|
||||
}
|
||||
if (abstractScreenController_->GetAbstractScreenGroup(mainScreen->groupDmsId_) == nullptr) {
|
||||
WLOGFE("get screen group failed.");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return mainScreen->groupDmsId_;
|
||||
screenGroupId = mainScreen->groupDmsId_;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
void DisplayManagerService::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)
|
||||
@ -575,14 +580,13 @@ std::vector<DisplayId> DisplayManagerService::GetAllDisplayIds()
|
||||
return abstractDisplayController_->GetAllDisplayIds();
|
||||
}
|
||||
|
||||
std::vector<sptr<ScreenInfo>> DisplayManagerService::GetAllScreenInfos()
|
||||
DMError DisplayManagerService::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("get all screen infos permission denied!");
|
||||
return std::vector<sptr<ScreenInfo>>();
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
std::vector<ScreenId> screenIds = abstractScreenController_->GetAllScreenIds();
|
||||
std::vector<sptr<ScreenInfo>> screenInfos;
|
||||
for (auto screenId: screenIds) {
|
||||
auto screenInfo = GetScreenInfoById(screenId);
|
||||
if (screenInfo == nullptr) {
|
||||
@ -591,20 +595,21 @@ std::vector<sptr<ScreenInfo>> DisplayManagerService::GetAllScreenInfos()
|
||||
}
|
||||
screenInfos.emplace_back(screenInfo);
|
||||
}
|
||||
return screenInfos;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
ScreenId DisplayManagerService::MakeExpand(std::vector<ScreenId> expandScreenIds, std::vector<Point> startPoints)
|
||||
DMError DisplayManagerService::MakeExpand(std::vector<ScreenId> expandScreenIds, std::vector<Point> startPoints,
|
||||
ScreenId& screenGroupId)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("make expand permission denied!");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (expandScreenIds.empty() || startPoints.empty() || expandScreenIds.size() != startPoints.size()) {
|
||||
WLOGFI("create expand fail, input params is invalid. "
|
||||
"screenId vector size :%{public}ud, startPoint vector size :%{public}ud",
|
||||
static_cast<uint32_t>(expandScreenIds.size()), static_cast<uint32_t>(startPoints.size()));
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
std::map<ScreenId, Point> pointsMap;
|
||||
uint32_t size = expandScreenIds.size();
|
||||
@ -623,7 +628,7 @@ ScreenId DisplayManagerService::MakeExpand(std::vector<ScreenId> expandScreenIds
|
||||
}
|
||||
if (allExpandScreenIds.empty()) {
|
||||
WLOGFE("allExpandScreenIds is empty. make expand failed.");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
std::shared_ptr<RSDisplayNode> rsDisplayNode;
|
||||
std::vector<Point> points;
|
||||
@ -638,53 +643,55 @@ ScreenId DisplayManagerService::MakeExpand(std::vector<ScreenId> expandScreenIds
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:MakeExpand");
|
||||
if (!abstractScreenController_->MakeExpand(allExpandScreenIds, points)) {
|
||||
WLOGFE("make expand failed.");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
auto screen = abstractScreenController_->GetAbstractScreen(allExpandScreenIds[0]);
|
||||
if (screen == nullptr || abstractScreenController_->GetAbstractScreenGroup(screen->groupDmsId_) == nullptr) {
|
||||
WLOGFE("get screen group failed.");
|
||||
return SCREEN_ID_INVALID;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return screen->groupDmsId_;
|
||||
screenGroupId = screen->groupDmsId_;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
bool DisplayManagerService::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
DMError DisplayManagerService::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set screen active permission denied!");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetScreenActiveMode(%" PRIu64", %u)", screenId, modeId);
|
||||
return abstractScreenController_->SetScreenActiveMode(screenId, modeId);
|
||||
}
|
||||
|
||||
bool DisplayManagerService::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
|
||||
DMError DisplayManagerService::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set virtual pixel permission denied!");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetVirtualPixelRatio(%" PRIu64", %f)", screenId,
|
||||
virtualPixelRatio);
|
||||
return abstractScreenController_->SetVirtualPixelRatio(screenId, virtualPixelRatio);
|
||||
}
|
||||
|
||||
bool DisplayManagerService::IsScreenRotationLocked()
|
||||
DMError DisplayManagerService::IsScreenRotationLocked(bool& isLocked)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("is screen rotation locked permission denied!");
|
||||
return false;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
return ScreenRotationController::IsScreenRotationLocked();
|
||||
isLocked = ScreenRotationController::IsScreenRotationLocked();
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
void DisplayManagerService::SetScreenRotationLocked(bool isLocked)
|
||||
DMError DisplayManagerService::SetScreenRotationLocked(bool isLocked)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set screen rotation locked permission denied!");
|
||||
return;
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
ScreenRotationController::SetScreenRotationLocked(isLocked);
|
||||
return ScreenRotationController::SetScreenRotationLocked(isLocked);
|
||||
}
|
||||
|
||||
void DisplayManagerService::SetGravitySensorSubscriptionEnabled()
|
||||
|
@ -133,11 +133,11 @@ void DisplayManagerServiceInner::RegisterDisplayChangeListener(sptr<IDisplayChan
|
||||
DisplayManagerService::GetInstance().RegisterDisplayChangeListener(listener);
|
||||
}
|
||||
|
||||
bool DisplayManagerServiceInner::SetOrientationFromWindow(DisplayId displayId, Orientation orientation)
|
||||
DMError DisplayManagerServiceInner::SetOrientationFromWindow(DisplayId displayId, Orientation orientation)
|
||||
{
|
||||
auto displayInfo = GetDisplayById(displayId);
|
||||
if (displayInfo == nullptr) {
|
||||
return false;
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
return DisplayManagerService::GetInstance().
|
||||
SetOrientationFromWindow(displayInfo->GetScreenId(), orientation);
|
||||
|
@ -106,7 +106,8 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
case DisplayManagerMessage::TRANS_ID_SET_ORIENTATION: {
|
||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||
Orientation orientation = static_cast<Orientation>(data.ReadUint32());
|
||||
reply.WriteBool(SetOrientation(screenId, orientation));
|
||||
DMError ret = SetOrientation(screenId, orientation);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT: {
|
||||
@ -118,13 +119,15 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
case DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT: {
|
||||
auto agent = iface_cast<IDisplayManagerAgent>(data.ReadRemoteObject());
|
||||
auto type = static_cast<DisplayManagerAgentType>(data.ReadUint32());
|
||||
reply.WriteBool(RegisterDisplayManagerAgent(agent, type));
|
||||
DMError ret = RegisterDisplayManagerAgent(agent, type);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT: {
|
||||
auto agent = iface_cast<IDisplayManagerAgent>(data.ReadRemoteObject());
|
||||
auto type = static_cast<DisplayManagerAgentType>(data.ReadUint32());
|
||||
reply.WriteBool(UnregisterDisplayManagerAgent(agent, type));
|
||||
DMError ret = UnregisterDisplayManagerAgent(agent, type);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN: {
|
||||
@ -188,8 +191,10 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
WLOGE("fail to receive mirror screen in stub. screen:%{public}" PRIu64"", mainScreenId);
|
||||
break;
|
||||
}
|
||||
ScreenId result = MakeMirror(mainScreenId, mirrorScreenId);
|
||||
reply.WriteUint64(static_cast<uint64_t>(result));
|
||||
ScreenId screenGroupId = INVALID_SCREEN_ID;
|
||||
DMError ret = MakeMirror(mainScreenId, mirrorScreenId, screenGroupId);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
reply.WriteUint64(static_cast<uint64_t>(screenGroupId));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID: {
|
||||
@ -205,7 +210,9 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS: {
|
||||
std::vector<sptr<ScreenInfo>> screenInfos = GetAllScreenInfos();
|
||||
std::vector<sptr<ScreenInfo>> screenInfos;
|
||||
DMError ret = GetAllScreenInfos(screenInfos);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
if (!MarshallingHelper::MarshallingVectorParcelableObj<ScreenInfo>(reply, screenInfos)) {
|
||||
WLOGE("fail to marshalling screenInfos in stub.");
|
||||
}
|
||||
@ -229,8 +236,10 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
WLOGE("fail to receive startPoint in stub.");
|
||||
break;
|
||||
}
|
||||
ScreenId result = MakeExpand(screenId, startPoint);
|
||||
reply.WriteUint64(static_cast<uint64_t>(result));
|
||||
ScreenId screenGroupId = INVALID_SCREEN_ID;
|
||||
DMError ret = MakeExpand(screenId, startPoint, screenGroupId);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
reply.WriteUint64(static_cast<uint64_t>(screenGroupId));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP: {
|
||||
@ -245,15 +254,15 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE: {
|
||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||
uint32_t modeId = data.ReadUint32();
|
||||
bool res = SetScreenActiveMode(screenId, modeId);
|
||||
reply.WriteBool(res);
|
||||
DMError ret = SetScreenActiveMode(screenId, modeId);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO: {
|
||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||
float virtualPixelRatio = data.ReadFloat();
|
||||
bool res = SetVirtualPixelRatio(screenId, virtualPixelRatio);
|
||||
reply.WriteBool(res);
|
||||
DMError ret = SetVirtualPixelRatio(screenId, virtualPixelRatio);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS: {
|
||||
@ -314,13 +323,16 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED: {
|
||||
bool isLocked = IsScreenRotationLocked();
|
||||
bool isLocked = false;
|
||||
DMError ret = IsScreenRotationLocked(isLocked);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
reply.WriteBool(isLocked);
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED: {
|
||||
bool isLocked = static_cast<bool>(data.ReadBool());
|
||||
SetScreenRotationLocked(isLocked);
|
||||
DMError ret = SetScreenRotationLocked(isLocked);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_HAS_PRIVATE_WINDOW: {
|
||||
|
@ -53,20 +53,21 @@ bool ScreenRotationController::IsScreenRotationLocked()
|
||||
return isScreenRotationLocked_;
|
||||
}
|
||||
|
||||
void ScreenRotationController::SetScreenRotationLocked(bool isLocked)
|
||||
DMError ScreenRotationController::SetScreenRotationLocked(bool isLocked)
|
||||
{
|
||||
isScreenRotationLocked_ = isLocked;
|
||||
if (isLocked) {
|
||||
rotationLockedRotation_ = GetCurrentDisplayRotation();
|
||||
return;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
if (GetCurrentDisplayRotation() == ConvertDeviceToDisplayRotation(lastSensorRotationConverted_)) {
|
||||
return;
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
Orientation currentOrientation = GetPreferredOrientation();
|
||||
if (IsSensorRelatedOrientation(currentOrientation)) {
|
||||
ProcessSwitchToSensorRelatedOrientation(currentOrientation, lastSensorRotationConverted_);
|
||||
}
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
void ScreenRotationController::SetDefaultDeviceRotationOffset(uint32_t defaultDeviceRotationOffset)
|
||||
|
@ -140,7 +140,7 @@ HWTEST_F(AbstractScreenControllerTest, SetScreenRotateAnimation01, Function | Sm
|
||||
HWTEST_F(AbstractScreenControllerTest, MakeMirror01, Function | SmallTest | Level3)
|
||||
{
|
||||
std::vector<ScreenId> screens;
|
||||
ASSERT_EQ(false, absController_->MakeMirror(5, screens));
|
||||
ASSERT_TRUE(DMError::DM_OK != absController_->MakeMirror(5, screens));
|
||||
}
|
||||
/**
|
||||
* @tc.name: MakeMirror
|
||||
@ -151,7 +151,7 @@ HWTEST_F(AbstractScreenControllerTest, MakeMirror02, Function | SmallTest | Leve
|
||||
{
|
||||
std::vector<ScreenId> screens;
|
||||
absController_->dmsScreenMap_[2]->type_ = ScreenType::UNDEFINED;
|
||||
ASSERT_EQ(false, absController_->MakeMirror(2, screens));
|
||||
ASSERT_TRUE(DMError::DM_OK != absController_->MakeMirror(2, screens));
|
||||
}
|
||||
/**
|
||||
* @tc.name: MakeMirror
|
||||
@ -164,7 +164,7 @@ HWTEST_F(AbstractScreenControllerTest, MakeMirror03, Function | SmallTest | Leve
|
||||
absController_->dmsScreenMap_[2]->type_ = ScreenType::REAL;
|
||||
absController_->dmsScreenMap_[2]->groupDmsId_ = 5;
|
||||
absController_->abstractScreenCallback_ = nullptr;
|
||||
ASSERT_EQ(false, absController_->MakeMirror(2, screens));
|
||||
ASSERT_TRUE(DMError::DM_OK != absController_->MakeMirror(2, screens));
|
||||
}
|
||||
/**
|
||||
* @tc.name: MakeMirror
|
||||
@ -177,7 +177,7 @@ HWTEST_F(AbstractScreenControllerTest, MakeMirror04, Function | SmallTest | Leve
|
||||
absController_->dmsScreenMap_[2]->type_ = ScreenType::REAL;
|
||||
absController_->dmsScreenMap_[2]->groupDmsId_ = 5;
|
||||
absController_->abstractScreenCallback_ = new AbstractScreenController::AbstractScreenCallback;
|
||||
ASSERT_EQ(false, absController_->MakeMirror(2, screens));
|
||||
ASSERT_TRUE(DMError::DM_OK != absController_->MakeMirror(2, screens));
|
||||
}
|
||||
/**
|
||||
* @tc.name: ProcessScreenConnected
|
||||
@ -436,7 +436,7 @@ HWTEST_F(AbstractScreenControllerTest, SetOrientation01, Function | SmallTest |
|
||||
{
|
||||
absController_->dmsScreenMap_[1]->isScreenGroup_ = true;
|
||||
Orientation orientation = Orientation::BEGIN;
|
||||
ASSERT_EQ(false, absController_->SetOrientation(1, orientation, true));
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, absController_->SetOrientation(1, orientation, true));
|
||||
}
|
||||
/**
|
||||
* @tc.name: SetRotation
|
||||
@ -456,7 +456,7 @@ HWTEST_F(AbstractScreenControllerTest, SetRotation01, Function | SmallTest | Lev
|
||||
*/
|
||||
HWTEST_F(AbstractScreenControllerTest, SetScreenActiveMode01, Function | SmallTest | Level3)
|
||||
{
|
||||
ASSERT_EQ(false, absController_->SetScreenActiveMode(5, 0));
|
||||
ASSERT_TRUE(DMError::DM_OK != absController_->SetScreenActiveMode(5, 0));
|
||||
}
|
||||
/**
|
||||
* @tc.name: SetScreenActiveMode
|
||||
@ -466,7 +466,7 @@ HWTEST_F(AbstractScreenControllerTest, SetScreenActiveMode01, Function | SmallTe
|
||||
HWTEST_F(AbstractScreenControllerTest, SetScreenActiveMode02, Function | SmallTest | Level3)
|
||||
{
|
||||
absController_->screenIdManager_.dms2RsScreenIdMap_.erase(1);
|
||||
ASSERT_EQ(false, absController_->SetScreenActiveMode(1, 0));
|
||||
ASSERT_TRUE(DMError::DM_OK != absController_->SetScreenActiveMode(1, 0));
|
||||
}
|
||||
/**
|
||||
* @tc.name: ProcessScreenModeChanged
|
||||
@ -719,7 +719,7 @@ HWTEST_F(AbstractScreenControllerTest, SetVirtualPixelRatio01, Function | SmallT
|
||||
ScreenId id = 0;
|
||||
float ratio = 1.0;
|
||||
screen->isScreenGroup_ = true;
|
||||
ASSERT_EQ(false, absController_->SetVirtualPixelRatio(id, ratio));
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, absController_->SetVirtualPixelRatio(id, ratio));
|
||||
}
|
||||
/**
|
||||
* @tc.name: SetVirtualPixelRatio
|
||||
@ -731,7 +731,7 @@ HWTEST_F(AbstractScreenControllerTest, SetVirtualPixelRatio02, Function | SmallT
|
||||
ScreenId id = 0;
|
||||
float ratio = 1.0;
|
||||
absController_->abstractScreenCallback_ = nullptr;
|
||||
ASSERT_EQ(true, absController_->SetVirtualPixelRatio(id, ratio));
|
||||
ASSERT_EQ(DMError::DM_OK, absController_->SetVirtualPixelRatio(id, ratio));
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
@ -209,18 +209,18 @@ HWTEST_F(DisplayManagerProxyTest, SetOrientation01, Function | SmallTest | Level
|
||||
DisplayManagerProxy proxy1(nullptr);
|
||||
ASSERT_EQ(nullptr, proxy1.remoteObject_);
|
||||
auto result1 = proxy1.SetOrientation(0, Orientation::VERTICAL);
|
||||
ASSERT_EQ(false, result1);
|
||||
ASSERT_TRUE(DMError::DM_OK != result1);
|
||||
|
||||
sptr<RemoteMocker> remoteMocker = new RemoteMocker();
|
||||
DisplayManagerProxy proxy2(remoteMocker);
|
||||
ASSERT_EQ(static_cast<sptr<IRemoteObject>>(remoteMocker), proxy2.remoteObject_);
|
||||
|
||||
auto result2 = proxy2.SetOrientation(0, Orientation::VERTICAL);
|
||||
ASSERT_EQ(false, result2);
|
||||
ASSERT_TRUE(DMError::DM_OK == result2);
|
||||
|
||||
remoteMocker->sendRequestResult_ = 1;
|
||||
auto result3 = proxy2.SetOrientation(0, Orientation::VERTICAL);
|
||||
ASSERT_EQ(false, result3);
|
||||
ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3);
|
||||
}
|
||||
/**
|
||||
* @tc.name: GetDisplaySnapshot01
|
||||
|
@ -220,7 +220,8 @@ HWTEST_F(DisplayManagerServiceTest, GetDisplayInfo, Function | SmallTest | Level
|
||||
ASSERT_EQ(SCREEN_ID_INVALID, dms_->GetScreenGroupIdByScreenId(0));
|
||||
|
||||
dms_->GetAllDisplayIds();
|
||||
dms_->GetAllScreenInfos();
|
||||
std::vector<sptr<ScreenInfo>> screenInfos;
|
||||
dms_->GetAllScreenInfos(screenInfos);
|
||||
|
||||
dms_->abstractDisplayController_->abstractDisplayMap_.clear();
|
||||
}
|
||||
@ -250,8 +251,8 @@ HWTEST_F(DisplayManagerServiceTest, VirtualScreen, Function | SmallTest | Level3
|
||||
HWTEST_F(DisplayManagerServiceTest, OrientationAndRotation, Function | SmallTest | Level3)
|
||||
{
|
||||
Orientation orientation = Orientation::UNSPECIFIED;
|
||||
ASSERT_EQ(false, dms_->SetOrientation(0, orientation));
|
||||
ASSERT_EQ(false, dms_->SetOrientationFromWindow(0, orientation));
|
||||
ASSERT_TRUE(DMError::DM_OK != dms_->SetOrientation(0, orientation));
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->SetOrientationFromWindow(0, orientation));
|
||||
Rotation rotation = Rotation::ROTATION_0;
|
||||
ASSERT_EQ(false, dms_->SetRotationFromWindow(0, rotation));
|
||||
}
|
||||
@ -299,13 +300,13 @@ HWTEST_F(DisplayManagerServiceTest, RegisterDisplayManagerAgent, Function | Smal
|
||||
sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
|
||||
DisplayManagerAgentType type = DisplayManagerAgentType::DISPLAY_STATE_LISTENER;
|
||||
|
||||
ASSERT_EQ(false, dms_->RegisterDisplayManagerAgent(nullptr, type));
|
||||
ASSERT_EQ(false, dms_->UnregisterDisplayManagerAgent(nullptr, type));
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->RegisterDisplayManagerAgent(nullptr, type));
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->UnregisterDisplayManagerAgent(nullptr, type));
|
||||
|
||||
ASSERT_EQ(false, dms_->UnregisterDisplayManagerAgent(displayManagerAgent, type));
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->UnregisterDisplayManagerAgent(displayManagerAgent, type));
|
||||
|
||||
ASSERT_EQ(true, dms_->RegisterDisplayManagerAgent(displayManagerAgent, type));
|
||||
ASSERT_EQ(true, dms_->UnregisterDisplayManagerAgent(displayManagerAgent, type));
|
||||
ASSERT_EQ(DMError::DM_OK, dms_->RegisterDisplayManagerAgent(displayManagerAgent, type));
|
||||
ASSERT_EQ(DMError::DM_OK, dms_->UnregisterDisplayManagerAgent(displayManagerAgent, type));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -352,11 +353,15 @@ HWTEST_F(DisplayManagerServiceTest, RsDisplayNode, Function | SmallTest | Level3
|
||||
HWTEST_F(DisplayManagerServiceTest, MirrorAndExpand, Function | SmallTest | Level3)
|
||||
{
|
||||
std::vector<ScreenId> mirrorScreenIds;
|
||||
ASSERT_EQ(SCREEN_ID_INVALID, dms_->MakeMirror(DISPLAY_ID_INVALID, mirrorScreenIds));
|
||||
ScreenId screenGroupId1 = DISPLAY_ID_INVALID;
|
||||
dms_->MakeMirror(DISPLAY_ID_INVALID, mirrorScreenIds, screenGroupId1);
|
||||
ASSERT_EQ(SCREEN_ID_INVALID, screenGroupId1);
|
||||
|
||||
std::vector<ScreenId> expandScreenIds;
|
||||
std::vector<Point> startPoints;
|
||||
ASSERT_EQ(SCREEN_ID_INVALID, dms_->MakeExpand(expandScreenIds, startPoints));
|
||||
ScreenId screenGroupId2 = DISPLAY_ID_INVALID;
|
||||
dms_->MakeExpand(expandScreenIds, startPoints, screenGroupId2);
|
||||
ASSERT_EQ(SCREEN_ID_INVALID, screenGroupId2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -366,7 +371,7 @@ HWTEST_F(DisplayManagerServiceTest, MirrorAndExpand, Function | SmallTest | Leve
|
||||
*/
|
||||
HWTEST_F(DisplayManagerServiceTest, ScreenActiveMode, Function | SmallTest | Level3)
|
||||
{
|
||||
ASSERT_EQ(false, dms_->SetScreenActiveMode(SCREEN_ID_INVALID, 0));
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->SetScreenActiveMode(SCREEN_ID_INVALID, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -376,19 +381,7 @@ HWTEST_F(DisplayManagerServiceTest, ScreenActiveMode, Function | SmallTest | Lev
|
||||
*/
|
||||
HWTEST_F(DisplayManagerServiceTest, VirtualPixelRatio, Function | SmallTest | Level3)
|
||||
{
|
||||
ASSERT_EQ(false, dms_->SetVirtualPixelRatio(SCREEN_ID_INVALID, 0.f));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ScreenRotationLock
|
||||
* @tc.desc: DMS mirror
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerServiceTest, ScreenRotationLock, Function | SmallTest | Level3)
|
||||
{
|
||||
dms_->SetScreenRotationLocked(false);
|
||||
ASSERT_EQ(false, dms_->IsScreenRotationLocked());
|
||||
ASSERT_NE(nullptr, dms_->GetCutoutInfo(10));
|
||||
ASSERT_TRUE(DMError::DM_OK != dms_->SetVirtualPixelRatio(SCREEN_ID_INVALID, 0.f));
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
@ -66,12 +66,12 @@ public:
|
||||
bool Freeze(std::vector<DisplayId> displayIds);
|
||||
bool Unfreeze(std::vector<DisplayId> displayIds);
|
||||
|
||||
bool RegisterDisplayListener(sptr<IDisplayListener> listener);
|
||||
bool UnregisterDisplayListener(sptr<IDisplayListener> listener);
|
||||
bool RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener);
|
||||
bool UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener);
|
||||
bool RegisterScreenshotListener(sptr<IScreenshotListener> listener);
|
||||
bool UnregisterScreenshotListener(sptr<IScreenshotListener> listener);
|
||||
DMError RegisterDisplayListener(sptr<IDisplayListener> listener);
|
||||
DMError UnregisterDisplayListener(sptr<IDisplayListener> listener);
|
||||
DMError RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener);
|
||||
DMError UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener);
|
||||
DMError RegisterScreenshotListener(sptr<IScreenshotListener> listener);
|
||||
DMError UnregisterScreenshotListener(sptr<IScreenshotListener> listener);
|
||||
|
||||
constexpr static int32_t MAX_RESOLUTION_SIZE_SCREENSHOT = 3840; // max resolution, 4K
|
||||
|
||||
|
@ -73,12 +73,14 @@ enum class DMError : int32_t {
|
||||
DM_ERROR_UNREGISTER_AGENT_FAILED = 190,
|
||||
DM_ERROR_INVALID_CALLING = 200,
|
||||
DM_ERROR_INVALID_PERMISSION = 201,
|
||||
DM_ERROR_NOT_SYSTEM_APP = 202,
|
||||
DM_ERROR_UNKNOWN = -1,
|
||||
};
|
||||
|
||||
enum class DmErrorCode : int32_t {
|
||||
DM_OK = 0,
|
||||
DM_ERROR_NO_PERMISSION = 201,
|
||||
DM_ERROR_NOT_SYSTEM_APP = 202,
|
||||
DM_ERROR_INVALID_PARAM = 401,
|
||||
DM_ERROR_DEVICE_NOT_SUPPORT = 801,
|
||||
DM_ERROR_INVALID_SCREEN = 1400001,
|
||||
@ -101,6 +103,7 @@ const std::map<DMError, DmErrorCode> DM_JS_TO_ERROR_CODE_MAP {
|
||||
{DMError::DM_ERROR_RENDER_SERVICE_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL },
|
||||
{DMError::DM_ERROR_UNREGISTER_AGENT_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL },
|
||||
{DMError::DM_ERROR_INVALID_CALLING, DmErrorCode::DM_ERROR_INVALID_CALLING },
|
||||
{DMError::DM_ERROR_NOT_SYSTEM_APP, DmErrorCode::DM_ERROR_NOT_SYSTEM_APP },
|
||||
{DMError::DM_ERROR_UNKNOWN, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL },
|
||||
};
|
||||
|
||||
|
@ -78,9 +78,9 @@ public:
|
||||
ScreenId GetParentId() const;
|
||||
uint32_t GetModeId() const;
|
||||
std::vector<sptr<SupportedScreenModes>> GetSupportedModes() const;
|
||||
bool SetScreenActiveMode(uint32_t modeId);
|
||||
bool SetOrientation(Orientation orientation) const;
|
||||
bool SetDensityDpi(uint32_t dpi) const;
|
||||
DMError SetScreenActiveMode(uint32_t modeId);
|
||||
DMError SetOrientation(Orientation orientation) const;
|
||||
DMError SetDensityDpi(uint32_t dpi) const;
|
||||
sptr<ScreenInfo> GetScreenInfo() const;
|
||||
|
||||
// colorspace, gamut
|
||||
|
@ -52,10 +52,10 @@ public:
|
||||
|
||||
sptr<Screen> GetScreenById(ScreenId screenId);
|
||||
sptr<ScreenGroup> GetScreenGroup(ScreenId groupId);
|
||||
std::vector<sptr<Screen>> GetAllScreens();
|
||||
DMError GetAllScreens(std::vector<sptr<Screen>>& screens);
|
||||
|
||||
ScreenId MakeExpand(const std::vector<ExpandOption>& options);
|
||||
ScreenId MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId);
|
||||
DMError MakeExpand(const std::vector<ExpandOption>& options, ScreenId& screenGroupId);
|
||||
DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId, ScreenId& screenGroupId);
|
||||
DMError RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens);
|
||||
ScreenId CreateVirtualScreen(VirtualScreenOption option);
|
||||
DMError DestroyVirtualScreen(ScreenId screenId);
|
||||
@ -63,14 +63,14 @@ public:
|
||||
bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason);
|
||||
ScreenPowerState GetScreenPower(ScreenId screenId);
|
||||
DMError SetScreenRotationLocked(bool isLocked);
|
||||
bool IsScreenRotationLocked();
|
||||
DMError IsScreenRotationLocked(bool& isLocked);
|
||||
|
||||
bool RegisterScreenListener(sptr<IScreenListener> listener);
|
||||
bool UnregisterScreenListener(sptr<IScreenListener> listener);
|
||||
bool RegisterScreenGroupListener(sptr<IScreenGroupListener> listener);
|
||||
bool UnregisterScreenGroupListener(sptr<IScreenGroupListener> listener);
|
||||
bool RegisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener);
|
||||
bool UnregisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener);
|
||||
DMError RegisterScreenListener(sptr<IScreenListener> listener);
|
||||
DMError UnregisterScreenListener(sptr<IScreenListener> listener);
|
||||
DMError RegisterScreenGroupListener(sptr<IScreenGroupListener> listener);
|
||||
DMError UnregisterScreenGroupListener(sptr<IScreenGroupListener> listener);
|
||||
DMError RegisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener);
|
||||
DMError UnregisterVirtualScreenGroupListener(sptr<IVirtualScreenGroupListener> listener);
|
||||
private:
|
||||
ScreenManager();
|
||||
~ScreenManager();
|
||||
|
@ -151,6 +151,7 @@ public:
|
||||
virtual void OnDialogDeathRecipient() const = 0;
|
||||
};
|
||||
|
||||
static WMError DefaultCreateErrCode = WMError::WM_OK;
|
||||
class Window : public RefBase {
|
||||
public:
|
||||
/**
|
||||
@ -162,7 +163,8 @@ public:
|
||||
* @return sptr<Window> If create window success,return window instance;Otherwise, return nullptr
|
||||
*/
|
||||
static sptr<Window> Create(const std::string& windowName,
|
||||
sptr<WindowOption>& option, const std::shared_ptr<AbilityRuntime::Context>& context = nullptr);
|
||||
sptr<WindowOption>& option, const std::shared_ptr<AbilityRuntime::Context>& context = nullptr,
|
||||
WMError& errCode = DefaultCreateErrCode);
|
||||
/**
|
||||
* @brief find window by windowName
|
||||
*
|
||||
@ -252,8 +254,8 @@ public:
|
||||
* @return WMError
|
||||
*/
|
||||
virtual WMError SetWindowMode(WindowMode mode) = 0;
|
||||
virtual void SetAlpha(float alpha) = 0;
|
||||
virtual void SetTransform(const Transform& trans) = 0;
|
||||
virtual WMError SetAlpha(float alpha) = 0;
|
||||
virtual WMError SetTransform(const Transform& trans) = 0;
|
||||
virtual const Transform& GetTransform() const = 0;
|
||||
virtual WMError AddWindowFlag(WindowFlag flag) = 0;
|
||||
virtual WMError RemoveWindowFlag(WindowFlag flag) = 0;
|
||||
@ -328,19 +330,19 @@ public:
|
||||
virtual WMError SetBrightness(float brightness) = 0;
|
||||
virtual float GetBrightness() const = 0;
|
||||
virtual WMError SetCallingWindow(uint32_t windowId) = 0;
|
||||
virtual void SetPrivacyMode(bool isPrivacyMode) = 0;
|
||||
virtual WMError SetPrivacyMode(bool isPrivacyMode) = 0;
|
||||
virtual bool IsPrivacyMode() const = 0;
|
||||
virtual void SetSystemPrivacyMode(bool isSystemPrivacyMode) = 0;
|
||||
virtual WMError BindDialogTarget(sptr<IRemoteObject> targetToken) = 0;
|
||||
virtual void SetSnapshotSkip(bool isSkip) = 0;
|
||||
virtual WmErrorCode RaiseToAppTop() = 0;
|
||||
virtual WMError SetSnapshotSkip(bool isSkip) = 0;
|
||||
|
||||
// window effect
|
||||
virtual WMError SetCornerRadius(float cornerRadius) = 0;
|
||||
virtual WMError SetShadowRadius(float radius) = 0;
|
||||
virtual WMError SetShadowColor(std::string color) = 0;
|
||||
virtual void SetShadowOffsetX(float offsetX) = 0;
|
||||
virtual void SetShadowOffsetY(float offsetY) = 0;
|
||||
virtual WMError SetShadowOffsetX(float offsetX) = 0;
|
||||
virtual WMError SetShadowOffsetY(float offsetY) = 0;
|
||||
virtual WMError SetBlur(float radius) = 0;
|
||||
virtual WMError SetBackdropBlur(float radius) = 0;
|
||||
virtual WMError SetBackdropBlurStyle(WindowBlurStyle blurStyle) = 0;
|
||||
@ -358,26 +360,26 @@ public:
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
virtual bool RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) = 0;
|
||||
virtual bool RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) = 0;
|
||||
virtual bool UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) = 0;
|
||||
virtual bool UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) = 0;
|
||||
virtual bool RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) = 0;
|
||||
virtual bool UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) = 0;
|
||||
virtual bool RegisterDragListener(const sptr<IWindowDragListener>& listener) = 0;
|
||||
virtual bool UnregisterDragListener(const sptr<IWindowDragListener>& listener) = 0;
|
||||
virtual bool RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) = 0;
|
||||
virtual bool UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) = 0;
|
||||
virtual WMError RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) = 0;
|
||||
virtual WMError UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) = 0;
|
||||
virtual WMError RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) = 0;
|
||||
virtual WMError UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) = 0;
|
||||
virtual WMError RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) = 0;
|
||||
virtual WMError UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) = 0;
|
||||
virtual WMError RegisterDragListener(const sptr<IWindowDragListener>& listener) = 0;
|
||||
virtual WMError UnregisterDragListener(const sptr<IWindowDragListener>& listener) = 0;
|
||||
virtual WMError RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) = 0;
|
||||
virtual WMError UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) = 0;
|
||||
virtual void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) = 0;
|
||||
virtual bool RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) = 0;
|
||||
virtual bool UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) = 0;
|
||||
virtual bool RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) = 0;
|
||||
virtual bool UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) = 0;
|
||||
virtual bool RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener) = 0;
|
||||
virtual bool RegisterScreenshotListener(const sptr<IScreenshotListener>& listener) = 0;
|
||||
virtual bool UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener) = 0;
|
||||
virtual bool RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) = 0;
|
||||
virtual bool UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) = 0;
|
||||
virtual WMError RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) = 0;
|
||||
virtual WMError UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) = 0;
|
||||
virtual WMError RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) = 0;
|
||||
virtual WMError UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) = 0;
|
||||
virtual WMError RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener) = 0;
|
||||
virtual WMError RegisterScreenshotListener(const sptr<IScreenshotListener>& listener) = 0;
|
||||
virtual WMError UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener) = 0;
|
||||
virtual WMError RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) = 0;
|
||||
virtual WMError UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) = 0;
|
||||
virtual void RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) = 0;
|
||||
virtual void UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) = 0;
|
||||
virtual void NotifyTouchDialogTarget() = 0;
|
||||
@ -411,7 +413,7 @@ public:
|
||||
* @brief disable main window decoration. It must be callled before loadContent.
|
||||
*
|
||||
*/
|
||||
virtual void DisableAppWindowDecor() = 0;
|
||||
virtual WMError DisableAppWindowDecor() = 0;
|
||||
/**
|
||||
* @brief return window decoration is enabled. It is called by ACE
|
||||
*
|
||||
|
@ -121,17 +121,17 @@ WM_DECLARE_SINGLE_INSTANCE_BASE(WindowManager);
|
||||
friend class WindowManagerAgent;
|
||||
friend class WMSDeathRecipient;
|
||||
public:
|
||||
bool RegisterFocusChangedListener(const sptr<IFocusChangedListener>& listener);
|
||||
bool UnregisterFocusChangedListener(const sptr<IFocusChangedListener>& listener);
|
||||
bool RegisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener);
|
||||
bool UnregisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener);
|
||||
bool RegisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener);
|
||||
bool UnregisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener);
|
||||
bool RegisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
|
||||
bool UnregisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
|
||||
bool RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener);
|
||||
bool UnregisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener);
|
||||
void MinimizeAllAppWindows(DisplayId displayId);
|
||||
WMError RegisterFocusChangedListener(const sptr<IFocusChangedListener>& listener);
|
||||
WMError UnregisterFocusChangedListener(const sptr<IFocusChangedListener>& listener);
|
||||
WMError RegisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener);
|
||||
WMError UnregisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener);
|
||||
WMError RegisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener);
|
||||
WMError UnregisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener);
|
||||
WMError RegisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
|
||||
WMError UnregisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
|
||||
WMError RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener);
|
||||
WMError UnregisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener);
|
||||
WMError MinimizeAllAppWindows(DisplayId displayId);
|
||||
WMError ToggleShownStateForAllAppWindows();
|
||||
WMError SetWindowLayoutMode(WindowLayoutMode mode);
|
||||
WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) const;
|
||||
|
@ -124,6 +124,7 @@ enum class WMError : int32_t {
|
||||
WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE,
|
||||
WM_ERROR_INVALID_OPERATION,
|
||||
WM_ERROR_INVALID_PERMISSION,
|
||||
WM_ERROR_NOT_SYSTEM_APP,
|
||||
WM_ERROR_NO_REMOTE_ANIMATION,
|
||||
WM_ERROR_INVALID_DISPLAY,
|
||||
WM_ERROR_INVALID_PARENT,
|
||||
@ -145,6 +146,7 @@ enum class WMError : int32_t {
|
||||
enum class WmErrorCode : int32_t {
|
||||
WM_OK = 0,
|
||||
WM_ERROR_NO_PERMISSION = 201,
|
||||
WM_ERROR_NOT_SYSTEM_APP = 202,
|
||||
WM_ERROR_INVALID_PARAM = 401,
|
||||
WM_ERROR_DEVICE_NOT_SUPPORT = 801,
|
||||
WM_ERROR_REPEAT_OPERATION = 1300001,
|
||||
@ -160,26 +162,27 @@ enum class WmErrorCode : int32_t {
|
||||
};
|
||||
|
||||
const std::map<WMError, WmErrorCode> WM_JS_TO_ERROR_CODE_MAP {
|
||||
{WMError::WM_OK, WmErrorCode::WM_OK },
|
||||
{WMError::WM_DO_NOTHING, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_DESTROYED_OBJECT, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_DEVICE_NOT_SUPPORT, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT },
|
||||
{WMError::WM_ERROR_INVALID_OPERATION, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_INVALID_PARAM, WmErrorCode::WM_ERROR_INVALID_PARAM },
|
||||
{WMError::WM_ERROR_INVALID_PERMISSION, WmErrorCode::WM_ERROR_NO_PERMISSION },
|
||||
{WMError::WM_ERROR_INVALID_TYPE, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_INVALID_WINDOW, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_IPC_FAILED, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY },
|
||||
{WMError::WM_ERROR_NO_MEM, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY },
|
||||
{WMError::WM_ERROR_NO_REMOTE_ANIMATION, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY },
|
||||
{WMError::WM_ERROR_INVALID_DISPLAY, WmErrorCode::WM_ERROR_INVALID_DISPLAY },
|
||||
{WMError::WM_ERROR_INVALID_PARENT, WmErrorCode::WM_ERROR_INVALID_PARENT },
|
||||
{WMError::WM_ERROR_OPER_FULLSCREEN_FAILED, WmErrorCode::WM_ERROR_OPER_FULLSCREEN_FAILED },
|
||||
{WMError::WM_ERROR_REPEAT_OPERATION, WmErrorCode::WM_ERROR_REPEAT_OPERATION },
|
||||
{WMError::WM_ERROR_NULLPTR, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_SAMGR, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY },
|
||||
{WMError::WM_ERROR_START_ABILITY_FAILED, WmErrorCode::WM_ERROR_START_ABILITY_FAILED },
|
||||
{WMError::WM_OK, WmErrorCode::WM_OK },
|
||||
{WMError::WM_DO_NOTHING, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_DESTROYED_OBJECT, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_DEVICE_NOT_SUPPORT, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT },
|
||||
{WMError::WM_ERROR_INVALID_OPERATION, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_INVALID_PARAM, WmErrorCode::WM_ERROR_INVALID_PARAM },
|
||||
{WMError::WM_ERROR_INVALID_PERMISSION, WmErrorCode::WM_ERROR_NO_PERMISSION },
|
||||
{WMError::WM_ERROR_NOT_SYSTEM_APP, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP },
|
||||
{WMError::WM_ERROR_INVALID_TYPE, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_INVALID_WINDOW, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_IPC_FAILED, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY },
|
||||
{WMError::WM_ERROR_NO_MEM, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY },
|
||||
{WMError::WM_ERROR_NO_REMOTE_ANIMATION, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY },
|
||||
{WMError::WM_ERROR_INVALID_DISPLAY, WmErrorCode::WM_ERROR_INVALID_DISPLAY },
|
||||
{WMError::WM_ERROR_INVALID_PARENT, WmErrorCode::WM_ERROR_INVALID_PARENT },
|
||||
{WMError::WM_ERROR_OPER_FULLSCREEN_FAILED, WmErrorCode::WM_ERROR_OPER_FULLSCREEN_FAILED },
|
||||
{WMError::WM_ERROR_REPEAT_OPERATION, WmErrorCode::WM_ERROR_REPEAT_OPERATION },
|
||||
{WMError::WM_ERROR_NULLPTR, WmErrorCode::WM_ERROR_STATE_ABNORMALLY },
|
||||
{WMError::WM_ERROR_SAMGR, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY },
|
||||
{WMError::WM_ERROR_START_ABILITY_FAILED, WmErrorCode::WM_ERROR_START_ABILITY_FAILED },
|
||||
};
|
||||
|
||||
enum class WindowFlag : uint32_t {
|
||||
|
@ -96,12 +96,12 @@ NativeValue* JsScreen::OnSetOrientation(NativeEngine& engine, NativeCallbackInfo
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
bool res = screen_->SetOrientation(orientation);
|
||||
if (res) {
|
||||
DmErrorCode ret = DM_JS_TO_ERROR_CODE_MAP.at(screen_->SetOrientation(orientation));
|
||||
if (ret == DmErrorCode::DM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGI("OnSetOrientation success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_SYSTEM_INNORMAL),
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret),
|
||||
"JsScreen::OnSetOrientation failed."));
|
||||
WLOGFE("OnSetOrientation failed");
|
||||
}
|
||||
@ -147,12 +147,12 @@ NativeValue* JsScreen::OnSetScreenActiveMode(NativeEngine& engine, NativeCallbac
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
bool res = screen_->SetScreenActiveMode(modeId);
|
||||
if (res) {
|
||||
DmErrorCode ret = DM_JS_TO_ERROR_CODE_MAP.at(screen_->SetScreenActiveMode(modeId));
|
||||
if (ret == DmErrorCode::DM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGI("OnSetScreenActiveMode success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_SYSTEM_INNORMAL),
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret),
|
||||
"JsScreen::OnSetScreenActiveMode failed."));
|
||||
WLOGFE("OnSetScreenActiveMode failed");
|
||||
}
|
||||
@ -197,12 +197,12 @@ NativeValue* JsScreen::OnSetDensityDpi(NativeEngine& engine, NativeCallbackInfo&
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
bool res = screen_->SetDensityDpi(densityDpi);
|
||||
if (res) {
|
||||
DmErrorCode ret = DM_JS_TO_ERROR_CODE_MAP.at(screen_->SetDensityDpi(densityDpi));
|
||||
if (ret == DmErrorCode::DM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGI("OnSetDensityDpi success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_SYSTEM_INNORMAL),
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret),
|
||||
"JsScreen::OnSetDensityDpi failed."));
|
||||
WLOGFE("OnSetDensityDpi failed");
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
using namespace AbilityRuntime;
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "JsScreenListener"};
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "JsScreenListener"};
|
||||
}
|
||||
inline uint32_t SCREEN_DISCONNECT_TYPE = 0;
|
||||
inline uint32_t SCREEN_CONNECT_TYPE = 1;
|
||||
|
@ -35,7 +35,7 @@ constexpr size_t ARGC_TWO = 2;
|
||||
constexpr size_t ARGC_THREE = 3;
|
||||
constexpr int32_t INDEX_ONE = 1;
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "JsScreenManager"};
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "JsScreenManager"};
|
||||
}
|
||||
|
||||
class JsScreenManager {
|
||||
@ -60,7 +60,7 @@ static NativeValue* GetAllScreens(NativeEngine* engine, NativeCallbackInfo* info
|
||||
static NativeValue* RegisterScreenManagerCallback(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsScreenManager* me = CheckParamsAndGetThis<JsScreenManager>(engine, info);
|
||||
return (me != nullptr) ? me->OnRegisterScreenMangerCallback(*engine, *info) : nullptr;
|
||||
return (me != nullptr) ? me->OnRegisterScreenManagerCallback(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
static NativeValue* UnregisterScreenMangerCallback(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
@ -119,8 +119,12 @@ NativeValue* OnGetAllScreens(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
WLOGI("OnGetAllScreens is called");
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[this](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
std::vector<sptr<Screen>> screens = SingletonContainer::Get<ScreenManager>().GetAllScreens();
|
||||
if (!screens.empty()) {
|
||||
std::vector<sptr<Screen>> screens;
|
||||
auto res = DM_JS_TO_ERROR_CODE_MAP.at(SingletonContainer::Get<ScreenManager>().GetAllScreens(screens));
|
||||
if (res != DmErrorCode::DM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(res),
|
||||
"JsScreenManager::OnGetAllScreens failed."));
|
||||
} else if (!screens.empty()) {
|
||||
task.Resolve(engine, CreateJsScreenVectorObject(engine, screens));
|
||||
WLOGI("JsScreenManager::OnGetAllScreens success");
|
||||
} else {
|
||||
@ -174,37 +178,42 @@ bool IfCallbackRegistered(const std::string& type, NativeValue* jsListenerObject
|
||||
return false;
|
||||
}
|
||||
|
||||
void RegisterScreenListenerWithType(NativeEngine& engine, const std::string& type, NativeValue* value)
|
||||
DmErrorCode RegisterScreenListenerWithType(NativeEngine& engine, const std::string& type, NativeValue* value)
|
||||
{
|
||||
if (IfCallbackRegistered(type, value)) {
|
||||
WLOGFE("JsScreenManager::RegisterScreenListenerWithType callback already registered!");
|
||||
return;
|
||||
return DmErrorCode::DM_ERROR_INVALID_CALLING;
|
||||
}
|
||||
std::unique_ptr<NativeReference> callbackRef;
|
||||
callbackRef.reset(engine.CreateReference(value, 1));
|
||||
sptr<JsScreenListener> screenListener = new(std::nothrow) JsScreenListener(&engine);
|
||||
if (screenListener == nullptr) {
|
||||
WLOGFE("screenListener is nullptr");
|
||||
return;
|
||||
return DmErrorCode::DM_ERROR_INVALID_SCREEN;
|
||||
}
|
||||
if (type == EVENT_CONNECT || type == EVENT_DISCONNECT || type == EVENT_CHANGE) {
|
||||
SingletonContainer::Get<ScreenManager>().RegisterScreenListener(screenListener);
|
||||
DmErrorCode ret = DM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<ScreenManager>().RegisterScreenListener(screenListener));
|
||||
if (ret != DmErrorCode::DM_OK) {
|
||||
return ret;
|
||||
}
|
||||
WLOGI("JsScreenManager::RegisterScreenListenerWithType success");
|
||||
} else {
|
||||
WLOGFE("JsScreenManager::RegisterScreenListenerWithType failed method: %{public}s not support!",
|
||||
type.c_str());
|
||||
return;
|
||||
return DmErrorCode::DM_ERROR_INVALID_CALLING;
|
||||
}
|
||||
screenListener->AddCallback(type, value);
|
||||
jsCbMap_[type][std::move(callbackRef)] = screenListener;
|
||||
return DmErrorCode::DM_OK;
|
||||
}
|
||||
|
||||
void UnregisterAllScreenListenerWithType(const std::string& type)
|
||||
DmErrorCode UnregisterAllScreenListenerWithType(const std::string& type)
|
||||
{
|
||||
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
|
||||
WLOGI("JsScreenManager::UnregisterAllScreenListenerWithType methodName %{public}s not registered!",
|
||||
WLOGFE("JsScreenManager::UnregisterAllScreenListenerWithType methodName %{public}s not registered!",
|
||||
type.c_str());
|
||||
return;
|
||||
return DmErrorCode::DM_ERROR_INVALID_CALLING;
|
||||
}
|
||||
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
|
||||
it->second->RemoveAllCallback();
|
||||
@ -216,26 +225,28 @@ void UnregisterAllScreenListenerWithType(const std::string& type)
|
||||
jsCbMap_[type].erase(it++);
|
||||
}
|
||||
jsCbMap_.erase(type);
|
||||
return DmErrorCode::DM_OK;
|
||||
}
|
||||
|
||||
void UnRegisterScreenListenerWithType(const std::string& type, NativeValue* value)
|
||||
DmErrorCode UnRegisterScreenListenerWithType(const std::string& type, NativeValue* value)
|
||||
{
|
||||
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
|
||||
WLOGI("JsScreenManager::UnRegisterScreenListenerWithType methodName %{public}s not registered!",
|
||||
type.c_str());
|
||||
return;
|
||||
return DmErrorCode::DM_ERROR_INVALID_CALLING;
|
||||
}
|
||||
if (value == nullptr) {
|
||||
WLOGFE("JsScreenManager::UnRegisterScreenListenerWithType value is nullptr");
|
||||
return;
|
||||
return DmErrorCode::DM_ERROR_INVALID_SCREEN;
|
||||
}
|
||||
DmErrorCode ret = DmErrorCode::DM_OK;
|
||||
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
|
||||
if (value->StrictEquals(it->first->Get())) {
|
||||
it->second->RemoveCallback(type, value);
|
||||
if (type == EVENT_CONNECT || type == EVENT_DISCONNECT || type == EVENT_CHANGE) {
|
||||
sptr<ScreenManager::IScreenListener> thisListener(it->second);
|
||||
SingletonContainer::Get<ScreenManager>().UnregisterScreenListener(thisListener);
|
||||
WLOGI("JsScreenManager::UnRegisterScreenListenerWithType success");
|
||||
ret = DM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<ScreenManager>().UnregisterScreenListener(thisListener));
|
||||
}
|
||||
jsCbMap_[type].erase(it++);
|
||||
break;
|
||||
@ -246,11 +257,15 @@ void UnRegisterScreenListenerWithType(const std::string& type, NativeValue* valu
|
||||
if (jsCbMap_[type].empty()) {
|
||||
jsCbMap_.erase(type);
|
||||
}
|
||||
if (ret == DmErrorCode::DM_OK) {
|
||||
WLOGFI("JsScreenManager::UnRegisterScreenListenerWithType success");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
NativeValue* OnRegisterScreenMangerCallback(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
NativeValue* OnRegisterScreenManagerCallback(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGI("JsScreenManager::OnRegisterScreenMangerCallback is called");
|
||||
WLOGI("JsScreenManager::OnRegisterScreenManagerCallback is called");
|
||||
if (info.argc < ARGC_TWO) {
|
||||
WLOGFE("Params not match");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_PARAM)));
|
||||
@ -264,17 +279,21 @@ NativeValue* OnRegisterScreenMangerCallback(NativeEngine& engine, NativeCallback
|
||||
}
|
||||
NativeValue* value = info.argv[INDEX_ONE];
|
||||
if (value == nullptr) {
|
||||
WLOGI("JsScreenManager::OnRegisterScreenMangerCallback info->argv[1] is nullptr");
|
||||
WLOGI("JsScreenManager::OnRegisterScreenManagerCallback info->argv[1] is nullptr");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
if (!value->IsCallable()) {
|
||||
WLOGI("JsScreenManager::OnRegisterScreenMangerCallback info->argv[1] is not callable");
|
||||
WLOGI("JsScreenManager::OnRegisterScreenManagerCallback info->argv[1] is not callable");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
RegisterScreenListenerWithType(engine, cbType, value);
|
||||
DmErrorCode ret = RegisterScreenListenerWithType(engine, cbType, value);
|
||||
if (ret != DmErrorCode::DM_OK) {
|
||||
WLOGFE("JsScreenManager::OnRegisterScreenManagerCallback failed");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
}
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
@ -298,9 +317,17 @@ NativeValue* OnUnregisterScreenManagerCallback(NativeEngine& engine, NativeCallb
|
||||
} else {
|
||||
NativeValue* value = info.argv[INDEX_ONE];
|
||||
if ((value == nullptr) || (!value->IsCallable())) {
|
||||
UnregisterAllScreenListenerWithType(cbType);
|
||||
DmErrorCode ret = UnregisterAllScreenListenerWithType(cbType);
|
||||
if (ret != DmErrorCode::DM_OK) {
|
||||
WLOGFE("JsScreenManager::OnUnRegisterAllScreenManagerCallback failed");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
}
|
||||
} else {
|
||||
UnRegisterScreenListenerWithType(cbType, value);
|
||||
DmErrorCode ret = UnRegisterScreenListenerWithType(cbType, value);
|
||||
if (ret != DmErrorCode::DM_OK) {
|
||||
WLOGFE("JsScreenManager::OnUnRegisterScreenManagerCallback failed");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return engine.CreateUndefined();
|
||||
@ -338,12 +365,14 @@ NativeValue* OnMakeMirror(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[mainScreenId, screenIds](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
ScreenId id = SingletonContainer::Get<ScreenManager>().MakeMirror(mainScreenId, screenIds);
|
||||
if (id != SCREEN_ID_INVALID) {
|
||||
task.Resolve(engine, CreateJsValue(engine, static_cast<uint32_t>(id)));
|
||||
ScreenId screenGroupId = INVALID_SCREEN_ID;
|
||||
DmErrorCode ret = DM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<ScreenManager>().MakeMirror(mainScreenId, screenIds, screenGroupId));
|
||||
if (ret == DmErrorCode::DM_OK) {
|
||||
task.Resolve(engine, CreateJsValue(engine, static_cast<uint32_t>(screenGroupId)));
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine,
|
||||
static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_SCREEN),
|
||||
static_cast<int32_t>(ret),
|
||||
"JsScreenManager::OnMakeMirror failed."));
|
||||
}
|
||||
};
|
||||
@ -389,13 +418,15 @@ NativeValue* OnMakeExpand(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[options](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
ScreenId id = SingletonContainer::Get<ScreenManager>().MakeExpand(options);
|
||||
if (id != SCREEN_ID_INVALID) {
|
||||
task.Resolve(engine, CreateJsValue(engine, static_cast<uint32_t>(id)));
|
||||
ScreenId screenGroupId = INVALID_SCREEN_ID;
|
||||
DmErrorCode ret = DM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<ScreenManager>().MakeExpand(options, screenGroupId));
|
||||
if (ret == DmErrorCode::DM_OK) {
|
||||
task.Resolve(engine, CreateJsValue(engine, static_cast<uint32_t>(screenGroupId)));
|
||||
WLOGI("MakeExpand success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine,
|
||||
static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_SCREEN),
|
||||
static_cast<int32_t>(ret),
|
||||
"JsScreenManager::OnMakeExpand failed."));
|
||||
WLOGFE("MakeExpand failed");
|
||||
}
|
||||
@ -633,8 +664,17 @@ NativeValue* OnIsScreenRotationLocked(NativeEngine& engine, NativeCallbackInfo&
|
||||
WLOGI("OnIsScreenRotationLocked is called");
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
bool isLocked = SingletonContainer::Get<ScreenManager>().IsScreenRotationLocked();
|
||||
task.Resolve(engine, CreateJsValue(engine, isLocked));
|
||||
bool isLocked = false;
|
||||
auto res = DM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<ScreenManager>().IsScreenRotationLocked(isLocked));
|
||||
if (res == DmErrorCode::DM_OK) {
|
||||
task.Resolve(engine, CreateJsValue(engine, isLocked));
|
||||
WLOGFI("OnIsScreenRotationLocked success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(res),
|
||||
"JsScreenManager::OnIsScreenRotationLocked failed."));
|
||||
WLOGFE("OnIsScreenRotationLocked failed");
|
||||
}
|
||||
};
|
||||
NativeValue* lastParam = nullptr;
|
||||
if (info.argc >= ARGC_ONE && info.argv[ARGC_ONE - 1] != nullptr &&
|
||||
@ -673,8 +713,16 @@ NativeValue* OnSetScreenRotationLocked(NativeEngine& engine, NativeCallbackInfo&
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[isLocked](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
SingletonContainer::Get<ScreenManager>().SetScreenRotationLocked(isLocked);
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
auto res = DM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<ScreenManager>().SetScreenRotationLocked(isLocked));
|
||||
if (res == DmErrorCode::DM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGFI("OnSetScreenRotationLocked success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(res),
|
||||
"JsScreenManager::OnSetScreenRotationLocked failed."));
|
||||
WLOGFE("OnSetScreenRotationLocked failed");
|
||||
}
|
||||
};
|
||||
NativeValue* lastParam = (info.argc <= ARGC_ONE) ? nullptr :
|
||||
((info.argv[ARGC_TWO - 1] != nullptr && info.argv[ARGC_TWO - 1]->TypeOf() == NATIVE_FUNCTION) ?
|
||||
@ -730,6 +778,8 @@ NativeValue* InitDisplayErrorCode(NativeEngine* engine)
|
||||
|
||||
object->SetProperty("DM_ERROR_NO_PERMISSION",
|
||||
CreateJsValue(*engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_NO_PERMISSION)));
|
||||
object->SetProperty("DM_ERROR_NOT_SYSTEM_APP",
|
||||
CreateJsValue(*engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_NOT_SYSTEM_APP)));
|
||||
object->SetProperty("DM_ERROR_INVALID_PARAM",
|
||||
CreateJsValue(*engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_PARAM)));
|
||||
object->SetProperty("DM_ERROR_DEVICE_NOT_SUPPORT",
|
||||
|
@ -86,7 +86,7 @@ NativeValue* JsWindowManager::ToggleShownStateForAllAppWindows(NativeEngine* eng
|
||||
NativeValue* JsWindowManager::RegisterWindowManagerCallback(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsWindowManager* me = CheckParamsAndGetThis<JsWindowManager>(engine, info);
|
||||
return (me != nullptr) ? me->OnRegisterWindowMangerCallback(*engine, *info) : nullptr;
|
||||
return (me != nullptr) ? me->OnRegisterWindowManagerCallback(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindowManager::UnregisterWindowMangerCallback(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
@ -222,13 +222,14 @@ static void CreateNewSystemWindowTask(void* contextPtr, sptr<WindowOption> windo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sptr<Window> window = Window::Create(windowOption->GetWindowName(), windowOption, context->lock());
|
||||
if (window != nullptr) {
|
||||
WMError wmError = WMError::WM_OK;
|
||||
sptr<Window> window = Window::Create(windowOption->GetWindowName(), windowOption, context->lock(), wmError);
|
||||
WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(wmError);
|
||||
if (window != nullptr && wmErrorCode == WmErrorCode::WM_OK) {
|
||||
task.Resolve(engine, CreateJsWindowObject(engine, window));
|
||||
} else {
|
||||
WLOGFE("Create window failed");
|
||||
int32_t err = static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
|
||||
int32_t err = static_cast<int32_t>(wmErrorCode);
|
||||
task.Reject(engine, CreateJsError(engine, err, "Create window failed"));
|
||||
}
|
||||
}
|
||||
@ -262,12 +263,14 @@ static void CreateSystemWindowTask(void* contextPtr, std::string windowName, Win
|
||||
return;
|
||||
}
|
||||
windowOption->SetWindowType(winType);
|
||||
sptr<Window> window = Window::Create(windowName, windowOption, context->lock());
|
||||
if (window != nullptr) {
|
||||
WMError wmError = WMError::WM_OK;
|
||||
sptr<Window> window = Window::Create(windowName, windowOption, context->lock(), wmError);
|
||||
WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(wmError);
|
||||
if (window != nullptr && wmErrorCode == WmErrorCode::WM_OK) {
|
||||
task.Resolve(engine, CreateJsWindowObject(engine, window));
|
||||
} else {
|
||||
WLOGFE("Create window failed");
|
||||
int32_t err = static_cast<int32_t>(WMError::WM_ERROR_NULLPTR);
|
||||
int32_t err = static_cast<int32_t>(wmErrorCode);
|
||||
task.Reject(engine, CreateJsError(engine, err, "Create window failed"));
|
||||
}
|
||||
}
|
||||
@ -588,9 +591,14 @@ NativeValue* JsWindowManager::OnMinimizeAll(NativeEngine& engine, NativeCallback
|
||||
WLOGI("Display id = %{public}" PRIu64", err = %{public}d", static_cast<uint64_t>(displayId), errCode);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
SingletonContainer::Get<WindowManager>().MinimizeAllAppWindows(static_cast<uint64_t>(displayId));
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGI("OnMinimizeAll success");
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<WindowManager>().MinimizeAllAppWindows(static_cast<uint64_t>(displayId)));
|
||||
if (ret == WmErrorCode::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGFI("OnMinimizeAll success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "OnMinimizeAll failed"));
|
||||
}
|
||||
};
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr :
|
||||
((info.argv[1] != nullptr && info.argv[1]->TypeOf() == NATIVE_FUNCTION) ?
|
||||
@ -624,9 +632,9 @@ NativeValue* JsWindowManager::OnToggleShownStateForAllAppWindows(NativeEngine& e
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* JsWindowManager::OnRegisterWindowMangerCallback(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
NativeValue* JsWindowManager::OnRegisterWindowManagerCallback(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGFD("OnRegisterWindowMangerCallback");
|
||||
WLOGFD("OnRegisterWindowManagerCallback");
|
||||
if (info.argc < 2) { // 2: params num
|
||||
WLOGFE("Argc is invalid: %{public}zu", info.argc);
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
@ -645,7 +653,11 @@ NativeValue* JsWindowManager::OnRegisterWindowMangerCallback(NativeEngine& engin
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
registerManager_->RegisterListener(nullptr, cbType, CaseType::CASE_WINDOW_MANAGER, engine, value);
|
||||
WmErrorCode ret = registerManager_->RegisterListener(nullptr, cbType, CaseType::CASE_WINDOW_MANAGER, engine, value);
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("Register end, type = %{public}s, callback = %{public}p", cbType.c_str(), value);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
@ -666,16 +678,21 @@ NativeValue* JsWindowManager::OnUnregisterWindowManagerCallback(NativeEngine& en
|
||||
}
|
||||
|
||||
NativeValue* value = nullptr;
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (info.argc == 1) {
|
||||
registerManager_->UnregisterListener(nullptr, cbType, CaseType::CASE_WINDOW_MANAGER, value);
|
||||
ret = registerManager_->UnregisterListener(nullptr, cbType, CaseType::CASE_WINDOW_MANAGER, value);
|
||||
} else {
|
||||
value = info.argv[1];
|
||||
if ((value == nullptr) || (!value->IsCallable())) {
|
||||
registerManager_->UnregisterListener(nullptr, cbType, CaseType::CASE_WINDOW_MANAGER, nullptr);
|
||||
ret = registerManager_->UnregisterListener(nullptr, cbType, CaseType::CASE_WINDOW_MANAGER, nullptr);
|
||||
} else {
|
||||
registerManager_->UnregisterListener(nullptr, cbType, CaseType::CASE_WINDOW_MANAGER, value);
|
||||
ret = registerManager_->UnregisterListener(nullptr, cbType, CaseType::CASE_WINDOW_MANAGER, value);
|
||||
}
|
||||
}
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("Unregister end, type = %{public}s, callback = %{public}p", cbType.c_str(), value);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ private:
|
||||
static NativeValue* OnFindWindowSync(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
static NativeValue* OnMinimizeAll(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
static NativeValue* OnToggleShownStateForAllAppWindows(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnRegisterWindowMangerCallback(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnRegisterWindowManagerCallback(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnUnregisterWindowManagerCallback(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
static NativeValue* OnGetTopWindow(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
static NativeValue* OnGetLastWindow(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
@ -1081,8 +1081,8 @@ NativeValue* JsWindow::OnSetWindowType(NativeEngine& engine, NativeCallbackInfo&
|
||||
WLOGFE("window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
WMError ret = weakWindow->SetWindowType(winType);
|
||||
if (ret == WMError::WM_OK) {
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetWindowType(winType));
|
||||
if (ret == WmErrorCode::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window set type failed"));
|
||||
@ -1101,9 +1101,9 @@ NativeValue* JsWindow::OnSetWindowType(NativeEngine& engine, NativeCallbackInfo&
|
||||
|
||||
NativeValue* JsWindow::OnSetWindowMode(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set window mode permission denied!");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_CALLING)));
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_NOT_SYSTEM_APP)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||
@ -1239,7 +1239,11 @@ NativeValue* JsWindow::OnRegisterWindowCallback(NativeEngine& engine, NativeCall
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
registerManager_->RegisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, engine, value);
|
||||
WmErrorCode ret = registerManager_->RegisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, engine, value);
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("Register end, window [%{public}u, %{public}s], type = %{public}s, callback = %{public}p",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), cbType.c_str(), value);
|
||||
return engine.CreateUndefined();
|
||||
@ -1260,17 +1264,22 @@ NativeValue* JsWindow::OnUnregisterWindowCallback(NativeEngine& engine, NativeCa
|
||||
}
|
||||
|
||||
NativeValue* value = nullptr;
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (info.argc == 1) {
|
||||
registerManager_->UnregisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, value);
|
||||
ret = registerManager_->UnregisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, value);
|
||||
} else {
|
||||
value = info.argv[1];
|
||||
if (value == nullptr || !value->IsCallable()) {
|
||||
registerManager_->UnregisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, nullptr);
|
||||
ret = registerManager_->UnregisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, nullptr);
|
||||
} else {
|
||||
registerManager_->UnregisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, value);
|
||||
ret = registerManager_->UnregisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("Unregister end, window [%{public}u, %{public}s], type = %{public}s, callback = %{public}p",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), cbType.c_str(), value);
|
||||
return engine.CreateUndefined();
|
||||
@ -2477,9 +2486,9 @@ NativeValue* JsWindow::OnSetWindowKeepScreenOn(NativeEngine& engine, NativeCallb
|
||||
|
||||
NativeValue* JsWindow::OnSetWakeUpScreen(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set wake up screen permission denied!");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_CALLING)));
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_NOT_SYSTEM_APP)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WmErrorCode errCode = WmErrorCode::WM_OK;
|
||||
@ -2797,7 +2806,12 @@ NativeValue* JsWindow::OnDisableWindowDecor(NativeEngine& engine, NativeCallback
|
||||
if (windowToken_ == nullptr) {
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
windowToken_->DisableAppWindowDecor();
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->DisableAppWindowDecor());
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("Window DisableWindowDecor failed");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("Window [%{public}u, %{public}s] disable app window decor end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
return engine.CreateUndefined();
|
||||
@ -3096,7 +3110,12 @@ NativeValue* JsWindow::OnSetSnapshotSkip(NativeEngine& engine, NativeCallbackInf
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
window->SetSnapshotSkip(isSkip);
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetSnapshotSkip(isSkip));
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("Window SetSnapshotSkip failed");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("[%{public}u, %{public}s] set snapshotSkip end",
|
||||
window->GetWindowId(), window->GetWindowName().c_str());
|
||||
|
||||
@ -3164,7 +3183,12 @@ NativeValue* JsWindow::OnOpacity(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
float alpha = static_cast<double>(*nativeVal);
|
||||
windowToken_->SetAlpha(alpha);
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetAlpha(alpha));
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("Window Opacity failed");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("Window [%{public}u, %{public}s] Opacity end, alpha = %{public}f",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), alpha);
|
||||
return engine.CreateUndefined();
|
||||
@ -3245,7 +3269,12 @@ NativeValue* JsWindow::OnScale(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
windowToken_->SetTransform(trans);
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetTransform(trans));
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("Window Scale failed");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("Window [%{public}u, %{public}s] Scale end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
WLOGI("scaleX = %{public}f, scaleY = %{public}f, pivotX = %{public}f pivotY = %{public}f",
|
||||
@ -3310,7 +3339,12 @@ NativeValue* JsWindow::OnRotate(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
windowToken_->SetTransform(trans);
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetTransform(trans));
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("Window Rotate failed");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("Window [%{public}u, %{public}s] Rotate end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
WLOGI("rotateX = %{public}f, rotateY = %{public}f," \
|
||||
@ -3362,7 +3396,12 @@ NativeValue* JsWindow::OnTranslate(NativeEngine& engine, NativeCallbackInfo& inf
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
windowToken_->SetTransform(trans);
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetTransform(trans));
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("Window Translate failed");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
WLOGI("Window [%{public}u, %{public}s] Translate end," \
|
||||
"translateX = %{public}f, translateY = %{public}f, translateZ = %{public}f",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(),
|
||||
@ -3370,39 +3409,40 @@ NativeValue* JsWindow::OnTranslate(NativeEngine& engine, NativeCallbackInfo& inf
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
void JsWindow::CreateTransitionController(NativeEngine& engine)
|
||||
WmErrorCode JsWindow::CreateTransitionController(NativeEngine& engine)
|
||||
{
|
||||
if (windowToken_ == nullptr) {
|
||||
WLOGFE("windowToken_ is nullptr not match");
|
||||
return;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) {
|
||||
WLOGFE("CreateTransitionController is not allowed since window is not system window");
|
||||
return;
|
||||
return WmErrorCode::WM_ERROR_INVALID_CALLING;
|
||||
}
|
||||
NativeValue* objValue = engine.CreateObject();
|
||||
auto name = GetWindowName();
|
||||
std::shared_ptr<NativeReference> jsWindowObj = FindJsWindowObject(name);
|
||||
if (jsWindowObj == nullptr || jsWindowObj->Get() == nullptr) {
|
||||
return;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
sptr<JsTransitionController> nativeController = new JsTransitionController(
|
||||
engine, jsWindowObj, windowToken_);
|
||||
NativeObject* object = ConvertNativeValueTo<NativeObject>(objValue);
|
||||
if (object == nullptr) {
|
||||
WLOGFE("Failed to convert to TransitionController Object");
|
||||
return;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
object->SetNativePointer(new wptr<JsTransitionController>(nativeController),
|
||||
[](NativeEngine*, void* data, void*) {
|
||||
WLOGFE("Finalizer for wptr form native Transition Controller is called");
|
||||
delete static_cast<wptr<JsTransitionController>*>(data);
|
||||
}, nullptr);
|
||||
windowToken_->RegisterAnimationTransitionController(nativeController);
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->RegisterAnimationTransitionController(nativeController));
|
||||
jsTransControllerObj_.reset(engine.CreateReference(objValue, 1));
|
||||
nativeController->SetJsController(jsTransControllerObj_);
|
||||
WLOGI("Window [%{public}u, %{public}s] CreateTransitionController end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
return ret;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnGetTransitionController(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
@ -3418,16 +3458,20 @@ NativeValue* JsWindow::OnGetTransitionController(NativeEngine& engine, NativeCal
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
if (jsTransControllerObj_ == nullptr || jsTransControllerObj_->Get() == nullptr) {
|
||||
CreateTransitionController(engine);
|
||||
WmErrorCode ret = CreateTransitionController(engine);
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("Window GetTransitionController failed");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
}
|
||||
}
|
||||
return jsTransControllerObj_ == nullptr ? nullptr : jsTransControllerObj_->Get();
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnSetCornerRadius(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set corner radius permission denied!");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_CALLING)));
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_NOT_SYSTEM_APP)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
if (info.argc < 1) {
|
||||
@ -3497,28 +3541,28 @@ NativeValue* JsWindow::OnSetShadow(NativeEngine& engine, NativeCallbackInfo& inf
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetShadowColor(color));
|
||||
}
|
||||
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
if (info.argc >= 3) { // parse the 3rd param: offsetX
|
||||
if ((ret == WmErrorCode::WM_OK) && info.argc >= 3) { // parse the 3rd param: offsetX
|
||||
NativeNumber* nativeVal = ConvertNativeValueTo<NativeNumber>(info.argv[2]); // 2: the 3rd param
|
||||
if (nativeVal == nullptr) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
windowToken_->SetShadowOffsetX(static_cast<double>(*nativeVal));
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetShadowOffsetX(static_cast<double>(*nativeVal)));
|
||||
}
|
||||
|
||||
if (info.argc >= 4) { // parse the 4th param: offsetY
|
||||
if ((ret == WmErrorCode::WM_OK) && info.argc >= 4) { // parse the 4th param: offsetY
|
||||
NativeNumber* nativeVal = ConvertNativeValueTo<NativeNumber>(info.argv[3]); // 3: the 4th param
|
||||
if (nativeVal == nullptr) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
windowToken_->SetShadowOffsetY(static_cast<double>(*nativeVal));
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetShadowOffsetY(static_cast<double>(*nativeVal)));
|
||||
}
|
||||
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
}
|
||||
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ private:
|
||||
NativeValue* OnRotate(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnTranslate(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnGetTransitionController(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
void CreateTransitionController(NativeEngine& engine);
|
||||
WmErrorCode CreateTransitionController(NativeEngine& engine);
|
||||
|
||||
// window effect
|
||||
NativeValue* OnSetCornerRadius(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
@ -51,156 +51,167 @@ JsWindowRegisterManager::~JsWindowRegisterManager()
|
||||
{
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessWindowChangeRegister(sptr<JsWindowListener> listener,
|
||||
WmErrorCode JsWindowRegisterManager::ProcessWindowChangeRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
if (window == nullptr) {
|
||||
WLOGFE("[NAPI]Window is nullptr");
|
||||
return false;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
sptr<IWindowChangeListener> thisListener(listener);
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (isRegister) {
|
||||
window->RegisterWindowChangeListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterWindowChangeListener(thisListener));
|
||||
} else {
|
||||
window->UnregisterWindowChangeListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterWindowChangeListener(thisListener));
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessSystemAvoidAreaChangeRegister(sptr<JsWindowListener> listener,
|
||||
WmErrorCode JsWindowRegisterManager::ProcessSystemAvoidAreaChangeRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
if (window == nullptr) {
|
||||
WLOGFE("[NAPI]Window is nullptr");
|
||||
return false;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("[NAPI]listener is nullptr");
|
||||
return false;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
listener->SetIsDeprecatedInterface(true);
|
||||
sptr<IAvoidAreaChangedListener> thisListener(listener);
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (isRegister) {
|
||||
window->RegisterAvoidAreaChangeListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterAvoidAreaChangeListener(thisListener));
|
||||
} else {
|
||||
window->UnregisterAvoidAreaChangeListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterAvoidAreaChangeListener(thisListener));
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessAvoidAreaChangeRegister(sptr<JsWindowListener> listener,
|
||||
WmErrorCode JsWindowRegisterManager::ProcessAvoidAreaChangeRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
if (window == nullptr) {
|
||||
WLOGFE("[NAPI]Window is nullptr");
|
||||
return false;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
sptr<IAvoidAreaChangedListener> thisListener(listener);
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (isRegister) {
|
||||
window->RegisterAvoidAreaChangeListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterAvoidAreaChangeListener(thisListener));
|
||||
} else {
|
||||
window->UnregisterAvoidAreaChangeListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterAvoidAreaChangeListener(thisListener));
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessLifeCycleEventRegister(sptr<JsWindowListener> listener,
|
||||
WmErrorCode JsWindowRegisterManager::ProcessLifeCycleEventRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
if (window == nullptr) {
|
||||
WLOGFE("[NAPI]Window is nullptr");
|
||||
return false;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
sptr<IWindowLifeCycle> thisListener(listener);
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (isRegister) {
|
||||
window->RegisterLifeCycleListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterLifeCycleListener(thisListener));
|
||||
} else {
|
||||
window->UnregisterLifeCycleListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterLifeCycleListener(thisListener));
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessOccupiedAreaChangeRegister(sptr<JsWindowListener> listener,
|
||||
WmErrorCode JsWindowRegisterManager::ProcessOccupiedAreaChangeRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
if (window == nullptr) {
|
||||
WLOGFE("[NAPI]Window is nullptr");
|
||||
return false;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
sptr<IOccupiedAreaChangeListener> thisListener(listener);
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (isRegister) {
|
||||
window->RegisterOccupiedAreaChangeListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterOccupiedAreaChangeListener(thisListener));
|
||||
} else {
|
||||
window->UnregisterOccupiedAreaChangeListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterOccupiedAreaChangeListener(thisListener));
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessSystemBarChangeRegister(sptr<JsWindowListener> listener,
|
||||
WmErrorCode JsWindowRegisterManager::ProcessSystemBarChangeRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
sptr<ISystemBarChangedListener> thisListener(listener);
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (isRegister) {
|
||||
SingletonContainer::Get<WindowManager>().RegisterSystemBarChangedListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<WindowManager>().RegisterSystemBarChangedListener(thisListener));
|
||||
} else {
|
||||
SingletonContainer::Get<WindowManager>().UnregisterSystemBarChangedListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<WindowManager>().UnregisterSystemBarChangedListener(thisListener));
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessTouchOutsideRegister(sptr<JsWindowListener> listener,
|
||||
WmErrorCode JsWindowRegisterManager::ProcessTouchOutsideRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
WLOGI("called");
|
||||
if (window == nullptr) {
|
||||
return false;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
sptr<ITouchOutsideListener> thisListener(listener);
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (isRegister) {
|
||||
window->RegisterTouchOutsideListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterTouchOutsideListener(thisListener));
|
||||
} else {
|
||||
window->UnregisterTouchOutsideListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterTouchOutsideListener(thisListener));
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessScreenshotRegister(sptr<JsWindowListener> listener,
|
||||
WmErrorCode JsWindowRegisterManager::ProcessScreenshotRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
WLOGI("called");
|
||||
if (window == nullptr) {
|
||||
WLOGFE("%{public}sregister screenshot listener failed. window is null", isRegister? "" : "un");
|
||||
return false;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
sptr<IScreenshotListener> thisListener(listener);
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (isRegister) {
|
||||
window->RegisterScreenshotListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterScreenshotListener(thisListener));
|
||||
} else {
|
||||
window->UnregisterScreenshotListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterScreenshotListener(thisListener));
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessDialogTargetTouchRegister(sptr<JsWindowListener> listener,
|
||||
WmErrorCode JsWindowRegisterManager::ProcessDialogTargetTouchRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
if (window == nullptr) {
|
||||
return false;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
sptr<IDialogTargetTouchListener> thisListener(listener);
|
||||
WmErrorCode ret = WmErrorCode::WM_OK;
|
||||
if (isRegister) {
|
||||
window->RegisterDialogTargetTouchListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterDialogTargetTouchListener(thisListener));
|
||||
} else {
|
||||
window->UnregisterDialogTargetTouchListener(thisListener);
|
||||
ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterDialogTargetTouchListener(thisListener));
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::ProcessDialogDeathRecipientRegister(sptr<JsWindowListener> listener,
|
||||
WmErrorCode JsWindowRegisterManager::ProcessDialogDeathRecipientRegister(sptr<JsWindowListener> listener,
|
||||
sptr<Window> window, bool isRegister)
|
||||
{
|
||||
if (window == nullptr) {
|
||||
return false;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
sptr<IDialogDeathRecipientListener> thisListener(listener);
|
||||
if (isRegister) {
|
||||
@ -208,7 +219,7 @@ bool JsWindowRegisterManager::ProcessDialogDeathRecipientRegister(sptr<JsWindowL
|
||||
} else {
|
||||
window->UnregisterDialogDeathRecipientListener(thisListener);
|
||||
}
|
||||
return true;
|
||||
return WmErrorCode::WM_OK;
|
||||
}
|
||||
|
||||
bool JsWindowRegisterManager::IsCallbackRegistered(std::string type, NativeValue* jsListenerObject)
|
||||
@ -227,50 +238,53 @@ bool JsWindowRegisterManager::IsCallbackRegistered(std::string type, NativeValue
|
||||
return false;
|
||||
}
|
||||
|
||||
void JsWindowRegisterManager::RegisterListener(sptr<Window> window, std::string type,
|
||||
WmErrorCode JsWindowRegisterManager::RegisterListener(sptr<Window> window, std::string type,
|
||||
CaseType caseType, NativeEngine& engine, NativeValue* value)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
if (IsCallbackRegistered(type, value)) {
|
||||
return;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
if (listenerProcess_[caseType].count(type) == 0) {
|
||||
WLOGFE("[NAPI]Type %{public}s is not supported", type.c_str());
|
||||
return;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
std::shared_ptr<NativeReference> callbackRef;
|
||||
callbackRef.reset(engine.CreateReference(value, 1));
|
||||
sptr<JsWindowListener> windowManagerListener = new(std::nothrow) JsWindowListener(&engine, callbackRef);
|
||||
if (windowManagerListener == nullptr) {
|
||||
WLOGFE("[NAPI]New JsWindowListener failed");
|
||||
return;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
if (!((this->*listenerProcess_[caseType][type])(windowManagerListener, window, true))) {
|
||||
WmErrorCode ret = (this->*listenerProcess_[caseType][type])(windowManagerListener, window, true);
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("[NAPI]Register type %{public}s failed", type.c_str());
|
||||
return;
|
||||
return ret;
|
||||
}
|
||||
jsCbMap_[type][callbackRef] = windowManagerListener;
|
||||
WLOGI("[NAPI]Register type %{public}s success! callback map size: %{public}zu",
|
||||
type.c_str(), jsCbMap_[type].size());
|
||||
return WmErrorCode::WM_OK;
|
||||
}
|
||||
|
||||
void JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std::string type,
|
||||
WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std::string type,
|
||||
CaseType caseType, NativeValue* value)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
|
||||
WLOGFE("[NAPI]Type %{public}s was not registerted", type.c_str());
|
||||
return;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
if (listenerProcess_[caseType].count(type) == 0) {
|
||||
WLOGFE("[NAPI]Type %{public}s is not supported", type.c_str());
|
||||
return;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
if (value == nullptr) {
|
||||
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
|
||||
if (!((this->*listenerProcess_[caseType][type])(it->second, window, false))) {
|
||||
WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false);
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("[NAPI]Unregister type %{public}s failed, no value", type.c_str());
|
||||
return;
|
||||
return ret;
|
||||
}
|
||||
jsCbMap_[type].erase(it++);
|
||||
}
|
||||
@ -281,16 +295,17 @@ void JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std::strin
|
||||
continue;
|
||||
}
|
||||
findFlag = true;
|
||||
if (!(this->*listenerProcess_[caseType][type])(it->second, window, false)) {
|
||||
WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false);
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
WLOGFE("[NAPI]Unregister type %{public}s failed", type.c_str());
|
||||
return;
|
||||
return ret;
|
||||
}
|
||||
jsCbMap_[type].erase(it);
|
||||
break;
|
||||
}
|
||||
if (!findFlag) {
|
||||
WLOGFE("[NAPI]Unregister type %{public}s failed because not found callback!", type.c_str());
|
||||
return;
|
||||
return WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
}
|
||||
}
|
||||
WLOGI("[NAPI]Unregister type %{public}s success! callback map size: %{public}zu",
|
||||
@ -299,6 +314,7 @@ void JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std::strin
|
||||
if (jsCbMap_[type].empty()) {
|
||||
jsCbMap_.erase(type);
|
||||
}
|
||||
return WmErrorCode::WM_OK;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -33,23 +33,26 @@ class JsWindowRegisterManager {
|
||||
public:
|
||||
JsWindowRegisterManager();
|
||||
~JsWindowRegisterManager();
|
||||
void RegisterListener(sptr<Window> window, std::string type,
|
||||
WmErrorCode RegisterListener(sptr<Window> window, std::string type,
|
||||
CaseType caseType, NativeEngine& engine, NativeValue* value);
|
||||
void UnregisterListener(sptr<Window> window, std::string type,
|
||||
WmErrorCode UnregisterListener(sptr<Window> window, std::string type,
|
||||
CaseType caseType, NativeValue* value);
|
||||
private:
|
||||
bool IsCallbackRegistered(std::string type, NativeValue* jsListenerObject);
|
||||
bool ProcessWindowChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessSystemAvoidAreaChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessAvoidAreaChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessLifeCycleEventRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessOccupiedAreaChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessSystemBarChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessTouchOutsideRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessScreenshotRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessDialogTargetTouchRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
bool ProcessDialogDeathRecipientRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
using Func_t = bool(JsWindowRegisterManager::*)(sptr<JsWindowListener>, sptr<Window> window, bool);
|
||||
WmErrorCode ProcessWindowChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
WmErrorCode ProcessSystemAvoidAreaChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window,
|
||||
bool isRegister);
|
||||
WmErrorCode ProcessAvoidAreaChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
WmErrorCode ProcessLifeCycleEventRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
WmErrorCode ProcessOccupiedAreaChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window,
|
||||
bool isRegister);
|
||||
WmErrorCode ProcessSystemBarChangeRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
WmErrorCode ProcessTouchOutsideRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
WmErrorCode ProcessScreenshotRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
WmErrorCode ProcessDialogTargetTouchRegister(sptr<JsWindowListener> listener, sptr<Window> window, bool isRegister);
|
||||
WmErrorCode ProcessDialogDeathRecipientRegister(sptr<JsWindowListener> listener, sptr<Window> window,
|
||||
bool isRegister);
|
||||
using Func_t = WmErrorCode(JsWindowRegisterManager::*)(sptr<JsWindowListener>, sptr<Window> window, bool);
|
||||
std::map<std::string, std::map<std::shared_ptr<NativeReference>, sptr<JsWindowListener>>> jsCbMap_;
|
||||
std::mutex mtx_;
|
||||
std::map<CaseType, std::map<std::string, Func_t>> listenerProcess_;
|
||||
|
@ -371,6 +371,8 @@ NativeValue* WindowErrorCodeInit(NativeEngine* engine)
|
||||
}
|
||||
object->SetProperty("WM_ERROR_NO_PERMISSION", CreateJsValue(*engine,
|
||||
static_cast<int32_t>(WmErrorCode::WM_ERROR_NO_PERMISSION)));
|
||||
object->SetProperty("WM_ERROR_NOT_SYSTEM_APP", CreateJsValue(*engine,
|
||||
static_cast<int32_t>(WmErrorCode::WM_ERROR_NOT_SYSTEM_APP)));
|
||||
object->SetProperty("WM_ERROR_INVALID_PARAM", CreateJsValue(*engine,
|
||||
static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
object->SetProperty("WM_ERROR_DEVICE_NOT_SUPPORT", CreateJsValue(*engine,
|
||||
|
@ -479,10 +479,10 @@ NativeValue* JsWindowStage::OnGetSubWindow(NativeEngine& engine, NativeCallbackI
|
||||
|
||||
NativeValue* JsWindowStage::OnSetShowOnLockScreen(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set show on lock screen permission denied!");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_CALLING)));
|
||||
return CreateJsValue(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_CALLING));
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_NOT_SYSTEM_APP)));
|
||||
return CreateJsValue(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_NOT_SYSTEM_APP));
|
||||
}
|
||||
if (info.argc < 1) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
@ -534,9 +534,13 @@ NativeValue* JsWindowStage::OnDisableWindowDecor(NativeEngine& engine, NativeCal
|
||||
WLOGFE("[NAPI]Window is null");
|
||||
return CreateJsValue(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY));
|
||||
}
|
||||
window->DisableAppWindowDecor();
|
||||
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->DisableAppWindowDecor());
|
||||
if (ret != WmErrorCode::WM_OK) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(ret)));
|
||||
WLOGI("[NAPI]Window [%{public}u, %{public}s] disable app window decor end",
|
||||
window->GetWindowId(), window->GetWindowName().c_str());
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,8 @@ public:
|
||||
virtual bool IsLayoutFullScreen() const override;
|
||||
virtual WMError SetWindowType(WindowType type) override;
|
||||
virtual WMError SetWindowMode(WindowMode mode) override;
|
||||
virtual void SetAlpha(float alpha) override;
|
||||
virtual void SetTransform(const Transform& trans) override;
|
||||
virtual WMError SetAlpha(float alpha) override;
|
||||
virtual WMError SetTransform(const Transform& trans) override;
|
||||
virtual WMError AddWindowFlag(WindowFlag flag) override;
|
||||
virtual WMError RemoveWindowFlag(WindowFlag flag) override;
|
||||
virtual WMError SetWindowFlags(uint32_t flags) override;
|
||||
@ -107,19 +107,19 @@ public:
|
||||
virtual WMError SetBrightness(float brightness) override;
|
||||
virtual float GetBrightness() const override;
|
||||
virtual WMError SetCallingWindow(uint32_t windowId) override;
|
||||
virtual void SetPrivacyMode(bool isPrivacyMode) override;
|
||||
virtual WMError SetPrivacyMode(bool isPrivacyMode) override;
|
||||
virtual bool IsPrivacyMode() const override;
|
||||
virtual void SetSystemPrivacyMode(bool isSystemPrivacyMode) override;
|
||||
virtual void DisableAppWindowDecor() override;
|
||||
virtual WMError DisableAppWindowDecor() override;
|
||||
virtual WMError BindDialogTarget(sptr<IRemoteObject> targetToken) override;
|
||||
virtual void SetSnapshotSkip(bool isSkip) override;
|
||||
virtual WMError SetSnapshotSkip(bool isSkip) override;
|
||||
|
||||
// window effect
|
||||
virtual WMError SetCornerRadius(float cornerRadius) override;
|
||||
virtual WMError SetShadowRadius(float radius) override;
|
||||
virtual WMError SetShadowColor(std::string color) override;
|
||||
virtual void SetShadowOffsetX(float offsetX) override;
|
||||
virtual void SetShadowOffsetY(float offsetY) override;
|
||||
virtual WMError SetShadowOffsetX(float offsetX) override;
|
||||
virtual WMError SetShadowOffsetY(float offsetY) override;
|
||||
virtual WMError SetBlur(float radius) override;
|
||||
virtual WMError SetBackdropBlur(float radius) override;
|
||||
virtual WMError SetBackdropBlurStyle(WindowBlurStyle blurStyle) override;
|
||||
@ -135,26 +135,27 @@ public:
|
||||
virtual bool IsFocused() const override;
|
||||
virtual void SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer>& inputEventConsumer) override;
|
||||
|
||||
virtual bool RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
|
||||
virtual bool RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
|
||||
virtual bool UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
|
||||
virtual bool UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
|
||||
virtual bool RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
|
||||
virtual bool UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
|
||||
virtual bool RegisterDragListener(const sptr<IWindowDragListener>& listener) override;
|
||||
virtual bool UnregisterDragListener(const sptr<IWindowDragListener>& listener) override;
|
||||
virtual bool RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
|
||||
virtual bool UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
|
||||
virtual WMError RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
|
||||
virtual WMError RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
|
||||
virtual WMError UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
|
||||
virtual WMError UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
|
||||
virtual WMError RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
|
||||
virtual WMError UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
|
||||
virtual WMError RegisterDragListener(const sptr<IWindowDragListener>& listener) override;
|
||||
virtual WMError UnregisterDragListener(const sptr<IWindowDragListener>& listener) override;
|
||||
virtual WMError RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
|
||||
virtual WMError UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
|
||||
virtual void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) override;
|
||||
virtual bool RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
|
||||
virtual bool UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
|
||||
virtual bool RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual bool UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual bool RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener) override;
|
||||
virtual bool RegisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
|
||||
virtual bool UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
|
||||
virtual bool RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
|
||||
virtual bool UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
|
||||
virtual WMError RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
|
||||
virtual WMError UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
|
||||
virtual WMError RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual WMError UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual WMError RegisterAnimationTransitionController(
|
||||
const sptr<IAnimationTransitionController>& listener) override;
|
||||
virtual WMError RegisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
|
||||
virtual WMError UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
|
||||
virtual WMError RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
|
||||
virtual WMError UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
|
||||
virtual void RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) override;
|
||||
virtual void UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) override;
|
||||
virtual void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) override;
|
||||
|
@ -23,14 +23,16 @@ JsWindowRegisterManager::~JsWindowRegisterManager()
|
||||
{
|
||||
}
|
||||
|
||||
void JsWindowRegisterManager::RegisterListener(sptr<Window> window, std::string type,
|
||||
WmErrorCode JsWindowRegisterManager::RegisterListener(sptr<Window> window, std::string type,
|
||||
CaseType caseType, NativeEngine& engine, NativeValue* value)
|
||||
{
|
||||
return WmErrorCode::WM_OK;
|
||||
}
|
||||
|
||||
void JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std::string type,
|
||||
WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr<Window> window, std::string type,
|
||||
CaseType caseType, NativeValue* value)
|
||||
{
|
||||
return WmErrorCode::WM_OK;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -32,9 +32,9 @@ class JsWindowRegisterManager {
|
||||
public:
|
||||
JsWindowRegisterManager();
|
||||
~JsWindowRegisterManager();
|
||||
void RegisterListener(sptr<Window> window, std::string type,
|
||||
WmErrorCode RegisterListener(sptr<Window> window, std::string type,
|
||||
CaseType caseType, NativeEngine& engine, NativeValue* value);
|
||||
void UnregisterListener(sptr<Window> window, std::string type,
|
||||
WmErrorCode UnregisterListener(sptr<Window> window, std::string type,
|
||||
CaseType caseType, NativeValue* value);
|
||||
};
|
||||
} // namespace Rosen
|
||||
|
@ -219,14 +219,14 @@ WMError WindowImpl::SetWindowMode(WindowMode mode)
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::SetAlpha(float alpha)
|
||||
WMError WindowImpl::SetAlpha(float alpha)
|
||||
{
|
||||
return;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::SetTransform(const Transform& trans)
|
||||
WMError WindowImpl::SetTransform(const Transform& trans)
|
||||
{
|
||||
return;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
const Transform& WindowImpl::GetTransform() const
|
||||
@ -427,9 +427,9 @@ WMError WindowImpl::SetCallingWindow(uint32_t windowId)
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::SetPrivacyMode(bool isPrivacyMode)
|
||||
WMError WindowImpl::SetPrivacyMode(bool isPrivacyMode)
|
||||
{
|
||||
return;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::IsPrivacyMode() const
|
||||
@ -442,14 +442,14 @@ void WindowImpl::SetSystemPrivacyMode(bool isSystemPrivacyMode)
|
||||
return;
|
||||
}
|
||||
|
||||
void WindowImpl::SetSnapshotSkip(bool isSkip)
|
||||
WMError WindowImpl::SetSnapshotSkip(bool isSkip)
|
||||
{
|
||||
return;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::DisableAppWindowDecor()
|
||||
WMError WindowImpl::DisableAppWindowDecor()
|
||||
{
|
||||
return;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::IsDecorEnable() const
|
||||
@ -497,54 +497,54 @@ void WindowImpl::SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer
|
||||
return;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
|
||||
WMError WindowImpl::RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
|
||||
WMError WindowImpl::RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
|
||||
WMError WindowImpl::UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
|
||||
WMError WindowImpl::UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
|
||||
WMError WindowImpl::RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
|
||||
WMError WindowImpl::UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterDragListener(const sptr<IWindowDragListener>& listener)
|
||||
WMError WindowImpl::RegisterDragListener(const sptr<IWindowDragListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterDragListener(const sptr<IWindowDragListener>& listener)
|
||||
WMError WindowImpl::UnregisterDragListener(const sptr<IWindowDragListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
|
||||
WMError WindowImpl::RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
|
||||
WMError WindowImpl::UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func)
|
||||
@ -552,49 +552,49 @@ void WindowImpl::RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFun
|
||||
return;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
|
||||
WMError WindowImpl::RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
|
||||
WMError WindowImpl::UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
|
||||
WMError WindowImpl::RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
|
||||
WMError WindowImpl::UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener)
|
||||
WMError WindowImpl::RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterScreenshotListener(const sptr<IScreenshotListener>& listener)
|
||||
WMError WindowImpl::RegisterScreenshotListener(const sptr<IScreenshotListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener)
|
||||
WMError WindowImpl::UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
|
||||
WMError WindowImpl::RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
|
||||
WMError WindowImpl::UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener)
|
||||
@ -724,14 +724,14 @@ WMError WindowImpl::SetShadowColor(std::string color)
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::SetShadowOffsetX(float offsetX)
|
||||
WMError WindowImpl::SetShadowOffsetX(float offsetX)
|
||||
{
|
||||
return;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::SetShadowOffsetY(float offsetY)
|
||||
WMError WindowImpl::SetShadowOffsetY(float offsetY)
|
||||
{
|
||||
return;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError WindowImpl::SetBlur(float radius)
|
||||
|
@ -24,9 +24,9 @@ namespace Rosen {
|
||||
class MockDisplayManagerAdapter : public DisplayManagerAdapter {
|
||||
public:
|
||||
MOCK_METHOD0(Clear, void());
|
||||
MOCK_METHOD2(RegisterDisplayManagerAgent, bool(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
MOCK_METHOD2(RegisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type));
|
||||
MOCK_METHOD2(UnregisterDisplayManagerAgent, bool(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
MOCK_METHOD2(UnregisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type));
|
||||
MOCK_METHOD0(GetDefaultDisplayInfo, sptr<DisplayInfo>());
|
||||
MOCK_METHOD1(GetDisplayInfoByScreenId, sptr<DisplayInfo>(ScreenId screenId));
|
||||
@ -46,9 +46,9 @@ public:
|
||||
class MockScreenManagerAdapter : public ScreenManagerAdapter {
|
||||
public:
|
||||
MOCK_METHOD0(Clear, void());
|
||||
MOCK_METHOD2(RegisterDisplayManagerAgent, bool(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
MOCK_METHOD2(RegisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type));
|
||||
MOCK_METHOD2(UnregisterDisplayManagerAgent, bool(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
MOCK_METHOD2(UnregisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type));
|
||||
MOCK_METHOD2(RequestRotation, bool(ScreenId screenId, Rotation rotation));
|
||||
MOCK_METHOD2(CreateVirtualScreen, ScreenId(VirtualScreenOption option,
|
||||
@ -56,10 +56,12 @@ public:
|
||||
MOCK_METHOD1(DestroyVirtualScreen, DMError(ScreenId screenId));
|
||||
MOCK_METHOD2(SetVirtualScreenSurface, DMError(ScreenId screenId, sptr<Surface> surface));
|
||||
MOCK_METHOD1(GetScreenGroupInfoById, sptr<ScreenGroupInfo>(ScreenId screenId));
|
||||
MOCK_METHOD0(GetAllScreenInfos, std::vector<sptr<ScreenInfo>>());
|
||||
MOCK_METHOD2(MakeMirror, ScreenId(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId));
|
||||
MOCK_METHOD2(MakeExpand, ScreenId(std::vector<ScreenId> screenId, std::vector<Point> startPoint));
|
||||
MOCK_METHOD2(SetScreenActiveMode, bool(ScreenId screenId, uint32_t modeId));
|
||||
MOCK_METHOD1(GetAllScreenInfos, DMError(std::vector<sptr<ScreenInfo>>& screenInfos));
|
||||
MOCK_METHOD3(MakeMirror, DMError(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId,
|
||||
ScreenId& screenGroupId));
|
||||
MOCK_METHOD3(MakeExpand, DMError(std::vector<ScreenId> screenId, std::vector<Point> startPoint,
|
||||
ScreenId& screenGroupId));
|
||||
MOCK_METHOD2(SetScreenActiveMode, DMError(ScreenId screenId, uint32_t modeId));
|
||||
MOCK_METHOD1(GetScreenInfo, sptr<ScreenInfo>(ScreenId screenId));
|
||||
MOCK_METHOD2(SetScreenPowerForAll, bool(ScreenPowerState state, PowerStateChangeReason reason));
|
||||
MOCK_METHOD1(GetScreenPower, ScreenPowerState(ScreenId dmsScreenId));
|
||||
@ -72,8 +74,8 @@ public:
|
||||
MOCK_METHOD1(SetScreenColorTransform, DMError(ScreenId screenId));
|
||||
|
||||
MOCK_METHOD1(RemoveVirtualScreenFromGroup, void(std::vector<ScreenId> screens));
|
||||
MOCK_METHOD1(SetScreenRotationLocked, void(bool isLocked));
|
||||
MOCK_METHOD0(IsScreenRotationLocked, bool());
|
||||
MOCK_METHOD1(SetScreenRotationLocked, DMError(bool isLocked));
|
||||
MOCK_METHOD1(IsScreenRotationLocked, DMError(bool& isLocked));
|
||||
};
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
MOCK_METHOD3(GetAvoidAreaByType, WMError(uint32_t windowId, AvoidAreaType type, AvoidArea& avoidArea));
|
||||
MOCK_METHOD2(BindDialogTarget, WMError(uint32_t& windowId, sptr<IRemoteObject> targetToken));
|
||||
MOCK_METHOD2(UpdateRsTree, WMError(uint32_t windowId, bool isAdd));
|
||||
MOCK_METHOD1(MinimizeAllAppWindows, void(DisplayId displayId));
|
||||
MOCK_METHOD1(MinimizeAllAppWindows, WMError(DisplayId displayId));
|
||||
MOCK_METHOD0(ToggleShownStateForAllAppWindows, WMError());
|
||||
MOCK_METHOD2(ProcessPointDown, void(uint32_t windowId, bool isPointDown));
|
||||
MOCK_METHOD1(ProcessPointUp, void(uint32_t windowId));
|
||||
@ -43,9 +43,9 @@ public:
|
||||
MOCK_METHOD2(GetModeChangeHotZones, WMError(DisplayId displayId, ModeChangeHotZones& hotZones));
|
||||
MOCK_METHOD3(NotifyServerReadyToMoveOrDrag, void(uint32_t windowId, sptr<WindowProperty>& windowProperty,
|
||||
sptr<MoveDragProperty>& moveDragProperty));
|
||||
MOCK_METHOD2(RegisterWindowManagerAgent, bool(WindowManagerAgentType type,
|
||||
MOCK_METHOD2(RegisterWindowManagerAgent, WMError(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent));
|
||||
MOCK_METHOD2(UnregisterWindowManagerAgent, bool(WindowManagerAgentType type,
|
||||
MOCK_METHOD2(UnregisterWindowManagerAgent, WMError(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent));
|
||||
MOCK_METHOD1(GetVisibilityWindowInfo, WMError(std::vector<sptr<WindowVisibilityInfo>>& infos));
|
||||
MOCK_METHOD1(GetAccessibilityWindowInfo, WMError(std::vector<sptr<AccessibilityWindowInfo>>& infos));
|
||||
|
@ -63,7 +63,8 @@ int main(int argc, char *argv[])
|
||||
ScreenId virtualScreenId = ScreenManager::GetInstance().CreateVirtualScreen(option);
|
||||
std::vector<ScreenId> mirrorIds;
|
||||
mirrorIds.push_back(virtualScreenId);
|
||||
ScreenManager::GetInstance().MakeMirror(mainId, mirrorIds);
|
||||
ScreenId screenGroupId = static_cast<ScreenId>(1);
|
||||
ScreenManager::GetInstance().MakeMirror(mainId, mirrorIds, screenGroupId);
|
||||
int fileIndex = 1;
|
||||
auto startTime = time(nullptr);
|
||||
if (startTime < 0) {
|
||||
|
@ -73,7 +73,8 @@ bool ScreenPowerFuzzTest(const uint8_t *data, size_t size)
|
||||
startPos += GetObject<uint32_t>(powerStateChangeReason, data + startPos, size - startPos);
|
||||
screenManager.SetScreenPowerForAll(static_cast<ScreenPowerState>(screenPowerState),
|
||||
static_cast<PowerStateChangeReason>(startPos));
|
||||
auto allScreen = screenManager.GetAllScreens();
|
||||
std::vector<sptr<Screen>> allScreen;
|
||||
screenManager.GetAllScreens(allScreen);
|
||||
for (auto screen: allScreen) {
|
||||
screenManager.GetScreenPower(screen->GetId());
|
||||
}
|
||||
@ -109,7 +110,8 @@ bool MakeMirrorWithVirtualScreenFuzzTest(const uint8_t *data, size_t size)
|
||||
screenManager.SetVirtualScreenSurface(screenId, nullptr);
|
||||
|
||||
// make mirror
|
||||
ScreenId groupId = screenManager.MakeMirror(0, { screenId });
|
||||
ScreenId groupId;
|
||||
screenManager.MakeMirror(0, { screenId }, groupId);
|
||||
if (groupId == SCREEN_ID_INVALID) {
|
||||
screenManager.DestroyVirtualScreen(screenId);
|
||||
return false;
|
||||
@ -153,7 +155,8 @@ bool MakeExpandWithVirtualScreenFuzzTest(const uint8_t *data, size_t size)
|
||||
screenManager.SetVirtualScreenSurface(screenId, nullptr);
|
||||
// make expand
|
||||
std::vector<ExpandOption> options = {{0, 0, 0}, {screenId, 0, 0}};
|
||||
ScreenId groupId = screenManager.MakeExpand(options);
|
||||
ScreenId groupId;
|
||||
screenManager.MakeExpand(options, groupId);
|
||||
if (groupId == SCREEN_ID_INVALID) {
|
||||
screenManager.DestroyVirtualScreen(screenId);
|
||||
return false;
|
||||
@ -249,8 +252,9 @@ bool MakeMirrorFuzzTest(const uint8_t *data, size_t size)
|
||||
startPos += GetObject<ScreenId>(screenId, data + startPos, size - startPos);
|
||||
screenIds.emplace_back(screenId);
|
||||
}
|
||||
ScreenId screenGroupId;
|
||||
GetObject<ScreenId>(screenId, data + startPos, size - startPos);
|
||||
screenManager.MakeMirror(screenId, screenIds);
|
||||
screenManager.MakeMirror(screenId, screenIds, screenGroupId);
|
||||
screenManager.UnregisterScreenGroupListener(screenGroupListener);
|
||||
screenManager.UnregisterScreenListener(screenListener);
|
||||
return true;
|
||||
@ -276,7 +280,8 @@ bool MakeExpandFuzzTest(const uint8_t *data, size_t size)
|
||||
ExpandOption option = {screenId, 0, 0};
|
||||
options.emplace_back(option);
|
||||
}
|
||||
screenManager.MakeExpand(options);
|
||||
ScreenId screenGroupId;
|
||||
screenManager.MakeExpand(options, screenGroupId);
|
||||
screenManager.UnregisterScreenGroupListener(screenGroupListener);
|
||||
screenManager.UnregisterScreenListener(screenListener);
|
||||
return true;
|
||||
|
@ -91,7 +91,7 @@ void DisplayChangeTest::SetUpTestCase()
|
||||
defaultScreen_ = ScreenManager::GetInstance().GetScreenById(screenId);
|
||||
ASSERT_NE(nullptr, defaultScreen_);
|
||||
|
||||
ASSERT_EQ(true, DisplayManager::GetInstance().RegisterDisplayListener(listener_));
|
||||
ASSERT_EQ(DMError::DM_OK, DisplayManager::GetInstance().RegisterDisplayListener(listener_));
|
||||
}
|
||||
|
||||
void DisplayChangeTest::TearDownTestCase()
|
||||
@ -175,8 +175,8 @@ namespace {
|
||||
HWTEST_F(DisplayChangeTest, RegisterDisplayChangeListener01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<DisplayChangeEventListener> listener = new DisplayChangeEventListener();
|
||||
bool ret = DisplayManager::GetInstance().RegisterDisplayListener(listener);
|
||||
ASSERT_EQ(true, ret);
|
||||
DMError ret = DisplayManager::GetInstance().RegisterDisplayListener(listener);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,8 +186,8 @@ HWTEST_F(DisplayChangeTest, RegisterDisplayChangeListener01, Function | SmallTes
|
||||
*/
|
||||
HWTEST_F(DisplayChangeTest, RegisterDisplayChangeListener02, Function | SmallTest | Level2)
|
||||
{
|
||||
bool ret = DisplayManager::GetInstance().RegisterDisplayListener(nullptr);
|
||||
ASSERT_EQ(false, ret);
|
||||
DMError ret = DisplayManager::GetInstance().RegisterDisplayListener(nullptr);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,8 +199,8 @@ HWTEST_F(DisplayChangeTest, UnregisterDisplayChangeListener01, Function | SmallT
|
||||
{
|
||||
sptr<DisplayChangeEventListener> listener = new DisplayChangeEventListener();
|
||||
DisplayManager::GetInstance().RegisterDisplayListener(listener);
|
||||
bool ret = DisplayManager::GetInstance().UnregisterDisplayListener(listener);
|
||||
ASSERT_EQ(true, ret);
|
||||
DMError ret = DisplayManager::GetInstance().UnregisterDisplayListener(listener);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,8 +210,8 @@ HWTEST_F(DisplayChangeTest, UnregisterDisplayChangeListener01, Function | SmallT
|
||||
*/
|
||||
HWTEST_F(DisplayChangeTest, UnregisterDisplayChangeListener02, Function | SmallTest | Level2)
|
||||
{
|
||||
bool ret = DisplayManager::GetInstance().UnregisterDisplayListener(nullptr);
|
||||
ASSERT_EQ(false, ret);
|
||||
DMError ret = DisplayManager::GetInstance().UnregisterDisplayListener(nullptr);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -222,8 +222,8 @@ HWTEST_F(DisplayChangeTest, UnregisterDisplayChangeListener02, Function | SmallT
|
||||
HWTEST_F(DisplayChangeTest, UnregisterDisplayChangeListener03, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<DisplayChangeEventListener> listener = new DisplayChangeEventListener();
|
||||
bool ret = DisplayManager::GetInstance().UnregisterDisplayListener(listener);
|
||||
ASSERT_EQ(false, ret);
|
||||
DMError ret = DisplayManager::GetInstance().UnregisterDisplayListener(listener);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -334,7 +334,7 @@ HWTEST_F(DisplayChangeTest, CheckScreenDensityChange01, Function | SmallTest | L
|
||||
GetDisplayById(defaultDisplayId_)->GetVirtualPixelRatio() * BASELINE_DENSITY);
|
||||
ASSERT_NE(0, DisplayChangeTest::originalDisplayDpi);
|
||||
uint32_t densityDpi = 320;
|
||||
ASSERT_EQ(true, defaultScreen_->SetDensityDpi(densityDpi));
|
||||
ASSERT_EQ(DMError::DM_OK, defaultScreen_->SetDensityDpi(densityDpi));
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
}
|
||||
|
||||
@ -346,7 +346,7 @@ HWTEST_F(DisplayChangeTest, CheckScreenDensityChange01, Function | SmallTest | L
|
||||
HWTEST_F(DisplayChangeTest, CheckScreenDensityChange02, Function | SmallTest | Level2)
|
||||
{
|
||||
uint32_t densityDpi = 80;
|
||||
ASSERT_EQ(true, defaultScreen_->SetDensityDpi(densityDpi));
|
||||
ASSERT_EQ(DMError::DM_OK, defaultScreen_->SetDensityDpi(densityDpi));
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ HWTEST_F(DisplayChangeTest, CheckScreenDensityChange02, Function | SmallTest | L
|
||||
HWTEST_F(DisplayChangeTest, CheckScreenDensityChange03, Function | SmallTest | Level2)
|
||||
{
|
||||
uint32_t densityDpi = 700;
|
||||
ASSERT_EQ(false, defaultScreen_->SetDensityDpi(densityDpi));
|
||||
ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, defaultScreen_->SetDensityDpi(densityDpi));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,7 +369,7 @@ HWTEST_F(DisplayChangeTest, CheckScreenDensityChange03, Function | SmallTest | L
|
||||
HWTEST_F(DisplayChangeTest, CheckScreenDensityChange04, Function | SmallTest | Level2)
|
||||
{
|
||||
uint32_t densityDpi = 40;
|
||||
ASSERT_EQ(false, defaultScreen_->SetDensityDpi(densityDpi));
|
||||
ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, defaultScreen_->SetDensityDpi(densityDpi));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -379,7 +379,7 @@ HWTEST_F(DisplayChangeTest, CheckScreenDensityChange04, Function | SmallTest | L
|
||||
*/
|
||||
HWTEST_F(DisplayChangeTest, CheckScreenDensityChange05, Function | SmallTest | Level2)
|
||||
{
|
||||
ASSERT_EQ(true, defaultScreen_->SetDensityDpi(DisplayChangeTest::originalDisplayDpi));
|
||||
ASSERT_EQ(DMError::DM_OK, defaultScreen_->SetDensityDpi(DisplayChangeTest::originalDisplayDpi));
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ HWTEST_F(DisplayChangeTest, CheckWaterfallCompression01, Function | SmallTest |
|
||||
uint32_t originSize = DisplayCutoutController::GetWaterfallAreaCompressionSizeWhenHorizontal();
|
||||
uint32_t testSizeInVp = 24;
|
||||
DisplayCutoutController::SetWaterfallAreaCompressionSizeWhenHorizontal(testSizeInVp);
|
||||
|
||||
|
||||
ASSERT_EQ(true, DisplayCutoutController::IsWaterfallAreaCompressionEnableWhenHorizontal());
|
||||
ASSERT_EQ(testSizeInVp, DisplayCutoutController::GetWaterfallAreaCompressionSizeWhenHorizontal());
|
||||
|
||||
|
@ -132,8 +132,8 @@ namespace {
|
||||
HWTEST_F(DisplayPowerTest, register_display_power_event_listener_001, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<IDisplayPowerEventListener> listener = new DisplayPowerEventListener();
|
||||
bool ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(listener);
|
||||
ASSERT_EQ(true, ret);
|
||||
DMError ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(listener);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener);
|
||||
}
|
||||
|
||||
@ -144,8 +144,8 @@ HWTEST_F(DisplayPowerTest, register_display_power_event_listener_001, Function |
|
||||
*/
|
||||
HWTEST_F(DisplayPowerTest, register_display_power_event_listener_002, Function | SmallTest | Level2)
|
||||
{
|
||||
bool ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(nullptr);
|
||||
ASSERT_EQ(false, ret);
|
||||
DMError ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(nullptr);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,8 +157,8 @@ HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_001, Function
|
||||
{
|
||||
sptr<IDisplayPowerEventListener> listener = new DisplayPowerEventListener();
|
||||
DisplayManager::GetInstance().RegisterDisplayPowerEventListener(listener);
|
||||
bool ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener);
|
||||
ASSERT_EQ(true, ret);
|
||||
DMError ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener);
|
||||
ASSERT_EQ(DMError::DM_OK, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,8 +168,8 @@ HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_001, Function
|
||||
*/
|
||||
HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_002, Function | SmallTest | Level2)
|
||||
{
|
||||
bool ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(nullptr);
|
||||
ASSERT_EQ(false, ret);
|
||||
DMError ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(nullptr);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,8 +180,8 @@ HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_002, Function
|
||||
HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_003, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<IDisplayPowerEventListener> listener = new DisplayPowerEventListener();
|
||||
bool ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener);
|
||||
ASSERT_EQ(false, ret);
|
||||
DMError ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener);
|
||||
ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,7 +174,8 @@ sptr<Window> ScreenManagerTest::CreateWindowByDisplayId(DisplayId displayId)
|
||||
}
|
||||
|
||||
#define CHECK_TEST_INIT_SCREEN_STATE \
|
||||
std::vector<sptr<Screen>> allScreens = ScreenManager::GetInstance().GetAllScreens(); \
|
||||
std::vector<sptr<Screen>> allScreens; \
|
||||
ScreenManager::GetInstance().GetAllScreens(allScreens); \
|
||||
ASSERT_LT(0, allScreens.size()); \
|
||||
ScreenId groupId = SCREEN_ID_INVALID; \
|
||||
for (auto screen : allScreens) { \
|
||||
@ -281,10 +282,11 @@ HWTEST_F(ScreenManagerTest, ScreenManager02, Function | MediumTest | Level2)
|
||||
defaultOption_.surface_ = utils.psurface_;
|
||||
defaultOption_.isForShot_ = false;
|
||||
ScreenId virtualScreenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption_);
|
||||
ScreenId screenGroupId;
|
||||
sleep(TEST_SLEEP_S);
|
||||
std::vector<ScreenId> mirrorIds;
|
||||
mirrorIds.push_back(virtualScreenId);
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds);
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds, screenGroupId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_NE(SCREEN_ID_INVALID, virtualScreenId);
|
||||
DMError res = ScreenManager::GetInstance().DestroyVirtualScreen(virtualScreenId);
|
||||
@ -325,10 +327,11 @@ HWTEST_F(ScreenManagerTest, ScreenManager04, Function | MediumTest | Level2)
|
||||
ASSERT_TRUE(utils.CreateSurface());
|
||||
defaultOption_.surface_ = utils.psurface_;
|
||||
ScreenId virtualScreenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption_);
|
||||
ScreenId screenGroupId;
|
||||
sleep(TEST_SLEEP_S);
|
||||
std::vector<ScreenId> mirrorIds;
|
||||
mirrorIds.push_back(virtualScreenId);
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds);
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds, screenGroupId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_NE(SCREEN_ID_INVALID, virtualScreenId);
|
||||
DMError res = ScreenManager::GetInstance().DestroyVirtualScreen(virtualScreenId);
|
||||
@ -351,13 +354,14 @@ HWTEST_F(ScreenManagerTest, ScreenManager05, Function | MediumTest | Level2)
|
||||
defaultOption_.surface_ = utils.psurface_;
|
||||
defaultOption_.isForShot_ = true;
|
||||
ScreenId virtualScreenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption_);
|
||||
ScreenId screenGroupId;
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
ASSERT_NE(SCREEN_ID_INVALID, virtualScreenId);
|
||||
uint32_t lastCount = -1u;
|
||||
std::vector<ScreenId> mirrorIds;
|
||||
mirrorIds.push_back(virtualScreenId);
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds);
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds, screenGroupId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
while (utils.successCount_ < acquireFrames_ && waitCount_ <= maxWaitCount_) {
|
||||
@ -388,6 +392,7 @@ HWTEST_F(ScreenManagerTest, ScreenManager06, Function | MediumTest | Level2)
|
||||
defaultOption_.surface_ = nullptr;
|
||||
defaultOption_.isForShot_ = true;
|
||||
ScreenId virtualScreenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption_);
|
||||
ScreenId screenGroupId;
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_NE(SCREEN_ID_INVALID, virtualScreenId);
|
||||
|
||||
@ -397,7 +402,7 @@ HWTEST_F(ScreenManagerTest, ScreenManager06, Function | MediumTest | Level2)
|
||||
uint32_t lastCount = -1u;
|
||||
std::vector<ScreenId> mirrorIds;
|
||||
mirrorIds.push_back(virtualScreenId);
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds);
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds, screenGroupId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
while (utils.successCount_ < acquireFrames_ && waitCount_ <= maxWaitCount_) {
|
||||
@ -429,12 +434,12 @@ HWTEST_F(ScreenManagerTest, ScreenManager07, Function | MediumTest | Level2)
|
||||
auto defaultModeId = screen->GetModeId();
|
||||
ASSERT_GT(modes.size(), 0);
|
||||
for (uint32_t modeIdx = 0; modeIdx < modes.size(); modeIdx++) {
|
||||
ASSERT_EQ(true, screen->SetScreenActiveMode(modeIdx));
|
||||
ASSERT_EQ(DMError::DM_OK, screen->SetScreenActiveMode(modeIdx));
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_EQ(modeIdx, screen->GetModeId());
|
||||
sleep(TEST_SLEEP_S);
|
||||
}
|
||||
ASSERT_EQ(true, screen->SetScreenActiveMode(defaultModeId));
|
||||
ASSERT_EQ(DMError::DM_OK, screen->SetScreenActiveMode(defaultModeId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -453,12 +458,14 @@ HWTEST_F(ScreenManagerTest, ScreenManager08, Function | MediumTest | Level2)
|
||||
sleep(TEST_SLEEP_S);
|
||||
CHECK_SCREEN_STATE_AFTER_CREATE_VIRTUAL_SCREEN
|
||||
CheckScreenStateInGroup(false, group, groupId, virtualScreen, virtualScreenId);
|
||||
std::vector<sptr<Screen>> screens = ScreenManager::GetInstance().GetAllScreens();
|
||||
std::vector<sptr<Screen>> screens;
|
||||
ScreenManager::GetInstance().GetAllScreens(screens);
|
||||
sleep(TEST_SLEEP_S);
|
||||
sptr<Screen> defaultScreen = screens.front();
|
||||
ASSERT_TRUE(defaultScreen);
|
||||
std::vector<ExpandOption> options = {{defaultScreen->GetId(), 0, 0}, {virtualScreenId, defaultWidth_, 0}};
|
||||
ScreenId expansionGroup = ScreenManager::GetInstance().MakeExpand(options);
|
||||
ScreenId expansionGroup;
|
||||
ScreenManager::GetInstance().MakeExpand(options, expansionGroup);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_NE(SCREEN_ID_INVALID, expansionGroup);
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_EXPAND, ScreenGroupChangeEvent::ADD_TO_GROUP,
|
||||
@ -497,7 +504,8 @@ HWTEST_F(ScreenManagerTest, ScreenManager09, Function | MediumTest | Level2)
|
||||
CheckScreenStateInGroup(false, group, groupId, virtualScreen, virtualScreenId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
std::vector<ExpandOption> options = {{defaultScreenId_, 0, 0}, {virtualScreenId, defaultWidth_, 0}};
|
||||
ScreenId expansionId = ScreenManager::GetInstance().MakeExpand(options);
|
||||
ScreenId expansionId;
|
||||
ScreenManager::GetInstance().MakeExpand(options, expansionId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_EXPAND, ScreenGroupChangeEvent::ADD_TO_GROUP,
|
||||
virtualScreenId, group, screenGroupChangeListener);
|
||||
@ -577,7 +585,8 @@ HWTEST_F(ScreenManagerTest, ScreenManager11, Function | MediumTest | Level2)
|
||||
|
||||
std::vector<ScreenId> mirrorIds;
|
||||
mirrorIds.push_back(virtualScreenId);
|
||||
auto mirrorGroup = ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds);
|
||||
ScreenId mirrorGroup;
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds, mirrorGroup);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_EQ(mirrorGroup, groupId);
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_MIRROR, ScreenGroupChangeEvent::ADD_TO_GROUP,
|
||||
@ -625,7 +634,8 @@ HWTEST_F(ScreenManagerTest, ScreenManager12, Function | MediumTest | Level2)
|
||||
|
||||
std::vector<ScreenId> mirrorIds;
|
||||
mirrorIds.push_back(virtualScreenId);
|
||||
auto mirrorGroup = ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds);
|
||||
ScreenId mirrorGroup;
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorIds, mirrorGroup);
|
||||
ASSERT_EQ(mirrorGroup, groupId);
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_MIRROR, ScreenGroupChangeEvent::ADD_TO_GROUP,
|
||||
virtualScreenId, group, screenGroupChangeListener);
|
||||
@ -667,12 +677,14 @@ HWTEST_F(ScreenManagerTest, ScreenManager13, Function | MediumTest | Level2)
|
||||
CHECK_SCREEN_STATE_AFTER_CREATE_VIRTUAL_SCREEN
|
||||
CheckScreenStateInGroup(false, group, groupId, virtualScreen, virtualScreenId);
|
||||
|
||||
std::vector<sptr<Screen>> screens = ScreenManager::GetInstance().GetAllScreens();
|
||||
std::vector<sptr<Screen>> screens;
|
||||
ScreenManager::GetInstance().GetAllScreens(screens);
|
||||
sleep(TEST_SLEEP_S);
|
||||
sptr<Screen> defaultScreen = screens.front();
|
||||
ASSERT_TRUE(defaultScreen);
|
||||
std::vector<ExpandOption> options = {{defaultScreen->GetId(), 0, 0}, {virtualScreenId, defaultWidth_, 0}};
|
||||
ScreenId expansionGroup = ScreenManager::GetInstance().MakeExpand(options);
|
||||
ScreenId expansionGroup;
|
||||
ScreenManager::GetInstance().MakeExpand(options, expansionGroup);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_NE(SCREEN_ID_INVALID, expansionGroup);
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_EXPAND, ScreenGroupChangeEvent::ADD_TO_GROUP,
|
||||
@ -714,11 +726,13 @@ HWTEST_F(ScreenManagerTest, ScreenManager14, Function | MediumTest | Level2)
|
||||
CHECK_SCREEN_STATE_AFTER_CREATE_VIRTUAL_SCREEN
|
||||
CheckScreenStateInGroup(false, group, groupId, virtualScreen, virtualScreenId);
|
||||
|
||||
std::vector<sptr<Screen>> screens = ScreenManager::GetInstance().GetAllScreens();
|
||||
std::vector<sptr<Screen>> screens;
|
||||
ScreenManager::GetInstance().GetAllScreens(screens);
|
||||
sptr<Screen> defaultScreen = screens.front();
|
||||
ASSERT_TRUE(defaultScreen);
|
||||
std::vector<ExpandOption> options = {{defaultScreen->GetId(), 0, 0}, {virtualScreenId, defaultWidth_, 0}};
|
||||
ScreenId expansionGroup = ScreenManager::GetInstance().MakeExpand(options);
|
||||
ScreenId expansionGroup;
|
||||
ScreenManager::GetInstance().MakeExpand(options, expansionGroup);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_EQ(expansionGroup, groupId);
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_EXPAND, ScreenGroupChangeEvent::ADD_TO_GROUP,
|
||||
@ -727,7 +741,8 @@ HWTEST_F(ScreenManagerTest, ScreenManager14, Function | MediumTest | Level2)
|
||||
|
||||
std::vector<ScreenId> mirrorScreens;
|
||||
mirrorScreens.emplace_back(virtualScreenId);
|
||||
auto mirrorGroup = ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorScreens);
|
||||
ScreenId mirrorGroup;
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorScreens, mirrorGroup);
|
||||
ASSERT_EQ(mirrorGroup, groupId);
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_MIRROR, ScreenGroupChangeEvent::CHANGE_GROUP,
|
||||
virtualScreenId, group, screenGroupChangeListener);
|
||||
@ -767,7 +782,8 @@ HWTEST_F(ScreenManagerTest, ScreenManager15, Function | MediumTest | Level2)
|
||||
|
||||
std::vector<ScreenId> mirrorScreens;
|
||||
mirrorScreens.emplace_back(virtualScreenId);
|
||||
auto mirrorGroup = ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorScreens);
|
||||
ScreenId mirrorGroup;
|
||||
ScreenManager::GetInstance().MakeMirror(defaultScreenId_, mirrorScreens, mirrorGroup);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_EQ(mirrorGroup, groupId);
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_MIRROR, ScreenGroupChangeEvent::ADD_TO_GROUP,
|
||||
@ -776,11 +792,13 @@ HWTEST_F(ScreenManagerTest, ScreenManager15, Function | MediumTest | Level2)
|
||||
virtualScreenGroupChangeListener);
|
||||
CheckScreenStateInGroup(true, group, groupId, virtualScreen, virtualScreenId);
|
||||
|
||||
std::vector<sptr<Screen>> screens = ScreenManager::GetInstance().GetAllScreens();
|
||||
std::vector<sptr<Screen>> screens;
|
||||
ScreenManager::GetInstance().GetAllScreens(screens);
|
||||
sptr<Screen> defaultScreen = screens.front();
|
||||
ASSERT_TRUE(defaultScreen);
|
||||
std::vector<ExpandOption> options = {{defaultScreen->GetId(), 0, 0}, {virtualScreenId, defaultWidth_, 0}};
|
||||
ScreenId expansionGroup = ScreenManager::GetInstance().MakeExpand(options);
|
||||
ScreenId expansionGroup;
|
||||
ScreenManager::GetInstance().MakeExpand(options, expansionGroup);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_EQ(expansionGroup, groupId);
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_EXPAND, ScreenGroupChangeEvent::CHANGE_GROUP,
|
||||
@ -808,7 +826,8 @@ HWTEST_F(ScreenManagerTest, ScreenManager15, Function | MediumTest | Level2)
|
||||
*/
|
||||
HWTEST_F(ScreenManagerTest, ScreenManager16, Function | MediumTest | Level2)
|
||||
{
|
||||
auto screens = ScreenManager::GetInstance().GetAllScreens();
|
||||
std::vector<sptr<Screen>> screens;
|
||||
ScreenManager::GetInstance().GetAllScreens(screens);
|
||||
ASSERT_TRUE(screens[0]);
|
||||
auto display = DisplayManager::GetInstance().GetDefaultDisplay();
|
||||
ASSERT_TRUE(display);
|
||||
@ -857,10 +876,12 @@ HWTEST_F(ScreenManagerTest, ScreenManager17, Function | MediumTest | Level2)
|
||||
*/
|
||||
HWTEST_F(ScreenManagerTest, ScreenManager18, Function | SmallTest | Level1)
|
||||
{
|
||||
bool originalLockStatus = ScreenManager::GetInstance().IsScreenRotationLocked();
|
||||
bool originalLockStatus;
|
||||
ScreenManager::GetInstance().IsScreenRotationLocked(originalLockStatus);
|
||||
ScreenManager::GetInstance().SetScreenRotationLocked(!originalLockStatus);
|
||||
sleep(TEST_SLEEP_S);
|
||||
bool modifiedLockedStatus = ScreenManager::GetInstance().IsScreenRotationLocked();
|
||||
bool modifiedLockedStatus;
|
||||
ScreenManager::GetInstance().IsScreenRotationLocked(modifiedLockedStatus);
|
||||
ScreenManager::GetInstance().SetScreenRotationLocked(originalLockStatus);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_EQ(!originalLockStatus, modifiedLockedStatus);
|
||||
@ -888,7 +909,8 @@ HWTEST_F(ScreenManagerTest, VirtualExpandScreen01, Function | MediumTest | Level
|
||||
CheckScreenStateInGroup(false, group, groupId, virtualScreen, virtualScreenId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
std::vector<ExpandOption> options = {{defaultScreenId_, 0, 0}, {virtualScreenId, defaultWidth_, 0}};
|
||||
ScreenId expansionId = ScreenManager::GetInstance().MakeExpand(options);
|
||||
ScreenId expansionId;
|
||||
ScreenManager::GetInstance().MakeExpand(options, expansionId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_EXPAND, ScreenGroupChangeEvent::ADD_TO_GROUP,
|
||||
@ -917,7 +939,7 @@ HWTEST_F(ScreenManagerTest, VirtualExpandScreen01, Function | MediumTest | Level
|
||||
uint32_t orientation = static_cast<uint32_t>(Orientation::VERTICAL);
|
||||
uint32_t end = static_cast<uint32_t>(Orientation::REVERSE_HORIZONTAL);
|
||||
ASSERT_TRUE(screenListener);
|
||||
|
||||
|
||||
for (; orientation <= end; ++orientation) {
|
||||
screen->SetOrientation(static_cast<Orientation>(orientation));
|
||||
screenListener->changeFuture_.GetResult(TIME_OUT);
|
||||
|
@ -204,7 +204,9 @@ HWTEST_F(WindowRotationTest, WindowRotationTest3, Function | MediumTest | Level3
|
||||
|
||||
ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, fullWindow->GetRequestedOrientation());
|
||||
auto display = DisplayManager::GetInstance().GetDefaultDisplay();
|
||||
auto screen = ScreenManager::GetInstance().GetAllScreens()[0];
|
||||
std::vector<sptr<Screen>> screens;
|
||||
ScreenManager::GetInstance().GetAllScreens(screens);
|
||||
auto screen = screens[0];
|
||||
ASSERT_EQ(Orientation::UNSPECIFIED, screen->GetOrientation());
|
||||
ASSERT_EQ(Orientation::UNSPECIFIED, display->GetOrientation());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
@ -68,6 +68,7 @@ ohos_shared_library("libwmutil") {
|
||||
external_deps = [
|
||||
"ability_runtime:ability_manager",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"graphic_standard:surface",
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <bundle_mgr_proxy.h>
|
||||
#include <system_ability_definition.h>
|
||||
#include <iservice_registry.h>
|
||||
#include <tokenid_kit.h>
|
||||
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
@ -49,33 +50,9 @@ bool Permission::IsSystemCalling()
|
||||
if (IsSystemServiceCalling(false)) {
|
||||
return true;
|
||||
}
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
if (uid < 0) {
|
||||
WLOGFE("Is not system calling, app caller uid is: %d,", uid);
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityManager == nullptr) {
|
||||
WLOGFE("Is not system calling, failed to get system ability mgr.");
|
||||
return false;
|
||||
}
|
||||
sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (remoteObject == nullptr) {
|
||||
WLOGFE("Is not system calling, failed to get bundle manager proxy.");
|
||||
return false;
|
||||
}
|
||||
sptr<AppExecFwk::IBundleMgr> iBundleMgr = iface_cast<AppExecFwk::IBundleMgr>(remoteObject);
|
||||
if (iBundleMgr == nullptr) {
|
||||
WLOGFE("Is not system calling, iBundleMgr is nullptr");
|
||||
return false;
|
||||
}
|
||||
bool isSystemAppCalling = iBundleMgr->CheckIsSystemAppByUid(uid);
|
||||
if (!isSystemAppCalling) {
|
||||
WLOGFE("Is not system calling, UID:%{public}d IsSystemApp:%{public}d", uid, isSystemAppCalling);
|
||||
}
|
||||
return isSystemAppCalling;
|
||||
uint64_t accessTokenIDEx = IPCSkeleton::GetCallingFullTokenID();
|
||||
bool isSystemApp = Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(accessTokenIDEx);
|
||||
return isSystemApp;
|
||||
}
|
||||
|
||||
bool Permission::CheckCallingPermission(const std::string& permission)
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
sptr<MoveDragProperty>& moveDragProperty);
|
||||
virtual void ProcessPointDown(uint32_t windowId, bool isPointDown = true);
|
||||
virtual void ProcessPointUp(uint32_t windowId);
|
||||
virtual void MinimizeAllAppWindows(DisplayId displayId);
|
||||
virtual WMError MinimizeAllAppWindows(DisplayId displayId);
|
||||
virtual WMError ToggleShownStateForAllAppWindows();
|
||||
virtual WMError SetWindowLayoutMode(WindowLayoutMode mode);
|
||||
virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action);
|
||||
@ -55,9 +55,9 @@ public:
|
||||
virtual WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones);
|
||||
virtual WMError UpdateRsTree(uint32_t windowId, bool isAdd);
|
||||
virtual WMError BindDialogTarget(uint32_t& windowId, sptr<IRemoteObject> targetToken);
|
||||
virtual bool RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
virtual WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent);
|
||||
virtual bool UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
virtual WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent);
|
||||
|
||||
virtual WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller);
|
||||
|
@ -136,8 +136,8 @@ public:
|
||||
virtual bool IsLayoutFullScreen() const override;
|
||||
virtual WMError SetWindowType(WindowType type) override;
|
||||
virtual WMError SetWindowMode(WindowMode mode) override;
|
||||
virtual void SetAlpha(float alpha) override;
|
||||
virtual void SetTransform(const Transform& trans) override;
|
||||
virtual WMError SetAlpha(float alpha) override;
|
||||
virtual WMError SetTransform(const Transform& trans) override;
|
||||
virtual WMError AddWindowFlag(WindowFlag flag) override;
|
||||
virtual WMError RemoveWindowFlag(WindowFlag flag) override;
|
||||
virtual WMError SetWindowFlags(uint32_t flags) override;
|
||||
@ -171,22 +171,22 @@ public:
|
||||
virtual WMError SetBrightness(float brightness) override;
|
||||
virtual float GetBrightness() const override;
|
||||
virtual WMError SetCallingWindow(uint32_t windowId) override;
|
||||
virtual void SetPrivacyMode(bool isPrivacyMode) override;
|
||||
virtual WMError SetPrivacyMode(bool isPrivacyMode) override;
|
||||
virtual bool IsPrivacyMode() const override;
|
||||
virtual void SetSystemPrivacyMode(bool isSystemPrivacyMode) override;
|
||||
virtual void DisableAppWindowDecor() override;
|
||||
virtual WMError DisableAppWindowDecor() override;
|
||||
virtual WMError BindDialogTarget(sptr<IRemoteObject> targetToken) override;
|
||||
virtual void SetSnapshotSkip(bool isSkip) override;
|
||||
WmErrorCode RaiseToAppTop() override;
|
||||
virtual WMError SetAspectRatio(float ratio) override;
|
||||
virtual WMError UnsetAspectRatio() override;
|
||||
virtual WMError SetSnapshotSkip(bool isSkip) override;
|
||||
|
||||
// window effect
|
||||
virtual WMError SetCornerRadius(float cornerRadius) override;
|
||||
virtual WMError SetShadowRadius(float radius) override;
|
||||
virtual WMError SetShadowColor(std::string color) override;
|
||||
virtual void SetShadowOffsetX(float offsetX) override;
|
||||
virtual void SetShadowOffsetY(float offsetY) override;
|
||||
virtual WMError SetShadowOffsetX(float offsetX) override;
|
||||
virtual WMError SetShadowOffsetY(float offsetY) override;
|
||||
virtual WMError SetBlur(float radius) override;
|
||||
virtual WMError SetBackdropBlur(float radius) override;
|
||||
virtual WMError SetBackdropBlurStyle(WindowBlurStyle blurStyle) override;
|
||||
@ -201,26 +201,27 @@ public:
|
||||
virtual WMError RequestFocus() const override;
|
||||
virtual void SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer>& inputEventConsumer) override;
|
||||
|
||||
virtual bool RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
|
||||
virtual bool RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
|
||||
virtual bool UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
|
||||
virtual bool UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
|
||||
virtual bool RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
|
||||
virtual bool UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
|
||||
virtual bool RegisterDragListener(const sptr<IWindowDragListener>& listener) override;
|
||||
virtual bool UnregisterDragListener(const sptr<IWindowDragListener>& listener) override;
|
||||
virtual bool RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
|
||||
virtual bool UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
|
||||
virtual WMError RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
|
||||
virtual WMError RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
|
||||
virtual WMError UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
|
||||
virtual WMError UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
|
||||
virtual WMError RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
|
||||
virtual WMError UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
|
||||
virtual WMError RegisterDragListener(const sptr<IWindowDragListener>& listener) override;
|
||||
virtual WMError UnregisterDragListener(const sptr<IWindowDragListener>& listener) override;
|
||||
virtual WMError RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
|
||||
virtual WMError UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
|
||||
virtual void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) override;
|
||||
virtual bool RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
|
||||
virtual bool UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
|
||||
virtual bool RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual bool UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual bool RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener) override;
|
||||
virtual bool RegisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
|
||||
virtual bool UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
|
||||
virtual bool RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
|
||||
virtual bool UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
|
||||
virtual WMError RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
|
||||
virtual WMError UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
|
||||
virtual WMError RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual WMError UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual WMError RegisterAnimationTransitionController(
|
||||
const sptr<IAnimationTransitionController>& listener) override;
|
||||
virtual WMError RegisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
|
||||
virtual WMError UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
|
||||
virtual WMError RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
|
||||
virtual WMError UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
|
||||
virtual void RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) override;
|
||||
virtual void UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) override;
|
||||
virtual void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) override;
|
||||
@ -279,8 +280,8 @@ public:
|
||||
private:
|
||||
template<typename T1, typename T2, typename Ret>
|
||||
using EnableIfSame = typename std::enable_if<std::is_same_v<T1, T2>, Ret>::type;
|
||||
template<typename T> bool RegisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener);
|
||||
template<typename T> bool UnregisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener);
|
||||
template<typename T> WMError RegisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener);
|
||||
template<typename T> WMError UnregisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener);
|
||||
template<typename T> void ClearUselessListeners(std::map<uint32_t, T>& listeners, uint32_t winId)
|
||||
{
|
||||
listeners.erase(winId);
|
||||
|
@ -25,7 +25,7 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "Window"};
|
||||
}
|
||||
sptr<Window> Window::Create(const std::string& windowName, sptr<WindowOption>& option,
|
||||
const std::shared_ptr<OHOS::AbilityRuntime::Context>& context)
|
||||
const std::shared_ptr<OHOS::AbilityRuntime::Context>& context, WMError& errCode)
|
||||
{
|
||||
if (windowName.empty()) {
|
||||
WLOGFE("window name is empty");
|
||||
@ -51,6 +51,7 @@ sptr<Window> Window::Create(const std::string& windowName, sptr<WindowOption>& o
|
||||
}
|
||||
WMError error = windowImpl->Create(option->GetParentId(), context);
|
||||
if (error != WMError::WM_OK) {
|
||||
errCode = error;
|
||||
return nullptr;
|
||||
}
|
||||
return windowImpl;
|
||||
|
@ -66,17 +66,17 @@ WMError WindowAdapter::RequestFocus(uint32_t windowId)
|
||||
return windowManagerServiceProxy_->RequestFocus(windowId);
|
||||
}
|
||||
|
||||
bool WindowAdapter::RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError WindowAdapter::RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(false);
|
||||
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
|
||||
return windowManagerServiceProxy_->RegisterWindowManagerAgent(type, windowManagerAgent);
|
||||
}
|
||||
|
||||
bool WindowAdapter::UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError WindowAdapter::UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(false);
|
||||
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
|
||||
return windowManagerServiceProxy_->UnregisterWindowManagerAgent(type, windowManagerAgent);
|
||||
}
|
||||
|
||||
@ -124,10 +124,10 @@ void WindowAdapter::ProcessPointUp(uint32_t windowId)
|
||||
return windowManagerServiceProxy_->ProcessPointUp(windowId);
|
||||
}
|
||||
|
||||
void WindowAdapter::MinimizeAllAppWindows(DisplayId displayId)
|
||||
WMError WindowAdapter::MinimizeAllAppWindows(DisplayId displayId)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN();
|
||||
windowManagerServiceProxy_->MinimizeAllAppWindows(displayId);
|
||||
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
|
||||
return windowManagerServiceProxy_->MinimizeAllAppWindows(displayId);
|
||||
}
|
||||
|
||||
WMError WindowAdapter::ToggleShownStateForAllAppWindows()
|
||||
|
@ -340,9 +340,10 @@ WMError WindowImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea)
|
||||
WMError WindowImpl::SetWindowType(WindowType type)
|
||||
{
|
||||
WLOGFD("window id: %{public}u, type:%{public}u.", property_->GetWindowId(), static_cast<uint32_t>(type));
|
||||
if (type != WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW && !Permission::IsSystemCalling()) {
|
||||
if (type != WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW && !Permission::IsSystemCalling() &&
|
||||
!Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set window type permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (!IsWindowValid()) {
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
@ -394,26 +395,27 @@ WMError WindowImpl::SetWindowMode(WindowMode mode)
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::SetAlpha(float alpha)
|
||||
WMError WindowImpl::SetAlpha(float alpha)
|
||||
{
|
||||
WLOGI("Window %{public}u alpha %{public}f", property_->GetWindowId(), alpha);
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set alpha permission denied!");
|
||||
return;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (!IsWindowValid()) {
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
property_->SetAlpha(alpha);
|
||||
surfaceNode_->SetAlpha(alpha);
|
||||
RSTransaction::FlushImplicitTransaction();
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::SetTransform(const Transform& trans)
|
||||
WMError WindowImpl::SetTransform(const Transform& trans)
|
||||
{
|
||||
WLOGI("Window %{public}u", property_->GetWindowId());
|
||||
if (!IsWindowValid()) {
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
Transform oriTrans = property_->GetTransform();
|
||||
property_->SetTransform(trans);
|
||||
@ -428,6 +430,7 @@ void WindowImpl::SetTransform(const Transform& trans)
|
||||
} else {
|
||||
TransformSurfaceNode(trans);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const Transform& WindowImpl::GetTransform() const
|
||||
@ -446,7 +449,10 @@ WMError WindowImpl::AddWindowFlag(WindowFlag flag)
|
||||
WLOGFE("Only support add show when locked when window create, id: %{public}u", property_->GetWindowId());
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
|
||||
if (flag == WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE && !Permission::IsSystemCalling()) {
|
||||
WLOGFE("set forbid split move permission denied!");
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
uint32_t updateFlags = property_->GetWindowFlags() | (static_cast<uint32_t>(flag));
|
||||
return SetWindowFlags(updateFlags);
|
||||
}
|
||||
@ -457,7 +463,10 @@ WMError WindowImpl::RemoveWindowFlag(WindowFlag flag)
|
||||
WLOGFE("Only support remove show when locked when window create, id: %{public}u", property_->GetWindowId());
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
|
||||
if (flag == WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE && !Permission::IsSystemCalling()) {
|
||||
WLOGFE("set forbid split move permission denied!");
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
uint32_t updateFlags = property_->GetWindowFlags() & (~(static_cast<uint32_t>(flag)));
|
||||
return SetWindowFlags(updateFlags);
|
||||
}
|
||||
@ -1703,11 +1712,11 @@ std::string WindowImpl::TransferLifeCycleEventToString(LifeCycleEvent type) cons
|
||||
return event;
|
||||
}
|
||||
|
||||
void WindowImpl::SetPrivacyMode(bool isPrivacyMode)
|
||||
WMError WindowImpl::SetPrivacyMode(bool isPrivacyMode)
|
||||
{
|
||||
property_->SetPrivacyMode(isPrivacyMode);
|
||||
surfaceNode_->SetSecurityLayer(isPrivacyMode || property_->GetSystemPrivacyMode());
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE);
|
||||
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE);
|
||||
}
|
||||
|
||||
bool WindowImpl::IsPrivacyMode() const
|
||||
@ -1721,13 +1730,14 @@ void WindowImpl::SetSystemPrivacyMode(bool isSystemPrivacyMode)
|
||||
surfaceNode_->SetSecurityLayer(isSystemPrivacyMode || property_->GetPrivacyMode());
|
||||
}
|
||||
|
||||
void WindowImpl::SetSnapshotSkip(bool isSkip)
|
||||
WMError WindowImpl::SetSnapshotSkip(bool isSkip)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set snapshot skip permission denied!");
|
||||
return;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
surfaceNode_->SetSecurityLayer(isSkip || property_->GetSystemPrivacyMode());
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WmErrorCode WindowImpl::RaiseToAppTop()
|
||||
@ -1751,18 +1761,19 @@ WmErrorCode WindowImpl::RaiseToAppTop()
|
||||
return SingletonContainer::Get<WindowAdapter>().RaiseToAppTop(GetWindowId());
|
||||
}
|
||||
|
||||
void WindowImpl::DisableAppWindowDecor()
|
||||
WMError WindowImpl::DisableAppWindowDecor()
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("disable app window decor permission denied!");
|
||||
return;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (!WindowHelper::IsMainWindow(property_->GetWindowType())) {
|
||||
WLOGFE("window decoration is invalid on sub window");
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_OPERATION;
|
||||
}
|
||||
WLOGI("disable app window decoration.");
|
||||
property_->SetDecorEnable(false);
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::IsDecorEnable() const
|
||||
@ -1882,78 +1893,78 @@ void WindowImpl::SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer
|
||||
inputEventConsumer_ = inputEventConsumer;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
|
||||
WMError WindowImpl::RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
|
||||
{
|
||||
WLOGFD("Start register");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return RegisterListener(lifecycleListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
|
||||
WMError WindowImpl::UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
|
||||
{
|
||||
WLOGFD("Start unregister");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return UnregisterListener(lifecycleListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
|
||||
WMError WindowImpl::RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
|
||||
{
|
||||
WLOGFD("Start register");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return RegisterListener(windowChangeListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
|
||||
WMError WindowImpl::UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
|
||||
{
|
||||
WLOGFD("Start register");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return UnregisterListener(windowChangeListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
|
||||
WMError WindowImpl::RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
|
||||
{
|
||||
WLOGFD("Start register");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
bool ret = RegisterListener(avoidAreaChangeListeners_[GetWindowId()], listener);
|
||||
WMError ret = RegisterListener(avoidAreaChangeListeners_[GetWindowId()], listener);
|
||||
if (avoidAreaChangeListeners_[GetWindowId()].size() == 1) {
|
||||
SingletonContainer::Get<WindowAdapter>().UpdateAvoidAreaListener(property_->GetWindowId(), true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
|
||||
WMError WindowImpl::UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
|
||||
{
|
||||
WLOGFD("Start unregister");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
bool ret = UnregisterListener(avoidAreaChangeListeners_[GetWindowId()], listener);
|
||||
WMError ret = UnregisterListener(avoidAreaChangeListeners_[GetWindowId()], listener);
|
||||
if (avoidAreaChangeListeners_[GetWindowId()].empty()) {
|
||||
SingletonContainer::Get<WindowAdapter>().UpdateAvoidAreaListener(property_->GetWindowId(), false);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterDragListener(const sptr<IWindowDragListener>& listener)
|
||||
WMError WindowImpl::RegisterDragListener(const sptr<IWindowDragListener>& listener)
|
||||
{
|
||||
WLOGFD("Start register");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
return RegisterListener(windowDragListeners_, listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterDragListener(const sptr<IWindowDragListener>& listener)
|
||||
WMError WindowImpl::UnregisterDragListener(const sptr<IWindowDragListener>& listener)
|
||||
{
|
||||
WLOGFD("Start unregister");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
return UnregisterListener(windowDragListeners_, listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
|
||||
WMError WindowImpl::RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
|
||||
{
|
||||
WLOGFD("Start register");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
return RegisterListener(displayMoveListeners_, listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
|
||||
WMError WindowImpl::UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
|
||||
{
|
||||
WLOGFD("Start unregister");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
@ -1966,39 +1977,51 @@ void WindowImpl::RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFun
|
||||
notifyNativefunc_ = std::move(func);
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
|
||||
WMError WindowImpl::RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
|
||||
{
|
||||
WLOGFD("Start register");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return RegisterListener(occupiedAreaChangeListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
|
||||
WMError WindowImpl::UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
|
||||
{
|
||||
WLOGFD("Start unregister");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return UnregisterListener(occupiedAreaChangeListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
|
||||
WMError WindowImpl::RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
|
||||
{
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("register touch outside listener permission denied!");
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
WLOGFD("Start register");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return RegisterListener(touchOutsideListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
|
||||
WMError WindowImpl::UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
|
||||
{
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("register touch outside listener permission denied!");
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
WLOGFD("Start unregister");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return UnregisterListener(touchOutsideListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener)
|
||||
WMError WindowImpl::RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener)
|
||||
{
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("register animation transition controller permission denied!");
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener is nullptr");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
animationTransitionController_ = listener;
|
||||
wptr<WindowProperty> propertyToken(property_);
|
||||
@ -2017,31 +2040,31 @@ bool WindowImpl::RegisterAnimationTransitionController(const sptr<IAnimationTran
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterScreenshotListener(const sptr<IScreenshotListener>& listener)
|
||||
WMError WindowImpl::RegisterScreenshotListener(const sptr<IScreenshotListener>& listener)
|
||||
{
|
||||
WLOGFD("Start register");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return RegisterListener(screenshotListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener)
|
||||
WMError WindowImpl::UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener)
|
||||
{
|
||||
WLOGFD("Start unregister");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return UnregisterListener(screenshotListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
|
||||
WMError WindowImpl::RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
|
||||
{
|
||||
WLOGFD("Start register");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
return RegisterListener(dialogTargetTouchListeners_[GetWindowId()], listener);
|
||||
}
|
||||
|
||||
bool WindowImpl::UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
|
||||
WMError WindowImpl::UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
|
||||
{
|
||||
WLOGFD("Start unregister");
|
||||
std::lock_guard<std::recursive_mutex> lock(globalMutex_);
|
||||
@ -2067,32 +2090,32 @@ void WindowImpl::UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathR
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool WindowImpl::RegisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener)
|
||||
WMError WindowImpl::RegisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener is nullptr");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
if (std::find(holder.begin(), holder.end(), listener) != holder.end()) {
|
||||
WLOGFE("Listener already registered");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
holder.emplace_back(listener);
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool WindowImpl::UnregisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener)
|
||||
WMError WindowImpl::UnregisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
holder.erase(std::remove_if(holder.begin(), holder.end(),
|
||||
[listener](sptr<T> registeredListener) {
|
||||
return registeredListener == listener;
|
||||
}), holder.end());
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler)
|
||||
@ -3270,9 +3293,9 @@ WMError WindowImpl::SetCornerRadius(float cornerRadius)
|
||||
|
||||
WMError WindowImpl::SetShadowRadius(float radius)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set shadow radius permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
WLOGI("Window %{public}s set shadow radius %{public}f", name_.c_str(), radius);
|
||||
if (MathHelper::LessNotEqual(radius, 0.0)) {
|
||||
@ -3285,9 +3308,9 @@ WMError WindowImpl::SetShadowRadius(float radius)
|
||||
|
||||
WMError WindowImpl::SetShadowColor(std::string color)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set shadow color permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
WLOGI("Window %{public}s set shadow color %{public}s", name_.c_str(), color.c_str());
|
||||
uint32_t colorValue;
|
||||
@ -3299,33 +3322,35 @@ WMError WindowImpl::SetShadowColor(std::string color)
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::SetShadowOffsetX(float offsetX)
|
||||
WMError WindowImpl::SetShadowOffsetX(float offsetX)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set shadow offset x permission denied!");
|
||||
return;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
WLOGI("Window %{public}s set shadow offsetX %{public}f", name_.c_str(), offsetX);
|
||||
surfaceNode_->SetShadowOffsetX(offsetX);
|
||||
RSTransaction::FlushImplicitTransaction();
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowImpl::SetShadowOffsetY(float offsetY)
|
||||
WMError WindowImpl::SetShadowOffsetY(float offsetY)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set shadow offset y permission denied!");
|
||||
return;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
WLOGI("Window %{public}s set shadow offsetY %{public}f", name_.c_str(), offsetY);
|
||||
surfaceNode_->SetShadowOffsetY(offsetY);
|
||||
RSTransaction::FlushImplicitTransaction();
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError WindowImpl::SetBlur(float radius)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set blur permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
WLOGI("Window %{public}s set blur radius %{public}f", name_.c_str(), radius);
|
||||
if (MathHelper::LessNotEqual(radius, 0.0)) {
|
||||
@ -3340,9 +3365,9 @@ WMError WindowImpl::SetBlur(float radius)
|
||||
|
||||
WMError WindowImpl::SetBackdropBlur(float radius)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set backdrop blur permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
WLOGI("Window %{public}s set backdrop blur radius %{public}f", name_.c_str(), radius);
|
||||
if (MathHelper::LessNotEqual(radius, 0.0)) {
|
||||
@ -3357,9 +3382,9 @@ WMError WindowImpl::SetBackdropBlur(float radius)
|
||||
|
||||
WMError WindowImpl::SetBackdropBlurStyle(WindowBlurStyle blurStyle)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set backdrop blur style permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
WLOGI("Window %{public}s set backdrop blur style %{public}u", name_.c_str(), blurStyle);
|
||||
if (blurStyle < WindowBlurStyle::WINDOW_BLUR_OFF || blurStyle > WindowBlurStyle::WINDOW_BLUR_THICK) {
|
||||
|
@ -239,49 +239,49 @@ void WindowManager::Impl::UpdateCameraFloatWindowStatus(uint32_t accessTokenId,
|
||||
|
||||
WindowManager::WindowManager() : pImpl_(std::make_unique<Impl>()) {}
|
||||
|
||||
bool WindowManager::RegisterFocusChangedListener(const sptr<IFocusChangedListener>& listener)
|
||||
WMError WindowManager::RegisterFocusChangedListener(const sptr<IFocusChangedListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
bool ret = true;
|
||||
WMError ret = WMError::WM_OK;
|
||||
if (pImpl_->focusChangedListenerAgent_ == nullptr) {
|
||||
pImpl_->focusChangedListenerAgent_ = new WindowManagerAgent();
|
||||
ret = SingletonContainer::Get<WindowAdapter>().RegisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS, pImpl_->focusChangedListenerAgent_);
|
||||
}
|
||||
if (!ret) {
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFW("RegisterWindowManagerAgent failed !");
|
||||
pImpl_->focusChangedListenerAgent_ = nullptr;
|
||||
} else {
|
||||
auto iter = std::find(pImpl_->focusChangedListeners_.begin(), pImpl_->focusChangedListeners_.end(), listener);
|
||||
if (iter != pImpl_->focusChangedListeners_.end()) {
|
||||
WLOGFW("Listener is already registered.");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
pImpl_->focusChangedListeners_.push_back(listener);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowManager::UnregisterFocusChangedListener(const sptr<IFocusChangedListener>& listener)
|
||||
WMError WindowManager::UnregisterFocusChangedListener(const sptr<IFocusChangedListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
auto iter = std::find(pImpl_->focusChangedListeners_.begin(), pImpl_->focusChangedListeners_.end(), listener);
|
||||
if (iter == pImpl_->focusChangedListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
pImpl_->focusChangedListeners_.erase(iter);
|
||||
bool ret = true;
|
||||
WMError ret = WMError::WM_OK;
|
||||
if (pImpl_->focusChangedListeners_.empty() && pImpl_->focusChangedListenerAgent_ != nullptr) {
|
||||
ret = SingletonContainer::Get<WindowAdapter>().UnregisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS, pImpl_->focusChangedListenerAgent_);
|
||||
@ -290,21 +290,21 @@ bool WindowManager::UnregisterFocusChangedListener(const sptr<IFocusChangedListe
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowManager::RegisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener)
|
||||
WMError WindowManager::RegisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
bool ret = true;
|
||||
WMError ret = WMError::WM_OK;
|
||||
if (pImpl_->systemBarChangedListenerAgent_ == nullptr) {
|
||||
pImpl_->systemBarChangedListenerAgent_ = new WindowManagerAgent();
|
||||
ret = SingletonContainer::Get<WindowAdapter>().RegisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR, pImpl_->systemBarChangedListenerAgent_);
|
||||
}
|
||||
if (!ret) {
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFW("RegisterWindowManagerAgent failed !");
|
||||
pImpl_->systemBarChangedListenerAgent_ = nullptr;
|
||||
} else {
|
||||
@ -312,18 +312,18 @@ bool WindowManager::RegisterSystemBarChangedListener(const sptr<ISystemBarChange
|
||||
listener);
|
||||
if (iter != pImpl_->systemBarChangedListeners_.end()) {
|
||||
WLOGFW("Listener is already registered.");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
pImpl_->systemBarChangedListeners_.push_back(listener);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowManager::UnregisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener)
|
||||
WMError WindowManager::UnregisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
@ -331,10 +331,10 @@ bool WindowManager::UnregisterSystemBarChangedListener(const sptr<ISystemBarChan
|
||||
listener);
|
||||
if (iter == pImpl_->systemBarChangedListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
pImpl_->systemBarChangedListeners_.erase(iter);
|
||||
bool ret = true;
|
||||
WMError ret = WMError::WM_OK;
|
||||
if (pImpl_->systemBarChangedListeners_.empty() && pImpl_->systemBarChangedListenerAgent_ != nullptr) {
|
||||
ret = SingletonContainer::Get<WindowAdapter>().UnregisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR, pImpl_->systemBarChangedListenerAgent_);
|
||||
@ -343,10 +343,10 @@ bool WindowManager::UnregisterSystemBarChangedListener(const sptr<ISystemBarChan
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WindowManager::MinimizeAllAppWindows(DisplayId displayId)
|
||||
WMError WindowManager::MinimizeAllAppWindows(DisplayId displayId)
|
||||
{
|
||||
WLOGFD("displayId %{public}" PRIu64"", displayId);
|
||||
SingletonContainer::Get<WindowAdapter>().MinimizeAllAppWindows(displayId);
|
||||
return SingletonContainer::Get<WindowAdapter>().MinimizeAllAppWindows(displayId);
|
||||
}
|
||||
|
||||
WMError WindowManager::ToggleShownStateForAllAppWindows()
|
||||
@ -365,47 +365,47 @@ WMError WindowManager::SetWindowLayoutMode(WindowLayoutMode mode)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowManager::RegisterWindowUpdateListener(const sptr<IWindowUpdateListener> &listener)
|
||||
WMError WindowManager::RegisterWindowUpdateListener(const sptr<IWindowUpdateListener> &listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
bool ret = true;
|
||||
WMError ret = WMError::WM_OK;
|
||||
if (pImpl_->windowUpdateListenerAgent_ == nullptr) {
|
||||
pImpl_->windowUpdateListenerAgent_ = new WindowManagerAgent();
|
||||
ret = SingletonContainer::Get<WindowAdapter>().RegisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE, pImpl_->windowUpdateListenerAgent_);
|
||||
}
|
||||
if (!ret) {
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFW("RegisterWindowManagerAgent failed !");
|
||||
pImpl_->windowUpdateListenerAgent_ = nullptr;
|
||||
} else {
|
||||
auto iter = std::find(pImpl_->windowUpdateListeners_.begin(), pImpl_->windowUpdateListeners_.end(), listener);
|
||||
if (iter != pImpl_->windowUpdateListeners_.end()) {
|
||||
WLOGI("Listener is already registered.");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
pImpl_->windowUpdateListeners_.emplace_back(listener);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowManager::UnregisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener)
|
||||
WMError WindowManager::UnregisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
auto iter = std::find(pImpl_->windowUpdateListeners_.begin(), pImpl_->windowUpdateListeners_.end(), listener);
|
||||
if (iter == pImpl_->windowUpdateListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
pImpl_->windowUpdateListeners_.erase(iter);
|
||||
bool ret = true;
|
||||
WMError ret = WMError::WM_OK;
|
||||
if (pImpl_->windowUpdateListeners_.empty() && pImpl_->windowUpdateListenerAgent_ != nullptr) {
|
||||
ret = SingletonContainer::Get<WindowAdapter>().UnregisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE, pImpl_->windowUpdateListenerAgent_);
|
||||
@ -414,21 +414,21 @@ bool WindowManager::UnregisterWindowUpdateListener(const sptr<IWindowUpdateListe
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowManager::RegisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener)
|
||||
WMError WindowManager::RegisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
bool ret = true;
|
||||
WMError ret = WMError::WM_OK;
|
||||
if (pImpl_->windowVisibilityListenerAgent_ == nullptr) {
|
||||
pImpl_->windowVisibilityListenerAgent_ = new WindowManagerAgent();
|
||||
ret = SingletonContainer::Get<WindowAdapter>().RegisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY,
|
||||
pImpl_->windowVisibilityListenerAgent_);
|
||||
}
|
||||
if (!ret) {
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFW("RegisterWindowManagerAgent failed !");
|
||||
pImpl_->windowVisibilityListenerAgent_ = nullptr;
|
||||
} else {
|
||||
@ -436,18 +436,18 @@ bool WindowManager::RegisterVisibilityChangedListener(const sptr<IVisibilityChan
|
||||
listener);
|
||||
if (iter != pImpl_->windowVisibilityListeners_.end()) {
|
||||
WLOGFW("Listener is already registered.");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
pImpl_->windowVisibilityListeners_.emplace_back(listener);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowManager::UnregisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener)
|
||||
WMError WindowManager::UnregisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
pImpl_->windowVisibilityListeners_.erase(std::remove_if(pImpl_->windowVisibilityListeners_.begin(),
|
||||
@ -455,7 +455,7 @@ bool WindowManager::UnregisterVisibilityChangedListener(const sptr<IVisibilityCh
|
||||
return registeredListener == listener;
|
||||
}), pImpl_->windowVisibilityListeners_.end());
|
||||
|
||||
bool ret = true;
|
||||
WMError ret = WMError::WM_OK;
|
||||
if (pImpl_->windowVisibilityListeners_.empty() && pImpl_->windowVisibilityListenerAgent_ != nullptr) {
|
||||
ret = SingletonContainer::Get<WindowAdapter>().UnregisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY,
|
||||
@ -465,22 +465,22 @@ bool WindowManager::UnregisterVisibilityChangedListener(const sptr<IVisibilityCh
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowManager::RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener)
|
||||
WMError WindowManager::RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
bool ret = true;
|
||||
WMError ret = WMError::WM_OK;
|
||||
if (pImpl_->cameraFloatWindowChangedListenerAgent_ == nullptr) {
|
||||
pImpl_->cameraFloatWindowChangedListenerAgent_ = new WindowManagerAgent();
|
||||
ret = SingletonContainer::Get<WindowAdapter>().RegisterWindowManagerAgent(
|
||||
WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT,
|
||||
pImpl_->cameraFloatWindowChangedListenerAgent_);
|
||||
}
|
||||
if (!ret) {
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFW("RegisterWindowManagerAgent failed !");
|
||||
pImpl_->cameraFloatWindowChangedListenerAgent_ = nullptr;
|
||||
} else {
|
||||
@ -488,18 +488,19 @@ bool WindowManager::RegisterCameraFloatWindowChangedListener(const sptr<ICameraF
|
||||
pImpl_->cameraFloatWindowChangedListeners_.end(), listener);
|
||||
if (iter != pImpl_->cameraFloatWindowChangedListeners_.end()) {
|
||||
WLOGFW("Listener is already registered.");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
pImpl_->cameraFloatWindowChangedListeners_.push_back(listener);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WindowManager::UnregisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener)
|
||||
WMError WindowManager::UnregisterCameraFloatWindowChangedListener(
|
||||
const sptr<ICameraFloatWindowChangedListener>& listener)
|
||||
{
|
||||
if (listener == nullptr) {
|
||||
WLOGFE("listener could not be null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
@ -507,10 +508,10 @@ bool WindowManager::UnregisterCameraFloatWindowChangedListener(const sptr<ICamer
|
||||
pImpl_->cameraFloatWindowChangedListeners_.end(), listener);
|
||||
if (iter == pImpl_->cameraFloatWindowChangedListeners_.end()) {
|
||||
WLOGFE("could not find this listener");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
pImpl_->cameraFloatWindowChangedListeners_.erase(iter);
|
||||
bool ret = true;
|
||||
WMError ret = WMError::WM_OK;
|
||||
if (pImpl_->cameraFloatWindowChangedListeners_.empty() &&
|
||||
pImpl_->cameraFloatWindowChangedListenerAgent_ != nullptr) {
|
||||
ret = SingletonContainer::Get<WindowAdapter>().UnregisterWindowManagerAgent(
|
||||
|
@ -2017,7 +2017,7 @@ HWTEST_F(WindowImplTest, SetWindowMode, Function | SmallTest | Level3)
|
||||
ASSERT_EQ(WMError::WM_DO_NOTHING, window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN));
|
||||
window->SetWindowState(WindowState::STATE_FROZEN);
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY));
|
||||
|
||||
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
@ -3166,7 +3166,7 @@ HWTEST_F(WindowImplTest, UpdateWindowStateWhenHide, Function | SmallTest | Level
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow->Create(INVALID_WINDOW_ID));
|
||||
ASSERT_EQ(WmErrorCode::WM_OK, mainWindow->UpdateWindowStateWhenHide());
|
||||
|
||||
|
||||
option = new WindowOption();
|
||||
option->SetWindowName("sub");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
|
||||
@ -3240,7 +3240,7 @@ HWTEST_F(WindowImplTest, RaiseToAppTop, Function | SmallTest | Level3)
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @tc.name: UpdateDecorEnable
|
||||
* @tc.desc: UpdateDecorEnable test
|
||||
|
@ -139,19 +139,19 @@ HWTEST_F(WindowManagerTest, RegisterCameraFloatWindowChangedListener01, Function
|
||||
auto oldListeners = windowManager.pImpl_->cameraFloatWindowChangedListeners_;
|
||||
windowManager.pImpl_->cameraFloatWindowChangedListenerAgent_ = nullptr;
|
||||
windowManager.pImpl_->cameraFloatWindowChangedListeners_.clear();
|
||||
ASSERT_EQ(false, windowManager.RegisterCameraFloatWindowChangedListener(nullptr));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.RegisterCameraFloatWindowChangedListener(nullptr));
|
||||
|
||||
sptr<TestCameraFloatWindowChangedListener> listener = new TestCameraFloatWindowChangedListener();
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(false));
|
||||
ASSERT_EQ(false, windowManager.RegisterCameraFloatWindowChangedListener(listener));
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_NULLPTR));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.RegisterCameraFloatWindowChangedListener(listener));
|
||||
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
ASSERT_EQ(true, windowManager.RegisterCameraFloatWindowChangedListener(listener));
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.RegisterCameraFloatWindowChangedListener(listener));
|
||||
ASSERT_EQ(1, windowManager.pImpl_->cameraFloatWindowChangedListeners_.size());
|
||||
|
||||
// to check that the same listner can not be registered twice
|
||||
ASSERT_EQ(true, windowManager.RegisterCameraFloatWindowChangedListener(listener));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.RegisterCameraFloatWindowChangedListener(listener));
|
||||
ASSERT_EQ(1, windowManager.pImpl_->cameraFloatWindowChangedListeners_.size());
|
||||
|
||||
windowManager.pImpl_->cameraFloatWindowChangedListenerAgent_ = oldWindowManagerAgent;
|
||||
@ -171,24 +171,24 @@ HWTEST_F(WindowManagerTest, UnregisterCameraFloatWindowChangedListener01, Functi
|
||||
windowManager.pImpl_->cameraFloatWindowChangedListeners_.clear();
|
||||
|
||||
// check nullpter
|
||||
ASSERT_EQ(false, windowManager.UnregisterCameraFloatWindowChangedListener(nullptr));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.UnregisterCameraFloatWindowChangedListener(nullptr));
|
||||
|
||||
sptr<TestCameraFloatWindowChangedListener> listener1 = new TestCameraFloatWindowChangedListener();
|
||||
sptr<TestCameraFloatWindowChangedListener> listener2 = new TestCameraFloatWindowChangedListener();
|
||||
ASSERT_EQ(true, windowManager.UnregisterCameraFloatWindowChangedListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterCameraFloatWindowChangedListener(listener1));
|
||||
|
||||
windowManager.RegisterCameraFloatWindowChangedListener(listener1);
|
||||
windowManager.RegisterCameraFloatWindowChangedListener(listener2);
|
||||
ASSERT_EQ(2, windowManager.pImpl_->cameraFloatWindowChangedListeners_.size());
|
||||
|
||||
ASSERT_EQ(true, windowManager.UnregisterCameraFloatWindowChangedListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterCameraFloatWindowChangedListener(listener1));
|
||||
|
||||
ASSERT_EQ(false, windowManager.UnregisterCameraFloatWindowChangedListener(listener2));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.UnregisterCameraFloatWindowChangedListener(listener2));
|
||||
ASSERT_EQ(0, windowManager.pImpl_->cameraFloatWindowChangedListeners_.size());
|
||||
ASSERT_EQ(nullptr, windowManager.pImpl_->cameraFloatWindowChangedListenerAgent_);
|
||||
|
||||
windowManager.pImpl_->cameraFloatWindowChangedListeners_.emplace_back(listener1);
|
||||
ASSERT_EQ(true, windowManager.UnregisterCameraFloatWindowChangedListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterCameraFloatWindowChangedListener(listener1));
|
||||
ASSERT_EQ(0, windowManager.pImpl_->cameraFloatWindowChangedListeners_.size());
|
||||
|
||||
windowManager.pImpl_->cameraFloatWindowChangedListenerAgent_ = oldWindowManagerAgent;
|
||||
@ -207,20 +207,20 @@ HWTEST_F(WindowManagerTest, RegisterVisibilityChangedListener01, Function | Smal
|
||||
auto oldListeners = windowManager.pImpl_->windowVisibilityListeners_;
|
||||
windowManager.pImpl_->windowVisibilityListenerAgent_ = nullptr;
|
||||
windowManager.pImpl_->windowVisibilityListeners_.clear();
|
||||
ASSERT_EQ(false, windowManager.RegisterVisibilityChangedListener(nullptr));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.RegisterVisibilityChangedListener(nullptr));
|
||||
|
||||
sptr<TestVisibilityChangedListener> listener = new TestVisibilityChangedListener();
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(false));
|
||||
ASSERT_EQ(false, windowManager.RegisterVisibilityChangedListener(listener));
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_NULLPTR));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.RegisterVisibilityChangedListener(listener));
|
||||
ASSERT_EQ(nullptr, windowManager.pImpl_->windowVisibilityListenerAgent_);
|
||||
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
ASSERT_EQ(true, windowManager.RegisterVisibilityChangedListener(listener));
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.RegisterVisibilityChangedListener(listener));
|
||||
ASSERT_EQ(1, windowManager.pImpl_->windowVisibilityListeners_.size());
|
||||
|
||||
// to check that the same listner can not be registered twice
|
||||
ASSERT_EQ(true, windowManager.RegisterVisibilityChangedListener(listener));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.RegisterVisibilityChangedListener(listener));
|
||||
ASSERT_EQ(1, windowManager.pImpl_->windowVisibilityListeners_.size());
|
||||
|
||||
windowManager.pImpl_->windowVisibilityListenerAgent_ = oldWindowManagerAgent;
|
||||
@ -240,7 +240,7 @@ HWTEST_F(WindowManagerTest, UnregisterVisibilityChangedListener01, Function | Sm
|
||||
windowManager.pImpl_->windowVisibilityListeners_.clear();
|
||||
|
||||
// check nullpter
|
||||
ASSERT_EQ(false, windowManager.UnregisterVisibilityChangedListener(nullptr));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.UnregisterVisibilityChangedListener(nullptr));
|
||||
|
||||
sptr<TestVisibilityChangedListener> listener1 = new TestVisibilityChangedListener();
|
||||
sptr<TestVisibilityChangedListener> listener2 = new TestVisibilityChangedListener();
|
||||
@ -249,13 +249,13 @@ HWTEST_F(WindowManagerTest, UnregisterVisibilityChangedListener01, Function | Sm
|
||||
windowManager.RegisterVisibilityChangedListener(listener2);
|
||||
ASSERT_EQ(2, windowManager.pImpl_->windowVisibilityListeners_.size());
|
||||
|
||||
ASSERT_EQ(true, windowManager.UnregisterVisibilityChangedListener(listener1));
|
||||
ASSERT_EQ(false, windowManager.UnregisterVisibilityChangedListener(listener2));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterVisibilityChangedListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.UnregisterVisibilityChangedListener(listener2));
|
||||
ASSERT_EQ(0, windowManager.pImpl_->windowVisibilityListeners_.size());
|
||||
ASSERT_EQ(nullptr, windowManager.pImpl_->windowVisibilityListenerAgent_);
|
||||
|
||||
windowManager.pImpl_->windowVisibilityListeners_.emplace_back(listener1);
|
||||
ASSERT_EQ(true, windowManager.UnregisterVisibilityChangedListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterVisibilityChangedListener(listener1));
|
||||
ASSERT_EQ(0, windowManager.pImpl_->windowVisibilityListeners_.size());
|
||||
|
||||
windowManager.pImpl_->windowVisibilityListenerAgent_ = oldWindowManagerAgent;
|
||||
@ -274,20 +274,20 @@ HWTEST_F(WindowManagerTest, RegisterWindowUpdateListener01, Function | SmallTest
|
||||
auto oldListeners = windowManager.pImpl_->windowUpdateListeners_;
|
||||
windowManager.pImpl_->windowUpdateListenerAgent_ = nullptr;
|
||||
windowManager.pImpl_->windowUpdateListeners_.clear();
|
||||
ASSERT_EQ(false, windowManager.RegisterWindowUpdateListener(nullptr));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.RegisterWindowUpdateListener(nullptr));
|
||||
|
||||
sptr<TestWindowUpdateListener> listener = new TestWindowUpdateListener();
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(false));
|
||||
ASSERT_EQ(false, windowManager.RegisterWindowUpdateListener(listener));
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_NULLPTR));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.RegisterWindowUpdateListener(listener));
|
||||
ASSERT_EQ(nullptr, windowManager.pImpl_->windowUpdateListenerAgent_);
|
||||
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
ASSERT_EQ(true, windowManager.RegisterWindowUpdateListener(listener));
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.RegisterWindowUpdateListener(listener));
|
||||
ASSERT_EQ(1, windowManager.pImpl_->windowUpdateListeners_.size());
|
||||
|
||||
// to check that the same listner can not be registered twice
|
||||
ASSERT_EQ(true, windowManager.RegisterWindowUpdateListener(listener));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.RegisterWindowUpdateListener(listener));
|
||||
ASSERT_EQ(1, windowManager.pImpl_->windowUpdateListeners_.size());
|
||||
|
||||
windowManager.pImpl_->windowUpdateListenerAgent_ = oldWindowManagerAgent;
|
||||
@ -307,24 +307,24 @@ HWTEST_F(WindowManagerTest, UnregisterWindowUpdateListener01, Function | SmallTe
|
||||
windowManager.pImpl_->windowUpdateListeners_.clear();
|
||||
|
||||
// check nullpter
|
||||
ASSERT_EQ(false, windowManager.UnregisterWindowUpdateListener(nullptr));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.UnregisterWindowUpdateListener(nullptr));
|
||||
|
||||
sptr<TestWindowUpdateListener> listener1 = new TestWindowUpdateListener();
|
||||
sptr<TestWindowUpdateListener> listener2 = new TestWindowUpdateListener();
|
||||
ASSERT_EQ(true, windowManager.UnregisterWindowUpdateListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterWindowUpdateListener(listener1));
|
||||
|
||||
windowManager.RegisterWindowUpdateListener(listener1);
|
||||
windowManager.RegisterWindowUpdateListener(listener2);
|
||||
ASSERT_EQ(2, windowManager.pImpl_->windowUpdateListeners_.size());
|
||||
|
||||
ASSERT_EQ(true, windowManager.UnregisterWindowUpdateListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterWindowUpdateListener(listener1));
|
||||
|
||||
ASSERT_EQ(false, windowManager.UnregisterWindowUpdateListener(listener2));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.UnregisterWindowUpdateListener(listener2));
|
||||
ASSERT_EQ(0, windowManager.pImpl_->windowUpdateListeners_.size());
|
||||
ASSERT_EQ(nullptr, windowManager.pImpl_->windowUpdateListenerAgent_);
|
||||
|
||||
windowManager.pImpl_->windowUpdateListeners_.emplace_back(listener1);
|
||||
ASSERT_EQ(true, windowManager.UnregisterWindowUpdateListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterWindowUpdateListener(listener1));
|
||||
ASSERT_EQ(0, windowManager.pImpl_->windowUpdateListeners_.size());
|
||||
|
||||
windowManager.pImpl_->windowUpdateListenerAgent_ = oldWindowManagerAgent;
|
||||
@ -343,20 +343,20 @@ HWTEST_F(WindowManagerTest, RegisterSystemBarChangedListener01, Function | Small
|
||||
auto oldListeners = windowManager.pImpl_->systemBarChangedListeners_;
|
||||
windowManager.pImpl_->systemBarChangedListenerAgent_ = nullptr;
|
||||
windowManager.pImpl_->systemBarChangedListeners_.clear();
|
||||
ASSERT_EQ(false, windowManager.RegisterSystemBarChangedListener(nullptr));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.RegisterSystemBarChangedListener(nullptr));
|
||||
|
||||
sptr<ISystemBarChangedListener> listener = new TestSystemBarChangedListener();
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(false));
|
||||
ASSERT_EQ(false, windowManager.RegisterSystemBarChangedListener(listener));
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_NULLPTR));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.RegisterSystemBarChangedListener(listener));
|
||||
ASSERT_EQ(nullptr, windowManager.pImpl_->systemBarChangedListenerAgent_);
|
||||
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(true));
|
||||
ASSERT_EQ(true, windowManager.RegisterSystemBarChangedListener(listener));
|
||||
EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.RegisterSystemBarChangedListener(listener));
|
||||
ASSERT_EQ(1, windowManager.pImpl_->systemBarChangedListeners_.size());
|
||||
|
||||
// to check that the same listner can not be registered twice
|
||||
ASSERT_EQ(true, windowManager.RegisterSystemBarChangedListener(listener));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.RegisterSystemBarChangedListener(listener));
|
||||
ASSERT_EQ(1, windowManager.pImpl_->systemBarChangedListeners_.size());
|
||||
|
||||
windowManager.pImpl_->systemBarChangedListenerAgent_ = oldWindowManagerAgent;
|
||||
@ -375,24 +375,24 @@ HWTEST_F(WindowManagerTest, UnregisterSystemBarChangedListener01, Function | Sma
|
||||
windowManager.pImpl_->systemBarChangedListenerAgent_ = new WindowManagerAgent();
|
||||
windowManager.pImpl_->systemBarChangedListeners_.clear();
|
||||
// check nullpter
|
||||
ASSERT_EQ(false, windowManager.UnregisterSystemBarChangedListener(nullptr));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.UnregisterSystemBarChangedListener(nullptr));
|
||||
|
||||
sptr<TestSystemBarChangedListener> listener1 = new TestSystemBarChangedListener();
|
||||
sptr<TestSystemBarChangedListener> listener2 = new TestSystemBarChangedListener();
|
||||
ASSERT_EQ(true, windowManager.UnregisterSystemBarChangedListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterSystemBarChangedListener(listener1));
|
||||
|
||||
windowManager.RegisterSystemBarChangedListener(listener1);
|
||||
windowManager.RegisterSystemBarChangedListener(listener2);
|
||||
ASSERT_EQ(2, windowManager.pImpl_->systemBarChangedListeners_.size());
|
||||
|
||||
|
||||
ASSERT_EQ(true, windowManager.UnregisterSystemBarChangedListener(listener1));
|
||||
ASSERT_EQ(false, windowManager.UnregisterSystemBarChangedListener(listener2));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterSystemBarChangedListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.UnregisterSystemBarChangedListener(listener2));
|
||||
ASSERT_EQ(0, windowManager.pImpl_->systemBarChangedListeners_.size());
|
||||
ASSERT_EQ(nullptr, windowManager.pImpl_->systemBarChangedListenerAgent_);
|
||||
|
||||
windowManager.pImpl_->systemBarChangedListeners_.push_back(listener1);
|
||||
ASSERT_EQ(true, windowManager.UnregisterSystemBarChangedListener(listener1));
|
||||
ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterSystemBarChangedListener(listener1));
|
||||
ASSERT_EQ(0, windowManager.pImpl_->systemBarChangedListeners_.size());
|
||||
|
||||
windowManager.pImpl_->systemBarChangedListenerAgent_ = oldWindowManagerAgent;
|
||||
|
@ -26,9 +26,9 @@ namespace Rosen {
|
||||
class WindowManagerAgentController {
|
||||
WM_DECLARE_SINGLE_INSTANCE_BASE(WindowManagerAgentController)
|
||||
public:
|
||||
bool RegisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
|
||||
WMError RegisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
|
||||
WindowManagerAgentType type);
|
||||
bool UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
|
||||
WMError UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
|
||||
WindowManagerAgentType type);
|
||||
|
||||
void UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused);
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
void ProcessPointDown(uint32_t windowId, bool isPointDown) override;
|
||||
void ProcessPointUp(uint32_t windowId) override;
|
||||
WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override;
|
||||
void MinimizeAllAppWindows(DisplayId displayId) override;
|
||||
WMError MinimizeAllAppWindows(DisplayId displayId) override;
|
||||
WMError ToggleShownStateForAllAppWindows() override;
|
||||
WMError SetWindowLayoutMode(WindowLayoutMode mode) override;
|
||||
WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action,
|
||||
@ -107,9 +107,9 @@ public:
|
||||
WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override;
|
||||
WmErrorCode RaiseToAppTop(uint32_t windowId) override;
|
||||
|
||||
bool RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
|
||||
bool UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
|
||||
|
||||
WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller) override;
|
||||
@ -145,8 +145,8 @@ private:
|
||||
void NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type);
|
||||
WMError GetFocusWindowInfo(sptr<IRemoteObject>& abilityToken);
|
||||
bool CheckSystemWindowPermission(const sptr<WindowProperty>& property) const;
|
||||
bool CheckAnimationPermission(const sptr<WindowProperty>& property) const;
|
||||
WMError CheckSystemWindowPermission(const sptr<WindowProperty>& property) const;
|
||||
WMError CheckAnimationPermission(const sptr<WindowProperty>& property) const;
|
||||
void ConfigureWindowManagerService();
|
||||
void PostVoidSyncTask(Task task);
|
||||
template<typename SyncTask, typename Return = std::invoke_result_t<SyncTask>>
|
||||
|
@ -82,14 +82,14 @@ public:
|
||||
sptr<MoveDragProperty>& moveDragProperty) = 0;
|
||||
virtual void ProcessPointDown(uint32_t windowId, bool isPointDown) = 0;
|
||||
virtual void ProcessPointUp(uint32_t windowId) = 0;
|
||||
virtual void MinimizeAllAppWindows(DisplayId displayId) = 0;
|
||||
virtual WMError MinimizeAllAppWindows(DisplayId displayId) = 0;
|
||||
virtual WMError ToggleShownStateForAllAppWindows() = 0;
|
||||
virtual WMError SetWindowLayoutMode(WindowLayoutMode mode) = 0;
|
||||
virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action,
|
||||
bool isAsyncTask = false) = 0;
|
||||
virtual bool RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
virtual WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent) = 0;
|
||||
virtual bool UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
virtual WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent) = 0;
|
||||
virtual WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) = 0;
|
||||
virtual WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) = 0;
|
||||
|
@ -42,14 +42,14 @@ public:
|
||||
sptr<MoveDragProperty>& moveDragProperty) override;
|
||||
void ProcessPointDown(uint32_t windowId, bool isPointDown) override;
|
||||
void ProcessPointUp(uint32_t windowId) override;
|
||||
void MinimizeAllAppWindows(DisplayId displayId) override;
|
||||
WMError MinimizeAllAppWindows(DisplayId displayId) override;
|
||||
WMError ToggleShownStateForAllAppWindows() override;
|
||||
WMError SetWindowLayoutMode(WindowLayoutMode mode) override;
|
||||
WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action,
|
||||
bool isAsyncTask = false) override;
|
||||
bool RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
|
||||
bool UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
|
||||
WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller) override;
|
||||
|
||||
|
@ -24,16 +24,16 @@ namespace {
|
||||
}
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(WindowManagerAgentController)
|
||||
|
||||
bool WindowManagerAgentController::RegisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
|
||||
WMError WindowManagerAgentController::RegisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
|
||||
WindowManagerAgentType type)
|
||||
{
|
||||
return wmAgentContainer_.RegisterAgent(windowManagerAgent, type);
|
||||
return wmAgentContainer_.RegisterAgent(windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
bool WindowManagerAgentController::UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
|
||||
WMError WindowManagerAgentController::UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
|
||||
WindowManagerAgentType type)
|
||||
{
|
||||
return wmAgentContainer_.UnregisterAgent(windowManagerAgent, type);
|
||||
return wmAgentContainer_.UnregisterAgent(windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
void WindowManagerAgentController::UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused)
|
||||
|
@ -675,40 +675,40 @@ void WindowManagerService::CancelStartingWindow(sptr<IRemoteObject> abilityToken
|
||||
});
|
||||
}
|
||||
|
||||
bool WindowManagerService::CheckAnimationPermission(const sptr<WindowProperty>& property) const
|
||||
WMError WindowManagerService::CheckAnimationPermission(const sptr<WindowProperty>& property) const
|
||||
{
|
||||
if (property->GetAnimationFlag() == static_cast<uint32_t>(WindowAnimation::CUSTOM)
|
||||
&& !Permission::IsSystemCalling()) {
|
||||
&& !Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFD("check animation permission failed");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowManagerService::CheckSystemWindowPermission(const sptr<WindowProperty>& property) const
|
||||
WMError WindowManagerService::CheckSystemWindowPermission(const sptr<WindowProperty>& property) const
|
||||
{
|
||||
WindowType type = property->GetWindowType();
|
||||
if (!WindowHelper::IsSystemWindow(type)) {
|
||||
// type is not system
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
if (type == WindowType::WINDOW_TYPE_DRAGGING_EFFECT || type == WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW ||
|
||||
type == WindowType::WINDOW_TYPE_TOAST) {
|
||||
// some system types counld be created by normal app
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
if (type == WindowType::WINDOW_TYPE_FLOAT &&
|
||||
Permission::CheckCallingPermission("ohos.permission.SYSTEM_FLOAT_WINDOW")) {
|
||||
// WINDOW_TYPE_FLOAT counld be created by normal app with the corresponding permission
|
||||
WLOGFD("check create permission success, normal app create float window with request permission.");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
if (Permission::IsSystemCalling()) {
|
||||
if (Permission::IsSystemCalling() || Permission::IsStartByHdcd()) {
|
||||
WLOGFD("check create permission success, create with system calling.");
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
WLOGFD("check system window permission failed.");
|
||||
return false;
|
||||
WLOGFE("check system window permission failed.");
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
WMError WindowManagerService::CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& property,
|
||||
@ -718,9 +718,9 @@ WMError WindowManagerService::CreateWindow(sptr<IWindow>& window, sptr<WindowPro
|
||||
WLOGFE("window is invalid");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
if (!CheckSystemWindowPermission(property)) {
|
||||
if (CheckSystemWindowPermission(property) != WMError::WM_OK) {
|
||||
WLOGFE("create system window permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
int pid = IPCSkeleton::GetCallingPid();
|
||||
int uid = IPCSkeleton::GetCallingUid();
|
||||
@ -738,7 +738,8 @@ WMError WindowManagerService::AddWindow(sptr<WindowProperty>& property)
|
||||
WLOGFE("property is nullptr");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
if (!CheckSystemWindowPermission(property) || !CheckAnimationPermission(property)) {
|
||||
if (CheckSystemWindowPermission(property) != WMError::WM_OK ||
|
||||
CheckAnimationPermission(property) != WMError::WM_OK) {
|
||||
WLOGFE("add window permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
}
|
||||
@ -763,6 +764,10 @@ WMError WindowManagerService::AddWindow(sptr<WindowProperty>& property)
|
||||
|
||||
WMError WindowManagerService::RemoveWindow(uint32_t windowId)
|
||||
{
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("remove window permission denied!");
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
return PostSyncTask([this, windowId]() {
|
||||
WLOGI("[WMS] Remove: %{public}u", windowId);
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "wms:RemoveWindow(%u)", windowId);
|
||||
@ -830,19 +835,19 @@ AvoidArea WindowManagerService::GetAvoidAreaByType(uint32_t windowId, AvoidAreaT
|
||||
});
|
||||
}
|
||||
|
||||
bool WindowManagerService::RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError WindowManagerService::RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("register windowManager agent permission denied!");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if ((windowManagerAgent == nullptr) || (windowManagerAgent->AsObject() == nullptr)) {
|
||||
WLOGFE("windowManagerAgent is null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
return PostSyncTask([this, &windowManagerAgent, type]() {
|
||||
bool ret = WindowManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type);
|
||||
WMError ret = WindowManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type);
|
||||
if (type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR) { // if system bar, notify once
|
||||
windowController_->NotifySystemBarTints();
|
||||
}
|
||||
@ -850,16 +855,16 @@ bool WindowManagerService::RegisterWindowManagerAgent(WindowManagerAgentType typ
|
||||
});
|
||||
}
|
||||
|
||||
bool WindowManagerService::UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError WindowManagerService::UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("unregister windowManager agent permission denied!");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if ((windowManagerAgent == nullptr) || (windowManagerAgent->AsObject() == nullptr)) {
|
||||
WLOGFE("windowManagerAgent is null");
|
||||
return false;
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
return PostSyncTask([this, &windowManagerAgent, type]() {
|
||||
return WindowManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowManagerAgent, type);
|
||||
@ -868,9 +873,9 @@ bool WindowManagerService::UnregisterWindowManagerAgent(WindowManagerAgentType t
|
||||
|
||||
WMError WindowManagerService::SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set window animation controller permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (controller == nullptr) {
|
||||
WLOGFE("RSWindowAnimation: Failed to set window animation controller, controller is null!");
|
||||
@ -1012,24 +1017,25 @@ void WindowManagerService::NotifyWindowClientPointUp(uint32_t windowId,
|
||||
});
|
||||
}
|
||||
|
||||
void WindowManagerService::MinimizeAllAppWindows(DisplayId displayId)
|
||||
WMError WindowManagerService::MinimizeAllAppWindows(DisplayId displayId)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("minimize all appWindows permission denied!");
|
||||
return;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
PostAsyncTask([this, displayId]() {
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "wms:MinimizeAllAppWindows(%" PRIu64")", displayId);
|
||||
WLOGI("displayId %{public}" PRIu64"", displayId);
|
||||
windowController_->MinimizeAllAppWindows(displayId);
|
||||
});
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError WindowManagerService::ToggleShownStateForAllAppWindows()
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("toggle shown state for all appwindows permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
PostAsyncTask([this]() {
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "wms:ToggleShownStateForAllAppWindows");
|
||||
@ -1047,9 +1053,9 @@ WMError WindowManagerService::GetTopWindowId(uint32_t mainWinId, uint32_t& topWi
|
||||
|
||||
WMError WindowManagerService::SetWindowLayoutMode(WindowLayoutMode mode)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set window layout mode permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
return PostSyncTask([this, mode]() {
|
||||
WLOGI("layoutMode: %{public}u", mode);
|
||||
@ -1067,11 +1073,10 @@ WMError WindowManagerService::UpdateProperty(sptr<WindowProperty>& windowPropert
|
||||
}
|
||||
if ((windowProperty->GetWindowFlags() == static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE) ||
|
||||
action == PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY) &&
|
||||
!Permission::IsSystemCalling()) {
|
||||
!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("SetForbidSplitMove or SetShowWhenLocked or SetTranform or SetTurnScreenOn permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
}
|
||||
|
||||
if (action == PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY) {
|
||||
return PostSyncTask([this, windowProperty, action]() mutable {
|
||||
windowController_->UpdateProperty(windowProperty, action);
|
||||
@ -1106,7 +1111,7 @@ WMError WindowManagerService::GetAccessibilityWindowInfo(std::vector<sptr<Access
|
||||
{
|
||||
if (!Permission::IsSystemServiceCalling()) {
|
||||
WLOGFE("get accessibility window info permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
return PostSyncTask([this, &infos]() {
|
||||
return windowController_->GetAccessibilityWindowInfo(infos);
|
||||
@ -1122,9 +1127,9 @@ WMError WindowManagerService::GetVisibilityWindowInfo(std::vector<sptr<WindowVis
|
||||
|
||||
WmErrorCode WindowManagerService::RaiseToAppTop(uint32_t windowId)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("window raise to app top permission denied!");
|
||||
return WmErrorCode::WM_ERROR_NO_PERMISSION;
|
||||
return WmErrorCode::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
return PostSyncTask([this, windowId]() {
|
||||
return windowController_->RaiseToAppTop(windowId);
|
||||
@ -1149,7 +1154,7 @@ WMError WindowManagerService::GetModeChangeHotZones(DisplayId displayId, ModeCha
|
||||
void WindowManagerService::MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
|
||||
sptr<RSIWindowAnimationFinishedCallback>& finishCallback)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("minimize windows by launcher permission denied!");
|
||||
return;
|
||||
}
|
||||
@ -1213,9 +1218,9 @@ void WindowManagerService::OnScreenshot(DisplayId displayId)
|
||||
|
||||
WMError WindowManagerService::BindDialogTarget(uint32_t& windowId, sptr<IRemoteObject> targetToken)
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("bind dialog target permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
return WMError::WM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
return PostSyncTask([this, &windowId, targetToken]() {
|
||||
return windowController_->BindDialogTarget(windowId, targetToken);
|
||||
|
@ -306,7 +306,7 @@ void WindowRoot::AddSurfaceNodeIdWindowNodePair(uint64_t surfaceNodeId, sptr<Win
|
||||
|
||||
void WindowRoot::GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) const
|
||||
{
|
||||
if (!Permission::IsSystemCalling()) {
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("Get Visible Window Permission Denied");
|
||||
}
|
||||
VisibleData& VisibleWindow = lastOcclusionData_->GetVisibleData();
|
||||
|
@ -196,7 +196,7 @@ AvoidArea WindowManagerProxy::GetAvoidAreaByType(uint32_t windowId, AvoidAreaTyp
|
||||
return *area;
|
||||
}
|
||||
|
||||
bool WindowManagerProxy::RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError WindowManagerProxy::RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -204,29 +204,29 @@ bool WindowManagerProxy::RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return false;
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (!data.WriteUint32(static_cast<uint32_t>(type))) {
|
||||
WLOGFE("Write type failed");
|
||||
return false;
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) {
|
||||
WLOGFE("Write IWindowManagerAgent failed");
|
||||
return false;
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return false;
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
return reply.ReadBool();
|
||||
return static_cast<WMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
bool WindowManagerProxy::UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError WindowManagerProxy::UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -234,26 +234,26 @@ bool WindowManagerProxy::UnregisterWindowManagerAgent(WindowManagerAgentType typ
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return false;
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (!data.WriteUint32(static_cast<uint32_t>(type))) {
|
||||
WLOGFE("Write type failed");
|
||||
return false;
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) {
|
||||
WLOGFE("Write IWindowManagerAgent failed");
|
||||
return false;
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return false;
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
return reply.ReadBool();
|
||||
return static_cast<WMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
WMError WindowManagerProxy::SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller)
|
||||
@ -358,23 +358,32 @@ void WindowManagerProxy::ProcessPointUp(uint32_t windowId)
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManagerProxy::MinimizeAllAppWindows(DisplayId displayId)
|
||||
WMError WindowManagerProxy::MinimizeAllAppWindows(DisplayId displayId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return;
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!data.WriteUint64(displayId)) {
|
||||
WLOGFE("Write displayId failed");
|
||||
return;
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_MINIMIZE_ALL_APP_WINDOWS),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
int32_t ret;
|
||||
if (!reply.ReadInt32(ret)) {
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
WLOGFE("MinimizeAllAppWindows: %{public}u", ret);
|
||||
return static_cast<WMError>(ret);
|
||||
}
|
||||
|
||||
WMError WindowManagerProxy::ToggleShownStateForAllAppWindows()
|
||||
|
@ -89,8 +89,8 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
|
||||
sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
|
||||
sptr<IWindowManagerAgent> windowManagerAgentProxy =
|
||||
iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
|
||||
bool ret = RegisterWindowManagerAgent(type, windowManagerAgentProxy);
|
||||
reply.WriteBool(ret);
|
||||
WMError errCode = RegisterWindowManagerAgent(type, windowManagerAgentProxy);
|
||||
reply.WriteInt32(static_cast<int32_t>(errCode));
|
||||
break;
|
||||
}
|
||||
case WindowManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT: {
|
||||
@ -98,8 +98,8 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
|
||||
sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
|
||||
sptr<IWindowManagerAgent> windowManagerAgentProxy =
|
||||
iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
|
||||
bool ret = UnregisterWindowManagerAgent(type, windowManagerAgentProxy);
|
||||
reply.WriteBool(ret);
|
||||
WMError errCode = UnregisterWindowManagerAgent(type, windowManagerAgentProxy);
|
||||
reply.WriteInt32(static_cast<int32_t>(errCode));
|
||||
break;
|
||||
}
|
||||
case WindowManagerMessage::TRANS_ID_NOTIFY_READY_MOVE_OR_DRAG: {
|
||||
@ -129,7 +129,8 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
|
||||
break;
|
||||
}
|
||||
case WindowManagerMessage::TRANS_ID_MINIMIZE_ALL_APP_WINDOWS: {
|
||||
MinimizeAllAppWindows(data.ReadUint64());
|
||||
WMError errCode = MinimizeAllAppWindows(data.ReadUint64());
|
||||
reply.WriteInt32(static_cast<int32_t>(errCode));
|
||||
break;
|
||||
}
|
||||
case WindowManagerMessage::TRANS_ID_TOGGLE_SHOWN_STATE_FOR_ALL_APP_WINDOWS: {
|
||||
|
@ -75,7 +75,7 @@ HWTEST_F(AccessibilityConnectionTest, FillAccessibilityWindowInfo01, Function |
|
||||
ASSERT_EQ(2, infos.size());
|
||||
ASSERT_TRUE(infos[0]->isDecorEnable_);
|
||||
ASSERT_TRUE(infos[0]->focused_);
|
||||
ASSERT_FALSE(infos[1]->isDecorEnable_);
|
||||
ASSERT_TRUE(infos[1]->isDecorEnable_);
|
||||
ASSERT_FALSE(infos[1]->focused_);
|
||||
}
|
||||
|
||||
|
@ -190,8 +190,8 @@ HWTEST_F(WindowManagerServiceTest, RegisterWindowManagerAgent01, Function | Smal
|
||||
{
|
||||
sptr<IWindowManagerAgent> windowManagerAgent = nullptr;
|
||||
WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT;
|
||||
ASSERT_EQ(false, wms->RegisterWindowManagerAgent(type, windowManagerAgent));
|
||||
ASSERT_EQ(false, wms->UnregisterWindowManagerAgent(type, windowManagerAgent));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->RegisterWindowManagerAgent(type, windowManagerAgent));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->UnregisterWindowManagerAgent(type, windowManagerAgent));
|
||||
}
|
||||
/**
|
||||
* @tc.name: SetWindowAnimationController
|
||||
|
@ -57,7 +57,10 @@ void NotifyServerReadyToMoveOrDrag(uint32_t windowId, sptr<WindowProperty>& wind
|
||||
sptr<MoveDragProperty>& moveDragProperty){};
|
||||
void ProcessPointDown(uint32_t windowId, bool isPointDown){};
|
||||
void ProcessPointUp(uint32_t windowId){};
|
||||
void MinimizeAllAppWindows(DisplayId displayId){};
|
||||
WMError MinimizeAllAppWindows(DisplayId displayId)
|
||||
{
|
||||
return WMError::WM_OK;
|
||||
};
|
||||
WMError ToggleShownStateForAllAppWindows()
|
||||
{
|
||||
return WMError::WM_OK;
|
||||
@ -71,15 +74,15 @@ WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeActio
|
||||
{
|
||||
return WMError::WM_OK;
|
||||
};
|
||||
bool RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
};
|
||||
bool UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
|
||||
const sptr<IWindowManagerAgent>& windowManagerAgent)
|
||||
{
|
||||
return true;
|
||||
return WMError::WM_OK;
|
||||
};
|
||||
WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user