merge from master

Signed-off-by: hejunfei <hejunfei@huawei.com>
This commit is contained in:
hejunfei 2024-08-30 10:10:44 +08:00
commit 7c21390d82
50 changed files with 2080 additions and 274 deletions

View File

@ -47,6 +47,7 @@ ohos_shared_library("libdm_lite") {
"src/display_lite.cpp",
"src/display_manager_adapter_lite.cpp",
"src/display_manager_lite.cpp",
"src/screen_manager_lite.cpp",
]
configs = [

View File

@ -53,14 +53,41 @@ class DisplayManagerAdapterLite : public BaseAdapterLite {
WM_DECLARE_SINGLE_INSTANCE(DisplayManagerAdapterLite);
public:
virtual sptr<DisplayInfo> GetDefaultDisplayInfo();
virtual std::vector<DisplayId> GetAllDisplayIds();
virtual bool IsFoldable();
virtual FoldStatus GetFoldStatus();
virtual FoldDisplayMode GetFoldDisplayMode();
virtual void SetFoldDisplayMode(const FoldDisplayMode);
virtual sptr<DisplayInfo> GetDisplayInfo(DisplayId displayId);
virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId);
/*
* used by powermgr
*/
virtual bool WakeUpBegin(PowerStateChangeReason reason);
virtual bool WakeUpEnd();
virtual bool SuspendBegin(PowerStateChangeReason reason);
virtual bool SuspendEnd();
virtual bool SetDisplayState(DisplayState state);
virtual DisplayState GetDisplayState(DisplayId displayId);
virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level);
virtual uint32_t GetScreenBrightness(uint64_t screenId);
private:
static inline SingletonDelegator<DisplayManagerAdapterLite> delegator;
};
class ScreenManagerAdapterLite : public BaseAdapterLite {
WM_DECLARE_SINGLE_INSTANCE(ScreenManagerAdapterLite);
public:
/*
* used by powermgr
*/
virtual bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason);
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason);
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId);
private:
static inline SingletonDelegator<ScreenManagerAdapterLite> delegator;
};
} // namespace OHOS::Rosen
#endif // FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_LITE_H

View File

@ -29,6 +29,7 @@ namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerAdapterLite"};
}
WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerAdapterLite)
WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManagerAdapterLite)
#define INIT_PROXY_CHECK_RETURN(ret) \
@ -157,6 +158,94 @@ sptr<CutoutInfo> DisplayManagerAdapterLite::GetCutoutInfo(DisplayId displayId)
return displayManagerServiceProxy_->GetCutoutInfo(displayId);
}
/*
* used by powermgr
*/
bool DisplayManagerAdapterLite::WakeUpBegin(PowerStateChangeReason reason)
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->WakeUpBegin(reason);
}
bool DisplayManagerAdapterLite::WakeUpEnd()
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->WakeUpEnd();
}
bool DisplayManagerAdapterLite::SuspendBegin(PowerStateChangeReason reason)
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->SuspendBegin(reason);
}
bool DisplayManagerAdapterLite::SuspendEnd()
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->SuspendEnd();
}
bool DisplayManagerAdapterLite::SetDisplayState(DisplayState state)
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->SetDisplayState(state);
}
DisplayState DisplayManagerAdapterLite::GetDisplayState(DisplayId displayId)
{
INIT_PROXY_CHECK_RETURN(DisplayState::UNKNOWN);
return displayManagerServiceProxy_->GetDisplayState(displayId);
}
bool DisplayManagerAdapterLite::SetScreenBrightness(uint64_t screenId, uint32_t level)
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->SetScreenBrightness(screenId, level);
}
uint32_t DisplayManagerAdapterLite::GetScreenBrightness(uint64_t screenId)
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->GetScreenBrightness(screenId);
}
std::vector<DisplayId> DisplayManagerAdapterLite::GetAllDisplayIds()
{
WLOGFD("DisplayManagerAdapter::GetAllDisplayIds enter");
INIT_PROXY_CHECK_RETURN(std::vector<DisplayId>());
return displayManagerServiceProxy_->GetAllDisplayIds();
}
bool ScreenManagerAdapterLite::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state,
PowerStateChangeReason reason)
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->SetSpecifiedScreenPower(screenId, state, reason);
}
bool ScreenManagerAdapterLite::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->SetScreenPowerForAll(state, reason);
}
ScreenPowerState ScreenManagerAdapterLite::GetScreenPower(ScreenId dmsScreenId)
{
INIT_PROXY_CHECK_RETURN(ScreenPowerState::INVALID_STATE);
return displayManagerServiceProxy_->GetScreenPower(dmsScreenId);
}
DMSDeathRecipientLite::DMSDeathRecipientLite(BaseAdapterLite& adapter) : adapter_(adapter)
{

View File

@ -49,6 +49,10 @@ public:
DMError UnregisterDisplayModeListener(sptr<IDisplayModeListener> listener);
void OnRemoteDied();
sptr<DisplayLite> GetDisplayById(DisplayId displayId);
/*
* used by powermgr
*/
bool SetDisplayState(DisplayState state, DisplayStateCallback callback);
private:
void NotifyDisplayCreate(sptr<DisplayInfo> info);
void NotifyDisplayDestroy(DisplayId);
@ -56,9 +60,15 @@ private:
bool UpdateDisplayInfoLocked(sptr<DisplayInfo>);
void NotifyFoldStatusChanged(FoldStatus foldStatus);
void NotifyDisplayModeChanged(FoldDisplayMode displayMode);
/*
* used by powermgr
*/
void NotifyDisplayStateChanged(DisplayId id, DisplayState state);
void ClearDisplayStateCallback();
void Clear();
std::map<DisplayId, sptr<DisplayLite>> displayMap_;
DisplayStateCallback displayStateCallback_;
std::recursive_mutex& mutex_;
std::set<sptr<IDisplayListener>> displayListeners_;
std::set<sptr<IFoldStatusListener>> foldStatusListeners_;
@ -69,6 +79,11 @@ private:
sptr<DisplayManagerFoldStatusAgent> foldStatusListenerAgent_;
class DisplayManagerDisplayModeAgent;
sptr<DisplayManagerDisplayModeAgent> displayModeListenerAgent_;
/*
* used by powermgr
*/
class DisplayManagerAgent;
sptr<DisplayManagerAgent> displayStateAgent_;
};
class DisplayManagerLite::Impl::DisplayManagerListener : public DisplayManagerAgentDefault {
@ -174,6 +189,24 @@ private:
sptr<Impl> pImpl_;
};
/*
* used by powermgr
*/
class DisplayManagerLite::Impl::DisplayManagerAgent : public DisplayManagerAgentDefault {
public:
explicit DisplayManagerAgent(sptr<Impl> impl) : pImpl_(impl)
{
}
~DisplayManagerAgent() = default;
virtual void NotifyDisplayStateChanged(DisplayId id, DisplayState state) override
{
pImpl_->NotifyDisplayStateChanged(id, state);
}
private:
sptr<Impl> pImpl_;
};
void DisplayManagerLite::Impl::Clear()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
@ -186,6 +219,7 @@ void DisplayManagerLite::Impl::Clear()
if (res != DMError::DM_OK) {
WLOGFW("UnregisterDisplayManagerAgent DISPLAY_EVENT_LISTENER failed");
}
ClearDisplayStateCallback();
}
DisplayManagerLite::Impl::~Impl()
@ -531,4 +565,132 @@ sptr<DisplayLite> DisplayManagerLite::GetDisplayById(DisplayId displayId)
std::lock_guard<std::recursive_mutex> lock(mutex_);
return pImpl_->GetDisplayById(displayId);
}
/*
* used by powermgr
*/
bool DisplayManagerLite::WakeUpBegin(PowerStateChangeReason reason)
{
WLOGFD("[UL_POWER]WakeUpBegin start, reason:%{public}u", reason);
return SingletonContainer::Get<DisplayManagerAdapterLite>().WakeUpBegin(reason);
}
bool DisplayManagerLite::WakeUpEnd()
{
WLOGFD("[UL_POWER]WakeUpEnd start");
return SingletonContainer::Get<DisplayManagerAdapterLite>().WakeUpEnd();
}
bool DisplayManagerLite::SuspendBegin(PowerStateChangeReason reason)
{
// dms->wms notify other windows to hide
WLOGFD("[UL_POWER]SuspendBegin start, reason:%{public}u", reason);
return SingletonContainer::Get<DisplayManagerAdapterLite>().SuspendBegin(reason);
}
bool DisplayManagerLite::SuspendEnd()
{
WLOGFD("[UL_POWER]SuspendEnd start");
return SingletonContainer::Get<DisplayManagerAdapterLite>().SuspendEnd();
}
bool DisplayManagerLite::SetDisplayState(DisplayState state, DisplayStateCallback callback)
{
return pImpl_->SetDisplayState(state, callback);
}
DisplayState DisplayManagerLite::GetDisplayState(DisplayId displayId)
{
return SingletonContainer::Get<DisplayManagerAdapterLite>().GetDisplayState(displayId);
}
bool DisplayManagerLite::Impl::SetDisplayState(DisplayState state, DisplayStateCallback callback)
{
WLOGFD("[UL_POWER]state:%{public}u", state);
bool ret = true;
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (displayStateCallback_ != nullptr || callback == nullptr) {
WLOGFI("[UL_POWER]previous callback not called or callback invalid");
if (displayStateCallback_ != nullptr) {
WLOGFI("[UL_POWER]previous callback not called, the displayStateCallback_ is not null");
}
if (callback == nullptr) {
WLOGFI("[UL_POWER]Invalid callback received");
}
return false;
}
displayStateCallback_ = callback;
if (displayStateAgent_ == nullptr) {
displayStateAgent_ = new DisplayManagerAgent(this);
ret = SingletonContainer::Get<DisplayManagerAdapterLite>().RegisterDisplayManagerAgent(
displayStateAgent_,
DisplayManagerAgentType::DISPLAY_STATE_LISTENER) == DMError::DM_OK;
}
}
ret = ret && SingletonContainer::Get<DisplayManagerAdapterLite>().SetDisplayState(state);
if (!ret) {
ClearDisplayStateCallback();
}
return ret;
}
void DisplayManagerLite::Impl::NotifyDisplayStateChanged(DisplayId id, DisplayState state)
{
WLOGFD("state:%{public}u", state);
DisplayStateCallback displayStateCallback = nullptr;
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
displayStateCallback = displayStateCallback_;
}
if (displayStateCallback) {
displayStateCallback(state);
ClearDisplayStateCallback();
return;
}
WLOGFW("callback_ target is not set!");
}
void DisplayManagerLite::Impl::ClearDisplayStateCallback()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
WLOGFD("[UL_POWER]Clear displaystatecallback enter");
displayStateCallback_ = nullptr;
if (displayStateAgent_ != nullptr) {
WLOGFI("[UL_POWER]UnregisterDisplayManagerAgent enter and displayStateAgent_ is cleared");
SingletonContainer::Get<DisplayManagerAdapterLite>().UnregisterDisplayManagerAgent(displayStateAgent_,
DisplayManagerAgentType::DISPLAY_STATE_LISTENER);
displayStateAgent_ = nullptr;
}
}
bool DisplayManagerLite::SetScreenBrightness(uint64_t screenId, uint32_t level)
{
WLOGFI("[UL_POWER]SetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level);
SingletonContainer::Get<DisplayManagerAdapterLite>().SetScreenBrightness(screenId, level);
return true;
}
uint32_t DisplayManagerLite::GetScreenBrightness(uint64_t screenId) const
{
uint32_t level = SingletonContainer::Get<DisplayManagerAdapterLite>().GetScreenBrightness(screenId);
WLOGFI("GetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level);
return level;
}
DisplayId DisplayManagerLite::GetDefaultDisplayId()
{
auto info = SingletonContainer::Get<DisplayManagerAdapterLite>().GetDefaultDisplayInfo();
if (info == nullptr) {
return DISPLAY_ID_INVALID;
}
return info->GetDisplayId();
}
std::vector<DisplayId> DisplayManagerLite::GetAllDisplayIds()
{
return SingletonContainer::Get<DisplayManagerAdapterLite>().GetAllDisplayIds();
}
} // namespace OHOS::Rosen

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "screen_manager_lite.h"
#include "display_manager_adapter_lite.h"
#include "singleton_delegator.h"
#include "window_manager_hilog.h"
namespace OHOS::Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenManagerLite"};
}
WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManagerLite)
ScreenManagerLite::ScreenManagerLite()
{
WLOGFD("Create ScreenManagerLite instance");
}
ScreenManagerLite::~ScreenManagerLite()
{
WLOGFD("Destroy ScreenManagerLite instance");
}
/*
* used by powermgr
*/
bool ScreenManagerLite::SetSpecifiedScreenPower(ScreenId screenId,
ScreenPowerState state, PowerStateChangeReason reason)
{
WLOGFI("screenId:%{public}" PRIu64 ", state:%{public}u, reason:%{public}u", screenId, state, reason);
return SingletonContainer::Get<ScreenManagerAdapterLite>().SetSpecifiedScreenPower(screenId, state, reason);
}
bool ScreenManagerLite::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
{
WLOGFI("state:%{public}u, reason:%{public}u", state, reason);
return SingletonContainer::Get<ScreenManagerAdapterLite>().SetScreenPowerForAll(state, reason);
}
ScreenPowerState ScreenManagerLite::GetScreenPower(ScreenId dmsScreenId)
{
return SingletonContainer::Get<ScreenManagerAdapterLite>().GetScreenPower(dmsScreenId);
}
} // namespace OHOS::Rosen

