jscallback 重构

Change-Id: I8ab61a788511baffb5eee2180d99018d3962a7b4
Signed-off-by: chyyy0213 <chenhaiying3@huawei.com>
This commit is contained in:
chyyy0213
2022-03-03 19:05:11 +08:00
83 changed files with 946 additions and 419 deletions
+1 -1
View File
@@ -62,7 +62,6 @@ public:
virtual bool WakeUpEnd();
virtual bool SuspendBegin(PowerStateChangeReason reason);
virtual bool SuspendEnd();
virtual bool SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason);
virtual bool SetDisplayState(DisplayState state);
virtual DisplayState GetDisplayState(DisplayId displayId);
virtual void NotifyDisplayEvent(DisplayEvent event);
@@ -77,6 +76,7 @@ public:
virtual ScreenId CreateVirtualScreen(VirtualScreenOption option);
virtual DMError DestroyVirtualScreen(ScreenId screenId);
virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason);
virtual bool SetOrientation(ScreenId screenId, Orientation orientation);
virtual sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId);
virtual std::vector<sptr<ScreenInfo>> GetAllScreenInfos();
+8 -2
View File
@@ -32,7 +32,7 @@ public:
}
~Impl() = default;
DEFINE_VAR_FUNC_GET_SET(std::string, Name, name);
DEFINE_VAR_FUNC_GET_SET(sptr<DisplayInfo>, DisplayInfo, displayInfo);
DEFINE_VAR_FUNC_GET_SET_WITH_LOCK(sptr<DisplayInfo>, DisplayInfo, displayInfo);
};
Display::Display(const std::string& name, sptr<DisplayInfo> info)
@@ -64,7 +64,13 @@ int32_t Display::GetHeight() const
uint32_t Display::GetFreshRate() const
{
UpdateDisplayInfo();
return pImpl_->GetDisplayInfo()->GetFreshRate();
return pImpl_->GetDisplayInfo()->GetRefreshRate();
}
uint32_t Display::GetRefreshRate() const
{
UpdateDisplayInfo();
return pImpl_->GetDisplayInfo()->GetRefreshRate();
}
ScreenId Display::GetScreenId() const
+21 -48
View File
@@ -21,6 +21,7 @@
#include "display_manager_adapter.h"
#include "display_manager_agent_default.h"
#include "dm_common.h"
#include "screen_manager.h"
#include "singleton_delegator.h"
#include "window_manager_hilog.h"
@@ -72,7 +73,7 @@ public:
void OnDisplayCreate(sptr<DisplayInfo> displayInfo) override
{
if (displayInfo == nullptr || displayInfo->GetDisplayId() == DISPLAY_ID_INVALD) {
if (displayInfo == nullptr || displayInfo->GetDisplayId() == DISPLAY_ID_INVALID) {
WLOGFE("OnDisplayCreate, displayInfo is invalid.");
return;
}
@@ -88,7 +89,7 @@ public:
void OnDisplayDestroy(DisplayId displayId) override
{
if (displayId == DISPLAY_ID_INVALD) {
if (displayId == DISPLAY_ID_INVALID) {
WLOGFE("OnDisplayDestroy, displayId is invalid.");
return;
}
@@ -104,7 +105,7 @@ public:
void OnDisplayChange(sptr<DisplayInfo> displayInfo, DisplayChangeEvent event) override
{
if (displayInfo == nullptr || displayInfo->GetDisplayId() == DISPLAY_ID_INVALD) {
if (displayInfo == nullptr || displayInfo->GetDisplayId() == DISPLAY_ID_INVALID) {
WLOGFE("OnDisplayChange, displayInfo is invalid.");
return;
}
@@ -236,7 +237,7 @@ sptr<Display> DisplayManager::Impl::GetDisplayByScreenId(ScreenId screenId)
return nullptr;
}
DisplayId displayId = displayInfo->GetDisplayId();
if (displayId == DISPLAY_ID_INVALD) {
if (displayId == DISPLAY_ID_INVALID) {
WLOGFE("get display by screenId: invalid displayInfo");
return nullptr;
}
@@ -251,7 +252,7 @@ sptr<Display> DisplayManager::Impl::GetDisplayByScreenId(ScreenId screenId)
std::shared_ptr<Media::PixelMap> DisplayManager::GetScreenshot(DisplayId displayId)
{
if (displayId == DISPLAY_ID_INVALD) {
if (displayId == DISPLAY_ID_INVALID) {
WLOGFE("displayId invalid!");
return nullptr;
}
@@ -268,7 +269,7 @@ std::shared_ptr<Media::PixelMap> DisplayManager::GetScreenshot(DisplayId display
std::shared_ptr<Media::PixelMap> DisplayManager::GetScreenshot(DisplayId displayId, const Media::Rect &rect,
const Media::Size &size, int rotation)
{
if (displayId == DISPLAY_ID_INVALD) {
if (displayId == DISPLAY_ID_INVALID) {
WLOGFE("displayId invalid!");
return nullptr;
}
@@ -450,8 +451,12 @@ void DisplayManager::Impl::NotifyDisplayPowerEvent(DisplayPowerEvent event, Even
{
WLOGFI("NotifyDisplayPowerEvent event:%{public}u, status:%{public}u, size:%{public}zu", event, status,
powerEventListeners_.size());
std::lock_guard<std::recursive_mutex> lock(mutex_);
for (auto& listener : powerEventListeners_) {
std::vector<sptr<IDisplayPowerEventListener>> powerEventListeners;
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
powerEventListeners = powerEventListeners_;
}
for (auto& listener : powerEventListeners) {
listener->OnDisplayPowerEvent(event, status);
}
}
@@ -459,9 +464,13 @@ void DisplayManager::Impl::NotifyDisplayPowerEvent(DisplayPowerEvent event, Even
void DisplayManager::Impl::NotifyDisplayStateChanged(DisplayId id, DisplayState state)
{
WLOGFI("state:%{public}u", state);
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (displayStateCallback_) {
displayStateCallback_(state);
DisplayStateCallback displayStateCallback;
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
displayStateCallback = displayStateCallback_;
}
if (displayStateCallback) {
displayStateCallback(state);
ClearDisplayStateCallback();
return;
}
@@ -495,7 +504,7 @@ bool DisplayManager::Impl::UpdateDisplayInfoLocked(sptr<DisplayInfo> displayInfo
}
DisplayId displayId = displayInfo->GetDisplayId();
WLOGFI("displayId:%{public}" PRIu64".", displayId);
if (displayId == DISPLAY_ID_INVALD) {
if (displayId == DISPLAY_ID_INVALID) {
WLOGFE("displayId is invalid.");
return false;
}
@@ -535,42 +544,6 @@ bool DisplayManager::SuspendEnd()
return SingletonContainer::Get<DisplayManagerAdapter>().SuspendEnd();
}
bool DisplayManager::SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason)
{
// TODO: should get all screen ids
WLOGFI("state:%{public}u, reason:%{public}u", state, reason);
ScreenId defaultId = GetDefaultDisplayId();
if (defaultId == DISPLAY_ID_INVALD) {
WLOGFI("defaultId invalid!");
return false;
}
ScreenPowerStatus status;
switch (state) {
case DisplayPowerState::POWER_ON: {
status = ScreenPowerStatus::POWER_STATUS_ON;
break;
}
case DisplayPowerState::POWER_OFF: {
status = ScreenPowerStatus::POWER_STATUS_OFF;
break;
}
default: {
WLOGFW("SetScreenPowerStatus state not support");
return false;
}
}
RSInterfaces::GetInstance().SetScreenPowerStatus(defaultId, status);
WLOGFI("SetScreenPowerStatus end");
return SingletonContainer::Get<DisplayManagerAdapter>().SetScreenPowerForAll(state, reason);
}
DisplayPowerState DisplayManager::GetScreenPower(uint64_t screenId)
{
DisplayPowerState res = static_cast<DisplayPowerState>(RSInterfaces::GetInstance().GetScreenPowerStatus(screenId));
WLOGFI("GetScreenPower:%{public}u, defaultId:%{public}" PRIu64".", res, screenId);
return res;
}
bool DisplayManager::Impl::SetDisplayState(DisplayState state, DisplayStateCallback callback)
{
WLOGFI("state:%{public}u", state);
+8 -10
View File
@@ -38,7 +38,7 @@ WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManagerAdapter)
DisplayId DisplayManagerAdapter::GetDefaultDisplayId()
{
INIT_PROXY_CHECK_RETURN(DISPLAY_ID_INVALD);
INIT_PROXY_CHECK_RETURN(DISPLAY_ID_INVALID);
return displayManagerServiceProxy_->GetDefaultDisplayId();
}
@@ -124,6 +124,12 @@ DMError ScreenManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<Su
return displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface);
}
bool ScreenManagerAdapter::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->SetScreenPowerForAll(state, reason);
}
bool ScreenManagerAdapter::SetOrientation(ScreenId screenId, Orientation orientation)
{
INIT_PROXY_CHECK_RETURN(false);
@@ -175,14 +181,6 @@ bool DisplayManagerAdapter::SuspendEnd()
return displayManagerServiceProxy_->SuspendEnd();
}
bool DisplayManagerAdapter::SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason)
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->SetScreenPowerForAll(state, reason);
}
bool DisplayManagerAdapter::SetDisplayState(DisplayState state)
{
INIT_PROXY_CHECK_RETURN(false);
@@ -299,7 +297,7 @@ std::vector<DisplayId> DisplayManagerAdapter::GetAllDisplayIds()
sptr<DisplayInfo> DisplayManagerAdapter::GetDisplayInfo(DisplayId displayId)
{
if (displayId == DISPLAY_ID_INVALD) {
if (displayId == DISPLAY_ID_INVALID) {
WLOGFE("screen id is invalid");
return nullptr;
}
+73 -3
View File
@@ -13,13 +13,17 @@
* limitations under the License.
*/
#include "screen_manager.h"
#include <map>
#include <vector>
#include <transaction/rs_interfaces.h>
#include "display_manager_adapter.h"
#include "display_manager_agent_default.h"
#include "singleton_delegator.h"
#include "window_manager_hilog.h"
#include <map>
#include <vector>
namespace OHOS::Rosen {
namespace {
@@ -328,7 +332,6 @@ ScreenId ScreenManager::MakeExpand(const std::vector<ExpandOption>& options)
ScreenId ScreenManager::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
{
WLOGFI("create mirror for screen: %{public}" PRIu64"", mainScreenId);
// TODO: "record screen" should use another function, "MakeMirror" should return group id.
ScreenId group = SingletonContainer::Get<ScreenManagerAdapter>().MakeMirror(mainScreenId, mirrorScreenId);
if (group == SCREEN_ID_INVALID) {
WLOGFI("create mirror failed");
@@ -361,6 +364,73 @@ DMError ScreenManager::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface>
return SingletonContainer::Get<ScreenManagerAdapter>().SetVirtualScreenSurface(screenId, surface);
}
bool ScreenManager::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
{
WLOGFI("state:%{public}u, reason:%{public}u", state, reason);
auto screenInfos = SingletonContainer::Get<ScreenManagerAdapter>().GetAllScreenInfos();
if (screenInfos.empty()) {
WLOGFI("no screen info");
return false;
}
ScreenPowerStatus status;
switch (state) {
case ScreenPowerState::POWER_ON: {
status = ScreenPowerStatus::POWER_STATUS_ON;
break;
}
case ScreenPowerState::POWER_OFF: {
status = ScreenPowerStatus::POWER_STATUS_OFF;
break;
}
default: {
WLOGFW("SetScreenPowerStatus state not support");
return false;
}
}
bool hasSetScreenPower = false;
for (sptr<ScreenInfo> screenInfo : screenInfos) {
if (screenInfo->GetType() != ScreenType::REAL) {
WLOGD("skip virtual screen %{public}" PRIu64"", screenInfo->GetScreenId());
continue;
}
RSInterfaces::GetInstance().SetScreenPowerStatus(screenInfo->GetRsScreenId(), status);
WLOGI("set screen power status. rsscreen %{public}" PRIu64", status %{public}u",
screenInfo->GetRsScreenId(), status);
hasSetScreenPower = true;
}
WLOGFI("SetScreenPowerStatus end");
if (!hasSetScreenPower) {
WLOGFI("no real screen");
return false;
}
return SingletonContainer::Get<ScreenManagerAdapter>().SetScreenPowerForAll(state, reason);
}
ScreenPowerState ScreenManager::GetScreenPower(ScreenId dmsScreenId)
{
auto screenInfos = SingletonContainer::Get<ScreenManagerAdapter>().GetAllScreenInfos();
if (screenInfos.empty()) {
WLOGFE("no screen info");
return ScreenPowerState::INVALID_STATE;
}
ScreenId rsId = SCREEN_ID_INVALID;
for (sptr<ScreenInfo> screenInfo : screenInfos) {
if (screenInfo->GetScreenId() == dmsScreenId) {
rsId = screenInfo->GetRsScreenId();
break;
}
}
if (rsId == SCREEN_ID_INVALID) {
WLOGFE("cannot find screen %{public}" PRIu64"", dmsScreenId);
return ScreenPowerState::INVALID_STATE;
}
ScreenPowerState state = static_cast<ScreenPowerState>(RSInterfaces::GetInstance().GetScreenPowerStatus(rsId));
WLOGFI("GetScreenPower:%{public}u, rsscreen:%{public}" PRIu64".", state, rsId);
return state;
}
void ScreenManager::Impl::NotifyScreenConnect(sptr<ScreenInfo> info)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
+13 -4
View File
@@ -51,7 +51,7 @@ public:
displayId_ = displayId;
}
bool isCallbackCalled_ { false };
DisplayId displayId_ { DISPLAY_ID_INVALD };
DisplayId displayId_ { DISPLAY_ID_INVALID };
};
class DisplayChangeTest : public testing::Test {
@@ -71,13 +71,13 @@ public:
static sptr<DisplayChangeEventListener> listener_;
static inline uint32_t times_ = 0;
};
DisplayId DisplayChangeTest::defaultDisplayId_ = DISPLAY_ID_INVALD;
DisplayId DisplayChangeTest::defaultDisplayId_ = DISPLAY_ID_INVALID;
sptr<DisplayChangeEventListener> DisplayChangeTest::listener_ = new DisplayChangeEventListener();
void DisplayChangeTest::SetUpTestCase()
{
defaultDisplayId_ = DisplayManager::GetInstance().GetDefaultDisplayId();
if (defaultDisplayId_ == DISPLAY_ID_INVALD) {
if (defaultDisplayId_ == DISPLAY_ID_INVALID) {
WLOGE("DisplayId is invalid!");
}
if (!DisplayManager::GetInstance().RegisterDisplayListener(listener_)) {
@@ -103,7 +103,7 @@ void DisplayChangeTest::TearDown()
void DisplayChangeTest::ResetDisplayChangeListener()
{
listener_->isCallbackCalled_ = false;
listener_->displayId_ = DISPLAY_ID_INVALD;
listener_->displayId_ = DISPLAY_ID_INVALID;
}
bool DisplayChangeTest::CheckDisplayChangeEventCallback(bool valueExpected)
@@ -137,6 +137,10 @@ bool DisplayChangeTest::ScreenSizeEqual(const sptr<Screen> screen, const sptr<Su
bool DisplayChangeTest::DisplaySizeEqual(const sptr<Display> display, const sptr<SupportedScreenModes> curInfo)
{
if (display == nullptr || curInfo == nullptr) {
WLOGFI("param is nullptr");
return false;
}
uint32_t dWidth = static_cast<uint32_t>(display->GetWidth());
uint32_t dHeight = static_cast<uint32_t>(display->GetHeight());
WLOGI("DisplaySizeEqual:: DisplaySize: %{public}u %{public}u, ActiveModeInfoSize: %{public}u %{public}u",
@@ -220,6 +224,7 @@ HWTEST_F(DisplayChangeTest, CheckDisplayStateChange01, Function | SmallTest | Le
{
WLOGFI("CheckDisplayStateChange01");
sptr<Display> defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_);
ASSERT_NE(nullptr, defaultDisplay);
ScreenId screenId = defaultDisplay->GetScreenId();
sptr<Screen> screen = ScreenManager::GetInstance().GetScreenById(screenId);
ASSERT_NE(nullptr, screen);
@@ -238,6 +243,7 @@ HWTEST_F(DisplayChangeTest, CheckDisplayStateChange02, Function | SmallTest | Le
{
WLOGFI("CheckDisplayStateChange02");
sptr<Display> defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_);
ASSERT_NE(nullptr, defaultDisplay);
ScreenId screenId = defaultDisplay->GetScreenId();
sptr<Screen> screen = ScreenManager::GetInstance().GetScreenById(screenId);
ASSERT_NE(nullptr, screen);
@@ -270,6 +276,7 @@ HWTEST_F(DisplayChangeTest, CheckDisplaySizeChange01, Function | MediumTest | Le
{
WLOGFI("CheckDisplaySizeChange01");
sptr<Display> defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_);
ASSERT_NE(nullptr, defaultDisplay);
ScreenId screenId = defaultDisplay->GetScreenId();
sptr<Screen> screen = ScreenManager::GetInstance().GetScreenById(screenId);
ASSERT_NE(nullptr, screen);
@@ -302,6 +309,7 @@ HWTEST_F(DisplayChangeTest, CheckDisplaySizeChange02, Function | MediumTest | Le
{
WLOGFI("CheckDisplaySizeChange02");
sptr<Display> defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_);
ASSERT_NE(nullptr, defaultDisplay);
ScreenId screenId = defaultDisplay->GetScreenId();
sptr<Screen> screen = ScreenManager::GetInstance().GetScreenById(screenId);
ASSERT_NE(nullptr, screen);
@@ -315,6 +323,7 @@ HWTEST_F(DisplayChangeTest, CheckDisplaySizeChange02, Function | MediumTest | Le
WLOGFI("SetScreenActiveMode: %{public}u -> %{public}u", usedModeIdx, modeIdx);
ASSERT_EQ(true, CheckDisplayChangeEventCallback(true));
defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_);
ASSERT_NE(nullptr, defaultDisplay);
ASSERT_EQ(true, DisplaySizeEqual(defaultDisplay, modes[modeIdx]));
break;
}
+1 -1
View File
@@ -53,7 +53,7 @@ namespace {
*/
HWTEST_F(DisplayMinimalTest, BasicDisplay01, Function | MediumTest | Level1)
{
ASSERT_NE(DISPLAY_ID_INVALD, DisplayManager::GetInstance().GetDefaultDisplayId());
ASSERT_NE(DISPLAY_ID_INVALID, DisplayManager::GetInstance().GetDefaultDisplayId());
}
/**
+11 -10
View File
@@ -15,6 +15,7 @@
#include <gtest/gtest.h>
#include "display_manager.h"
#include "screen_manager.h"
#include "window.h"
#include "window_manager_hilog.h"
@@ -71,7 +72,7 @@ sptr<DisplayPowerEventListener> DisplayPowerTest::listener_ = new DisplayPowerEv
void DisplayPowerTest::SetUpTestCase()
{
defaultId_ = DisplayManager::GetInstance().GetDefaultDisplayId();
if (defaultId_ == DISPLAY_ID_INVALD) {
if (defaultId_ == DISPLAY_ID_INVALID) {
WLOGFE("GetDefaultDisplayId failed!");
}
DisplayManager::GetInstance().RegisterDisplayPowerEventListener(listener_);
@@ -323,7 +324,7 @@ HWTEST_F(DisplayPowerTest, suspend_end_callback_001, Function | MediumTest | Lev
*/
HWTEST_F(DisplayPowerTest, set_screen_power_for_all_001, Function | MediumTest | Level2)
{
bool ret = DisplayManager::GetInstance().SetScreenPowerForAll(DisplayPowerState::POWER_OFF,
bool ret = ScreenManager::GetInstance().SetScreenPowerForAll(ScreenPowerState::POWER_OFF,
PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(true, ret);
CheckDisplayPowerEventCallback(true);
@@ -339,7 +340,7 @@ HWTEST_F(DisplayPowerTest, set_screen_power_for_all_001, Function | MediumTest |
*/
HWTEST_F(DisplayPowerTest, set_screen_power_for_all_002, Function | MediumTest | Level2)
{
bool ret = DisplayManager::GetInstance().SetScreenPowerForAll(DisplayPowerState::POWER_ON,
bool ret = ScreenManager::GetInstance().SetScreenPowerForAll(ScreenPowerState::POWER_ON,
PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(true, ret);
CheckDisplayPowerEventCallback(true);
@@ -355,7 +356,7 @@ HWTEST_F(DisplayPowerTest, set_screen_power_for_all_002, Function | MediumTest |
*/
HWTEST_F(DisplayPowerTest, set_screen_power_for_all_003, Function | MediumTest | Level2)
{
bool ret = DisplayManager::GetInstance().SetScreenPowerForAll(DisplayPowerState::INVALID_STATE,
bool ret = ScreenManager::GetInstance().SetScreenPowerForAll(ScreenPowerState::INVALID_STATE,
PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(false, ret);
CheckDisplayPowerEventCallback(true);
@@ -388,10 +389,10 @@ HWTEST_F(DisplayPowerTest, set_display_state_power_event_callback_001, Function
*/
HWTEST_F(DisplayPowerTest, get_display_power_001, Function | MediumTest | Level2)
{
DisplayPowerState stateToSet = DisplayPowerState::POWER_OFF;
bool ret = DisplayManager::GetInstance().SetScreenPowerForAll(stateToSet, PowerStateChangeReason::POWER_BUTTON);
ScreenPowerState stateToSet = ScreenPowerState::POWER_OFF;
bool ret = ScreenManager::GetInstance().SetScreenPowerForAll(stateToSet, PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(true, ret);
DisplayPowerState stateGet = DisplayManager::GetInstance().GetScreenPower(defaultId_);
ScreenPowerState stateGet = ScreenManager::GetInstance().GetScreenPower(defaultId_);
ASSERT_EQ(stateGet, stateToSet);
}
@@ -402,10 +403,10 @@ HWTEST_F(DisplayPowerTest, get_display_power_001, Function | MediumTest | Level2
*/
HWTEST_F(DisplayPowerTest, get_display_power_002, Function | MediumTest | Level2)
{
DisplayPowerState stateToSet = DisplayPowerState::POWER_ON;
bool ret = DisplayManager::GetInstance().SetScreenPowerForAll(stateToSet, PowerStateChangeReason::POWER_BUTTON);
ScreenPowerState stateToSet = ScreenPowerState::POWER_ON;
bool ret = ScreenManager::GetInstance().SetScreenPowerForAll(stateToSet, PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(true, ret);
DisplayPowerState stateGet = DisplayManager::GetInstance().GetScreenPower(defaultId_);
ScreenPowerState stateGet = ScreenManager::GetInstance().GetScreenPower(defaultId_);
ASSERT_EQ(stateGet, stateToSet);
}
+2 -2
View File
@@ -90,7 +90,7 @@ public:
};
sptr<Display> ScreenManagerTest::defaultDisplay_ = nullptr;
DisplayId ScreenManagerTest::defaultDisplayId_ = DISPLAY_ID_INVALD;
DisplayId ScreenManagerTest::defaultDisplayId_ = DISPLAY_ID_INVALID;
ScreenId ScreenManagerTest::defaultScreenId_ = INVALID_SCREEN_ID;
std::string ScreenManagerTest::defaultName_ = "virtualScreen01";
uint32_t ScreenManagerTest::defaultWidth_ = 480;
@@ -366,7 +366,7 @@ HWTEST_F(ScreenManagerTest, ScreenManager09, Function | MediumTest | Level2)
ASSERT_EQ(virtualScreenId, screenId);
std::vector<sptr<Screen>> screens = ScreenManager::GetInstance().GetAllScreens();
sptr<Screen> DefaultScreen = screens.front();
DisplayId virtualDisplayId = DISPLAY_ID_INVALD;
DisplayId virtualDisplayId = DISPLAY_ID_INVALID;
std::vector<DisplayId> displayIds = DisplayManager::GetInstance().GetAllDisplayIds();
for (auto& id : displayIds) {
if (id != defaultDisplayId_) {
+4 -5
View File
@@ -37,12 +37,12 @@ public:
virtual void SetUp() override;
virtual void TearDown() override;
static DisplayId defaultId_;
DisplayId invalidId_ = DISPLAY_ID_INVALD;
DisplayId invalidId_ = DISPLAY_ID_INVALID;
const std::string defaultCmd_ = "/system/bin/snapshot_display";
const int testTimeCount_ = 2;
};
DisplayId ScreenshotCmdTest::defaultId_ = DISPLAY_ID_INVALD;
DisplayId ScreenshotCmdTest::defaultId_ = DISPLAY_ID_INVALID;
void ScreenshotCmdTest::SetUpTestCase()
{
@@ -50,10 +50,9 @@ void ScreenshotCmdTest::SetUpTestCase()
if (display == nullptr) {
WLOGFE("GetDefaultDisplay: failed!\n");
return;
} else {
WLOGFI("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
display->GetHeight(), display->GetFreshRate());
}
WLOGFI("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
display->GetHeight(), display->GetRefreshRate());
defaultId_ = display->GetId();
}
+4 -5
View File
@@ -36,12 +36,12 @@ public:
static DisplayId defaultId_;
static Media::Rect defaultScreen_;
static Media::Size defaultImage_;
DisplayId invalidId_ = DISPLAY_ID_INVALD;
DisplayId invalidId_ = DISPLAY_ID_INVALID;
Media::Rect invalidRect_ = {-1, -1, -1, -1};
uint32_t defaultRot_ = 0;
};
DisplayId ScreenshotTest::defaultId_ = DISPLAY_ID_INVALD;
DisplayId ScreenshotTest::defaultId_ = DISPLAY_ID_INVALID;
Media::Rect ScreenshotTest::defaultScreen_ = {0, 0, 0, 0};
Media::Size ScreenshotTest::defaultImage_ = {0, 0};
@@ -51,10 +51,9 @@ void ScreenshotTest::SetUpTestCase()
if (display == nullptr) {
WLOGFE("GetDefaultDisplay: failed!\n");
return;
} else {
WLOGFI("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
display->GetHeight(), display->GetFreshRate());
}
WLOGFI("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
display->GetHeight(), display->GetRefreshRate());
defaultId_ = display->GetId();
defaultScreen_ = {0, 0, display->GetWidth(), display->GetHeight()};
@@ -52,14 +52,16 @@ public:
static ScreenId defaultScreenId_;
sptr<DisplayChangeEventListener> listener_ = new DisplayChangeEventListener();
};
DisplayId DisplayChangeUnitTest::defaultDisplayId_ = DISPLAY_ID_INVALD;
DisplayId DisplayChangeUnitTest::defaultDisplayId_ = DISPLAY_ID_INVALID;
ScreenId DisplayChangeUnitTest::defaultScreenId_ = SCREEN_ID_INVALID;
void DisplayChangeUnitTest::SetUpTestCase()
{
defaultDisplayId_ = DisplayManager::GetInstance().GetDefaultDisplayId();
sptr<Display> defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_);
defaultScreenId_ = defaultDisplay->GetScreenId();
if (defaultDisplay != nullptr) {
defaultScreenId_ = defaultDisplay->GetScreenId();
}
}
void DisplayChangeUnitTest::TearDownTestCase()
+9 -8
View File
@@ -15,6 +15,7 @@
#include <gtest/gtest.h>
#include "display_manager.h"
#include "screen_manager.h"
#include "mock_display_manager_adapter.h"
#include "singleton_mocker.h"
@@ -40,7 +41,7 @@ public:
static inline DisplayId defaultId_ = 0;
static inline uint32_t brightnessLevel_ = 80;
static inline uint32_t invalidBrightnessLevel_ = 1000000000;
static inline DisplayPowerState initialPowerState_;
static inline ScreenPowerState initialPowerState_;
static inline DisplayState initialState_;
};
@@ -54,13 +55,13 @@ void DisplayPowerUnitTest::TearDownTestCase()
void DisplayPowerUnitTest::SetUp()
{
initialPowerState_ = DisplayManager::GetInstance().GetScreenPower(defaultId_);
initialPowerState_ = ScreenManager::GetInstance().GetScreenPower(defaultId_);
initialState_ = DisplayManager::GetInstance().GetDisplayState(defaultId_);
}
void DisplayPowerUnitTest::TearDown()
{
DisplayManager::GetInstance().SetScreenPowerForAll(initialPowerState_, PowerStateChangeReason::POWER_BUTTON);
ScreenManager::GetInstance().SetScreenPowerForAll(initialPowerState_, PowerStateChangeReason::POWER_BUTTON);
DisplayStateCallback callback;
DisplayManager::GetInstance().SetDisplayState(initialState_, callback);
}
@@ -258,12 +259,12 @@ HWTEST_F(DisplayPowerUnitTest, set_screen_power_for_all_001, Function | MediumTe
EXPECT_CALL(m.Mock(), SetScreenPowerForAll(_, PowerStateChangeReason::POWER_BUTTON))
.Times(1).WillOnce(Return(true));
bool ret = DisplayManager::GetInstance().SetScreenPowerForAll(DisplayPowerState::POWER_OFF,
bool ret = ScreenManager::GetInstance().SetScreenPowerForAll(ScreenPowerState::POWER_OFF,
PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(true, ret);
DisplayPowerState state = DisplayManager::GetInstance().GetScreenPower(defaultId_);
ASSERT_EQ(state, DisplayPowerState::POWER_OFF);
ScreenPowerState state = ScreenManager::GetInstance().GetScreenPower(defaultId_);
ASSERT_EQ(state, ScreenPowerState::POWER_OFF);
}
/**
@@ -277,11 +278,11 @@ HWTEST_F(DisplayPowerUnitTest, set_screen_power_for_all_002, Function | MediumTe
EXPECT_CALL(m.Mock(), GetDefaultDisplayId()).Times(1).WillOnce(Return(defaultId_));
EXPECT_CALL(m.Mock(), SetScreenPowerForAll(_, PowerStateChangeReason::POWER_BUTTON)).Times(0);
bool ret = DisplayManager::GetInstance().SetScreenPowerForAll(DisplayPowerState::INVALID_STATE,
bool ret = ScreenManager::GetInstance().SetScreenPowerForAll(ScreenPowerState::INVALID_STATE,
PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(false, ret);
DisplayPowerState state = DisplayManager::GetInstance().GetScreenPower(defaultId_);
ScreenPowerState state = ScreenManager::GetInstance().GetScreenPower(defaultId_);
ASSERT_EQ(state, initialPowerState_);
}
@@ -36,7 +36,7 @@ public:
MOCK_METHOD0(WakeUpEnd, bool());
MOCK_METHOD1(SuspendBegin, bool(PowerStateChangeReason reason));
MOCK_METHOD0(SuspendEnd, bool());
MOCK_METHOD2(SetScreenPowerForAll, bool(DisplayPowerState state, PowerStateChangeReason reason));
MOCK_METHOD2(SetScreenPowerForAll, bool(ScreenPowerState state, PowerStateChangeReason reason));
MOCK_METHOD1(SetDisplayState, bool(DisplayState state));
MOCK_METHOD1(GetDisplayState, DisplayState(DisplayId displayId));
MOCK_METHOD1(NotifyDisplayEvent, void(DisplayEvent event));
+1 -1
View File
@@ -25,7 +25,7 @@ namespace Rosen {
using Mocker = SingletonMocker<ScreenManagerAdapter, MockScreenManagerAdapter>;
sptr<Display> ScreenManagerTest::defaultDisplay_ = nullptr;
DisplayId ScreenManagerTest::defaultDisplayId_ = DISPLAY_ID_INVALD;
DisplayId ScreenManagerTest::defaultDisplayId_ = DISPLAY_ID_INVALID;
uint32_t ScreenManagerTest::defaultWidth_ = 480;
uint32_t ScreenManagerTest::defaultHeight_ = 320;
+5 -5
View File
@@ -29,7 +29,7 @@ public:
constexpr static float DEFAULT_VIRTUAL_PIXEL_RATIO = 1.0;
constexpr static uint32_t DEFAULT_FRESH_RATE = 60;
AbstractDisplay(const DisplayInfo* info);
AbstractDisplay(DisplayId id, ScreenId screenId, int32_t width, int32_t height, uint32_t freshRate);
AbstractDisplay(DisplayId id, ScreenId screenId, int32_t width, int32_t height, uint32_t refreshRate);
~AbstractDisplay() = default;
static inline bool IsVertical(Rotation rotation)
{
@@ -38,7 +38,7 @@ public:
DisplayId GetId() const;
int32_t GetWidth() const;
int32_t GetHeight() const;
uint32_t GetFreshRate() const;
uint32_t GetRefreshRate() const;
float GetVirtualPixelRatio() const;
ScreenId GetAbstractScreenId() const;
bool BindAbstractScreen(ScreenId dmsScreenId);
@@ -48,18 +48,18 @@ public:
void SetId(DisplayId displayId);
void SetWidth(int32_t width);
void SetHeight(int32_t height);
void SetFreshRate(uint32_t freshRate);
void SetRefreshRate(uint32_t refreshRate);
void SetVirtualPixelRatio(float virtualPixelRatio);
void SetOrientation(Orientation orientation);
bool RequestRotation(Rotation rotation);
Rotation GetRotation();
private:
DisplayId id_ { DISPLAY_ID_INVALD };
DisplayId id_ { DISPLAY_ID_INVALID };
ScreenId screenId_ { SCREEN_ID_INVALID };
int32_t width_ { 0 };
int32_t height_ { 0 };
uint32_t freshRate_ { 0 };
uint32_t refreshRate_ { 0 };
float virtualPixelRatio_ { 1.0 };
Rotation rotation_ { Rotation::ROTATION_0 };
Orientation orientation_ { Orientation::UNSPECIFIED };
+1 -1
View File
@@ -96,7 +96,7 @@ public:
virtual bool WakeUpEnd() = 0;
virtual bool SuspendBegin(PowerStateChangeReason reason) = 0;
virtual bool SuspendEnd() = 0;
virtual bool SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason) = 0;
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) = 0;
virtual bool SetDisplayState(DisplayState state) = 0;
virtual DisplayState GetDisplayState(DisplayId displayId) = 0;
virtual std::vector<DisplayId> GetAllDisplayIds() = 0;
+1 -1
View File
@@ -57,7 +57,7 @@ public:
bool WakeUpEnd() override;
bool SuspendBegin(PowerStateChangeReason reason) override;
bool SuspendEnd() override;
bool SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason) override;
bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override;
bool SetDisplayState(DisplayState state) override;
std::vector<DisplayId> GetAllDisplayIds() override;
DisplayState GetDisplayState(DisplayId displayId) override;
+1 -1
View File
@@ -73,7 +73,7 @@ public:
bool WakeUpEnd() override;
bool SuspendBegin(PowerStateChangeReason reason) override;
bool SuspendEnd() override;
bool SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason) override;
bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override;
bool SetDisplayState(DisplayState state) override;
void UpdateRSTree(DisplayId displayId, std::shared_ptr<RSSurfaceNode>& surfaceNode, bool isAdd);
+9 -9
View File
@@ -33,15 +33,15 @@ AbstractDisplay::AbstractDisplay(const DisplayInfo* info)
id_ = info->GetDisplayId();
width_ = info->GetWidth();
height_ = info->GetHeight();
freshRate_ = info->GetFreshRate();
refreshRate_ = info->GetRefreshRate();
}
AbstractDisplay::AbstractDisplay(DisplayId id, ScreenId screenId, int32_t width, int32_t height, uint32_t freshRate)
AbstractDisplay::AbstractDisplay(DisplayId id, ScreenId screenId, int32_t width, int32_t height, uint32_t refreshRate)
: id_(id),
screenId_(screenId),
width_(width),
height_(height),
freshRate_(freshRate)
refreshRate_(refreshRate)
{
}
@@ -60,9 +60,9 @@ int32_t AbstractDisplay::GetHeight() const
return height_;
}
uint32_t AbstractDisplay::GetFreshRate() const
uint32_t AbstractDisplay::GetRefreshRate() const
{
return freshRate_;
return refreshRate_;
}
float AbstractDisplay::GetVirtualPixelRatio() const
@@ -80,9 +80,9 @@ void AbstractDisplay::SetHeight(int32_t height)
height_ = height;
}
void AbstractDisplay::SetFreshRate(uint32_t freshRate)
void AbstractDisplay::SetRefreshRate(uint32_t refreshRate)
{
freshRate_ = freshRate;
refreshRate_ = refreshRate;
}
void AbstractDisplay::SetVirtualPixelRatio(float virtualPixelRatio)
@@ -141,7 +141,7 @@ bool AbstractDisplay::BindAbstractScreen(sptr<AbstractScreen> abstractScreen)
}
width_ = static_cast<int32_t>(info->width_);
height_ = static_cast<int32_t>(info->height_);
freshRate_ = info->freshRate_;
refreshRate_ = info->refreshRate_;
screenId_ = dmsScreenId;
WLOGD("display bound to screen. display:%{public}" PRIu64", screen:%{public}" PRIu64"", id_, dmsScreenId);
return true;
@@ -158,7 +158,7 @@ sptr<DisplayInfo> AbstractDisplay::ConvertToDisplayInfo() const
displayInfo->width_ = width_;
displayInfo->height_ = height_;
displayInfo->id_ = id_;
displayInfo->freshRate_ = freshRate_;
displayInfo->refreshRate_ = refreshRate_;
displayInfo->screenId_ = screenId_;
displayInfo->rotation_ = rotation_;
displayInfo->orientation_ = orientation_;
+6 -6
View File
@@ -162,7 +162,7 @@ void AbstractDisplayController::OnAbstractScreenDisconnect(sptr<AbstractScreen>
}
WLOGI("disconnect screen. id:%{public}" PRIu64"", absScreen->dmsId_);
sptr<AbstractScreenGroup> screenGroup;
DisplayId absDisplayId = DISPLAY_ID_INVALD;
DisplayId absDisplayId = DISPLAY_ID_INVALID;
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
screenGroup = absScreen->GetGroup();
@@ -179,7 +179,7 @@ void AbstractDisplayController::OnAbstractScreenDisconnect(sptr<AbstractScreen>
WLOGE("support in future. combination:%{public}u", screenGroup->combination_);
}
}
if (absDisplayId == DISPLAY_ID_INVALD) {
if (absDisplayId == DISPLAY_ID_INVALID) {
WLOGE("the displayId of the disconnected expand screen was not found");
return;
}
@@ -215,7 +215,7 @@ DisplayId AbstractDisplayController::ProcessNormalScreenDisconnected(
return displayId;
}
}
return DISPLAY_ID_INVALD;
return DISPLAY_ID_INVALID;
}
DisplayId AbstractDisplayController::ProcessExpandScreenDisconnected(
@@ -231,7 +231,7 @@ DisplayId AbstractDisplayController::ProcessExpandScreenDisconnected(
return displayId;
}
}
return DISPLAY_ID_INVALD;
return DISPLAY_ID_INVALID;
}
void AbstractDisplayController::OnAbstractScreenChange(sptr<AbstractScreen> absScreen, DisplayChangeEvent event)
@@ -352,7 +352,7 @@ void AbstractDisplayController::BindAloneScreenLocked(sptr<AbstractScreen> realA
return;
}
sptr<AbstractDisplay> display = new AbstractDisplay(displayCount_.fetch_add(1),
realAbsScreen->dmsId_, info->width_, info->height_, info->freshRate_);
realAbsScreen->dmsId_, info->width_, info->height_, info->refreshRate_);
abstractDisplayMap_.insert((std::make_pair(display->GetId(), display)));
WLOGI("create display for new screen. screen:%{public}" PRIu64", display:%{public}" PRIu64"",
realAbsScreen->dmsId_, display->GetId());
@@ -395,7 +395,7 @@ void AbstractDisplayController::AddScreenToExpandLocked(sptr<AbstractScreen> abs
return;
}
sptr<AbstractDisplay> display = new AbstractDisplay(displayCount_.fetch_add(1),
absScreen->dmsId_, info->width_, info->height_, info->freshRate_);
absScreen->dmsId_, info->width_, info->height_, info->refreshRate_);
abstractDisplayMap_.insert((std::make_pair(display->GetId(), display)));
WLOGI("create display for new screen. screen:%{public}" PRIu64", display:%{public}" PRIu64"",
absScreen->dmsId_, display->GetId());
+1
View File
@@ -180,6 +180,7 @@ DMError AbstractScreen::SetScreenColorTransform()
void AbstractScreen::FillScreenInfo(sptr<ScreenInfo> info) const
{
info->id_ = dmsId_;
info->rsId_ = rsId_;
uint32_t width = 0;
uint32_t height = 0;
if (activeIdx_ >= 0 && activeIdx_ < modes_.size()) {
+11 -6
View File
@@ -243,11 +243,16 @@ void AbstractScreenController::OnRsScreenConnectionChange(ScreenId rsScreenId, S
void AbstractScreenController::ScreenConnectionInDisplayInit(sptr<AbstractScreenCallback> abstractScreenCallback)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (dmsScreenMap_.empty()) {
return;
std::map<ScreenId, sptr<AbstractScreen>> dmsScreenMap;
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
dmsScreenMap = dmsScreenMap_;
if (dmsScreenMap_.empty()) {
return;
}
}
for (auto& iter : dmsScreenMap_) {
for (auto& iter : dmsScreenMap) {
if (iter.second != nullptr && abstractScreenCallback != nullptr) {
WLOGFI("dmsScreenId :%{public}" PRIu64"", iter.first);
abstractScreenCallback->onConnect_(iter.second);
@@ -295,7 +300,7 @@ bool AbstractScreenController::FillAbstractScreen(sptr<AbstractScreen>& absScree
sptr<SupportedScreenModes> info = new SupportedScreenModes();
info->width_ = static_cast<uint32_t>(rsScreenModeInfo.GetScreenWidth());
info->height_ = static_cast<uint32_t>(rsScreenModeInfo.GetScreenHeight());
info->freshRate_ = rsScreenModeInfo.GetScreenFreshRate();
info->refreshRate_ = rsScreenModeInfo.GetScreenFreshRate();
absScreen->modes_.push_back(info);
WLOGD("fill screen w/h:%{public}d/%{public}d", info->width_, info->height_);
}
@@ -444,7 +449,7 @@ ScreenId AbstractScreenController::CreateVirtualScreen(VirtualScreenOption optio
info->height_ = option.height_;
auto defaultScreen = GetAbstractScreen(GetDefaultAbstractScreenId());
if (defaultScreen != nullptr && defaultScreen->GetActiveScreenMode() != nullptr) {
info->freshRate_ = defaultScreen->GetActiveScreenMode()->freshRate_;
info->refreshRate_ = defaultScreen->GetActiveScreenMode()->refreshRate_;
}
absScreen->modes_.push_back(info);
absScreen->activeIdx_ = 0;
+7 -7
View File
@@ -32,7 +32,7 @@ DisplayId DisplayManagerProxy::GetDefaultDisplayId()
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("GetDefaultDisplayId: remote is nullptr");
return DISPLAY_ID_INVALD;
return DISPLAY_ID_INVALID;
}
MessageParcel data;
@@ -40,11 +40,11 @@ DisplayId DisplayManagerProxy::GetDefaultDisplayId()
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("GetDefaultDisplayId: WriteInterfaceToken failed");
return DISPLAY_ID_INVALD;
return DISPLAY_ID_INVALID;
}
if (remote->SendRequest(TRANS_ID_GET_DEFAULT_DISPLAY_ID, data, reply, option) != ERR_NONE) {
WLOGFW("GetDefaultDisplayId: SendRequest failed");
return DISPLAY_ID_INVALD;
return DISPLAY_ID_INVALID;
}
DisplayId displayId = reply.ReadUint64();
@@ -589,7 +589,7 @@ bool DisplayManagerProxy::SuspendEnd()
return reply.ReadBool();
}
bool DisplayManagerProxy::SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason)
bool DisplayManagerProxy::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
{
MessageParcel data;
MessageParcel reply;
@@ -599,7 +599,7 @@ bool DisplayManagerProxy::SetScreenPowerForAll(DisplayPowerState state, PowerSta
return false;
}
if (!data.WriteUint32(static_cast<uint32_t>(state))) {
WLOGFE("Write DisplayPowerState failed");
WLOGFE("Write ScreenPowerState failed");
return false;
}
if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
@@ -748,8 +748,8 @@ sptr<ScreenInfo> DisplayManagerProxy::GetScreenInfoById(ScreenId screenId)
return nullptr;
}
for (auto& mode : info->GetModes()) {
WLOGFI("info modes is width: %{public}u, height: %{public}u, freshRate: %{public}u",
mode->width_, mode->height_, mode->freshRate_);
WLOGFI("info modes is width: %{public}u, height: %{public}u, refreshRate: %{public}u",
mode->width_, mode->height_, mode->refreshRate_);
}
return info;
}
+3 -3
View File
@@ -98,7 +98,7 @@ DisplayId DisplayManagerService::GetDefaultDisplayId()
sptr<AbstractDisplay> display = GetDisplayByScreen(dmsScreenId);
if (display == nullptr) {
WLOGFE("fail to get displayInfo by id: invalid display");
return DISPLAY_ID_INVALD;
return DISPLAY_ID_INVALID;
}
return display->GetId();
}
@@ -305,11 +305,11 @@ bool DisplayManagerService::SuspendEnd()
EventStatus::END);
}
bool DisplayManagerService::SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason)
bool DisplayManagerService::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
{
WLOGFI("SetScreenPowerForAll");
return DisplayManagerAgentController::GetInstance().NotifyDisplayPowerEvent(
state == DisplayPowerState::POWER_ON ? DisplayPowerEvent::DISPLAY_ON :
state == ScreenPowerState::POWER_ON ? DisplayPowerEvent::DISPLAY_ON :
DisplayPowerEvent::DISPLAY_OFF, EventStatus::END);
}
@@ -49,7 +49,7 @@ const sptr<AbstractDisplay> DisplayManagerServiceInner::GetDisplayById(DisplayId
const sptr<AbstractDisplay> DisplayManagerServiceInner::GetDefaultDisplay()
{
DisplayId defaultDisplayId = GetDefaultDisplayId();
if (defaultDisplayId == DISPLAY_ID_INVALD) {
if (defaultDisplayId == DISPLAY_ID_INVALID) {
WLOGFE("Fail to get default displayId");
return nullptr;
}
+3 -3
View File
@@ -146,7 +146,7 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
break;
}
case TRANS_ID_SET_SCREEN_POWER_FOR_ALL: {
DisplayPowerState state = static_cast<DisplayPowerState>(data.ReadUint32());
ScreenPowerState state = static_cast<ScreenPowerState>(data.ReadUint32());
PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32());
reply.WriteBool(SetScreenPowerForAll(state, reason));
break;
@@ -181,8 +181,8 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
auto screenInfo = GetScreenInfoById(screenId);
for (auto& mode : screenInfo->GetModes()) {
WLOGFI("info modes is width: %{public}u, height: %{public}u, freshRate: %{public}u",
mode->width_, mode->height_, mode->freshRate_);
WLOGFI("info modes is width: %{public}u, height: %{public}u, refreshRate: %{public}u",
mode->width_, mode->height_, mode->refreshRate_);
}
reply.WriteStrongParcelable(screenInfo);
break;
+4 -4
View File
@@ -27,7 +27,7 @@ namespace {
bool DisplayPowerController::SuspendBegin(PowerStateChangeReason reason)
{
WLOGFI("reason:%{public}u", reason);
DisplayManagerService::GetInstance().NotifyDisplayStateChange(DISPLAY_ID_INVALD,
DisplayManagerService::GetInstance().NotifyDisplayStateChange(DISPLAY_ID_INVALID,
DisplayStateChangeType::BEFORE_SUSPEND);
return true;
}
@@ -51,7 +51,7 @@ bool DisplayPowerController::SetDisplayState(DisplayState state)
isKeyguardDrawn = isKeyguardDrawn_;
}
if (!isKeyguardDrawn) {
DisplayManagerService::GetInstance().NotifyDisplayStateChange(DISPLAY_ID_INVALD,
DisplayManagerService::GetInstance().NotifyDisplayStateChange(DISPLAY_ID_INVALID,
DisplayStateChangeType::BEFORE_UNLOCK);
}
DisplayManagerAgentController::GetInstance().NotifyDisplayPowerEvent(DisplayPowerEvent::DISPLAY_ON,
@@ -72,7 +72,7 @@ bool DisplayPowerController::SetDisplayState(DisplayState state)
return false;
}
}
DisplayManagerAgentController::GetInstance().NotifyDisplayStateChanged(DISPLAY_ID_INVALD, state);
DisplayManagerAgentController::GetInstance().NotifyDisplayStateChanged(DISPLAY_ID_INVALID, state);
return true;
}
@@ -85,7 +85,7 @@ void DisplayPowerController::NotifyDisplayEvent(DisplayEvent event)
{
WLOGFI("DisplayEvent:%{public}u", event);
if (event == DisplayEvent::UNLOCK) {
DisplayManagerService::GetInstance().NotifyDisplayStateChange(DISPLAY_ID_INVALD,
DisplayManagerService::GetInstance().NotifyDisplayStateChange(DISPLAY_ID_INVALID,
DisplayStateChangeType::BEFORE_UNLOCK);
DisplayManagerAgentController::GetInstance().NotifyDisplayPowerEvent(DisplayPowerEvent::DESKTOP_READY,
EventStatus::BEGIN);
+1
View File
@@ -38,6 +38,7 @@ public:
int32_t GetWidth() const;
int32_t GetHeight() const;
uint32_t GetFreshRate() const;
uint32_t GetRefreshRate() const;
ScreenId GetScreenId() const;
float GetVirtualPixelRatio() const;
Rotation GetRotation() const;
@@ -55,8 +55,6 @@ public:
bool WakeUpEnd();
bool SuspendBegin(PowerStateChangeReason reason);
bool SuspendEnd();
bool SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason);
DisplayPowerState GetScreenPower(uint64_t screenId);
bool SetDisplayState(DisplayState state, DisplayStateCallback callback);
DisplayState GetDisplayState(DisplayId displayId);
bool SetScreenBrightness(uint64_t screenId, uint32_t level);
+2 -2
View File
@@ -24,7 +24,7 @@ namespace Rosen {
using DisplayId = uint64_t;
using ScreenId = uint64_t;
namespace {
constexpr DisplayId DISPLAY_ID_INVALD = -1ULL;
constexpr DisplayId DISPLAY_ID_INVALID = -1ULL;
constexpr ScreenId SCREEN_ID_INVALID = -1ULL;
const static std::string DEFAULT_SCREEN_NAME = "buildIn";
}
@@ -33,7 +33,7 @@ enum class PowerStateChangeReason : uint32_t {
POWER_BUTTON,
};
enum class DisplayPowerState : uint32_t {
enum class ScreenPowerState : uint32_t {
POWER_ON,
POWER_STAND_BY,
POWER_SUSPEND,
+1 -1
View File
@@ -37,7 +37,7 @@ struct Point {
struct SupportedScreenModes : public RefBase {
uint32_t width_;
uint32_t height_;
uint32_t freshRate_;
uint32_t refreshRate_;
};
struct VirtualScreenOption {
+2
View File
@@ -54,6 +54,8 @@ public:
ScreenId CreateVirtualScreen(VirtualScreenOption option);
DMError DestroyVirtualScreen(ScreenId screenId);
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);
bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason);
ScreenPowerState GetScreenPower(ScreenId screenId);
private:
ScreenManager();
+2 -2
View File
@@ -122,8 +122,8 @@ public:
virtual void UnregisterWindowChangeListener(sptr<IWindowChangeListener>& listener) = 0;
virtual void RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) = 0;
virtual void UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) = 0;
virtual void RegisterDragListener(sptr<IWindowDragListener>& listener) = 0;
virtual void UnregisterDragListener(sptr<IWindowDragListener>& listener) = 0;
virtual void RegisterDragListener(const sptr<IWindowDragListener>& listener) = 0;
virtual void UnregisterDragListener(const sptr<IWindowDragListener>& listener) = 0;
virtual void RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) = 0;
virtual void UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) = 0;
virtual WMError SetUIContent(const std::string& contentInfo, NativeEngine* engine,
+1 -1
View File
@@ -48,7 +48,7 @@ declare namespace screen {
function makeMirror(mainScreen:number, mirrorScreen:Array<number>): Promise<number>;
/**
* the paramter of making expand screen
* the parameter of making expand screen
* @devices tv, phone, tablet, wearable
* @since 8
*/
@@ -211,10 +211,10 @@ NativeValue* CreateJsScreenModeObject(NativeEngine& engine, sptr<SupportedScreen
}
uint32_t width = mode->width_;
uint32_t height = mode->height_;
uint32_t freshRate = mode->freshRate_;
uint32_t refreshRate = mode->refreshRate_;
optionObject->SetProperty("width", CreateJsValue(engine, width));
optionObject->SetProperty("height", CreateJsValue(engine, height));
optionObject->SetProperty("freshRate", CreateJsValue(engine, freshRate));
optionObject->SetProperty("freshRate", CreateJsValue(engine, refreshRate));
return objValue;
}
} // namespace Rosen
@@ -165,7 +165,7 @@ void UnregisterAllScreenListenerWithType(const std::string& type)
}
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
it->second->RemoveAllCallback();
if (type == "screenConnectEvent" || type == "screenChangeEvent") {
if (type == "connect" || type == "disconnect" || type == "change") {
sptr<ScreenManager::IScreenListener> thisListener(it->second);
SingletonContainer::Get<ScreenManager>().UnregisterScreenListener(thisListener);
WLOGFI("JsScreenManager::UnregisterAllScreenListenerWithType success");
@@ -185,7 +185,7 @@ void UnRegisterScreenListenerWithType(const std::string& type, NativeValue* valu
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
if (value->StrictEquals(it->first->Get())) {
it->second->RemoveCallback(value);
if (type == "screenConnectEvent" || type == "screenChangeEvent") {
if (type == "connect" || type == "disconnect" || type == "change") {
sptr<ScreenManager::IScreenListener> thisListener(it->second);
SingletonContainer::Get<ScreenManager>().UnregisterScreenListener(thisListener);
WLOGFI("JsScreenManager::UnRegisterScreenListenerWithType success");
@@ -102,7 +102,7 @@ static bool GetAPI7Ability(NativeEngine& engine, AppExecFwk::Ability* &ability)
if (ability == nullptr) {
return false;
} else {
WLOGE("JsWindowManager::GetAPI7Ability ability is %{public}p!", ability);
WLOGE("JsWindowManager::GetAPI7Ability ability is success!");
}
return true;
}
@@ -327,8 +327,7 @@ NativeValue* JsWindowManager::OnMinimizeAll(NativeEngine& engine, NativeCallback
WLOGFE("param is too small!");
errCode = WMError::WM_ERROR_INVALID_PARAM;
}
// TODO: use DisplayId instead of int64_t when engine supported
int64_t displayId = static_cast<int64_t>(DISPLAY_ID_INVALD);
int64_t displayId = static_cast<int64_t>(DISPLAY_ID_INVALID);
if (errCode == WMError::WM_OK && !ConvertFromJsValue(engine, info.argv[0], displayId)) {
WLOGFE("Failed to convert parameter to displayId");
errCode = WMError::WM_ERROR_INVALID_PARAM;
@@ -403,7 +402,6 @@ void JsWindowManager::UnregisterAllWmListenerWithType(std::string type)
}
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
if (type.compare(SYSTEM_BAR_TINT_CHANGE_CB) == 0) {
// it->second.jsCallBack_ = nullptr
sptr<ISystemBarChangedListener> thisListener(it->second);
SingletonContainer::Get<WindowManager>().UnregisterSystemBarChangedListener(thisListener);
WLOGFI("JsWindowManager::UnregisterAllWmListenerWithType systemBarTintChange success");
@@ -24,18 +24,15 @@ using namespace AbilityRuntime;
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsWindow"};
constexpr Rect EMPTY_RECT = {0, 0, 0, 0};
const std::map<std::string, uint32_t> JS_WINDOW_CALLBACK_TYPE = {
{"windowSizeChange", 0},
{"systemAvoidAreaChange", 1},
{"lifeCycleEvent", 2} // 2 is id of this callback type
};
}
static std::map<std::string, std::shared_ptr<NativeReference>> g_jsWindowMap;
std::recursive_mutex g_mutex;
// std::map<string, function<void(sptr<JsWindowListener>, sptr<Window>)>> JsWindow::g_registerMap =
// {
// {WINDOW_SIZE_CHANGE_CB, add},
// {SYSTEM_BAR_TINT_CHANGE_CB, std::minus<int>()},//标准库的函数,参数为两个整数,可以参考前一篇博客
// {SYSTEM_AVOID_AREA_CHANGE_CB, divide()},//类成员函数
// {LIFECYCLE_EVENT_CB, [](sptr<JsWindowListener> listener, sptr<Window> window){sptr<IAvoidAreaChangedListener> thisListener(listener);
// window->UnregisterAvoidAreaChangeListener(thisListener);}},//lambda表达式
// };
JsWindow::JsWindow(const sptr<Window>& window) : windowToken_(window)
{
}
@@ -266,7 +263,6 @@ NativeValue* JsWindow::OnDestroy(NativeEngine& engine, NativeCallbackInfo& info)
g_jsWindowMap.erase(windowName);
WLOGFI("JsWindow::OnDestroy windowName %{public}s is destroyed", windowName.c_str());
}
// FIX ME: windowToken = nullptr in aync task and don't affect other async task
task.Resolve(engine, engine.CreateUndefined());
WLOGFI("JsWindow::OnDestroy success");
};
@@ -536,44 +532,41 @@ bool JsWindow::IsCallbackRegistered(std::string type, NativeValue* jsListenerObj
return false;
}
// void JsWindow::ListenerProcess(std::string type, sptr<JsWindowListener> listener, bool isRegister)
// {
// switch (type)
// {
// case WINDOW_SIZE_CHANGE_CB: {
// sptr<IWindowChangeListener> thisListener(listener);
// if (isRegister) {
// windowToken_->RegisterWindowChangeListener(thisListener);
// } else {
// windowToken_->UnregisterWindowChangeListener(thisListener);
// }
// break;
// }
// case SYSTEM_AVOID_AREA_CHANGE_CB: {
// sptr<IAvoidAreaChangedListener> thisListener(listener);
// if (isRegister) {
// windowToken_->RegisterAvoidAreaChangeListener(thisListener);
// } else {
// windowToken_->UnregisterAvoidAreaChangeListener(thisListener);
// }
// break;
// }
// case LIFECYCLE_EVENT_CB: {
// sptr<IAvoidAreaChangedListener> thisListener(listener);
// if (isRegister) {
// windowToken_->RegisterAvoidAreaChangeListener(thisListener);
// } else {
// windowToken_->RegisterLifeCycleListener(thisListener);
// }
// break;
// }
// default: {
// WLOGFE("JsWindow::RegisterWindowListenerWithType failed method: %{public}s not support!",
// type.c_str());
// break;
// }
// }
// }
void JsWindow::ListenerProcess(uint32_t typeId, sptr<JsWindowListener> listener, bool isRegister)
{
switch (typeId)
{
case 0: { // windowSizeChange
sptr<IWindowChangeListener> thisListener(listener);
if (isRegister) {
windowToken_->RegisterWindowChangeListener(thisListener);
} else {
windowToken_->UnregisterWindowChangeListener(thisListener);
}
break;
}
case 1: { // avoidAreaChange
sptr<IAvoidAreaChangedListener> thisListener(listener);
if (isRegister) {
windowToken_->RegisterAvoidAreaChangeListener(thisListener);
} else {
windowToken_->UnregisterAvoidAreaChangeListener(thisListener);
}
break;
}
case 2: { // liftCycleEvent
sptr<IWindowLifeCycle> thisListener(listener);
if (isRegister) {
windowToken_->RegisterLifeCycleListener(thisListener);
} else {
windowToken_->UnregisterLifeCycleListener(thisListener);
}
break;
}
default:
break;
}
}
void JsWindow::RegisterWindowListenerWithType(NativeEngine& engine, std::string type, NativeValue* value)
{
@@ -589,15 +582,8 @@ void JsWindow::RegisterWindowListenerWithType(NativeEngine& engine, std::string
WLOGFE("JsWindow::RegisterWindowListenerWithType windowListener malloc failed");
return;
}
if (type.compare(WINDOW_SIZE_CHANGE_CB) == 0) {
sptr<IWindowChangeListener> thisListener(windowListener);
windowToken_->RegisterWindowChangeListener(thisListener);
} else if (type.compare(SYSTEM_AVOID_AREA_CHANGE_CB) == 0) {
sptr<IAvoidAreaChangedListener> thisListener(windowListener);
windowToken_->RegisterAvoidAreaChangeListener(thisListener);
} else if (type.compare(LIFECYCLE_EVENT_CB) == 0) {
sptr<IWindowLifeCycle> thisListener(windowListener);
windowToken_->RegisterLifeCycleListener(thisListener);
if (JS_WINDOW_CALLBACK_TYPE.count(type) != 0) {
ListenerProcess(JS_WINDOW_CALLBACK_TYPE.at(type), windowListener, true);
} else {
WLOGFE("JsWindow::RegisterWindowListenerWithType failed method: %{public}s not support!",
type.c_str());
@@ -616,23 +602,16 @@ void JsWindow::UnregisterAllWindowListenerWithType(std::string type)
return;
}
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) {
if (type.compare(WINDOW_SIZE_CHANGE_CB) == 0) {
sptr<IWindowChangeListener> thisListener(it->second);
windowToken_->UnregisterWindowChangeListener(thisListener);
} else if (type.compare(SYSTEM_AVOID_AREA_CHANGE_CB) == 0) {
sptr<IAvoidAreaChangedListener> thisListener(it->second);
windowToken_->UnregisterAvoidAreaChangeListener(thisListener);
} else if (type.compare(LIFECYCLE_EVENT_CB) == 0) {
sptr<IWindowLifeCycle> thisListener(it->second);
windowToken_->UnregisterLifeCycleListener(thisListener);
if (JS_WINDOW_CALLBACK_TYPE.count(type) != 0) {
ListenerProcess(JS_WINDOW_CALLBACK_TYPE.at(type), it->second, false);
} else {
WLOGFE("JsWindow::UnregisterWindowListenerWithType failed method: %{public}s not support!",
WLOGFE("JsWindow::UnregisterAllWindowListenerWithType failed method: %{public}s not support!",
type.c_str());
return;
}
jsCbMap_[type].erase(it++);
}
WLOGFI("JsWindow::UnregisterWindowListenerWithType %{public}s success! callback map size: %{public}u",
WLOGFI("JsWindow::UnregisterAllWindowListenerWithType %{public}s success! callback map size: %{public}u",
type.c_str(), jsCbMap_[type].size());
jsCbMap_.erase(type);
@@ -647,17 +626,8 @@ void JsWindow::UnregisterWindowListenerWithType(std::string type, NativeValue* v
}
for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();it++) {
if (value->StrictEquals(it->first->Get())) {
if (type.compare(WINDOW_SIZE_CHANGE_CB) == 0) {
sptr<IWindowChangeListener> thisListener(it->second);
windowToken_->UnregisterWindowChangeListener (thisListener);
WLOGFI("JsWindow::UnregisterWindowListenerWithType windowSizeChange success");
} else if (type.compare(SYSTEM_AVOID_AREA_CHANGE_CB) == 0) {
sptr<IAvoidAreaChangedListener> thisListener(it->second);
windowToken_->UnregisterAvoidAreaChangeListener(thisListener);
WLOGFI("JsWindow::UnregisterWindowListenerWithType systemAvoidAreaChange success");
} else if (type.compare(LIFECYCLE_EVENT_CB) == 0) {
sptr<IWindowLifeCycle> thisListener(it->second);
windowToken_->UnregisterLifeCycleListener(thisListener);
if (JS_WINDOW_CALLBACK_TYPE.count(type) != 0) {
ListenerProcess(JS_WINDOW_CALLBACK_TYPE.at(type), it->second, false);
} else {
WLOGFE("JsWindow::UnregisterWindowListenerWithType failed method: %{public}s not support!",
type.c_str());
@@ -1068,7 +1038,13 @@ NativeValue* JsWindow::OnSetColorSpace(NativeEngine& engine, NativeCallbackInfo&
WLOGFE("JsWindow::OnSetColorSpace Failed to convert parameter to ColorSpace");
} else {
colorSpace = static_cast<ColorSpace>(static_cast<uint32_t>(*nativeType));
WLOGFI("JsWindow::OnSetColorSpace %{public}u", static_cast<uint32_t>(colorSpace));
if (colorSpace > ColorSpace::COLOR_SPACE_WIDE_GAMUT) {
WLOGFE("JsWindow::OnSetColorSpace Failed, colorSpace %{public}u invalid!",
static_cast<uint32_t>(colorSpace));
errCode = WMError::WM_ERROR_INVALID_PARAM;
} else {
WLOGFI("JsWindow::OnSetColorSpace %{public}u", static_cast<uint32_t>(colorSpace));
}
}
}
@@ -57,6 +57,7 @@ public:
private:
bool IsCallbackRegistered(std::string type, NativeValue* jsListenerObject);
void ListenerProcess(uint32_t type, sptr<JsWindowListener> listener, bool isRegister);
void RegisterWindowListenerWithType(NativeEngine& engine, std::string type, NativeValue* value);
void UnregisterWindowListenerWithType(std::string type, NativeValue* value);
void UnregisterAllWindowListenerWithType(std::string type);
@@ -31,6 +31,7 @@ const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange";
const std::string SYSTEM_BAR_TINT_CHANGE_CB = "systemBarTintChange";
const std::string SYSTEM_AVOID_AREA_CHANGE_CB = "systemAvoidAreaChange";
const std::string LIFECYCLE_EVENT_CB = "lifeCycleEvent";
class JsWindowListener : public IWindowChangeListener,
public ISystemBarChangedListener,
public IAvoidAreaChangedListener,
+1 -1
View File
@@ -201,7 +201,7 @@ bool SnapShotUtils::WriteToPngWithPixelMap(const std::string &fileName, PixelMap
static bool ProcessDisplayId(DisplayId &displayId)
{
WM_SCOPED_TRACE("snapshot:ProcessDisplayId(%" PRIu64")", displayId);
if (displayId == DISPLAY_ID_INVALD) {
if (displayId == DISPLAY_ID_INVALID) {
displayId = DisplayManager::GetInstance().GetDefaultDisplayId();
} else {
bool validFlag = false;
+1 -1
View File
@@ -32,7 +32,7 @@ using WriteToPngParam = struct {
};
using CmdArgments = struct {
Rosen::DisplayId displayId = Rosen::DISPLAY_ID_INVALD;
Rosen::DisplayId displayId = Rosen::DISPLAY_ID_INVALID;
std::string fileName;
bool isWidthSet = false;
int32_t width = -1;
+29
View File
@@ -15,11 +15,19 @@
#ifndef OHOS_ROSEN_CLASS_VAR_DEFINITION_H
#define OHOS_ROSEN_CLASS_VAR_DEFINITION_H
#include <mutex>
namespace OHOS::Rosen {
#define DEFINE_VAR(type, memberName) \
private: \
type memberName##_;
#define DEFINE_VAR_WITH_LOCK(type, memberName) \
private: \
std::recursive_mutex memberName##Mutex_; \
type memberName##_;
#define DEFINE_VAR_DEFAULT(type, memberName, defaultValue) \
private: \
type memberName##_ {defaultValue};
@@ -31,6 +39,14 @@ public:
return memberName##_; \
}
#define DEFINE_FUNC_GET_WITH_LOCK(type, funcName, memberName) \
public: \
type Get##funcName() \
{ \
std::lock_guard<std::recursive_mutex> lock(memberName##Mutex_); \
return memberName##_; \
}
#define DEFINE_FUNC_SET(type, funcName, memberName) \
public: \
void Set##funcName(type value) \
@@ -38,6 +54,14 @@ public:
memberName##_ = value; \
}
#define DEFINE_FUNC_SET_WITH_LOCK(type, funcName, memberName) \
public: \
void Set##funcName(type value) \
{ \
std::lock_guard<std::recursive_mutex> lock(memberName##Mutex_); \
memberName##_ = value; \
}
#define DEFINE_VAR_FUNC_GET(type, funcName, memberName) \
DEFINE_VAR(type, memberName) \
DEFINE_FUNC_GET(type, funcName, memberName)
@@ -51,6 +75,11 @@ public:
DEFINE_FUNC_GET(type, funcName, memberName) \
DEFINE_FUNC_SET(type, funcName, memberName)
#define DEFINE_VAR_FUNC_GET_SET_WITH_LOCK(type, funcName, memberName) \
DEFINE_VAR_WITH_LOCK(type, memberName) \
DEFINE_FUNC_GET_WITH_LOCK(type, funcName, memberName) \
DEFINE_FUNC_SET_WITH_LOCK(type, funcName, memberName)
#define DEFINE_VAR_DEFAULT_FUNC_GET_SET(type, funcName, memberName, defaultValue) \
DEFINE_VAR_DEFAULT(type, memberName, defaultValue) \
DEFINE_FUNC_GET(type, funcName, memberName) \
+2 -1
View File
@@ -35,11 +35,12 @@ public:
virtual bool Marshalling(Parcel& parcel) const override;
static DisplayInfo *Unmarshalling(Parcel& parcel);
DEFINE_VAR_DEFAULT_FUNC_GET(DisplayId, DisplayId, id, DISPLAY_ID_INVALD);
DEFINE_VAR_DEFAULT_FUNC_GET(DisplayId, DisplayId, id, DISPLAY_ID_INVALID);
DEFINE_VAR_DEFAULT_FUNC_GET(DisplayType, DisplayType, type, DisplayType::DEFAULT);
DEFINE_VAR_DEFAULT_FUNC_GET(int32_t, Width, width, 0);
DEFINE_VAR_DEFAULT_FUNC_GET(int32_t, Height, height, 0);
DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, FreshRate, freshRate, 0);
DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, RefreshRate, refreshRate, 0);
DEFINE_VAR_DEFAULT_FUNC_GET(ScreenId, ScreenId, screenId, SCREEN_ID_INVALID);
DEFINE_VAR_DEFAULT_FUNC_GET(float, XDpi, xDpi, 0.0f);
DEFINE_VAR_DEFAULT_FUNC_GET(float, YDpi, yDpi, 0.0f);
+1
View File
@@ -41,6 +41,7 @@ public:
DEFINE_VAR_FUNC_GET(std::string, Name, name);
DEFINE_VAR_DEFAULT_FUNC_GET(ScreenId, ScreenId, id, SCREEN_ID_INVALID);
DEFINE_VAR_DEFAULT_FUNC_GET(ScreenId, RsScreenId, rsId, SCREEN_ID_INVALID);
DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, VirtualWidth, virtualWidth, 0);
DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, VirtualHeight, virtualHeight, 0);
DEFINE_VAR_DEFAULT_FUNC_GET(float, VirtualPixelRatio, virtualPixelRatio, 0.0f);
+3 -2
View File
@@ -20,7 +20,7 @@ bool DisplayInfo::Marshalling(Parcel &parcel) const
{
return parcel.WriteUint64(id_) && parcel.WriteUint32(type_) &&
parcel.WriteInt32(width_) && parcel.WriteInt32(height_) &&
parcel.WriteUint32(freshRate_) && parcel.WriteUint64(screenId_) &&
parcel.WriteUint32(freshRate_) && parcel.WriteUint32(refreshRate_) && parcel.WriteUint64(screenId_) &&
parcel.WriteFloat(xDpi_) && parcel.WriteFloat(yDpi_) &&
parcel.WriteUint32(static_cast<uint32_t>(rotation_)) &&
parcel.WriteUint32(static_cast<uint32_t>(orientation_));
@@ -34,7 +34,8 @@ DisplayInfo *DisplayInfo::Unmarshalling(Parcel &parcel)
uint32_t orientation;
bool res = parcel.ReadUint64(displayInfo->id_) && parcel.ReadUint32(type) &&
parcel.ReadInt32(displayInfo->width_) && parcel.ReadInt32(displayInfo->height_) &&
parcel.ReadUint32(displayInfo->freshRate_) && parcel.ReadUint64(displayInfo->screenId_) &&
parcel.ReadUint32(displayInfo->freshRate_) &&
parcel.ReadUint32(displayInfo->refreshRate_) && parcel.ReadUint64(displayInfo->screenId_) &&
parcel.ReadFloat(displayInfo->xDpi_) && parcel.ReadFloat(displayInfo->yDpi_) &&
parcel.ReadUint32(rotation) && parcel.ReadUint32(orientation);
if (!res) {
+4 -4
View File
@@ -18,7 +18,7 @@
namespace OHOS::Rosen {
bool ScreenInfo::Marshalling(Parcel &parcel) const
{
bool res = parcel.WriteString(name_) && parcel.WriteUint64(id_) &&
bool res = parcel.WriteString(name_) && parcel.WriteUint64(id_) && parcel.WriteUint64(rsId_) &&
parcel.WriteUint32(virtualWidth_) && parcel.WriteUint32(virtualHeight_) &&
parcel.WriteFloat(virtualPixelRatio_) && parcel.WriteUint64(parent_) &&
parcel.WriteBool(canHasChild_) && parcel.WriteUint32(static_cast<uint32_t>(rotation_)) &&
@@ -31,7 +31,7 @@ bool ScreenInfo::Marshalling(Parcel &parcel) const
for (uint32_t modeIndex = 0; modeIndex < modes_.size(); modeIndex++) {
if (parcel.WriteUint32(modes_[modeIndex]->height_) &&
parcel.WriteUint32(modes_[modeIndex]->width_) &&
parcel.WriteUint32(modes_[modeIndex]->freshRate_)) {
parcel.WriteUint32(modes_[modeIndex]->refreshRate_)) {
continue;
}
return false;
@@ -57,7 +57,7 @@ bool ScreenInfo::InnerUnmarshalling(Parcel& parcel)
uint32_t orientation;
uint32_t type;
name_ = parcel.ReadString();
bool res1 = parcel.ReadUint64(id_) &&
bool res1 = parcel.ReadUint64(id_) && parcel.ReadUint64(rsId_) &&
parcel.ReadUint32(virtualWidth_) && parcel.ReadUint32(virtualHeight_) &&
parcel.ReadFloat(virtualPixelRatio_) && parcel.ReadUint64(parent_) &&
parcel.ReadBool(canHasChild_) && parcel.ReadUint32(rotation) &&
@@ -71,7 +71,7 @@ bool ScreenInfo::InnerUnmarshalling(Parcel& parcel)
sptr<SupportedScreenModes> mode = new SupportedScreenModes();
if (parcel.ReadUint32(mode->height_) &&
parcel.ReadUint32(mode->width_) &&
parcel.ReadUint32(mode->freshRate_)) {
parcel.ReadUint32(mode->refreshRate_)) {
modes_.push_back(mode);
} else {
return false;
+1 -1
View File
@@ -37,7 +37,7 @@ public:
private:
sptr<WindowInputChannel> GetInputChannel(uint32_t windowId);
bool initInputListener_ = false;
std::mutex mtx_;
std::unordered_map<uint32_t, sptr<WindowInputChannel>> windowInputChannels_;
std::shared_ptr<MMI::IInputEventConsumer> inputListener_ = nullptr;
};
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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.
* You may obtain a copy of the License at
+2 -2
View File
@@ -106,8 +106,8 @@ public:
virtual void UnregisterWindowChangeListener(sptr<IWindowChangeListener>& listener) override;
virtual void RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
virtual void UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
virtual void RegisterDragListener(sptr<IWindowDragListener>& listener) override;
virtual void UnregisterDragListener(sptr<IWindowDragListener>& listener) override;
virtual void RegisterDragListener(const sptr<IWindowDragListener>& listener) override;
virtual void UnregisterDragListener(const sptr<IWindowDragListener>& listener) override;
virtual void RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
virtual void UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
+2 -1
View File
@@ -33,7 +33,8 @@ public:
private:
void OnVsync(int64_t timeStamp);
bool IsKeyboardEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const;
std::vector<std::shared_ptr<MMI::PointerEvent>> pointerEventPool_;
std::shared_ptr<MMI::PointerEvent> moveEvent_ = nullptr;
std::mutex mtx_;
sptr<Window> window_;
std::shared_ptr<VsyncStation::VsyncCallback> callback_ =
std::make_shared<VsyncStation::VsyncCallback>(VsyncStation::VsyncCallback());
+18 -16
View File
@@ -25,15 +25,15 @@ WM_IMPLEMENT_SINGLE_INSTANCE(InputTransferStation)
void InputEventListener::OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const
{
WLOGFI("OnInputEvent: receive keyEvent");
if (keyEvent == nullptr) {
WLOGE("OnInputEvent receive KeyEvent is nullptr");
WLOGFE("KeyEvent is nullptr");
return;
}
uint32_t windowId = static_cast<uint32_t>(keyEvent->GetAgentWindowId());
WLOGFI("Receive keyEvent, windowId: %{public}u", windowId);
auto channel = InputTransferStation::GetInstance().GetInputChannel(windowId);
if (channel == nullptr) {
WLOGE("OnInputEvent channel is nullptr");
WLOGFE("WindowInputChannel is nullptr");
return;
}
channel->HandleKeyEvent(keyEvent);
@@ -41,25 +41,25 @@ void InputEventListener::OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) c
void InputEventListener::OnInputEvent(std::shared_ptr<MMI::AxisEvent> axisEvent) const
{
WLOGFI("OnInputEvent: receive axisEvent");
if (axisEvent == nullptr) {
WLOGE("OnInputEvent receive axisEvent is nullptr");
WLOGFE("AxisEvent is nullptr");
return;
}
WLOGFI("Receive axisEvent, windowId: %{public}d", axisEvent->GetAgentWindowId());
axisEvent->MarkProcessed();
}
void InputEventListener::OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const
{
WLOGFI("OnInputEvent: receive pointerEvent");
if (pointerEvent == nullptr) {
WLOGE("OnInputEvent receive pointerEvent is nullptr");
WLOGFE("PointerEvent is nullptr");
return;
}
uint32_t windowId = static_cast<uint32_t>(pointerEvent->GetAgentWindowId());
WLOGFI("Receive pointerEvent, windowId: %{public}u", windowId);
auto channel = InputTransferStation::GetInstance().GetInputChannel(windowId);
if (channel == nullptr) {
WLOGE("OnInputEvent channel is nullptr");
WLOGFE("WindowInputChannel is nullptr");
return;
}
channel->HandlePointerEvent(pointerEvent);
@@ -67,28 +67,29 @@ void InputEventListener::OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointer
void InputTransferStation::AddInputWindow(const sptr<Window>& window)
{
WLOGFI("AddInputWindow: add window");
uint32_t windowId = window->GetWindowId();
WLOGFI("Add input window, windowId: %{public}u", windowId);
sptr<WindowInputChannel> inputChannel = new WindowInputChannel(window);
std::lock_guard<std::mutex> lock(mtx_);
windowInputChannels_.insert(std::make_pair(windowId, inputChannel));
if (!initInputListener_) {
WLOGFI("init input listener");
if (inputListener_ == nullptr) {
WLOGFI("Init input listener");
std::shared_ptr<MMI::IInputEventConsumer> listener = std::make_shared<InputEventListener>(InputEventListener());
MMI::InputManager::GetInstance()->SetWindowInputEventConsumer(listener);
inputListener_ = listener;
initInputListener_ = true;
}
}
void InputTransferStation::RemoveInputWindow(const sptr<Window>& window)
{
WLOGFI("RemoveInputWindow: remove window");
uint32_t windowId = window->GetWindowId();
WLOGFI("Remove input window, windowId: %{public}u", windowId);
std::lock_guard<std::mutex> lock(mtx_);
auto iter = windowInputChannels_.find(windowId);
if (iter != windowInputChannels_.end()) {
windowInputChannels_.erase(windowId);
} else {
WLOGE("RemoveInputWindow do not find windowId: %{public}d", windowId);
WLOGFE("Can not find windowId: %{public}d", windowId);
}
}
@@ -96,7 +97,7 @@ void InputTransferStation::SetInputListener(uint32_t windowId, std::shared_ptr<M
{
auto channel = GetInputChannel(windowId);
if (channel == nullptr) {
WLOGE("SetInputListener channel is nullptr");
WLOGFE("WindowInputChannel is nullptr, windowId: %{public}u", windowId);
return;
}
channel->SetInputListener(listener);
@@ -104,9 +105,10 @@ void InputTransferStation::SetInputListener(uint32_t windowId, std::shared_ptr<M
sptr<WindowInputChannel> InputTransferStation::GetInputChannel(uint32_t windowId)
{
std::lock_guard<std::mutex> lock(mtx_);
auto iter = windowInputChannels_.find(windowId);
if (iter == windowInputChannels_.end()) {
WLOGE("GetInputChannel do not find channel according to windowId: %{public}d", windowId);
WLOGFE("Can not find channel according to windowId: %{public}d", windowId);
return nullptr;
}
return iter->second;
+2 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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.
* You may obtain a copy of the License at
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include <vsync_station.h>
#include "vsync_station.h"
#include "transaction/rs_interfaces.h"
#include "window_manager_hilog.h"
+20 -19
View File
@@ -131,7 +131,7 @@ sptr<Window> WindowImpl::GetTopWindowWithContext(const std::shared_ptr<AbilityRu
break;
}
}
WLOGFI("GetTopWindowfinal MainWinId:%{public}d!", mainWinId);
WLOGFI("GetTopWindowfinal MainWinId:%{public}u!", mainWinId);
if (!mainWinId) {
WLOGFE("Cannot find topWindow!");
return nullptr;
@@ -238,7 +238,7 @@ WMError WindowImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea)
WMError WindowImpl::SetWindowType(WindowType type)
{
WLOGFI("window id: %{public}d, type:%{public}d", property_->GetWindowId(), static_cast<uint32_t>(type));
WLOGFI("window id: %{public}u, type:%{public}u", property_->GetWindowId(), static_cast<uint32_t>(type));
if (!IsWindowValid()) {
return WMError::WM_ERROR_INVALID_WINDOW;
}
@@ -259,7 +259,7 @@ WMError WindowImpl::SetWindowType(WindowType type)
WMError WindowImpl::SetWindowMode(WindowMode mode)
{
WLOGFI("[Client] Window %{public}d mode %{public}d", property_->GetWindowId(), static_cast<uint32_t>(mode));
WLOGFI("[Client] Window %{public}u mode %{public}u", property_->GetWindowId(), static_cast<uint32_t>(mode));
if (!IsWindowValid()) {
return WMError::WM_ERROR_INVALID_WINDOW;
}
@@ -798,7 +798,6 @@ void WindowImpl::StartMove()
}
startMoveFlag_ = true;
WLOGFI("[StartMove] windowId %{public}u", GetWindowId());
return;
}
WMError WindowImpl::RequestFocus() const
@@ -869,7 +868,7 @@ void WindowImpl::UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListene
}), avoidAreaChangeListeners_.end());
}
void WindowImpl::RegisterDragListener(sptr<IWindowDragListener>& listener)
void WindowImpl::RegisterDragListener(const sptr<IWindowDragListener>& listener)
{
if (listener == nullptr) {
return;
@@ -878,7 +877,7 @@ void WindowImpl::RegisterDragListener(sptr<IWindowDragListener>& listener)
windowDragListeners_.emplace_back(listener);
}
void WindowImpl::UnregisterDragListener(sptr<IWindowDragListener>& listener)
void WindowImpl::UnregisterDragListener(const sptr<IWindowDragListener>& listener)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto iter = std::find(windowDragListeners_.begin(), windowDragListeners_.end(), listener);
@@ -1045,7 +1044,6 @@ void WindowImpl::EndMoveOrDragWindow(int32_t pointId)
startDragFlag_ = false;
startMoveFlag_ = false;
pointEventStarted_ = false;
return;
}
void WindowImpl::ReadyToMoveOrDragWindow(int32_t globalX, int32_t globalY, int32_t pointId, const Rect& rect)
@@ -1245,9 +1243,13 @@ void WindowImpl::UpdateWindowState(WindowState state)
void WindowImpl::UpdateDragEvent(const PointInfo& point, DragEvent event)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
for (auto& iter : windowDragListeners_) {
iter->OnDrag(point.x, point.y, event);
std::vector<sptr<IWindowDragListener>> windowDragListeners;
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
windowDragListeners = windowDragListeners_;
}
for (auto& iter : windowDragListeners) {
iter->OnDrag(point.x - GetRect().posX_, point.y - GetRect().posY_, event);
}
}
@@ -1308,9 +1310,14 @@ void WindowImpl::SetDefaultOption()
break;
}
case WindowType::WINDOW_TYPE_TOAST:
case WindowType::WINDOW_TYPE_SEARCHING_BAR:
case WindowType::WINDOW_TYPE_FLOAT:
case WindowType::WINDOW_TYPE_SEARCHING_BAR: {
property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
break;
}
case WindowType::WINDOW_TYPE_VOLUME_OVERLAY: {
property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
property_->SetFocusable(false);
break;
}
case WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT: {
@@ -1340,20 +1347,14 @@ bool WindowImpl::IsLayoutFullScreen() const
uint32_t flags = GetWindowFlags();
auto mode = GetMode();
bool needAvoid = (flags & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID));
if (mode == WindowMode::WINDOW_MODE_FULLSCREEN && !needAvoid) {
return true;
}
return false;
return (mode == WindowMode::WINDOW_MODE_FULLSCREEN && !needAvoid);
}
bool WindowImpl::IsFullScreen() const
{
auto statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR);
auto naviProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_BAR);
if (IsLayoutFullScreen() && !statusProperty.enable_ && !naviProperty.enable_) {
return true;
}
return false;
return (IsLayoutFullScreen() && !statusProperty.enable_ && !naviProperty.enable_);
}
}
}
+29 -13
View File
@@ -31,17 +31,19 @@ WindowInputChannel::WindowInputChannel(const sptr<Window>& window)
void WindowInputChannel::HandleKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)
{
if (keyEvent == nullptr) {
WLOGE("HandleKeyEvent keyEvent is nullptr");
WLOGFE("keyEvent is nullptr");
return;
}
WLOGFI("Receive key event, windowId: %{public}d, keyCode: %{public}d",
window_->GetWindowId(), keyEvent->GetKeyCode());
bool isKeyboardEvent = IsKeyboardEvent(keyEvent);
bool inputMethodHasProcessed = false;
if (isKeyboardEvent) {
WLOGI("dispatch keyEvent to input method");
WLOGFI("dispatch keyEvent to input method");
inputMethodHasProcessed = MiscServices::InputMethodController::GetInstance()->dispatchKeyEvent(keyEvent);
}
if (!isKeyboardEvent || !inputMethodHasProcessed) {
WLOGI("dispatch keyEvent to ACE");
WLOGFI("dispatch keyEvent to ACE");
if (inputListener_ != nullptr) {
inputListener_->OnInputEvent(keyEvent);
return;
@@ -54,7 +56,7 @@ void WindowInputChannel::HandleKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent
void WindowInputChannel::HandlePointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
{
if (pointerEvent == nullptr) {
WLOGE("HandlePointerEvent pointerEvent is nullptr");
WLOGFE("pointerEvent is nullptr");
return;
}
if (inputListener_ != nullptr) {
@@ -62,13 +64,21 @@ void WindowInputChannel::HandlePointerEvent(std::shared_ptr<MMI::PointerEvent>&
return;
}
if (pointerEvent->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_MOVE) {
if (pointerEventPool_.size() > MAX_INPUT_NUM) {
pointerEventPool_.clear();
std::shared_ptr<MMI::PointerEvent> pointerEventTemp;
{
std::lock_guard<std::mutex> lock(mtx_);
pointerEventTemp = moveEvent_;
moveEvent_ = pointerEvent;
}
pointerEventPool_.emplace_back(pointerEvent);
VsyncStation::GetInstance().RequestVsync(VsyncStation::CallbackType::CALLBACK_INPUT, callback_);
WLOGFI("Receive move event, windowId: %{public}d, action: %{public}d",
window_->GetWindowId(), pointerEvent->GetPointerAction());
if (pointerEventTemp != nullptr) {
pointerEventTemp->MarkProcessed();
}
} else {
WLOGI("HandlePointerEvent cosume non-move, windowId: %{public}d", window_->GetWindowId());
WLOGFI("Dispatch non-move event, windowId: %{public}d, action: %{public}d",
window_->GetWindowId(), pointerEvent->GetPointerAction());
window_->ConsumePointerEvent(pointerEvent);
pointerEvent->MarkProcessed();
}
@@ -76,14 +86,20 @@ void WindowInputChannel::HandlePointerEvent(std::shared_ptr<MMI::PointerEvent>&
void WindowInputChannel::OnVsync(int64_t timeStamp)
{
if (pointerEventPool_.empty()) {
WLOGE("pointerEventPool_ is empty");
std::shared_ptr<MMI::PointerEvent> pointerEvent;
{
std::lock_guard<std::mutex> lock(mtx_);
pointerEvent = moveEvent_;
moveEvent_ = nullptr;
}
if (pointerEvent == nullptr) {
WLOGFE("moveEvent_ is nullptr");
return;
}
auto pointerEvent = pointerEventPool_.back();
WLOGFI("Dispatch move event, windowId: %{public}d, action: %{public}d",
window_->GetWindowId(), pointerEvent->GetPointerAction());
window_->ConsumePointerEvent(pointerEvent);
pointerEvent->MarkProcessed();
pointerEventPool_.clear();
}
void WindowInputChannel::SetInputListener(std::shared_ptr<MMI::IInputEventConsumer>& listener)
@@ -96,7 +112,7 @@ bool WindowInputChannel::IsKeyboardEvent(const std::shared_ptr<MMI::KeyEvent>& k
int32_t keyCode = keyEvent->GetKeyCode();
bool isKeyFN = (keyCode == MMI::KeyEvent::KEYCODE_FN);
bool isKeyboard = (keyCode >= MMI::KeyEvent::KEYCODE_0 && keyCode <= MMI::KeyEvent::KEYCODE_NUMPAD_RIGHT_PAREN);
WLOGI("isKeyFN: %{public}d, isKeyboard: %{public}d", isKeyFN, isKeyboard);
WLOGFI("isKeyFN: %{public}d, isKeyboard: %{public}d", isKeyFN, isKeyboard);
return (isKeyFN || isKeyboard);
}
}
+11 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
*/
#include "window_scene.h"
#include <new>
#include <configuration.h>
#include "static_call.h"
@@ -43,7 +43,11 @@ WMError WindowScene::Init(DisplayId displayId, const std::shared_ptr<AbilityRunt
{
displayId_ = displayId;
if (option == nullptr) {
option = new WindowOption();
option = new(std::nothrow) WindowOption();
if (option == nullptr) {
WLOGFW("alloc WindowOption failed");
return WMError::WM_ERROR_NULLPTR;
}
}
option->SetDisplayId(displayId);
@@ -166,6 +170,10 @@ WMError WindowScene::RequestFocus() const
void WindowScene::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
{
if (mainWindow_ == nullptr) {
WLOGFE("mainWindow_ is null");
return;
}
WLOGFI("notify mainWindow winId:%{public}d", mainWindow_->GetWindowId());
mainWindow_->UpdateConfiguration(configuration);
}
+14 -2
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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.
# You may obtain a copy of the License at
@@ -19,6 +19,7 @@ group("systemtest") {
testonly = true
deps = [
":wm_window_drag_test",
":wm_window_effect_test",
":wm_window_focus_test",
":wm_window_gamut_test",
@@ -166,6 +167,17 @@ ohos_systemtest("wm_window_visibility_info_test") {
## SystemTest wm_window_visibility_info_test }}}
## SystemTest wm_window_drag_test {{{
ohos_systemtest("wm_window_drag_test") {
module_out_path = module_out_path
sources = [ "window_drag_test.cpp" ]
deps = [ ":wm_systemtest_common" ]
}
## SystemTest drag_window_test }}}
## Build wm_systemtest_common.a {{{
config("wm_systemtest_common_public_config") {
include_dirs = [
@@ -214,7 +226,7 @@ ohos_static_library("wm_systemtest_common") {
public_deps = [
"//foundation/ace/ace_engine/interfaces/innerkits/ace:ace_uicontent",
# todo need delete it for abilitycontext
# need delete it for abilitycontext
"//foundation/ace/napi:ace_napi",
"//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client",
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
+223
View File
@@ -0,0 +1,223 @@
/*
* 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.
* 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 "wm_common.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
using utils = WindowTestUtils;
const int WAIT_CALLBACK_US = 100000; // 100000 us
class TestDragListener : public IWindowDragListener {
public:
PointInfo point_ { 0, 0 };
DragEvent event_ = DragEvent::DRAG_EVENT_END;
void OnDrag(int32_t x, int32_t y, DragEvent event) override;
};
void TestDragListener::OnDrag(int32_t x, int32_t y, DragEvent event)
{
event_ = event;
point_.x = x;
point_.y = y;
}
class WindowDragTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
virtual void SetUp() override;
virtual void TearDown() override;
static sptr<TestDragListener> firstWindowDragListener_;
static sptr<TestDragListener> secondWindowDragListener_;
utils::TestWindowInfo dragWindowInfo_;
utils::TestWindowInfo firstWindowInfo_;
utils::TestWindowInfo secondWindowInfo_;
};
sptr<TestDragListener> WindowDragTest::firstWindowDragListener_ =
new TestDragListener();
sptr<TestDragListener> WindowDragTest::secondWindowDragListener_ =
new TestDragListener();
void WindowDragTest::SetUpTestCase() {}
void WindowDragTest::TearDownTestCase() {}
void WindowDragTest::SetUp()
{
dragWindowInfo_ = {
.name = "dragWindow",
.rect = {200, 200, 380, 380},
.type = WindowType::WINDOW_TYPE_DRAGGING_EFFECT,
.mode = WindowMode::WINDOW_MODE_FLOATING,
.needAvoid = false,
.parentLimit = false,
.parentName = "",
};
firstWindowInfo_ = {
.name = "firstWindow",
.rect = utils::customAppRect_,
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
.needAvoid = false,
.parentLimit = false,
.parentName = "",
};
secondWindowInfo_ = {
.name = "secondWindow",
.rect = utils::customAppRect_,
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
.mode = WindowMode::WINDOW_MODE_FLOATING,
.needAvoid = false,
.parentLimit = false,
.parentName = "",
};
}
void WindowDragTest::TearDown() {}
namespace {
/**
* @tc.name: DragIn
* @tc.desc: Drag a window to another window
* @tc.type: FUNC
* @tc.require: AR000GKB4M
*/
HWTEST_F(WindowDragTest, DragIn, Function | MediumTest | Level3) {
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
firstWindow->RegisterDragListener(firstWindowDragListener_);
firstWindow->Show();
const sptr<Window> &dragWindow = utils::CreateTestWindow(dragWindowInfo_);
dragWindow->Show();
dragWindow->MoveTo(300, 300);
usleep(WAIT_CALLBACK_US);
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();
}
/**
* @tc.name: DragMove
* @tc.desc: Window Move
* @tc.type: FUNC
* @tc.require: AR000GKB4M
*/
HWTEST_F(WindowDragTest, DragMove, Function | MediumTest | Level3) {
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
firstWindow->RegisterDragListener(firstWindowDragListener_);
firstWindow->Show();
const sptr<Window> &dragWindow = utils::CreateTestWindow(dragWindowInfo_);
dragWindow->Show();
dragWindow->MoveTo(300, 300);
usleep(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);
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();
}
/**
* @tc.name: DragOut
* @tc.desc: Drag the drag window out of the current window
* @tc.type: FUNC
* @tc.require: AR000GKB4M
*/
HWTEST_F(WindowDragTest, DragOut, Function | MediumTest | Level3) {
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
firstWindow->RegisterDragListener(firstWindowDragListener_);
firstWindow->Show();
secondWindowInfo_.rect = {500, 500, 500, 500};
const sptr<Window> &secondWindow = utils::CreateTestWindow(secondWindowInfo_);
secondWindow->RegisterDragListener(secondWindowDragListener_);
secondWindow->Show();
const sptr<Window> &dragWindow = utils::CreateTestWindow(dragWindowInfo_);
dragWindow->Show();
dragWindow->MoveTo(300, 300);
usleep(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);
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);
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();
}
/**
* @tc.name: DragEnd
* @tc.desc: End window drag
* @tc.type: FUNC
* @tc.require: AR000GKB4M
*/
HWTEST_F(WindowDragTest, DragEnd, Function | MediumTest | Level3) {
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
firstWindow->RegisterDragListener(firstWindowDragListener_);
firstWindow->Show();
const sptr<Window> &dragWindow = utils::CreateTestWindow(dragWindowInfo_);
dragWindow->Show();
dragWindow->MoveTo(199, 199);
usleep(WAIT_CALLBACK_US);
dragWindow->Destroy();
usleep(WAIT_CALLBACK_US);
ASSERT_EQ(DragEvent::DRAG_EVENT_END, firstWindowDragListener_->event_);
firstWindow->UnregisterDragListener(firstWindowDragListener_);
firstWindow->Destroy();
}
} // namespace
} // namespace Rosen
} // namespace OHOS
+2 -3
View File
@@ -76,10 +76,9 @@ void WindowFocusTest::SetUpTestCase()
if (display == nullptr) {
WLOGFE("GetDefaultDisplay: failed!");
return;
} else {
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate());
}
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate());
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
utils::InitByDisplayRect(displayRect);
}
+3 -3
View File
@@ -163,10 +163,10 @@ void WindowImmersiveTest::SetUpTestCase()
auto display = DisplayManager::GetInstance().GetDisplayById(0);
if (display == nullptr) {
WLOGFE("GetDefaultDisplay: failed!");
} else {
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate());
return;
}
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate());
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
utils::InitByDisplayRect(displayRect);
}
@@ -38,10 +38,9 @@ void WindowInputMethodTest::SetUpTestCase()
if (display == nullptr) {
printf("GetDefaultDisplay: failed!\n");
return;
} else {
printf("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
display->GetHeight(), display->GetFreshRate());
}
printf("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
display->GetHeight(), display->GetFreshRate());
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
utils::InitByDisplayRect(displayRect);
}
+3 -3
View File
@@ -42,10 +42,10 @@ void WindowLayoutTest::SetUpTestCase()
auto display = DisplayManager::GetInstance().GetDisplayById(0);
if (display == nullptr) {
printf("GetDefaultDisplay: failed!\n");
} else {
printf("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
display->GetHeight(), display->GetFreshRate());
return;
}
printf("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(),
display->GetHeight(), display->GetFreshRate());
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
utils::InitByDisplayRect(displayRect);
+3 -3
View File
@@ -78,10 +78,10 @@ void WindowMoveDragTest::SetUp()
auto display = DisplayManager::GetInstance().GetDisplayById(0);
if (display == nullptr) {
WLOGFE("GetDefaultDisplay: failed!\n");
} else {
WLOGFI("GetDefaultDisplay: id %{public}llu, w %{public}d, h %{public}d, fps %{public}u\n",
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate());
return;
}
WLOGFI("GetDefaultDisplay: id %{public}llu, w %{public}d, h %{public}d, fps %{public}u\n",
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate());
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
utils::InitByDisplayRect(displayRect);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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.
* You may obtain a copy of the License at
@@ -64,6 +64,7 @@ static void ShowHideWindowSceneCallable(int i)
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
usleep(sleepTimeMs);
}
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
}
static void CreateDestroyWindowSceneCallable(int i)
@@ -79,6 +80,8 @@ static void CreateDestroyWindowSceneCallable(int i)
usleep(sleepTimeMs);
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
usleep(sleepTimeMs);
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
usleep(sleepTimeMs);
scene.clear();
usleep(sleepTimeMs);
}
@@ -107,6 +110,11 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow01, Function | MediumTest | L
ASSERT_EQ(WMError::WM_OK, scene3->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene2->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene1->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene2->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene4->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene5->GoDestroy());
}
/**
@@ -146,5 +154,67 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow03, Function | MediumTest | L
th4.join();
th5.join();
}
/**
* @tc.name: MultiAbilityWindow04
* @tc.desc: Five scene process in one thread, create/show/hide/destroy in order
* @tc.type: FUNC
*/
HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow04, Function | MediumTest | Level3)
{
sptr<WindowScene> scene1 = utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene1->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene1->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy());
sptr<WindowScene> scene2 = utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene2->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene2->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene2->GoDestroy());
sptr<WindowScene> scene3 = utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene3->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene3->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy());
sptr<WindowScene> scene4 = utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene4->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene4->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene4->GoDestroy());
sptr<WindowScene> scene5 = utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene5->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene5->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene5->GoDestroy());
}
/**
* @tc.name: MultiAbilityWindow05
* @tc.desc: Five scene process in one thread, create/show/hide/destroy out of order
* @tc.type: FUNC
*/
HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow05, Function | MediumTest | Level3)
{
sptr<WindowScene> scene1 = utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene1->GoForeground());
sptr<WindowScene> scene2 = utils::CreateWindowScene();
sptr<WindowScene> scene3 = utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene3->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene1->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy());
sptr<WindowScene> scene4 = utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene3->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene2->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene4->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene2->GoBackground());
sptr<WindowScene> scene5 = utils::CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene5->GoForeground());
ASSERT_EQ(WMError::WM_OK, scene5->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene4->GoBackground());
ASSERT_EQ(WMError::WM_OK, scene4->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene5->GoDestroy());
ASSERT_EQ(WMError::WM_OK, scene2->GoDestroy());
}
} // namespace Rosen
} // namespace OHOS
+152 -31
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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.
* You may obtain a copy of the License at
@@ -62,16 +62,18 @@ static sptr<WindowScene> CreateWindowScene()
}
static sptr<Window> CreateSubWindow(sptr<WindowScene> scene, WindowType type,
WindowMode mode, struct Rect rect, uint32_t flags)
struct Rect rect, uint32_t flags, std::string name = "")
{
sptr<WindowOption> subOp = new WindowOption();
subOp->SetWindowType(type);
subOp->SetWindowMode(mode);
subOp->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
subOp->SetWindowRect(rect);
subOp->SetWindowFlags(flags);
static int cnt = 0;
return scene->CreateWindow("SubWindow" + std::to_string(cnt++), subOp);
std::string subWinName = (name == "") ? "SubWindow" + std::to_string(cnt++) : name;
return scene->CreateWindow(subWinName, subOp);
}
/**
@@ -85,8 +87,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow01, Function | MediumTest | Level2)
struct Rect rect = {0, 0, 100, 200};
uint32_t flags = 0;
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW,
WindowMode::WINDOW_MODE_FLOATING, rect, flags);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags);
ASSERT_NE(nullptr, subWindow);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
@@ -94,6 +95,9 @@ HWTEST_F(WindowSubWindowTest, SubWindow01, Function | MediumTest | Level2)
ASSERT_EQ(WMError::WM_OK, subWindow->Hide());
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
subWindow->Destroy();
scene->GoDestroy();
}
/**
@@ -107,8 +111,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow02, Function | MediumTest | Level2)
struct Rect rect = {0, 0, 100, 200};
uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW,
WindowMode::WINDOW_MODE_FLOATING, rect, flags);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags);
ASSERT_NE(nullptr, subWindow);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
@@ -116,6 +119,9 @@ HWTEST_F(WindowSubWindowTest, SubWindow02, Function | MediumTest | Level2)
ASSERT_EQ(WMError::WM_OK, subWindow->Hide());
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
subWindow->Destroy();
scene->GoDestroy();
}
/**
@@ -129,8 +135,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow03, Function | MediumTest | Level2)
struct Rect rect = {0, 2000, 100, 200};
uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA,
WindowMode::WINDOW_MODE_FLOATING, rect, flags);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA, rect, flags);
ASSERT_NE(nullptr, subWindow);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
@@ -138,6 +143,9 @@ HWTEST_F(WindowSubWindowTest, SubWindow03, Function | MediumTest | Level2)
ASSERT_EQ(WMError::WM_OK, subWindow->Hide());
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
subWindow->Destroy();
scene->GoDestroy();
}
/**
@@ -151,8 +159,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow04, Function | MediumTest | Level2)
struct Rect rect = {0, 2000, 3000, 2000};
uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA,
WindowMode::WINDOW_MODE_FLOATING, rect, flags);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA, rect, flags);
ASSERT_NE(nullptr, subWindow);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
@@ -160,6 +167,9 @@ HWTEST_F(WindowSubWindowTest, SubWindow04, Function | MediumTest | Level2)
ASSERT_EQ(WMError::WM_OK, subWindow->Hide());
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
subWindow->Destroy();
scene->GoDestroy();
}
/**
@@ -173,12 +183,10 @@ HWTEST_F(WindowSubWindowTest, SubWindow05, Function | MediumTest | Level3)
struct Rect rect = {0, 0, 100, 200};
uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA,
WindowMode::WINDOW_MODE_FLOATING, rect, flags);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA, rect, flags);
ASSERT_NE(nullptr, subWindow);
sptr<Window> subWindow2 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW,
WindowMode::WINDOW_MODE_FLOATING, rect, flags);
sptr<Window> subWindow2 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags);
ASSERT_NE(nullptr, subWindow2);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
@@ -188,11 +196,15 @@ HWTEST_F(WindowSubWindowTest, SubWindow05, Function | MediumTest | Level3)
ASSERT_EQ(WMError::WM_OK, subWindow->Hide());
ASSERT_EQ(WMError::WM_OK, subWindow2->Hide());
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
subWindow->Destroy();
subWindow2->Destroy();
scene->GoDestroy();
}
/**
* @tc.name: SubWindow06
* @tc.desc: FullScreen Main Window + FullScreen SubWindow
* @tc.desc: FullScreen Main Window + 2 SubWindows
* @tc.type: FUNC
*/
HWTEST_F(WindowSubWindowTest, SubWindow06, Function | MediumTest | Level3)
@@ -200,16 +212,23 @@ HWTEST_F(WindowSubWindowTest, SubWindow06, Function | MediumTest | Level3)
sptr<WindowScene> scene = CreateWindowScene();
struct Rect rect = {0, 0, 100, 200};
uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW,
WindowMode::WINDOW_MODE_FULLSCREEN, rect, flags);
ASSERT_NE(nullptr, subWindow);
sptr<Window> subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0);
ASSERT_NE(nullptr, subWindow0);
sptr<Window> subWindow1 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0);
ASSERT_NE(nullptr, subWindow1);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
ASSERT_EQ(WMError::WM_OK, subWindow->Show());
ASSERT_EQ(WMError::WM_OK, subWindow0->Show());
ASSERT_EQ(WMError::WM_OK, subWindow1->Show());
ASSERT_EQ(WMError::WM_OK, subWindow->Hide());
ASSERT_EQ(WMError::WM_OK, subWindow0->Hide());
ASSERT_EQ(WMError::WM_OK, subWindow1->Hide());
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
subWindow0->Destroy();
subWindow1->Destroy();
scene->GoDestroy();
}
/**
@@ -223,8 +242,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow07, Function | MediumTest | Level4)
struct Rect rect = {0, 0, 100, 200};
uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW,
WindowMode::WINDOW_MODE_FLOATING, rect, flags);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags);
ASSERT_NE(nullptr, subWindow);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
@@ -232,6 +250,9 @@ HWTEST_F(WindowSubWindowTest, SubWindow07, Function | MediumTest | Level4)
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
ASSERT_EQ(WMError::WM_OK, subWindow->Hide());
subWindow->Destroy();
scene->GoDestroy();
}
/**
@@ -245,8 +266,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow08, Function | MediumTest | Level4)
struct Rect rect = {0, 0, 100, 200};
uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW,
WindowMode::WINDOW_MODE_FLOATING, rect, flags);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags);
ASSERT_NE(nullptr, subWindow);
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, subWindow->Show());
@@ -263,8 +283,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow09, Function | MediumTest | Level2)
struct Rect rect = {0, 0, 100, 200};
uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW,
WindowMode::WINDOW_MODE_FLOATING, rect, flags);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags);
ASSERT_NE(nullptr, subWindow);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
@@ -274,6 +293,9 @@ HWTEST_F(WindowSubWindowTest, SubWindow09, Function | MediumTest | Level2)
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
ASSERT_EQ(WMError::WM_OK, subWindow->Destroy());
subWindow->Destroy();
scene->GoDestroy();
}
/**
@@ -287,8 +309,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow10, Function | MediumTest | Level2)
struct Rect rect = {0, 0, 100, 200};
uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW,
WindowMode::WINDOW_MODE_FLOATING, rect, flags);
sptr<Window> subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags);
ASSERT_NE(nullptr, subWindow);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
@@ -297,6 +318,106 @@ HWTEST_F(WindowSubWindowTest, SubWindow10, Function | MediumTest | Level2)
sptr<Window> mainWindow = scene->GetMainWindow();
ASSERT_EQ(WMError::WM_OK, mainWindow->Destroy());
ASSERT_EQ(WMError::WM_ERROR_DESTROYED_OBJECT, subWindow->Destroy());
scene->GoDestroy();
}
/**
* @tc.name: SubWindow11
* @tc.desc: FullScreen Main Window + 5 subWindows
* @tc.type: FUNC
*/
HWTEST_F(WindowSubWindowTest, SubWindow11, Function | MediumTest | Level3)
{
sptr<WindowScene> scene = CreateWindowScene();
struct Rect rect = {0, 0, 100, 200};
sptr<Window> subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0);
ASSERT_NE(nullptr, subWindow0);
sptr<Window> subWindow1 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0);
ASSERT_NE(nullptr, subWindow1);
sptr<Window> subWindow2 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0);
ASSERT_NE(nullptr, subWindow2);
sptr<Window> subWindow3 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0);
ASSERT_NE(nullptr, subWindow3);
sptr<Window> subWindow4 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0);
ASSERT_NE(nullptr, subWindow4);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
ASSERT_EQ(WMError::WM_OK, subWindow0->Show());
ASSERT_EQ(WMError::WM_OK, subWindow1->Show());
ASSERT_EQ(WMError::WM_OK, subWindow2->Show());
ASSERT_EQ(WMError::WM_OK, subWindow3->Show());
ASSERT_EQ(WMError::WM_OK, subWindow4->Show());
ASSERT_EQ(WMError::WM_OK, subWindow0->Hide());
ASSERT_EQ(WMError::WM_OK, subWindow1->Hide());
ASSERT_EQ(WMError::WM_OK, subWindow2->Hide());
ASSERT_EQ(WMError::WM_OK, subWindow3->Hide());
ASSERT_EQ(WMError::WM_OK, subWindow4->Hide());
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
subWindow0->Destroy();
subWindow1->Destroy();
subWindow2->Destroy();
subWindow3->Destroy();
subWindow4->Destroy();
scene->GoDestroy();
}
/**
* @tc.name: SubWindow12
* @tc.desc: FullScreen Main Window + 2 SubWindows with the same name
* @tc.type: FUNC
*/
HWTEST_F(WindowSubWindowTest, SubWindow12, Function | MediumTest | Level3)
{
sptr<WindowScene> scene = CreateWindowScene();
struct Rect rect = {0, 0, 100, 200};
sptr<Window> subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub0");
sptr<Window> subWindow1 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub0");
ASSERT_NE(nullptr, subWindow0);
ASSERT_EQ(nullptr, subWindow1);
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
ASSERT_EQ(WMError::WM_OK, subWindow0->Show());
ASSERT_EQ(WMError::WM_OK, subWindow0->Hide());
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
subWindow0->Destroy();
scene->GoDestroy();
}
/**
* @tc.name: SubWindow13
* @tc.desc: FullScreen Main Window + 2 subwindows with the same name but one create after another destroyed
* @tc.type: FUNC
*/
HWTEST_F(WindowSubWindowTest, SubWindow13, Function | MediumTest | Level3)
{
sptr<WindowScene> scene = CreateWindowScene();
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
struct Rect rect = {0, 0, 100, 200};
sptr<Window> subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub1");
ASSERT_NE(nullptr, subWindow0);
ASSERT_EQ(WMError::WM_OK, subWindow0->Show());
ASSERT_EQ(WMError::WM_OK, subWindow0->Destroy());
sptr<Window> subWindow1 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub1");
ASSERT_NE(nullptr, subWindow1);
ASSERT_EQ(WMError::WM_OK, subWindow1->Show());
ASSERT_EQ(WMError::WM_OK, subWindow1->Destroy());
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
scene->GoDestroy();
}
} // namespace Rosen
} // namespace OHOS
+3 -3
View File
@@ -275,10 +275,10 @@ void WindowTestUtils::InitSplitRects()
auto display = DisplayManager::GetInstance().GetDisplayById(0);
if (display == nullptr) {
WLOGFE("GetDefaultDisplay: failed!");
} else {
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate());
return;
}
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate());
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
displayRect_ = displayRect;
@@ -69,10 +69,10 @@ void WindowVisibilityInfoTest::SetUpTestCase()
auto display = DisplayManager::GetInstance().GetDisplayById(0);
if (display == nullptr) {
WLOGFE("GetDefaultDisplay: failed!");
} else {
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate());
return;
}
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate());
Rect displayRect = {0, 0,
static_cast<uint32_t>(display->GetWidth()), static_cast<uint32_t>(display->GetHeight())};
utils::InitByDisplayRect(displayRect);
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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.
# You may obtain a copy of the License at
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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.
* You may obtain a copy of the License at
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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.
# You may obtain a copy of the License at
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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.
* You may obtain a copy of the License at
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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.
* You may obtain a copy of the License at
+1 -1
View File
@@ -48,7 +48,7 @@ static AvoidPos GetAvoidPosType(const Rect& rect)
return AvoidPos::AVOID_POS_TOP;
} else {
return AvoidPos::AVOID_POS_BOTTOM;
}
}
} else {
if (rect.posX_ == 0) {
return AvoidPos::AVOID_POS_LEFT;
+3 -3
View File
@@ -101,8 +101,8 @@ void DragController::FinishDrag(uint32_t windowId)
sptr<WindowNode> DragController::GetHitWindow(DisplayId id, PointInfo point)
{
// get display by point
if (id == DISPLAY_ID_INVALD) {
// Need get display by point
if (id == DISPLAY_ID_INVALID) {
WLOGFE("Get invalid display");
return nullptr;
}
@@ -138,4 +138,4 @@ bool DragController::GetHitPoint(uint32_t windowId, PointInfo& point)
return true;
}
}
}
}
+3 -3
View File
@@ -49,7 +49,7 @@ void InputWindowMonitor::UpdateInputWindow(uint32_t windowId)
void InputWindowMonitor::UpdateInputWindowByDisplayId(DisplayId displayId)
{
if (displayId == DISPLAY_ID_INVALD) {
if (displayId == DISPLAY_ID_INVALID) {
return;
}
auto container = windowRoot_->GetOrCreateWindowNodeContainer(displayId);
@@ -86,8 +86,8 @@ void InputWindowMonitor::UpdateDisplaysInfo(const sptr<WindowNodeContainer>& con
}
MMI::PhysicalDisplayInfo physicalDisplayInfo = {
.id = static_cast<int32_t>(container->GetScreenId()),
.leftDisplayId = static_cast<int32_t>(DISPLAY_ID_INVALD),
.upDisplayId = static_cast<int32_t>(DISPLAY_ID_INVALD),
.leftDisplayId = static_cast<int32_t>(DISPLAY_ID_INVALID),
.upDisplayId = static_cast<int32_t>(DISPLAY_ID_INVALID),
.topLeftX = 0,
.topLeftY = 0,
.width = static_cast<int32_t>(screenMode->width_),
+1 -1
View File
@@ -107,7 +107,7 @@ WMError WindowController::RemoveWindowNode(uint32_t windowId)
WMError WindowController::DestroyWindow(uint32_t windowId, bool onlySelf)
{
DisplayId displayId = DISPLAY_ID_INVALD;
DisplayId displayId = DISPLAY_ID_INVALID;
auto node = windowRoot_->GetWindowNode(windowId);
if (node != nullptr) {
displayId = node->GetDisplayId();
+17 -10
View File
@@ -75,7 +75,6 @@ void WindowInnerManager::DrawSurface(const sptr<Window>& window)
} else {
DrawColor(rsSurface, width, height);
}
return;
}
void WindowInnerManager::DrawBitmap(std::shared_ptr<RSSurface>& rsSurface, uint32_t width, uint32_t height)
@@ -95,14 +94,16 @@ void WindowInnerManager::DrawBitmap(std::shared_ptr<RSSurface>& rsSurface, uint3
SkMatrix matrix;
SkRect rect;
rect.set(0, 0, static_cast<int>(width), static_cast<int>(height));
if (width < height) {
// rotate when devider is hozizon
matrix.setScale(static_cast<float>(height) / dividerBitmap_.width(),
static_cast<float>(width) / dividerBitmap_.height());
matrix.postRotate(-90.0f); // devider shader rotate -90.0
} else {
matrix.setScale(static_cast<float>(width) / dividerBitmap_.width(),
static_cast<float>(height) / dividerBitmap_.height());
if (dividerBitmap_.width() != 0 && dividerBitmap_.height() != 0) {
if (width < height) {
// rotate when divider is horizontal
matrix.setScale(static_cast<float>(height) / dividerBitmap_.width(),
static_cast<float>(width) / dividerBitmap_.height());
matrix.postRotate(-90.0f); // divider shader rotate -90.0
} else {
matrix.setScale(static_cast<float>(width) / dividerBitmap_.width(),
static_cast<float>(height) / dividerBitmap_.height());
}
}
paint.setShader(dividerBitmap_.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat));
if (paint.getShader() == nullptr) {
@@ -113,7 +114,6 @@ void WindowInnerManager::DrawBitmap(std::shared_ptr<RSSurface>& rsSurface, uint3
canvas->drawRect(rect, paint);
frame->SetDamageRegion(0, 0, width, height);
rsSurface->FlushFrame(frame);
return;
}
void WindowInnerManager::DrawColor(std::shared_ptr<RSSurface>& rsSurface, uint32_t width, uint32_t height)
@@ -254,6 +254,9 @@ void WindowInnerManager::HandleMessage()
}
// loop to handle massages
for (auto& msg : handleMsgs) {
if (msg == nullptr) {
continue;
}
auto cmdType = msg->cmdType;
using Func_t = void(WindowInnerManager::*)(std::unique_ptr<WindowMessage> winMsg);
static const std::map<InnerWMCmd, Func_t> funcMap = {
@@ -277,6 +280,10 @@ void WindowInnerManager::SendMessage(InnerWMCmd cmdType, DisplayId displayId)
return;
}
std::unique_ptr<WindowMessage> winMsg = std::make_unique<WindowMessage>();
if (winMsg == nullptr) {
WLOGFI("alloc winMsg failed");
return;
}
winMsg->cmdType = cmdType;
winMsg->displayId = displayId;
WLOGFI("SendMessage : displayId = %{public}" PRIu64", type = %{public}d",
@@ -75,5 +75,5 @@ void WindowManagerAgentController::UpdateWindowVisibilityInfo(
agent->UpdateWindowVisibilityInfo(windowVisibilityInfos);
}
}
}
}
} // namespace Rosen
} // namespace OHOS
+2 -2
View File
@@ -560,5 +560,5 @@ WMError WindowManagerProxy::GetTopWindowId(uint32_t mainWinId, uint32_t& topWinI
int32_t ret = reply.ReadInt32();
return static_cast<WMError>(ret);
}
}
}
} // namespace Rosen
} // namespace OHOS
+10 -14
View File
@@ -111,7 +111,7 @@ void WindowManagerService::OnStop()
WMError WindowManagerService::CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& property,
const std::shared_ptr<RSSurfaceNode>& surfaceNode, uint32_t& windowId)
{
WM_SCOPED_TRACE("wms:CreateWindow(%d)", windowId);
WM_SCOPED_TRACE("wms:CreateWindow(%u)", windowId);
if (window == nullptr || property == nullptr || surfaceNode == nullptr) {
WLOGFE("window is invalid");
return WMError::WM_ERROR_NULLPTR;
@@ -143,16 +143,16 @@ WMError WindowManagerService::AddWindow(sptr<WindowProperty>& property)
WMError WindowManagerService::RemoveWindow(uint32_t windowId)
{
WLOGFI("[WMS] Remove: %{public}d", windowId);
WM_SCOPED_TRACE("wms:RemoveWindow(%d)", windowId);
WLOGFI("[WMS] Remove: %{public}u", windowId);
WM_SCOPED_TRACE("wms:RemoveWindow(%u)", windowId);
std::lock_guard<std::recursive_mutex> lock(mutex_);
return windowController_->RemoveWindowNode(windowId);
}
WMError WindowManagerService::DestroyWindow(uint32_t windowId, bool onlySelf)
{
WLOGFI("[WMS] Destroy: %{public}d", windowId);
WM_SCOPED_TRACE("wms:DestroyWindow(%d)", windowId);
WLOGFI("[WMS] Destroy: %{public}u", windowId);
WM_SCOPED_TRACE("wms:DestroyWindow(%u)", windowId);
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto node = windowRoot_->GetWindowNode(windowId);
if (node != nullptr && node->GetWindowType() == WindowType::WINDOW_TYPE_DRAGGING_EFFECT) {
@@ -177,7 +177,7 @@ WMError WindowManagerService::ResizeRect(uint32_t windowId, const Rect& rect, Wi
WMError WindowManagerService::RequestFocus(uint32_t windowId)
{
WLOGFI("[WMS] RequestFocus: %{public}d", windowId);
WLOGFI("[WMS] RequestFocus: %{public}u", windowId);
WM_SCOPED_TRACE("wms:RequestFocus");
std::lock_guard<std::recursive_mutex> lock(mutex_);
return windowController_->RequestFocus(windowId);
@@ -227,7 +227,7 @@ WMError WindowManagerService::SetSystemBarProperty(uint32_t windowId, WindowType
WMError WindowManagerService::SaveAbilityToken(const sptr<IRemoteObject>& abilityToken, uint32_t windowId)
{
WLOGFI("[WMS] SaveAbilityToken: %{public}d", windowId);
WLOGFI("[WMS] SaveAbilityToken: %{public}u", windowId);
std::lock_guard<std::recursive_mutex> lock(mutex_);
return windowController_->SaveAbilityToken(abilityToken, windowId);
}
@@ -266,12 +266,8 @@ void WindowManagerService::UnregisterWindowManagerAgent(WindowManagerAgentType t
void WindowManagerService::OnWindowEvent(Event event, uint32_t windowId)
{
switch (event) {
case Event::REMOTE_DIED:
DestroyWindow(windowId, true);
break;
default:
break;
if (event == Event::REMOTE_DIED) {
DestroyWindow(windowId, true);
}
}
@@ -309,7 +305,7 @@ WMError WindowManagerService::MaxmizeWindow(uint32_t windowId)
WMError WindowManagerService::GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId)
{
WM_SCOPED_TRACE("wms:GetTopWindowId(%d)", mainWinId);
WM_SCOPED_TRACE("wms:GetTopWindowId(%u)", mainWinId);
std::lock_guard<std::recursive_mutex> lock(mutex_);
return windowController_->GetTopWindowId(mainWinId, topWinId);
}
+7 -11
View File
@@ -242,7 +242,7 @@ WMError WindowNodeContainer::DestroyWindowNode(sptr<WindowNode>& node, std::vect
WMError WindowNodeContainer::RemoveWindowNode(sptr<WindowNode>& node)
{
if (node == nullptr || !node->surfaceNode_) {
if (node == nullptr) {
WLOGFE("window node or surface node is nullptr, invalid");
return WMError::WM_ERROR_DESTROYED_OBJECT;
}
@@ -484,20 +484,17 @@ void WindowNodeContainer::NotifySystemBarDismiss(sptr<WindowNode>& node)
{
WM_FUNCTION_TRACE();
SystemBarRegionTints tints;
bool isChanged = false;
auto& sysBarPropMapNode = node->GetSystemBarProperty();
for (auto it : sysBarPropMapNode) {
it.second.enable_ = false;
if (sysBarTintMap_[it.first].prop_.enable_) {
sysBarTintMap_[it.first].prop_.enable_ = false;
isChanged = true;
it.second.enable_ = false;
node->SetSystemBarProperty(it.first, it.second);
tints.emplace_back(sysBarTintMap_[it.first]);
WLOGFI("system bar dismiss, type: %{public}d", static_cast<int32_t>(it.first));
}
}
if (isChanged) {
WindowManagerAgentController::GetInstance().UpdateSystemBarRegionTints(displayId_, tints);
}
WindowManagerAgentController::GetInstance().UpdateSystemBarRegionTints(displayId_, tints);
}
void WindowNodeContainer::NotifySystemBarTints()
@@ -668,8 +665,8 @@ void WindowNodeContainer::DumpScreenWindowTree()
Rect rect = node->GetLayoutRect();
const std::string& windowName = node->GetWindowName().size() < WINDOW_NAME_MAX_LENGTH ?
node->GetWindowName() : node->GetWindowName().substr(0, WINDOW_NAME_MAX_LENGTH);
WLOGI("DumpScreenWindowTree: %{public}10s %{public}5d %{public}4d %{public}4d %{public}4d %{public}4d " \
"[%{public}4d %{public}4d %{public}4d %{public}4d]",
WLOGI("DumpScreenWindowTree: %{public}10s %{public}5u %{public}4u %{public}4u %{public}4u %{public}4u " \
"[%{public}4d %{public}4d %{public}4u %{public}4u]",
windowName.c_str(), node->GetWindowId(), node->GetWindowType(), node->GetWindowMode(),
node->GetWindowFlags(), --zOrder, rect.posX_, rect.posY_, rect.width_, rect.height_);
return false;
@@ -882,8 +879,7 @@ void WindowNodeContainer::MinimizeWindowFromAbility(const sptr<WindowNode>& node
WLOGFW("Target abilityToken is nullptr, windowId:%{public}u", node->GetWindowId());
return;
}
AAFwk::AbilityManagerClient::GetInstance()->DoAbilityBackground(node->abilityToken_,
static_cast<uint32_t>(WindowStateChangeReason::NORMAL));
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(node->abilityToken_, true);
}
WMError WindowNodeContainer::MinimizeAppNodeExceptOptions(const std::vector<uint32_t> &exceptionalIds,
+3
View File
@@ -159,6 +159,9 @@ WMError WindowRoot::MaxmizeWindow(uint32_t windowId)
WLOGFE("add window failed, window container could not be found");
return WMError::WM_ERROR_NULLPTR;
}
auto property = node->GetWindowProperty();
uint32_t flags = property->GetWindowFlags() & (~(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID)));
property->SetWindowFlags(flags);
container->NotifySystemBarDismiss(node);
return WMError::WM_OK;
}