mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-27 09:00:55 +00:00
Merge branch 'master' of gitee.com:openharmony/window_window_manager into lmz_remote
Signed-off-by: MingZhu <limingzhu10@huawei.com>
This commit is contained in:
commit
2b11cb58eb
@ -49,7 +49,8 @@
|
||||
"display_manager",
|
||||
"config_policy",
|
||||
"ace_engine",
|
||||
"multimedia_image_framework"
|
||||
"multimedia_image_framework",
|
||||
"preferences"
|
||||
],
|
||||
"third_party": [
|
||||
"flutter",
|
||||
|
@ -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->GetProducer());
|
||||
}
|
||||
|
||||
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.
|
||||
@ -211,6 +211,7 @@ bool Screen::SetDensityDpi(uint32_t dpi) const
|
||||
|
||||
sptr<ScreenInfo> Screen::GetScreenInfo() const
|
||||
{
|
||||
UpdateScreenInfo();
|
||||
return pImpl_->GetScreenInfo();
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
sptr<DisplayInfo> ConvertToDisplayInfo() const;
|
||||
Rotation GetRotation() const;
|
||||
Orientation GetOrientation() const;
|
||||
DisplayOrientation GetDisplayOrientation() const;
|
||||
FreezeFlag GetFreezeFlag() const;
|
||||
|
||||
void SetId(DisplayId displayId);
|
||||
@ -64,6 +65,7 @@ public:
|
||||
void SetRefreshRate(uint32_t refreshRate);
|
||||
void SetVirtualPixelRatio(float virtualPixelRatio);
|
||||
void SetOrientation(Orientation orientation);
|
||||
void SetDisplayOrientation(DisplayOrientation displayOrientation);
|
||||
bool RequestRotation(Rotation rotation);
|
||||
void SetFreezeFlag(FreezeFlag);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, WaterfallDisplayCompressionStatus, waterfallDisplayCompressionStatus, false);
|
||||
@ -80,6 +82,7 @@ private:
|
||||
float virtualPixelRatio_ { 1.0 };
|
||||
Rotation rotation_ { Rotation::ROTATION_0 };
|
||||
Orientation orientation_ { Orientation::UNSPECIFIED };
|
||||
DisplayOrientation displayOrientation_ { DisplayOrientation::UNKNOWN };
|
||||
FreezeFlag freezeFlag_ { FreezeFlag::UNFREEZING };
|
||||
DEFINE_VAR_DEFAULT_FUNC_SET(DisplayState, DisplayState, displayState, DisplayState::UNKNOWN);
|
||||
};
|
||||
|
@ -47,6 +47,8 @@ public:
|
||||
Rotation CalcRotation(Orientation orientation) const;
|
||||
bool SetVirtualPixelRatio(float virtualPixelRatio);
|
||||
float GetVirtualPixelRatio() const;
|
||||
bool SetSourceMode(ScreenSourceMode sourceMode);
|
||||
ScreenSourceMode GetSourceMode() const;
|
||||
|
||||
void UpdateRSTree(std::shared_ptr<RSSurfaceNode>& surfaceNode, bool isAdd);
|
||||
void UpdateDisplayGroupRSTree(std::shared_ptr<RSSurfaceNode>& surfaceNode, NodeId parentNodeId, bool isAdd);
|
||||
@ -98,6 +100,7 @@ public:
|
||||
Point GetChildPosition(ScreenId screenId) const;
|
||||
size_t GetChildCount() const;
|
||||
sptr<ScreenGroupInfo> ConvertToScreenGroupInfo() const;
|
||||
ScreenCombination GetScreenCombination() const;
|
||||
|
||||
ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE };
|
||||
ScreenId mirrorScreenId_ { SCREEN_ID_INVALID };
|
||||
|
@ -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<IBufferProducer> 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<IBufferProducer> 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<IBufferProducer> 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);
|
||||
|
||||
@ -57,6 +57,7 @@ public:
|
||||
static bool IsDisplayRotationVertical(Rotation rotation);
|
||||
static bool IsDisplayRotationHorizontal(Rotation rotation);
|
||||
static DeviceRotation ConvertSensorToDeviceRotation(SensorRotation sensorRotation);
|
||||
static DisplayOrientation ConvertRotationToDisplayOrientation(Rotation rotation);
|
||||
private:
|
||||
static void HandleGravitySensorEventCallback(SensorEvent *event);
|
||||
static Rotation GetCurrentDisplayRotation();
|
||||
@ -72,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);
|
||||
@ -89,6 +90,7 @@ private:
|
||||
static uint32_t defaultDeviceRotation_;
|
||||
static std::map<SensorRotation, DeviceRotation> sensorToDeviceRotationMap_;
|
||||
static std::map<DeviceRotation, Rotation> deviceToDisplayRotationMap_;
|
||||
static std::map<Rotation, DisplayOrientation> displayToDisplayOrientationMap_;
|
||||
static Orientation lastOrientationType_;
|
||||
static Rotation currentDisplayRotation_;
|
||||
static Rotation lastSensorDecidedRotation_;
|
||||
|
@ -39,6 +39,11 @@ AbstractDisplay::AbstractDisplay(DisplayId id, std::string name,
|
||||
orientation_(absScreen->orientation_)
|
||||
{
|
||||
RequestRotation(absScreen->rotation_);
|
||||
if (width_ > height_) {
|
||||
displayOrientation_ = DisplayOrientation::LANDSCAPE;
|
||||
} else {
|
||||
displayOrientation_ = DisplayOrientation::PORTRAIT;
|
||||
}
|
||||
auto numbersConfig = DisplayManagerConfig::GetIntNumbersConfig();
|
||||
if (numbersConfig.count("dpi") != 0) {
|
||||
uint32_t densityDpi = static_cast<uint32_t>(numbersConfig["dpi"][0]);
|
||||
@ -141,6 +146,11 @@ void AbstractDisplay::SetOrientation(Orientation orientation)
|
||||
orientation_ = orientation;
|
||||
}
|
||||
|
||||
void AbstractDisplay::SetDisplayOrientation(DisplayOrientation displayOrientation)
|
||||
{
|
||||
displayOrientation_ = displayOrientation;
|
||||
}
|
||||
|
||||
bool AbstractDisplay::RequestRotation(Rotation rotation)
|
||||
{
|
||||
WLOGD("request rotation from %{public}u to %{public}u, display %{public}" PRIu64"", rotation_, rotation, id_);
|
||||
@ -165,6 +175,11 @@ Orientation AbstractDisplay::GetOrientation() const
|
||||
return orientation_;
|
||||
}
|
||||
|
||||
DisplayOrientation AbstractDisplay::GetDisplayOrientation() const
|
||||
{
|
||||
return displayOrientation_;
|
||||
}
|
||||
|
||||
void AbstractDisplay::SetFreezeFlag(FreezeFlag freezeFlag)
|
||||
{
|
||||
freezeFlag_ = freezeFlag;
|
||||
@ -231,6 +246,7 @@ sptr<DisplayInfo> AbstractDisplay::ConvertToDisplayInfo() const
|
||||
displayInfo->SetDpi(virtualPixelRatio_ * DOT_PER_INCH);
|
||||
displayInfo->displayState_ = displayState_;
|
||||
displayInfo->SetWaterfallDisplayCompressionStatus(waterfallDisplayCompressionStatus_);
|
||||
displayInfo->SetDisplayOrientation(displayOrientation_);
|
||||
return displayInfo;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
@ -290,6 +290,8 @@ void AbstractDisplayController::ProcessDisplayRotationChange(sptr<AbstractScreen
|
||||
if (abstractDisplay->RequestRotation(absScreen->rotation_)) {
|
||||
// Notify rotation event to WMS
|
||||
SetDisplayStateChangeListener(abstractDisplay, DisplayStateChangeType::UPDATE_ROTATION);
|
||||
abstractDisplay->SetDisplayOrientation(
|
||||
ScreenRotationController::ConvertRotationToDisplayOrientation(absScreen->rotation_));
|
||||
}
|
||||
sptr<DisplayInfo> displayInfo = abstractDisplay->ConvertToDisplayInfo();
|
||||
DisplayManagerAgentController::GetInstance().OnDisplayChange(displayInfo,
|
||||
@ -422,7 +424,6 @@ void AbstractDisplayController::ProcessDisplayUpdateOrientation(sptr<AbstractScr
|
||||
if (abstractDisplay->RequestRotation(absScreen->rotation_)) {
|
||||
// Notify rotation event to WMS
|
||||
SetDisplayStateChangeListener(abstractDisplay, DisplayStateChangeType::UPDATE_ROTATION);
|
||||
ProcessDisplayCompression(absScreen);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ void AbstractScreen::UpdateRSTree(std::shared_ptr<RSSurfaceNode>& surfaceNode, b
|
||||
WLOGFE("node is nullptr");
|
||||
return;
|
||||
}
|
||||
WLOGFI("%{public}s surface: %{public}s, %{public}" PRIu64"", (isAdd ? "add" : "remove"),
|
||||
WLOGFD("%{public}s surface: %{public}s, %{public}" PRIu64"", (isAdd ? "add" : "remove"),
|
||||
surfaceNode->GetName().c_str(), surfaceNode->GetId());
|
||||
|
||||
if (isAdd) {
|
||||
@ -241,6 +241,7 @@ void AbstractScreen::FillScreenInfo(sptr<ScreenInfo> info) const
|
||||
if (fabsf(virtualPixelRatio) < 1e-6) {
|
||||
virtualPixelRatio = 1.0f;
|
||||
}
|
||||
ScreenSourceMode sourceMode = GetSourceMode();
|
||||
info->virtualPixelRatio_ = virtualPixelRatio;
|
||||
info->virtualHeight_ = height / virtualPixelRatio;
|
||||
info->virtualWidth_ = width / virtualPixelRatio;
|
||||
@ -249,6 +250,7 @@ void AbstractScreen::FillScreenInfo(sptr<ScreenInfo> info) const
|
||||
info->isScreenGroup_ = isScreenGroup_;
|
||||
info->rotation_ = rotation_;
|
||||
info->orientation_ = orientation_;
|
||||
info->sourceMode_ = sourceMode;
|
||||
info->type_ = type_;
|
||||
info->modeId_ = activeIdx_;
|
||||
info->modes_ = modes_;
|
||||
@ -271,6 +273,33 @@ float AbstractScreen::GetVirtualPixelRatio() const
|
||||
return virtualPixelRatio_;
|
||||
}
|
||||
|
||||
ScreenSourceMode AbstractScreen::GetSourceMode() const
|
||||
{
|
||||
sptr<AbstractScreenGroup> abstractScreenGroup = GetGroup();
|
||||
if (abstractScreenGroup == nullptr) {
|
||||
return ScreenSourceMode::SCREEN_ALONE;
|
||||
}
|
||||
ScreenId defaultId = screenController_->GetDefaultAbstractScreenId();
|
||||
if (dmsId_ == defaultId) {
|
||||
return ScreenSourceMode::SCREEN_MAIN;
|
||||
}
|
||||
ScreenCombination combination = abstractScreenGroup->GetScreenCombination();
|
||||
switch (combination) {
|
||||
case ScreenCombination::SCREEN_MIRROR: {
|
||||
return ScreenSourceMode::SCREEN_MIRROR;
|
||||
}
|
||||
case ScreenCombination::SCREEN_EXPAND: {
|
||||
return ScreenSourceMode::SCREEN_EXTEND;
|
||||
}
|
||||
case ScreenCombination::SCREEN_ALONE: {
|
||||
return ScreenSourceMode::SCREEN_ALONE;
|
||||
}
|
||||
default: {
|
||||
return ScreenSourceMode::SCREEN_ALONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rotation AbstractScreen::CalcRotation(Orientation orientation) const
|
||||
{
|
||||
sptr<SupportedScreenModes> info = GetActiveScreenMode();
|
||||
@ -467,4 +496,9 @@ size_t AbstractScreenGroup::GetChildCount() const
|
||||
{
|
||||
return abstractScreenMap_.size();
|
||||
}
|
||||
|
||||
ScreenCombination AbstractScreenGroup::GetScreenCombination() const
|
||||
{
|
||||
return combination_;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -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) {
|
||||
@ -648,8 +648,8 @@ bool AbstractScreenController::SetOrientation(ScreenId screenId, Orientation new
|
||||
screen->screenRequestedOrientation_ = newOrientation;
|
||||
}
|
||||
if (screen->orientation_ == newOrientation) {
|
||||
WLOGI("skip setting orientation. screen %{public}" PRIu64" orientation %{public}u", screenId, newOrientation);
|
||||
return true;
|
||||
WLOGFD("skip setting orientation. screen %{public}" PRIu64" orientation %{public}u", screenId, newOrientation);
|
||||
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(
|
||||
@ -706,8 +706,8 @@ void AbstractScreenController::SetScreenRotateAnimation(
|
||||
RSAnimationTimingCurve::CreateCubicCurve(0.2, 0.0, 0.2, 1.0); // animation curve: cubic [0.2, 0.0, 0.2, 1.0]
|
||||
#ifdef SOC_PERF_ENABLE
|
||||
// Increase frequency to improve windowRotation perf
|
||||
// 10012 means "web_gesture" level that setting duration: 800, lit_cpu_min_freq: 1421000, mid_cpu_min_feq: 1882000
|
||||
OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequest(10012, "");
|
||||
// 10027 means "web_gesture" level that setting duration: 800, lit_cpu_min_freq: 1421000, mid_cpu_min_feq: 1882000
|
||||
OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequest(10027, "");
|
||||
#endif
|
||||
RSNode::Animate(timingProtocol, curve, [weakNode, x, y, w, h, rotationAfter]() {
|
||||
auto displayNode = weakNode.lock();
|
||||
@ -721,7 +721,7 @@ void AbstractScreenController::SetScreenRotateAnimation(
|
||||
}, []() {
|
||||
#ifdef SOC_PERF_ENABLE
|
||||
// ClosePerf in finishCallBack
|
||||
OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(10012, false, "");
|
||||
OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(10027, false, "");
|
||||
#endif
|
||||
});
|
||||
}
|
||||
@ -746,6 +746,7 @@ bool AbstractScreenController::SetRotation(ScreenId screenId, Rotation rotationA
|
||||
screen->rotation_ = rotationAfter;
|
||||
} else {
|
||||
WLOGI("rotation not changed. screen %{public}" PRIu64" rotation %{public}u", screenId, rotationAfter);
|
||||
return false;
|
||||
}
|
||||
|
||||
NotifyScreenChanged(screen->ConvertToScreenInfo(), ScreenChangeEvent::UPDATE_ROTATION);
|
||||
@ -811,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;
|
||||
{
|
||||
@ -824,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_);
|
||||
@ -844,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)
|
||||
@ -873,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_);
|
||||
@ -888,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) {
|
||||
@ -904,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,
|
||||
@ -1250,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
|
||||
@ -1273,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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -105,7 +105,7 @@ void DisplayCutoutController::CheckBoundingRectsBoundary(DisplayId displayId, st
|
||||
static_cast<int32_t>(boundingRect.width_) + boundingRect.posX_ > static_cast<int32_t>(displayWidth) ||
|
||||
static_cast<int32_t>(boundingRect.height_) + boundingRect.posY_ > static_cast<int32_t>(displayHeight) ||
|
||||
boundingRect.width_ > displayWidth || boundingRect.height_ > displayHeight ||
|
||||
boundingRect.isUninitializedRect()) {
|
||||
boundingRect.IsUninitializedRect()) {
|
||||
WLOGFE("boundingRect boundary is invalid");
|
||||
iter = boundingRects.erase(iter);
|
||||
} else {
|
||||
@ -260,7 +260,7 @@ void DisplayCutoutController::TransferBoundingRectsByRotation(DisplayId displayI
|
||||
}
|
||||
uint32_t displayHeight = modes->height_;
|
||||
uint32_t displayWidth = modes->width_;
|
||||
|
||||
|
||||
switch (currentRotation) {
|
||||
case Rotation::ROTATION_90: {
|
||||
for (DMRect rect : displayBoundingRects) {
|
||||
|
@ -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<IBu
|
||||
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;
|
||||
@ -265,21 +265,21 @@ DMError DisplayManagerService::SetVirtualScreenSurface(ScreenId screenId, sptr<I
|
||||
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);
|
||||
@ -359,30 +359,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);
|
||||
}
|
||||
@ -486,7 +488,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;
|
||||
}
|
||||
@ -494,11 +496,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);
|
||||
@ -510,18 +513,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)
|
||||
@ -576,14 +581,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) {
|
||||
@ -592,20 +596,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();
|
||||
@ -624,7 +629,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;
|
||||
@ -639,53 +644,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);
|
||||
|
@ -32,7 +32,7 @@ namespace {
|
||||
int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
WLOGFI("OnRemoteRequest code is %{public}u", code);
|
||||
WLOGFD("OnRemoteRequest code is %{public}u", code);
|
||||
if (data.ReadInterfaceToken() != GetDescriptor()) {
|
||||
WLOGFE("InterfaceToken check failed");
|
||||
return -1;
|
||||
@ -105,7 +105,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: {
|
||||
@ -117,13 +118,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: {
|
||||
@ -187,8 +190,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: {
|
||||
@ -204,7 +209,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.");
|
||||
}
|
||||
@ -228,8 +235,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: {
|
||||
@ -244,15 +253,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: {
|
||||
@ -313,13 +322,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: {
|
||||
|
@ -36,12 +36,14 @@ Rotation ScreenRotationController::rotationLockedRotation_;
|
||||
uint32_t ScreenRotationController::defaultDeviceRotation_ = 0;
|
||||
std::map<SensorRotation, DeviceRotation> ScreenRotationController::sensorToDeviceRotationMap_;
|
||||
std::map<DeviceRotation, Rotation> ScreenRotationController::deviceToDisplayRotationMap_;
|
||||
std::map<Rotation, DisplayOrientation> ScreenRotationController::displayToDisplayOrientationMap_;
|
||||
DeviceRotation ScreenRotationController::lastSensorRotationConverted_ = DeviceRotation::INVALID;
|
||||
|
||||
void ScreenRotationController::Init()
|
||||
{
|
||||
ProcessRotationMapping();
|
||||
currentDisplayRotation_ = GetCurrentDisplayRotation();
|
||||
defaultDisplayId_ = DisplayManagerServiceInner::GetInstance().GetDefaultDisplayId();
|
||||
lastSensorDecidedRotation_ = currentDisplayRotation_;
|
||||
rotationLockedRotation_ = currentDisplayRotation_;
|
||||
}
|
||||
@ -51,12 +53,21 @@ bool ScreenRotationController::IsScreenRotationLocked()
|
||||
return isScreenRotationLocked_;
|
||||
}
|
||||
|
||||
void ScreenRotationController::SetScreenRotationLocked(bool isLocked)
|
||||
DMError ScreenRotationController::SetScreenRotationLocked(bool isLocked)
|
||||
{
|
||||
isScreenRotationLocked_ = isLocked;
|
||||
if (isLocked) {
|
||||
rotationLockedRotation_ = GetCurrentDisplayRotation();
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
isScreenRotationLocked_ = isLocked;
|
||||
if (GetCurrentDisplayRotation() == ConvertDeviceToDisplayRotation(lastSensorRotationConverted_)) {
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
Orientation currentOrientation = GetPreferredOrientation();
|
||||
if (IsSensorRelatedOrientation(currentOrientation)) {
|
||||
ProcessSwitchToSensorRelatedOrientation(currentOrientation, lastSensorRotationConverted_);
|
||||
}
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
void ScreenRotationController::SetDefaultDeviceRotationOffset(uint32_t defaultDeviceRotationOffset)
|
||||
@ -255,16 +266,14 @@ void ScreenRotationController::ProcessSwitchToSensorRelatedOrientation(
|
||||
void ScreenRotationController::ProcessSwitchToAutoRotation(DeviceRotation rotation)
|
||||
{
|
||||
if (rotation != DeviceRotation::INVALID) {
|
||||
return;
|
||||
SetScreenRotation(ConvertDeviceToDisplayRotation(rotation));
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenRotationController::ProcessSwitchToAutoRotationPortrait(DeviceRotation rotation)
|
||||
{
|
||||
if (IsCurrentDisplayVertical()) {
|
||||
return;
|
||||
}
|
||||
if (IsDeviceRotationVertical(rotation)) {
|
||||
SetScreenRotation(ConvertDeviceToDisplayRotation(rotation));
|
||||
return;
|
||||
}
|
||||
SetScreenRotation(ConvertDeviceToDisplayRotation(DeviceRotation::ROTATION_PORTRAIT));
|
||||
@ -272,10 +281,8 @@ void ScreenRotationController::ProcessSwitchToAutoRotationPortrait(DeviceRotatio
|
||||
|
||||
void ScreenRotationController::ProcessSwitchToAutoRotationLandscape(DeviceRotation rotation)
|
||||
{
|
||||
if (IsCurrentDisplayHorizontal()) {
|
||||
return;
|
||||
}
|
||||
if (IsDeviceRotationHorizontal(rotation)) {
|
||||
SetScreenRotation(ConvertDeviceToDisplayRotation(rotation));
|
||||
return;
|
||||
}
|
||||
SetScreenRotation(ConvertDeviceToDisplayRotation(DeviceRotation::ROTATION_LANDSCAPE));
|
||||
@ -313,6 +320,14 @@ DeviceRotation ScreenRotationController::ConvertSensorToDeviceRotation(SensorRot
|
||||
return sensorToDeviceRotationMap_.at(sensorRotation);
|
||||
}
|
||||
|
||||
DisplayOrientation ScreenRotationController::ConvertRotationToDisplayOrientation(Rotation rotation)
|
||||
{
|
||||
if (displayToDisplayOrientationMap_.empty()) {
|
||||
ProcessRotationMapping();
|
||||
}
|
||||
return displayToDisplayOrientationMap_.at(rotation);
|
||||
}
|
||||
|
||||
Rotation ScreenRotationController::ConvertDeviceToDisplayRotation(DeviceRotation deviceRotation)
|
||||
{
|
||||
if (deviceRotation == DeviceRotation::INVALID) {
|
||||
@ -342,6 +357,18 @@ void ScreenRotationController::ProcessRotationMapping()
|
||||
defaultDeviceRotation_ == 1 ? Rotation::ROTATION_180 : Rotation::ROTATION_270},
|
||||
};
|
||||
}
|
||||
if (displayToDisplayOrientationMap_.empty()) {
|
||||
displayToDisplayOrientationMap_ = {
|
||||
{defaultDeviceRotation_ == 0 ? Rotation::ROTATION_0 : Rotation::ROTATION_90,
|
||||
DisplayOrientation::PORTRAIT},
|
||||
{defaultDeviceRotation_ == 1 ? Rotation::ROTATION_0 : Rotation::ROTATION_90,
|
||||
DisplayOrientation::LANDSCAPE},
|
||||
{defaultDeviceRotation_ == 0 ? Rotation::ROTATION_180 : Rotation::ROTATION_270,
|
||||
DisplayOrientation::PORTRAIT_INVERTED},
|
||||
{defaultDeviceRotation_ == 1 ? Rotation::ROTATION_180 : Rotation::ROTATION_270,
|
||||
DisplayOrientation::LANDSCAPE_INVERTED},
|
||||
};
|
||||
}
|
||||
if (sensorToDeviceRotationMap_.empty()) {
|
||||
sensorToDeviceRotationMap_ = {
|
||||
{SensorRotation::ROTATION_0, CalcDeviceRotation(SensorRotation::ROTATION_0)},
|
||||
|
@ -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.
|
||||
@ -210,18 +210,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
|
||||
|
@ -88,7 +88,7 @@ private:
|
||||
NativeValue* OnStartAbility(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGI("OnStartAbility is called");
|
||||
if (info.argc < 2) {// at least two argc
|
||||
if (info.argc < 2) { // at least two argc
|
||||
WLOGFE("Start ability failed, not enough params.");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
@ -120,7 +120,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 2) ? nullptr : info.argv[2];// at least two argc
|
||||
NativeValue* lastParam = (info.argc <= 2) ? nullptr : info.argv[2]; // at least two argc
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JSServiceExtensionContext::OnStartAbility",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
|
@ -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 },
|
||||
};
|
||||
|
||||
@ -161,6 +164,14 @@ enum class Orientation : uint32_t {
|
||||
END = LOCKED,
|
||||
};
|
||||
|
||||
enum class DisplayOrientation : uint32_t {
|
||||
PORTRAIT = 0,
|
||||
LANDSCAPE,
|
||||
PORTRAIT_INVERTED,
|
||||
LANDSCAPE_INVERTED,
|
||||
UNKNOWN,
|
||||
};
|
||||
|
||||
enum class DisplayChangeEvent : uint32_t {
|
||||
UPDATE_ORIENTATION,
|
||||
UPDATE_ROTATION,
|
||||
@ -170,6 +181,13 @@ enum class DisplayChangeEvent : uint32_t {
|
||||
DISPLAY_VIRTUAL_PIXEL_RATIO_CHANGED,
|
||||
UNKNOWN,
|
||||
};
|
||||
|
||||
enum class ScreenSourceMode: uint32_t {
|
||||
SCREEN_MAIN = 0,
|
||||
SCREEN_MIRROR = 1,
|
||||
SCREEN_EXTEND = 2,
|
||||
SCREEN_ALONE = 3,
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // OHOS_ROSEN_DM_COMMON_H
|
@ -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();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -60,8 +60,7 @@ public:
|
||||
virtual void AfterBackground() {}
|
||||
virtual void AfterFocused() {}
|
||||
virtual void AfterUnfocused() {}
|
||||
virtual void ForegroundFailed() {}
|
||||
virtual void ForegroundInvalidMode() {}
|
||||
virtual void ForegroundFailed(int32_t ret) {}
|
||||
virtual void AfterActive() {}
|
||||
virtual void AfterInactive() {}
|
||||
};
|
||||
@ -69,7 +68,7 @@ public:
|
||||
class IWindowChangeListener : virtual public RefBase {
|
||||
public:
|
||||
virtual void OnSizeChange(Rect rect, WindowSizeChangeReason reason) {}
|
||||
virtual void OnModeChange(WindowMode mode) {}
|
||||
virtual void OnModeChange(WindowMode mode, bool hasDeco = true) {}
|
||||
};
|
||||
|
||||
class IAvoidAreaChangedListener : virtual public RefBase {
|
||||
@ -152,6 +151,7 @@ public:
|
||||
virtual void OnDialogDeathRecipient() const = 0;
|
||||
};
|
||||
|
||||
static WMError DefaultCreateErrCode = WMError::WM_OK;
|
||||
class Window : public RefBase {
|
||||
public:
|
||||
/**
|
||||
@ -163,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
|
||||
*
|
||||
@ -253,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;
|
||||
@ -329,18 +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
|
||||
*
|
||||
@ -476,6 +478,19 @@ public:
|
||||
* @param configuration configuration for app
|
||||
*/
|
||||
virtual bool IsAllowHaveSystemSubWindow() = 0;
|
||||
|
||||
/**
|
||||
* @brief Set aspect ratio of this window
|
||||
*
|
||||
* @param ratio the aspect ratio of window except decoration
|
||||
* @return WMError
|
||||
*/
|
||||
virtual WMError SetAspectRatio(float ratio) = 0;
|
||||
/**
|
||||
* @brief Unset aspect ratio
|
||||
* @return WMError
|
||||
*/
|
||||
virtual WMError UnsetAspectRatio() = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -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 {
|
||||
@ -349,7 +352,7 @@ struct Rect {
|
||||
return !this->operator==(a);
|
||||
}
|
||||
|
||||
bool isUninitializedRect() const
|
||||
bool IsUninitializedRect() const
|
||||
{
|
||||
return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
|
||||
}
|
||||
@ -404,8 +407,8 @@ public:
|
||||
|
||||
bool isEmptyAvoidArea() const
|
||||
{
|
||||
return topRect_.isUninitializedRect() && leftRect_.isUninitializedRect() &&
|
||||
rightRect_.isUninitializedRect() && bottomRect_.isUninitializedRect();
|
||||
return topRect_.IsUninitializedRect() && leftRect_.IsUninitializedRect() &&
|
||||
rightRect_.IsUninitializedRect() && bottomRect_.IsUninitializedRect();
|
||||
}
|
||||
|
||||
static inline bool WriteParcel(Parcel& parcel, const Rect& rect)
|
||||
|
@ -162,6 +162,34 @@ declare namespace display {
|
||||
STATE_ON_SUSPEND,
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates the display orientation.
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @since 10
|
||||
*/
|
||||
enum Orientation {
|
||||
/**
|
||||
* Indicate that the display content is in portrait mode.
|
||||
*/
|
||||
PORTRAIT = 0,
|
||||
|
||||
/**
|
||||
* Indicate that the display content is in landscape mode.
|
||||
*/
|
||||
LANDSCAPE = 1,
|
||||
|
||||
/**
|
||||
* Indicate that the display content is in the opposite direction of the portrait mode.
|
||||
*/
|
||||
PORTRAIT_INVERTED = 2,
|
||||
|
||||
/**
|
||||
* Indicate that the display content is in the opposite direction of the landscape mode.
|
||||
*/
|
||||
LANDSCAPE_INVERTED = 3,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rectangle
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
@ -238,6 +266,12 @@ declare namespace display {
|
||||
* Rotation degrees of the display.
|
||||
*/
|
||||
rotation: number;
|
||||
|
||||
/**
|
||||
* Diplay orientation.
|
||||
* @since 10
|
||||
*/
|
||||
orientation: Orientation;
|
||||
|
||||
/**
|
||||
* Display width, in pixels.
|
||||
|
@ -170,7 +170,7 @@ NativeValue* CreateJsBoundingRectsArrayObject(NativeEngine& engine, std::vector<
|
||||
|
||||
NativeValue* CreateJsDisplayObject(NativeEngine& engine, sptr<Display>& display)
|
||||
{
|
||||
WLOGI("JsDisplay::CreateJsDisplay is called");
|
||||
WLOGI("CreateJsDisplay is called");
|
||||
NativeValue* objValue = nullptr;
|
||||
std::shared_ptr<NativeReference> jsDisplayObj = FindJsDisplayObject(display->GetId());
|
||||
if (jsDisplayObj != nullptr && jsDisplayObj->Get() != nullptr) {
|
||||
@ -205,6 +205,7 @@ NativeValue* CreateJsDisplayObject(NativeEngine& engine, sptr<Display>& display)
|
||||
}
|
||||
|
||||
object->SetProperty("rotation", CreateJsValue(engine, info->GetRotation()));
|
||||
object->SetProperty("orientation", CreateJsValue(engine, info->GetDisplayOrientation()));
|
||||
object->SetProperty("densityDPI", CreateJsValue(engine, info->GetVirtualPixelRatio() * DOT_PER_INCH));
|
||||
object->SetProperty("densityPixels", CreateJsValue(engine, info->GetVirtualPixelRatio()));
|
||||
object->SetProperty("scaledDensity", CreateJsValue(engine, info->GetVirtualPixelRatio()));
|
||||
|
@ -44,7 +44,7 @@ explicit JsDisplayManager(NativeEngine* engine) {
|
||||
|
||||
static void Finalizer(NativeEngine* engine, void* data, void* hint)
|
||||
{
|
||||
WLOGI("JsDisplayManager::Finalizer is called");
|
||||
WLOGI("Finalizer is called");
|
||||
std::unique_ptr<JsDisplayManager>(static_cast<JsDisplayManager*>(data));
|
||||
}
|
||||
|
||||
@ -96,10 +96,10 @@ std::mutex mtx_;
|
||||
|
||||
NativeValue* OnGetDefaultDisplay(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGI("JsDisplayManager::OnGetDefaultDisplay is called");
|
||||
WLOGI("GetDefaultDisplay called");
|
||||
DMError errCode = DMError::DM_OK;
|
||||
if (info.argc != 0 && info.argc != ARGC_ONE) {
|
||||
WLOGFE("JsDisplayManager::OnGetDefaultDisplay params not match");
|
||||
WLOGFE("OnGetDefaultDisplay params not match");
|
||||
errCode = DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ NativeValue* OnGetDefaultDisplay(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
sptr<Display> display = SingletonContainer::Get<DisplayManager>().GetDefaultDisplay();
|
||||
if (display != nullptr) {
|
||||
task.Resolve(engine, CreateJsDisplayObject(engine, display));
|
||||
WLOGI("JsDisplayManager::OnGetDefaultDisplay success");
|
||||
WLOGI("OnGetDefaultDisplay success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine,
|
||||
static_cast<int32_t>(DMError::DM_ERROR_NULLPTR), "JsDisplayManager::OnGetDefaultDisplay failed."));
|
||||
@ -130,10 +130,10 @@ NativeValue* OnGetDefaultDisplay(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
|
||||
NativeValue* OnGetDefaultDisplaySync(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGI("JsDisplayManager::OnGetDefaultDisplaySync is called");
|
||||
WLOGI("GetDefaultDisplaySync called");
|
||||
sptr<Display> display = SingletonContainer::Get<DisplayManager>().GetDefaultDisplaySync();
|
||||
if (display == nullptr) {
|
||||
WLOGFE("JsDisplayManager::OnGetDefaultDisplaySync, display is nullptr.");
|
||||
WLOGFE("OnGetDefaultDisplaySync, display is nullptr.");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_SCREEN)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
@ -142,10 +142,10 @@ NativeValue* OnGetDefaultDisplaySync(NativeEngine& engine, NativeCallbackInfo& i
|
||||
|
||||
NativeValue* OnGetAllDisplay(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGI("JsDisplayManager::OnGetAllDisplay is called");
|
||||
WLOGI("GetAllDisplay called");
|
||||
DMError errCode = DMError::DM_OK;
|
||||
if (info.argc != 0 && info.argc != ARGC_ONE) {
|
||||
WLOGFE("JsDisplayManager::OnGetAllDisplay params not match");
|
||||
WLOGFE("OnGetAllDisplay params not match");
|
||||
errCode = DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ NativeValue* OnGetAllDisplay(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
std::vector<sptr<Display>> displays = SingletonContainer::Get<DisplayManager>().GetAllDisplays();
|
||||
if (!displays.empty()) {
|
||||
task.Resolve(engine, CreateJsDisplayArrayObject(engine, displays));
|
||||
WLOGI("JsDisplayManager::GetAllDisplays success");
|
||||
WLOGI("GetAllDisplays success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine,
|
||||
static_cast<int32_t>(DMError::DM_ERROR_NULLPTR), "JsDisplayManager::OnGetAllDisplay failed."));
|
||||
@ -177,14 +177,14 @@ NativeValue* OnGetAllDisplay(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
|
||||
NativeValue* OnGetAllDisplays(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGI("JsDisplayManager::OnGetAllDisplays is called");
|
||||
WLOGI("GetAllDisplays is called");
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
std::vector<sptr<Display>> displays = SingletonContainer::Get<DisplayManager>().GetAllDisplays();
|
||||
if (!displays.empty()) {
|
||||
task.Resolve(engine, CreateJsDisplayArrayObject(engine, displays));
|
||||
WLOGI("JsDisplayManager::GetAllDisplays success");
|
||||
WLOGI("GetAllDisplays success");
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine,
|
||||
static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_SCREEN),
|
||||
@ -206,7 +206,7 @@ NativeValue* OnGetAllDisplays(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
void RegisterDisplayListenerWithType(NativeEngine& engine, const std::string& type, NativeValue* value)
|
||||
{
|
||||
if (IfCallbackRegistered(type, value)) {
|
||||
WLOGFE("JsDisplayManager::RegisterDisplayListenerWithType callback already registered!");
|
||||
WLOGFE("RegisterDisplayListenerWithType callback already registered!");
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<NativeReference> callbackRef;
|
||||
@ -218,9 +218,9 @@ void RegisterDisplayListenerWithType(NativeEngine& engine, const std::string& ty
|
||||
}
|
||||
if (type == EVENT_ADD || type == EVENT_REMOVE || type == EVENT_CHANGE) {
|
||||
SingletonContainer::Get<DisplayManager>().RegisterDisplayListener(displayListener);
|
||||
WLOGI("JsDisplayManager::RegisterDisplayListenerWithType success");
|
||||
WLOGI("RegisterDisplayListenerWithType success");
|
||||
} else {
|
||||
WLOGFE("JsDisplayManager::RegisterDisplayListenerWithType failed method: %{public}s not support!",
|
||||
WLOGFE("RegisterDisplayListenerWithType failed method: %{public}s not support!",
|
||||
type.c_str());
|
||||
return;
|
||||
}
|
||||
@ -231,13 +231,13 @@ void RegisterDisplayListenerWithType(NativeEngine& engine, const std::string& ty
|
||||
bool IfCallbackRegistered(const std::string& type, NativeValue* jsListenerObject)
|
||||
{
|
||||
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
|
||||
WLOGI("JsDisplayManager::IfCallbackRegistered methodName %{public}s not registered!", type.c_str());
|
||||
WLOGI("IfCallbackRegistered methodName %{public}s not registered!", type.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto& iter : jsCbMap_[type]) {
|
||||
if (jsListenerObject->StrictEquals(iter.first->Get())) {
|
||||
WLOGFE("JsDisplayManager::IfCallbackRegistered callback already registered!");
|
||||
WLOGFE("IfCallbackRegistered callback already registered!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -247,7 +247,7 @@ bool IfCallbackRegistered(const std::string& type, NativeValue* jsListenerObject
|
||||
void UnregisterAllDisplayListenerWithType(const std::string& type)
|
||||
{
|
||||
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
|
||||
WLOGI("JsDisplayManager::UnregisterAllDisplayListenerWithType methodName %{public}s not registered!",
|
||||
WLOGI("UnregisterAllDisplayListenerWithType methodName %{public}s not registered!",
|
||||
type.c_str());
|
||||
return;
|
||||
}
|
||||
@ -256,7 +256,7 @@ void UnregisterAllDisplayListenerWithType(const std::string& type)
|
||||
if (type == EVENT_ADD || type == EVENT_REMOVE || type == EVENT_CHANGE) {
|
||||
sptr<DisplayManager::IDisplayListener> thisListener(it->second);
|
||||
SingletonContainer::Get<DisplayManager>().UnregisterDisplayListener(thisListener);
|
||||
WLOGI("JsDisplayManager::UnregisterAllDisplayListenerWithType success");
|
||||
WLOGI("UnregisterAllDisplayListenerWithType success");
|
||||
}
|
||||
jsCbMap_[type].erase(it++);
|
||||
}
|
||||
@ -266,7 +266,7 @@ void UnregisterAllDisplayListenerWithType(const std::string& type)
|
||||
void UnRegisterDisplayListenerWithType(const std::string& type, NativeValue* value)
|
||||
{
|
||||
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
|
||||
WLOGI("JsDisplayManager::UnRegisterDisplayListenerWithType methodName %{public}s not registered!",
|
||||
WLOGI("UnRegisterDisplayListenerWithType methodName %{public}s not registered!",
|
||||
type.c_str());
|
||||
return;
|
||||
}
|
||||
@ -276,7 +276,7 @@ void UnRegisterDisplayListenerWithType(const std::string& type, NativeValue* val
|
||||
if (type == EVENT_ADD || type == EVENT_REMOVE || type == EVENT_CHANGE) {
|
||||
sptr<DisplayManager::IDisplayListener> thisListener(it->second);
|
||||
SingletonContainer::Get<DisplayManager>().UnregisterDisplayListener(thisListener);
|
||||
WLOGI("JsDisplayManager::UnRegisterDisplayListenerWithType success");
|
||||
WLOGI("UnRegisterDisplayListenerWithType success");
|
||||
}
|
||||
jsCbMap_[type].erase(it++);
|
||||
break;
|
||||
@ -291,7 +291,7 @@ void UnRegisterDisplayListenerWithType(const std::string& type, NativeValue* val
|
||||
|
||||
NativeValue* OnRegisterDisplayManagerCallback(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGI("JsDisplayManager::OnRegisterDisplayManagerCallback is called");
|
||||
WLOGI("OnRegisterDisplayManagerCallback is called");
|
||||
if (info.argc < ARGC_TWO) {
|
||||
WLOGFE("JsDisplayManager Params not match: %{public}zu", info.argc);
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_PARAM)));
|
||||
@ -305,12 +305,12 @@ NativeValue* OnRegisterDisplayManagerCallback(NativeEngine& engine, NativeCallba
|
||||
}
|
||||
NativeValue* value = info.argv[INDEX_ONE];
|
||||
if (value == nullptr) {
|
||||
WLOGI("JsDisplayManager::OnRegisterDisplayManagerCallback info->argv[1] is nullptr");
|
||||
WLOGI("OnRegisterDisplayManagerCallback 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("JsDisplayManager::OnRegisterDisplayManagerCallback info->argv[1] is not callable");
|
||||
WLOGI("OnRegisterDisplayManagerCallback info->argv[1] is not callable");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
@ -321,7 +321,7 @@ NativeValue* OnRegisterDisplayManagerCallback(NativeEngine& engine, NativeCallba
|
||||
|
||||
NativeValue* OnUnregisterDisplayManagerCallback(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WLOGI("JsDisplayManager::OnUnregisterDisplayCallback is called");
|
||||
WLOGI("OnUnregisterDisplayCallback is called");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
WLOGFE("JsDisplayManager Params not match %{public}zu", info.argc);
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_PARAM)));
|
||||
@ -377,7 +377,7 @@ NativeValue* OnHasPrivateWindow(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
|
||||
NativeValue* CreateJsDisplayArrayObject(NativeEngine& engine, std::vector<sptr<Display>>& displays)
|
||||
{
|
||||
WLOGI("JsDisplayManager::CreateJsDisplayArrayObject is called");
|
||||
WLOGI("CreateJsDisplayArrayObject is called");
|
||||
NativeValue* arrayValue = engine.CreateArray(displays.size());
|
||||
NativeArray* array = ConvertNativeValueTo<NativeArray>(arrayValue);
|
||||
if (array == nullptr) {
|
||||
@ -397,7 +397,7 @@ NativeValue* CreateJsDisplayArrayObject(NativeEngine& engine, std::vector<sptr<D
|
||||
|
||||
NativeValue* InitDisplayState(NativeEngine* engine)
|
||||
{
|
||||
WLOGI("JsDisplayManager::InitDisplayState called");
|
||||
WLOGI("InitDisplayState called");
|
||||
|
||||
if (engine == nullptr) {
|
||||
WLOGFE("engine is nullptr");
|
||||
@ -427,7 +427,7 @@ NativeValue* InitDisplayState(NativeEngine* engine)
|
||||
|
||||
NativeValue* InitDisplayErrorCode(NativeEngine* engine)
|
||||
{
|
||||
WLOGI("JsDisplayManager::InitDisplayErrorCode called");
|
||||
WLOGI("InitDisplayErrorCode called");
|
||||
|
||||
if (engine == nullptr) {
|
||||
WLOGFE("engine is nullptr");
|
||||
@ -459,7 +459,7 @@ NativeValue* InitDisplayErrorCode(NativeEngine* engine)
|
||||
|
||||
NativeValue* InitDisplayError(NativeEngine* engine)
|
||||
{
|
||||
WLOGI("JsDisplayManager::InitDisplayError called");
|
||||
WLOGI("InitDisplayError called");
|
||||
|
||||
if (engine == nullptr) {
|
||||
WLOGFE("engine is nullptr");
|
||||
|
@ -160,6 +160,32 @@ declare namespace screen {
|
||||
surfaceId: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate the source mode of the screen
|
||||
* @since 10
|
||||
*/
|
||||
enum ScreenSourceMode {
|
||||
/**
|
||||
* Indicate that the screen is the default screen.
|
||||
*/
|
||||
SCREEN_MAIN = 0,
|
||||
|
||||
/**
|
||||
* Indicate that the screen is in mirror mode.
|
||||
*/
|
||||
SCREEN_MIRROR = 1,
|
||||
|
||||
/**
|
||||
* Indicate that the screen is in extend mode.
|
||||
*/
|
||||
SCREEN_EXTEND = 2,
|
||||
|
||||
/**
|
||||
* Indicate that the screen stands alone.
|
||||
*/
|
||||
SCREEN_ALONE = 3,
|
||||
}
|
||||
|
||||
/**
|
||||
* interface for screen
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
@ -191,6 +217,13 @@ declare namespace screen {
|
||||
*/
|
||||
readonly orientation: Orientation;
|
||||
|
||||
/**
|
||||
* Source mode of the screen
|
||||
* @since 10
|
||||
*/
|
||||
readonly sourceMode: ScreenSourceMode;
|
||||
|
||||
|
||||
/**
|
||||
* set the orientation of the screen
|
||||
* @throws DM_ERROR_INVALID_PARAM If param is not valid
|
||||
|
@ -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");
|
||||
}
|
||||
@ -260,6 +260,7 @@ NativeValue* CreateJsScreenObject(NativeEngine& engine, sptr<Screen>& screen)
|
||||
object->SetProperty("parent",
|
||||
CreateJsValue(engine, parentId == SCREEN_ID_INVALID ? -1 : static_cast<int64_t>(parentId)));
|
||||
object->SetProperty("orientation", CreateJsValue(engine, info->GetOrientation()));
|
||||
object->SetProperty("sourceMode", CreateJsValue(engine, info->GetSourceMode()));
|
||||
object->SetProperty("activeModeIndex", CreateJsValue(engine, info->GetModeId()));
|
||||
object->SetProperty("supportedModeInfo", CreateJsScreenModeArrayObject(engine, info->GetModes()));
|
||||
object->SetProperty("densityDpi", CreateJsValue(engine,
|
||||
|
@ -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",
|
||||
|
@ -64,13 +64,14 @@ ohos_shared_library("window_native_kit") {
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:dialog_request_info",
|
||||
"ability_runtime:runtime",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc_js:rpc",
|
||||
"ipc:ipc_napi_common",
|
||||
"multimedia_image_framework:image",
|
||||
"multimedia_image_framework:image_native",
|
||||
"napi:ace_napi",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -1240,6 +1240,46 @@ declare namespace window {
|
||||
* @since 9
|
||||
*/
|
||||
snapshot(): Promise<image.PixelMap>;
|
||||
|
||||
/**
|
||||
* Sets the aspect ratio of window
|
||||
* @param { number } ratio - The aspect ratio of window except decoration
|
||||
* @param { AsyncCallback<void> } callback - The callback of setAspectRatio.
|
||||
* @throws { BusinessError } 401 - If param is invalid
|
||||
* @throws { BusinessError } 1300002 - If window state is abnormally
|
||||
* @throws { BusinessError } 1300004 - If this window can not set aspect ratio
|
||||
* @since 10
|
||||
*/
|
||||
setAspectRatio(ratio: number, callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Sets the aspect ratio of window
|
||||
* @param { number } ratio - The aspect ratio of window except decoration
|
||||
* @returns { Promise<void> } - The promise returned by the function.
|
||||
* @throws { BusinessError } 401 - If param is invalid
|
||||
* @throws { BusinessError } 1300002 - If window state is abnormally
|
||||
* @throws { BusinessError } 1300004 - If this window can not set aspect ratio
|
||||
* @since 10
|
||||
*/
|
||||
setAspectRatio(ratio: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Unsets the aspect ratio of window
|
||||
* @param { AsyncCallback<void> } callback - The callback of setAspectRatio.
|
||||
* @throws { BusinessError } 1300002 - If window state is abnormally
|
||||
* @throws { BusinessError } 1300004 - If this window can not unset aspect ratio
|
||||
* @since 10
|
||||
*/
|
||||
unsetAspectRatio(callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Unsets the aspect ratio of window
|
||||
* @returns { Promise<void> } - The promise returned by the function.
|
||||
* @throws { BusinessError } 1300002 - If window state is abnormally
|
||||
* @throws { BusinessError } 1300004 - If this window can not unset aspect ratio
|
||||
* @since 10
|
||||
*/
|
||||
unsetAspectRatio(): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Transition Context
|
||||
|
@ -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();
|
||||
}
|
||||
@ -883,6 +900,7 @@ NativeValue* JsWindowManagerInit(NativeEngine* engine, NativeValue* exportObj)
|
||||
object->SetProperty("WindowMode", WindowModeInit(engine));
|
||||
object->SetProperty("ColorSpace", ColorSpaceInit(engine));
|
||||
object->SetProperty("WindowStageEventType", WindowStageEventTypeInit(engine));
|
||||
object->SetProperty("WindowEventType", WindowEventTypeInit(engine));
|
||||
object->SetProperty("WindowLayoutMode", WindowLayoutModeInit(engine));
|
||||
object->SetProperty("Orientation", OrientationInit(engine));
|
||||
object->SetProperty("BlurStyle", BlurStyleInit(engine));
|
||||
|
@ -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);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -32,6 +32,7 @@
|
||||
#include "pixel_map_napi.h"
|
||||
#include "napi_remote_object.h"
|
||||
#include "permission.h"
|
||||
#include "request_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@ -454,6 +455,13 @@ NativeValue* JsWindow::SetSnapshotSkip(NativeEngine* engine, NativeCallbackInfo*
|
||||
return (me != nullptr) ? me->OnSetSnapshotSkip(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::RaiseToAppTop(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGI("RaiseToAppTop");
|
||||
JsWindow* me = CheckParamsAndGetThis<JsWindow>(engine, info);
|
||||
return (me != nullptr) ? me->OnRaiseToAppTop(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::DisableWindowDecor(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGI("DisableWindowDecor");
|
||||
@ -573,6 +581,20 @@ NativeValue* JsWindow::SetBackdropBlurStyle(NativeEngine* engine, NativeCallback
|
||||
return (me != nullptr) ? me->OnSetBackdropBlurStyle(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::SetAspectRatio(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGI("[NAPI]SetAspectRatio");
|
||||
JsWindow* me = CheckParamsAndGetThis<JsWindow>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetAspectRatio(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::UnsetAspectRatio(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGI("[NAPI]UnsetAspectRatio");
|
||||
JsWindow* me = CheckParamsAndGetThis<JsWindow>(engine, info);
|
||||
return (me != nullptr) ? me->OnUnsetAspectRatio(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnShow(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WMError errCode = WMError::WM_OK;
|
||||
@ -595,8 +617,7 @@ NativeValue* JsWindow::OnShow(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window show failed"));
|
||||
}
|
||||
WLOGI("Window [%{public}u, %{public}s] show end, ret = %{public}d",
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
WLOGI("Window [%{public}u] show end, ret = %{public}d", weakWindow->GetWindowId(), ret);
|
||||
};
|
||||
NativeValue* result = nullptr;
|
||||
NativeValue* lastParam = (info.argc == 0) ? nullptr :
|
||||
@ -764,8 +785,7 @@ NativeValue* JsWindow::OnHide(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window hide failed"));
|
||||
}
|
||||
WLOGI("Window [%{public}u, %{public}s] hide end, ret = %{public}d",
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
WLOGI("Window [%{public}u] hide end, ret = %{public}d", weakWindow->GetWindowId(), ret);
|
||||
};
|
||||
|
||||
NativeValue* result = nullptr;
|
||||
@ -1061,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"));
|
||||
@ -1081,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;
|
||||
@ -1219,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();
|
||||
@ -1240,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();
|
||||
@ -1267,6 +1296,12 @@ NativeValue* JsWindow::OnBindDialogTarget(NativeEngine& engine, NativeCallbackIn
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
token = NAPI_ohos_rpc_getNativeRemoteObject(
|
||||
reinterpret_cast<napi_env>(&engine), reinterpret_cast<napi_value>(info.argv[0]));
|
||||
if (token == nullptr) {
|
||||
std::shared_ptr<AbilityRuntime::RequestInfo> requestInfo = AbilityRuntime::RequestInfo::UnwrapRequestInfo(engine, info.argv[0]);
|
||||
if (requestInfo != nullptr) {
|
||||
token = requestInfo->GetToken();
|
||||
}
|
||||
}
|
||||
if (token == nullptr) {
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
@ -2451,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;
|
||||
@ -2771,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();
|
||||
@ -3070,13 +3110,50 @@ 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());
|
||||
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnRaiseToAppTop(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[this](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
auto window = weakToken.promote();
|
||||
if (window == nullptr) {
|
||||
WLOGFE("window is nullptr");
|
||||
task.Reject(engine, CreateJsError(engine,
|
||||
static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
|
||||
return;
|
||||
}
|
||||
|
||||
WmErrorCode errCode = window->RaiseToAppTop();
|
||||
if (errCode != WmErrorCode::WM_OK) {
|
||||
WLOGFE("raise window zorder failed");
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode)));
|
||||
return;
|
||||
}
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGI("Window [%{public}u, %{public}s] zorder raise success",
|
||||
window->GetWindowId(), window->GetWindowName().c_str());
|
||||
};
|
||||
NativeValue* lastParam = (info.argc == 0) ? nullptr :
|
||||
((info.argv[0] != nullptr && info.argv[0]->TypeOf() == NATIVE_FUNCTION) ?
|
||||
info.argv[0] : nullptr);
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JsWindow::OnRaiseToAppTop",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnOpacity(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (info.argc < 1) {
|
||||
@ -3106,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();
|
||||
@ -3187,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",
|
||||
@ -3252,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," \
|
||||
@ -3304,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(),
|
||||
@ -3312,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)
|
||||
@ -3360,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) {
|
||||
@ -3439,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();
|
||||
}
|
||||
|
||||
@ -3572,6 +3674,105 @@ NativeValue* JsWindow::OnSetBackdropBlurStyle(NativeEngine& engine, NativeCallba
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnSetAspectRatio(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WMError errCode = WMError::WM_OK;
|
||||
if (info.argc < 1 || info.argc > 2) { // 2: maximum params num
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (!WindowHelper::IsMainWindow(windowToken_->GetType())) {
|
||||
WLOGFE("[NAPI]SetAspectRatio is not allowed since window is main window");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_CALLING)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
float aspectRatio = 0.0;
|
||||
if (errCode == WMError::WM_OK) {
|
||||
NativeNumber* nativeVal = ConvertNativeValueTo<NativeNumber>(info.argv[0]);
|
||||
if (nativeVal == nullptr) {
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
aspectRatio = static_cast<double>(*nativeVal);
|
||||
}
|
||||
}
|
||||
|
||||
if (errCode == WMError::WM_ERROR_INVALID_PARAM || aspectRatio <= 0.0) {
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[weakToken, aspectRatio](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr) {
|
||||
task.Reject(engine,
|
||||
CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY),
|
||||
"OnSetAspectRatio failed."));
|
||||
return;
|
||||
}
|
||||
WMError ret = weakWindow->SetAspectRatio(aspectRatio);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "SetAspectRatio failed."));
|
||||
}
|
||||
WLOGI("[NAPI]Window [%{public}u, %{public}s] set aspect ratio end, ret = %{public}d",
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == 1) ? nullptr :
|
||||
(info.argv[1]->TypeOf() == NATIVE_FUNCTION ? info.argv[1] : nullptr);
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JsWindow::SetAspectRatio",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnUnsetAspectRatio(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (info.argc >= 1) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
if (!WindowHelper::IsMainWindow(windowToken_->GetType())) {
|
||||
WLOGFE("[NAPI]UnsetAspectRatio is not allowed since window is main window");
|
||||
engine.Throw(CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_CALLING)));
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
wptr<Window> weakToken(windowToken_);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[weakToken](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
auto weakWindow = weakToken.promote();
|
||||
if (weakWindow == nullptr) {
|
||||
task.Reject(engine,
|
||||
CreateJsError(engine, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY),
|
||||
"OnUnsetAspectRatio failed."));
|
||||
return;
|
||||
}
|
||||
WMError ret = weakWindow->UnsetAspectRatio();
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "UnsetAspectRatio failed."));
|
||||
}
|
||||
WLOGI("[NAPI]Window [%{public}u, %{public}s] unset aspect ratio end, ret = %{public}d",
|
||||
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret);
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == 0) ? nullptr :
|
||||
(info.argv[0]->TypeOf() == NATIVE_FUNCTION ? info.argv[0] : nullptr);
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JsWindow::OnUnsetAspectRatio",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeReference> FindJsWindowObject(std::string windowName)
|
||||
{
|
||||
WLOGFD("Try to find window %{public}s in g_jsWindowMap", windowName.c_str());
|
||||
@ -3666,6 +3867,7 @@ void BindFunctions(NativeEngine& engine, NativeObject* object, const char *modul
|
||||
BindNativeFunction(engine, *object, "setTransparent", moduleName, JsWindow::SetTransparent);
|
||||
BindNativeFunction(engine, *object, "setCallingWindow", moduleName, JsWindow::SetCallingWindow);
|
||||
BindNativeFunction(engine, *object, "setSnapshotSkip", moduleName, JsWindow::SetSnapshotSkip);
|
||||
BindNativeFunction(engine, *object, "raiseToAppTop", moduleName, JsWindow::RaiseToAppTop);
|
||||
BindNativeFunction(engine, *object, "disableWindowDecor", moduleName, JsWindow::DisableWindowDecor);
|
||||
BindNativeFunction(engine, *object, "dump", moduleName, JsWindow::Dump);
|
||||
BindNativeFunction(engine, *object, "setForbidSplitMove", moduleName, JsWindow::SetForbidSplitMove);
|
||||
@ -3681,6 +3883,8 @@ void BindFunctions(NativeEngine& engine, NativeObject* object, const char *modul
|
||||
BindNativeFunction(engine, *object, "setBlur", moduleName, JsWindow::SetBlur);
|
||||
BindNativeFunction(engine, *object, "setBackdropBlur", moduleName, JsWindow::SetBackdropBlur);
|
||||
BindNativeFunction(engine, *object, "setBackdropBlurStyle", moduleName, JsWindow::SetBackdropBlurStyle);
|
||||
BindNativeFunction(engine, *object, "setAspectRatio", moduleName, JsWindow::SetAspectRatio);
|
||||
BindNativeFunction(engine, *object, "unsetAspectRatio", moduleName, JsWindow::UnsetAspectRatio);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -90,6 +90,9 @@ public:
|
||||
static NativeValue* SetPreferredOrientation(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* DisableWindowDecor(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetSnapshotSkip(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* RaiseToAppTop(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetAspectRatio(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* UnsetAspectRatio(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
// colorspace, gamut
|
||||
static NativeValue* IsSupportWideGamut(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* IsWindowSupportWideGamut(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
@ -153,6 +156,9 @@ private:
|
||||
NativeValue* OnIsShowing(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnIsWindowShowingSync(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetPreferredOrientation(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnRaiseToAppTop(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetAspectRatio(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnUnsetAspectRatio(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
||||
// colorspace, gamut
|
||||
NativeValue* OnIsSupportWideGamut(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
@ -190,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);
|
||||
|
@ -74,7 +74,7 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason)
|
||||
*engine_, std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
void JsWindowListener::OnModeChange(WindowMode mode)
|
||||
void JsWindowListener::OnModeChange(WindowMode mode, bool hasDeco)
|
||||
{
|
||||
WLOGI("[NAPI]OnModeChange %{public}u", mode);
|
||||
}
|
||||
@ -173,12 +173,22 @@ void JsWindowListener::LifeCycleCallBack(LifeCycleEventType eventType)
|
||||
|
||||
void JsWindowListener::AfterForeground()
|
||||
{
|
||||
LifeCycleCallBack(LifeCycleEventType::FOREGROUND);
|
||||
if (state_ == WindowState::STATE_INITIAL || state_ == WindowState::STATE_HIDDEN) {
|
||||
LifeCycleCallBack(LifeCycleEventType::FOREGROUND);
|
||||
state_ = WindowState::STATE_SHOWN;
|
||||
} else {
|
||||
WLOGFD("[NAPI]window is already shown");
|
||||
}
|
||||
}
|
||||
|
||||
void JsWindowListener::AfterBackground()
|
||||
{
|
||||
LifeCycleCallBack(LifeCycleEventType::BACKGROUND);
|
||||
if (state_ == WindowState::STATE_INITIAL || state_ == WindowState::STATE_SHOWN) {
|
||||
LifeCycleCallBack(LifeCycleEventType::BACKGROUND);
|
||||
state_ = WindowState::STATE_HIDDEN;
|
||||
} else {
|
||||
WLOGFD("[NAPI]window is already hide");
|
||||
}
|
||||
}
|
||||
|
||||
void JsWindowListener::AfterFocused()
|
||||
|
@ -36,6 +36,7 @@ const std::string SYSTEM_AVOID_AREA_CHANGE_CB = "systemAvoidAreaChange";
|
||||
const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange";
|
||||
const std::string LIFECYCLE_EVENT_CB = "lifeCycleEvent";
|
||||
const std::string WINDOW_STAGE_EVENT_CB = "windowStageEvent";
|
||||
const std::string WINDOW_EVENT_CB = "windowEvent";
|
||||
const std::string KEYBOARD_HEIGHT_CHANGE_CB = "keyboardHeightChange";
|
||||
const std::string TOUCH_OUTSIDE_CB = "touchOutside";
|
||||
const std::string SCREENSHOT_EVENT_CB = "screenshot";
|
||||
@ -57,7 +58,7 @@ public:
|
||||
~JsWindowListener();
|
||||
void OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) override;
|
||||
void OnSizeChange(Rect rect, WindowSizeChangeReason reason) override;
|
||||
void OnModeChange(WindowMode mode) override;
|
||||
void OnModeChange(WindowMode mode, bool hasDeco) override;
|
||||
void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override;
|
||||
void AfterForeground() override;
|
||||
void AfterBackground() override;
|
||||
@ -70,6 +71,7 @@ public:
|
||||
void OnDialogDeathRecipient() const override;
|
||||
void CallJsMethod(const char* methodName, NativeValue* const* argv = nullptr, size_t argc = 0);
|
||||
private:
|
||||
WindowState state_ {WindowState::STATE_INITIAL};
|
||||
void LifeCycleCallBack(LifeCycleEventType eventType);
|
||||
NativeEngine* engine_ = nullptr;
|
||||
std::shared_ptr<NativeReference> jsCallBack_ = nullptr;
|
||||
|
@ -34,6 +34,7 @@ JsWindowRegisterManager::JsWindowRegisterManager()
|
||||
{ SYSTEM_AVOID_AREA_CHANGE_CB, &JsWindowRegisterManager::ProcessSystemAvoidAreaChangeRegister },
|
||||
{ AVOID_AREA_CHANGE_CB, &JsWindowRegisterManager::ProcessAvoidAreaChangeRegister },
|
||||
{ LIFECYCLE_EVENT_CB, &JsWindowRegisterManager::ProcessLifeCycleEventRegister },
|
||||
{ WINDOW_EVENT_CB, &JsWindowRegisterManager::ProcessLifeCycleEventRegister },
|
||||
{ KEYBOARD_HEIGHT_CHANGE_CB, &JsWindowRegisterManager::ProcessOccupiedAreaChangeRegister },
|
||||
{ TOUCH_OUTSIDE_CB, &JsWindowRegisterManager::ProcessTouchOutsideRegister },
|
||||
{ SCREENSHOT_EVENT_CB, &JsWindowRegisterManager::ProcessScreenshotRegister },
|
||||
@ -50,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) {
|
||||
@ -207,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)
|
||||
@ -226,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++);
|
||||
}
|
||||
@ -280,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",
|
||||
@ -298,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_;
|
||||
|
@ -232,6 +232,33 @@ NativeValue* WindowStageEventTypeInit(NativeEngine* engine)
|
||||
return objValue;
|
||||
}
|
||||
|
||||
NativeValue* WindowEventTypeInit(NativeEngine* engine)
|
||||
{
|
||||
WLOGFD("WindowEventTypeInit");
|
||||
|
||||
if (engine == nullptr) {
|
||||
WLOGFE("Engine is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NativeValue *objValue = engine->CreateObject();
|
||||
NativeObject *object = ConvertNativeValueTo<NativeObject>(objValue);
|
||||
if (object == nullptr) {
|
||||
WLOGFE("Failed to get object");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
object->SetProperty("WINDOW_SHOWN", CreateJsValue(*engine,
|
||||
static_cast<int32_t>(LifeCycleEventType::FOREGROUND)));
|
||||
object->SetProperty("WINDOW_ACTIVE", CreateJsValue(*engine,
|
||||
static_cast<int32_t>(LifeCycleEventType::ACTIVE)));
|
||||
object->SetProperty("WINDOW_INACTIVE", CreateJsValue(*engine,
|
||||
static_cast<int32_t>(LifeCycleEventType::INACTIVE)));
|
||||
object->SetProperty("WINDOW_HIDDEN", CreateJsValue(*engine,
|
||||
static_cast<int32_t>(LifeCycleEventType::BACKGROUND)));
|
||||
return objValue;
|
||||
}
|
||||
|
||||
NativeValue* WindowLayoutModeInit(NativeEngine* engine)
|
||||
{
|
||||
WLOGFD("WindowLayoutModeInit");
|
||||
@ -344,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,
|
||||
|
@ -176,6 +176,7 @@ const std::map<ApiOrientation, Orientation> JS_TO_NATIVE_ORIENTATION_MAP {
|
||||
NativeValue* ColorSpaceInit(NativeEngine* engine);
|
||||
NativeValue* OrientationInit(NativeEngine* engine);
|
||||
NativeValue* WindowStageEventTypeInit(NativeEngine* engine);
|
||||
NativeValue* WindowEventTypeInit(NativeEngine* engine);
|
||||
NativeValue* WindowLayoutModeInit(NativeEngine* engine);
|
||||
NativeValue* BlurStyleInit(NativeEngine* engine);
|
||||
NativeValue* WindowErrorCodeInit(NativeEngine* 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();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -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;
|
||||
@ -188,6 +189,9 @@ public:
|
||||
virtual std::shared_ptr<Media::PixelMap> Snapshot() override;
|
||||
virtual WMError NotifyMemoryLevel(int32_t level) const override;
|
||||
virtual bool IsAllowHaveSystemSubWindow() override;
|
||||
WmErrorCode RaiseToAppTop() override;
|
||||
virtual WMError SetAspectRatio(float ratio) override;
|
||||
virtual WMError UnsetAspectRatio() override;
|
||||
|
||||
private:
|
||||
static std::map<std::string, std::pair<uint32_t, sptr<Window>>> windowMap_;
|
||||
|
@ -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
|
||||
|
38
previewer/mock/request_info.h
Normal file
38
previewer/mock/request_info.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_REQUEST_INFO_H
|
||||
#define OHOS_ABILITY_RUNTIME_REQUEST_INFO_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class RequestInfo {
|
||||
public:
|
||||
static NativeValue* WrapRequestInfo(NativeEngine &engine, RequestInfo *request) {
|
||||
return nullptr;
|
||||
};
|
||||
static std::shared_ptr<RequestInfo> UnwrapRequestInfo(NativeEngine &engine, NativeValue *jsParam) {
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
sptr<IRemoteObject> GetToken() {
|
||||
return callerToken_;
|
||||
};
|
||||
private:
|
||||
sptr<IRemoteObject> callerToken_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_REQUEST_INFO_H
|
@ -32,6 +32,7 @@ class Ability;
|
||||
namespace Rosen {
|
||||
class Window;
|
||||
enum class WindowMode : uint32_t;
|
||||
class RSSurfaceNode;
|
||||
}
|
||||
|
||||
namespace AAFwk {
|
||||
@ -101,6 +102,21 @@ public:
|
||||
// receive label and icon
|
||||
virtual void SetAppWindowTitle(const std::string& title) = 0;
|
||||
virtual void SetAppWindowIcon(const std::shared_ptr<OHOS::Media::PixelMap>& pixelMap) = 0;
|
||||
|
||||
// ArkTS Form
|
||||
virtual std::shared_ptr<Rosen::RSSurfaceNode> GetCardRootNode()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void ProcessFormUpdate(const std::string& data) = 0;
|
||||
virtual void SetFormWidth(const float width) = 0;
|
||||
virtual void SetFormHeight(const float height) = 0;
|
||||
virtual float GetFormWidth() = 0;
|
||||
virtual float GetFormHeight() = 0;
|
||||
|
||||
virtual void SetActionEventHandler(
|
||||
std::function<void(const std::string& action)>&& actionCallback) = 0;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -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)
|
||||
@ -758,5 +758,20 @@ bool WindowImpl::IsAllowHaveSystemSubWindow()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
WmErrorCode WindowImpl::RaiseToAppTop()
|
||||
{
|
||||
return WmErrorCode::WM_OK;
|
||||
}
|
||||
|
||||
WMError WindowImpl::SetAspectRatio(float ratio)
|
||||
{
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError WindowImpl::UnsetAspectRatio()
|
||||
{
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -15,7 +15,10 @@
|
||||
-->
|
||||
<Configs>
|
||||
<!--decor enable is true means app main window show decoration-->
|
||||
<decor enable="false"></decor>
|
||||
<decor enable="false">
|
||||
<!--supportedMode could be configed as fullscreen, floating, split or the combination of them-->
|
||||
<supportedMode>floating fullscreen</supportedMode>
|
||||
</decor>
|
||||
<!--max number of main window that could be shown on display-->
|
||||
<maxAppWindowNumber>100</maxAppWindowNumber>
|
||||
<!--maximum number of windows supported by unified rendering -->
|
||||
@ -92,4 +95,6 @@
|
||||
</shadow>
|
||||
</appWindows>
|
||||
</windowEffect>
|
||||
<!--startWindowTransitionAnimation enable is true means startWindow replace with alpha animation-->
|
||||
<startWindowTransitionAnimation enable="false"></startWindowTransitionAnimation>
|
||||
</Configs>
|
||||
|
@ -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
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
MOCK_METHOD1(ProcessVsyncEvent, bool(uint64_t timeStampNanos));
|
||||
MOCK_METHOD1(UpdateConfiguration, void(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config));
|
||||
MOCK_METHOD2(UpdateViewportConfig, void(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason));
|
||||
MOCK_METHOD1(UpdateWindowMode, void(OHOS::Rosen::WindowMode mode));
|
||||
MOCK_METHOD2(UpdateWindowMode, void(OHOS::Rosen::WindowMode mode, bool hasDeco));
|
||||
MOCK_METHOD3(HideWindowTitleButton, void(bool hideSplit, bool hideMaximize, bool hideMinimize));
|
||||
MOCK_METHOD0(GetBackgroundColor, uint32_t());
|
||||
MOCK_METHOD1(SetBackgroundColor, void(uint32_t color));
|
||||
@ -66,6 +66,13 @@ public:
|
||||
MOCK_METHOD1(NotifyMemoryLevel, void(int32_t level));
|
||||
MOCK_METHOD1(SetAppWindowTitle, void(const std::string& title));
|
||||
MOCK_METHOD1(SetAppWindowIcon, void(const std::shared_ptr<Media::PixelMap>& pixelMap));
|
||||
MOCK_METHOD0(GetCardRootNode, std::shared_ptr<Rosen::RSSurfaceNode>());
|
||||
MOCK_METHOD1(ProcessFormUpdate, void(const std::string& data));
|
||||
MOCK_METHOD1(SetFormWidth, void(const float width));
|
||||
MOCK_METHOD1(SetFormHeight, void(const float height));
|
||||
MOCK_METHOD0(GetFormWidth, float());
|
||||
MOCK_METHOD0(GetFormHeight, float());
|
||||
MOCK_METHOD1(SetActionEventHandler, void(std::function<void(const std::string& action)>&& actionCallback));
|
||||
};
|
||||
} // namespace Ace
|
||||
} // 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,12 +43,14 @@ 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));
|
||||
MOCK_METHOD1(RaiseToAppTop, WmErrorCode(uint32_t windowId));
|
||||
MOCK_METHOD1(GetSystemConfig, WMError(SystemConfig& systemConfig));
|
||||
};
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
@ -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) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <iremote_broker.h>
|
||||
#include <iservice_registry.h>
|
||||
#include <securec.h>
|
||||
#include <set>
|
||||
#include <system_ability_definition.h>
|
||||
|
||||
#include "display_manager_interface.h"
|
||||
@ -60,6 +61,13 @@ std::pair<sptr<IDisplayManager>, sptr<IRemoteObject>> GetProxy()
|
||||
|
||||
bool IPCFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
std::set<uint32_t> ignore = {
|
||||
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN),
|
||||
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE),
|
||||
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND),
|
||||
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR),
|
||||
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT)
|
||||
};
|
||||
uint32_t code;
|
||||
int flags, waitTime;
|
||||
if (data == nullptr || size < sizeof(code) + sizeof(flags) + sizeof(waitTime)) {
|
||||
@ -76,7 +84,11 @@ bool IPCFuzzTest(const uint8_t* data, size_t size)
|
||||
MessageParcel sendData;
|
||||
MessageParcel reply;
|
||||
MessageOption option(flags, waitTime);
|
||||
sendData.WriteBuffer(data + startPos, size - startPos);
|
||||
if (ignore.find(code) != ignore.end()) {
|
||||
return false;
|
||||
}
|
||||
uint32_t dataSize = (size - startPos) > 1024 * 1024 ? 1024 * 1024 : (size - startPos);
|
||||
sendData.WriteBuffer(data + startPos, dataSize);
|
||||
proxy.second->SendRequest(code, sendData, reply, option);
|
||||
return true;
|
||||
}
|
||||
@ -90,8 +102,6 @@ void IPCSpecificInterfaceFuzzTest1(sptr<IRemoteObject> proxy, MessageParcel& sen
|
||||
sendData, reply, option);
|
||||
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN),
|
||||
sendData, reply, option);
|
||||
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT),
|
||||
sendData, reply, option);
|
||||
proxy->SendRequest(
|
||||
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT),
|
||||
sendData, reply, option);
|
||||
@ -135,10 +145,14 @@ void IPCSpecificInterfaceFuzzTest1(sptr<IRemoteObject> proxy, MessageParcel& sen
|
||||
}
|
||||
|
||||
void IPCSpecificInterfaceFuzzTest2(sptr<IRemoteObject> proxy, MessageParcel& sendData, MessageParcel& reply,
|
||||
MessageOption& option)
|
||||
MessageOption& option, sptr<IDisplayManager> manager)
|
||||
{
|
||||
int flags = option.GetFlags();
|
||||
option.SetFlags(MessageOption::TF_SYNC);
|
||||
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN),
|
||||
sendData, reply, option);
|
||||
manager->DestroyVirtualScreen(static_cast<ScreenId>(reply.ReadUint64()));
|
||||
option.SetFlags(flags);
|
||||
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN),
|
||||
sendData, reply, option);
|
||||
proxy->SendRequest(
|
||||
@ -197,9 +211,10 @@ bool IPCInterfaceFuzzTest(const uint8_t* data, size_t size)
|
||||
MessageParcel reply;
|
||||
MessageOption option(flags, waitTime);
|
||||
sendData.WriteInterfaceToken(proxy.first->GetDescriptor());
|
||||
sendData.WriteBuffer(data + startPos, size - startPos);
|
||||
uint32_t dataSize = (size - startPos) > 1024 * 1024 ? 1024 * 1024 : (size - startPos);
|
||||
sendData.WriteBuffer(data + startPos, dataSize);
|
||||
IPCSpecificInterfaceFuzzTest1(proxy.second, sendData, reply, option);
|
||||
IPCSpecificInterfaceFuzzTest2(proxy.second, sendData, reply, option);
|
||||
IPCSpecificInterfaceFuzzTest2(proxy.second, sendData, reply, option, proxy.first);
|
||||
return true;
|
||||
}
|
||||
} // namespace.OHOS::Rosen
|
||||
|
@ -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());
|
||||
|
||||
|
@ -96,6 +96,9 @@ sptr<Window> DisplayManagerTest::CreateWindow(std::string name, WindowMode mode,
|
||||
option->SetWindowMode(mode);
|
||||
option->SetWindowName(name);
|
||||
sptr<Window> window = Window::Create(option->GetWindowName(), option);
|
||||
if (window == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
window->AddWindowFlag(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
|
||||
window->Show();
|
||||
sleep(WAIT_FOR_SYNC_US); // wait for rect updated
|
||||
@ -128,12 +131,12 @@ namespace {
|
||||
HWTEST_F(DisplayManagerTest, HasPrivateWindow, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<Window> window = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
|
||||
ASSERT_NE(nullptr, window);
|
||||
window->SetPrivacyMode(true);
|
||||
sleep(WAIT_FOR_SYNC_US);
|
||||
bool hasPrivateWindow = false;
|
||||
DisplayId id = DisplayManager::GetInstance().GetDefaultDisplayId();
|
||||
DisplayManager::GetInstance().HasPrivateWindow(id, hasPrivateWindow);
|
||||
ASSERT_TRUE(hasPrivateWindow);
|
||||
|
||||
window->SetPrivacyMode(false);
|
||||
sleep(WAIT_FOR_SYNC_US);
|
||||
@ -151,14 +154,15 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindow, Function | SmallTest | Level2)
|
||||
HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<Window> window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
|
||||
ASSERT_NE(nullptr, window1);
|
||||
// 10:rect.posX_, 120:rect.posY_, 650:rect.width, 500:rect.height
|
||||
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, Rect {10, 120, 650, 500});
|
||||
ASSERT_NE(nullptr, window2);
|
||||
window2->SetPrivacyMode(true);
|
||||
// 10:rect.posX_, 110:rect.posY_, 650:rect.width, 500:rect.height
|
||||
sptr<Window> window3 = CreateWindow("covered", WindowMode::WINDOW_MODE_FLOATING, Rect {10, 120, 650, 500});
|
||||
ASSERT_NE(nullptr, window1);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
ASSERT_NE(nullptr, window3);
|
||||
|
||||
sleep(WAIT_FOR_SYNC_US);
|
||||
bool hasPrivateWindow = false;
|
||||
DisplayId id = DisplayManager::GetInstance().GetDefaultDisplayId();
|
||||
@ -178,14 +182,15 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered, Function | SmallTest | Lev
|
||||
HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<Window> window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
|
||||
ASSERT_NE(nullptr, window1);
|
||||
// 10:rect.posX_, 120:rect.posY_, 650:rect.width, 500:rect.height
|
||||
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, Rect {10, 120, 650, 500});
|
||||
ASSERT_NE(nullptr, window2);
|
||||
window2->SetPrivacyMode(true);
|
||||
// 5:rect.posX_, 110:rect.posY_, 650:rect.width, 500:rect.height
|
||||
sptr<Window> window3 = CreateWindow("covered", WindowMode::WINDOW_MODE_FLOATING, Rect {5, 110, 650, 500});
|
||||
ASSERT_NE(nullptr, window1);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
ASSERT_NE(nullptr, window3);
|
||||
|
||||
sleep(WAIT_FOR_SYNC_US);
|
||||
bool hasPrivateWindow = false;
|
||||
DisplayId id = DisplayManager::GetInstance().GetDefaultDisplayId();
|
||||
@ -210,20 +215,21 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered02, Function | SmallTest | L
|
||||
uint32_t baseWidth = vpr * MIN_FLOATING_WIDTH;
|
||||
|
||||
sptr<Window> window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
|
||||
ASSERT_NE(nullptr, window1);
|
||||
// 10:rect.posX_, 120:rect.posY_, 650:rect.width, 500:rect.height
|
||||
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING,
|
||||
Rect {10, 220, baseWidth + 10, 500});
|
||||
ASSERT_NE(nullptr, window2);
|
||||
window2->SetPrivacyMode(true);
|
||||
// 5:rect.posX_, 110:rect.posY_, 655:rect.width, 500:rect.height
|
||||
sptr<Window> window3 = CreateWindow("covered1", WindowMode::WINDOW_MODE_FLOATING,
|
||||
Rect {5, 210, baseWidth + 15, 500});
|
||||
ASSERT_NE(nullptr, window3);
|
||||
// 5:rect.posX_, 300:rect.posY_, 655:rect.width, 500:rect.height
|
||||
sptr<Window> window4 = CreateWindow("covered2", WindowMode::WINDOW_MODE_FLOATING,
|
||||
Rect {5, 400, baseWidth + 15, 500});
|
||||
ASSERT_NE(nullptr, window1);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
ASSERT_NE(nullptr, window3);
|
||||
ASSERT_NE(nullptr, window4);
|
||||
|
||||
sleep(WAIT_FOR_SYNC_US);
|
||||
bool hasPrivateWindow = false;
|
||||
DisplayId id = DisplayManager::GetInstance().GetDefaultDisplayId();
|
||||
@ -244,17 +250,18 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered02, Function | SmallTest | L
|
||||
HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered03, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<Window> window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
|
||||
ASSERT_NE(nullptr, window1);
|
||||
// 10:rect.posX_, 120:rect.pos_Y, rect.width_:650, rect.height_:700
|
||||
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, Rect {10, 120, 650, 700});
|
||||
ASSERT_NE(nullptr, window2);
|
||||
window2->SetPrivacyMode(true);
|
||||
// 5:rect.posX_, 110:rect.pos_Y, rect.width_:655, rect.height_:500
|
||||
sptr<Window> window3 = CreateWindow("covered1", WindowMode::WINDOW_MODE_FLOATING, Rect {5, 110, 655, 500});
|
||||
ASSERT_NE(nullptr, window3);
|
||||
// 5:rect.posX_, 700:rect.pos_Y, rect.width_:655, rect.height_:500
|
||||
sptr<Window> window4 = CreateWindow("covered2", WindowMode::WINDOW_MODE_FLOATING, Rect {5, 700, 655, 500});
|
||||
ASSERT_NE(nullptr, window1);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
ASSERT_NE(nullptr, window3);
|
||||
ASSERT_NE(nullptr, window4);
|
||||
|
||||
sleep(WAIT_FOR_SYNC_US);
|
||||
bool hasPrivateWindow = false;
|
||||
DisplayId id = DisplayManager::GetInstance().GetDefaultDisplayId();
|
||||
@ -275,10 +282,11 @@ HWTEST_F(DisplayManagerTest, HasPrivateWindowCovered03, Function | SmallTest | L
|
||||
HWTEST_F(DisplayManagerTest, HasPrivateWindowSkipSnapShot, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<Window> window1 = CreateWindow("test", WindowMode::WINDOW_MODE_FULLSCREEN, Rect {0, 0, 0, 0});
|
||||
ASSERT_NE(nullptr, window1);
|
||||
// 10:rect.posX_, 120:rect.posY_, 650:rect.width, 500:rect.height
|
||||
sptr<Window> window2 = CreateWindow("private", WindowMode::WINDOW_MODE_FLOATING, Rect {10, 120, 650, 500});
|
||||
ASSERT_NE(nullptr, window1);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
|
||||
window2->SetSnapshotSkip(true);
|
||||
sleep(WAIT_FOR_SYNC_US);
|
||||
bool hasPrivateWindow = false;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <parameters.h>
|
||||
|
||||
#include "common_test_utils.h"
|
||||
#include "display_test_utils.h"
|
||||
@ -106,8 +105,8 @@ sptr<Display> ScreenManagerTest::defaultDisplay_ = nullptr;
|
||||
DisplayId ScreenManagerTest::defaultDisplayId_ = DISPLAY_ID_INVALID;
|
||||
ScreenId ScreenManagerTest::defaultScreenId_ = INVALID_SCREEN_ID;
|
||||
std::string ScreenManagerTest::defaultName_ = "virtualScreen01";
|
||||
uint32_t ScreenManagerTest::defaultWidth_ = 480;
|
||||
uint32_t ScreenManagerTest::defaultHeight_ = 320;
|
||||
uint32_t ScreenManagerTest::defaultWidth_ = 2560;
|
||||
uint32_t ScreenManagerTest::defaultHeight_ = 1600;
|
||||
float ScreenManagerTest::defaultDensity_ = 2.0;
|
||||
int32_t ScreenManagerTest::defaultFlags_ = 0;
|
||||
VirtualScreenOption ScreenManagerTest::defaultOption_ = {
|
||||
@ -175,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) { \
|
||||
@ -282,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);
|
||||
@ -326,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);
|
||||
@ -352,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_) {
|
||||
@ -389,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);
|
||||
|
||||
@ -398,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_) {
|
||||
@ -430,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));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -454,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,
|
||||
@ -485,7 +491,8 @@ HWTEST_F(ScreenManagerTest, ScreenManager08, Function | MediumTest | Level2)
|
||||
*/
|
||||
HWTEST_F(ScreenManagerTest, ScreenManager09, Function | MediumTest | Level2)
|
||||
{
|
||||
system::SetParameter("rosen.uni.partialrender.enabled", "0");
|
||||
(void)system("param set rosen.uni.partialrender.enabled 0");
|
||||
|
||||
DisplayTestUtils utils;
|
||||
ASSERT_TRUE(utils.CreateSurface());
|
||||
defaultOption_.surface_ = utils.psurface_;
|
||||
@ -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);
|
||||
@ -524,7 +532,8 @@ HWTEST_F(ScreenManagerTest, ScreenManager09, Function | MediumTest | Level2)
|
||||
window->Show();
|
||||
sleep(TEST_SLEEP_S_LONG);
|
||||
window->Destroy();
|
||||
system::SetParameter("rosen.uni.partialrender.enabled", "4");
|
||||
|
||||
(void)system("param set rosen.uni.partialrender.enabled 4");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -576,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,
|
||||
@ -624,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);
|
||||
@ -666,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,
|
||||
@ -713,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,
|
||||
@ -726,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);
|
||||
@ -766,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,
|
||||
@ -775,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,
|
||||
@ -807,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);
|
||||
@ -856,14 +876,95 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: VirtualExpandScreen01
|
||||
* @tc.desc: Create virtual expand screen and rotate.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScreenManagerTest, VirtualExpandScreen01, Function | MediumTest | Level1)
|
||||
{
|
||||
(void)system("param set rosen.uni.partialrender.enabled 0");
|
||||
|
||||
DisplayTestUtils utils;
|
||||
ASSERT_TRUE(utils.CreateSurface());
|
||||
defaultOption_.surface_ = utils.psurface_;
|
||||
defaultOption_.isForShot_ = true;
|
||||
|
||||
CHECK_TEST_INIT_SCREEN_STATE
|
||||
ScreenId virtualScreenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption_);
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
CHECK_SCREEN_STATE_AFTER_CREATE_VIRTUAL_SCREEN
|
||||
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, expansionId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
CheckScreenGroupState(ScreenCombination::SCREEN_EXPAND, ScreenGroupChangeEvent::ADD_TO_GROUP,
|
||||
virtualScreenId, group, screenGroupChangeListener);
|
||||
CheckScreenStateInGroup(true, group, groupId, virtualScreen, virtualScreenId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_NE(SCREEN_ID_INVALID, expansionId);
|
||||
DisplayId virtualDisplayId = DisplayManager::GetInstance().GetDisplayByScreen(virtualScreenId)->GetId();
|
||||
ASSERT_NE(DISPLAY_ID_INVALID, virtualDisplayId);
|
||||
|
||||
sptr<Window> window = CreateWindowByDisplayId(virtualDisplayId);
|
||||
ASSERT_NE(nullptr, window);
|
||||
ASSERT_EQ(true, DrawWindowColor(window, COLOR_RED));
|
||||
|
||||
window->Show();
|
||||
sleep(TEST_SLEEP_S_LONG);
|
||||
|
||||
const std::string rsCmd = "snapshot_display -i " + std::to_string(virtualDisplayId);
|
||||
(void)system(rsCmd.c_str());
|
||||
|
||||
auto screen = ScreenManager::GetInstance().GetScreenById(virtualScreenId);
|
||||
ASSERT_TRUE(screen);
|
||||
auto display = DisplayManager::GetInstance().GetDisplayByScreen(virtualScreenId);
|
||||
ASSERT_TRUE(display);
|
||||
|
||||
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);
|
||||
usleep(1E6);
|
||||
ASSERT_EQ(static_cast<uint32_t>(screen->GetOrientation()), orientation);
|
||||
ASSERT_EQ(static_cast<uint32_t>(display->GetOrientation()), orientation);
|
||||
(void)system(rsCmd.c_str());
|
||||
sleep(TEST_SLEEP_S);
|
||||
}
|
||||
screen->SetOrientation(Orientation::UNSPECIFIED);
|
||||
ASSERT_EQ(static_cast<uint32_t>(screen->GetOrientation()), static_cast<uint32_t>(Orientation::UNSPECIFIED));
|
||||
ASSERT_EQ(static_cast<uint32_t>(display->GetOrientation()), static_cast<uint32_t>(Orientation::UNSPECIFIED));
|
||||
|
||||
window->Destroy();
|
||||
DMError res = ScreenManager::GetInstance().DestroyVirtualScreen(virtualScreenId);
|
||||
sleep(TEST_SLEEP_S);
|
||||
ASSERT_EQ(DMError::DM_OK, res);
|
||||
|
||||
ScreenManager::GetInstance().UnregisterScreenListener(screenListener);
|
||||
ScreenManager::GetInstance().UnregisterScreenGroupListener(screenGroupChangeListener);
|
||||
ScreenManager::GetInstance().UnregisterVirtualScreenGroupListener(virtualScreenGroupChangeListener);
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
(void)system("param set rosen.uni.partialrender.enabled 4");
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -36,6 +36,7 @@ group("systemtest") {
|
||||
":wms_window_move_drag_test",
|
||||
":wms_window_multi_ability_test",
|
||||
":wms_window_occupied_area_change_test",
|
||||
":wms_window_raisetoapptop_test",
|
||||
":wms_window_rotation_test",
|
||||
":wms_window_split_immersive_test",
|
||||
":wms_window_split_test",
|
||||
@ -190,6 +191,14 @@ ohos_systemtest("wms_window_drag_test") {
|
||||
deps = [ ":wms_systemtest_common" ]
|
||||
}
|
||||
|
||||
ohos_systemtest("wms_window_raisetoapptop_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "window_raisetoapptop_test.cpp" ]
|
||||
|
||||
deps = [ ":wms_systemtest_common" ]
|
||||
}
|
||||
|
||||
ohos_systemtest("wms_window_rotation_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
|
@ -24,7 +24,7 @@ using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using Utils = WindowTestUtils;
|
||||
const int WAIT_CALLBACK_US = 100000; // 100000 us
|
||||
const int WAIT_CALLBACK_US = 1; // 1s
|
||||
|
||||
class TestDragListener : public IWindowDragListener {
|
||||
public:
|
||||
@ -52,6 +52,7 @@ public:
|
||||
Utils::TestWindowInfo dragWindowInfo_;
|
||||
Utils::TestWindowInfo firstWindowInfo_;
|
||||
Utils::TestWindowInfo secondWindowInfo_;
|
||||
std::vector<sptr<Window>> activeWindows_;
|
||||
};
|
||||
|
||||
sptr<TestDragListener> WindowDragTest::firstWindowDragListener_ =
|
||||
@ -94,9 +95,15 @@ void WindowDragTest::SetUp()
|
||||
.parentLimit = false,
|
||||
.parentId = INVALID_WINDOW_ID,
|
||||
};
|
||||
activeWindows_.clear();
|
||||
}
|
||||
|
||||
void WindowDragTest::TearDown() {}
|
||||
void WindowDragTest::TearDown() {
|
||||
while (!activeWindows_.empty()) {
|
||||
ASSERT_EQ(WMError::WM_OK, activeWindows_.back()->Destroy());
|
||||
activeWindows_.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
@ -113,14 +120,16 @@ HWTEST_F(WindowDragTest, DragIn, Function | MediumTest | Level3) {
|
||||
const sptr<Window> &dragWindow = Utils::CreateTestWindow(dragWindowInfo_);
|
||||
dragWindow->Show();
|
||||
dragWindow->MoveTo(300, 300);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
sleep(WAIT_CALLBACK_US);
|
||||
|
||||
activeWindows_.push_back(firstWindow);
|
||||
activeWindows_.push_back(dragWindow);
|
||||
|
||||
ASSERT_EQ(300, firstWindowDragListener_->point_.x);
|
||||
ASSERT_EQ(300, firstWindowDragListener_->point_.y);
|
||||
ASSERT_EQ(DragEvent::DRAG_EVENT_IN, firstWindowDragListener_->event_);
|
||||
|
||||
dragWindow->Destroy();
|
||||
firstWindow->UnregisterDragListener(firstWindowDragListener_);
|
||||
firstWindow->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,20 +146,22 @@ HWTEST_F(WindowDragTest, DragMove, Function | MediumTest | Level3) {
|
||||
const sptr<Window> &dragWindow = Utils::CreateTestWindow(dragWindowInfo_);
|
||||
dragWindow->Show();
|
||||
dragWindow->MoveTo(300, 300);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
|
||||
activeWindows_.push_back(firstWindow);
|
||||
activeWindows_.push_back(dragWindow);
|
||||
|
||||
sleep(WAIT_CALLBACK_US);
|
||||
ASSERT_EQ(300, firstWindowDragListener_->point_.x);
|
||||
ASSERT_EQ(300, firstWindowDragListener_->point_.y);
|
||||
ASSERT_EQ(DragEvent::DRAG_EVENT_IN, firstWindowDragListener_->event_);
|
||||
|
||||
dragWindow->MoveTo(400, 400);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
sleep(WAIT_CALLBACK_US);
|
||||
ASSERT_EQ(400, firstWindowDragListener_->point_.x);
|
||||
ASSERT_EQ(400, firstWindowDragListener_->point_.y);
|
||||
ASSERT_EQ(DragEvent::DRAG_EVENT_MOVE, firstWindowDragListener_->event_);
|
||||
|
||||
dragWindow->Destroy();
|
||||
firstWindow->UnregisterDragListener(firstWindowDragListener_);
|
||||
firstWindow->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,29 +183,31 @@ HWTEST_F(WindowDragTest, DragOut, Function | MediumTest | Level3) {
|
||||
const sptr<Window> &dragWindow = Utils::CreateTestWindow(dragWindowInfo_);
|
||||
dragWindow->Show();
|
||||
dragWindow->MoveTo(300, 300);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
|
||||
activeWindows_.push_back(firstWindow);
|
||||
activeWindows_.push_back(secondWindow);
|
||||
activeWindows_.push_back(dragWindow);
|
||||
|
||||
sleep(WAIT_CALLBACK_US);
|
||||
ASSERT_EQ(300, firstWindowDragListener_->point_.x);
|
||||
ASSERT_EQ(300, firstWindowDragListener_->point_.y);
|
||||
ASSERT_EQ(DragEvent::DRAG_EVENT_IN, firstWindowDragListener_->event_);
|
||||
|
||||
dragWindow->MoveTo(400, 400);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
sleep(WAIT_CALLBACK_US);
|
||||
ASSERT_EQ(400, firstWindowDragListener_->point_.x);
|
||||
ASSERT_EQ(400, firstWindowDragListener_->point_.y);
|
||||
ASSERT_EQ(DragEvent::DRAG_EVENT_MOVE, firstWindowDragListener_->event_);
|
||||
|
||||
dragWindow->MoveTo(600, 600);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
sleep(WAIT_CALLBACK_US);
|
||||
ASSERT_EQ(100, secondWindowDragListener_->point_.x);
|
||||
ASSERT_EQ(100, secondWindowDragListener_->point_.y);
|
||||
ASSERT_EQ(DragEvent::DRAG_EVENT_IN, secondWindowDragListener_->event_);
|
||||
ASSERT_EQ(DragEvent::DRAG_EVENT_OUT, firstWindowDragListener_->event_);
|
||||
|
||||
dragWindow->Destroy();
|
||||
firstWindow->UnregisterDragListener(firstWindowDragListener_);
|
||||
secondWindow->UnregisterDragListener(secondWindowDragListener_);
|
||||
firstWindow->Destroy();
|
||||
secondWindow->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,18 +216,23 @@ HWTEST_F(WindowDragTest, DragOut, Function | MediumTest | Level3) {
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowDragTest, DragEnd, Function | MediumTest | Level3) {
|
||||
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
|
||||
const sptr<Window> firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
|
||||
ASSERT_NE(nullptr, firstWindow);
|
||||
firstWindow->RegisterDragListener(firstWindowDragListener_);
|
||||
firstWindow->SetTurnScreenOn(true);
|
||||
firstWindow->Show();
|
||||
|
||||
const sptr<Window> &dragWindow = Utils::CreateTestWindow(dragWindowInfo_);
|
||||
const sptr<Window> dragWindow = Utils::CreateTestWindow(dragWindowInfo_);
|
||||
ASSERT_NE(nullptr, dragWindow);
|
||||
dragWindow->Show();
|
||||
dragWindow->MoveTo(199, 199);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
|
||||
|
||||
sleep(WAIT_CALLBACK_US);
|
||||
dragWindow->Destroy();
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
sleep(WAIT_CALLBACK_US);
|
||||
ASSERT_EQ(DragEvent::DRAG_EVENT_END, firstWindowDragListener_->event_);
|
||||
|
||||
firstWindow->UnregisterDragListener(firstWindowDragListener_);
|
||||
firstWindow->Destroy();
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ HWTEST_F(WindowEffectTest, WindowEffect01, Function | MediumTest | Level3)
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetCornerRadius(0.0));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetCornerRadius(16.0));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetCornerRadius(1000.0));
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetCornerRadius(-1.0));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetCornerRadius(-1.0));
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->Destroy());
|
||||
}
|
||||
|
227
test/systemtest/wms/window_raisetoapptop_test.cpp
Normal file
227
test/systemtest/wms/window_raisetoapptop_test.cpp
Normal file
@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// gtest
|
||||
#include <gtest/gtest.h>
|
||||
#include "window_test_utils.h"
|
||||
|
||||
#include "window_impl.h"
|
||||
#include "wm_common.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using Utils = WindowTestUtils;
|
||||
class WindowRaiseToAppTopTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
std::vector<sptr<Window>> activeWindows_;
|
||||
Utils::TestWindowInfo fullInfo_;
|
||||
private:
|
||||
static constexpr uint32_t TEST_SLEEP_S = 1;
|
||||
};
|
||||
|
||||
void WindowRaiseToAppTopTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowRaiseToAppTopTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowRaiseToAppTopTest::SetUp()
|
||||
{
|
||||
fullInfo_ = {
|
||||
.name = "",
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.parentId = INVALID_WINDOW_ID,
|
||||
};
|
||||
activeWindows_.clear();
|
||||
}
|
||||
|
||||
void WindowRaiseToAppTopTest::TearDown()
|
||||
{
|
||||
while (!activeWindows_.empty()) {
|
||||
ASSERT_EQ(WMError::WM_OK, activeWindows_.back()->Destroy());
|
||||
activeWindows_.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: WindowRaiseToAppTopTest1
|
||||
* @tc.desc: to raise to app top, normal
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowRaiseToAppTopTest, NormalRaise1, Function | MediumTest | Level3)
|
||||
{
|
||||
fullInfo_.name = "mainWindow.1";
|
||||
sptr<Window> mainWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow);
|
||||
activeWindows_.push_back(mainWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
fullInfo_.name = "subWindow.1";
|
||||
fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
|
||||
fullInfo_.parentId = mainWindow->GetWindowId();
|
||||
sptr<Window> subWindow1 = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, subWindow1);
|
||||
activeWindows_.push_back(subWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow1->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
fullInfo_.name = "subWindow.2";
|
||||
fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
|
||||
fullInfo_.parentId = mainWindow->GetWindowId();
|
||||
sptr<Window> subWindow2 = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, subWindow2);
|
||||
activeWindows_.push_back(subWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow2->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
auto result1 = mainWindow->RaiseToAppTop();
|
||||
ASSERT_EQ(WmErrorCode::WM_ERROR_INVALID_PARENT, result1);
|
||||
auto result2 = subWindow1->RaiseToAppTop();
|
||||
ASSERT_EQ(WmErrorCode::WM_OK, result2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowRaiseToAppTopTest2
|
||||
* @tc.desc: to raise to app top, with dialog
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowRaiseToAppTopTest, RaiseWithDialog1, Function | MediumTest | Level3)
|
||||
{
|
||||
fullInfo_.name = "mainWindow.1";
|
||||
sptr<Window> mainWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow);
|
||||
activeWindows_.push_back(mainWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
fullInfo_.name = "subWindow.1";
|
||||
fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
|
||||
fullInfo_.parentId = mainWindow->GetWindowId();
|
||||
sptr<Window> subWindow1 = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, subWindow1);
|
||||
activeWindows_.push_back(subWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow1->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
fullInfo_.name = "subWindow.2";
|
||||
fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
|
||||
fullInfo_.parentId = mainWindow->GetWindowId();
|
||||
sptr<Window> subWindow2 = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, subWindow2);
|
||||
activeWindows_.push_back(subWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow2->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
fullInfo_.name = "dialog.2";
|
||||
fullInfo_.type = WindowType::WINDOW_TYPE_DIALOG;
|
||||
fullInfo_.parentId = INVALID_WINDOW_ID;
|
||||
sptr<Window> dialog = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, dialog);
|
||||
activeWindows_.push_back(dialog);
|
||||
ASSERT_EQ(WMError::WM_OK, dialog->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
auto result = subWindow1->RaiseToAppTop();
|
||||
ASSERT_EQ(WmErrorCode::WM_OK, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowRaiseToAppTopTest3
|
||||
* @tc.desc: to raise to app top, in hide
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowRaiseToAppTopTest, RaiseWhenHide, Function | MediumTest | Level3)
|
||||
{
|
||||
fullInfo_.name = "mainWindow.1";
|
||||
sptr<Window> mainWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow);
|
||||
activeWindows_.push_back(mainWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
fullInfo_.name = "subWindow.1";
|
||||
fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
|
||||
fullInfo_.parentId = mainWindow->GetWindowId();
|
||||
sptr<Window> subWindow1 = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, subWindow1);
|
||||
activeWindows_.push_back(subWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow1->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
fullInfo_.name = "subWindow.2";
|
||||
fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
|
||||
fullInfo_.parentId = mainWindow->GetWindowId();
|
||||
sptr<Window> subWindow2 = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, subWindow2);
|
||||
activeWindows_.push_back(subWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow2->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow->Hide());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
auto result = subWindow1->RaiseToAppTop();
|
||||
ASSERT_EQ(WmErrorCode::WM_OK, result);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow1->Hide());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
result = subWindow1->RaiseToAppTop();
|
||||
ASSERT_EQ(WmErrorCode::WM_ERROR_STATE_ABNORMALLY, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowRaiseToAppTopTest3
|
||||
* @tc.desc: to raise to app top, not app subwindow
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowRaiseToAppTopTest, NotAppSubWindow, Function | MediumTest | Level3)
|
||||
{
|
||||
fullInfo_.name = "mainWindow.1";
|
||||
fullInfo_.type = WindowType::WINDOW_TYPE_FLOAT;
|
||||
sptr<Window> mainWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow);
|
||||
activeWindows_.push_back(mainWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
fullInfo_.name = "subWindow.1";
|
||||
fullInfo_.type = WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW;
|
||||
fullInfo_.parentId = mainWindow->GetWindowId();
|
||||
sptr<Window> subWindow1 = Utils::CreateTestWindow(fullInfo_);
|
||||
ASSERT_NE(nullptr, subWindow1);
|
||||
activeWindows_.push_back(subWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow1->Show());
|
||||
sleep(TEST_SLEEP_S);
|
||||
|
||||
auto result = subWindow1->RaiseToAppTop();
|
||||
ASSERT_EQ(WmErrorCode::WM_ERROR_INVALID_CALLING, result);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -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);
|
||||
|
@ -36,6 +36,7 @@ ohos_shared_library("libwmutil") {
|
||||
"src/display_info.cpp",
|
||||
"src/perform_reporter.cpp",
|
||||
"src/permission.cpp",
|
||||
"src/persistent_storage.cpp",
|
||||
"src/screen_group_info.cpp",
|
||||
"src/screen_info.cpp",
|
||||
"src/screenshot_info.cpp",
|
||||
@ -67,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",
|
||||
@ -76,6 +78,7 @@ ohos_shared_library("libwmutil") {
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_core",
|
||||
"multimedia_image_framework:image_native",
|
||||
"preferences:native_preferences",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
part_name = "window_manager"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -39,7 +39,7 @@ struct DMRect {
|
||||
return !this->operator==(a);
|
||||
}
|
||||
|
||||
bool isUninitializedRect() const
|
||||
bool IsUninitializedRect() const
|
||||
{
|
||||
return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
|
||||
}
|
||||
@ -59,8 +59,8 @@ struct WaterfallDisplayAreaRects {
|
||||
|
||||
bool isUninitialized() const
|
||||
{
|
||||
return (left.isUninitializedRect() && top.isUninitializedRect() && right.isUninitializedRect() &&
|
||||
bottom.isUninitializedRect());
|
||||
return (left.IsUninitializedRect() && top.IsUninitializedRect() && right.IsUninitializedRect() &&
|
||||
bottom.IsUninitializedRect());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(int32_t, OffsetY, offsetY, 0);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(DisplayState, DisplayState, displayState, DisplayState::UNKNOWN);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, WaterfallDisplayCompressionStatus, waterfallDisplayCompressionStatus, false);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(DisplayOrientation, DisplayOrientation, displayOrientation,
|
||||
DisplayOrientation::UNKNOWN);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // FOUNDATION_DMSERVER_DISPLAY_INFO_H
|
81
utils/include/persistent_storage.h
Normal file
81
utils/include/persistent_storage.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ROSEN_WINDOW_PERSISTENT_STORAGE_H
|
||||
#define OHOS_ROSEN_WINDOW_PERSISTENT_STORAGE_H
|
||||
|
||||
#include "preferences.h"
|
||||
#include "preferences_helper.h"
|
||||
|
||||
#include "window_manager_hilog.h"
|
||||
#include "wm_common_inner.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using PersistentPerference = NativePreferences::Preferences;
|
||||
class PersistentStorage {
|
||||
public:
|
||||
PersistentStorage() = default;
|
||||
~PersistentStorage() = default;
|
||||
|
||||
template <typename T>
|
||||
static void Insert(const std::string& key, const T& value, PersistentStorageType storageType)
|
||||
{
|
||||
auto pref = GetPreference(storageType);
|
||||
if (!pref) {
|
||||
WLOG_E("[PersistentStorage] Preferences is nullptr");
|
||||
return;
|
||||
}
|
||||
switch (storageType) {
|
||||
case PersistentStorageType::ASPECT_RATIO: {
|
||||
pref->PutFloat(key, value);
|
||||
WLOG_D("[PersistentStorage] Insert aspect ratio, key %{public}s, value %{public}f", key.c_str(), value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WLOG_W("[PersistentStorage] Unknown storage type!");
|
||||
}
|
||||
pref->Flush();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void Get(const std::string& key, T& value, PersistentStorageType storageType)
|
||||
{
|
||||
auto pref = GetPreference(storageType);
|
||||
if (!pref) {
|
||||
WLOG_E("[PersistentStorage] Preferences is nullptr");
|
||||
return;
|
||||
}
|
||||
switch (storageType) {
|
||||
case PersistentStorageType::ASPECT_RATIO: {
|
||||
value = pref->GetFloat(key);
|
||||
WLOG_D("[PersistentStorage] Get aspect ratio, key: %{public}s, value:%{public}f", key.c_str(), value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WLOG_W("[PersistentStorage] Unknown storage type!");
|
||||
}
|
||||
}
|
||||
|
||||
static bool HasKey(const std::string& key, PersistentStorageType storageType);
|
||||
static void Delete(const std::string& key, PersistentStorageType storageType);
|
||||
|
||||
private:
|
||||
static std::shared_ptr<PersistentPerference> GetPreference(PersistentStorageType storageType);
|
||||
static std::map<PersistentStorageType, std::string> storagePath_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ROSEN_WINDOW_PERSISTENT_STORAGE_H
|
@ -47,6 +47,7 @@ public:
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, IsScreenGroup, isScreenGroup, false);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(Rotation, Rotation, rotation, Rotation::ROTATION_0);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, Orientation, orientation, Orientation::UNSPECIFIED);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(ScreenSourceMode, SourceMode, sourceMode, ScreenSourceMode::SCREEN_ALONE);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(ScreenType, Type, type, ScreenType::UNDEFINED);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(uint32_t, ModeId, modeId, 0);
|
||||
DEFINE_VAR_FUNC_GET(std::vector<sptr<SupportedScreenModes>>, Modes, modes);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -66,6 +66,11 @@ public:
|
||||
return (type >= WindowType::SYSTEM_SUB_WINDOW_BASE && type < WindowType::SYSTEM_SUB_WINDOW_END);
|
||||
}
|
||||
|
||||
static inline bool IsSystemMainWindow(WindowType type)
|
||||
{
|
||||
return IsBelowSystemWindow(type) || IsAboveSystemWindow(type);
|
||||
}
|
||||
|
||||
static inline bool IsSystemWindow(WindowType type)
|
||||
{
|
||||
return (IsBelowSystemWindow(type) || IsAboveSystemWindow(type) || IsSystemSubWindow(type));
|
||||
@ -521,6 +526,33 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool IsAspectRatioSatisfiedWithSizeLimits(const WindowSizeLimits& sizeLimits, float ratio, float vpr)
|
||||
{
|
||||
/*
|
||||
* 1) Usually the size limits won't be empty after show window.
|
||||
* In case of SetAspectRatio is called befor show (size limits may be empty at that time) or the
|
||||
* sizeLimits is empty, there is no need to check ratio (layout will check), return true directly.
|
||||
* 2) ratio : 0.0 means unset aspect ratio
|
||||
*/
|
||||
if (sizeLimits.IsEmpty() || MathHelper::NearZero(ratio)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t winFrameW = static_cast<uint32_t>(WINDOW_FRAME_WIDTH * vpr) * 2; // 2 mean double decor width
|
||||
uint32_t winFrameH = static_cast<uint32_t>(WINDOW_FRAME_WIDTH * vpr) +
|
||||
static_cast<uint32_t>(WINDOW_TITLE_BAR_HEIGHT * vpr); // decor height
|
||||
uint32_t maxWidth = sizeLimits.maxWidth_ - winFrameW;
|
||||
uint32_t minWidth = sizeLimits.minWidth_ - winFrameW;
|
||||
uint32_t maxHeight = sizeLimits.maxHeight_ - winFrameH;
|
||||
uint32_t minHeight = sizeLimits.minHeight_ - winFrameH;
|
||||
float maxRatio = static_cast<float>(maxWidth) / static_cast<float>(minHeight);
|
||||
float minRatio = static_cast<float>(minWidth) / static_cast<float>(maxHeight);
|
||||
if (maxRatio < ratio || ratio < minRatio) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
WindowHelper() = default;
|
||||
~WindowHelper() = default;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -87,6 +87,7 @@ public:
|
||||
void UpdatePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
bool isNeedComputerTransform();
|
||||
void ClearTransformZAxisOffset(Transform& trans);
|
||||
void SetAspectRatio(float ratio);
|
||||
|
||||
const std::string& GetWindowName() const;
|
||||
const AbilityInfo& GetAbilityInfo() const;
|
||||
@ -132,6 +133,7 @@ public:
|
||||
WindowSizeLimits GetUpdatedSizeLimits() const;
|
||||
const TransformHelper::Matrix4& GetTransformMat() const;
|
||||
const TransformHelper::Matrix4& GetWorldTransformMat() const;
|
||||
float GetAspectRatio() const;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override;
|
||||
static WindowProperty* Unmarshalling(Parcel& parcel);
|
||||
@ -184,7 +186,7 @@ private:
|
||||
{ WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() },
|
||||
{ WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty() },
|
||||
};
|
||||
bool isDecorEnable_ { false };
|
||||
bool isDecorEnable_ { true };
|
||||
Rect originRect_ = { 0, 0, 0, 0 };
|
||||
bool isStretchable_ {false};
|
||||
DragType dragType_ = DragType::DRAG_UNDEFINED;
|
||||
@ -201,6 +203,7 @@ private:
|
||||
// if scale of trans_ is less than 1.0, zoomTrans_ may be an identity matrix
|
||||
bool isDisplayZoomOn_ {false};
|
||||
bool isAnimateWindow_ {false};
|
||||
float aspectRatio_ {0.0};
|
||||
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, RequestedOrientation, requestedOrientation, Orientation::UNSPECIFIED);
|
||||
WindowSizeLimits sizeLimits_;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -43,6 +43,7 @@ enum class WindowUpdateReason : uint32_t {
|
||||
UPDATE_RECT,
|
||||
UPDATE_FLAGS,
|
||||
UPDATE_TYPE,
|
||||
UPDATE_ASPECT_RATIO,
|
||||
NEED_SWITCH_CASCADE_END,
|
||||
UPDATE_OTHER_PROPS,
|
||||
UPDATE_TRANSFORM,
|
||||
@ -79,6 +80,7 @@ enum class PropertyChangeAction : uint32_t {
|
||||
ACTION_UPDATE_TRANSFORM_PROPERTY = 1 << 13,
|
||||
ACTION_UPDATE_ANIMATION_FLAG = 1 << 14,
|
||||
ACTION_UPDATE_PRIVACY_MODE = 1 << 15,
|
||||
ACTION_UPDATE_ASPECT_RATIO = 1 << 16,
|
||||
};
|
||||
|
||||
struct ModeChangeHotZonesConfig {
|
||||
@ -114,13 +116,15 @@ struct AppWindowEffectConfig {
|
||||
|
||||
struct SystemConfig : public Parcelable {
|
||||
bool isSystemDecorEnable_ = true;
|
||||
uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
|
||||
bool isStretchable_ = false;
|
||||
WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
|
||||
AppWindowEffectConfig effectConfig_;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override
|
||||
{
|
||||
if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_)) {
|
||||
if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) ||
|
||||
!parcel.WriteUint32(decorModeSupportInfo_)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -157,6 +161,7 @@ struct SystemConfig : public Parcelable {
|
||||
SystemConfig* config = new SystemConfig();
|
||||
config->isSystemDecorEnable_ = parcel.ReadBool();
|
||||
config->isStretchable_ = parcel.ReadBool();
|
||||
config->decorModeSupportInfo_ = parcel.ReadUint32();
|
||||
config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
|
||||
config->effectConfig_.fullScreenCornerRadius_ = parcel.ReadFloat();
|
||||
config->effectConfig_.splitCornerRadius_ = parcel.ReadFloat();
|
||||
@ -188,6 +193,11 @@ struct WindowSizeLimits {
|
||||
uint32_t minWidth, uint32_t minHeight, float maxRatio, float minRatio)
|
||||
: maxWidth_(maxWidth), maxHeight_(maxHeight),
|
||||
minWidth_(minWidth), minHeight_(minHeight), maxRatio_(maxRatio), minRatio_(minRatio) {}
|
||||
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return (maxWidth_ == 0 || minWidth_ == 0 || maxHeight_ == 0 || minHeight_ == 0);
|
||||
}
|
||||
};
|
||||
|
||||
struct ModeChangeHotZones {
|
||||
@ -217,6 +227,12 @@ enum class TraceTaskId : int32_t {
|
||||
REMOTE_ANIMATION,
|
||||
CONNECT_EXTENSION,
|
||||
REMOTE_ANIMATION_HOME,
|
||||
START_WINDOW_ANIMATION,
|
||||
};
|
||||
|
||||
enum class PersistentStorageType : uint32_t {
|
||||
UKNOWN = 0,
|
||||
ASPECT_RATIO,
|
||||
};
|
||||
|
||||
struct MoveDragProperty : public Parcelable {
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
MAP,
|
||||
BOOL,
|
||||
STRING,
|
||||
STRINGS,
|
||||
INTS,
|
||||
FLOATS,
|
||||
POSITIVE_FLOATS,
|
||||
@ -43,6 +44,7 @@ public:
|
||||
std::string stringValue_;
|
||||
std::vector<int>* intsValue_;
|
||||
std::vector<float>* floatsValue_;
|
||||
std::vector<std::string>* stringsValue_;
|
||||
};
|
||||
ConfigItem() {}
|
||||
~ConfigItem()
|
||||
@ -75,6 +77,10 @@ public:
|
||||
delete floatsValue_;
|
||||
floatsValue_ = nullptr;
|
||||
break;
|
||||
case ValueType::STRINGS:
|
||||
delete stringsValue_;
|
||||
stringsValue_ = nullptr;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -102,6 +108,9 @@ public:
|
||||
case ValueType::FLOATS:
|
||||
floatsValue_ = new std::vector<float>(*value.floatsValue_);
|
||||
break;
|
||||
case ValueType::STRINGS:
|
||||
stringsValue_ = new std::vector<std::string>(*value.stringsValue_);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -137,6 +146,10 @@ public:
|
||||
floatsValue_ = value.floatsValue_;
|
||||
value.floatsValue_ = nullptr;
|
||||
break;
|
||||
case ValueType::STRINGS:
|
||||
stringsValue_ = value.stringsValue_;
|
||||
value.stringsValue_ = nullptr;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -188,6 +201,13 @@ public:
|
||||
type_ = ValueType::FLOATS;
|
||||
floatsValue_ = new std::vector<float>(value);
|
||||
}
|
||||
// set strings value
|
||||
void SetValue(const std::vector<std::string>& value)
|
||||
{
|
||||
ClearValue();
|
||||
type_ = ValueType::STRINGS;
|
||||
stringsValue_ = new std::vector<std::string>(value);
|
||||
}
|
||||
bool IsInts() const
|
||||
{
|
||||
return type_ == ValueType::INTS;
|
||||
@ -200,6 +220,10 @@ public:
|
||||
{
|
||||
return type_ == ValueType::STRING;
|
||||
}
|
||||
bool IsStrings() const
|
||||
{
|
||||
return type_ == ValueType::STRINGS;
|
||||
}
|
||||
bool IsBool() const
|
||||
{
|
||||
return type_ == ValueType::BOOL;
|
||||
|
@ -31,7 +31,7 @@ bool DisplayInfo::Marshalling(Parcel &parcel) const
|
||||
parcel.WriteInt32(offsetX_) && parcel.WriteInt32(offsetY_) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(displayState_)) &&
|
||||
parcel.WriteBool(waterfallDisplayCompressionStatus_) &&
|
||||
parcel.WriteInt32(dpi_);
|
||||
parcel.WriteInt32(dpi_) && parcel.WriteUint32(static_cast<uint32_t>(displayOrientation_));
|
||||
}
|
||||
|
||||
DisplayInfo *DisplayInfo::Unmarshalling(Parcel &parcel)
|
||||
@ -44,6 +44,7 @@ DisplayInfo *DisplayInfo::Unmarshalling(Parcel &parcel)
|
||||
uint32_t rotation;
|
||||
uint32_t orientation;
|
||||
uint32_t displayState;
|
||||
uint32_t displayOrientation;
|
||||
bool res = parcel.ReadString(displayInfo->name_) &&
|
||||
parcel.ReadUint64(displayInfo->id_) && parcel.ReadUint32(type) &&
|
||||
parcel.ReadInt32(displayInfo->width_) && parcel.ReadInt32(displayInfo->height_) &&
|
||||
@ -53,7 +54,7 @@ DisplayInfo *DisplayInfo::Unmarshalling(Parcel &parcel)
|
||||
parcel.ReadUint32(rotation) && parcel.ReadUint32(orientation) &&
|
||||
parcel.ReadInt32(displayInfo->offsetX_) && parcel.ReadInt32(displayInfo->offsetY_) &&
|
||||
parcel.ReadUint32(displayState) && parcel.ReadBool(displayInfo->waterfallDisplayCompressionStatus_) &&
|
||||
parcel.ReadInt32(displayInfo->dpi_);
|
||||
parcel.ReadInt32(displayInfo->dpi_) && parcel.ReadUint32(displayOrientation);
|
||||
if (!res) {
|
||||
delete displayInfo;
|
||||
return nullptr;
|
||||
@ -62,6 +63,7 @@ DisplayInfo *DisplayInfo::Unmarshalling(Parcel &parcel)
|
||||
displayInfo->rotation_ = static_cast<Rotation>(rotation);
|
||||
displayInfo->orientation_ = static_cast<Orientation>(orientation);
|
||||
displayInfo->displayState_ = static_cast<DisplayState>(displayState);
|
||||
displayInfo->displayOrientation_ = static_cast<DisplayOrientation>(displayOrientation);
|
||||
return displayInfo;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
@ -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,45 +50,21 @@ 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)
|
||||
{
|
||||
WLOGI("permission:%{public}s", permission.c_str());
|
||||
WLOGFD("permission:%{public}s", permission.c_str());
|
||||
|
||||
if (Security::AccessToken::AccessTokenKit::VerifyAccessToken(IPCSkeleton::GetCallingTokenID(), permission) !=
|
||||
AppExecFwk::Constants::PERMISSION_GRANTED) {
|
||||
WLOGI("permission denied!");
|
||||
return false;
|
||||
}
|
||||
WLOGI("permission ok!");
|
||||
WLOGFD("permission ok!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
65
utils/src/persistent_storage.cpp
Normal file
65
utils/src/persistent_storage.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "persistent_storage.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "PersistentStorage"};
|
||||
}
|
||||
std::map<PersistentStorageType, std::string> PersistentStorage::storagePath_ = {
|
||||
{ PersistentStorageType::ASPECT_RATIO, "/data/service/el1/public/window/window_aspect_ratio.xml" },
|
||||
};
|
||||
|
||||
bool PersistentStorage::HasKey(const std::string& key, PersistentStorageType storageType)
|
||||
{
|
||||
bool res = false;
|
||||
auto pref = GetPreference(storageType);
|
||||
if (!pref) {
|
||||
WLOGE("[PersistentStorage] Preferences is nullptr");
|
||||
return res;
|
||||
}
|
||||
res = pref->HasKey(key);
|
||||
WLOGD("[PersistentStorage] Key: %{public}s, hasKey: %{public}d", key.c_str(), res);
|
||||
return res;
|
||||
}
|
||||
|
||||
void PersistentStorage::Delete(const std::string& key, PersistentStorageType storageType)
|
||||
{
|
||||
auto pref = GetPreference(storageType);
|
||||
if (!pref) {
|
||||
WLOGE("[PersistentStorage] Preferences is nullptr");
|
||||
return;
|
||||
}
|
||||
pref->Delete(key);
|
||||
pref->Flush();
|
||||
WLOGD("[PersistentStorage] Delete key %{public}s", key.c_str());
|
||||
}
|
||||
|
||||
std::shared_ptr<PersistentPerference> PersistentStorage::GetPreference(PersistentStorageType storageType)
|
||||
{
|
||||
auto iter = storagePath_.find(storageType);
|
||||
if (iter == storagePath_.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto fileName = storagePath_[storageType];
|
||||
int errCode;
|
||||
auto pref = NativePreferences::PreferencesHelper::GetPreferences(fileName, errCode);
|
||||
WLOGD("[PersistentStorage] GetPreference fileName: %{public}s, errCode: %{public}d", fileName.c_str(), errCode);
|
||||
return pref;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -23,6 +23,7 @@ bool ScreenInfo::Marshalling(Parcel &parcel) const
|
||||
parcel.WriteFloat(virtualPixelRatio_) && parcel.WriteUint64(lastParent_) && parcel.WriteUint64(parent_) &&
|
||||
parcel.WriteBool(isScreenGroup_) && parcel.WriteUint32(static_cast<uint32_t>(rotation_)) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(orientation_)) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(sourceMode_)) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(type_)) &&
|
||||
parcel.WriteUint32(modeId_) && parcel.WriteUint32(static_cast<uint32_t>(modes_.size()));
|
||||
if (!res) {
|
||||
@ -58,13 +59,14 @@ bool ScreenInfo::InnerUnmarshalling(Parcel& parcel)
|
||||
uint32_t size = 0;
|
||||
uint32_t rotation;
|
||||
uint32_t orientation;
|
||||
uint32_t sourceMode;
|
||||
uint32_t type;
|
||||
name_ = parcel.ReadString();
|
||||
bool res1 = parcel.ReadUint64(id_) &&
|
||||
parcel.ReadUint32(virtualWidth_) && parcel.ReadUint32(virtualHeight_) &&
|
||||
parcel.ReadFloat(virtualPixelRatio_) && parcel.ReadUint64(lastParent_) && parcel.ReadUint64(parent_) &&
|
||||
parcel.ReadBool(isScreenGroup_) && parcel.ReadUint32(rotation) &&
|
||||
parcel.ReadUint32(orientation) && parcel.ReadUint32(type) &&
|
||||
parcel.ReadUint32(orientation) && parcel.ReadUint32(sourceMode) && parcel.ReadUint32(type) &&
|
||||
parcel.ReadUint32(modeId_) && parcel.ReadUint32(size);
|
||||
if (!res1) {
|
||||
return false;
|
||||
@ -85,6 +87,7 @@ bool ScreenInfo::InnerUnmarshalling(Parcel& parcel)
|
||||
}
|
||||
rotation_ = static_cast<Rotation>(rotation);
|
||||
orientation_ = static_cast<Orientation>(orientation);
|
||||
sourceMode_ = static_cast<ScreenSourceMode>(sourceMode);
|
||||
type_ = static_cast<ScreenType>(type);
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -557,6 +557,16 @@ void WindowProperty::GetTouchHotAreas(std::vector<Rect>& rects) const
|
||||
rects = touchHotAreas_;
|
||||
}
|
||||
|
||||
void WindowProperty::SetAspectRatio(float ratio)
|
||||
{
|
||||
aspectRatio_ = ratio;
|
||||
}
|
||||
|
||||
float WindowProperty::GetAspectRatio() const
|
||||
{
|
||||
return aspectRatio_;
|
||||
}
|
||||
|
||||
uint32_t WindowProperty::GetAccessTokenId() const
|
||||
{
|
||||
return accessTokenId_;
|
||||
@ -756,7 +766,7 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action)
|
||||
parcel.WriteUint32(static_cast<uint32_t>(windowSizeChangeReason_));
|
||||
break;
|
||||
case PropertyChangeAction::ACTION_UPDATE_MODE:
|
||||
ret = ret && parcel.WriteUint32(static_cast<uint32_t>(mode_));
|
||||
ret = ret && parcel.WriteUint32(static_cast<uint32_t>(mode_)) && parcel.WriteBool(isDecorEnable_);
|
||||
break;
|
||||
case PropertyChangeAction::ACTION_UPDATE_FLAGS:
|
||||
ret = ret && parcel.WriteUint32(flags_);
|
||||
@ -800,6 +810,9 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action)
|
||||
case PropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE:
|
||||
ret = ret && parcel.WriteBool(isPrivacyMode_);
|
||||
break;
|
||||
case PropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO:
|
||||
ret = ret && parcel.WriteFloat(aspectRatio_);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -819,6 +832,7 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action)
|
||||
break;
|
||||
case PropertyChangeAction::ACTION_UPDATE_MODE:
|
||||
SetWindowMode(static_cast<WindowMode>(parcel.ReadUint32()));
|
||||
SetDecorEnable(parcel.ReadBool());
|
||||
break;
|
||||
case PropertyChangeAction::ACTION_UPDATE_FLAGS:
|
||||
SetWindowFlags(parcel.ReadUint32());
|
||||
@ -863,6 +877,9 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action)
|
||||
case PropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE:
|
||||
SetPrivacyMode(parcel.ReadBool());
|
||||
break;
|
||||
case PropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO:
|
||||
SetAspectRatio(parcel.ReadFloat());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#ifndef OHOS_ROSEN_RESSCHED_REPORT_H
|
||||
#define OHOS_ROSEN_RESSCHED_REPORT_H
|
||||
|
||||
#include "event_handler.h"
|
||||
#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE
|
||||
#include "res_sched_client.h"
|
||||
#endif
|
||||
@ -28,9 +29,12 @@ namespace Rosen {
|
||||
#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE
|
||||
namespace {
|
||||
constexpr int64_t PERF_TIME_OUT = 200;
|
||||
constexpr int64_t SLIDE_PERF_TIME_OUT = 1000;
|
||||
constexpr int32_t PERF_CLICK_NORMAL_CODE = 9;
|
||||
constexpr int32_t PERF_DRAG_CODE = 31;
|
||||
constexpr int32_t PERF_MOVE_CODE = 32;
|
||||
constexpr int32_t PERF_SLIDE_CODE = 34;
|
||||
const std::string TASK_NAME = "SlideOff";
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -92,6 +96,34 @@ class ResSchedReport {
|
||||
#endif
|
||||
}
|
||||
|
||||
void TrigSlide(WindowType type, bool isOn)
|
||||
{
|
||||
#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE
|
||||
if (type != WindowType::WINDOW_TYPE_STATUS_BAR) {
|
||||
return;
|
||||
}
|
||||
static auto lastRequestPerfTime = std::chrono::steady_clock::now();
|
||||
static auto eventRunner = AppExecFwk::EventRunner::GetMainEventRunner();
|
||||
static auto handler = std::make_shared<AppExecFwk::EventHandler>(eventRunner);
|
||||
static auto task = []() {
|
||||
std::unordered_map<std::string, std::string> mapPayload;
|
||||
OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(PERF_SLIDE_CODE, 1, mapPayload);
|
||||
};
|
||||
auto current = std::chrono::steady_clock::now();
|
||||
bool isTimeOut = std::chrono::duration_cast<std::chrono::milliseconds>(current - lastRequestPerfTime).
|
||||
count() > SLIDE_PERF_TIME_OUT;
|
||||
if (isTimeOut && isOn) {
|
||||
handler->RemoveTask(TASK_NAME);
|
||||
lastRequestPerfTime = current;
|
||||
std::unordered_map<std::string, std::string> mapPayload;
|
||||
OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(PERF_SLIDE_CODE, 0, mapPayload);
|
||||
}
|
||||
if (!isTimeOut && !isOn) {
|
||||
// 500 is the animation duration.
|
||||
handler->PostTask(task, TASK_NAME, 500, AppExecFwk::EventQueue::Priority::HIGH);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE
|
||||
void RequestPerf(int32_t code, int64_t timeOut)
|
||||
|
@ -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);
|
||||
@ -72,6 +72,7 @@ public:
|
||||
virtual void SetAnchorAndScale(int32_t x, int32_t y, float scale);
|
||||
virtual void SetAnchorOffset(int32_t deltaX, int32_t deltaY);
|
||||
virtual void OffWindowZoom();
|
||||
virtual WmErrorCode RaiseToAppTop(uint32_t windowId);
|
||||
private:
|
||||
static inline SingletonDelegator<WindowAdapter> delegator;
|
||||
bool InitWMSProxy();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user