View File

@ -20,6 +20,7 @@ group("unittest") {
testonly = true
deps = [
":dm_display_lite_power_unit_test",
":dm_display_lite_test",
":dm_display_manager_adapter_lite_test",
":dm_display_manager_lite_test",
@ -72,6 +73,21 @@ ohos_unittest("dm_display_manager_lite_test") {
]
}
ohos_unittest("dm_display_lite_power_unit_test") {
module_out_path = module_out_path
include_dirs = [ "../../src" ]
sources = [ "display_lite_power_unit_test.cpp" ]
deps = [ ":dm_unittest_common_lite" ]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
]
}
## Build dm_unittest_common_lite.a {{{
config("dm_unittest_common_public_config") {
include_dirs = [

View File

@ -0,0 +1,211 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include "display_manager_lite.h"
#include "screen_manager_lite.h"
#include "mock_display_manager_adapter_lite.h"
#include "singleton_mocker.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
using Mocker = SingletonMocker<DisplayManagerAdapterLite, MockDisplayManagerAdapterLite>;
class DisplayLitePowerUnitTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
static inline DisplayId defaultId_ = 0;
static inline uint32_t brightnessLevel_ = 80;
static inline ScreenPowerState initialPowerState_;
static inline DisplayState initialState_;
};
void DisplayLitePowerUnitTest::SetUpTestCase()
{
}
void DisplayLitePowerUnitTest::TearDownTestCase()
{
}
void DisplayLitePowerUnitTest::SetUp()
{
initialPowerState_ = ScreenManagerLite::GetInstance().GetScreenPower(defaultId_);
initialState_ = DisplayManagerLite::GetInstance().GetDisplayState(defaultId_);
}
void DisplayLitePowerUnitTest::TearDown()
{
ScreenManagerLite::GetInstance().SetScreenPowerForAll(initialPowerState_, PowerStateChangeReason::POWER_BUTTON);
DisplayStateCallback callback;
DisplayManagerLite::GetInstance().SetDisplayState(initialState_, callback);
}
namespace {
/**
* @tc.name: wake_up_begin_001
* @tc.desc: call WakeUpBegin and check return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, wake_up_begin_001, Function | SmallTest | Level2)
{
Mocker m;
EXPECT_CALL(m.Mock(), WakeUpBegin(PowerStateChangeReason::POWER_BUTTON)).Times(1).WillOnce(Return(true));;
bool ret = DisplayManagerLite::GetInstance().WakeUpBegin(PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(true, ret);
EXPECT_CALL(m.Mock(), WakeUpBegin(PowerStateChangeReason::POWER_BUTTON)).Times(1).WillOnce(Return(false));;
ret = DisplayManagerLite::GetInstance().WakeUpBegin(PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(false, ret);
}
/**
* @tc.name: wake_up_end_001
* @tc.desc: call WakeUpEnd and check return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, wake_up_end_001, Function | SmallTest | Level2)
{
Mocker m;
EXPECT_CALL(m.Mock(), WakeUpEnd()).Times(1).WillOnce(Return(true));
bool ret = DisplayManagerLite::GetInstance().WakeUpEnd();
ASSERT_EQ(true, ret);
EXPECT_CALL(m.Mock(), WakeUpEnd()).Times(1).WillOnce(Return(false));
ret = DisplayManagerLite::GetInstance().WakeUpEnd();
ASSERT_EQ(false, ret);
}
/**
* @tc.name: suspend_begin_001
* @tc.desc: call SuspendBegin and check return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, suspend_begin_001, Function | SmallTest | Level2)
{
Mocker m;
EXPECT_CALL(m.Mock(), SuspendBegin(PowerStateChangeReason::POWER_BUTTON)).Times(1).WillOnce(Return(true));;
bool ret = DisplayManagerLite::GetInstance().SuspendBegin(PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(true, ret);
EXPECT_CALL(m.Mock(), SuspendBegin(PowerStateChangeReason::POWER_BUTTON)).Times(1).WillOnce(Return(false));;
ret = DisplayManagerLite::GetInstance().SuspendBegin(PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(false, ret);
}
/**
* @tc.name: suspend_end_001
* @tc.desc: call SuspendEnd and check return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, suspend_end_001, Function | SmallTest | Level2)
{
Mocker m;
EXPECT_CALL(m.Mock(), SuspendEnd()).Times(1).WillOnce(Return(true));
bool ret = DisplayManagerLite::GetInstance().SuspendEnd();
ASSERT_EQ(true, ret);
EXPECT_CALL(m.Mock(), SuspendEnd()).Times(1).WillOnce(Return(false));
ret = DisplayManagerLite::GetInstance().SuspendEnd();
ASSERT_EQ(false, ret);
}
/**
* @tc.name: set_screen_brightness_001
* @tc.desc: Call SetScreenBrightness with a valid value and check the GetScreenBrightness return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, set_screen_brightness_001, Function | MediumTest | Level2)
{
bool ret = DisplayManagerLite::GetInstance().SetScreenBrightness(defaultId_, brightnessLevel_);
ASSERT_EQ(true, ret);
}
/**
* @tc.name: SetSpecifiedScreenPower
* @tc.desc: test SetSpecifiedScreenPower
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, set_specified_screen_power_001, Function | SmallTest | Level2)
{
ScreenPowerState state = ScreenPowerState{0};
PowerStateChangeReason reason = PowerStateChangeReason{0};
bool ret = ScreenManagerLite::GetInstance().SetSpecifiedScreenPower(0, state, reason);
ASSERT_TRUE(ret);
}
/**
* @tc.name: set_screen_power_for_all_001
* @tc.desc: Call SetScreenPowerForAll with valid value and check the GetScreenPower return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, set_screen_power_for_all_001, Function | MediumTest | Level2)
{
SingletonMocker<ScreenManagerAdapterLite, MockScreenManagerAdapterLite> m;
EXPECT_CALL(m.Mock(), GetScreenPower(_)).Times(1).WillOnce(Return(ScreenPowerState::POWER_OFF));
EXPECT_CALL(m.Mock(), SetScreenPowerForAll(_, PowerStateChangeReason::POWER_BUTTON))
.Times(1).WillOnce(Return(true));
bool ret = ScreenManagerLite::GetInstance().SetScreenPowerForAll(ScreenPowerState::POWER_OFF,
PowerStateChangeReason::POWER_BUTTON);
ASSERT_EQ(true, ret);
ScreenPowerState state = ScreenManagerLite::GetInstance().GetScreenPower(defaultId_);
ASSERT_EQ(state, ScreenPowerState::POWER_OFF);
}
/**
* @tc.name: set_display_state_001
* @tc.desc: Call SetDisplayState with valid value and check the GetDisplayState return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, set_display_state_001, Function | MediumTest | Level2)
{
DisplayState stateToSet = (initialState_ == DisplayState::OFF ? DisplayState::ON : DisplayState::OFF);
Mocker m;
EXPECT_CALL(m.Mock(), RegisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_STATE_LISTENER))
.Times(1).WillOnce(Return(DMError::DM_OK));
EXPECT_CALL(m.Mock(), SetDisplayState(stateToSet)).Times(1).WillOnce(Return(true));
DisplayStateCallback callback = [](DisplayState state) {};
bool ret = DisplayManagerLite::GetInstance().SetDisplayState(stateToSet, callback);
ASSERT_EQ(true, ret);
EXPECT_CALL(m.Mock(), GetDisplayState(defaultId_)).Times(1).WillOnce(Return(stateToSet));
DisplayState state = DisplayManagerLite::GetInstance().GetDisplayState(defaultId_);
ASSERT_EQ(state, stateToSet);
}
/**
* @tc.name: set_display_state_002
* @tc.desc: Call SetDisplayState with invalid callback and check the GetDisplayState return value
* @tc.type: FUNC
*/
HWTEST_F(DisplayLitePowerUnitTest, set_display_state_002, Function | MediumTest | Level2)
{
Mocker m;
EXPECT_CALL(m.Mock(), SetDisplayState(_)).Times(0);
DisplayState stateToSet = (initialState_ == DisplayState::OFF ? DisplayState::ON : DisplayState::OFF);
bool ret = DisplayManagerLite::GetInstance().SetDisplayState(stateToSet, nullptr);
ASSERT_EQ(false, ret);
}
}
}
}

View File

@ -100,6 +100,64 @@ HWTEST_F(DisplayManagerAdapterLiteTest, Clear01, Function | SmallTest | Level2)
SingletonContainer::Get<DisplayManagerAdapterLite>().Clear();
ASSERT_FALSE(SingletonContainer::Get<DisplayManagerAdapterLite>().isProxyValid_);
}
/**
* @tc.name: WakeUpBegin
* @tc.desc: test WakeUpBegin
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerAdapterLiteTest, WakeUpBegin, Function | SmallTest | Level2)
{
PowerStateChangeReason reason = PowerStateChangeReason{0};
bool ret = SingletonContainer::Get<DisplayManagerAdapterLite>().WakeUpBegin(reason);
ASSERT_TRUE(ret);
}
/**
* @tc.name: WakeUpEnd
* @tc.desc: test WakeUpEnd
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerAdapterLiteTest, WakeUpEnd, Function | SmallTest | Level2)
{
bool ret = SingletonContainer::Get<DisplayManagerAdapterLite>().WakeUpEnd();
ASSERT_TRUE(ret);
}
/**
* @tc.name: SuspendBegin
* @tc.desc: test SuspendBegin
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerAdapterLiteTest, SuspendBegin, Function | SmallTest | Level2)
{
PowerStateChangeReason reason = PowerStateChangeReason{0};
bool ret = SingletonContainer::Get<DisplayManagerAdapterLite>().SuspendBegin(reason);
ASSERT_TRUE(ret);
}
/**
* @tc.name: SuspendEnd
* @tc.desc: test SuspendEnd
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerAdapterLiteTest, SuspendEnd, Function | SmallTest | Level2)
{
bool ret = SingletonContainer::Get<DisplayManagerAdapterLite>().SuspendEnd();
ASSERT_TRUE(ret);
}
/**
* @tc.name: SetDisplayState
* @tc.desc: test SetDisplayState
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerAdapterLiteTest, SetDisplayState, Function | SmallTest | Level2)
{
DisplayState state = DisplayState{1};
bool ret = SingletonContainer::Get<DisplayManagerAdapterLite>().SetDisplayState(state);
ASSERT_FALSE(ret);
}
}
}
}

View File

@ -636,6 +636,19 @@ HWTEST_F(DisplayManagerTest, GetFoldDisplayMode03, Function | SmallTest | Level1
ASSERT_EQ(ret, FoldDisplayMode::UNKNOWN);
displayInfo.clear();
}
/**
* @tc.name: GetScreenBrightness
* @tc.desc: GetScreenBrightness
* @tc.type: FUNC
*/
HWTEST_F(DisplayManagerTest, GetScreenBrightness, Function | SmallTest | Level1)
{
uint64_t screenId = 2;
auto ret = DisplayManagerLite::GetInstance().GetScreenBrightness(screenId);
ASSERT_FALSE(ret == 1);
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -157,6 +157,87 @@ public:
* @return Default display object.
*/
sptr<DisplayLite> GetDisplayById(DisplayId displayId);
/*
* used by powermgr
*/
/**
* @brief Begin to wake up screen.
*
* @param reason Reason for power state change.
* @return True means begin success, false means begin failed.
*/
bool WakeUpBegin(PowerStateChangeReason reason);
/**
* @brief Wake up screen end.
*
* @return True means end success, false means end failed.
*/
bool WakeUpEnd();
/**
* @brief Begin to suspend the screen.
*
* @param reason Reason for power state change.
* @return True means begin success, false means begin failed.
*/
bool SuspendBegin(PowerStateChangeReason reason);
/**
* @brief Suspend screen end.
*
* @return True means suspend screen end success.
* @return False means suspend screen end failed.
*/
bool SuspendEnd();
/**
* @brief Set the Display State object
*
* @param state State of display.
* @param callback Callback for display state.
* @return True means set success, false means set failed.
*/
bool SetDisplayState(DisplayState state, DisplayStateCallback callback);
/**
* @brief Get the state of the target display.
*
* @param displayId Display id.
* @return State of display.
*/
DisplayState GetDisplayState(DisplayId displayId);
/**
* @brief Set the brightness level of the target screen.
*
* @param screenId Target screen.
* @param level Brightness level.
*/
bool SetScreenBrightness(uint64_t screenId, uint32_t level);
/**
* @brief Get the brightness level of the target screen.
*
* @param screenId Screen id.
* @return Brightness value of screen.
*/
uint32_t GetScreenBrightness(uint64_t screenId) const;
/**
* @brief Obtain the id of the default display.
*
* @return Default display id.
*/
DisplayId GetDefaultDisplayId();
/**
* @brief Get IDs of all displays.
*
* @return All display IDs.
*/
std::vector<DisplayId> GetAllDisplayIds();
private:
DisplayManagerLite();
~DisplayManagerLite();

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_DM_SCREEN_MANAGER_H
#define FOUNDATION_DM_SCREEN_MANAGER_H
#include <refbase.h>
#include "dm_common.h"
#include "wm_single_instance.h"
namespace OHOS::Rosen {
class ScreenManagerLite : public RefBase {
WM_DECLARE_SINGLE_INSTANCE_BASE(ScreenManagerLite);
friend class DMSDeathRecipient;
public:
/*
* used by powermgr
*/
/**
* @brief Set the screen power state on the specified screen.
*
* @param screenId Screen id.
* @param state Screen power state.
* @param reason Reason for power state change.
* @return True means set success, false means set failed.
*/
bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason);
/**
* @brief Set the screen power states for all screens.
*
* @param state Screen power state.
* @param reason Reason for power state change.
* @return True means set success, false means set failed.
*/
bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason);
/**
* @brief Get screen power state.
*
* @param screenId Screen id.
* @return Power state of screen.
*/
ScreenPowerState GetScreenPower(ScreenId screenId);
private:
ScreenManagerLite();
~ScreenManagerLite();
void OnRemoteDied();
};
} // namespace OHOS::Rosen
#endif // FOUNDATION_DM_SCREEN_MANAGER_H

View File

@ -30,6 +30,26 @@ public:
DisplayManagerAgentType type));
MOCK_METHOD0(GetDefaultDisplayInfo, sptr<DisplayInfo>());
MOCK_METHOD1(GetDisplayInfo, sptr<DisplayInfo>(DisplayId displayId));
MOCK_METHOD1(WakeUpBegin, bool(PowerStateChangeReason reason));
MOCK_METHOD0(WakeUpEnd, bool());
MOCK_METHOD1(SuspendBegin, bool(PowerStateChangeReason reason));
MOCK_METHOD0(SuspendEnd, bool());
MOCK_METHOD1(SetDisplayState, bool(DisplayState state));
MOCK_METHOD1(GetDisplayState, DisplayState(DisplayId displayId));
};
class MockScreenManagerAdapterLite : public ScreenManagerAdapterLite {
public:
MOCK_METHOD0(Clear, void());
MOCK_METHOD2(RegisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type));
MOCK_METHOD2(UnregisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type));
MOCK_METHOD3(SetSpecifiedScreenPower, bool(ScreenId screenId, ScreenPowerState state,
PowerStateChangeReason reason));
MOCK_METHOD2(SetScreenPowerForAll, bool(ScreenPowerState state, PowerStateChangeReason reason));
MOCK_METHOD1(GetScreenPower, ScreenPowerState(ScreenId dmsScreenId));
};
}
} // namespace OHOS

View File

@ -384,7 +384,7 @@ HWTEST_F(DisplayManagerTest, SetVirtualScreenSecurityExemption, Function | Small
uint32_t pid = 0;
std::vector<uint64_t> windowList;
auto ret = DisplayManager::GetInstance().SetVirtualScreenSecurityExemption(id, pid, windowList);
ASSERT_EQ(DMError::DM_OK, ret);
ASSERT_NE(DMError::DM_OK, ret); // not virtual screen for id 0
sleep(2);
}

View File

@ -360,7 +360,6 @@ void WindowSessionProperty::SetWindowFlags(uint32_t flags)
flags_ = flags;
}
/** @note @window.hierarchy */
void WindowSessionProperty::SetTopmost(bool topmost)
{
topmost_ = topmost;

View File

@ -44,14 +44,12 @@ public:
void OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const override;
void OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const override;
void OnInputEvent(std::shared_ptr<MMI::AxisEvent> axisEvent) const override;
void RegisterWindowChanged();
private:
void DispatchKeyEventCallback(
int32_t focusedSessionId, std::shared_ptr<MMI::KeyEvent> keyEvent, bool consumed) const;
void UpdateLastMouseEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const;
bool CheckPointerEvent(const std::shared_ptr<MMI::PointerEvent> pointerEvent) const;
void ProcessEnterLeaveEventAsync();
bool IsKeyboardEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const;
Ace::UIContent* uiContent_ = nullptr;
std::weak_ptr<AppExecFwk::EventHandler> weakEventConsumer_;

View File

@ -105,63 +105,6 @@ bool IntentionEventManager::EnableInputEventListener(Ace::UIContent* uiContent,
return true;
}
void IntentionEventManager::InputEventListener::RegisterWindowChanged()
{}
void IntentionEventManager::InputEventListener::ProcessEnterLeaveEventAsync()
{
auto task = [this]() {
std::lock_guard<std::mutex> guard(mouseEventMutex_);
if ((g_lastMouseEvent == nullptr) ||
(g_lastMouseEvent->GetButtonId() != MMI::PointerEvent::BUTTON_NONE &&
g_lastMouseEvent->GetPointerAction() != MMI::PointerEvent::POINTER_ACTION_BUTTON_UP)) {
return;
}
auto enterSession = SceneSession::GetEnterWindow().promote();
if (enterSession == nullptr) {
WLOGFE("Enter session is null, do not reissuing enter leave events");
return;
}
if (g_lastLeaveWindowId == enterSession->GetPersistentId()) {
WLOGFI("g_lastLeaveWindowId:%{public}d equal enterSession id", g_lastLeaveWindowId);
return;
}
WLOGFD("Reissue enter leave, persistentId:%{public}d", enterSession->GetPersistentId());
auto leavePointerEvent = std::make_shared<MMI::PointerEvent>(*g_lastMouseEvent);
if (leavePointerEvent != nullptr) {
leavePointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_LEAVE_WINDOW);
}
WSError ret = enterSession->TransferPointerEvent(leavePointerEvent);
if (ret != WSError::WS_OK && leavePointerEvent != nullptr) {
leavePointerEvent->MarkProcessed();
}
g_lastLeaveWindowId = enterSession->GetPersistentId();
auto enterPointerEvent = std::make_shared<MMI::PointerEvent>(*g_lastMouseEvent);
if (enterPointerEvent == nullptr) {
WLOGFE("The enter pointer event is nullptr");
return;
}
enterPointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW);
if (uiContent_ == nullptr) {
WLOGFE("ProcessEnterLeaveEventAsync uiContent_ is null");
return;
}
if (!(uiContent_->ProcessPointerEvent(enterPointerEvent))) {
WLOGFE("The UI content consumes pointer event failed");
enterPointerEvent->MarkProcessed();
}
};
auto eventHandler = weakEventConsumer_.lock();
if (eventHandler == nullptr) {
WLOGFE("ProcessEnterLeaveEventAsync eventHandler is null");
return;
}
eventHandler->PostTask(std::move(task), "wms:ProcessEventLeaveEventAsync",
DELAY_TIME, AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
void IntentionEventManager::InputEventListener::UpdateLastMouseEvent(
std::shared_ptr<MMI::PointerEvent> pointerEvent) const
{

View File

@ -184,6 +184,8 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj)
JsSceneSessionManager::IsScbCoreEnabled);
BindNativeFunction(env, exportObj, "updateAppHookDisplayInfo", moduleName,
JsSceneSessionManager::UpdateAppHookDisplayInfo);
BindNativeFunction(env, exportObj, "refreshPcZOrder", moduleName,
JsSceneSessionManager::RefreshPcZOrder);
return NapiGetUndefined(env);
}
@ -898,6 +900,13 @@ napi_value JsSceneSessionManager::IsScbCoreEnabled(napi_env env, napi_callback_i
return (me != nullptr) ? me->OnIsScbCoreEnabled(env, info) : nullptr;
}
napi_value JsSceneSessionManager::RefreshPcZOrder(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]");
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
return (me != nullptr) ? me->OnRefreshPcZOrder(env, info) : nullptr;
}
bool JsSceneSessionManager::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject)
{
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsSceneSessionManager::IsCallbackRegistered[%s]", type.c_str());
@ -2953,4 +2962,33 @@ napi_value JsSceneSessionManager::OnIsScbCoreEnabled(napi_env env, napi_callback
napi_get_boolean(env, Session::IsScbCoreEnabled(), &result);
return result;
}
} // namespace OHOS::Rosen
napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_info info)
{
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < ARGC_TWO) {
TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc);
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
uint32_t startZOrder;
if (!ConvertFromJsValue(env, argv[0], startZOrder)) {
TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert start Z order to %{public}d", startZOrder);
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
std::vector<int32_t> persistentIds;
if (!ConvertInt32ArrayFromJs(env, argv[1], persistentIds)) {
TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert persistentIds");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
return NapiGetUndefined(env);
}
SceneSessionManager::GetInstance().RefreshPcZOrderList(startZOrder, std::move(persistentIds));
return NapiGetUndefined(env);
}
} // namespace OHOS::Rosen

View File

@ -103,6 +103,7 @@ public:
static napi_value GetFreeMultiWindowConfig(napi_env env, napi_callback_info info);
static napi_value GetIsLayoutFullScreen(napi_env env, napi_callback_info info);
static napi_value IsScbCoreEnabled(napi_env env, napi_callback_info info);
static napi_value RefreshPcZOrder(napi_env env, napi_callback_info info);
private:
napi_value OnRegisterCallback(napi_env env, napi_callback_info info);
@ -159,6 +160,7 @@ private:
napi_value OnInitScheduleUtils(napi_env env, napi_callback_info info);
napi_value OnSetAppForceLandscapeConfig(napi_env env, napi_callback_info info);
napi_value OnIsScbCoreEnabled(napi_env env, napi_callback_info info);
napi_value OnRefreshPcZOrder(napi_env env, napi_callback_info info);
void OnStatusBarEnabledUpdate(bool enable, const std::string& bundleName);
void OnGestureNavigationEnabledUpdate(bool enable, const std::string& bundleName);

View File

@ -393,6 +393,7 @@ public:
void SetMinimizedFlagByUserSwitch(bool isMinimized);
bool IsMinimizedByUserSwitch() const;
void UnregisterSessionChangeListeners() override;
void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel; }
protected:
void NotifySessionRectChange(const WSRect& rect, const SizeChangeReason& reason = SizeChangeReason::UNDEFINED);
@ -572,6 +573,11 @@ private:
// Multi User
bool isMinimizedByUserSwitch_ { false };
/*
* Window ZOrder: PC
*/
bool isPcScenePanel_ { false };
};
} // namespace OHOS::Rosen
#endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H

View File

@ -4271,7 +4271,9 @@ uint32_t SceneSession::UpdateUIParam(const SessionUIParam& uiParam)
static_cast<uint32_t>(SessionUIDirtyFlag::RECT) : 0;
dirtyFlags_ |= UpdateScaleInner(uiParam.scaleX_, uiParam.scaleY_, uiParam.pivotX_, uiParam.pivotY_) ?
static_cast<uint32_t>(SessionUIDirtyFlag::SCALE) : 0;
dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast<uint32_t>(SessionUIDirtyFlag::Z_ORDER) : 0;
if (!isPcScenePanel_) {
dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast<uint32_t>(SessionUIDirtyFlag::Z_ORDER) : 0;
}
if (!lastVisible && IsVisible() && !isFocused_ && !postProcessFocusState_.enabled_ &&
GetForegroundInteractiveStatus()) {
postProcessFocusState_.enabled_ = true;

View File

@ -378,6 +378,7 @@ public:
WMError TerminateSessionByPersistentId(int32_t persistentId);
WMError GetProcessSurfaceNodeIdByPersistentId(const int32_t pid,
const std::vector<int32_t>& persistentIds, std::vector<uint64_t>& surfaceNodeIds) override;
void RefreshPcZOrderList(uint32_t startZOrder, std::vector<int32_t>&& persistentIds);
protected:
SceneSessionManager();

View File

@ -43,7 +43,6 @@ public:
static void HandleSensorEventInput(DeviceRotation deviceRotation);
private:
static float ConvertDeviceToFloat(DeviceRotation deviceRotation);
static DeviceRotation ConvertSinglePocketOuterRotation(DeviceRotation deviceRotation);
};
} // Rosen
} // OHOS

View File

@ -47,6 +47,21 @@ public:
sptr<DisplayInfo> GetDefaultDisplayInfo() override;
virtual sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) override;
sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) override;
/*
* used by powermgr
*/
bool WakeUpBegin(PowerStateChangeReason reason) override;
bool WakeUpEnd() override;
bool SuspendBegin(PowerStateChangeReason reason) override;
bool SuspendEnd() override;
bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override;
bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override;
ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override;
bool SetDisplayState(DisplayState state) override;
DisplayState GetDisplayState(DisplayId displayId) override;
bool SetScreenBrightness(uint64_t screenId, uint32_t level) override;
uint32_t GetScreenBrightness(uint64_t screenId) override;
std::vector<DisplayId> GetAllDisplayIds() override;
protected:
ScreenSessionManagerLite() = default;
virtual ~ScreenSessionManagerLite();

View File

@ -63,6 +63,8 @@ public:
TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS,
TRANS_ID_SCENE_BOARD_GET_CURRENT_FOLD_CREASE_REGION,
TRANS_ID_GET_CUTOUT_INFO,
TRANS_ID_SET_SCREEN_BRIGHTNESS,
TRANS_ID_GET_SCREEN_BRIGHTNESS,
};
virtual DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
@ -77,6 +79,21 @@ public:
virtual sptr<DisplayInfo> GetDefaultDisplayInfo() { return nullptr; }
virtual sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) { return nullptr; }
virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) { return nullptr; }
/*
* used by powermgr
*/
virtual bool WakeUpBegin(PowerStateChangeReason reason) { return false; }
virtual bool WakeUpEnd() { return false; }
virtual bool SuspendBegin(PowerStateChangeReason reason) { return false; }
virtual bool SuspendEnd() { return false; }
virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) { return false; }
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) { return false; }
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) { return ScreenPowerState::INVALID_STATE; }
virtual bool SetDisplayState(DisplayState state) { return false; }
virtual DisplayState GetDisplayState(DisplayId displayId) { return DisplayState::UNKNOWN; }
virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) { return false; }
virtual uint32_t GetScreenBrightness(uint64_t screenId) { return 0; }
virtual std::vector<DisplayId> GetAllDisplayIds() { return std::vector<DisplayId>{}; }
};
} // namespace Rosen
} // namespace OHOS

View File

@ -42,6 +42,21 @@ public:
virtual sptr<DisplayInfo> GetDefaultDisplayInfo() override;
virtual sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) override;
virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) override;
/*
* used by powermgr
*/
virtual bool WakeUpBegin(PowerStateChangeReason reason) override;
virtual bool WakeUpEnd() override;
virtual bool SuspendBegin(PowerStateChangeReason reason) override;
virtual bool SuspendEnd() override;
virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) override;
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override;
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override;
virtual bool SetDisplayState(DisplayState state) override;
virtual DisplayState GetDisplayState(DisplayId displayId) override;
virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) override;
virtual uint32_t GetScreenBrightness(uint64_t screenId) override;
virtual std::vector<DisplayId> GetAllDisplayIds() override;
private:
static inline BrokerDelegator<ScreenSessionManagerLiteProxy> delegator_;
};

View File

@ -31,6 +31,7 @@ public:
virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option) override;
private:
int RemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option);
int HandleRegisterDisplayManagerAgent(MessageParcel& data, MessageParcel& reply);
int HandleUnRegisterDisplayManagerAgent(MessageParcel& data, MessageParcel& reply);
int HandleGetFoldDisplayMode(MessageParcel& data, MessageParcel& reply);
@ -40,6 +41,21 @@ private:
int HandleGetDefaultDisplayInfo(MessageParcel& data, MessageParcel& reply);
int HandleGetDisplayById(MessageParcel& data, MessageParcel& reply);
int HandleGetCutoutInfo(MessageParcel& data, MessageParcel& reply);
/*
* used by powermgr
*/
int HandleWakeUpBegin(MessageParcel& data, MessageParcel& reply);
int HandleWakeUpEnd(MessageParcel& data, MessageParcel& reply);
int HandleSuspendBegin(MessageParcel& data, MessageParcel& reply);
int HandleSuspendEnd(MessageParcel& data, MessageParcel& reply);
int HandleSetSpecifiedScreenPower(MessageParcel& data, MessageParcel& reply);
int HandleSetScreenPowerForAll(MessageParcel& data, MessageParcel& reply);
int HandleGetScreenPower(MessageParcel& data, MessageParcel& reply);
int HandleSetDisplayState(MessageParcel& data, MessageParcel& reply);
int HandleGetDisplayState(MessageParcel& data, MessageParcel& reply);
int HandleSetScreenBrightness(MessageParcel& data, MessageParcel& reply);
int HandleGetScreenBrightness(MessageParcel& data, MessageParcel& reply);
int HandleGetAllDisplayIds(MessageParcel& data, MessageParcel& reply);
};
} // namespace Rosen
} // namespace OHOS

View File

@ -3876,7 +3876,7 @@ bool SceneSessionManager::IsSessionVisible(const sptr<SceneSession>& session)
}
const auto& state = session->GetSessionState();
if (WindowHelper::IsSubWindow(session->GetWindowType())) {
const auto& parentSceneSession = GetSceneSession(session->GetParentPersistentId());
const auto& parentSceneSession = session->GetParentSession();
if (parentSceneSession == nullptr) {
WLOGFW("Can not find parent for this sub window, id: %{public}d", session->GetPersistentId());
return false;
@ -10177,4 +10177,34 @@ WMError SceneSessionManager::GetProcessSurfaceNodeIdByPersistentId(const int32_t
return WMError::WM_OK;
}
void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, std::vector<int32_t>&& persistentIds)
{
auto task = [this, startZOrder, persistentIds = std::move(persistentIds)] {
std::ostringstream oss;
oss << "[";
for (size_t i = 0; i < persistentIds.size(); i++) {
int32_t persistentId = persistentIds[i];
oss << persistentId;
if (i < persistentIds.size() - 1) {
oss << ",";
}
auto sceneSession = GetSceneSession(persistentId);
if (sceneSession == nullptr) {
TLOGE(WmsLogTag::WMS_LAYOUT, "sceneSession is nullptr persistentId = %{public}d", persistentId);
continue;
}
if (i > UINT32_MAX - startZOrder) {
TLOGE(WmsLogTag::WMS_LAYOUT, "Z order overflow, stop refresh");
break;
}
sceneSession->SetPcScenePanel(true);
sceneSession->SetZOrder(i + startZOrder);
}
oss << "]";
TLOGI(WmsLogTag::WMS_LAYOUT, "RefreshPcZOrderList:%{public}s", oss.str().c_str());
return WSError::WS_OK;
};
taskScheduler_->PostTask(task, "RefreshPcZOrderList");
}
} // namespace OHOS::Rosen

View File

@ -15,17 +15,12 @@
#include "screen_rotation_property.h"
#include "screen_session_manager.h"
#include "fold_screen_state_internel.h"
namespace OHOS {
namespace Rosen {
void ScreenRotationProperty::HandleSensorEventInput(DeviceRotation deviceRotation)
{
static DeviceRotation lastSensorRotationConverted_ = DeviceRotation::INVALID;
if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice() &&
ScreenSessionManager::GetInstance().GetFoldStatus() == FoldStatus::FOLDED) {
deviceRotation = ConvertSinglePocketOuterRotation(deviceRotation);
}
TLOGI(WmsLogTag::DMS, "DeviceRotation: %{public}d, "
"lastSensorRotationConverted: %{public}d", deviceRotation, lastSensorRotationConverted_);
@ -40,22 +35,6 @@ void ScreenRotationProperty::HandleSensorEventInput(DeviceRotation deviceRotatio
screenSession->HandleSensorRotation(ConvertDeviceToFloat(deviceRotation));
}
DeviceRotation ScreenRotationProperty::ConvertSinglePocketOuterRotation(DeviceRotation deviceRotation)
{
DeviceRotation sensorRotation = deviceRotation;
switch (deviceRotation) {
case DeviceRotation::ROTATION_LANDSCAPE:
sensorRotation = DeviceRotation::ROTATION_LANDSCAPE_INVERTED;
break;
case DeviceRotation::ROTATION_LANDSCAPE_INVERTED:
sensorRotation = DeviceRotation::ROTATION_LANDSCAPE;
break;
default:
TLOGW(WmsLogTag::DMS, "no need to covert, rotation: %{public}d", deviceRotation);
}
return sensorRotation;
}
float ScreenRotationProperty::ConvertDeviceToFloat(DeviceRotation deviceRotation)
{
float sensorRotation = -1.0f; // -1 mean keep before degree

View File

@ -155,9 +155,16 @@ void ScreenSessionManager::HandleFoldScreenPowerInit()
return;
}
foldScreenController_->SetOnBootAnimation(true);
auto ret = rsInterface_.SetScreenCorrection(SCREEN_ID_FULL, static_cast<ScreenRotation>(g_screenRotationOffSet));
std::ostringstream oss;
oss << "SetScreenCorrection g_screenRotationOffSet: " << g_screenRotationOffSet << " ret value: " << ret;
if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice()) {
auto ret = rsInterface_.SetScreenCorrection(SCREEN_ID_MAIN,
static_cast<ScreenRotation>(g_screenRotationOffSet));
oss << "SetScreenCorrection g_screenRotationOffSet: " << g_screenRotationOffSet << " ret value: " << ret;
} else {
auto ret = rsInterface_.SetScreenCorrection(SCREEN_ID_FULL,
static_cast<ScreenRotation>(g_screenRotationOffSet));
oss << "SetScreenCorrection g_screenRotationOffSet: " << g_screenRotationOffSet << " ret value: " << ret;
}
TLOGI(WmsLogTag::DMS, "%{public}s", oss.str().c_str());
screenEventTracker_.RecordEvent(oss.str());
FoldScreenPowerInit();
@ -5393,7 +5400,7 @@ bool ScreenSessionManager::SetVirtualScreenStatus(ScreenId screenId, VirtualScre
return false;
}
return rsInterface_.SetVirtualScreenStatus(screenId, screenStatus);
return rsInterface_.SetVirtualScreenStatus(rsScreenId, screenStatus);
}
DMError ScreenSessionManager::SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,

View File

@ -16,6 +16,7 @@
#include "session_manager/include/screen_session_manager_lite.h"
#include <system_ability_definition.h>
#include <iservice_registry.h>
#include <transaction/rs_interfaces.h>
#include "window_manager_hilog.h"
namespace OHOS::Rosen {
@ -157,6 +158,113 @@ sptr<CutoutInfo> ScreenSessionManagerLite::GetCutoutInfo(DisplayId displayId)
return nullptr;
}
/*
* used by powermgr
*/
bool ScreenSessionManagerLite::WakeUpBegin(PowerStateChangeReason reason)
{
ConnectToServer();
if (screenSessionManager_) {
return screenSessionManager_->WakeUpBegin(reason);
}
return false;
}
bool ScreenSessionManagerLite::WakeUpEnd()
{
ConnectToServer();
if (screenSessionManager_) {
return screenSessionManager_->WakeUpEnd();
}
return false;
}
bool ScreenSessionManagerLite::SuspendBegin(PowerStateChangeReason reason)
{
ConnectToServer();
if (screenSessionManager_) {
return screenSessionManager_->SuspendBegin(reason);
}
return false;
}
bool ScreenSessionManagerLite::SuspendEnd()
{
ConnectToServer();
if (screenSessionManager_) {
return screenSessionManager_->SuspendEnd();
}
return false;
}
bool ScreenSessionManagerLite::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state,
PowerStateChangeReason reason)
{
ConnectToServer();
if (screenSessionManager_) {
return screenSessionManager_->SetSpecifiedScreenPower(screenId, state, reason);
}
return false;
}
bool ScreenSessionManagerLite::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
{
ConnectToServer();
if (screenSessionManager_) {
return screenSessionManager_->SetScreenPowerForAll(state, reason);
}
return false;
}
ScreenPowerState ScreenSessionManagerLite::GetScreenPower(ScreenId dmsScreenId)
{
ConnectToServer();
if (screenSessionManager_) {
return screenSessionManager_->GetScreenPower(dmsScreenId);
}
return ScreenPowerState::INVALID_STATE;
}
bool ScreenSessionManagerLite::SetDisplayState(DisplayState state)
{
ConnectToServer();
if (screenSessionManager_) {
return screenSessionManager_->SetDisplayState(state);
}
return false;
}
DisplayState ScreenSessionManagerLite::GetDisplayState(DisplayId displayId)
{
ConnectToServer();
if (screenSessionManager_) {
return screenSessionManager_->GetDisplayState(displayId);
}
return DisplayState::UNKNOWN;
}
bool ScreenSessionManagerLite::SetScreenBrightness(uint64_t screenId, uint32_t level)
{
ConnectToServer();
RSInterfaces::GetInstance().SetScreenBacklight(screenId, level);
return true;
}
uint32_t ScreenSessionManagerLite::GetScreenBrightness(uint64_t screenId)
{
ConnectToServer();
return static_cast<uint32_t>(RSInterfaces::GetInstance().GetScreenBacklight(screenId));
}
std::vector<DisplayId> ScreenSessionManagerLite::GetAllDisplayIds()
{
ConnectToServer();
if (screenSessionManager_) {
return screenSessionManager_->GetAllDisplayIds();
}
return std::vector<DisplayId>{};
}
void ScreenSessionManagerLite::Clear()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);

View File

@ -289,4 +289,342 @@ sptr<CutoutInfo> ScreenSessionManagerLiteProxy::GetCutoutInfo(DisplayId displayI
sptr<CutoutInfo> info = reply.ReadParcelable<CutoutInfo>();
return info;
}
/*
* used by powermgr
*/
bool ScreenSessionManagerLiteProxy::WakeUpBegin(PowerStateChangeReason reason)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]WakeUpBegin remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("[UL_POWER]WakeUpBegin: WriteInterfaceToken failed");
return false;
}
if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
WLOGFE("[UL_POWER]WakeUpBegin: Write PowerStateChangeReason failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_WAKE_UP_BEGIN),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]WakeUpBegin: SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool ScreenSessionManagerLiteProxy::WakeUpEnd()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]WakeUpEnd remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("[UL_POWER]WakeUpEnd: WriteInterfaceToken failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_WAKE_UP_END),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]WakeUpEnd: SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool ScreenSessionManagerLiteProxy::SuspendBegin(PowerStateChangeReason reason)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]SuspendBegin remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("[UL_POWER]SuspendBegin: WriteInterfaceToken failed");
return false;
}
if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
WLOGFE("[UL_POWER]SuspendBegin: Write PowerStateChangeReason failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_SUSPEND_BEGIN),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SuspendBegin: SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool ScreenSessionManagerLiteProxy::SuspendEnd()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]SuspendEnd remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("[UL_POWER]SuspendEnd: WriteInterfaceToken failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_SUSPEND_END),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SuspendEnd: SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool ScreenSessionManagerLiteProxy::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state,
PowerStateChangeReason reason)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]SetSpecifiedScreenPower remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("[UL_POWER]WriteInterfaceToken failed");
return false;
}
if (!data.WriteUint32(static_cast<uint32_t>(screenId))) {
WLOGFE("[UL_POWER]Write ScreenId failed");
return false;
}
if (!data.WriteUint32(static_cast<uint32_t>(state))) {
WLOGFE("[UL_POWER]Write ScreenPowerState failed");
return false;
}
if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
WLOGFE("[UL_POWER]Write PowerStateChangeReason failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool ScreenSessionManagerLiteProxy::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]SetScreenPowerForAll remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("[UL_POWER]WriteInterfaceToken failed");
return false;
}
if (!data.WriteUint32(static_cast<uint32_t>(state))) {
WLOGFE("[UL_POWER]Write ScreenPowerState failed");
return false;
}
if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
WLOGFE("[UL_POWER]Write PowerStateChangeReason failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SendRequest failed");
return false;
}
return reply.ReadBool();
}
ScreenPowerState ScreenSessionManagerLiteProxy::GetScreenPower(ScreenId dmsScreenId)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("GetScreenPower remote is nullptr");
return ScreenPowerState::INVALID_STATE;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return ScreenPowerState::INVALID_STATE;
}
if (!data.WriteUint64(static_cast<uint64_t>(dmsScreenId))) {
WLOGFE("Write dmsScreenId failed");
return ScreenPowerState::INVALID_STATE;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_GET_SCREEN_POWER),
data, reply, option) != ERR_NONE) {
WLOGFW("SendRequest failed");
return ScreenPowerState::INVALID_STATE;
}
return static_cast<ScreenPowerState>(reply.ReadUint32());
}
bool ScreenSessionManagerLiteProxy::SetDisplayState(DisplayState state)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]SetDisplayState remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("[UL_POWER]WriteInterfaceToken failed");
return false;
}
if (!data.WriteUint32(static_cast<uint32_t>(state))) {
WLOGFE("[UL_POWER]Write DisplayState failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_SET_DISPLAY_STATE),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SendRequest failed");
return false;
}
return reply.ReadBool();
}
DisplayState ScreenSessionManagerLiteProxy::GetDisplayState(DisplayId displayId)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("GetDisplayState remote is nullptr");
return DisplayState::UNKNOWN;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return DisplayState::UNKNOWN;
}
if (!data.WriteUint64(displayId)) {
WLOGFE("Write displayId failed");
return DisplayState::UNKNOWN;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_GET_DISPLAY_STATE),
data, reply, option) != ERR_NONE) {
WLOGFW("SendRequest failed");
return DisplayState::UNKNOWN;
}
return static_cast<DisplayState>(reply.ReadUint32());
}
bool ScreenSessionManagerLiteProxy::SetScreenBrightness(uint64_t screenId, uint32_t level)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("SetScreenBrightness remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return false;
}
if (!data.WriteUint64(screenId)) {
WLOGFE("Write screenId failed");
return false;
}
if (!data.WriteUint64(level)) {
WLOGFE("Write level failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_SET_SCREEN_BRIGHTNESS),
data, reply, option) != ERR_NONE) {
WLOGFW("SendRequest failed");
return false;
}
return reply.ReadBool();
}
uint32_t ScreenSessionManagerLiteProxy::GetScreenBrightness(uint64_t screenId)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("GetScreenBrightness remote is nullptr");
return 0;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return 0;
}
if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
WLOGFE("Write screenId failed");
return 0;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_GET_SCREEN_BRIGHTNESS),
data, reply, option) != ERR_NONE) {
WLOGFW("SendRequest failed");
return 0;
}
return reply.ReadUint32();
}
std::vector<DisplayId> ScreenSessionManagerLiteProxy::GetAllDisplayIds()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]GetAllDisplayIds remote is nullptr");
return {};
}
std::vector<DisplayId> allDisplayIds;
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return allDisplayIds;
}
if (remote->SendRequest(static_cast<uint32_t>(ScreenManagerLiteMessage::TRANS_ID_GET_ALL_DISPLAYIDS),
data, reply, option) != ERR_NONE) {
WLOGFW("SendRequest failed");
return allDisplayIds;
}
reply.ReadUInt64Vector(&allDisplayIds);
return allDisplayIds;
}
} // namespace OHOS::Rosen

View File

@ -35,42 +35,80 @@ int32_t ScreenSessionManagerLiteStub::OnRemoteRequest(uint32_t code, MessageParc
}
ScreenManagerLiteMessage msgId = static_cast<ScreenManagerLiteMessage>(code);
switch (msgId) {
case ScreenManagerLiteMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT: {
case ScreenManagerLiteMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT:
HandleRegisterDisplayManagerAgent(data, reply);
break;
}
case ScreenManagerLiteMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT: {
case ScreenManagerLiteMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT:
HandleUnRegisterDisplayManagerAgent(data, reply);
break;
}
case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE: {
case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE:
HandleGetFoldDisplayMode(data, reply);
break;
}
case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE: {
case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE:
HandleSetFoldDisplayMode(data, reply);
break;
}
case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_IS_FOLDABLE: {
case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_IS_FOLDABLE:
HandleIsFoldable(data, reply);
break;
}
case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS: {
case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS:
HandleGetFoldStatus(data, reply);
break;
}
case ScreenManagerLiteMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO: {
case ScreenManagerLiteMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO:
HandleGetDefaultDisplayInfo(data, reply);
break;
}
case ScreenManagerLiteMessage::TRANS_ID_GET_DISPLAY_BY_ID: {
case ScreenManagerLiteMessage::TRANS_ID_GET_DISPLAY_BY_ID:
HandleGetDisplayById(data, reply);
break;
}
case ScreenManagerLiteMessage::TRANS_ID_GET_CUTOUT_INFO: {
case ScreenManagerLiteMessage::TRANS_ID_GET_CUTOUT_INFO:
HandleGetCutoutInfo(data, reply);
break;
}
default:
return RemoteRequest(code, data, reply, option);
}
return 0;
}
int ScreenSessionManagerLiteStub::RemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
MessageOption& option)
{
ScreenManagerLiteMessage msgId = static_cast<ScreenManagerLiteMessage>(code);
switch (msgId) {
case ScreenManagerLiteMessage::TRANS_ID_WAKE_UP_BEGIN:
HandleWakeUpBegin(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_WAKE_UP_END:
HandleWakeUpEnd(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_SUSPEND_BEGIN:
HandleSuspendBegin(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_SUSPEND_END:
HandleSuspendEnd(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER:
HandleSetSpecifiedScreenPower(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL:
HandleSetScreenPowerForAll(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_GET_SCREEN_POWER:
HandleGetScreenPower(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_SET_DISPLAY_STATE:
HandleSetDisplayState(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_GET_DISPLAY_STATE:
HandleGetDisplayState(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_GET_ALL_DISPLAYIDS:
HandleGetAllDisplayIds(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_SET_SCREEN_BRIGHTNESS:
HandleSetScreenBrightness(data, reply);
break;
case ScreenManagerLiteMessage::TRANS_ID_GET_SCREEN_BRIGHTNESS:
HandleGetScreenBrightness(data, reply);
break;
default:
WLOGFW("unknown transaction code");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
@ -159,4 +197,109 @@ int ScreenSessionManagerLiteStub::HandleGetCutoutInfo(MessageParcel &data, Messa
reply.WriteParcelable(cutoutInfo);
return ERR_NONE;
}
/*
* used by powermgr
*/
int ScreenSessionManagerLiteStub::HandleWakeUpBegin(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleWakeUpBegin!");
PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32());
reply.WriteBool(WakeUpBegin(reason));
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleWakeUpEnd(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleWakeUpEnd!");
reply.WriteBool(WakeUpEnd());
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleSuspendBegin(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleSuspendBegin!");
PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32());
reply.WriteBool(SuspendBegin(reason));
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleSuspendEnd(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleSuspendEnd!");
reply.WriteBool(SuspendEnd());
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleSetSpecifiedScreenPower(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleSetSpecifiedScreenPower!");
ScreenId screenId = static_cast<ScreenId>(data.ReadUint32());
ScreenPowerState state = static_cast<ScreenPowerState>(data.ReadUint32());
PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32());
reply.WriteBool(SetSpecifiedScreenPower(screenId, state, reason));
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleSetScreenPowerForAll(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleSetScreenPowerForAll!");
ScreenPowerState state = static_cast<ScreenPowerState>(data.ReadUint32());
PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32());
reply.WriteBool(SetScreenPowerForAll(state, reason));
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleGetScreenPower(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleGetScreenPower!");
ScreenId dmsScreenId;
if (!data.ReadUint64(dmsScreenId)) {
WLOGFE("fail to read dmsScreenId.");
return ERR_INVALID_DATA;
}
reply.WriteUint32(static_cast<uint32_t>(GetScreenPower(dmsScreenId)));
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleSetDisplayState(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleSetDisplayState!");
DisplayState state = static_cast<DisplayState>(data.ReadUint32());
reply.WriteBool(SetDisplayState(state));
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleGetDisplayState(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleGetDisplayState!");
DisplayState state = GetDisplayState(data.ReadUint64());
reply.WriteUint32(static_cast<uint32_t>(state));
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleSetScreenBrightness(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleSetScreenBrightness!");
uint64_t screenId = data.ReadUint64();
uint32_t level = data.ReadUint64();
reply.WriteBool(SetScreenBrightness(screenId, level));
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleGetScreenBrightness(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleGetScreenBrightness!");
uint64_t screenId = data.ReadUint64();
reply.WriteUint32(GetScreenBrightness(screenId));
return ERR_NONE;
}
int ScreenSessionManagerLiteStub::HandleGetAllDisplayIds(MessageParcel& data, MessageParcel& reply)
{
WLOGFD("run HandleGetAllDisplayIds!");
std::vector<DisplayId> allDisplayIds = GetAllDisplayIds();
reply.WriteUInt64Vector(allDisplayIds);
return ERR_NONE;
}
} // namespace OHOS::Rosen

View File

@ -160,6 +160,102 @@ HWTEST_F(ScreenSessionManagerLiteProxyTest, GetCutoutInfo, Function | SmallTest
auto res = screenSessionManagerLiteProxy_->GetCutoutInfo(displayId);
ASSERT_EQ(nullptr, res);
}
/**
* @tc.name: WakeUpBegin
* @tc.desc: WakeUpBegin
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerLiteProxyTest, WakeUpBegin, Function | SmallTest | Level1)
{
PowerStateChangeReason reason {0};
bool expectation = true;
EXPECT_EQ(expectation, screenSessionManagerLiteProxy_->WakeUpBegin(reason));
}
/**
* @tc.name: WakeUpEnd
* @tc.desc: WakeUpEnd
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerLiteProxyTest, WakeUpEnd, Function | SmallTest | Level1)
{
bool expectation = true;
EXPECT_EQ(expectation, screenSessionManagerLiteProxy_->WakeUpEnd());
}
/**
* @tc.name: SuspendEnd
* @tc.desc: SuspendEnd
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerLiteProxyTest, SuspendEnd, Function | SmallTest | Level1)
{
bool expectation = true;
EXPECT_EQ(expectation, screenSessionManagerLiteProxy_->SuspendEnd());
}
/**
* @tc.name: SetDisplayState
* @tc.desc: SetDisplayState
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerLiteProxyTest, SetDisplayState, Function | SmallTest | Level1)
{
DisplayState state {1};
screenSessionManagerLiteProxy_->SetDisplayState(state);
int resultValue = 0;
ASSERT_EQ(resultValue, 0);
}
/**
* @tc.name: SetSpecifiedScreenPower
* @tc.desc: SetSpecifiedScreenPower
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerLiteProxyTest, SetSpecifiedScreenPower, Function | SmallTest | Level1)
{
ScreenPowerState state {0};
ScreenId id = 1001;
PowerStateChangeReason reason {1};
bool expectation = true;
EXPECT_EQ(expectation, screenSessionManagerLiteProxy_->SetSpecifiedScreenPower(id, state, reason));
}
/**
* @tc.name: SetScreenPowerForAll
* @tc.desc: SetScreenPowerForAll
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerLiteProxyTest, SetScreenPowerForAll, Function | SmallTest | Level1)
{
ScreenPowerState state {0};
PowerStateChangeReason reason {1};
bool expectation = true;
EXPECT_EQ(expectation, screenSessionManagerLiteProxy_->SetScreenPowerForAll(state, reason));
}
/**
* @tc.name: GetDisplayState
* @tc.desc: GetDisplayState
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerLiteProxyTest, GetDisplayState, Function | SmallTest | Level1)
{
DisplayId displayId {0};
EXPECT_NE(DisplayState::UNKNOWN, screenSessionManagerLiteProxy_->GetDisplayState(displayId));
}
/**
* @tc.name: GetScreenPower
* @tc.desc: GetScreenPower
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerLiteProxyTest, GetScreenPower, Function | SmallTest | Level1)
{
ScreenId dmsScreenId = 1001;
EXPECT_NE(ScreenPowerState::INVALID_STATE, screenSessionManagerLiteProxy_->GetScreenPower(dmsScreenId));
}
}
}
}

View File

@ -829,7 +829,7 @@ HWTEST_F(ScreenSessionManagerTest, NotifyScreenChanged, Function | SmallTest | L
*/
HWTEST_F(ScreenSessionManagerTest, NotifyDisplayEvent, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
DisplayEvent event = DisplayEvent::KEYGUARD_DRAWN;
@ -2086,14 +2086,13 @@ HWTEST_F(ScreenSessionManagerTest, SetVirtualScreenBlackList01, Function | Small
*/
HWTEST_F(ScreenSessionManagerTest, SetVirtualScreenBlackList02, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1010;
ScreenId rsScreenId = SCREEN_ID_INVALID;
ASSERT_FALSE(ssm->ConvertScreenIdToRsScreenId(screenId, rsScreenId));
std::vector<uint64_t> windowId = {10, 20, 30};
ssm->SetVirtualScreenBlackList(screenId, windowId);
ssm = nullptr;
}
/**
@ -2166,7 +2165,7 @@ HWTEST_F(ScreenSessionManagerTest, ScreenCastConnection, Function | SmallTest |
*/
HWTEST_F(ScreenSessionManagerTest, ReportFoldStatusToScb, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ssm->clientProxy_ = nullptr;
FoldStatus currentStatus = FoldStatus::FOLDED;
@ -2176,7 +2175,6 @@ HWTEST_F(ScreenSessionManagerTest, ReportFoldStatusToScb, Function | SmallTest |
std::vector<std::string> screenFoldInfo {std::to_string(static_cast<int32_t>(currentStatus)),
std::to_string(static_cast<int32_t>(nextStatus)), std::to_string(duration), std::to_string(postureAngle)};
ssm->ReportFoldStatusToScb(screenFoldInfo);
ssm = nullptr;
}
/**
@ -2186,7 +2184,7 @@ HWTEST_F(ScreenSessionManagerTest, ReportFoldStatusToScb, Function | SmallTest |
*/
HWTEST_F(ScreenSessionManagerTest, DisablePowerOffRenderControl01, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1050;
ScreenId rsScreenId = SCREEN_ID_INVALID;
@ -2194,7 +2192,6 @@ HWTEST_F(ScreenSessionManagerTest, DisablePowerOffRenderControl01, Function | Sm
ssm->screenIdManager_.sms2RsScreenIdMap_[screenId] = rsScreenId1;
ASSERT_TRUE(ssm->ConvertScreenIdToRsScreenId(screenId, rsScreenId));
ssm->DisablePowerOffRenderControl(screenId);
ssm = nullptr;
}
/**
@ -2204,13 +2201,12 @@ HWTEST_F(ScreenSessionManagerTest, DisablePowerOffRenderControl01, Function | Sm
*/
HWTEST_F(ScreenSessionManagerTest, DisablePowerOffRenderControl02, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1010;
ScreenId rsScreenId = SCREEN_ID_INVALID;
ASSERT_FALSE(ssm->ConvertScreenIdToRsScreenId(screenId, rsScreenId));
ssm->DisablePowerOffRenderControl(screenId);
ssm = nullptr;
}
/**
@ -2220,12 +2216,11 @@ HWTEST_F(ScreenSessionManagerTest, DisablePowerOffRenderControl02, Function | Sm
*/
HWTEST_F(ScreenSessionManagerTest, CheckAndSendHiSysEvent, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
std::string eventName = "GET_DISPLAY_SNAPSHOT";
std::string bundleName = "hmos.screenshot";
ssm->CheckAndSendHiSysEvent(eventName, bundleName);
ssm = nullptr;
}
/**
@ -2235,14 +2230,13 @@ HWTEST_F(ScreenSessionManagerTest, CheckAndSendHiSysEvent, Function | SmallTest
*/
HWTEST_F(ScreenSessionManagerTest, NotifyFoldToExpandCompletion, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
bool foldToExpand = false;
ssm->NotifyFoldToExpandCompletion(foldToExpand);
foldToExpand = true;
ssm->NotifyFoldToExpandCompletion(foldToExpand);
ssm = nullptr;
}
/**
@ -2252,12 +2246,11 @@ HWTEST_F(ScreenSessionManagerTest, NotifyFoldToExpandCompletion, Function | Smal
*/
HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea01, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1050;
DMRect area = DMRect{};
ssm->UpdateAvailableArea(screenId, area);
ssm = nullptr;
}
/**
@ -2267,7 +2260,7 @@ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea01, Function | SmallTest |
*/
HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea02, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1050;
DMRect area{0, 0, 600, 900};
@ -2278,7 +2271,6 @@ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea02, Function | SmallTest |
ASSERT_EQ(screenSession1, screenSession);
ASSERT_TRUE(screenSession->UpdateAvailableArea(area));
ssm->UpdateAvailableArea(screenId, area);
ssm = nullptr;
}
/**
@ -2288,7 +2280,7 @@ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea02, Function | SmallTest |
*/
HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea03, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1050;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0);
@ -2297,7 +2289,6 @@ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea03, Function | SmallTest |
ssm->screenSessionMap_[screenId] = screenSession;
ASSERT_FALSE(screenSession->UpdateAvailableArea(area));
ssm->UpdateAvailableArea(screenId, area);
ssm = nullptr;
}
/**
@ -2307,11 +2298,10 @@ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea03, Function | SmallTest |
*/
HWTEST_F(ScreenSessionManagerTest, NotifyAvailableAreaChanged01, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
DMRect area = DMRect{};
ssm->NotifyAvailableAreaChanged(area);
ssm = nullptr;
}
/**
@ -2321,7 +2311,7 @@ HWTEST_F(ScreenSessionManagerTest, NotifyAvailableAreaChanged01, Function | Smal
*/
HWTEST_F(ScreenSessionManagerTest, NotifyFoldStatusChanged02, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
std::string statusParam;
auto ret = ssm->NotifyFoldStatusChanged(statusParam);
@ -2345,8 +2335,6 @@ HWTEST_F(ScreenSessionManagerTest, NotifyFoldStatusChanged02, Function | SmallTe
ssm->HandleFoldScreenPowerInit();
ret = ssm->NotifyFoldStatusChanged(statusParam);
ASSERT_EQ(ret, 0);
ssm = nullptr;
}
/**
@ -2356,13 +2344,12 @@ HWTEST_F(ScreenSessionManagerTest, NotifyFoldStatusChanged02, Function | SmallTe
*/
HWTEST_F(ScreenSessionManagerTest, Dump, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
int fd = 2;
std::vector<std::u16string> args;
int ret = ssm->Dump(fd, args);
ASSERT_EQ(ret, 0);
ssm = nullptr;
}
/**
@ -2372,12 +2359,11 @@ HWTEST_F(ScreenSessionManagerTest, Dump, Function | SmallTest | Level3)
*/
HWTEST_F(ScreenSessionManagerTest, GetDisplayNode01, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1050;
auto ret = ssm->GetDisplayNode(screenId);
ASSERT_EQ(ret, nullptr);
ssm = nullptr;
}
/**
@ -2387,7 +2373,7 @@ HWTEST_F(ScreenSessionManagerTest, GetDisplayNode01, Function | SmallTest | Leve
*/
HWTEST_F(ScreenSessionManagerTest, GetDisplayNode02, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1050;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0);
@ -2395,7 +2381,6 @@ HWTEST_F(ScreenSessionManagerTest, GetDisplayNode02, Function | SmallTest | Leve
ssm->screenSessionMap_[screenId] = screenSession;
auto ret = ssm->GetDisplayNode(screenId);
ASSERT_NE(ret, nullptr);
ssm = nullptr;
}
/**
@ -2405,11 +2390,10 @@ HWTEST_F(ScreenSessionManagerTest, GetDisplayNode02, Function | SmallTest | Leve
*/
HWTEST_F(ScreenSessionManagerTest, GetScreenProperty01, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1050;
auto ret = ssm->GetScreenProperty(screenId);
ssm = nullptr;
}
/**
@ -2419,14 +2403,13 @@ HWTEST_F(ScreenSessionManagerTest, GetScreenProperty01, Function | SmallTest | L
*/
HWTEST_F(ScreenSessionManagerTest, GetScreenProperty02, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1050;
sptr<ScreenSession> screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0);
ASSERT_NE(screenSession, nullptr);
ssm->screenSessionMap_[screenId] = screenSession;
auto ret = ssm->GetScreenProperty(screenId);
ssm = nullptr;
}
/**
@ -2436,7 +2419,7 @@ HWTEST_F(ScreenSessionManagerTest, GetScreenProperty02, Function | SmallTest | L
*/
HWTEST_F(ScreenSessionManagerTest, GetCurrentScreenPhyBounds01, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
float phyWidth = 0.0f;
float phyHeight = 0.0f;
@ -2450,8 +2433,6 @@ HWTEST_F(ScreenSessionManagerTest, GetCurrentScreenPhyBounds01, Function | Small
ASSERT_NE(ssm->foldScreenController_, nullptr);
ssm->GetCurrentScreenPhyBounds(phyWidth, phyHeight, isReset, screenId);
ASSERT_FALSE(isReset);
ssm = nullptr;
}
/**
@ -2461,7 +2442,7 @@ HWTEST_F(ScreenSessionManagerTest, GetCurrentScreenPhyBounds01, Function | Small
*/
HWTEST_F(ScreenSessionManagerTest, SetVirtualScreenStatus, Function | SmallTest | Level3)
{
sptr<ScreenSessionManager> ssm = new ScreenSessionManager();
ScreenSessionManager* ssm = new ScreenSessionManager();
ASSERT_NE(ssm, nullptr);
ScreenId screenId = 1050;
auto ret = ssm->SetVirtualScreenStatus(screenId, VirtualScreenStatus::VIRTUAL_SCREEN_PAUSE);
@ -2471,7 +2452,6 @@ HWTEST_F(ScreenSessionManagerTest, SetVirtualScreenStatus, Function | SmallTest
ssm->screenIdManager_.sms2RsScreenIdMap_[screenId] = rsScreenId1;
ASSERT_TRUE(ssm->ConvertScreenIdToRsScreenId(screenId, rsScreenId));
ssm->SetVirtualScreenStatus(screenId, VirtualScreenStatus::VIRTUAL_SCREEN_PAUSE);
ssm = nullptr;
}
/**

View File

@ -355,78 +355,6 @@ HWTEST_F(IntentionEventManagerTest, UpdateLastMouseEvent, Function | MediumTest
inputEventListener_->UpdateLastMouseEvent(pointerEvent);
}
/**
* @tc.name: ProcessEnterLeaveEventAsync0
* @tc.desc: ProcessEnterLeaveEventAsync0 Test
* @tc.type: FUNC
*/
HWTEST_F(IntentionEventManagerTest, ProcessEnterLeaveEventAsync0, Function | MediumTest | Level2)
{
std::shared_ptr<IntentionEventManager::InputEventListener> inputEventListener1 =
std::make_shared<IntentionEventManager::InputEventListener>(nullptr, nullptr);
EXPECT_NE(nullptr, inputEventListener1);
inputEventListener1->ProcessEnterLeaveEventAsync();
usleep(WAIT_SYNC_IN_NS);
}
/**
* @tc.name: ProcessEnterLeaveEventAsync1
* @tc.desc: ProcessEnterLeaveEventAsync1 Test
* @tc.type: FUNC
*/
HWTEST_F(IntentionEventManagerTest, ProcessEnterLeaveEventAsync1, Function | MediumTest | Level2)
{
inputEventListener_->ProcessEnterLeaveEventAsync();
usleep(WAIT_SYNC_IN_NS);
std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
EXPECT_NE(nullptr, pointerEvent);
pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_MOUSE);
pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP);
inputEventListener_->UpdateLastMouseEvent(pointerEvent);
SceneSession::ClearEnterWindow();
EXPECT_EQ(nullptr, SceneSession::GetEnterWindow().promote());
inputEventListener_->ProcessEnterLeaveEventAsync();
usleep(WAIT_SYNC_IN_NS);
SessionInfo info;
info.bundleName_ = "IntentionEventManager";
info.moduleName_ = "InputEventListener";
info.isSystem_ = false;
info.persistentId_ = -1;
sptr<SceneSession::SpecificSessionCallback> callback =
new SceneSession::SpecificSessionCallback();
EXPECT_NE(nullptr, callback);
sptr<SceneSession> sceneSession = new SceneSession(info, callback);
EXPECT_NE(nullptr, sceneSession);
EXPECT_EQ(-1, sceneSession->GetPersistentId());
pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW);
sceneSession->TransferPointerEvent(pointerEvent, true);
EXPECT_NE(nullptr, SceneSession::GetEnterWindow().promote());
inputEventListener_->ProcessEnterLeaveEventAsync();
usleep(WAIT_SYNC_IN_NS);
sceneSession->sessionInfo_.isSystem_ = false;
inputEventListener_->ProcessEnterLeaveEventAsync();
usleep(WAIT_SYNC_IN_NS);
sceneSession->sessionInfo_.isSystem_ = true;
auto tempUiContent = inputEventListener_->uiContent_;
inputEventListener_->uiContent_ = nullptr;
inputEventListener_->ProcessEnterLeaveEventAsync();
usleep(WAIT_SYNC_IN_NS);
inputEventListener_->uiContent_ = tempUiContent;
sceneSession->sessionInfo_.persistentId_ = 2024;
inputEventListener_->ProcessEnterLeaveEventAsync();
usleep(WAIT_SYNC_IN_NS);
std::shared_ptr<IntentionEventManager::InputEventListener> inputEventListener2 =
std::make_shared<IntentionEventManager::InputEventListener>(nullptr, eventHandler_);
inputEventListener2->ProcessEnterLeaveEventAsync();
usleep(WAIT_SYNC_IN_NS);
}
/**
* @tc.name: OnInputEventPointer1
* @tc.desc: OnInputEventPointer1 Test

View File

@ -403,6 +403,16 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionFocus, Function | SmallTest | L
FocusChangeReason reason = FocusChangeReason::DEFAULT;
ssm_->RequestSessionFocus(0, true, reason);
ssm_->RequestSessionFocus(100, true, reason);
sceneSession->property_ = property;
ASSERT_NE(sceneSession->property_, nullptr);
sceneSession->persistentId_ = 1;
sceneSession->isVisible_ = true;
sceneSession->state_ = SessionState::STATE_ACTIVE;
sceneSession->focusedOnShow_ = true;
sceneSession->property_->focusable_ = true;
sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
ssm_->RequestSessionFocus(1, true, reason);
}
/**
@ -476,6 +486,19 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionUnfocus, Function | SmallTest |
ASSERT_NE(sceneSession, nullptr);
FocusChangeReason reason = FocusChangeReason::MOVE_UP;
ssm_->RequestSessionUnfocus(0, reason);
sptr<SceneSession> focusedSession = new (std::nothrow) SceneSession(info, nullptr);
ASSERT_NE(focusedSession, nullptr);
focusedSession->property_ = property;
ASSERT_NE(focusedSession->property_, nullptr);
sceneSession->persistentId_ = 1;
focusedSession->persistentId_ = 2;
focusedSession->property_->parentPersistentId_ = 1;
ssm_->focusedSessionId_ = 1;
ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
ssm_->sceneSessionMap_.insert({focusedSession->GetPersistentId(), focusedSession});
ssm_->RequestSessionUnfocus(1, reason);
ssm_->sceneSessionMap_.clear();
}
/**

View File

@ -582,6 +582,54 @@ HWTEST_F(SceneSessionManagerTest9, RecoverAndReconnectSceneSession02, Function |
ssm_->RecoverAndReconnectSceneSession(nullptr, nullptr, nullptr, session, property, nullptr);
}
/**
* @tc.name: RefreshPcZorder
* @tc.desc: RefreshPcZorder
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level3) {
std::vector<int32_t> persistentIds;
SessionInfo info1;
info1.abilityName_ = "RefreshPcZorder1";
info1.bundleName_ = "RefreshPcZorder1";
sptr<SceneSession> session1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
ASSERT_NE(session1, nullptr);
persistentIds.push_back(session1->GetPersistentId());
ssm_->sceneSessionMap_.insert({session1->GetPersistentId(), session1});
SessionInfo info2;
info2.abilityName_ = "RefreshPcZorder2";
info2.bundleName_ = "RefreshPcZorder2";
sptr<SceneSession> session2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
ASSERT_NE(session2, nullptr);
persistentIds.push_back(session2->GetPersistentId());
ssm_->sceneSessionMap_.insert({session2->GetPersistentId(), session2});
SessionInfo info3;
info3.abilityName_ = "RefreshPcZorder3";
info3.bundleName_ = "RefreshPcZorder3";
sptr<SceneSession> session3 = sptr<SceneSession>::MakeSptr(info3, nullptr);
ASSERT_NE(session3, nullptr);
session3->SetZOrder(404);
ssm_->sceneSessionMap_.insert({session3->GetPersistentId(), session3});
persistentIds.push_back(999);
uint32_t startZOrder = 100;
std::vector<int32_t> newPersistentIds = persistentIds;
ssm_->RefreshPcZOrderList(startZOrder, std::move(persistentIds));
ssm_->RefreshPcZOrderList(UINT32_MAX, std::move(newPersistentIds));
auto start = std::chrono::system_clock::now();
// Due to RefreshPcZOrderList being asynchronous, spin lock is added.
// The spin lock itself is set with a timeout escape time of 3 seconds
while (true) {
if ((session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100) ||
std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start).count() >= 3) {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
ASSERT_EQ(session2->GetZOrder(), 101);
ASSERT_EQ(session3->GetZOrder(), 404);
ASSERT_EQ(session1->GetZOrder(), UINT32_MAX);
}
/**
* @tc.name: GetSessionRSVisible
* @tc.desc: GetSessionRSVisible

View File

@ -600,6 +600,10 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest
property->SetSystemCalling(true);
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED));
sceneSession->property_ = property;
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED));
property->SetSystemCalling(false);
EXPECT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, sceneSession->ProcessUpdatePropertyByAction(property,
@ -609,6 +613,10 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED));
sceneSession->property_ = property;
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED));
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS));
@ -633,11 +641,53 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest
WSPropertyChangeAction::ACTION_UPDATE_RECT));
}
/**
* @tc.name: ProcessUpdatePropertyByAction4
* @tc.desc: ProcessUpdatePropertyByAction4 function
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction4, Function | SmallTest | Level2)
{
SessionInfo info;
info.abilityName_ = "ProcessUpdatePropertyByAction4";
info.bundleName_ = "ProcessUpdatePropertyByAction4";
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
ASSERT_NE(nullptr, sceneSession);
sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
ASSERT_NE(nullptr, property);
property->SetSystemCalling(true);
sceneSession->property_ = property;
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS));
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE));
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS));
sceneSession->property_ = nullptr;
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED));
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED));
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS));
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE));
EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS));
}
/**
* @tc.name: HandleSpecificSystemBarProperty
* @tc.desc: HandleSpecificSystemBarProperty
* @tc.type: FUNC
*/
*/
HWTEST_F(SceneSessionTest4, HandleSpecificSystemBarProperty, Function | SmallTest | Level2)
{
SessionInfo info;
@ -649,13 +699,32 @@ HWTEST_F(SceneSessionTest4, HandleSpecificSystemBarProperty, Function | SmallTes
ASSERT_NE(nullptr, property);
WindowType type = WindowType::WINDOW_TYPE_STATUS_BAR;
sceneSession->HandleSpecificSystemBarProperty(type, property);
sceneSession->isDisplayStatusBarTemporarily_.store(true);
sceneSession->HandleSpecificSystemBarProperty(type, property);
sceneSession->specificCallback_ = nullptr;
sceneSession->HandleSpecificSystemBarProperty(type, property);
sptr<SceneSession::SpecificSessionCallback> specificCallback =
new (std::nothrow) SceneSession::SpecificSessionCallback();
ASSERT_NE(nullptr, specificCallback);
sceneSession->specificCallback_ = specificCallback;
sceneSession->HandleSpecificSystemBarProperty(type, property);
sceneSession->specificCallback_->onUpdateAvoidArea_ = nullptr;
sceneSession->HandleSpecificSystemBarProperty(type, property);
UpdateAvoidAreaCallback onUpdateAvoidArea;
sceneSession->specificCallback_->onUpdateAvoidArea_ = onUpdateAvoidArea;
sceneSession->HandleSpecificSystemBarProperty(type, property);
}
/**
* @tc.name: SetWindowFlags1
* @tc.desc: SetWindowFlags1
* @tc.type: FUNC
*/
*/
HWTEST_F(SceneSessionTest4, SetWindowFlags1, Function | SmallTest | Level2)
{
SessionInfo info;

View File

@ -94,6 +94,50 @@ HWTEST_F(SessionProxyMockTest, TransferAccessibilityEvent03, Function | SmallTes
MockMessageParcel::ClearAllErrorFlag();
WLOGI("TransferAccessibilityEvent03 end");
}
/**
* @tc.name: UpdateSessionPropertyByAction
* @tc.desc: normal function
* @tc.type: FUNC
*/
HWTEST_F(SessionProxyMockTest, UpdateSessionPropertyByAction, Function | SmallTest | Level2)
{
MockMessageParcel::ClearAllErrorFlag();
sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker();
SessionProxy* sessionProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker);
ASSERT_NE(sessionProxy, nullptr);
MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true);
ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr,
WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON));
MockMessageParcel::ClearAllErrorFlag();
MockMessageParcel::SetWriteUint32ErrorFlag(true);
ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr,
WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON));
MockMessageParcel::ClearAllErrorFlag();
sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
ASSERT_NE(property, nullptr);
MockMessageParcel::SetWriteBoolErrorFlag(true);
ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON));
MockMessageParcel::ClearAllErrorFlag();
MockMessageParcel::SetWriteBoolErrorFlag(false);
ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(property,
WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON));
MockMessageParcel::ClearAllErrorFlag();
MockMessageParcel::SetWriteBoolErrorFlag(true);
ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr,
WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON));
MockMessageParcel::ClearAllErrorFlag();
MockMessageParcel::SetWriteBoolErrorFlag(false);
ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr,
WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON));
MockMessageParcel::ClearAllErrorFlag();
}
} // namespace
} // namespace Rosen
} // namespace OHOS

View File

@ -581,6 +581,38 @@ HWTEST_F(SessionStubTest, HandleSetDialogSessionBackGestureEnabled01, Function |
auto res = session_->HandleSetDialogSessionBackGestureEnabled(data, reply);
ASSERT_EQ(0, res);
}
/**
* @tc.name: HandleUpdatePropertyByAction01
* @tc.desc: sessionStub sessionStubTest
* @tc.type: FUNC
* @tc.require: #I6JLSI
*/
HWTEST_F(SessionStubTest, HandleUpdatePropertyByAction01, Function | SmallTest | Level2)
{
MessageParcel data;
MessageParcel reply;
data.WriteBool(true);
ASSERT_NE(session_, nullptr);
auto res = session_->HandleUpdatePropertyByAction(data, reply);
ASSERT_EQ(0, res);
}
/**
* @tc.name: HandleUpdatePropertyByAction02
* @tc.desc: sessionStub sessionStubTest
* @tc.type: FUNC
* @tc.require: #I6JLSI
*/
HWTEST_F(SessionStubTest, HandleUpdatePropertyByAction02, Function | SmallTest | Level2)
{
MessageParcel data;
MessageParcel reply;
data.WriteBool(false);
ASSERT_NE(session_, nullptr);
auto res = session_->HandleUpdatePropertyByAction(data, reply);
ASSERT_EQ(0, res);
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -28,6 +28,8 @@
#include "session/host/include/session.h"
#include "session_manager/include/scene_session_manager.h"
#include "session_info.h"
#include "session/screen/include/screen_session.h"
#include "screen_session_manager/include/screen_session_manager_client.h"
#include "wm_common.h"
#include "window_manager_hilog.h"
@ -984,6 +986,61 @@ HWTEST_F(WindowSessionTest3, RectCheckProcess, Function | SmallTest | Level2)
EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr));
}
/**
* @tc.name: RectCheckProcess01
* @tc.desc: RectCheckProcess01 Test
* @tc.type: FUNC
*/
HWTEST_F(WindowSessionTest3, RectCheckProcess01, Function | SmallTest | Level2)
{
ASSERT_NE(session_, nullptr);
session_->state_ = SessionState::STATE_INACTIVE;
session_->isVisible_ = false;
session_->property_ = nullptr;
session_->RectCheckProcess();
session_->state_ = SessionState::STATE_ACTIVE;
session_->isVisible_ = true;
session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
session_->RectCheckProcess();
session_->property_->displayId_ = 0;
sptr<ScreenSession> screenSession = new ScreenSession(0, ScreenProperty(), 0);
ASSERT_NE(screenSession, nullptr);
ScreenProperty screenProperty = screenSession->GetScreenProperty();
ASSERT_NE(&screenProperty, nullptr);
screenSession->screenId_ = 0;
screenSession->SetVirtualPixelRatio(0.0f);
ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession));
session_->RectCheckProcess();
ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
screenSession->SetVirtualPixelRatio(1.0f);
ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession));
session_->RectCheckProcess();
WSRect rect = {0, 0, 0, 0};
session_->winRect_ = rect;
session_->RectCheckProcess();
session_->winRect_.height_ = 200;
session_->RectCheckProcess();
session_->aspectRatio_ = 0.0f;
session_->RectCheckProcess();
session_->aspectRatio_ = 0.5f;
session_->RectCheckProcess();
session_->winRect_.width_ = 200;
session_->RectCheckProcess();
session_->aspectRatio_ = 1.0f;
session_->RectCheckProcess();
ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
}
/**
* @tc.name: SetIsPcAppInPad
* @tc.desc: SetIsPcAppInPad Test

View File

@ -651,13 +651,38 @@ HWTEST_F(WindowSessionPropertyTest, SetIsLayoutFullScreen, Function | SmallTest
*/
HWTEST_F(WindowSessionPropertyTest, Read, Function | SmallTest | Level2)
{
WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
if (property != nullptr) {
Parcel parcel = Parcel();
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE);
ASSERT_EQ(property->GetPersistentId(), INVALID_SESSION_ID);
delete property;
}
sptr<WindowSessionProperty> property = new WindowSessionProperty();
ASSERT_NE(property, nullptr);
Parcel parcel = Parcel();
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_RECT);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_PROPS);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_FLAGS);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOPMOST);
property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO);
ASSERT_EQ(property->GetPersistentId(), INVALID_SESSION_ID);
}
/**
@ -667,21 +692,38 @@ HWTEST_F(WindowSessionPropertyTest, Read, Function | SmallTest | Level2)
*/
HWTEST_F(WindowSessionPropertyTest, Write, Function | SmallTest | Level2)
{
WindowSessionProperty *oldProperty = new (std::nothrow) WindowSessionProperty();
WindowSessionProperty *newProperty = new (std::nothrow) WindowSessionProperty();
if ((oldProperty != nullptr) && (newProperty != nullptr)) {
int32_t persistentId = 2;
oldProperty->SetPersistentId(persistentId);
oldProperty->SetFocusable(true);
Parcel parcel = Parcel();
oldProperty->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
newProperty->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
ASSERT_EQ(newProperty->GetPersistentId(), persistentId);
ASSERT_EQ(newProperty->GetFocusable(), true);
delete oldProperty;
delete newProperty;
}
sptr<WindowSessionProperty> property = new WindowSessionProperty();
ASSERT_NE(property, nullptr);
Parcel parcel = Parcel();
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_RECT);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_PROPS);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_FLAGS);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOPMOST);
property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO);
ASSERT_EQ(property->GetPersistentId(), INVALID_SESSION_ID);
}
/**

View File

@ -216,7 +216,8 @@ private:
void CalculateNewLimitsByLimits(
WindowLimits& newLimits, WindowLimits& customizedLimits, float& virtualPixelRatio);
void CalculateNewLimitsByRatio(WindowLimits& newLimits, WindowLimits& customizedLimits);
void NotifyDisplayInfoChange();
void NotifyDisplayInfoChange(const sptr<DisplayInfo>& info = nullptr);
void UpdateDensityInner(const sptr<DisplayInfo>& info = nullptr);
/**
* Window Immersive
@ -230,7 +231,7 @@ private:
std::atomic<bool> isDefaultDensityEnabled_ = false;
std::atomic<uint32_t> getAvoidAreaCnt_ = 0;
bool enableImmersiveMode_ = false;
void PreLayoutOnShow(WindowType type);
void PreLayoutOnShow(WindowType type, const sptr<DisplayInfo>& info = nullptr);
void InitSystemSessionDragEnable();
WMError RegisterKeyboardPanelInfoChangeListener(const sptr<IKeyboardPanelInfoChangeListener>& listener) override;

View File

@ -28,6 +28,7 @@
#include "singleton_container.h"
#include "common/include/window_session_property.h"
#include "display_info.h"
#include "interfaces/include/ws_common.h"
#include "interfaces/include/ws_common_inner.h"
#include "session/container/include/zidl/session_stage_stub.h"
@ -276,7 +277,8 @@ protected:
virtual WMError SetLayoutFullScreenByApiVersion(bool status);
virtual float GetVirtualPixelRatio(sptr<DisplayInfo> displayInfo);
void UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr,
const sptr<DisplayInfo>& info = nullptr);
void NotifySizeChange(Rect rect, WindowSizeChangeReason reason);
void NotifySubWindowClose(bool& terminateCloseProcess);
void NotifySwitchFreeMultiWindow(bool enable);

View File

@ -165,7 +165,7 @@ void VsyncStation::RemoveCallback()
void VsyncStation::VsyncCallbackInner(int64_t timestamp, int64_t frameCount)
{
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER,
"OnVsyncCallback %{public}" PRId64 ":%{public}" PRId64, timestamp, frameCount);
"OnVsyncCallback %" PRId64 ":%" PRId64, timestamp, frameCount);
Callbacks vsyncCallbacks;
{
std::lock_guard<std::mutex> lock(mutex_);

View File

@ -571,10 +571,10 @@ void WindowAdapter::OffWindowZoom()
/** @note @window.hierarchy */
WMError WindowAdapter::RaiseToAppTop(uint32_t windowId)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
auto wmsProxy = GetWindowManagerServiceProxy();
CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
return wmsProxy->RaiseToAppTop(windowId);
}

View File

@ -25,7 +25,6 @@
#include "anr_handler.h"
#include "color_parser.h"
#include "common/include/future_callback.h"
#include "display_info.h"
#include "singleton_container.h"
#include "display_manager.h"
#include "display_manager_adapter.h"
@ -950,7 +949,7 @@ void WindowSceneSessionImpl::UpdateSubWindowStateAndNotify(int32_t parentPersist
}
}
void WindowSceneSessionImpl::PreLayoutOnShow(WindowType type)
void WindowSceneSessionImpl::PreLayoutOnShow(WindowType type, const sptr<DisplayInfo>& info)
{
std::shared_ptr<Ace::UIContent> uiContent = GetUIContentSharedPtr();
if (uiContent == nullptr) {
@ -961,7 +960,7 @@ void WindowSceneSessionImpl::PreLayoutOnShow(WindowType type)
TLOGI(WmsLogTag::WMS_LIFE, "name: %{public}s, id: %{public}d, type: %{public}u, requestRect:%{public}s",
property_->GetWindowName().c_str(), GetPersistentId(), type, requestRect.ToString().c_str());
if (requestRect.width_ != 0 && requestRect.height_ != 0) {
UpdateViewportConfig(GetRequestRect(), WindowSizeChangeReason::RESIZE);
UpdateViewportConfig(GetRequestRect(), WindowSizeChangeReason::RESIZE, nullptr, info);
}
state_ = WindowState::STATE_SHOWN;
requestState_ = WindowState::STATE_SHOWN;
@ -1017,7 +1016,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation)
float density = GetVirtualPixelRatio(displayInfo);
if (!MathHelper::NearZero(virtualPixelRatio_ - density) ||
!MathHelper::NearZero(property_->GetLastLimitsVpr() - density)) {
UpdateDensity();
UpdateDensityInner(displayInfo);
}
WMError ret = UpdateAnimationFlagProperty(withAnimation);
@ -1030,7 +1029,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation)
if (WindowHelper::IsMainWindow(type)) {
ret = static_cast<WMError>(hostSession->Foreground(property_, true));
} else if (WindowHelper::IsSubWindow(type) || WindowHelper::IsSystemWindow(type)) {
PreLayoutOnShow(type);
PreLayoutOnShow(type, displayInfo);
// Add maintenance logs before the IPC process.
TLOGI(WmsLogTag::WMS_LIFE, "Show session [name: %{public}s, id: %{public}d]",
property_->GetWindowName().c_str(), GetPersistentId());
@ -1055,7 +1054,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation)
static_cast<int32_t>(ret), property_->GetWindowName().c_str(), GetPersistentId());
}
NotifyWindowStatusChange(GetMode());
NotifyDisplayInfoChange();
NotifyDisplayInfoChange(displayInfo);
return ret;
}
@ -1362,6 +1361,8 @@ WMError WindowSceneSessionImpl::Destroy(bool needNotifyServer, bool needClearLis
if (WindowHelper::IsMainWindow(GetType())) {
SetUIContentComplete();
}
surfaceNode_ = nullptr;
TLOGI(WmsLogTag::WMS_LIFE, "Destroy success, id: %{public}d", property_->GetPersistentId());
return WMError::WM_OK;
}
@ -2026,6 +2027,12 @@ WMError WindowSceneSessionImpl::Maximize(MaximizePresentation presentation)
if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) {
return WMError::WM_ERROR_INVALID_WINDOW;
}
// The device is not supported
auto isPC = windowSystemConfig_.uiType_ == UI_TYPE_PC;
if (!isPC && !IsFreeMultiWindowMode()) {
TLOGE(WmsLogTag::WMS_LAYOUT, "The device is not supported");
return WMError::WM_ERROR_INVALID_WINDOW;
}
if (property_->GetCompatibleModeInPc()) {
TLOGE(WmsLogTag::WMS_IMMS, "isCompatibleModeInPc, can not Maximize");
return WMError::WM_ERROR_INVALID_WINDOW;
@ -3582,6 +3589,11 @@ WMError WindowSceneSessionImpl::SetWindowMask(const std::vector<std::vector<uint
}
void WindowSceneSessionImpl::UpdateDensity()
{
UpdateDensityInner(nullptr);
}
void WindowSceneSessionImpl::UpdateDensityInner(const sptr<DisplayInfo>& info)
{
if (!userLimitsSet_) {
UpdateWindowSizeLimits();
@ -3593,10 +3605,10 @@ void WindowSceneSessionImpl::UpdateDensity()
}
}
NotifyDisplayInfoChange();
NotifyDisplayInfoChange(info);
auto preRect = GetRect();
UpdateViewportConfig(preRect, WindowSizeChangeReason::UNDEFINED);
UpdateViewportConfig(preRect, WindowSizeChangeReason::UNDEFINED, nullptr, info);
WLOGFI("[%{public}d, %{public}d, %{public}u, %{public}u]",
preRect.posX_, preRect.posY_, preRect.width_, preRect.height_);
}
@ -3655,17 +3667,23 @@ WSError WindowSceneSessionImpl::UpdateOrientation()
return WSError::WS_OK;
}
void WindowSceneSessionImpl::NotifyDisplayInfoChange()
void WindowSceneSessionImpl::NotifyDisplayInfoChange(const sptr<DisplayInfo>& info)
{
TLOGD(WmsLogTag::DMS, "id: %{public}d", GetPersistentId());
auto displayId = property_->GetDisplayId();
auto display = SingletonContainer::IsDestroyed() ? nullptr :
SingletonContainer::Get<DisplayManager>().GetDisplayById(displayId);
if (display == nullptr) {
TLOGE(WmsLogTag::DMS, "get display by displayId %{public}" PRIu64 " failed.", displayId);
return;
sptr<DisplayInfo> displayInfo = nullptr;
DisplayId displayId = 0;
if (info == nullptr) {
displayId = property_->GetDisplayId();
auto display = SingletonContainer::IsDestroyed() ? nullptr :
SingletonContainer::Get<DisplayManager>().GetDisplayById(displayId);
if (display == nullptr) {
TLOGE(WmsLogTag::DMS, "get display by displayId %{public}" PRIu64 " failed.", displayId);
return;
}
displayInfo = display->GetDisplayInfo();
} else {
displayInfo = info;
}
auto displayInfo = display->GetDisplayInfo();
if (displayInfo == nullptr) {
TLOGE(WmsLogTag::DMS, "get display info %{public}" PRIu64 " failed.", displayId);
return;

View File

@ -889,14 +889,19 @@ float WindowSessionImpl::GetVirtualPixelRatio(sptr<DisplayInfo> displayInfo)
}
void WindowSessionImpl::UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction>& rsTransaction)
const std::shared_ptr<RSTransaction>& rsTransaction, const sptr<DisplayInfo>& info)
{
auto display = SingletonContainer::Get<DisplayManager>().GetDisplayById(property_->GetDisplayId());
if (display == nullptr) {
WLOGFE("display is null!");
return;
sptr<DisplayInfo> displayInfo;
if (info == nullptr) {
auto display = SingletonContainer::Get<DisplayManager>().GetDisplayById(property_->GetDisplayId());
if (display == nullptr) {
WLOGFE("display is null!");
return;
}
displayInfo = display->GetDisplayInfo();
} else {
displayInfo = info;
}
auto displayInfo = display->GetDisplayInfo();
if (displayInfo == nullptr) {
WLOGFE("displayInfo is null!");
return;

View File

@ -1464,7 +1464,11 @@ HWTEST_F(WindowSceneSessionImplTest2, Maximize03, Function | SmallTest | Level2)
ASSERT_NE(nullptr, window);
// case1: only set maximize()
MaximizePresentation presentation = MaximizePresentation::ENTER_IMMERSIVE;
window->windowSystemConfig_.uiType_ = "phone";
auto ret = window->Maximize(presentation);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret);
window->windowSystemConfig_.uiType_ = "pc";
ret = window->Maximize(presentation);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(window->GetImmersiveModeEnabledState(), true);

View File

@ -1031,23 +1031,23 @@ WMError WindowManagerProxy::RaiseToAppTop(uint32_t windowId)
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return WMError::WM_DO_NOTHING;
return WMError::WM_ERROR_IPC_FAILED;
}
if (!data.WriteUint32(windowId)) {
WLOGFE("Write anchor delatX failed");
return WMError::WM_DO_NOTHING;
return WMError::WM_ERROR_IPC_FAILED;
}
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("remote is null");
return WMError::WM_DO_NOTHING;
return WMError::WM_ERROR_IPC_FAILED;
}
if (remote->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_RAISE_WINDOW_Z_ORDER),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return WMError::WM_DO_NOTHING;
return WMError::WM_ERROR_IPC_FAILED;
}
return WMError::WM_OK;
}