kuangmei 2024-10-25 11:01:07 +08:00
commit f3a2ac9e70
201 changed files with 8545 additions and 2988 deletions

View File

@ -38,7 +38,6 @@
"hisysevent",
"ability_runtime",
"napi",
"node",
"common_event_service",
"hilog",
"access_token",

View File

@ -18,6 +18,7 @@ config("libdm_private_config") {
include_dirs = [
"include",
"../dm/include",
"../dmserver/include",
]
}
@ -43,11 +44,10 @@ ohos_shared_library("libdm_lite") {
}
sources = [
"../dm/src/zidl/display_manager_agent_stub.cpp",
"../window_scene/screen_session_manager/src/zidl/screen_session_manager_lite_proxy.cpp",
"../wmserver/src/zidl/mock_session_manager_service_proxy.cpp",
"src/display_lite.cpp",
"src/display_manager_adapter_lite.cpp",
"src/display_manager_lite.cpp",
"src/display_manager_lite_proxy.cpp",
"src/screen_manager_lite.cpp",
]
@ -75,6 +75,10 @@ ohos_shared_library("libdm_lite") {
if (build_variant == "user") {
defines += [ "IS_RELEASE_VERSION" ]
}
if (window_manager_use_sceneboard) {
defines += [ "SCENE_BOARD_ENABLED" ]
}
}
group("test") {

View File

@ -22,7 +22,8 @@
#include "display_lite.h"
#include "dm_common.h"
#include "singleton_delegator.h"
#include "zidl/screen_session_manager_lite_interface.h"
#include "display_manager_lite_proxy.h"
#include "zidl/display_manager_agent_interface.h"
namespace OHOS::Rosen {
class BaseAdapterLite {
@ -36,7 +37,7 @@ public:
protected:
bool InitDMSProxy();
std::recursive_mutex mutex_;
sptr<IScreenSessionManagerLite> displayManagerServiceProxy_ = nullptr;
sptr<DisplayManagerLiteProxy> displayManagerServiceProxy_ = nullptr;
sptr<IRemoteObject::DeathRecipient> dmsDeath_ = nullptr;
bool isProxyValid_ { false };
};
@ -67,8 +68,11 @@ public:
virtual bool WakeUpEnd();
virtual bool SuspendBegin(PowerStateChangeReason reason);
virtual bool SuspendEnd();
virtual ScreenId GetInternalScreenId();
virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason);
virtual bool SetDisplayState(DisplayState state);
virtual DisplayState GetDisplayState(DisplayId displayId);
virtual bool TryToCancelScreenOff();
virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level);
virtual uint32_t GetScreenBrightness(uint64_t screenId);
private:

View File

@ -0,0 +1,83 @@
/*
* 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 OHOS_ROSEN_DISPLAY_MANAGER_LITE_PROXY_H
#define OHOS_ROSEN_DISPLAY_MANAGER_LITE_PROXY_H
#include "display_manager_interface_code.h"
#include <iremote_broker.h>
#include <iremote_proxy.h>
#include <cinttypes>
#include "dm_common.h"
#include "zidl/display_manager_agent_interface.h"
#include "display_info.h"
#include "fold_screen_info.h"
#include "screen_group_info.h"
namespace OHOS {
namespace Rosen {
class DisplayManagerLiteProxy : public IRemoteBroker {
public:
#ifdef SCENE_BOARD_ENABLED
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IScreenSessionManager");
#else
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IDisplayManager");
#endif
explicit DisplayManagerLiteProxy(const sptr<IRemoteObject>& impl) : remoteObject(impl) {}
~DisplayManagerLiteProxy() = default;
sptr<IRemoteObject> AsObject() { return remoteObject; };
virtual DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type);
virtual DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type);
virtual FoldDisplayMode GetFoldDisplayMode();
virtual void SetFoldDisplayMode(const FoldDisplayMode displayMode);
virtual bool IsFoldable();
FoldStatus GetFoldStatus();
virtual sptr<DisplayInfo> GetDefaultDisplayInfo();
virtual sptr<DisplayInfo> GetDisplayInfoById(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 ScreenId GetInternalScreenId();
virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason);
virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason);
virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason);
virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId);
virtual bool SetDisplayState(DisplayState state);
virtual DisplayState GetDisplayState(DisplayId displayId);
virtual bool TryToCancelScreenOff();
virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level);
virtual uint32_t GetScreenBrightness(uint64_t screenId);
virtual std::vector<DisplayId> GetAllDisplayIds();
private:
sptr<IRemoteObject> Remote() { return remoteObject; };
sptr<IRemoteObject> remoteObject = nullptr;
};
} // namespace Rosen
} // namespace OHOS
#endif // OHOS_ROSEN_SCREEN_SESSION_MANAGER_LITE_PROXY_H

View File

@ -20,9 +20,9 @@
#include <system_ability_definition.h>
#include "display_manager_lite.h"
#include "screen_manager_lite.h"
#include "dm_common.h"
#include "window_manager_hilog.h"
#include "zidl/mock_session_manager_service_interface.h"
namespace OHOS::Rosen {
namespace {
@ -61,40 +61,31 @@ bool BaseAdapterLite::InitDMSProxy()
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (!isProxyValid_) {
sptr<ISystemAbilityManager> systemAbilityManager =
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (!systemAbilityManager) {
WLOGFE("Failed to get system ability mgr.");
return false;
}
sptr<IRemoteObject> mockRemoteObject = systemAbilityManager->GetSystemAbility(WINDOW_MANAGER_SERVICE_ID);
if (!mockRemoteObject) {
WLOGFI("Remote object is nullptr");
sptr<IRemoteObject> remoteObject
= systemAbilityManager->GetSystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID);
if (!remoteObject) {
WLOGFE("Failed to get display manager service.");
return false;
}
auto mockSessionManagerServiceProxy_ = iface_cast<IMockSessionManagerInterface>(mockRemoteObject);
if (!mockSessionManagerServiceProxy_) {
WLOGFW("Get mock session manager service proxy failed, nullptr");
displayManagerServiceProxy_ = new(std::nothrow) DisplayManagerLiteProxy(remoteObject);
if ((!displayManagerServiceProxy_) || (!displayManagerServiceProxy_->AsObject())) {
WLOGFW("Failed to get system display manager services");
return false;
}
sptr<IRemoteObject> displayRemoteObject = mockSessionManagerServiceProxy_->GetScreenSessionManagerLite();
if (!displayRemoteObject) {
WLOGFE("displayRemoteObject is nullptr");
dmsDeath_ = new(std::nothrow) DMSDeathRecipientLite(*this);
if (dmsDeath_ == nullptr) {
WLOGFE("Failed to create death Recipient ptr DMSDeathRecipient");
return false;
}
displayManagerServiceProxy_ = iface_cast<IScreenSessionManagerLite>(displayRemoteObject);
if ((!displayManagerServiceProxy_) || (!displayManagerServiceProxy_->AsObject())) {
WLOGFE("Failed to get system scene session manager services");
return false;
}
dmsDeath_ = new (std::nothrow) DMSDeathRecipientLite(*this);
if (!dmsDeath_) {
WLOGFE("Failed to create death Recipient ptr DMSDeathRecipientLite");
return false;
}
sptr<IRemoteObject> remoteObject = displayManagerServiceProxy_->AsObject();
if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(dmsDeath_)) {
WLOGFE("Failed to add death recipient.");
WLOGFE("Failed to add death recipient");
return false;
}
isProxyValid_ = true;
@ -189,6 +180,21 @@ bool DisplayManagerAdapterLite::SuspendEnd()
return displayManagerServiceProxy_->SuspendEnd();
}
ScreenId DisplayManagerAdapterLite::GetInternalScreenId()
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->GetInternalScreenId();
}
bool DisplayManagerAdapterLite::SetScreenPowerById(ScreenId screenId, ScreenPowerState state,
PowerStateChangeReason reason)
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->SetScreenPowerById(screenId, state, reason);
}
bool DisplayManagerAdapterLite::SetDisplayState(DisplayState state)
{
INIT_PROXY_CHECK_RETURN(false);
@ -203,6 +209,13 @@ DisplayState DisplayManagerAdapterLite::GetDisplayState(DisplayId displayId)
return displayManagerServiceProxy_->GetDisplayState(displayId);
}
bool DisplayManagerAdapterLite::TryToCancelScreenOff()
{
INIT_PROXY_CHECK_RETURN(false);
return displayManagerServiceProxy_->TryToCancelScreenOff();
}
bool DisplayManagerAdapterLite::SetScreenBrightness(uint64_t screenId, uint32_t level)
{
INIT_PROXY_CHECK_RETURN(false);
@ -219,7 +232,7 @@ uint32_t DisplayManagerAdapterLite::GetScreenBrightness(uint64_t screenId)
std::vector<DisplayId> DisplayManagerAdapterLite::GetAllDisplayIds()
{
WLOGFD("DisplayManagerAdapter::GetAllDisplayIds enter");
WLOGFD("DisplayManagerAdapterLite::GetAllDisplayIds enter");
INIT_PROXY_CHECK_RETURN(std::vector<DisplayId>());
return displayManagerServiceProxy_->GetAllDisplayIds();
@ -266,6 +279,7 @@ void DMSDeathRecipientLite::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath)
WLOGFI("dms OnRemoteDied");
adapter_.Clear();
SingletonContainer::Get<DisplayManagerLite>().OnRemoteDied();
SingletonContainer::Get<ScreenManagerLite>().OnRemoteDied();
return;
}

View File

@ -590,6 +590,18 @@ bool DisplayManagerLite::SuspendEnd()
return SingletonContainer::Get<DisplayManagerAdapterLite>().SuspendEnd();
}
ScreenId DisplayManagerLite::GetInternalScreenId()
{
WLOGFD("[UL_POWER]GetInternalScreenId start");
return SingletonContainer::Get<DisplayManagerAdapterLite>().GetInternalScreenId();
}
bool DisplayManagerLite::SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason)
{
WLOGFD("[UL_POWER]SetScreenPowerById start");
return SingletonContainer::Get<DisplayManagerAdapterLite>().SetScreenPowerById(screenId, state, reason);
}
bool DisplayManagerLite::SetDisplayState(DisplayState state, DisplayStateCallback callback)
{
return pImpl_->SetDisplayState(state, callback);
@ -661,9 +673,15 @@ void DisplayManagerLite::Impl::ClearDisplayStateCallback()
}
}
bool DisplayManagerLite::TryToCancelScreenOff()
{
WLOGFD("[UL_POWER]TryToCancelScreenOff start");
return SingletonContainer::Get<DisplayManagerAdapterLite>().TryToCancelScreenOff();
}
bool DisplayManagerLite::SetScreenBrightness(uint64_t screenId, uint32_t level)
{
WLOGFI("[UL_POWER]SetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level);
WLOGFD("[UL_POWER]SetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level);
SingletonContainer::Get<DisplayManagerAdapterLite>().SetScreenBrightness(screenId, level);
return true;
}
@ -671,7 +689,7 @@ bool DisplayManagerLite::SetScreenBrightness(uint64_t screenId, uint32_t level)
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);
WLOGFD("[UL_POWER]GetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level);
return level;
}

View File

@ -0,0 +1,714 @@
/*
* 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 "display_manager_lite_proxy.h"
#include <ipc_types.h>
#include <message_option.h>
#include <message_parcel.h>
#include "dm_common.h"
#include "marshalling_helper.h"
#include "window_manager_hilog.h"
namespace OHOS::Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerLiteProxy" };
}
DMError DisplayManagerLiteProxy::RegisterDisplayManagerAgent(
const sptr<IDisplayManagerAgent>& displayManagerAgent, DisplayManagerAgentType type)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("remote is null");
return DMError::DM_ERROR_IPC_FAILED;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
WLOGFD("DisplayManagerLiteProxy::RegisterDisplayManagerAgent");
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("RegisterDisplayManagerAgent WriteInterfaceToken failed");
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
}
if (displayManagerAgent == nullptr) {
WLOGFE("IDisplayManagerAgent is null");
return DMError::DM_ERROR_INVALID_PARAM;
}
if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) {
WLOGFE("Write IDisplayManagerAgent failed");
return DMError::DM_ERROR_IPC_FAILED;
}
if (!data.WriteUint32(static_cast<uint32_t>(type))) {
WLOGFE("Write DisplayManagerAgent type failed");
return DMError::DM_ERROR_IPC_FAILED;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return DMError::DM_ERROR_IPC_FAILED;
}
return static_cast<DMError>(reply.ReadInt32());
}
DMError DisplayManagerLiteProxy::UnregisterDisplayManagerAgent(
const sptr<IDisplayManagerAgent>& displayManagerAgent, DisplayManagerAgentType type)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("remote is null");
return DMError::DM_ERROR_IPC_FAILED;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
WLOGFD("DisplayManagerLiteProxy::UnregisterDisplayManagerAgent");
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("UnregisterDisplayManagerAgent WriteInterfaceToken failed");
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
}
if (displayManagerAgent == nullptr) {
WLOGFE("IDisplayManagerAgent is null");
return DMError::DM_ERROR_INVALID_PARAM;
}
if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) {
WLOGFE("Write IWindowManagerAgent failed");
return DMError::DM_ERROR_IPC_FAILED;
}
if (!data.WriteUint32(static_cast<uint32_t>(type))) {
WLOGFE("Write DisplayManagerAgent type failed");
return DMError::DM_ERROR_IPC_FAILED;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return DMError::DM_ERROR_IPC_FAILED;
}
return static_cast<DMError>(reply.ReadInt32());
}
FoldDisplayMode DisplayManagerLiteProxy::GetFoldDisplayMode()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("remote is null");
return FoldDisplayMode::UNKNOWN;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken Failed");
return FoldDisplayMode::UNKNOWN;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE),
data, reply, option) != ERR_NONE) {
WLOGFE("Send TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE request failed");
return FoldDisplayMode::UNKNOWN;
}
return static_cast<FoldDisplayMode>(reply.ReadUint32());
}
void DisplayManagerLiteProxy::SetFoldDisplayMode(const FoldDisplayMode displayMode)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("remote is null");
return;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken Failed");
return;
}
if (!data.WriteUint32(static_cast<uint32_t>(displayMode))) {
WLOGFE("Write displayMode failed");
return;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE),
data, reply, option) != ERR_NONE) {
WLOGFE("Send TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE request failed");
}
}
bool DisplayManagerLiteProxy::IsFoldable()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("remote is null");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("IsFoldable WriteInterfaceToken failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_IS_FOLDABLE),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return false;
}
return reply.ReadBool();
}
FoldStatus DisplayManagerLiteProxy::GetFoldStatus()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("remote is null");
return FoldStatus::UNKNOWN;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return FoldStatus::UNKNOWN;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return FoldStatus::UNKNOWN;
}
return static_cast<FoldStatus>(reply.ReadUint32());
}
sptr<DisplayInfo> OHOS::Rosen::DisplayManagerLiteProxy::GetDefaultDisplayInfo()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("remote is null");
return nullptr;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return nullptr;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return nullptr;
}
sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
if (info == nullptr) {
WLOGFW("read display info failed, info is nullptr.");
}
return info;
}
sptr<DisplayInfo> DisplayManagerLiteProxy::GetDisplayInfoById(DisplayId displayId)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("GetDisplayInfoById: remote is nullptr");
return nullptr;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("GetDisplayInfoById: WriteInterfaceToken failed");
return nullptr;
}
if (!data.WriteUint64(displayId)) {
WLOGFW("GetDisplayInfoById: WriteUint64 displayId failed");
return nullptr;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID),
data, reply, option) != ERR_NONE) {
WLOGFW("GetDisplayInfoById: SendRequest failed");
return nullptr;
}
sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
if (info == nullptr) {
WLOGFW("DisplayManagerProxy::GetDisplayInfoById SendRequest nullptr.");
return nullptr;
}
return info;
}
sptr<CutoutInfo> DisplayManagerLiteProxy::GetCutoutInfo(DisplayId displayId)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFW("get cutout info : remote is null");
return nullptr;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("get cutout info : failed");
return nullptr;
}
if (!data.WriteUint64(displayId)) {
WLOGFE("get cutout info: write displayId failed");
return nullptr;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_CUTOUT_INFO),
data, reply, option) != ERR_NONE) {
WLOGFW("GetCutoutInfo: GetCutoutInfo failed");
return nullptr;
}
sptr<CutoutInfo> info = reply.ReadParcelable<CutoutInfo>();
return info;
}
/*
* used by powermgr
*/
bool DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]WakeUpBegin: SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_WAKE_UP_END),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]WakeUpEnd: SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SuspendBegin: SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_SUSPEND_END),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SuspendEnd: SendRequest failed");
return false;
}
return reply.ReadBool();
}
ScreenId DisplayManagerLiteProxy::GetInternalScreenId()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]GetInternalScreenId remote is nullptr");
return SCREEN_ID_INVALID;
}
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("[UL_POWER]GetInternalScreenId: WriteInterfaceToken failed");
return SCREEN_ID_INVALID;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_INTERNAL_SCREEN_ID),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]GetInternalScreenId: SendRequest failed");
return SCREEN_ID_INVALID;
}
return reply.ReadUint64();
}
bool DisplayManagerLiteProxy::SetScreenPowerById(ScreenId screenId, ScreenPowerState state,
PowerStateChangeReason reason)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]SetScreenPowerById remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("[UL_POWER]WriteInterfaceToken failed");
return false;
}
if (!data.WriteUint64(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>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_BY_ID),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SendRequest failed");
return false;
}
return reply.ReadBool();
}
ScreenPowerState DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER),
data, reply, option) != ERR_NONE) {
WLOGFW("SendRequest failed");
return ScreenPowerState::INVALID_STATE;
}
return static_cast<ScreenPowerState>(reply.ReadUint32());
}
bool DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]SendRequest failed");
return false;
}
return reply.ReadBool();
}
DisplayState DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE),
data, reply, option) != ERR_NONE) {
WLOGFW("SendRequest failed");
return DisplayState::UNKNOWN;
}
return static_cast<DisplayState>(reply.ReadUint32());
}
bool DisplayManagerLiteProxy::TryToCancelScreenOff()
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
WLOGFE("[UL_POWER]TryToCancelScreenOff remote is nullptr");
return false;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("[UL_POWER]TryToCancelScreenOff: WriteInterfaceToken failed");
return false;
}
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_TRY_TO_CANCEL_SCREEN_OFF),
data, reply, option) != ERR_NONE) {
WLOGFW("[UL_POWER]TryToCancelScreenOff: SendRequest failed");
return false;
}
return reply.ReadBool();
}
bool DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_BRIGHTNESS),
data, reply, option) != ERR_NONE) {
WLOGFW("SendRequest failed");
return false;
}
return reply.ReadBool();
}
uint32_t DisplayManagerLiteProxy::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>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_BRIGHTNESS),
data, reply, option) != ERR_NONE) {
WLOGFW("SendRequest failed");
return 0;
}
return reply.ReadUint32();
}
std::vector<DisplayId> DisplayManagerLiteProxy::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>(DisplayManagerMessage::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

@ -13,8 +13,9 @@
* limitations under the License.
*/
#include "screen_manager_lite.h"
#include <cinttypes>
#include "display_manager_adapter_lite.h"
#include "display_manager_agent_default.h"
#include "singleton_delegator.h"
#include "window_manager_hilog.h"
@ -23,10 +24,95 @@ namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenManagerLite"};
}
/*
* used by powermgr
*/
class ScreenManagerLite::Impl : public RefBase {
public:
Impl() = default;
~Impl();
static inline SingletonDelegator<ScreenManagerLite> delegator;
DMError RegisterScreenListener(sptr<IScreenListener> listener);
DMError UnregisterScreenListener(sptr<IScreenListener> listener);
DMError RegisterDisplayManagerAgent();
DMError UnregisterDisplayManagerAgent();
void OnRemoteDied();
private:
void NotifyScreenConnect(sptr<ScreenInfo> info);
void NotifyScreenDisconnect(ScreenId);
void NotifyScreenChange(const sptr<ScreenInfo>& screenInfo);
class ScreenManagerListener;
sptr<ScreenManagerListener> screenManagerListener_;
std::mutex mutex_;
std::set<sptr<IScreenListener>> screenListeners_;
};
class ScreenManagerLite::Impl::ScreenManagerListener : public DisplayManagerAgentDefault {
public:
explicit ScreenManagerListener(sptr<Impl> impl) : pImpl_(impl)
{
}
void OnScreenConnect(sptr<ScreenInfo> screenInfo)
{
if (screenInfo == nullptr || screenInfo->GetScreenId() == SCREEN_ID_INVALID) {
WLOGFE("OnScreenConnect, screenInfo is invalid.");
return;
}
if (pImpl_ == nullptr) {
WLOGFE("OnScreenConnect, impl is nullptr.");
return;
}
std::lock_guard<std::mutex> lock(pImpl_->mutex_);
for (auto listener : pImpl_->screenListeners_) {
listener->OnConnect(screenInfo->GetScreenId());
}
};
void OnScreenDisconnect(ScreenId screenId)
{
if (screenId == SCREEN_ID_INVALID) {
WLOGFE("OnScreenDisconnect, screenId is invalid.");
return;
}
if (pImpl_ == nullptr) {
WLOGFE("OnScreenDisconnect, impl is nullptr.");
return;
}
std::lock_guard<std::mutex> lock(pImpl_->mutex_);
for (auto listener : pImpl_->screenListeners_) {
listener->OnDisconnect(screenId);
}
};
void OnScreenChange(const sptr<ScreenInfo>& screenInfo, ScreenChangeEvent event)
{
if (screenInfo == nullptr) {
WLOGFE("OnScreenChange, screenInfo is null.");
return;
}
if (pImpl_ == nullptr) {
WLOGFE("OnScreenChange, impl is nullptr.");
return;
}
WLOGFD("OnScreenChange. event %{public}u", event);
std::lock_guard<std::mutex> lock(pImpl_->mutex_);
for (auto listener: pImpl_->screenListeners_) {
listener->OnChange(screenInfo->GetScreenId());
}
};
private:
sptr<Impl> pImpl_;
};
WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManagerLite)
ScreenManagerLite::ScreenManagerLite()
{
pImpl_ = new Impl();
WLOGFD("Create ScreenManagerLite instance");
}
@ -35,9 +121,81 @@ ScreenManagerLite::~ScreenManagerLite()
WLOGFD("Destroy ScreenManagerLite instance");
}
/*
* used by powermgr
*/
ScreenManagerLite::Impl::~Impl()
{
std::lock_guard<std::mutex> lock(mutex_);
UnregisterDisplayManagerAgent();
}
DMError ScreenManagerLite::Impl::RegisterDisplayManagerAgent()
{
DMError regSucc = DMError::DM_OK;
if (screenManagerListener_ == nullptr) {
screenManagerListener_ = new ScreenManagerListener(this);
regSucc = SingletonContainer::Get<ScreenManagerAdapterLite>().RegisterDisplayManagerAgent(
screenManagerListener_, DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
if (regSucc != DMError::DM_OK) {
screenManagerListener_ = nullptr;
WLOGFW("RegisterDisplayManagerAgent failed !");
}
}
return regSucc;
}
DMError ScreenManagerLite::Impl::UnregisterDisplayManagerAgent()
{
DMError unRegSucc = DMError::DM_OK;
if (screenManagerListener_ != nullptr) {
unRegSucc = SingletonContainer::Get<ScreenManagerAdapterLite>().UnregisterDisplayManagerAgent(
screenManagerListener_, DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
screenManagerListener_ = nullptr;
if (unRegSucc != DMError::DM_OK) {
WLOGFW("UnregisterDisplayManagerAgent failed!");
}
}
return unRegSucc;
}
DMError ScreenManagerLite::Impl::RegisterScreenListener(sptr<IScreenListener> listener)
{
std::lock_guard<std::mutex> lock(mutex_);
DMError regSucc = RegisterDisplayManagerAgent();
if (regSucc == DMError::DM_OK) {
screenListeners_.insert(listener);
}
return regSucc;
}
DMError ScreenManagerLite::RegisterScreenListener(sptr<IScreenListener> listener)
{
if (listener == nullptr) {
WLOGFE("RegisterScreenListener listener is nullptr.");
return DMError::DM_ERROR_NULLPTR;
}
return pImpl_->RegisterScreenListener(listener);
}
DMError ScreenManagerLite::Impl::UnregisterScreenListener(sptr<IScreenListener> listener)
{
std::lock_guard<std::mutex> lock(mutex_);
auto iter = std::find(screenListeners_.begin(), screenListeners_.end(), listener);
if (iter == screenListeners_.end()) {
WLOGFE("could not find this listener");
return DMError::DM_ERROR_NULLPTR;
}
screenListeners_.erase(iter);
return UnregisterDisplayManagerAgent();
}
DMError ScreenManagerLite::UnregisterScreenListener(sptr<IScreenListener> listener)
{
if (listener == nullptr) {
WLOGFE("UnregisterScreenListener listener is nullptr.");
return DMError::DM_ERROR_NULLPTR;
}
return pImpl_->UnregisterScreenListener(listener);
}
bool ScreenManagerLite::SetSpecifiedScreenPower(ScreenId screenId,
ScreenPowerState state, PowerStateChangeReason reason)
{
@ -56,4 +214,16 @@ ScreenPowerState ScreenManagerLite::GetScreenPower(ScreenId dmsScreenId)
return SingletonContainer::Get<ScreenManagerAdapterLite>().GetScreenPower(dmsScreenId);
}
void ScreenManagerLite::Impl::OnRemoteDied()
{
WLOGFD("dms is died");
std::lock_guard<std::mutex> lock(mutex_);
screenManagerListener_ = nullptr;
}
void ScreenManagerLite::OnRemoteDied()
{
pImpl_->OnRemoteDied();
}
} // namespace OHOS::Rosen

View File

@ -28,6 +28,7 @@
#include "screen.h"
#include "screen_info.h"
#include "screen_group_info.h"
#include "display_manager_interface_code.h"
#include "zidl/display_manager_agent_interface.h"
namespace OHOS::Rosen {
@ -35,122 +36,6 @@ class IDisplayManager : public IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IDisplayManager");
enum class DisplayManagerMessage : uint32_t {
TRANS_ID_GET_DEFAULT_DISPLAY_INFO = 0,
TRANS_ID_GET_DISPLAY_BY_ID,
TRANS_ID_GET_DISPLAY_BY_SCREEN,
TRANS_ID_GET_DISPLAY_SNAPSHOT,
TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT,
TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT,
TRANS_ID_WAKE_UP_BEGIN,
TRANS_ID_WAKE_UP_END,
TRANS_ID_SUSPEND_BEGIN,
TRANS_ID_SUSPEND_END,
TRANS_ID_GET_INTERNAL_SCREEN_ID,
TRANS_ID_SET_SCREEN_POWER_BY_ID,
TRANS_ID_SET_SPECIFIED_SCREEN_POWER,
TRANS_ID_SET_SCREEN_POWER_FOR_ALL,
TRANS_ID_GET_SCREEN_POWER,
TRANS_ID_SET_DISPLAY_STATE,
TRANS_ID_GET_DISPLAY_STATE,
TRANS_ID_GET_ALL_DISPLAYIDS,
TRANS_ID_NOTIFY_DISPLAY_EVENT,
TRANS_ID_TRY_TO_CANCEL_SCREEN_OFF,
TRANS_ID_SET_FREEZE_EVENT,
TRANS_ID_SCREEN_BASE = 1000,
TRANS_ID_CREATE_VIRTUAL_SCREEN = TRANS_ID_SCREEN_BASE,
TRANS_ID_DESTROY_VIRTUAL_SCREEN,
TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE,
TRANS_ID_SET_VIRTUAL_SCREEN_CANVAS_ROTATION,
TRANS_ID_GET_SCREEN_INFO_BY_ID,
TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID,
TRANS_ID_SET_SCREEN_ACTIVE_MODE,
TRANS_ID_GET_ALL_SCREEN_INFOS,
TRANS_ID_SET_ORIENTATION,
TRANS_ID_SET_VIRTUAL_PIXEL_RATIO,
TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM,
TRANS_ID_SET_RESOLUTION,
TRANS_ID_GET_DENSITY_IN_CURRENT_RESOLUTION,
TRANS_ID_SCREENGROUP_BASE = 1100,
TRANS_ID_SCREEN_MAKE_MIRROR = TRANS_ID_SCREENGROUP_BASE,
TRANS_ID_MULTI_SCREEN_MODE_SWITCH,
TRANS_ID_SET_MULTI_SCREEN_POSITION,
TRANS_ID_SCREEN_MAKE_EXPAND,
TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP,
TRANS_ID_SCREEN_GAMUT_BASE = 1200,
TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS = TRANS_ID_SCREEN_GAMUT_BASE,
TRANS_ID_SCREEN_GET_COLOR_GAMUT,
TRANS_ID_SCREEN_SET_COLOR_GAMUT,
TRANS_ID_SCREEN_GET_GAMUT_MAP,
TRANS_ID_SCREEN_SET_GAMUT_MAP,
TRANS_ID_SCREEN_SET_COLOR_TRANSFORM,
TRANS_ID_SCREEN_GET_PIXEL_FORMAT,
TRANS_ID_SCREEN_SET_PIXEL_FORMAT,
TRANS_ID_SCREEN_GET_SUPPORTED_HDR_FORMAT,
TRANS_ID_SCREEN_GET_HDR_FORMAT,
TRANS_ID_SCREEN_SET_HDR_FORMAT,
TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_SPACE,
TRANS_ID_SCREEN_GET_COLOR_SPACE,
TRANS_ID_SCREEN_SET_COLOR_SPACE,
TRANS_ID_IS_SCREEN_ROTATION_LOCKED,
TRANS_ID_SET_SCREEN_ROTATION_LOCKED,
TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS,
TRANS_ID_HAS_PRIVATE_WINDOW,
TRANS_ID_GET_CUTOUT_INFO,
TRANS_ID_HAS_IMMERSIVE_WINDOW,
TRANS_ID_ADD_SURFACE_NODE,
TRANS_ID_REMOVE_SURFACE_NODE,
TRANS_ID_SCREEN_STOP_MIRROR,
TRANS_ID_SCREEN_STOP_EXPAND,
TRANS_ID_SCREEN_DISABLE_MIRROR,
TRANS_ID_SCENE_BOARD_SCREEN_BASE = 2000,
TRANS_ID_SCENE_BOARD_DUMP_ALL_SCREEN,
TRANS_ID_SCENE_BOARD_DUMP_SPECIAL_SCREEN,
TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE,
TRANS_ID_SET_FOLD_DISPLAY_MODE_FROM_JS,
TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE,
TRANS_ID_SCENE_BOARD_SET_DISPLAY_SCALE,
TRANS_ID_SCENE_BOARD_IS_FOLDABLE,
TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS,
TRANS_ID_SCENE_BOARD_GET_CURRENT_FOLD_CREASE_REGION,
TRANS_ID_SCENE_BOARD_MAKE_UNIQUE_SCREEN,
TRANS_ID_SCENE_BOARD_LOCK_FOLD_DISPLAY_STATUS,
TRANS_ID_SET_LOCK_FOLD_DISPLAY_STATUS_FROM_JS,
TRANS_ID_SET_CLIENT = 2500,
TRANS_ID_GET_SCREEN_PROPERTY,
TRANS_ID_GET_DISPLAY_NODE,
TRANS_ID_UPDATE_SCREEN_ROTATION_PROPERTY,
TRANS_ID_UPDATE_AVAILABLE_AREA,
TRANS_ID_SET_SCREEN_OFF_DELAY_TIME,
TRANS_ID_GET_CURVED_SCREEN_COMPRESSION_AREA,
TRANS_ID_GET_PHY_SCREEN_PROPERTY,
TRANS_ID_NOTIFY_DISPLAY_CHANGE_INFO,
TRANS_ID_SET_SCREEN_PRIVACY_STATE,
TRANS_ID_SET_SCREENID_PRIVACY_STATE,
TRANS_ID_SET_SCREEN_PRIVACY_WINDOW_LIST,
TRANS_ID_RESIZE_VIRTUAL_SCREEN,
TRANS_ID_GET_AVAILABLE_AREA,
TRANS_ID_NOTIFY_FOLD_TO_EXPAND_COMPLETION,
TRANS_ID_CONVERT_SCREENID_TO_RSSCREENID,
TRANS_ID_GET_VIRTUAL_SCREEN_FLAG,
TRANS_ID_SET_VIRTUAL_SCREEN_FLAG,
TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE,
TRANS_ID_GET_DEVICE_SCREEN_CONFIG,
TRANS_ID_SET_VIRTUAL_SCREEN_REFRESH_RATE,
TRANS_ID_DEVICE_IS_CAPTURE,
TRANS_ID_GET_SNAPSHOT_BY_PICKER,
TRANS_ID_SWITCH_USER,
TRANS_ID_SET_VIRTUAL_SCREEN_BLACK_LIST,
TRANS_ID_DISABLE_POWEROFF_RENDER_CONTROL,
TRANS_ID_PROXY_FOR_FREEZE,
TRANS_ID_RESET_ALL_FREEZE_STATUS,
TRANS_ID_NOTIFY_DISPLAY_HOOK_INFO,
TRANS_ID_GET_ALL_PHYSICAL_DISPLAY_RESOLUTION,
TRANS_ID_SET_VIRTUAL_SCREEN_STATUS,
TRANS_ID_SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION,
TRANS_ID_SET_VIRTUAL_SCREEN_MAX_REFRESHRATE,
};
virtual sptr<DisplayInfo> GetDefaultDisplayInfo() = 0;
virtual sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) = 0;
virtual sptr<DisplayInfo> GetDisplayInfoByScreen(ScreenId screenId) = 0;
@ -241,6 +126,8 @@ public:
virtual bool SetDisplayState(DisplayState state) = 0;
virtual DisplayState GetDisplayState(DisplayId displayId) = 0;
virtual bool TryToCancelScreenOff() = 0;
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() = 0;
virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) = 0;
virtual void NotifyDisplayEvent(DisplayEvent event) = 0;

View File

@ -0,0 +1,138 @@
/*
* 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_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H
#define FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H
namespace OHOS::Rosen {
enum class DisplayManagerMessage : unsigned int {
TRANS_ID_GET_DEFAULT_DISPLAY_INFO = 0,
TRANS_ID_GET_DISPLAY_BY_ID,
TRANS_ID_GET_DISPLAY_BY_SCREEN,
TRANS_ID_GET_DISPLAY_SNAPSHOT,
TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT,
TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT,
TRANS_ID_WAKE_UP_BEGIN,
TRANS_ID_WAKE_UP_END,
TRANS_ID_SUSPEND_BEGIN,
TRANS_ID_SUSPEND_END,
TRANS_ID_GET_INTERNAL_SCREEN_ID,
TRANS_ID_SET_SCREEN_POWER_BY_ID,
TRANS_ID_SET_SPECIFIED_SCREEN_POWER,
TRANS_ID_SET_SCREEN_POWER_FOR_ALL,
TRANS_ID_GET_SCREEN_POWER,
TRANS_ID_SET_DISPLAY_STATE,
TRANS_ID_GET_DISPLAY_STATE,
TRANS_ID_GET_ALL_DISPLAYIDS,
TRANS_ID_NOTIFY_DISPLAY_EVENT,
TRANS_ID_TRY_TO_CANCEL_SCREEN_OFF,
TRANS_ID_SET_SCREEN_BRIGHTNESS,
TRANS_ID_GET_SCREEN_BRIGHTNESS,
TRANS_ID_SET_FREEZE_EVENT,
TRANS_ID_SCREEN_BASE = 1000,
TRANS_ID_CREATE_VIRTUAL_SCREEN = TRANS_ID_SCREEN_BASE,
TRANS_ID_DESTROY_VIRTUAL_SCREEN,
TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE,
TRANS_ID_SET_VIRTUAL_SCREEN_CANVAS_ROTATION,
TRANS_ID_GET_SCREEN_INFO_BY_ID,
TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID,
TRANS_ID_SET_SCREEN_ACTIVE_MODE,
TRANS_ID_GET_ALL_SCREEN_INFOS,
TRANS_ID_SET_ORIENTATION,
TRANS_ID_SET_VIRTUAL_PIXEL_RATIO,
TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM,
TRANS_ID_SET_RESOLUTION,
TRANS_ID_GET_DENSITY_IN_CURRENT_RESOLUTION,
TRANS_ID_SCREENGROUP_BASE = 1100,
TRANS_ID_SCREEN_MAKE_MIRROR = TRANS_ID_SCREENGROUP_BASE,
TRANS_ID_MULTI_SCREEN_MODE_SWITCH,
TRANS_ID_SET_MULTI_SCREEN_POSITION,
TRANS_ID_SCREEN_MAKE_EXPAND,
TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP,
TRANS_ID_SCREEN_GAMUT_BASE = 1200,
TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS = TRANS_ID_SCREEN_GAMUT_BASE,
TRANS_ID_SCREEN_GET_COLOR_GAMUT,
TRANS_ID_SCREEN_SET_COLOR_GAMUT,
TRANS_ID_SCREEN_GET_GAMUT_MAP,
TRANS_ID_SCREEN_SET_GAMUT_MAP,
TRANS_ID_SCREEN_SET_COLOR_TRANSFORM,
TRANS_ID_SCREEN_GET_PIXEL_FORMAT,
TRANS_ID_SCREEN_SET_PIXEL_FORMAT,
TRANS_ID_SCREEN_GET_SUPPORTED_HDR_FORMAT,
TRANS_ID_SCREEN_GET_HDR_FORMAT,
TRANS_ID_SCREEN_SET_HDR_FORMAT,
TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_SPACE,
TRANS_ID_SCREEN_GET_COLOR_SPACE,
TRANS_ID_SCREEN_SET_COLOR_SPACE,
TRANS_ID_IS_SCREEN_ROTATION_LOCKED,
TRANS_ID_SET_SCREEN_ROTATION_LOCKED,
TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS,
TRANS_ID_HAS_PRIVATE_WINDOW,
TRANS_ID_GET_CUTOUT_INFO,
TRANS_ID_HAS_IMMERSIVE_WINDOW,
TRANS_ID_ADD_SURFACE_NODE,
TRANS_ID_REMOVE_SURFACE_NODE,
TRANS_ID_SCREEN_STOP_MIRROR,
TRANS_ID_SCREEN_STOP_EXPAND,
TRANS_ID_SCREEN_DISABLE_MIRROR,
TRANS_ID_SCENE_BOARD_SCREEN_BASE = 2000,
TRANS_ID_SCENE_BOARD_DUMP_ALL_SCREEN,
TRANS_ID_SCENE_BOARD_DUMP_SPECIAL_SCREEN,
TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE,
TRANS_ID_SET_FOLD_DISPLAY_MODE_FROM_JS,
TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE,
TRANS_ID_SCENE_BOARD_SET_DISPLAY_SCALE,
TRANS_ID_SCENE_BOARD_IS_FOLDABLE,
TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS,
TRANS_ID_SCENE_BOARD_GET_CURRENT_FOLD_CREASE_REGION,
TRANS_ID_SCENE_BOARD_MAKE_UNIQUE_SCREEN,
TRANS_ID_SCENE_BOARD_LOCK_FOLD_DISPLAY_STATUS,
TRANS_ID_SET_LOCK_FOLD_DISPLAY_STATUS_FROM_JS,
TRANS_ID_SET_CLIENT = 2500,
TRANS_ID_GET_SCREEN_PROPERTY,
TRANS_ID_GET_DISPLAY_NODE,
TRANS_ID_UPDATE_SCREEN_ROTATION_PROPERTY,
TRANS_ID_UPDATE_AVAILABLE_AREA,
TRANS_ID_SET_SCREEN_OFF_DELAY_TIME,
TRANS_ID_GET_CURVED_SCREEN_COMPRESSION_AREA,
TRANS_ID_GET_PHY_SCREEN_PROPERTY,
TRANS_ID_NOTIFY_DISPLAY_CHANGE_INFO,
TRANS_ID_SET_SCREEN_PRIVACY_STATE,
TRANS_ID_SET_SCREENID_PRIVACY_STATE,
TRANS_ID_SET_SCREEN_PRIVACY_WINDOW_LIST,
TRANS_ID_RESIZE_VIRTUAL_SCREEN,
TRANS_ID_GET_AVAILABLE_AREA,
TRANS_ID_NOTIFY_FOLD_TO_EXPAND_COMPLETION,
TRANS_ID_CONVERT_SCREENID_TO_RSSCREENID,
TRANS_ID_GET_VIRTUAL_SCREEN_FLAG,
TRANS_ID_SET_VIRTUAL_SCREEN_FLAG,
TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE,
TRANS_ID_GET_DEVICE_SCREEN_CONFIG,
TRANS_ID_SET_VIRTUAL_SCREEN_REFRESH_RATE,
TRANS_ID_DEVICE_IS_CAPTURE,
TRANS_ID_GET_SNAPSHOT_BY_PICKER,
TRANS_ID_SWITCH_USER,
TRANS_ID_SET_VIRTUAL_SCREEN_BLACK_LIST,
TRANS_ID_DISABLE_POWEROFF_RENDER_CONTROL,
TRANS_ID_PROXY_FOR_FREEZE,
TRANS_ID_RESET_ALL_FREEZE_STATUS,
TRANS_ID_NOTIFY_DISPLAY_HOOK_INFO,
TRANS_ID_GET_ALL_PHYSICAL_DISPLAY_RESOLUTION,
TRANS_ID_SET_VIRTUAL_SCREEN_STATUS,
TRANS_ID_SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION,
TRANS_ID_SET_VIRTUAL_SCREEN_MAX_REFRESHRATE,
};
}
#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H

View File

@ -91,6 +91,8 @@ public:
DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId, std::shared_ptr<RSSurfaceNode>& surfaceNode) override;
DisplayState GetDisplayState(DisplayId displayId) override;
bool TryToCancelScreenOff() override;
bool SetScreenBrightness(uint64_t screenId, uint32_t level) override;
uint32_t GetScreenBrightness(uint64_t screenId) override;
void NotifyDisplayEvent(DisplayEvent event) override;
bool SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze) override;

View File

@ -492,6 +492,19 @@ bool DisplayManagerService::TryToCancelScreenOff()
return false;
}
bool DisplayManagerService::SetScreenBrightness(uint64_t screenId, uint32_t level)
{
RSInterfaces::GetInstance().SetScreenBacklight(screenId, level);
return true;
}
uint32_t DisplayManagerService::GetScreenBrightness(uint64_t screenId)
{
uint32_t level = static_cast<uint32_t>(RSInterfaces::GetInstance().GetScreenBacklight(screenId));
TLOGI(WmsLogTag::DMS, "GetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level);
return level;
}
void DisplayManagerService::NotifyDisplayEvent(DisplayEvent event)
{
if (!Permission::IsSystemServiceCalling()) {

View File

@ -193,6 +193,17 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
reply.WriteUint32(static_cast<uint32_t>(state));
break;
}
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_BRIGHTNESS: {
uint64_t screenId = data.ReadUint64();
uint32_t level = data.ReadUint64();
reply.WriteBool(SetScreenBrightness(screenId, level));
break;
}
case DisplayManagerMessage::TRANS_ID_GET_SCREEN_BRIGHTNESS: {
uint64_t screenId = data.ReadUint64();
reply.WriteUint32(GetScreenBrightness(screenId));
break;
}
case DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT: {
DisplayEvent event = static_cast<DisplayEvent>(data.ReadUint32());
NotifyDisplayEvent(event);

View File

@ -76,7 +76,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest01, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO);
DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -96,7 +96,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest02, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID);
DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -116,7 +116,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest03, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN);
DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -136,7 +136,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest04, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN);
DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -156,7 +156,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest05, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN);
DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -176,7 +176,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest06, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE);
DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -196,7 +196,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest07, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_ORIENTATION);
DisplayManagerMessage::TRANS_ID_SET_ORIENTATION);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -216,7 +216,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest08, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT);
DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -236,7 +236,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest09, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT);
DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -256,7 +256,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest10, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT);
DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -276,7 +276,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest11, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN);
DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -296,7 +296,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest12, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_WAKE_UP_END);
DisplayManagerMessage::TRANS_ID_WAKE_UP_END);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -316,7 +316,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest13, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN);
DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -336,7 +336,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest14, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SUSPEND_END);
DisplayManagerMessage::TRANS_ID_SUSPEND_END);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -356,7 +356,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest15, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER);
DisplayManagerMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -376,7 +376,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest16, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL);
DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -396,7 +396,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest17, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER);
DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -416,7 +416,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest18, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE);
DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -436,7 +436,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest19, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE);
DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -456,7 +456,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest20, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT);
DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -476,7 +476,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest21, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_FREEZE_EVENT);
DisplayManagerMessage::TRANS_ID_SET_FREEZE_EVENT);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -496,7 +496,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest22, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR);
DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -516,7 +516,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest23, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID);
DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -536,7 +536,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest24, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID);
DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -556,7 +556,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest25, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS);
DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -576,7 +576,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest26, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS);
DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -596,7 +596,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest27, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND);
DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -616,7 +616,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest28, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP);
DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -636,7 +636,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest29, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE);
DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -656,7 +656,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest30, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO);
DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -676,7 +676,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest31, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS);
DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -696,7 +696,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest32, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT);
DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -716,7 +716,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest33, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT);
DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -736,7 +736,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest34, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP);
DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -756,7 +756,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest35, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP);
DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -776,7 +776,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest36, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM);
DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -796,7 +796,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest37, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED);
DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -816,7 +816,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest38, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED);
DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -836,7 +836,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest39, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS);
DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -856,7 +856,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest40, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_HAS_PRIVATE_WINDOW);
DisplayManagerMessage::TRANS_ID_HAS_PRIVATE_WINDOW);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -876,7 +876,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest41, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_CUTOUT_INFO);
DisplayManagerMessage::TRANS_ID_GET_CUTOUT_INFO);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -896,7 +896,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest42, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_ADD_SURFACE_NODE);
DisplayManagerMessage::TRANS_ID_ADD_SURFACE_NODE);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -916,7 +916,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest43, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_REMOVE_SURFACE_NODE);
DisplayManagerMessage::TRANS_ID_REMOVE_SURFACE_NODE);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -936,7 +936,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest44, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_STOP_MIRROR);
DisplayManagerMessage::TRANS_ID_SCREEN_STOP_MIRROR);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -956,7 +956,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest45, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_STOP_EXPAND);
DisplayManagerMessage::TRANS_ID_SCREEN_STOP_EXPAND);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -976,7 +976,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest46, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_RESIZE_VIRTUAL_SCREEN);
DisplayManagerMessage::TRANS_ID_RESIZE_VIRTUAL_SCREEN);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
@ -996,7 +996,7 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest47, Function | SmallTest | Level
data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor());
uint32_t code = static_cast<uint32_t>(
IDisplayManager::DisplayManagerMessage::TRANS_ID_SCENE_BOARD_MAKE_UNIQUE_SCREEN);
DisplayManagerMessage::TRANS_ID_SCENE_BOARD_MAKE_UNIQUE_SCREEN);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);

View File

@ -34,6 +34,7 @@ const static std::string DEFAULT_SCREEN_NAME = "buildIn";
constexpr int DOT_PER_INCH_MAXIMUM_VALUE = 1000;
constexpr int DOT_PER_INCH_MINIMUM_VALUE = 80;
constexpr uint32_t BASELINE_DENSITY = 160;
constexpr float INCH_TO_MM = 25.4f;
}
/**

View File

@ -192,6 +192,23 @@ public:
*/
bool SuspendEnd();
/**
* @brief Get id of internal screen.
*
* @return Internal screen id.
*/
ScreenId GetInternalScreenId();
/**
* @brief Set the screen power state by screen id.
*
* @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 SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason);
/**
* @brief Set the Display State object
*
@ -209,6 +226,14 @@ public:
*/
DisplayState GetDisplayState(DisplayId displayId);
/**
* @brief Try to cancel screenoff action before display power off.
*
* @return True means cancel screenoff action success.
* @return False means cancel screenoff action failed.
*/
bool TryToCancelScreenOff();
/**
* @brief Set the brightness level of the target screen.
*

View File

@ -23,11 +23,45 @@
namespace OHOS::Rosen {
class ScreenManagerLite : public RefBase {
WM_DECLARE_SINGLE_INSTANCE_BASE(ScreenManagerLite);
friend class DMSDeathRecipient;
friend class DMSDeathRecipientLite;
public:
/*
* used by powermgr
*/
class IScreenListener : public virtual RefBase {
public:
/**
* @brief Notify when a new screen is connected.
*/
virtual void OnConnect(ScreenId) = 0;
/**
* @brief Notify when a screen is disconnected.
*/
virtual void OnDisconnect(ScreenId) = 0;
/**
* @brief Notify when state of the screen is changed.
*/
virtual void OnChange(ScreenId) = 0;
};
/**
* @brief Register screen listener.
*
* @param listener IScreenListener.
* @return DM_OK means register success, others means register failed.
*/
DMError RegisterScreenListener(sptr<IScreenListener> listener);
/**
* @brief Unregister screen listener.
*
* @param listener IScreenListener.
* @return DM_OK means unregister success, others means unregister failed.
*/
DMError UnregisterScreenListener(sptr<IScreenListener> listener);
/**
* @brief Set the screen power state on the specified screen.
*
@ -58,6 +92,9 @@ private:
ScreenManagerLite();
~ScreenManagerLite();
void OnRemoteDied();
class Impl;
sptr<Impl> pImpl_;
};
} // namespace OHOS::Rosen

View File

@ -35,6 +35,10 @@ public:
virtual WMError HideNonSecureWindows(bool shouldHide) = 0;
virtual WMError SetWaterMarkFlag(bool isEnable) = 0;
virtual WMError HidePrivacyContentForHost(bool needHide) = 0;
virtual bool IsPcOrPadFreeMultiWindowMode() const = 0;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -754,7 +754,7 @@ public:
* @param isTopmost whether main window is topmost
* @return WMError
*/
virtual WMError SetMainWindowTopmost(bool isTopmost) { return WMError::WM_OK; }
virtual WMError SetMainWindowTopmost(bool isTopmost) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
/**
* @brief Get whether main window is topmost
*
@ -1743,6 +1743,13 @@ public:
*/
virtual bool IsPcOrPadCapabilityEnabled() const { return false; }
/**
* @brief Is pc window or pad free multi-window.
*
* @return True means pc window or pad free multi-window, false means the opposite.
*/
virtual bool IsPcOrPadFreeMultiWindowMode() const { return false; }
/**
* @brief Register transfer component data callback.
*
@ -2069,6 +2076,17 @@ public:
return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
}
/**
* @brief Hide the display content when snapshot.
*
* @param needHide bool.
* @return WMError
*/
virtual WMError HidePrivacyContentForHost(bool needHide)
{
return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
}
/**
* @brief Set the modality of window.
*
@ -2363,18 +2381,18 @@ public:
virtual void NotifyExtensionEventAsync(uint32_t notifyEvent) {}
/**
* @brief Get IsUIExtensionFlag of window.
* @brief Get isUIExtFirstSubWindow flag
*
* @return true - is UIExtension window, flase - is not UIEXtension window.
* @return true - is the first sub window of UIExtension, false - is not the first sub window of UIExtension
*/
virtual bool GetIsUIExtensionFlag() const { return false; }
virtual bool GetIsUIExtFirstSubWindow() const { return false; }
/**
* @brief Get IsUIExtensionSubWindowFlag of window.
* @brief Get whether this window is a sub window of any level of UIExtension.
*
* @return true - is UIExtension sub window, false - is not UIExtension sub window.
*/
virtual bool GetIsUIExtensionSubWindowFlag() const { return false; }
virtual bool GetIsUIExtAnySubWindow() const { return false; }
/**
* @brief Set whether to enable gesture back.

View File

@ -231,11 +231,11 @@ public:
void SetOnlySupportSceneBoard(bool onlySupportSceneBoard);
/**
* @brief Set ExtensionSubWindow tag.
* @brief Set whether this window is the first sub window of UIExtension.
*
* @param isExtensionTag ExtensionSubWindow tag.
* @param isUIExtFirstSubWindow whether is the first sub window of UIExtension.
*/
void SetExtensionTag(bool isExtensionTag);
void SetIsUIExtFirstSubWindow(bool isUIExtFirstSubWindow);
/**
* @brief Set UIExtension usage.
@ -427,11 +427,11 @@ public:
bool GetOnlySupportSceneBoard() const;
/**
* @brief Get only sceneboard supported
* @brief Get isUIExtFirstSubWindow flag
*
* @return Return ExtensionTag of subwindow.
* @return true - is the first sub window of UIExtension, false - is not the first sub window of UIExtension
*/
bool GetExtensionTag() const;
bool GetIsUIExtFirstSubWindow() const;
/**
* @brief Get UIExtension usage.
@ -476,17 +476,20 @@ public:
virtual WindowType GetParentWindowType() const;
/**
* @brief Set whether this window is a sub window of the UIExtension.
* @brief Set whether this window is a sub window of any level of UIExtension.
*
* @return isUIExtensionSubWindowFlag.
* @param isUIExtAnySubWindow true - is any sub window of UIExtension,
* false - is not any sub window of UIExtension.
*/
void SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag);
void SetIsUIExtAnySubWindow(bool isUIExtAnySubWindow);
/**
* @brief Get IsUIExtensionSubWindowFlag of window.
* @brief Get whether this window is a sub window of any level of UIExtension.
*
* @return true - is UIExtension sub window, false - is not UIExtension sub window.
* @return true - is a sub window of any level of UIExtension,
* false - is not a sub window of any level of UIExtension.
*/
bool GetIsUIExtensionSubWindowFlag() const;
bool GetIsUIExtAnySubWindow() const;
private:
Rect windowRect_ { 0, 0, 0, 0 };
@ -524,8 +527,8 @@ private:
*/
int32_t realParentId_ = INVALID_WINDOW_ID;
uint32_t uiExtensionUsage_ = static_cast<uint32_t>(UIExtensionUsage::EMBEDDED);
bool isExtensionTag_ = false;
bool isUIExtensionSubWindowFlag_ = false;
bool isUIExtFirstSubWindow_ = false;
bool isUIExtAnySubWindow_ = false;
WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
};
} // namespace Rosen

View File

@ -67,7 +67,6 @@ ohos_static_library("wm_napi_util") {
"hilog:libhilog",
"ipc:ipc_single",
"napi:ace_napi",
"node:node_header_notice",
]
subsystem_name = "window"

View File

@ -242,38 +242,68 @@ napi_value OnGetAllDisplay(napi_env env, napi_callback_info info)
DMError errCode = DMError::DM_OK;
size_t argc = 4;
napi_value argv[4] = {nullptr};
std::string taskName = "OnGetAllDisplay";
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc != 0 && argc != ARGC_ONE) {
WLOGFE("OnGetAllDisplay params not match");
errCode = DMError::DM_ERROR_INVALID_PARAM;
return NapiGetUndefined(env);
}
NapiAsyncTask::CompleteCallback complete =
[=](napi_env env, NapiAsyncTask& task, int32_t status) {
if (errCode != DMError::DM_OK) {
task.Reject(env, CreateJsError(env,
static_cast<int32_t>(errCode), "JsDisplayManager::OnGetAllDisplay failed."));
}
std::vector<sptr<Display>> displays = SingletonContainer::Get<DisplayManager>().GetAllDisplays();
if (!displays.empty()) {
task.Resolve(env, CreateJsDisplayArrayObject(env, displays));
WLOGI("GetAllDisplays success");
} else {
task.Reject(env, CreateJsError(env,
static_cast<int32_t>(DMError::DM_ERROR_NULLPTR), "JsDisplayManager::OnGetAllDisplay failed."));
}
};
napi_value lastParam = nullptr;
if (argc == ARGC_ONE && GetType(env, argv[0]) == napi_function) {
lastParam = argv[0];
}
napi_value result = nullptr;
NapiAsyncTask::Schedule("JsDisplayManager::OnGetAllDisplay",
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
std::unique_ptr<NapiAsyncTask> napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result);
auto asyncTask = [this, env, task = napiAsyncTask.get()]() {
std::vector<sptr<Display>> displays = SingletonContainer::Get<DisplayManager>().GetAllDisplays();
if (!displays.empty()) {
task->Resolve(env, CreateJsDisplayArrayObject(env, displays));
WLOGI("GetAllDisplays success");
} else {
task->Reject(env, CreateJsError(env,
static_cast<int32_t>(DMError::DM_ERROR_NULLPTR), "JsDisplayManager::OnGetAllDisplay failed."));
}
delete task;
};
NapiSendDmsEvent(env, asyncTask, napiAsyncTask, taskName);
return result;
}
void NapiSendDmsEvent(napi_env env, std::function<void()> asyncTask,
std::unique_ptr<AbilityRuntime::NapiAsyncTask>& napiAsyncTask, std::string taskName)
{
if (!env) {
WLOGFE("env is null");
return;
}
if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) {
napiAsyncTask->Reject(env, CreateJsError(env,
static_cast<int32_t>(DmErrorCode::DM_ERROR_INVALID_SCREEN), "Send event failed!"));
} else {
napiAsyncTask.release();
WLOGFI("%{public}s:send event success", taskName.c_str());
}
}
std::unique_ptr<NapiAsyncTask> CreateEmptyAsyncTask(napi_env env, napi_value lastParam, napi_value* result)
{
napi_valuetype type = napi_undefined;
napi_typeof(env, lastParam, &type);
if (lastParam == nullptr || type != napi_function) {
napi_deferred nativeDeferred = nullptr;
napi_create_promise(env, &nativeDeferred, result);
return std::make_unique<NapiAsyncTask>(nativeDeferred, std::unique_ptr<NapiAsyncTask::ExecuteCallback>(),
std::unique_ptr<NapiAsyncTask::CompleteCallback>());
} else {
napi_get_undefined(env, result);
napi_ref callbackRef = nullptr;
napi_create_reference(env, lastParam, 1, &callbackRef);
return std::make_unique<NapiAsyncTask>(callbackRef, std::unique_ptr<NapiAsyncTask::ExecuteCallback>(),
std::unique_ptr<NapiAsyncTask::CompleteCallback>());
}
}
napi_value CreateJsDisplayPhysicalArrayObject(napi_env env,
const std::vector<DisplayPhysicalResolution>& physicalArray)
{
@ -315,7 +345,7 @@ napi_value OnGetAllDisplayPhysicalResolution(napi_env env, napi_callback_info in
task.Resolve(env, CreateJsDisplayPhysicalArrayObject(env, displayPhysicalArray));
WLOGI("OnGetAllDisplayPhysicalResolution success");
} else {
task.Reject(env, CreateJsError(env, static_cast<int32_t>(DMError::DM_ERROR_NULLPTR),
task.Reject(env, CreateJsError(env, static_cast<int32_t>(DmErrorCode::DM_ERROR_SYSTEM_INNORMAL),
"JsDisplayManager::OnGetAllDisplayPhysicalResolution failed."));
}
};

View File

@ -48,6 +48,10 @@ class ExtensionWindow {
setWaterMarkFlag(type, callback) {
return this.__extension_window__.setWaterMarkFlag(type, callback);
}
hidePrivacyContentForHost(type, callback) {
return this.__extension_window__.hidePrivacyContentForHost(type, callback);
}
}
export default ExtensionWindow;

View File

@ -76,6 +76,8 @@ napi_value JsExtensionWindow::CreateJsExtensionWindow(napi_env env, sptr<Rosen::
BindNativeFunction(env, objValue, "createSubWindowWithOptions", moduleName,
JsExtensionWindow::CreateSubWindowWithOptions);
BindNativeFunction(env, objValue, "setWaterMarkFlag", moduleName, JsExtensionWindow::SetWaterMarkFlag);
BindNativeFunction(env, objValue, "hidePrivacyContentForHost", moduleName,
JsExtensionWindow::HidePrivacyContentForHost);
return objValue;
}
@ -172,6 +174,13 @@ napi_value JsExtensionWindow::SetWaterMarkFlag(napi_env env, napi_callback_info
return (me != nullptr) ? me->OnSetWaterMarkFlag(env, info) : nullptr;
}
napi_value JsExtensionWindow::HidePrivacyContentForHost(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_UIEXT, "enter");
JsExtensionWindow* me = CheckParamsAndGetThis<JsExtensionWindow>(env, info);
return (me != nullptr) ? me->OnHidePrivacyContentForHost(env, info) : nullptr;
}
napi_value JsExtensionWindow::LoadContent(napi_env env, napi_callback_info info)
{
TLOGI(WmsLogTag::WMS_UIEXT, "LoadContent is called");
@ -837,6 +846,44 @@ napi_value JsExtensionWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_inf
return NapiGetUndefined(env);
}
napi_value JsExtensionWindow::OnHidePrivacyContentForHost(napi_env env, napi_callback_info info)
{
if (extensionWindow_ == nullptr) {
TLOGE(WmsLogTag::WMS_UIEXT, "extension window is nullptr");
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
}
sptr<Window> windowImpl = extensionWindow_->GetWindow();
if (windowImpl == nullptr) {
TLOGE(WmsLogTag::WMS_UIEXT, "windowImpl is nullptr");
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
}
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < 1) {
TLOGE(WmsLogTag::WMS_UIEXT, "Argc is invalid: %{public}zu", argc);
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
bool needHide = false;
if (!ConvertFromJsValue(env, argv[0], needHide)) {
TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to bool");
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
auto ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->HidePrivacyContentForHost(needHide));
if (ret != WmErrorCode::WM_OK) {
return NapiThrowError(env, ret);
}
TLOGI(WmsLogTag::WMS_UIEXT, "finished, window [%{public}u, %{public}s], needHide:%{public}u.",
windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), needHide);
return NapiGetUndefined(env);
}
napi_value JsExtensionWindow::GetProperties(napi_env env, napi_callback_info info)
{
TLOGI(WmsLogTag::WMS_UIEXT, "GetProperties is called");
@ -855,6 +902,11 @@ napi_value JsExtensionWindow::GetProperties(napi_env env, napi_callback_info inf
napi_value JsExtensionWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_info info)
{
if (extensionWindow_ == nullptr) {
TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]extensionWindow is null");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)));
return NapiGetUndefined(env);
}
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
@ -870,6 +922,12 @@ napi_value JsExtensionWindow::OnCreateSubWindowWithOptions(napi_env env, napi_ca
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_INVALID_PARAM)));
return NapiGetUndefined(env);
}
if ((option->GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_IS_APPLICATION_MODAL)) &&
!extensionWindow_->IsPcOrPadFreeMultiWindowMode()) {
TLOGE(WmsLogTag::WMS_SUB, "device not support");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT)));
return NapiGetUndefined(env);
}
if (option->GetWindowTopmost() && !Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
TLOGE(WmsLogTag::WMS_SUB, "Modal subwindow has topmost, but no system permission");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WmErrorCode::WM_ERROR_NOT_SYSTEM_APP)));
@ -880,19 +938,16 @@ napi_value JsExtensionWindow::OnCreateSubWindowWithOptions(napi_env env, napi_ca
NapiAsyncTask::CompleteCallback complete =
[where, extensionWindow = extensionWindow_, windowName = std::move(windowName),
windowOption = option](napi_env env, NapiAsyncTask& task, int32_t status) mutable {
if (extensionWindow == nullptr) {
task.Reject(env, CreateJsError(env,
static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "extensionWindow is null"));
}
windowOption->SetWindowType(Rosen::WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
windowOption->SetWindowMode(Rosen::WindowMode::WINDOW_MODE_FLOATING);
windowOption->SetOnlySupportSceneBoard(true);
windowOption->SetExtensionTag(true);
auto extWindow = extensionWindow->GetWindow();
if (extWindow == nullptr) {
task.Reject(env, CreateJsError(env,
static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "extension's window is null"));
return;
}
windowOption->SetWindowType(Rosen::WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
windowOption->SetWindowMode(Rosen::WindowMode::WINDOW_MODE_FLOATING);
windowOption->SetOnlySupportSceneBoard(true);
windowOption->SetIsUIExtFirstSubWindow(true);
auto window = Window::Create(windowName, windowOption, extWindow->GetContext());
if (window == nullptr) {
task.Reject(env, CreateJsError(env,

View File

@ -59,6 +59,8 @@ public:
static napi_value SetWindowKeepScreenOn(napi_env env, napi_callback_info info);
static napi_value CreateSubWindowWithOptions(napi_env env, napi_callback_info info);
static napi_value SetWaterMarkFlag(napi_env env, napi_callback_info info);
static napi_value HidePrivacyContentForHost(napi_env env, napi_callback_info info);
private:
napi_value OnGetWindowAvoidArea(napi_env env, napi_callback_info info);
napi_value OnRegisterExtensionWindowCallback(napi_env env, napi_callback_info info);
@ -80,6 +82,7 @@ private:
napi_value OnSetWindowBrightness(napi_env env, napi_callback_info info);
napi_value OnSetWindowKeepScreenOn(napi_env env, napi_callback_info info);
napi_value OnSetWaterMarkFlag(napi_env env, napi_callback_info info);
napi_value OnHidePrivacyContentForHost(napi_env env, napi_callback_info info);
napi_value OnCreateSubWindowWithOptions(napi_env env, napi_callback_info info);

View File

@ -219,8 +219,8 @@ napi_value JsPipWindowManager::CreatePipController(napi_env env, napi_callback_i
napi_value JsPipWindowManager::NapiSendTask(napi_env env, PipOption& pipOption)
{
napi_value result = nullptr;
std::unique_ptr<NapiAsyncTask> napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result);
auto asyncTask = [this, env, task = napiAsyncTask.get(), pipOption]() {
std::shared_ptr<NapiAsyncTask> napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result);
auto asyncTask = [this, env, task = napiAsyncTask, pipOption]() {
if (!PictureInPictureManager::IsSupportPiP()) {
task->Reject(env, CreateJsError(env, static_cast<int32_t>(
WMError::WM_ERROR_DEVICE_NOT_SUPPORT), "device not support pip."));
@ -242,13 +242,10 @@ napi_value JsPipWindowManager::NapiSendTask(napi_env env, PipOption& pipOption)
sptr<PictureInPictureController> pipController =
new PictureInPictureController(pipOptionPtr, mainWindow, mainWindow->GetWindowId(), env);
task->Resolve(env, CreateJsPipControllerObject(env, pipController));
delete task;
};
if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) {
napiAsyncTask->Reject(env, CreateJsError(env,
static_cast<int32_t>(WMError::WM_ERROR_PIP_INTERNAL_ERROR), "Send event failed"));
} else {
napiAsyncTask.release();
}
return result;
}

View File

@ -1379,20 +1379,20 @@ napi_value JsWindow::OnRecover(napi_env env, napi_callback_info info)
napi_value JsWindow::OnRestore(napi_env env, napi_callback_info info)
{
NapiAsyncTask::CompleteCallback complete =
[weakToken = windowToken_](napi_env env, NapiAsyncTask& task, int32_t status) {
if (weakToken == nullptr) {
[windowToken = windowToken_](napi_env env, NapiAsyncTask& task, int32_t status) {
if (windowToken == nullptr) {
TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param");
task.Reject(env,
JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY));
return;
}
if (!WindowHelper::IsMainWindow(weakToken->GetType())) {
if (!WindowHelper::IsMainWindow(windowToken->GetType())) {
TLOGNE(WmsLogTag::WMS_LIFE, "Restore fail, not main window");
task.Reject(env,
JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_CALLING));
return ;
}
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakToken->Restore());
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken->Restore());
if (ret == WmErrorCode::WM_OK) {
task.Resolve(env, NapiGetUndefined(env));
} else {
@ -3697,6 +3697,10 @@ napi_value JsWindow::OnSetWindowTopmost(napi_env env, napi_callback_info info)
TLOGE(WmsLogTag::WMS_HIERARCHY, "windowToken is nullptr");
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
}
if (!windowToken_->IsPcOrPadFreeMultiWindowMode()) {
TLOGE(WmsLogTag::WMS_HIERARCHY, "[NAPI]device not support");
return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT);
}
if (!WindowHelper::IsMainWindow(windowToken_->GetType())) {
TLOGE(WmsLogTag::WMS_HIERARCHY, "[NAPI]not allowed since window is not main window");
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING);
@ -6668,14 +6672,14 @@ static void SetRequestFocusTask(NapiAsyncTask::ExecuteCallback& execute, NapiAsy
if (*errCodePtr != WmErrorCode::WM_OK) {
return;
}
auto weakWindow = weakToken.promote();
if (weakWindow == nullptr) {
auto window = weakToken.promote();
if (window == nullptr) {
*errCodePtr = WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
return;
}
*errCodePtr = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->RequestFocusByClient(isFocused));
TLOGI(WmsLogTag::WMS_FOCUS, "Window [%{public}u, %{public}s] request focus end, err = %{public}d",
weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), *errCodePtr);
*errCodePtr = WM_JS_TO_ERROR_CODE_MAP.at(window->RequestFocusByClient(isFocused));
TLOGNI(WmsLogTag::WMS_FOCUS, "Window [%{public}u, %{public}s] request focus end, err = %{public}d",
window->GetWindowId(), window->GetWindowName().c_str(), *errCodePtr);
};
complete = [weakToken, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) {
if (errCodePtr == nullptr) {
@ -6825,6 +6829,12 @@ static void CreateNewSubWindowTask(const sptr<Window>& windowToken, const std::s
static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "window is null"));
return;
}
if (windowOption == nullptr) {
TLOGE(WmsLogTag::WMS_SUB, "windowOption is null");
task.Reject(env, CreateJsError(env,
static_cast<int32_t>(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "windowOption is null"));
return;
}
if (!WindowHelper::IsSubWindow(windowToken->GetType()) &&
!WindowHelper::IsMainWindow(windowToken->GetType())) {
TLOGE(WmsLogTag::WMS_SUB, "This is not subWindow or mainWindow.");
@ -6873,16 +6883,17 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in
return NapiGetUndefined(env);
}
sptr<WindowOption> windowOption = new WindowOption();
if (windowOption == nullptr) {
TLOGE(WmsLogTag::WMS_SUB, "window option is null");
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY));
return NapiGetUndefined(env);
}
if (!ParseSubWindowOptions(env, argv[1], windowOption)) {
TLOGE(WmsLogTag::WMS_SUB, "Failed to convert parameter to options");
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_PARAM));
return NapiGetUndefined(env);
}
if ((windowOption->GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_IS_APPLICATION_MODAL)) &&
!windowToken_->IsPcOrPadFreeMultiWindowMode()) {
TLOGE(WmsLogTag::WMS_SUB, "device not support");
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT));
return NapiGetUndefined(env);
}
if (windowOption->GetWindowTopmost() && !Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
TLOGE(WmsLogTag::WMS_SUB, "Modal subwindow has topmost, but no system permission");
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP));

View File

@ -672,7 +672,11 @@ bool ParseAndCheckRect(napi_env env, napi_value jsObject,
(touchableRect.posY_ > static_cast<int32_t>(windowRect.height_)) ||
(touchableRect.width_ > (windowRect.width_ - static_cast<uint32_t>(touchableRect.posX_))) ||
(touchableRect.height_ > (windowRect.height_ - static_cast<uint32_t>(touchableRect.posY_)))) {
TLOGE(WmsLogTag::WMS_EVENT, "Outside the window area");
TLOGE(WmsLogTag::WMS_EVENT, "Outside the window area, "
"touchRect:[%{public}d %{public}d %{public}u %{public}u], "
"windowRect:[%{public}d %{public}d %{public}u %{public}u]",
touchableRect.posX_, touchableRect.posY_, touchableRect.width_, touchableRect.height_,
windowRect.posX_, windowRect.posY_, windowRect.width_, windowRect.height_);
return false;
}
return true;

View File

@ -632,10 +632,16 @@ napi_value JsWindowStage::OnSetDefaultDensityEnabled(napi_env env, napi_callback
napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callback_info info)
{
std::string windowName;
auto windowScene = windowScene_.lock();
if (windowScene == nullptr) {
TLOGE(WmsLogTag::WMS_SUB, "WindowScene is null");
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY));
return NapiGetUndefined(env);
}
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
std::string windowName;
if (!ConvertFromJsValue(env, argv[0], windowName)) {
WLOGFE("[NAPI]Failed to convert parameter to windowName");
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_PARAM));
@ -647,6 +653,12 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_PARAM));
return NapiGetUndefined(env);
}
if ((option->GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_IS_APPLICATION_MODAL)) &&
!windowScene->GetMainWindow()->IsPcOrPadFreeMultiWindowMode()) {
TLOGE(WmsLogTag::WMS_SUB, "device not support");
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT));
return NapiGetUndefined(env);
}
if (option->GetWindowTopmost() && !Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
TLOGE(WmsLogTag::WMS_SUB, "Modal subwindow has topmost, but no system permission");
@ -656,14 +668,8 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba
const char* const where = __func__;
NapiAsyncTask::CompleteCallback complete =
[where, weak = windowScene_, windowName = std::move(windowName), option]
[where, windowScene, windowName = std::move(windowName), option]
(napi_env env, NapiAsyncTask& task, int32_t status) mutable {
auto windowScene = weak.lock();
if (windowScene == nullptr) {
TLOGNE(WmsLogTag::WMS_SUB, "%{public}s [NAPI]Window scene is null", where);
task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY));
return;
}
option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
option->SetOnlySupportSceneBoard(true);

View File

@ -308,6 +308,7 @@ public:
virtual WMError HideNonSystemFloatingWindows(bool shouldHide) = 0;
virtual bool IsFloatingWindowAppType() const { return false; }
virtual bool IsPcOrPadCapabilityEnabled() const { return false; }
virtual bool IsPcOrPadFreeMultiWindowMode() const { return false; }
virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag) = 0;
virtual WMError RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0;
virtual WMError UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0;

View File

@ -393,17 +393,20 @@ public:
bool GetWindowTopmost() const;
/**
* @brief Set whether this window is a sub window of the UIExtension.
* @brief Set whether this window is a sub window of any level of UIExtension.
*
* @return isUIExtensionSubWindowFlag.
* @param isUIExtAnySubWindow true - is any sub window of UIExtension,
* false - is not any sub window of UIExtension.
*/
void SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag);
void SetIsUIExtAnySubWindow(bool isUIExtAnySubWindow);
/**
* @brief Get IsUIExtensionSubWindowFlag of window.
* @brief Get whether this window is a sub window of any level of UIExtension.
*
* @return true - is UIExtension sub window, false - is not UIExtension sub window.
* @return true - is a sub window of any level of UIExtension,
* false - is not a sub window of any level of UIExtension.
*/
bool GetIsUIExtensionSubWindowFlag() const;
bool GetIsUIExtAnySubWindow() const;
private:
Rect windowRect_ { 0, 0, 0, 0 };

View File

@ -55,6 +55,12 @@ public:
MOCK_METHOD2(DispatchKeyEvent, void(uint32_t windowId, std::shared_ptr<MMI::KeyEvent> event));
MOCK_METHOD0(GetMaximizeMode, MaximizeMode());
MOCK_METHOD1(GetWindowModeType, WMError(WindowModeType& windowModeType));
MOCK_METHOD6(RecoverAndReconnectSceneSession, WMError(const sptr<ISessionStage>& sessionStage,
const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
sptr<ISession>& session, sptr<WindowSessionProperty> property, sptr<IRemoteObject> token));
MOCK_METHOD6(RecoverAndConnectSpecificSession, void(const sptr<ISessionStage>& sessionStage,
const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token));
};
}
} // namespace OHOS

View File

@ -32,7 +32,7 @@ const int SLEEP_US = 10 * 1000; // 10ms
const int MAX_SNAPSHOT_COUNT = 10;
const int MAX_WAIT_COUNT = 200;
const float DEFAULT_DENSITY = 2.0;
const std::string FILE_NAME = "/data/snapshot_virtual_screen";
const std::string FILE_NAME = "/data/local/tmp/snapshot_virtual_screen";
}
static ScreenId mainId;

View File

@ -86,53 +86,53 @@ bool IPCFuzzTest(const uint8_t* data, size_t size)
void IPCSpecificInterfaceFuzzTest1(sptr<IRemoteObject> proxy, MessageParcel& sendData, MessageParcel& reply,
MessageOption& option)
{
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT),
sendData, reply, option);
proxy->SendRequest(
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT),
sendData, reply, option);
proxy->SendRequest(
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_WAKE_UP_END),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_WAKE_UP_END),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SUSPEND_END),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SUSPEND_END),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_FREEZE_EVENT),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_FREEZE_EVENT),
sendData, reply, option);
}
@ -141,48 +141,48 @@ void IPCSpecificInterfaceFuzzTest2(sptr<IRemoteObject> proxy, MessageParcel& sen
{
int flags = option.GetFlags();
option.SetFlags(MessageOption::TF_SYNC);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN),
sendData, reply, option);
manager->DestroyVirtualScreen(static_cast<ScreenId>(reply.ReadUint64()));
option.SetFlags(flags);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN),
sendData, reply, option);
proxy->SendRequest(
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID),
sendData, reply, option);
proxy->SendRequest(
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_ORIENTATION),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_ORIENTATION),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND),
sendData, reply, option);
proxy->SendRequest(
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP),
sendData, reply, option);
proxy->SendRequest(
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP),
sendData, reply, option);
proxy->SendRequest(static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP),
proxy->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP),
sendData, reply, option);
proxy->SendRequest(
static_cast<uint32_t>(IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM),
sendData, reply, option);
}

View File

@ -30,7 +30,7 @@ namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "ScreenSessionManagerFuzzTest"};
}
using DMMessage = IScreenSessionManager::DisplayManagerMessage;
using DMMessage = DisplayManagerMessage;
std::pair<sptr<IScreenSessionManager>, sptr<IRemoteObject>> GetProxy()
{

View File

@ -49,12 +49,12 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.RewindRead(0);
std::shared_ptr<ScreenSessionManagerStub> screenStub = std::make_shared<ScreenSessionManagerStub>();
screenStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IDisplayManager::DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT),
parcel, reply, option);
parcel.RewindRead(0);
screenStub->OnRemoteRequest(
static_cast<uint32_t>(
Rosen::IDisplayManager::DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT),
DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT),
parcel, reply, option);
return true;
}

View File

@ -49,7 +49,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
std::shared_ptr<ScreenSessionManagerStub> screenStub = std::make_shared<ScreenSessionManagerStub>();
screenStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE),
parcel, reply, option);
return true;
}

View File

@ -49,11 +49,11 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.RewindRead(0);
std::shared_ptr<ScreenSessionManagerStub> screenStub = std::make_shared<ScreenSessionManagerStub>();
screenStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IDisplayManager::DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN),
parcel, reply, option);
parcel.RewindRead(0);
screenStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IDisplayManager::DisplayManagerMessage::TRANS_ID_WAKE_UP_END),
static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_WAKE_UP_END),
parcel, reply, option);
return true;
}

View File

@ -39,6 +39,7 @@ group("systemtest") {
":wms_window_nointeraction_listener_test",
":wms_window_occupied_area_change_test",
":wms_window_raisetoapptop_test",
":wms_window_recover_test",
":wms_window_rotation_test",
":wms_window_split_immersive_test",
":wms_window_split_test",
@ -379,6 +380,33 @@ ohos_systemtest("wms_window_rotation_test") {
]
}
ohos_systemtest("wms_window_recover_test") {
module_out_path = module_out_path
sources = [ "window_recover_test.cpp" ]
include_dirs = [
"${window_base_path}/test/common/mock",
"${window_base_path}/window_scene/test/mock",
"${window_base_path}/window_scene/session/host/include/zidl",
"${window_base_path}/window_scene/common/include",
]
deps = [
":wms_systemtest_common",
"${window_base_path}/window_scene/common:window_scene_common",
"${window_base_path}/window_scene/session:scene_session",
]
external_deps = [
"ability_runtime:app_context",
"accessibility:accessibility_common",
"c_utils:utils",
"hilog:libhilog",
"init:libbegetutil",
]
}
ohos_systemtest("wms_window_occupied_area_change_test") {
module_out_path = module_out_path

View File

@ -48,13 +48,14 @@ void WindowMultiAbilityTest::TearDown()
{
}
static void DoSceneResource(sptr<WindowScene> windowscene){
static void DoSceneResource(sptr<WindowScene> windowscene)
{
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
ASSERT_EQ(WMError::WM_OK, windowscene->GoBackground());
ASSERT_EQ(WMError::WM_OK, windowscene->GoDestroy());
}else {
ASSERT_NE(WMError::WM_OK, windowscene->GoBackground());
ASSERT_NE(WMError::WM_OK, windowscene->GoDestroy());
} else {
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowscene->GoBackground());
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowscene->GoDestroy());
}
}
@ -216,18 +217,10 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow2, Function | MediumTest | Le
HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow03, Function | MediumTest | Level3)
{
sptr<WindowScene> scene1 = Utils::CreateWindowScene();
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
ASSERT_EQ(WMError::WM_OK, scene1->GoForeground());
} else {
ASSERT_NE(WMError::WM_OK, scene1->GoForeground());
}
ASSERT_EQ(WMError::WM_OK, scene1->GoForeground());
sptr<WindowScene> scene2 = Utils::CreateWindowScene();
sptr<WindowScene> scene3 = Utils::CreateWindowScene();
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
ASSERT_EQ(WMError::WM_OK, scene3->GoForeground());
} else {
ASSERT_NE(WMError::WM_OK, scene3->GoForeground());
}
ASSERT_EQ(WMError::WM_OK, scene3->GoForeground());
DoSceneResource(scene1);
sptr<WindowScene> scene4 = Utils::CreateWindowScene();
if (!SceneBoardJudgement::IsSceneBoardEnabled()) {

View File

@ -0,0 +1,157 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// gtest
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "window_test_utils.h"
#include "ability_context_impl.h"
#include "context_impl.h"
#include "iremote_object_mocker.h"
#include "mock_session.h"
#include "mock_window_adapter.h"
#include "window_session_impl.h"
#include "window_scene_session_impl.h"
#include "singleton_mocker.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
using Mocker = SingletonMocker<WindowAdapter, MockWindowAdapter>;
using Utils = WindowTestUtils;
class WindowRecoverTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
};
void WindowRecoverTest::SetUpTestCase() {}
void WindowRecoverTest::TearDownTestCase() {}
void WindowRecoverTest::SetUp() {}
void WindowRecoverTest::TearDown() {}
namespace {
/**
* @tc.name: RecoverAndReconnectSceneSession
* @tc.desc: RecoverAndReconnectSceneSession
* @tc.type: FUNC
*/
HWTEST_F(WindowRecoverTest, RecoverAndReconnectSceneSession, Function | SmallTest | Level2)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
ASSERT_NE(nullptr, option);
option->SetWindowName("RecoverAndReconnectSceneSession");
sptr<WindowSceneSessionImpl> windowSceneSession = new (std::nothrow) WindowSceneSessionImpl(option);
ASSERT_NE(nullptr, windowSceneSession);
windowSceneSession->property_->SetPersistentId(1112);
windowSceneSession->property_->SetParentId(1000);
windowSceneSession->property_->SetParentPersistentId(1000);
windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
std::shared_ptr<AbilityRuntime::AbilityContextImpl> context =
std::make_shared<AbilityRuntime::AbilityContextImpl>();
ASSERT_NE(nullptr, context);
SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
context->SetAbilityInfo(abilityInfo);
sptr<IRemoteObject> sessionToken = new (std::nothrow) IRemoteObjectMocker();
ASSERT_NE(nullptr, sessionToken);
context->SetToken(sessionToken);
std::shared_ptr<AppExecFwk::ApplicationInfo> applicationInfo = std::make_shared<AppExecFwk::ApplicationInfo>();
ASSERT_NE(nullptr, applicationInfo);
applicationInfo->apiCompatibleVersion = 12;
auto stageContent = std::make_shared<AbilityRuntime::ContextImpl>();
ASSERT_NE(nullptr, stageContent);
stageContent->SetApplicationInfo(applicationInfo);
stageContent->InitHapModuleInfo(abilityInfo);
context->stageContext_ = stageContent;
struct RSSurfaceNodeConfig config;
std::shared_ptr<RSSurfaceNode> windowSceneSessionSurfaceNode = RSSurfaceNode::Create(config);
windowSceneSession->surfaceNode_ = windowSceneSessionSurfaceNode;
ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(context, session));
std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
sptr<WindowSessionProperty> property = nullptr;
sptr<IRemoteObject> token = nullptr;
EXPECT_CALL(m->Mock(), RecoverAndReconnectSceneSession(_, _, _, _, _, _)).WillOnce(DoAll(
SaveArg<2>(&surfaceNode), SaveArg<4>(&property), SaveArg<5>(&token), Return(WMError::WM_OK)
));
windowSceneSession->RecoverAndReconnectSceneSession();
ASSERT_EQ(surfaceNode, windowSceneSession->surfaceNode_);
ASSERT_EQ(property, windowSceneSession->property_);
ASSERT_EQ(token, sessionToken);
windowSceneSession->Destroy(false, false);
}
/**
* @tc.name: RecoverAndConnectSpecificSession
* @tc.desc: RecoverAndConnectSpecificSession
* @tc.type: FUNC
*/
HWTEST_F(WindowRecoverTest, RecoverAndConnectSpecificSession, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
ASSERT_NE(nullptr, option);
option->SetWindowName("RecoverAndConnectSpecificSession");
sptr<WindowSceneSessionImpl> windowSceneSession = new (std::nothrow) WindowSceneSessionImpl(option);
ASSERT_NE(nullptr, windowSceneSession);
windowSceneSession->property_->SetPersistentId(1112);
windowSceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
windowSceneSession->property_->SetIsUIExtFirstSubWindow(true);
std::shared_ptr<AbilityRuntime::AbilityContextImpl> context =
std::make_shared<AbilityRuntime::AbilityContextImpl>();
ASSERT_NE(nullptr, context);
SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
sptr<IRemoteObject> sessionToken = new (std::nothrow) IRemoteObjectMocker();
ASSERT_NE(nullptr, sessionToken);
context->SetToken(sessionToken);
struct RSSurfaceNodeConfig config;
std::shared_ptr<RSSurfaceNode> windowSceneSessionSurfaceNode = RSSurfaceNode::Create(config);
ASSERT_NE(nullptr, windowSceneSessionSurfaceNode);
windowSceneSession->surfaceNode_ = windowSceneSessionSurfaceNode;
ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(context, session));
std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
sptr<WindowSessionProperty> property = nullptr;
sptr<IRemoteObject> token = nullptr;
EXPECT_CALL(m->Mock(), RecoverAndConnectSpecificSession(_, _, _, _, _, _)).WillOnce(DoAll(
SaveArg<2>(&surfaceNode), SaveArg<3>(&property), SaveArg<5>(&token)
));
windowSceneSession->RecoverAndConnectSpecificSession();
ASSERT_EQ(surfaceNode, windowSceneSession->surfaceNode_);
ASSERT_EQ(property, windowSceneSession->property_);
ASSERT_EQ(token, sessionToken);
windowSceneSession->Destroy(false, false);
}
} // namespace
} // namespace Rosen
} // namespace OHOS

View File

@ -29,7 +29,7 @@ public:
virtual void OnScreenshot(DisplayId displayId) = 0;
virtual void OnImmersiveStateChange(ScreenId screenId, bool& immersive) { return; }
virtual void OnGetSurfaceNodeIdsFromMissionIds(std::vector<uint64_t>& missionIds,
std::vector<uint64_t>& surfaceNodeIds) { return; }
std::vector<uint64_t>& surfaceNodeIds, bool isBlackList = false) { return; }
virtual void OnScreenFoldStatusChanged(const std::vector<std::string>& screenFoldInfo) { return; }
};
}

View File

@ -90,7 +90,7 @@ class CAPABILITY("mutex") SingleThreadGuard {};
// ONLY used for those accessed ONLY on scene session manager thread.
// If other looper threads(NOT ffrt or ipc), define a new one.
constexpr SingleThreadGuard SCENE_SESSION_THREAD;
constexpr SingleThreadGuard SCENE_GUARD;
template <typename Guard>
struct SCOPED_CAPABILITY ScopedGuard final {

View File

@ -24,9 +24,11 @@ namespace OHOS {
namespace Rosen {
namespace {
static const std::string g_foldScreenType = system::GetParameter("const.window.foldscreen.type", "0,0,0,0");
static const std::string PHY_ROTATION_OFFSET = system::GetParameter("const.window.phyrotation.offset", "0");
static const std::string SINGLE_DISPLAY = "1";
static const std::string DUAL_DISPLAY = "2";
static const std::string SINGLE_POCKET_DISPLAY = "4";
static const std::string DEFAULT_OFFSET = "0";
}
class FoldScreenStateInternel {
public:
@ -89,6 +91,36 @@ public:
return elems;
}
static std::vector<std::string> GetPhyRotationOffset()
{
static std::vector<std::string> phyOffsets;
if (phyOffsets.empty()) {
std::vector<std::string> elems = StringSplit(PHY_ROTATION_OFFSET, ';');
for (auto& num : elems) {
if (IsNumber(num)) {
phyOffsets.push_back(num);
} else {
phyOffsets.push_back(DEFAULT_OFFSET);
}
}
}
return phyOffsets;
}
static bool IsNumber(const std::string& str)
{
int32_t length = static_cast<int32_t>(str.size());
if (length == 0) {
return false;
}
for (int32_t i = 0; i < length; i++) {
if (str.at(i) < '0' || str.at(i) > '9') {
return false;
}
}
return true;
}
static bool IsValidFoldType(const std::string& foldTypeStr)
{
std::regex reg("^([0-9],){3}[0-9]{1}$");

View File

@ -40,7 +40,7 @@ public:
Return PostSyncTask(SyncTask&& task, const std::string& name = "ssmTask")
{
Return ret;
if (!handler_ || handler_->GetEventRunner()->IsCurrentRunnerThread()) {
if (handler_->GetEventRunner()->IsCurrentRunnerThread()) {
StartTraceForSyncTask(name);
ret = task();
FinishTraceForSyncTask();

View File

@ -207,14 +207,14 @@ public:
int32_t GetRealParentId() const;
void SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage);
UIExtensionUsage GetUIExtensionUsage() const;
void SetExtensionFlag(bool isExtensionFlag);
bool GetExtensionFlag() const;
void SetIsUIExtFirstSubWindow(bool isUIExtFirstSubWindow);
bool GetIsUIExtFirstSubWindow() const;
void SetIsUIExtensionAbilityProcess(bool isUIExtensionAbilityProcess);
bool GetIsUIExtensionAbilityProcess() const;
void SetParentWindowType(WindowType parentWindowType);
WindowType GetParentWindowType() const;
void SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag);
bool GetIsUIExtensionSubWindowFlag() const;
void SetIsUIExtAnySubWindow(bool isUIExtAnySubWindow);
bool GetIsUIExtAnySubWindow() const;
/*
* Multi instance
@ -362,9 +362,9 @@ private:
*/
int32_t realParentId_ = INVALID_SESSION_ID;
UIExtensionUsage uiExtensionUsage_ { UIExtensionUsage::EMBEDDED };
bool isExtensionFlag_ = false;
bool isUIExtFirstSubWindow_ = false;
bool isUIExtensionAbilityProcess_ = false;
bool isUIExtensionSubWindowFlag_ = false;
bool isUIExtAnySubWindow_ = false;
WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
/*

View File

@ -38,7 +38,7 @@ std::shared_ptr<AppExecFwk::EventHandler> TaskScheduler::GetEventHandler()
void TaskScheduler::PostAsyncTask(Task&& task, const std::string& name, int64_t delayTime)
{
if (!handler_ || (delayTime == 0 && handler_->GetEventRunner()->IsCurrentRunnerThread())) {
if (delayTime == 0 && handler_->GetEventRunner()->IsCurrentRunnerThread()) {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str());
task();
return;
@ -55,7 +55,7 @@ void TaskScheduler::PostAsyncTask(Task&& task, const std::string& name, int64_t
void TaskScheduler::PostVoidSyncTask(Task&& task, const std::string& name)
{
if (!handler_ || handler_->GetEventRunner()->IsCurrentRunnerThread()) {
if (handler_->GetEventRunner()->IsCurrentRunnerThread()) {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str());
task();
return;
@ -72,7 +72,7 @@ void TaskScheduler::PostVoidSyncTask(Task&& task, const std::string& name)
void TaskScheduler::PostTask(Task&& task, const std::string& name, int64_t delayTime)
{
if (!handler_ || handler_->GetEventRunner()->IsCurrentRunnerThread()) {
if (handler_->GetEventRunner()->IsCurrentRunnerThread()) {
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str());
task();
return;
@ -89,9 +89,7 @@ void TaskScheduler::PostTask(Task&& task, const std::string& name, int64_t delay
void TaskScheduler::RemoveTask(const std::string& name)
{
if (handler_) {
handler_->RemoveTask("wms:" + name);
}
handler_->RemoveTask("wms:" + name);
}
void TaskScheduler::AddExportTask(std::string taskName, Task task)

View File

@ -1043,7 +1043,7 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const
parcel.WriteBool(isNeedUpdateWindowMode_) && parcel.WriteUint32(callingSessionId_) &&
parcel.WriteBool(isLayoutFullScreen_) &&
parcel.WriteInt32(realParentId_) &&
parcel.WriteBool(isExtensionFlag_) &&
parcel.WriteBool(isUIExtFirstSubWindow_) &&
parcel.WriteBool(isUIExtensionAbilityProcess_) &&
parcel.WriteUint32(static_cast<uint32_t>(uiExtensionUsage_)) &&
parcel.WriteUint32(static_cast<uint32_t>(parentWindowType_)) &&
@ -1113,7 +1113,7 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel)
property->SetCallingSessionId(parcel.ReadUint32());
property->SetIsLayoutFullScreen(parcel.ReadBool());
property->SetRealParentId(parcel.ReadInt32());
property->SetExtensionFlag(parcel.ReadBool());
property->SetIsUIExtFirstSubWindow(parcel.ReadBool());
property->SetIsUIExtensionAbilityProcess(parcel.ReadBool());
property->SetUIExtensionUsage(static_cast<UIExtensionUsage>(parcel.ReadUint32()));
property->SetParentWindowType(static_cast<WindowType>(parcel.ReadUint32()));
@ -1508,14 +1508,14 @@ int32_t WindowSessionProperty::GetRealParentId() const
return realParentId_;
}
void WindowSessionProperty::SetExtensionFlag(bool isExtensionFlag)
void WindowSessionProperty::SetIsUIExtFirstSubWindow(bool isUIExtFirstSubWindow)
{
isExtensionFlag_ = isExtensionFlag;
isUIExtFirstSubWindow_ = isUIExtFirstSubWindow;
}
bool WindowSessionProperty::GetExtensionFlag() const
bool WindowSessionProperty::GetIsUIExtFirstSubWindow() const
{
return isExtensionFlag_;
return isUIExtFirstSubWindow_;
}
void WindowSessionProperty::SetIsUIExtensionAbilityProcess(bool isUIExtensionAbilityProcess)
@ -1528,14 +1528,14 @@ bool WindowSessionProperty::GetIsUIExtensionAbilityProcess() const
return isUIExtensionAbilityProcess_;
}
void WindowSessionProperty::SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag)
void WindowSessionProperty::SetIsUIExtAnySubWindow(bool isUIExtAnySubWindow)
{
isUIExtensionSubWindowFlag_ = isUIExtensionSubWindowFlag;
isUIExtAnySubWindow_ = isUIExtAnySubWindow;
}
bool WindowSessionProperty::GetIsUIExtensionSubWindowFlag() const
bool WindowSessionProperty::GetIsUIExtAnySubWindow() const
{
return isUIExtensionSubWindowFlag_;
return isUIExtAnySubWindow_;
}
void WindowSessionProperty::SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage)

View File

@ -303,6 +303,7 @@ struct SessionInfo {
sptr<IRemoteObject> rootToken_ = nullptr;
uint64_t screenId_ = -1;
bool isPersistentRecover_ = false;
bool isFromIcon_ = false;
mutable std::shared_ptr<AAFwk::Want> want = nullptr; // want for ability start
std::shared_ptr<AAFwk::Want> closeAbilityWant = nullptr;

View File

@ -373,6 +373,7 @@ sptr<SceneSession> JsRootSceneSession::GenSceneSession(SessionInfo& info)
sceneSession->SetSessionInfoPersistentId(sceneSession->GetPersistentId());
}
}
sceneSession->SetSessionInfoProcessOptions(info.processOptions);
return sceneSession;
}
} // namespace OHOS::Rosen

View File

@ -214,7 +214,7 @@ static napi_value CreatePipTemplateInfo(napi_env env, const sptr<SceneSession>&
return pipTemplateInfoValue;
}
static void SetWindowSize(napi_env env, napi_value objValue, const sptr<SceneSession>& session)
static void SetWindowSizeAndPosition(napi_env env, napi_value objValue, const sptr<SceneSession>& session)
{
auto abilityInfo = session->GetSessionInfo().abilityInfo;
if (!abilityInfo) {
@ -233,6 +233,16 @@ static void SetWindowSize(napi_env env, napi_value objValue, const sptr<SceneSes
TLOGI(WmsLogTag::WMS_LAYOUT, "ohos.ability.window.height = %{public}d", value);
napi_set_named_property(env, objValue, "windowHeight", CreateJsValue(env, value));
}
} else if (item.name == "ohos.ability.window.left") {
if (item.value.size() > 0) {
TLOGI(WmsLogTag::WMS_LAYOUT, "ohos.ability.window.left = %{public}s", item.value.c_str());
napi_set_named_property(env, objValue, "windowLeft", CreateJsValue(env, item.value));
}
} else if (item.name == "ohos.ability.window.top") {
if (item.value.size() > 0) {
TLOGI(WmsLogTag::WMS_LAYOUT, "ohos.ability.window.top = %{public}s", item.value.c_str());
napi_set_named_property(env, objValue, "windowTop", CreateJsValue(env, item.value));
}
}
}
}
@ -267,7 +277,7 @@ napi_value JsSceneSession::Create(napi_env env, const sptr<SceneSession>& sessio
CreateJsValue(env, static_cast<int32_t>(session->GetSubWindowModalType())));
napi_set_named_property(env, objValue, "appInstanceKey",
CreateJsValue(env, session->GetSessionInfo().appInstanceKey_));
SetWindowSize(env, objValue, session);
SetWindowSizeAndPosition(env, objValue, session);
sptr<WindowSessionProperty> sessionProperty = session->GetSessionProperty();
if (sessionProperty != nullptr) {
napi_set_named_property(env, objValue, "screenId",
@ -319,6 +329,7 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c
BindNativeFunction(env, objValue, "setWaterMarkFlag", moduleName, JsSceneSession::SetWaterMarkFlag);
BindNativeFunction(env, objValue, "setPipActionEvent", moduleName, JsSceneSession::SetPipActionEvent);
BindNativeFunction(env, objValue, "setPiPControlEvent", moduleName, JsSceneSession::SetPiPControlEvent);
BindNativeFunction(env, objValue, "notifyPipOcclusionChange", moduleName, JsSceneSession::NotifyPipOcclusionChange);
BindNativeFunction(env, objValue, "notifyDisplayStatusBarTemporarily", moduleName,
JsSceneSession::NotifyDisplayStatusBarTemporarily);
BindNativeFunction(env, objValue, "setTemporarilyShowWhenLocked", moduleName,
@ -1878,6 +1889,13 @@ napi_value JsSceneSession::SetPiPControlEvent(napi_env env, napi_callback_info i
return (me != nullptr) ? me->OnSetPiPControlEvent(env, info) : nullptr;
}
napi_value JsSceneSession::NotifyPipOcclusionChange(napi_env env, napi_callback_info info)
{
TLOGI(WmsLogTag::WMS_PIP, "[NAPI]");
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
return (me != nullptr) ? me->OnNotifyPipOcclusionChange(env, info) : nullptr;
}
napi_value JsSceneSession::NotifyDisplayStatusBarTemporarily(napi_env env, napi_callback_info info)
{
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
@ -3122,6 +3140,7 @@ sptr<SceneSession> JsSceneSession::GenSceneSession(SessionInfo& info)
sceneSession->SetSessionInfo(info);
}
}
sceneSession->SetSessionInfoProcessOptions(info.processOptions);
return sceneSession;
}
@ -4256,6 +4275,32 @@ napi_value JsSceneSession::OnSetPiPControlEvent(napi_env env, napi_callback_info
return NapiGetUndefined(env);
}
napi_value JsSceneSession::OnNotifyPipOcclusionChange(napi_env env, napi_callback_info info)
{
size_t argc = ARG_COUNT_4;
napi_value argv[ARG_COUNT_4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc < 1) {
TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Argc count 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);
}
bool occluded = false;
if (!ConvertFromJsValue(env, argv[0], occluded)) {
TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to convert parameter, keep default: false");
}
auto session = weakSession_.promote();
if (session == nullptr) {
TLOGE(WmsLogTag::WMS_PIP, "[NAPI]session is nullptr, id:%{public}d", persistentId_);
return NapiGetUndefined(env);
}
TLOGI(WmsLogTag::WMS_PIP, "[NAPI]persistId:%{public}d, occluded:%{public}d", persistentId_, occluded);
// Maybe expand with session visibility&state change
SceneSessionManager::GetInstance().HandleKeepScreenOn(session, !occluded);
return NapiGetUndefined(env);
}
napi_value JsSceneSession::OnNotifyDisplayStatusBarTemporarily(napi_env env, napi_callback_info info)
{
auto session = weakSession_.promote();

View File

@ -122,6 +122,7 @@ private:
static napi_value SetExitSplitOnBackground(napi_env env, napi_callback_info info);
static napi_value SetWaterMarkFlag(napi_env env, napi_callback_info info);
static napi_value SetPipActionEvent(napi_env env, napi_callback_info info);
static napi_value NotifyPipOcclusionChange(napi_env env, napi_callback_info info);
static napi_value SetPiPControlEvent(napi_env env, napi_callback_info info);
static napi_value NotifyDisplayStatusBarTemporarily(napi_env env, napi_callback_info info);
static napi_value SetTemporarilyShowWhenLocked(napi_env env, napi_callback_info info);
@ -179,6 +180,7 @@ private:
napi_value OnSetWaterMarkFlag(napi_env env, napi_callback_info info);
napi_value OnSetPipActionEvent(napi_env env, napi_callback_info info);
napi_value OnSetPiPControlEvent(napi_env env, napi_callback_info info);
napi_value OnNotifyPipOcclusionChange(napi_env env, napi_callback_info info);
napi_value OnNotifyDisplayStatusBarTemporarily(napi_env env, napi_callback_info info);
napi_value OnSetTemporarilyShowWhenLocked(napi_env env, napi_callback_info info);
napi_value OnSetSkipDraw(napi_env env, napi_callback_info info);

View File

@ -1207,6 +1207,10 @@ static napi_value CreateWindowModes(napi_env env,
{
napi_value arrayValue = nullptr;
napi_create_array_with_length(env, windowModes.size(), &arrayValue);
if (arrayValue == nullptr) {
TLOGE(WmsLogTag::WMS_SCB, "Failed to create napi array");
return NapiGetUndefined(env);
}
auto index = 0;
for (const auto& windowMode : windowModes) {
napi_set_element(env, arrayValue, index++, CreateJsValue(env, static_cast<int32_t>(windowMode)));
@ -1278,6 +1282,10 @@ static napi_value CreateAbilityInfos(napi_env env, const std::vector<SCBAbilityI
{
napi_value arrayValue = nullptr;
napi_create_array_with_length(env, scbAbilityInfos.size(), &arrayValue);
if (arrayValue == nullptr) {
TLOGE(WmsLogTag::WMS_SCB, "Failed to create napi array");
return NapiGetUndefined(env);
}
auto index = 0;
for (const auto& scbAbilityInfo : scbAbilityInfos) {
napi_set_element(env, arrayValue, index++, CreateSCBAbilityInfo(env, scbAbilityInfo));
@ -1313,7 +1321,7 @@ napi_value JsSceneSessionManager::OnGetAllAbilityInfos(napi_env env, napi_callba
}
auto errCode = std::make_shared<int32_t>(static_cast<int32_t>(WSErrorCode::WS_OK));
auto scbAbilityInfos = std::make_shared<std::vector<SCBAbilityInfo>>();
auto execute = [want, userId, infos = scbAbilityInfos, errCode] () {
auto execute = [want, userId, infos = scbAbilityInfos, errCode]() {
auto code = WS_JS_TO_ERROR_CODE_MAP.at(
SceneSessionManager::GetInstance().GetAllAbilityInfos(want, userId, *infos));
*errCode = static_cast<int32_t>(code);
@ -1337,8 +1345,8 @@ napi_value JsSceneSessionManager::OnGetAllAbilityInfos(napi_env env, napi_callba
napi_value JsSceneSessionManager::OnGetBatchAbilityInfos(napi_env env, napi_callback_info info)
{
size_t argc = 4;
napi_value argv[4] = { nullptr };
size_t argc = DEFAULT_ARG_COUNT;
napi_value argv[DEFAULT_ARG_COUNT] = { nullptr };
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc != ARGC_TWO) {
TLOGE(WmsLogTag::DEFAULT, "[NAPI]Argc is invalid: %{public}zu", argc);
@ -1354,7 +1362,7 @@ napi_value JsSceneSessionManager::OnGetBatchAbilityInfos(napi_env env, napi_call
return NapiGetUndefined(env);
}
std::vector<std::string> bundleNames;
if (!ParseArrayStringValue(env, argv[1], bundleNames)) {
if (!ParseArrayStringValue(env, argv[ARG_INDEX_ONE], bundleNames)) {
TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to bundleNames");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
"Input parameter is missing or invalid"));
@ -1362,7 +1370,7 @@ napi_value JsSceneSessionManager::OnGetBatchAbilityInfos(napi_env env, napi_call
}
auto errCode = std::make_shared<WSErrorCode>(WSErrorCode::WS_OK);
auto scbAbilityInfos = std::make_shared<std::vector<SCBAbilityInfo>>();
auto execute = [bundleNames, userId, infos = scbAbilityInfos, errCode] {
auto execute = [bundleNames = std::move(bundleNames), userId, infos = scbAbilityInfos, errCode] {
*errCode = WS_JS_TO_ERROR_CODE_MAP.at(
SceneSessionManager::GetInstance().GetBatchAbilityInfos(bundleNames, userId, *infos));
};

View File

@ -939,6 +939,7 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo)
}
napi_set_named_property(env, objValue, "errorReason",
CreateJsValue(env, sessionInfo.errorReason));
napi_set_named_property(env, objValue, "isFromIcon", CreateJsValue(env, sessionInfo.isFromIcon_));
SetJsSessionInfoByWant(env, sessionInfo, objValue);
return objValue;
}

View File

@ -569,7 +569,7 @@ void JsScreenSession::OnPowerStatusChange(DisplayPowerEvent event, EventStatus e
napi_call_function(env, NapiGetUndefined(env), method, ArraySize(argv), argv, nullptr);
};
if (env_ != nullptr) {
napi_status ret = napi_send_event(env_, asyncTask, napi_eprio_immediate);
napi_status ret = napi_send_event(env_, asyncTask, napi_eprio_vip);
if (ret != napi_status::napi_ok) {
WLOGFE("OnPowerStatusChange: Failed to SendEvent.");
} else {

View File

@ -237,7 +237,7 @@ void JsScreenSessionManager::OnScreenConnected(const sptr<ScreenSession>& screen
napi_call_function(env, NapiGetUndefined(env), method, ArraySize(argv), argv, nullptr);
};
if (env_ != nullptr) {
napi_status ret = napi_send_event(env_, asyncTask, napi_eprio_immediate);
napi_status ret = napi_send_event(env_, asyncTask, napi_eprio_vip);
if (ret != napi_status::napi_ok) {
WLOGFE("OnScreenConnected: Failed to SendEvent.");
}

View File

@ -28,6 +28,13 @@ namespace OHOS {
namespace Rosen {
using OHOS::AppExecFwk::AppStateData;
using OHOS::AppExecFwk::IApplicationStateObserver;
enum class ReportTentModeStatus : int32_t {
NORMAL_EXIT_TENT_MODE = 0,
NORMAL_ENTER_TENT_MODE = 1,
ABNORMAL_EXIT_TENT_MODE_DUE_TO_ANGLE = 2,
ABNORMAL_EXIT_TENT_MODE_DUE_TO_HALL = 3,
};
class ApplicationStatePocketObserver : public IApplicationStateObserver {
public:
ApplicationStatePocketObserver();
@ -66,6 +73,7 @@ private:
int allowUserSensorForLargeFoldDevice = 0;
bool TriggerTentExit(float angle, int hall);
void TentModeHandleSensorChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy);
void ReportTentStatusChange(ReportTentModeStatus tentStatus);
};
} // namespace Rosen
} // namespace OHOS

View File

@ -60,7 +60,6 @@ private:
/*
hidumper
*/
#ifndef IS_RELEASE_VERSION
void ShowNotifyFoldStatusChangedInfo();
void ShowIllegalArgsInfo();
void SetMotionSensorvalue(std::string input);
@ -71,7 +70,6 @@ private:
bool IsValidDisplayModeCommand(std::string command);
int SetFoldDisplayMode();
int SetFoldStatusLocked();
#endif
private:
int fd_;

View File

@ -87,6 +87,8 @@ public:
bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) 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;
bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override;
bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override;
ScreenPowerState GetScreenPower(ScreenId screenId) override;
@ -327,6 +329,8 @@ private:
void OnHgmRefreshRateChange(uint32_t refreshRate);
sptr<ScreenSession> GetOrCreateScreenSession(ScreenId screenId);
void CreateScreenProperty(ScreenId screenId, ScreenProperty& property);
void InitScreenDensity(sptr<ScreenSession> session, const ScreenProperty& property);
float CalcDefaultExtendScreenDensity(const ScreenProperty& property);
sptr<ScreenSession> GetScreenSessionInner(ScreenId screenId, ScreenProperty property);
sptr<ScreenSession> CreatePhysicalMirrorSessionInner(ScreenId screenId, ScreenId defaultScreenId,
ScreenProperty property);
@ -336,8 +340,14 @@ private:
void AddVirtualScreenDeathRecipient(const sptr<IRemoteObject>& displayManagerAgent, ScreenId smsScreenId);
void SendCastEvent(const bool &isPlugIn);
void PhyMirrorConnectWakeupScreen();
void HandleScreenEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent);
bool IsScreenRestored(sptr<ScreenSession> screenSession);
bool GetIsCurrentInUseById(ScreenId screenId);
bool GetMultiScreenInfo(MultiScreenMode& multiScreenMode,
MultiScreenPositionOptions& mainScreenOption, MultiScreenPositionOptions& secondaryScreenOption);
void RecoverMultiScreenInfoFromData(sptr<ScreenSession> screenSession);
void HandleScreenConnectEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent);
void HandleScreenDisconnectEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent);
ScreenRotation ConvertOffsetToCorrectRotation(int32_t phyOffset);
void MultiScreenModeChange(ScreenId mainScreenId, ScreenId secondaryScreenId, const std::string& operateType);
void SetClientInner();
void GetCurrentScreenPhyBounds(float& phyWidth, float& phyHeight, bool& isReset, const ScreenId& screenid);
@ -503,6 +513,8 @@ private:
void SetCastFromSettingData();
void RegisterCastObserver(std::vector<ScreenId>& mirrorScreenIds);
void ExitCoordination(const std::string& reason);
void UpdateDisplayState(std::vector<ScreenId> screenIds, DisplayState state);
DisplayState lastDisplayState_ { DisplayState::UNKNOWN };
private:
class ScbClientListenerDeathRecipient : public IRemoteObject::DeathRecipient {

View File

@ -47,21 +47,6 @@ 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

@ -40,6 +40,18 @@ public:
static void SetSettingRotationScreenId(int32_t screenId);
static bool GetSettingRotation(int32_t& rotation, const std::string& key = SETTING_ROTATION_KEY);
static bool GetSettingRotationScreenID(int32_t& screenId, const std::string& key = SETTING_ROTATION_SCREEN_ID_KEY);
static void RemoveInvalidChar(std::string& dataStr, const std::string& inputString);
static bool SplitString(std::vector<std::string>& splitValues, const std::string& inputString);
static int32_t GetDataFromString(std::vector<uint64_t>& datas, const std::string& inputString);
static bool GetSettingRecoveryResolutionString(std::vector<std::string>& resolutionStrings,
const std::string& key = SETTING_RECOVERY_RESOLUTION_KEY);
static bool GetSettingRecoveryResolutionMap(std::map<uint64_t, std::pair<int32_t, int32_t>>& resolution);
static bool GetSettingScreenModeString(std::vector<std::string>& screenModeStrings,
const std::string& key = SETTING_SCREEN_MODE_KEY);
static bool GetSettingScreenModeMap(std::map<uint64_t, uint32_t>& screenMode);
static bool GetSettingRelativePositionString(std::vector<std::string>& relativePositionStrings,
const std::string& key = SETTING_RELATIVE_POSITION_KEY);
static bool GetSettingRelativePositionMap(std::map<uint64_t, std::pair<uint32_t, uint32_t>>& relativePosition);
private:
static const constexpr char* SETTING_DPI_KEY {"user_set_dpi_value"};
@ -47,6 +59,9 @@ private:
static const constexpr char* SETTING_CAST_KEY {"huaweicast.data.privacy_projection_state"};
static const constexpr char* SETTING_ROTATION_KEY {"screen_rotation_value"};
static const constexpr char* SETTING_ROTATION_SCREEN_ID_KEY {"screen_rotation_screen_id_value"};
static const constexpr char* SETTING_RECOVERY_RESOLUTION_KEY {"user_set_recovery_resolution"};
static const constexpr char* SETTING_SCREEN_MODE_KEY {"user_set_last_screen_mode"};
static const constexpr char* SETTING_RELATIVE_POSITION_KEY {"user_set_relative_position"};
static sptr<SettingObserver> dpiObserver_;
static sptr<SettingObserver> extendDpiObserver_;
static sptr<SettingObserver> castObserver_;

View File

@ -98,6 +98,8 @@ public:
virtual bool SetDisplayState(DisplayState state) override { return false; }
virtual DisplayState GetDisplayState(DisplayId displayId) override {return DisplayState::UNKNOWN; }
virtual bool TryToCancelScreenOff() override { return false; }
virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) override { return false; }
virtual uint32_t GetScreenBrightness(uint64_t screenId) override { return 0; }
virtual std::vector<DisplayId> GetAllDisplayIds() override { return std::vector<DisplayId>{}; }
virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) override { return nullptr; }
virtual void NotifyDisplayEvent(DisplayEvent event) override {}

View File

@ -63,8 +63,6 @@ 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,
@ -79,21 +77,6 @@ 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,21 +42,6 @@ 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,7 +31,6 @@ 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);
@ -41,21 +40,6 @@ 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

@ -342,7 +342,6 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeInner(sptr<ScreenSession> scr
if (isScreenOn) {
ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false);
ScreenSessionManager::GetInstance().SetScreenPowerForFold(ScreenPowerStatus::POWER_STATUS_ON);
PowerMgr::PowerMgrClient::GetInstance().RefreshActivity();
} else {
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
}
@ -367,7 +366,6 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeToCoordination()
ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false);
ScreenSessionManager::GetInstance().SetScreenPower(ScreenPowerStatus::POWER_STATUS_ON,
PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH);
PowerMgr::PowerMgrClient::GetInstance().RefreshActivity();
} else {
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
}

View File

@ -22,6 +22,10 @@
#include "screen_session_manager/include/screen_session_manager.h"
#include "window_manager_hilog.h"
#ifdef POWER_MANAGER_ENABLE
#include <power_mgr_client.h>
#endif
namespace OHOS::Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "SensorFoldStateManager"};
@ -45,11 +49,12 @@ void SensorFoldStateManager::HandleSensorChange(FoldStatus nextState, float angl
return;
}
if (mState_ == nextState && !IsTentMode()) {
WLOGFI("fold state doesn't change, foldState = %{public}d.", mState_);
WLOGFD("fold state doesn't change, foldState = %{public}d.", mState_);
return;
}
WLOGFI("current state: %{public}d, next state: %{public}d.", mState_, nextState);
ReportNotifyFoldStatusChange(static_cast<int32_t>(mState_), static_cast<int32_t>(nextState), angle);
PowerMgr::PowerMgrClient::GetInstance().RefreshActivity();
NotifyReportFoldStatusToScb(mState_, nextState, angle);

View File

@ -14,6 +14,7 @@
*/
#include <parameters.h>
#include <hisysevent.h>
#include "fold_screen_controller/fold_screen_policy.h"
#include "fold_screen_controller/sensor_fold_state_manager/single_display_sensor_pocket_fold_state_manager.h"
@ -251,9 +252,11 @@ void SingleDisplaySensorPocketFoldStateManager::HandleTentChange(bool isTent, sp
}
if (isTent) {
ReportTentStatusChange(ReportTentModeStatus::NORMAL_ENTER_TENT_MODE);
FoldStatus currentState = GetCurrentState();
foldScreenPolicy->ChangeOnTentMode(currentState);
} else {
ReportTentStatusChange(ReportTentModeStatus::NORMAL_EXIT_TENT_MODE);
foldScreenPolicy->ChangeOffTentMode();
}
}
@ -261,11 +264,13 @@ void SingleDisplaySensorPocketFoldStateManager::HandleTentChange(bool isTent, sp
bool SingleDisplaySensorPocketFoldStateManager::TriggerTentExit(float angle, int hall)
{
if (hall == HALL_FOLDED_THRESHOLD) {
ReportTentStatusChange(ReportTentModeStatus::ABNORMAL_EXIT_TENT_MODE_DUE_TO_HALL);
WLOGI("Exit tent mode due to hall sensor report folded");
return true;
}
if (std::isless(angle, TENT_MODE_EXIT_MIN_THRESHOLD) || std::isgreater(angle, TENT_MODE_EXIT_MAX_THRESHOLD)) {
ReportTentStatusChange(ReportTentModeStatus::ABNORMAL_EXIT_TENT_MODE_DUE_TO_ANGLE);
WLOGI("Exit tent mode due to angle sensor report angle:%{public}f", angle);
return true;
}
@ -283,6 +288,20 @@ void SingleDisplaySensorPocketFoldStateManager::TentModeHandleSensorChange(float
}
}
void SingleDisplaySensorPocketFoldStateManager::ReportTentStatusChange(ReportTentModeStatus tentStatus)
{
int32_t status = static_cast<int32_t>(tentStatus);
TLOGI(WmsLogTag::DMS, "report tentStatus: %{public}d", status);
int32_t ret = HiSysEventWrite(
OHOS::HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER,
"TENT_MODE",
OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
"TENT_STATUS", status);
if (ret != 0) {
TLOGE(WmsLogTag::DMS, "Write HiSysEvent error, ret: %{public}d", ret);
}
}
ApplicationStatePocketObserver::ApplicationStatePocketObserver() {}
void ApplicationStatePocketObserver::OnForegroundApplicationChanged(const AppStateData &appStateData)

View File

@ -256,7 +256,6 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToMain(sptr<ScreenSession>
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToMain: IsFoldScreenOn is true, screenIdMain ON.");
screenId_ = SCREEN_ID_MAIN;
ChangeScreenDisplayModePower(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_ON);
PowerMgr::PowerMgrClient::GetInstance().RefreshActivity();
SetdisplayModeChangeStatus(false);
};
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMain, "screenOnMainTask");
@ -307,7 +306,6 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToFull(sptr<ScreenSession>
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToFull: IsFoldScreenOn is true, screenIdFull ON.");
screenId_ = SCREEN_ID_FULL;
ChangeScreenDisplayModePower(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON);
PowerMgr::PowerMgrClient::GetInstance().RefreshActivity();
SetdisplayModeChangeStatus(false);
};
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnFull, "screenOnFullTask");
@ -327,7 +325,7 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToFull(sptr<ScreenSession>
auto taskScreenOnFullOn = [=] {
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToFull: IsFoldScreenOn is false, screenIdFull ON.");
screenId_ = SCREEN_ID_FULL;
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
PowerMgr::PowerMgrClient::GetInstance().WakeupDeviceAsync();
SetdisplayModeChangeStatus(false);
};
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnFullOn, "screenOnFullOnTask");
@ -347,7 +345,7 @@ void SingleDisplayFoldPolicy::SendPropertyChangeResult(sptr<ScreenSession> scree
screenProperty_ = ScreenSessionManager::GetInstance().GetPhyScreenProperty(screenId);
ScreenProperty property = screenSession->UpdatePropertyByFoldControl(screenProperty_);
screenSession->PropertyChange(property, reason);
screenSession->SetRotation(Rotation::ROTATION_0);
screenSession->SetRotationAndScreenRotationOnly(Rotation::ROTATION_0);
TLOGI(WmsLogTag::DMS, "screenBounds : width_= %{public}f, height_= %{public}f",
screenSession->GetScreenProperty().GetBounds().rect_.width_,
screenSession->GetScreenProperty().GetBounds().rect_.height_);

View File

@ -78,8 +78,7 @@ void SingleDisplayPocketFoldPolicy::SetdisplayModeChangeStatus(bool status)
displayModeChangeRunning_ = false;
endTimePoint_ = std::chrono::steady_clock::now();
if (lastCachedisplayMode_.load() != GetScreenDisplayMode()) {
TLOGI(WmsLogTag::DMS, "start change displaymode to lastest mode");
ChangeScreenDisplayMode(lastCachedisplayMode_.load());
ScreenSessionManager::GetInstance().TriggerDisplayModeUpdate(lastCachedisplayMode_.load());
}
}
}
@ -156,7 +155,7 @@ void SingleDisplayPocketFoldPolicy::SendSensorResult(FoldStatus foldStatus)
{
TLOGI(WmsLogTag::DMS, "SendSensorResult FoldStatus: %{public}d", foldStatus);
FoldDisplayMode displayMode = GetModeMatchStatus();
if (displayMode != currentDisplayMode_ && !(currentDisplayMode_ == FoldDisplayMode::COORDINATION &&
if (!(currentDisplayMode_ == FoldDisplayMode::COORDINATION &&
displayMode == FoldDisplayMode::FULL)) {
ChangeScreenDisplayMode(displayMode);
}
@ -262,24 +261,21 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMainWhenFoldScreenO
TLOGI(WmsLogTag::DMS, "IsFoldScreenOn is true, begin.");
ReportFoldStatusChangeBegin(static_cast<int32_t>(SCREEN_ID_FULL),
static_cast<int32_t>(SCREEN_ID_MAIN));
// off full screen
auto taskScreenOnMainOff = [=] {
auto taskScreenOnMain = [=] {
// off full screen
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToMain: IsFoldScreenOn is true, screenIdFull OFF.");
screenId_ = SCREEN_ID_FULL;
ChangeScreenDisplayModePower(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_OFF);
SetdisplayModeChangeStatus(false);
};
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMainOff, "screenOnMainOffTask");
SendPropertyChangeResult(screenSession, SCREEN_ID_MAIN, ScreenPropertyChangeReason::FOLD_SCREEN_FOLDING);
// on main screen
auto taskScreenOnMainOn = [=] {
// on main screen
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToMain: IsFoldScreenOn is true, screenIdMain ON.");
screenId_ = SCREEN_ID_MAIN;
ChangeScreenDisplayModePower(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_ON);
PowerMgr::PowerMgrClient::GetInstance().RefreshActivity();
SetdisplayModeChangeStatus(false);
};
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMainOn, "screenOnMainOnTask");
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMain, "screenOnMainTask");
SendPropertyChangeResult(screenSession, SCREEN_ID_MAIN, ScreenPropertyChangeReason::FOLD_SCREEN_FOLDING);
}
void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMainWhenFoldScreenOff(sptr<ScreenSession> screenSession)
@ -302,7 +298,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMainWhenFoldScreenO
RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE_MAIN, MAIN_TP_OFF.c_str());
#endif
if (ifTentMode) {
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
PowerMgr::PowerMgrClient::GetInstance().WakeupDeviceAsync();
}
SetdisplayModeChangeStatus(false);
};
@ -340,24 +336,21 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToFull(sptr<ScreenSes
#endif
if (PowerMgr::PowerMgrClient::GetInstance().IsFoldScreenOn()) {
TLOGI(WmsLogTag::DMS, "IsFoldScreenOn is true, begin.");
// off main screen
auto taskScreenOnFullOff = [=] {
auto taskScreenOnFull = [=] {
// off main screen
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToFull: IsFoldScreenOn is true, screenIdMain OFF.");
screenId_ = SCREEN_ID_MAIN;
ChangeScreenDisplayModePower(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_OFF);
SetdisplayModeChangeStatus(false);
};
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnFullOff, "screenOnFullOffTask");
SendPropertyChangeResult(screenSession, SCREEN_ID_FULL, ScreenPropertyChangeReason::FOLD_SCREEN_EXPAND);
// on full screen
auto taskScreenOnFullOn = [=] {
// on full screen
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToFull: IsFoldScreenOn is true, screenIdFull ON.");
screenId_ = SCREEN_ID_FULL;
ChangeScreenDisplayModePower(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON);
PowerMgr::PowerMgrClient::GetInstance().RefreshActivity();
SetdisplayModeChangeStatus(false);
};
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnFullOn, "screenOnFullOnTask");
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnFull, "screenOnFullTask");
SendPropertyChangeResult(screenSession, SCREEN_ID_FULL, ScreenPropertyChangeReason::FOLD_SCREEN_EXPAND);
} else { //AOD scene
TLOGI(WmsLogTag::DMS, "IsFoldScreenOn is false, begin.");
// off main screen
@ -373,7 +366,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToFull(sptr<ScreenSes
auto taskScreenOnFullOn = [=] {
TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToFull: IsFoldScreenOn is false, screenIdFull ON.");
screenId_ = SCREEN_ID_FULL;
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
PowerMgr::PowerMgrClient::GetInstance().WakeupDeviceAsync();
SetdisplayModeChangeStatus(false);
};
screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnFullOn, "screenOnFullOnTask");
@ -393,7 +386,7 @@ void SingleDisplayPocketFoldPolicy::SendPropertyChangeResult(sptr<ScreenSession>
screenProperty_ = ScreenSessionManager::GetInstance().GetPhyScreenProperty(screenId);
ScreenProperty property = screenSession->UpdatePropertyByFoldControl(screenProperty_);
screenSession->PropertyChange(property, reason);
screenSession->SetRotation(Rotation::ROTATION_0);
screenSession->SetRotationAndScreenRotationOnly(Rotation::ROTATION_0);
TLOGI(WmsLogTag::DMS, "screenBounds : width_= %{public}f, height_= %{public}f",
screenSession->GetScreenProperty().GetBounds().rect_.width_,
screenSession->GetScreenProperty().GetBounds().rect_.height_);

View File

@ -134,6 +134,7 @@ void ScreenSessionDumper::ExcuteInjectCmd()
bool isDebugMode = system::GetBoolParameter("dms.hidumper.supportdebug", false);
if (!isDebugMode) {
TLOGI(WmsLogTag::DMS, "Can't use DMS hidumper inject methods.");
dumpInfo_.append("dms.hidumper.supportdebug false\n");
return;
}
if (params_[0] == STATUS_FOLD_HALF || params_[0] == STATUS_EXPAND || params_[0] == STATUS_FOLD) {

View File

@ -71,6 +71,7 @@ const std::string STATUS_FOLD_HALF = "-z";
const std::string STATUS_EXPAND = "-y";
const std::string STATUS_FOLD = "-p";
const std::string SETTING_LOCKED_KEY = "settings.general.accelerometer_rotation_status";
const ScreenId SCREEN_ID_DEFAULT = 0;
const ScreenId SCREEN_ID_FULL = 0;
const ScreenId SCREEN_ID_MAIN = 5;
const ScreenId SCREEN_ID_PC_MAIN = 9;
@ -94,6 +95,9 @@ constexpr int32_t RES_FAILURE_FOR_PRIVACY_WINDOW = -2;
constexpr int32_t REMOVE_DISPLAY_MODE = 0;
constexpr int32_t INVALID_DPI = 0;
constexpr int32_t IRREGULAR_REFRESH_RATE_SKIP_THRETHOLD = 10;
constexpr uint32_t SCREEN_MAIN_IN_DATA = 0;
constexpr uint32_t SCREEN_MIRROR_IN_DATA = 1;
constexpr uint32_t SCREEN_EXTEND_IN_DATA = 2;
const int32_t ROTATE_POLICY = system::GetIntParameter("const.window.device.rotate_policy", 0);
constexpr int32_t FOLDABLE_DEVICE { 2 };
@ -106,6 +110,7 @@ static const constexpr char* SET_SETTING_DPI_KEY {"default_display_dpi"};
const std::string SCREEN_EXTEND = "extend";
const std::string SCREEN_MIRROR = "mirror";
const std::string SCREEN_UNKNOWN = "unknown";
constexpr float PHYSICAL_MASS = 1.6f;
// based on the bundle_util
inline int32_t GetUserIdByCallingUid()
@ -143,10 +148,37 @@ ScreenSessionManager::ScreenSessionManager()
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
if (g_foldScreenFlag) {
HandleFoldScreenPowerInit();
} else {
std::vector<std::string> phyOffsets = FoldScreenStateInternel::GetPhyRotationOffset();
int32_t phyOffset = static_cast<int32_t>(std::stoi(phyOffsets[0]));
ScreenRotation correctRotation = ConvertOffsetToCorrectRotation(phyOffset);
rsInterface_.SetScreenCorrection(SCREEN_ID_DEFAULT, correctRotation);
TLOGI(WmsLogTag::DMS, "SetScreenCorrection, phyOffset: %{public}u, correctRotation: %{public}u",
phyOffset, correctRotation);
}
WatchParameter(BOOTEVENT_BOOT_COMPLETED.c_str(), BootFinishedCallback, this);
}
ScreenRotation ScreenSessionManager::ConvertOffsetToCorrectRotation(int32_t phyOffset)
{
ScreenRotation offsetRotation = ScreenRotation::ROTATION_0;
switch (phyOffset) {
case 90: // Rotation 90 degree
offsetRotation = ScreenRotation::ROTATION_270;
break;
case 180: // Rotation 180 degree
offsetRotation = ScreenRotation::ROTATION_180;
break;
case 270: // Rotation 270 degree
offsetRotation = ScreenRotation::ROTATION_90;
break;
default:
offsetRotation = ScreenRotation::ROTATION_0;
break;
}
return offsetRotation;
}
void ScreenSessionManager::HandleFoldScreenPowerInit()
{
TLOGI(WmsLogTag::DMS, "Enter");
@ -571,7 +603,13 @@ void ScreenSessionManager::OnScreenChange(ScreenId screenId, ScreenEvent screenE
if (foldScreenController_ != nullptr) {
screenSession->SetFoldScreen(true);
}
HandleScreenEvent(screenSession, screenId, screenEvent);
if (screenEvent == ScreenEvent::CONNECTED) {
HandleScreenConnectEvent(screenSession, screenId, screenEvent);
} else if (screenEvent == ScreenEvent::DISCONNECTED) {
HandleScreenDisconnectEvent(screenSession, screenId, screenEvent);
} else {
TLOGE(WmsLogTag::DMS, "screenEvent error!");
}
}
void ScreenSessionManager::SendCastEvent(const bool &isPlugIn)
@ -628,38 +666,148 @@ void ScreenSessionManager::PhyMirrorConnectWakeupScreen()
}
}
void ScreenSessionManager::HandleScreenEvent(sptr<ScreenSession> screenSession,
bool ScreenSessionManager::IsScreenRestored(sptr<ScreenSession> screenSession)
{
const ScreenProperty& screenProperty = screenSession->GetScreenProperty();
ScreenId currentScreenId = screenSession->GetScreenId();
int32_t currentWidth = screenProperty.GetBounds().rect_.GetWidth();
int32_t currentHeight = screenProperty.GetBounds().rect_.GetHeight();
TLOGI(WmsLogTag::DMS, "currentScreenId: %{public}" PRIu64
", currentWidth: %{public}d, currentHeight: %{public}d", currentScreenId, currentWidth, currentHeight);
std::map<uint64_t, std::pair<int32_t, int32_t>> resolution;
bool ret = ScreenSettingHelper::GetSettingRecoveryResolutionMap(resolution);
if (!ret) {
TLOGE(WmsLogTag::DMS, "get recovery resolution failed");
return false;
}
for (auto& [screenId, screenInfo] : resolution) {
if (screenInfo.first == currentWidth && screenInfo.second == currentHeight) {
TLOGI(WmsLogTag::DMS, "found restored screen, screenId: %{public}" PRIu64 "", screenId);
return true;
}
}
return false;
}
bool ScreenSessionManager::GetIsCurrentInUseById(ScreenId screenId)
{
auto session = GetScreenSession(screenId);
if (session == nullptr) {
TLOGE(WmsLogTag::DMS, "session not found");
return false;
}
if (!session->GetIsCurrentInUse()) {
TLOGE(WmsLogTag::DMS, "session not in use");
return false;
}
return true;
}
bool ScreenSessionManager::GetMultiScreenInfo(MultiScreenMode& multiScreenMode,
MultiScreenPositionOptions& mainScreenOption, MultiScreenPositionOptions& secondaryScreenOption)
{
std::map<ScreenId, uint32_t> screenMode;
std::map<ScreenId, std::pair<uint32_t, uint32_t>> relativePosition;
bool ret = ScreenSettingHelper::GetSettingScreenModeMap(screenMode);
if (!ret) {
TLOGE(WmsLogTag::DMS, "get last screen mode map failed");
return false;
}
ret = ScreenSettingHelper::GetSettingRelativePositionMap(relativePosition);
if (!ret) {
TLOGE(WmsLogTag::DMS, "get relative position mode map failed");
return false;
}
for (auto& [screenId, mode] : screenMode) {
ret = GetIsCurrentInUseById(screenId);
if (!ret) {
TLOGE(WmsLogTag::DMS, "session not currently in use, screenId: %{public}" PRIu64 "", screenId);
continue;
}
if (mode == SCREEN_MAIN_IN_DATA) {
mainScreenOption.screenId_ = screenId;
mainScreenOption.startX_ = relativePosition[screenId].first;
mainScreenOption.startY_ = relativePosition[screenId].second;
} else {
if (mode == SCREEN_MIRROR_IN_DATA) {
multiScreenMode = MultiScreenMode::SCREEN_MIRROR;
} else if (mode == SCREEN_EXTEND_IN_DATA) {
multiScreenMode = MultiScreenMode::SCREEN_EXTEND;
} else {
TLOGE(WmsLogTag::DMS, "screen mode error!");
continue;
}
secondaryScreenOption.screenId_ = screenId;
secondaryScreenOption.startX_ = relativePosition[screenId].first;
secondaryScreenOption.startY_ = relativePosition[screenId].second;
}
}
if (mainScreenOption.screenId_ == secondaryScreenOption.screenId_ ||
mainScreenOption.screenId_ == SCREEN_ID_INVALID ||
secondaryScreenOption.screenId_ == SCREEN_ID_INVALID) {
TLOGE(WmsLogTag::DMS, "screen info error!");
return false;
}
return true;
}
void ScreenSessionManager::RecoverMultiScreenInfoFromData(sptr<ScreenSession> screenSession)
{
bool ret = IsScreenRestored(screenSession);
if (!ret) {
TLOGE(WmsLogTag::DMS, "no restored screen found");
return;
}
MultiScreenMode multiScreenMode;
MultiScreenPositionOptions mainScreenOption;
MultiScreenPositionOptions secondaryScreenOption;
mainScreenOption.screenId_ = SCREEN_ID_INVALID;
secondaryScreenOption.screenId_ = SCREEN_ID_INVALID;
ret = GetMultiScreenInfo(multiScreenMode, mainScreenOption, secondaryScreenOption);
if (!ret) {
TLOGE(WmsLogTag::DMS, "get main and secondary option failed");
return;
}
TLOGI(WmsLogTag::DMS, "check pass, get multiScreenMod: %{public}d", static_cast<int32_t>(multiScreenMode));
TLOGI(WmsLogTag::DMS,
"mID:%{public}" PRIu64", X:%{public}u, Y:%{public}u,sID:%{public}" PRIu64", X:%{public}u, Y:%{public}u",
mainScreenOption.screenId_, mainScreenOption.startX_, mainScreenOption.startY_,
secondaryScreenOption.screenId_, secondaryScreenOption.startX_, secondaryScreenOption.startY_);
SetMultiScreenMode(mainScreenOption.screenId_, secondaryScreenOption.screenId_, multiScreenMode);
SetMultiScreenRelativePosition(mainScreenOption, secondaryScreenOption);
SetDpiFromSettingData(false);
}
void ScreenSessionManager::HandleScreenConnectEvent(sptr<ScreenSession> screenSession,
ScreenId screenId, ScreenEvent screenEvent)
{
bool phyMirrorEnable = IsDefaultMirrorMode(screenId);
if (screenEvent == ScreenEvent::CONNECTED) {
if (phyMirrorEnable) {
PhyMirrorConnectWakeupScreen();
NotifyCastWhenScreenConnectChange(true);
}
if (foldScreenController_ != nullptr) {
if ((screenId == 0 || (screenId == SCREEN_ID_MAIN && isCoordinationFlag_ == true)) &&
clientProxy_) {
TLOGI(WmsLogTag::DMS, "event: connect %{public}" PRIu64 ", %{public}" PRIu64 ", "
"name=%{public}s", screenId, screenSession->GetRSScreenId(), screenSession->GetName().c_str());
clientProxy_->OnScreenConnectionChanged(screenId, ScreenEvent::CONNECTED,
screenSession->GetRSScreenId(), screenSession->GetName(), screenSession->GetIsExtend());
}
return;
}
if (clientProxy_ && !phyMirrorEnable) {
clientProxy_->OnScreenConnectionChanged(screenId, ScreenEvent::CONNECTED,
if (phyMirrorEnable) {
PhyMirrorConnectWakeupScreen();
NotifyCastWhenScreenConnectChange(true);
}
if (foldScreenController_ != nullptr) {
if ((screenId == 0 || (screenId == SCREEN_ID_MAIN && isCoordinationFlag_ == true)) &&
clientProxy_) {
TLOGI(WmsLogTag::DMS, "event: connect %{public}" PRIu64 ", %{public}" PRIu64 ", "
"name=%{public}s", screenId, screenSession->GetRSScreenId(), screenSession->GetName().c_str());
clientProxy_->OnScreenConnectionChanged(screenId, screenEvent,
screenSession->GetRSScreenId(), screenSession->GetName(), screenSession->GetIsExtend());
}
if (phyMirrorEnable) {
NotifyScreenConnected(screenSession->ConvertToScreenInfo());
isPhyScreenConnected_ = true;
}
return;
} else if (screenEvent == ScreenEvent::DISCONNECTED) {
HandleScreenDisconnectEvent(screenSession, screenId, screenEvent);
}
if (clientProxy_ && !phyMirrorEnable) {
clientProxy_->OnScreenConnectionChanged(screenId, screenEvent,
screenSession->GetRSScreenId(), screenSession->GetName(), screenSession->GetIsExtend());
}
if (ScreenSceneConfig::GetExternalScreenDefaultMode() == "none") {
RecoverMultiScreenInfoFromData(screenSession);
}
if (phyMirrorEnable) {
NotifyScreenConnected(screenSession->ConvertToScreenInfo());
isPhyScreenConnected_ = true;
}
TLOGI(WmsLogTag::DMS, "ConnectScreenSession success. ScreenId: %{public}" PRIu64 "", screenId);
}
void ScreenSessionManager::HandleScreenDisconnectEvent(sptr<ScreenSession> screenSession,
@ -1273,21 +1421,6 @@ void ScreenSessionManager::CreateScreenProperty(ScreenId screenId, ScreenPropert
property.SetPhyBounds(screenBounds);
property.SetBounds(screenBounds);
property.SetAvailableArea({0, 0, screenMode.GetScreenWidth(), screenMode.GetScreenHeight()});
if (isDensityDpiLoad_) {
if (screenId == SCREEN_ID_MAIN) {
TLOGI(WmsLogTag::DMS, "subDensityDpi_ = %{public}f", subDensityDpi_);
property.SetVirtualPixelRatio(subDensityDpi_);
property.SetDefaultDensity(subDensityDpi_);
property.SetDensityInCurResolution(subDensityDpi_);
} else {
TLOGI(WmsLogTag::DMS, "densityDpi_ = %{public}f", densityDpi_);
property.SetVirtualPixelRatio(densityDpi_);
property.SetDefaultDensity(densityDpi_);
property.SetDensityInCurResolution(densityDpi_);
}
} else {
property.UpdateVirtualPixelRatio(screenBounds);
}
property.SetRefreshRate(screenRefreshRate);
property.SetDefaultDeviceRotationOffset(defaultDeviceRotationOffset_);
@ -1299,6 +1432,53 @@ void ScreenSessionManager::CreateScreenProperty(ScreenId screenId, ScreenPropert
property.CalcDefaultDisplayOrientation();
}
void ScreenSessionManager::InitScreenDensity(sptr<ScreenSession> session, const ScreenProperty& property)
{
if (session->GetScreenProperty().GetScreenType() == ScreenType::REAL && !session->isInternal_) {
// 表示拓展屏
float extendDensity = CalcDefaultExtendScreenDensity(property);
TLOGI(WmsLogTag::DMS, "extendDensity = %{public}f", extendDensity);
session->SetVirtualPixelRatio(extendDensity);
session->SetDefaultDensity(extendDensity);
session->SetDensityInCurResolution(extendDensity);
return;
}
if (isDensityDpiLoad_) {
if (session->GetScreenId() == SCREEN_ID_MAIN) {
TLOGI(WmsLogTag::DMS, "subDensityDpi_ = %{public}f", subDensityDpi_);
session->SetVirtualPixelRatio(subDensityDpi_);
session->SetDefaultDensity(subDensityDpi_);
session->SetDensityInCurResolution(subDensityDpi_);
} else {
TLOGI(WmsLogTag::DMS, "densityDpi_ = %{public}f", densityDpi_);
session->SetVirtualPixelRatio(densityDpi_);
session->SetDefaultDensity(densityDpi_);
session->SetDensityInCurResolution(densityDpi_);
}
} else {
session->UpdateVirtualPixelRatio(property.GetBounds());
}
}
float ScreenSessionManager::CalcDefaultExtendScreenDensity(const ScreenProperty& property)
{
int32_t phyWith = property.GetPhyWidth();
int32_t phyHeight = property.GetPhyHeight();
float phyDiagonal = std::sqrt(static_cast<float>(phyWith * phyWith + phyHeight * phyHeight));
TLOGI(WmsLogTag::DMS, "phyDiagonal:%{public}f", phyDiagonal);
if (phyDiagonal > 0) {
RRect phyBounds = property.GetPhyBounds();
int32_t width = phyBounds.rect_.GetWidth();
int32_t height = phyBounds.rect_.GetHeight();
float PPI = std::sqrt(static_cast<float>(width * width + height * height)) * INCH_TO_MM / phyDiagonal;
float density = PPI * PHYSICAL_MASS / BASELINE_DENSITY;
TLOGI(WmsLogTag::DMS, "PPI:%{public}f", PPI);
return density;
} else {
return densityDpi_;
}
}
sptr<ScreenSession> ScreenSessionManager::GetOrCreateScreenSession(ScreenId screenId)
{
TLOGI(WmsLogTag::DMS, "GetOrCreateScreenSession ENTER. ScreenId: %{public}" PRIu64 "", screenId);
@ -1308,12 +1488,10 @@ sptr<ScreenSession> ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre
return screenSession;
}
if (ScreenSceneConfig::GetExternalScreenDefaultMode() == "none") {
if (ScreenSceneConfig::GetExternalScreenDefaultMode() == "none" && phyScreenPropMap_.size() > 1) {
// pc is none, pad&&phone is mirror
if (phyScreenPropMap_.size() > 1) {
TLOGI(WmsLogTag::DMS, "Only Support one External screen.");
return nullptr;
}
TLOGI(WmsLogTag::DMS, "Only Support one External screen.");
return nullptr;
}
screenIdManager_.UpdateScreenId(screenId, screenId);
@ -1354,6 +1532,7 @@ sptr<ScreenSession> ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre
screenEventTracker_.RecordEvent("create screen session success.");
SetHdrFormats(screenId, session);
SetColorSpaces(screenId, session);
InitScreenDensity(session, property);
RegisterRefreshRateChangeListener();
TLOGI(WmsLogTag::DMS, "CreateScreenSession success. ScreenId: %{public}" PRIu64 "", screenId);
return session;
@ -1639,6 +1818,18 @@ bool ScreenSessionManager::SetDisplayState(DisplayState state)
return sessionDisplayPowerController_->SetDisplayState(state);
}
UpdateDisplayState(screenIds, state);
bool ret = sessionDisplayPowerController_->SetDisplayState(state);
if (!ret && state == DisplayState::OFF) {
state = lastDisplayState_;
UpdateDisplayState(screenIds, state);
}
lastDisplayState_ = state;
return ret;
}
void ScreenSessionManager::UpdateDisplayState(std::vector<ScreenId> screenIds, DisplayState state)
{
for (auto screenId : screenIds) {
sptr<ScreenSession> screenSession = GetScreenSession(screenId);
if (screenSession == nullptr) {
@ -1650,7 +1841,6 @@ bool ScreenSessionManager::SetDisplayState(DisplayState state)
TLOGI(WmsLogTag::DMS, "[UL_POWER]set screenSession displayState property: %{public}u",
screenSession->GetScreenProperty().GetDisplayState());
}
return sessionDisplayPowerController_->SetDisplayState(state);
}
void ScreenSessionManager::BlockScreenOnByCV(void)
@ -1705,6 +1895,20 @@ bool ScreenSessionManager::TryToCancelScreenOff()
return false;
}
bool ScreenSessionManager::SetScreenBrightness(uint64_t screenId, uint32_t level)
{
TLOGI(WmsLogTag::DMS, "SetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level);
RSInterfaces::GetInstance().SetScreenBacklight(screenId, level);
return true;
}
uint32_t ScreenSessionManager::GetScreenBrightness(uint64_t screenId)
{
uint32_t level = static_cast<uint32_t>(RSInterfaces::GetInstance().GetScreenBacklight(screenId));
TLOGI(WmsLogTag::DMS, "GetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level);
return level;
}
int32_t ScreenSessionManager::SetScreenOffDelayTime(int32_t delay)
{
DmsXcollie dmsXcollie("DMS:SetScreenOffDelayTime", XCOLLIE_TIMEOUT_10S);
@ -2047,6 +2251,8 @@ void ScreenSessionManager::SetDpiFromSettingData()
float dpi = static_cast<float>(settingDpi) / BASELINE_DENSITY;
ScreenId defaultScreenId = GetDefaultScreenId();
SetVirtualPixelRatio(defaultScreenId, dpi);
} else {
TLOGE(WmsLogTag::DMS, "setting dpi error, settingDpi: %{public}d", settingDpi);
}
}
@ -2065,9 +2271,7 @@ void ScreenSessionManager::SetDpiFromSettingData(bool isInternal)
} else {
TLOGI(WmsLogTag::DMS, "get setting dpi success,settingDpi: %{public}u", settingDpi);
}
if (settingDpi >= DOT_PER_INCH_MINIMUM_VALUE && settingDpi <= DOT_PER_INCH_MAXIMUM_VALUE
&& cachedSettingDpi_ != settingDpi) {
cachedSettingDpi_ = settingDpi;
if (settingDpi >= DOT_PER_INCH_MINIMUM_VALUE && settingDpi <= DOT_PER_INCH_MAXIMUM_VALUE) {
float dpi = static_cast<float>(settingDpi) / BASELINE_DENSITY;
ScreenId screenId = SCREEN_ID_INVALID;
{
@ -2241,8 +2445,10 @@ void ScreenSessionManager::NotifyAndPublishEvent(sptr<DisplayInfo> displayInfo,
std::map<DisplayId, sptr<DisplayInfo>> emptyMap;
NotifyDisplayStateChange(GetDefaultScreenId(), screenSession->ConvertToDisplayInfo(),
emptyMap, DisplayStateChangeType::UPDATE_ROTATION);
std::string identity = IPCSkeleton::ResetCallingIdentity();
ScreenSessionPublish::GetInstance().PublishDisplayRotationEvent(
displayInfo->GetScreenId(), displayInfo->GetRotation());
IPCSkeleton::SetCallingIdentity(identity);
}
void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation,
@ -2272,7 +2478,10 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const
}
sptr<DisplayInfo> displayInfo = screenSession->ConvertToDisplayInfo();
TLOGI(WmsLogTag::DMS, "Update Screen Rotation Property Only");
screenSession->UpdatePropertyOnly(bounds, rotation, GetFoldDisplayMode());
{
std::lock_guard<std::recursive_mutex> lock_info(displayInfoMutex_);
screenSession->UpdatePropertyOnly(bounds, rotation, GetFoldDisplayMode());
}
NotifyDisplayChanged(displayInfo, DisplayChangeEvent::UPDATE_ROTATION);
NotifyScreenChanged(screenSession->ConvertToScreenInfo(), ScreenChangeEvent::UPDATE_ROTATION);
return;
@ -2283,7 +2492,11 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const
screenId);
return;
}
screenSession->UpdatePropertyAfterRotation(bounds, rotation, GetFoldDisplayMode());
{
std::lock_guard<std::recursive_mutex> lock_info(displayInfoMutex_);
screenSession->SetPhysicalRotation(rotation, GetFoldStatus());
screenSession->UpdatePropertyAfterRotation(bounds, rotation, GetFoldDisplayMode());
}
sptr<DisplayInfo> displayInfo = screenSession->ConvertToDisplayInfo();
NotifyAndPublishEvent(displayInfo, screenId, screenSession);
}
@ -2716,7 +2929,7 @@ ScreenId ScreenSessionManager::CreateVirtualScreen(VirtualScreenOption option,
}
if (clientProxy_ && option.missionIds_.size() > 0) {
std::vector<uint64_t> surfaceNodeIds;
clientProxy_->OnGetSurfaceNodeIdsFromMissionIdsChanged(option.missionIds_, surfaceNodeIds);
clientProxy_->OnGetSurfaceNodeIdsFromMissionIdsChanged(option.missionIds_, surfaceNodeIds, false);
option.missionIds_ = surfaceNodeIds;
}
ScreenId rsId = rsInterface_.CreateVirtualScreen(option.name_, option.width_,
@ -2878,41 +3091,40 @@ DMError ScreenSessionManager::DestroyVirtualScreen(ScreenId screenId)
SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid());
return DMError::DM_ERROR_NOT_SYSTEM_APP;
}
// virtual screen destroy callback to notify scb
TLOGI(WmsLogTag::DMS, "destroy virtual screen");
OnVirtualScreenChange(screenId, ScreenEvent::DISCONNECTED);
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
ScreenId rsScreenId = SCREEN_ID_INVALID;
screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId);
for (auto &agentIter : screenAgentMap_) {
auto iter = std::find(agentIter.second.begin(), agentIter.second.end(), screenId);
if (iter != agentIter.second.end()) {
iter = agentIter.second.erase(iter);
if (agentIter.first != nullptr && agentIter.second.empty()) {
screenAgentMap_.erase(agentIter.first);
{
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId);
for (auto &agentIter : screenAgentMap_) {
auto iter = std::find(agentIter.second.begin(), agentIter.second.end(), screenId);
if (iter != agentIter.second.end()) {
iter = agentIter.second.erase(iter);
if (agentIter.first != nullptr && agentIter.second.empty()) {
screenAgentMap_.erase(agentIter.first);
}
break;
}
break;
}
}
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:DestroyVirtualScreen(%" PRIu64")", screenId);
if (rsScreenId != SCREEN_ID_INVALID && GetScreenSession(screenId) != nullptr) {
auto screen = GetScreenSession(screenId);
auto screen = GetScreenSession(screenId);
if (rsScreenId != SCREEN_ID_INVALID && screen != nullptr) {
if (CheckScreenInScreenGroup(screen)) {
NotifyDisplayDestroy(screenId);
}
auto smsScreenMapIter = screenSessionMap_.find(screenId);
if (smsScreenMapIter != screenSessionMap_.end()) {
auto screenGroup = RemoveFromGroupLocked(smsScreenMapIter->second);
{
std::lock_guard<std::recursive_mutex> lock(screenSessionMapMutex_);
auto screenGroup = RemoveFromGroupLocked(screen);
if (screenGroup != nullptr) {
NotifyScreenGroupChanged(
smsScreenMapIter->second->ConvertToScreenInfo(), ScreenGroupChangeEvent::REMOVE_FROM_GROUP);
NotifyScreenGroupChanged(screen->ConvertToScreenInfo(), ScreenGroupChangeEvent::REMOVE_FROM_GROUP);
}
screenSessionMap_.erase(smsScreenMapIter);
NotifyScreenDisconnected(screenId);
TLOGI(WmsLogTag::DMS, "DestroyVirtualScreen success, id: %{public}" PRIu64"", screenId);
screenSessionMap_.erase(screenId);
}
NotifyScreenDisconnected(screenId);
TLOGI(WmsLogTag::DMS, "DestroyVirtualScreen success, id: %{public}" PRIu64"", screenId);
}
screenIdManager_.DeleteScreenId(screenId);
virtualScreenCount_ = virtualScreenCount_ > 0 ? virtualScreenCount_ - 1 : 0;
@ -3549,15 +3761,12 @@ sptr<ScreenSessionGroup> ScreenSessionManager::AddAsFirstScreenLocked(sptr<Scree
if (isExpandCombination_) {
screenGroup = new(std::nothrow) ScreenSessionGroup(smsGroupScreenId,
SCREEN_ID_INVALID, name, ScreenCombination::SCREEN_EXPAND);
newScreen->SetScreenCombination(ScreenCombination::SCREEN_EXPAND);
} else if (isUnique) {
screenGroup = new(std::nothrow) ScreenSessionGroup(smsGroupScreenId,
SCREEN_ID_INVALID, name, ScreenCombination::SCREEN_UNIQUE);
newScreen->SetScreenCombination(ScreenCombination::SCREEN_UNIQUE);
} else {
screenGroup = new(std::nothrow) ScreenSessionGroup(smsGroupScreenId,
SCREEN_ID_INVALID, name, ScreenCombination::SCREEN_MIRROR);
newScreen->SetScreenCombination(ScreenCombination::SCREEN_MIRROR);
}
if (screenGroup == nullptr) {
TLOGE(WmsLogTag::DMS, "new ScreenSessionGroup failed");
@ -5031,7 +5240,7 @@ void ScreenSessionManager::ScbStatusRecoveryWhenSwitchUser(std::vector<int32_t>
auto task = [=] {
clientProxy_->SwitchUserCallback(oldScbPids, newScbPid);
};
taskScheduler_->PostAsyncTask(task, "ProxyForUnFreeze NotifyDisplayChanged", delayTime);
taskScheduler_->PostAsyncTask(task, "clientProxy_ SwitchUserCallback task", delayTime);
}
void ScreenSessionManager::SetClient(const sptr<IScreenSessionManagerClient>& client)
@ -5252,7 +5461,11 @@ void ScreenSessionManager::NotifyAvailableAreaChanged(DMRect area)
return;
}
for (auto& agent : agents) {
agent->NotifyAvailableAreaChanged(area);
int32_t agentPid = dmAgentContainer_.GetAgentPid(agent);
if (!IsFreezed(agentPid,
DisplayManagerAgentType::AVAILABLE_AREA_CHANGED_LISTENER)) {
agent->NotifyAvailableAreaChanged(area);
}
}
}
@ -5470,7 +5683,7 @@ void ScreenSessionManager::SetVirtualScreenBlackList(ScreenId screenId, std::vec
return;
}
std::vector<uint64_t> surfaceNodeIds;
clientProxy_->OnGetSurfaceNodeIdsFromMissionIdsChanged(windowIdList, surfaceNodeIds);
clientProxy_->OnGetSurfaceNodeIdsFromMissionIdsChanged(windowIdList, surfaceNodeIds, true);
rsInterface_.SetVirtualScreenBlackList(rsScreenId, surfaceNodeIds);
}

View File

@ -158,113 +158,6 @@ 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

@ -24,6 +24,13 @@ sptr<SettingObserver> ScreenSettingHelper::dpiObserver_;
sptr<SettingObserver> ScreenSettingHelper::extendDpiObserver_;
sptr<SettingObserver> ScreenSettingHelper::castObserver_;
sptr<SettingObserver> ScreenSettingHelper::rotationObserver_;
constexpr int32_t PARAM_NUM_TEN = 10;
constexpr int32_t EXPECT_SCREEN_MODE_SIZE = 2;
constexpr int32_t EXPECT_RELATIVE_POSITION_SIZE = 3;
constexpr int32_t EXPECT_RESOLUTION_SIZE = 3;
constexpr int32_t RESOLVED_DATA_INDEX_ZERO = 0;
constexpr int32_t RESOLVED_DATA_INDEX_ONE = 1;
constexpr int32_t RESOLVED_DATA_INDEX_TWO = 2;
void ScreenSettingHelper::RegisterSettingDpiObserver(SettingObserver::UpdateFunc func)
{
@ -226,5 +233,217 @@ bool ScreenSettingHelper::GetSettingRotationScreenID(int32_t& screenId, const st
TLOGE(WmsLogTag::DMS, "current rotation screen id:%{public}d", screenId);
return true;
}
void ScreenSettingHelper::RemoveInvalidChar(std::string& dataStr, const std::string& inputString)
{
for (char character : inputString) {
if (!std::isdigit(character) && character != ' ' && character != ',' && character != '.') {
continue;
}
dataStr += character;
}
TLOGI(WmsLogTag::DMS, "process done, dataStr: %{public}s", dataStr.c_str());
}
bool ScreenSettingHelper::SplitString(std::vector<std::string>& splitValues, const std::string& inputString)
{
TLOGI(WmsLogTag::DMS, "input value: %{public}s", inputString.c_str());
std::string dataStr;
RemoveInvalidChar(dataStr, inputString);
int32_t strLength = dataStr.size();
int32_t beginIdx = 0;
std::string currentValue;
for (int32_t currentIdx = 0; currentIdx < strLength; currentIdx++) {
if (dataStr[currentIdx] != ',') {
continue;
}
currentValue = dataStr.substr(beginIdx, currentIdx - beginIdx);
if (currentValue.size() > 0) {
splitValues.push_back(currentValue);
TLOGI(WmsLogTag::DMS, "resolving current value success, currentValue: %{public}s",
currentValue.c_str());
}
beginIdx = currentIdx + 1;
}
currentValue = dataStr.substr(beginIdx, strLength - beginIdx);
if (currentValue.size() > 0) {
splitValues.push_back(currentValue);
TLOGI(WmsLogTag::DMS, "resolving current value success, currentValue: %{public}s",
currentValue.c_str());
}
if (splitValues.size() == 0) {
TLOGE(WmsLogTag::DMS, "resolving split values failed");
return false;
}
return true;
}
int32_t ScreenSettingHelper::GetDataFromString(std::vector<uint64_t>& datas, const std::string& inputString)
{
TLOGI(WmsLogTag::DMS, "begin to resolve string, value: %{public}s", inputString.c_str());
int32_t strLength = inputString.size();
int32_t beginIdx = 0;
for (int32_t currentIdx = 0; currentIdx < strLength; currentIdx++) {
if (inputString[currentIdx] != ' ') {
continue;
}
std::string dataStr = inputString.substr(beginIdx, currentIdx - beginIdx);
if (dataStr.size() > 0) {
uint64_t data = static_cast<uint64_t>(strtoll(dataStr.c_str(), nullptr, PARAM_NUM_TEN));
datas.push_back(data);
TLOGI(WmsLogTag::DMS, "resolving data success, data: %{public}d", static_cast<uint32_t>(data));
}
beginIdx = currentIdx + 1;
}
std::string dataStr = inputString.substr(beginIdx, strLength - beginIdx);
if (dataStr.size() > 0) {
uint64_t data = static_cast<uint64_t>(strtoll(dataStr.c_str(), nullptr, PARAM_NUM_TEN));
datas.push_back(data);
TLOGI(WmsLogTag::DMS, "resolving data success, data: %{public}d", static_cast<uint32_t>(data));
}
return datas.size();
}
bool ScreenSettingHelper::GetSettingRecoveryResolutionString(std::vector<std::string>& resolutionString,
const std::string& key)
{
std::string value;
SettingProvider& settingProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID);
ErrCode ret = settingProvider.GetStringValue(key, value);
if (ret != ERR_OK) {
TLOGE(WmsLogTag::DMS, "get setting recovery resolution failed, ret=%{public}d", ret);
return false;
}
bool ret1 = SplitString(resolutionString, value);
if (!ret1) {
TLOGE(WmsLogTag::DMS, "resolving resolution string failed");
return false;
}
return true;
}
bool ScreenSettingHelper::GetSettingRecoveryResolutionMap
(std::map<uint64_t, std::pair<int32_t, int32_t>>& resolution)
{
std::vector<std::string> resolutionStrings;
bool ret = GetSettingRecoveryResolutionString(resolutionStrings);
if (!ret) {
TLOGE(WmsLogTag::DMS, "get resolution string failed");
return false;
}
for (auto& resolutionString : resolutionStrings) {
std::vector<uint64_t> resolutionData;
int32_t dataSize = GetDataFromString(resolutionData, resolutionString);
if (dataSize != EXPECT_RESOLUTION_SIZE) {
TLOGE(WmsLogTag::DMS, "get data failed");
continue;
}
uint64_t screenId = resolutionData[RESOLVED_DATA_INDEX_ZERO];
int32_t width = static_cast<int32_t>(resolutionData[RESOLVED_DATA_INDEX_ONE]);
int32_t height = static_cast<int32_t>(resolutionData[RESOLVED_DATA_INDEX_TWO]);
TLOGI(WmsLogTag::DMS, "get data success, screenId: %{public}d, width: %{public}d, height: %{public}d",
static_cast<uint32_t>(screenId), width, height);
resolution[screenId] = std::make_pair(width, height);
}
if (resolution.empty()) {
TLOGE(WmsLogTag::DMS, "no resolution found");
return false;
}
return true;
}
bool ScreenSettingHelper::GetSettingScreenModeString(std::vector<std::string>& screenModeStrings,
const std::string& key)
{
std::string value;
SettingProvider& settingProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID);
ErrCode ret = settingProvider.GetStringValue(key, value);
if (ret != ERR_OK) {
TLOGE(WmsLogTag::DMS, "get setting screen mode failed, ret=%{public}d", ret);
return false;
}
bool ret1 = SplitString(screenModeStrings, value);
if (!ret1) {
TLOGE(WmsLogTag::DMS, "resolving screen mode failed");
return false;
}
return true;
}
bool ScreenSettingHelper::GetSettingScreenModeMap(std::map<uint64_t, uint32_t>& screenMode)
{
std::vector<std::string> screenModeStrings;
bool ret = GetSettingScreenModeString(screenModeStrings);
if (!ret) {
TLOGE(WmsLogTag::DMS, "get last screen mode string failed");
return false;
}
for (auto& screenModeString : screenModeStrings) {
std::vector<uint64_t> screenModeData;
int32_t dataSize = GetDataFromString(screenModeData, screenModeString);
if (dataSize != EXPECT_SCREEN_MODE_SIZE) {
TLOGE(WmsLogTag::DMS, "get data failed");
continue;
}
uint64_t screenId = screenModeData[RESOLVED_DATA_INDEX_ZERO];
uint32_t mode = static_cast<int32_t>(screenModeData[RESOLVED_DATA_INDEX_ONE]);
TLOGI(WmsLogTag::DMS, "get data success, screenId: %{public}d, mode: %{public}d",
static_cast<uint32_t>(screenId), mode);
screenMode[screenId] = mode;
}
if (screenMode.empty()) {
TLOGE(WmsLogTag::DMS, "no last screen mode found");
return false;
}
return true;
}
bool ScreenSettingHelper::GetSettingRelativePositionString(std::vector<std::string>& relativePositionStrings,
const std::string& key)
{
std::string value;
SettingProvider& settingProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID);
ErrCode ret = settingProvider.GetStringValue(key, value);
if (ret != ERR_OK) {
TLOGE(WmsLogTag::DMS, "get setting relative position failed, ret=%{public}d", ret);
return false;
}
bool ret1 = SplitString(relativePositionStrings, value);
if (!ret1) {
TLOGE(WmsLogTag::DMS, "resolving relative position failed");
return false;
}
return true;
}
bool ScreenSettingHelper::GetSettingRelativePositionMap
(std::map<uint64_t, std::pair<uint32_t, uint32_t>>& relativePosition)
{
std::vector<std::string> relativePositionStrings;
bool ret = GetSettingRelativePositionString(relativePositionStrings);
if (!ret) {
TLOGE(WmsLogTag::DMS, "get relative position string failed");
return false;
}
for (auto& relativePositionString : relativePositionStrings) {
std::vector<uint64_t> relativePositionData;
int32_t dataSize = GetDataFromString(relativePositionData, relativePositionString);
if (dataSize != EXPECT_RELATIVE_POSITION_SIZE) {
TLOGE(WmsLogTag::DMS, "get data failed");
continue;
}
uint64_t screenId = relativePositionData[RESOLVED_DATA_INDEX_ZERO];
uint32_t startX = static_cast<uint32_t>(relativePositionData[RESOLVED_DATA_INDEX_ONE]);
uint32_t startY = static_cast<uint32_t>(relativePositionData[RESOLVED_DATA_INDEX_TWO]);
TLOGI(WmsLogTag::DMS, "get data success, screenId: %{public}d, startX: %{public}d, startY: %{public}d",
static_cast<uint32_t>(screenId), startX, startY);
relativePosition[screenId] = std::make_pair(startX, startY);
}
if (relativePosition.empty()) {
TLOGE(WmsLogTag::DMS, "no relative position found");
return false;
}
return true;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -289,342 +289,4 @@ 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,80 +35,42 @@ 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);
@ -197,109 +159,4 @@ 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

@ -135,6 +135,17 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
reply.WriteBool(TryToCancelScreenOff());
break;
}
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_BRIGHTNESS: {
uint64_t screenId = data.ReadUint64();
uint32_t level = data.ReadUint64();
reply.WriteBool(SetScreenBrightness(screenId, level));
break;
}
case DisplayManagerMessage::TRANS_ID_GET_SCREEN_BRIGHTNESS: {
uint64_t screenId = data.ReadUint64();
reply.WriteUint32(GetScreenBrightness(screenId));
break;
}
case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID: {
DisplayId displayId = data.ReadUint64();
auto info = GetDisplayInfoById(displayId);

View File

@ -63,7 +63,7 @@ public:
void OnScreenshot(DisplayId displayId) override;
void OnImmersiveStateChanged(ScreenId screenId, bool& immersive) override;
void OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t>& missionIds,
std::vector<uint64_t>& surfaceNodeIds) override;
std::vector<uint64_t>& surfaceNodeIds, bool isBlackList = false) override;
void OnUpdateFoldDisplayMode(FoldDisplayMode displayMode) override;
void UpdateAvailableArea(ScreenId screenId, DMRect area);
int32_t SetScreenOffDelayTime(int32_t delay);

View File

@ -66,7 +66,7 @@ public:
virtual void OnImmersiveStateChanged(ScreenId screenId, bool& immersive) = 0;
virtual void SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId) = 0;
virtual void OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t>& missionIds,
std::vector<uint64_t>& surfaceNodeIds) = 0;
std::vector<uint64_t>& surfaceNodeIds, bool isBlackList = false) = 0;
virtual void OnUpdateFoldDisplayMode(FoldDisplayMode displayMode) = 0;
virtual void SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) = 0;
virtual void OnFoldStatusChangedReportUE(const std::vector<std::string>& screenFoldInfo) = 0;

View File

@ -45,7 +45,7 @@ public:
void OnImmersiveStateChanged(ScreenId screenId, bool& immersive) override;
void SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId) override;
void OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t>& missionIds,
std::vector<uint64_t>& surfaceNodeIds) override;
std::vector<uint64_t>& surfaceNodeIds, bool isBlackList = false) override;
void OnUpdateFoldDisplayMode(FoldDisplayMode displayMode) override;
void SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) override;
void OnFoldStatusChangedReportUE(const std::vector<std::string>& screenFoldInfo) override;

View File

@ -261,10 +261,10 @@ void ScreenSessionManagerClient::OnUpdateFoldDisplayMode(FoldDisplayMode display
}
void ScreenSessionManagerClient::OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t>& missionIds,
std::vector<uint64_t>& surfaceNodeIds)
std::vector<uint64_t>& surfaceNodeIds, bool isBlackList)
{
if (displayChangeListener_) {
displayChangeListener_->OnGetSurfaceNodeIdsFromMissionIds(missionIds, surfaceNodeIds);
displayChangeListener_->OnGetSurfaceNodeIdsFromMissionIds(missionIds, surfaceNodeIds, isBlackList);
}
}
@ -320,6 +320,8 @@ void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId,
return;
}
auto foldDisplayMode = screenSessionManager_->GetFoldDisplayMode();
auto foldStatus = screenSessionManager_->GetFoldStatus();
screenSession->SetPhysicalRotation(rotation, foldStatus);
screenSession->UpdateToInputManager(bounds, rotation, foldDisplayMode);
}

View File

@ -374,7 +374,7 @@ void ScreenSessionManagerClientProxy::OnDisplayStateChanged(DisplayId defaultDis
}
void ScreenSessionManagerClientProxy::OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t>& missionIds,
std::vector<uint64_t>& surfaceNodeIds)
std::vector<uint64_t>& surfaceNodeIds, bool isBlackList)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
@ -397,6 +397,10 @@ void ScreenSessionManagerClientProxy::OnGetSurfaceNodeIdsFromMissionIdsChanged(s
WLOGFE("Write surfaceNodeIds failed");
return;
}
if (!data.WriteBool(isBlackList)) {
WLOGFE("Write isBlackList failed");
return;
}
if (remote->SendRequest(static_cast<uint32_t>(
ScreenSessionManagerClientMessage::TRANS_ID_GET_SURFACENODEID_FROM_MISSIONID),
data, reply, option) != ERR_NONE) {

View File

@ -205,7 +205,8 @@ int ScreenSessionManagerClientStub::HandleOnGetSurfaceNodeIdsFromMissionIdsChang
data.ReadUInt64Vector(&missionIds);
std::vector<uint64_t> surfaceNodeIds;
data.ReadUInt64Vector(&surfaceNodeIds);
OnGetSurfaceNodeIdsFromMissionIdsChanged(missionIds, surfaceNodeIds);
bool isBlackList = data.ReadBool();
OnGetSurfaceNodeIdsFromMissionIdsChanged(missionIds, surfaceNodeIds, isBlackList);
if (!reply.WriteUInt64Vector(surfaceNodeIds)) {
WLOGFE("Write surfaceNodeIds failed");
return ERR_TRANSACTION_FAILED;

View File

@ -52,6 +52,7 @@ public:
void OpenKeyboardSyncTransaction() override;
void CloseKeyboardSyncTransaction(const WSRect& keyboardPanelRect, bool isKeyboardShow, bool isRotating) override;
bool IsVisibleForeground() const override;
uint32_t GetCallingSessionId() override;
private:
sptr<SceneSession> GetSceneSession(uint32_t persistentId);
@ -59,7 +60,6 @@ private:
WSError SetKeyboardSessionGravity(SessionGravity gravity, uint32_t percent) override;
void SetCallingSessionId(uint32_t callingSessionId) override;
uint32_t GetCallingSessionId();
void NotifyOccupiedAreaChangeInfo(const sptr<SceneSession>& callingSession, const WSRect& rect,
const WSRect& occupiedArea, const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);

View File

@ -18,7 +18,7 @@
#include <bitset>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <string>
#include <shared_mutex>
#include <vector>
@ -37,6 +37,7 @@ static constexpr uint32_t MAX_INSTANCE_COUNT = 10;
class MultiInstanceManager {
public:
static MultiInstanceManager& GetInstance();
static bool IsSupportMultiInstance(const SystemSessionConfig& systemConfig);
void Init(const sptr<AppExecFwk::IBundleMgr>& bundleMgr, const std::shared_ptr<TaskScheduler>& taskScheduler);
void IncreaseInstanceKeyRefCount(const sptr<SceneSession>& sceneSession);
void DecreaseInstanceKeyRefCount(const sptr<SceneSession>& sceneSession);
@ -59,20 +60,27 @@ public:
bool IsInstanceKeyExist(const std::string& bundleName, const std::string& instanceKey);
private:
uint32_t FindMinimumAvailableInstanceId(const std::string& bundleName, uint32_t maxInstanceCount) const;
uint32_t FindMinimumAvailableInstanceId(const std::string& bundleName, uint32_t maxInstanceCount);
void RemoveInstanceKey(const std::string& bundleName, const std::string& instanceKey);
void AddInstanceId(const std::string& bundleName, uint32_t instanceId);
void RemoveInstanceId(const std::string& bundleName, uint32_t instanceId);
bool ConvertInstanceKeyToInstanceId(const std::string& instanceKey, uint32_t& instanceId) const;
std::map<std::string, std::vector<uint32_t>> bundleInstanceIdListMap_;
std::map<std::string, std::bitset<MAX_INSTANCE_COUNT>> bundleInstanceUsageMap_;
std::map<std::string, AppExecFwk::ApplicationInfo> appInfoMap_;
std::map<std::string, int32_t> instanceKeyRefCountMap_;
std::shared_mutex mutex_;
std::unordered_map<std::string, std::vector<uint32_t>> bundleInstanceIdListMap_;
std::unordered_map<std::string, std::bitset<MAX_INSTANCE_COUNT>> bundleInstanceUsageMap_;
// Above guarded by mutex_
std::shared_mutex appInfoMutex_;
std::unordered_map<std::string, AppExecFwk::ApplicationInfo> appInfoMap_;
// Above guarded by appInfoMutex_
// Guarded by SceneSessionManager sceneSessionMapMutex_
std::unordered_map<std::string, int32_t> instanceKeyRefCountMap_;
sptr<AppExecFwk::IBundleMgr> bundleMgr_;
std::shared_ptr<TaskScheduler> taskScheduler_;
int32_t userId_ = 0;
std::shared_mutex mutex_;
std::shared_mutex appInfoMutex_;
};
} // namespace OHOS::Rosen

View File

@ -32,6 +32,7 @@ const std::string PARAM_DMS_PERSISTENT_ID_KEY = "ohos.dms.persistentId";
}
class SceneSession;
using SpecificSessionCreateCallback =
std::function<sptr<SceneSession>(const SessionInfo& info, sptr<WindowSessionProperty> property)>;
using SpecificSessionDestroyCallback = std::function<WSError(const int32_t& persistentId)>;
@ -170,6 +171,7 @@ public:
virtual SessionGravity GetKeyboardGravity() const { return SessionGravity::SESSION_GRAVITY_DEFAULT; };
virtual void OnKeyboardPanelUpdated() {};
virtual void OnCallingSessionUpdated() {};
virtual uint32_t GetCallingSessionId() { return INVALID_SESSION_ID; };
bool GetScreenWidthAndHeightFromServer(const sptr<WindowSessionProperty>& sessionProperty,
uint32_t& screenWidth, uint32_t& screenHeight);
bool GetScreenWidthAndHeightFromClient(const sptr<WindowSessionProperty>& sessionProperty,
@ -456,7 +458,12 @@ public:
bool IsMinimizedByUserSwitch() const;
void UnregisterSessionChangeListeners() override;
void SetVisibilityChangedDetectFunc(const VisibilityChangedDetectFunc& func);
/*
* Window ZOrder: PC
*/
void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel; }
void PcUpdateZOrderAndDirty(const uint32_t zOrder);
void SetPrivacyModeChangeNotifyFunc(const NotifyPrivacyModeChangeFunc& func);
@ -527,6 +534,12 @@ private:
void HandleStyleEvent(MMI::WindowArea area) override;
WSError HandleEnterWinwdowArea(int32_t windowX, int32_t windowY);
/*
* Window Lifecycle
*/
bool CheckIdentityTokenIfMatched(const std::string& identityToken);
bool CheckPidIfMatched();
// session lifecycle funcs
WSError ForegroundTask(const sptr<WindowSessionProperty>& property);
@ -670,14 +683,14 @@ private:
int32_t customDecorHeight_ = 0;
ForceHideState forceHideState_ { ForceHideState::NOT_HIDDEN };
std::string clientIdentityToken_ = { "" };
SessionChangeByActionNotifyManagerFunc sessionChangeByActionNotifyManagerFunc_;
int32_t oriPosYBeforeRaisedByKeyboard_ = 0;
std::atomic_bool isTemporarilyShowWhenLocked_ { false };
std::shared_mutex modalUIExtensionInfoListMutex_;
std::vector<ExtensionWindowEventInfo> modalUIExtensionInfoList_;
mutable std::shared_mutex uiExtNodeIdToPersistentIdMapMutex_;
std::map<uint64_t, int32_t> uiExtNodeIdToPersistentIdMap_;
std::string clientIdentityToken_ = { "" };
SessionChangeByActionNotifyManagerFunc sessionChangeByActionNotifyManagerFunc_;
bool isAddBlank_ = false;
bool bufferAvailableCallbackEnable_ = false;

View File

@ -195,6 +195,7 @@ public:
void SetSessionInfoTime(const std::string& time);
void SetSessionInfoAbilityInfo(const std::shared_ptr<AppExecFwk::AbilityInfo>& abilityInfo);
void SetSessionInfoWant(const std::shared_ptr<AAFwk::Want>& want);
void SetSessionInfoProcessOptions(const std::shared_ptr<AAFwk::ProcessOptions>& processOptions);
void ResetSessionInfoResultCode();
void SetSessionInfoPersistentId(int32_t persistentId);
void SetSessionInfoCallerPersistentId(int32_t callerPersistentId);

View File

@ -499,7 +499,7 @@ void KeyboardSession::UpdateCallingSessionIdAndPosition(uint32_t callingSessionI
TLOGE(WmsLogTag::WMS_KEYBOARD, "Session property is nullptr");
return;
}
uint32_t curSessionId = sessionProperty->GetCallingSessionId();
uint32_t curSessionId = GetCallingSessionId();
// When calling window id changes, restore the old calling session, raise the new calling session.
if (curSessionId != INVALID_WINDOW_ID && callingSessionId != curSessionId && IsSessionForeground()) {
TLOGI(WmsLogTag::WMS_KEYBOARD, "curId: %{public}d, newId: %{public}d", curSessionId, callingSessionId);

View File

@ -31,6 +31,11 @@ MultiInstanceManager& MultiInstanceManager::GetInstance()
return instance;
}
bool MultiInstanceManager::IsSupportMultiInstance(const SystemSessionConfig& systemConfig)
{
return systemConfig.IsPcWindow();
}
void MultiInstanceManager::Init(const sptr<AppExecFwk::IBundleMgr>& bundleMgr,
const std::shared_ptr<TaskScheduler>& taskScheduler)
{
@ -98,7 +103,10 @@ uint32_t MultiInstanceManager::GetMaxInstanceCount(const std::string& bundleName
TLOGE(WmsLogTag::WMS_LIFE, "App info not found, bundleName:%{public}s", bundleName.c_str());
return 0u;
}
return iter->second.multiAppMode.maxCount;
if (iter->second.multiAppMode.multiAppModeType == AppExecFwk::MultiAppModeType::MULTI_INSTANCE) {
return iter->second.multiAppMode.maxCount;
}
return 0u;
}
uint32_t MultiInstanceManager::GetInstanceCount(const std::string& bundleName)
@ -191,8 +199,9 @@ void MultiInstanceManager::RemoveInstanceKey(const std::string& bundleName, cons
}
uint32_t MultiInstanceManager::FindMinimumAvailableInstanceId(const std::string& bundleName,
uint32_t maxInstanceCount) const
uint32_t maxInstanceCount)
{
std::shared_lock<std::shared_mutex> lock(mutex_);
auto iter = bundleInstanceUsageMap_.find(bundleName);
if (iter == bundleInstanceUsageMap_.end()) {
TLOGE(WmsLogTag::WMS_LIFE, "not found available instanceId");

View File

@ -110,14 +110,11 @@ WSError SceneSession::ConnectInner(const sptr<ISessionStage>& sessionStage,
TLOGE(WmsLogTag::WMS_LIFE, "session is null");
return WSError::WS_ERROR_DESTROYED_OBJECT;
}
if (SessionHelper::IsMainWindow(session->GetWindowType()) && !identityToken.empty() &&
!session->clientIdentityToken_.empty() && identityToken != session->clientIdentityToken_) {
TLOGW(WmsLogTag::WMS_LIFE,
"Identity Token vaildate failed, clientIdentityToken: %{public}s, "
"identityToken: %{public}s, bundleName: %{public}s",
session->clientIdentityToken_.c_str(), identityToken.c_str(),
session->GetSessionInfo().bundleName_.c_str());
return WSError::WS_OK;
if (SessionHelper::IsMainWindow(session->GetWindowType())) {
if (!session->CheckIdentityTokenIfMatched(identityToken)) {
TLOGNW(WmsLogTag::WMS_LIFE, "check failed");
return WSError::WS_OK;
}
}
if (property) {
property->SetCollaboratorType(session->GetCollaboratorType());
@ -225,13 +222,11 @@ WSError SceneSession::Foreground(
}
}
if (isFromClient && SessionHelper::IsMainWindow(GetWindowType()) && !identityToken.empty() &&
!clientIdentityToken_.empty() && identityToken != clientIdentityToken_) {
TLOGW(WmsLogTag::WMS_LIFE,
"Foreground Identity Token vaildate failed, clientIdentityToken: %{public}s, "
"identityToken: %{public}s, bundleName: %{public}s",
clientIdentityToken_.c_str(), identityToken.c_str(), GetSessionInfo().bundleName_.c_str());
return WSError::WS_OK;
if (isFromClient && SessionHelper::IsMainWindow(GetWindowType())) {
if (!CheckPidIfMatched() || !CheckIdentityTokenIfMatched(identityToken)) {
TLOGW(WmsLogTag::WMS_LIFE, "check failed");
return WSError::WS_OK;
}
}
return ForegroundTask(property);
}
@ -286,15 +281,12 @@ WSError SceneSession::Background(bool isFromClient, const std::string& identityT
return WSError::WS_ERROR_NOT_SYSTEM_APP;
}
if (isFromClient && SessionHelper::IsMainWindow(GetWindowType()) && !identityToken.empty() &&
!clientIdentityToken_.empty() && identityToken != clientIdentityToken_) {
TLOGW(WmsLogTag::WMS_LIFE,
"Background Identity Token vaildate failed, clientIdentityToken: %{public}s, "
"identityToken: %{public}s, bundleName: %{public}s",
clientIdentityToken_.c_str(), identityToken.c_str(), GetSessionInfo().bundleName_.c_str());
return WSError::WS_OK;
if (isFromClient && SessionHelper::IsMainWindow(GetWindowType())) {
if (!CheckPidIfMatched() || !CheckIdentityTokenIfMatched(identityToken)) {
TLOGW(WmsLogTag::WMS_LIFE, "check failed");
return WSError::WS_OK;
}
}
return BackgroundTask(true);
}
@ -381,15 +373,12 @@ void SceneSession::ClearJsSceneSessionCbMap(bool needRemove)
WSError SceneSession::Disconnect(bool isFromClient, const std::string& identityToken)
{
if (isFromClient && SessionHelper::IsMainWindow(GetWindowType()) && !identityToken.empty() &&
!clientIdentityToken_.empty() && identityToken != clientIdentityToken_) {
TLOGW(WmsLogTag::WMS_LIFE,
"Disconnect Identity Token vaildate failed, clientIdentityToken: %{public}s, "
"identityToken: %{public}s, bundleName: %{public}s",
clientIdentityToken_.c_str(), identityToken.c_str(), GetSessionInfo().bundleName_.c_str());
return WSError::WS_OK;
if (isFromClient && SessionHelper::IsMainWindow(GetWindowType())) {
if (!CheckPidIfMatched() || !CheckIdentityTokenIfMatched(identityToken)) {
TLOGW(WmsLogTag::WMS_LIFE, "check failed");
return WSError::WS_OK;
}
}
return DisconnectTask(isFromClient, true);
}
@ -781,7 +770,7 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason,
}
if (session->winRect_ == rect && session->reason_ != SizeChangeReason::DRAG_END &&
(session->GetWindowType() != WindowType::WINDOW_TYPE_KEYBOARD_PANEL &&
session->GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT)) {
session->GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT)) {
if (!session->sessionStage_) {
TLOGD(WmsLogTag::WMS_LAYOUT, "skip same rect update id:%{public}d rect:%{public}s",
session->GetPersistentId(), rect.ToString().c_str());
@ -2020,7 +2009,8 @@ WSError SceneSession::TransferPointerEvent(const std::shared_ptr<MMI::PointerEve
}
if ((property->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING && property->GetDragEnabled())
|| isDragEnabledSystemWindow) {
if ((systemConfig_.IsPcWindow() || IsFreeMultiWindowMode() || property->GetIsPcAppInPad()) &&
if ((systemConfig_.IsPcWindow() || IsFreeMultiWindowMode() ||
(property->GetIsPcAppInPad() && !isMainWindow)) &&
moveDragController_->ConsumeDragEvent(pointerEvent, winRect_, property, systemConfig_)) {
moveDragController_->UpdateGravityWhenDrag(pointerEvent, surfaceNode_);
PresentFoucusIfNeed(pointerEvent->GetPointerAction());
@ -2389,7 +2379,7 @@ void SceneSession::HandleMoveDrag(WSRect& rect, WSRect& globalRect, const SizeCh
void SceneSession::HandleMoveDragEnd(WSRect& rect, const SizeChangeReason reason)
{
if (GetOriPosYBeforeRaisedByKeyboard() != 0) {
TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling session is moved and reset oriPosYBeforeRaisedBykeyboard");
TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling session is moved and reset oriPosYBeforeRaisedByKeyboard");
SetOriPosYBeforeRaisedByKeyboard(0);
}
if (moveDragController_->GetMoveDragEndDisplayId() == moveDragController_->GetMoveDragStartDisplayId() ||
@ -2525,6 +2515,7 @@ void SceneSession::SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool need
rsTransaction->Begin();
}
auto leashWinSurfaceNode = GetLeashWinSurfaceNode();
auto property = GetSessionProperty();
if (surfaceNode_ && leashWinSurfaceNode) {
leashWinSurfaceNode->SetGlobalPositionEnabled(isGlobal);
leashWinSurfaceNode->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
@ -2546,8 +2537,9 @@ void SceneSession::SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool need
surfaceNode_->SetGlobalPositionEnabled(isGlobal);
surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
surfaceNode_->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
} else if (WindowHelper::IsSystemWindow(GetWindowType()) && surfaceNode_) {
TLOGD(WmsLogTag::WMS_SYSTEM, "systemwindow setSurfaceBounds");
} else if (WindowHelper::IsSystemWindow(GetWindowType()) &&
property && property->GetDragEnabled() && surfaceNode_) {
TLOGD(WmsLogTag::WMS_SYSTEM, "drag enabled systemwindow setSurfaceBounds");
surfaceNode_->SetGlobalPositionEnabled(isGlobal);
surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
surfaceNode_->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
@ -3341,6 +3333,7 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptr<AAFwk::Sess
info.isBackTransition_ = abilitySessionInfo->isBackTransition;
info.needClearInNotShowRecent_ = abilitySessionInfo->needClearInNotShowRecent;
info.appInstanceKey_ = abilitySessionInfo->instanceKey;
info.isFromIcon_ = abilitySessionInfo->isFromIcon;
if (session->IsPcOrPadEnableActivation()) {
info.startWindowOption = abilitySessionInfo->startWindowOption;
}
@ -3356,11 +3349,12 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptr<AAFwk::Sess
TLOGI(WmsLogTag::WMS_LIFE, "bundleName:%{public}s, moduleName:%{public}s, "
"abilityName:%{public}s, appIndex:%{public}d, affinity:%{public}s. "
"callState:%{public}d, want persistentId:%{public}d, "
"uiAbilityId:%{public}" PRIu64 ", windowMode:%{public}d, callerId: %{public}d "
"needClearInNotShowRecent:%{public}u, appInstanceKey: %{public}s",
"uiAbilityId:%{public}" PRIu64 ", windowMode:%{public}d, callerId:%{public}d "
"needClearInNotShowRecent:%{public}u, appInstanceKey: %{public}s, isFromIcon:%{public}d",
info.bundleName_.c_str(), info.moduleName_.c_str(), info.abilityName_.c_str(), info.appIndex_,
info.sessionAffinity.c_str(), info.callState_, info.persistentId_, info.uiAbilityId_,
info.windowMode, info.callerPersistentId_, info.needClearInNotShowRecent_, info.appInstanceKey_.c_str());
info.windowMode, info.callerPersistentId_, info.needClearInNotShowRecent_, info.appInstanceKey_.c_str(),
info.isFromIcon_);
return info;
}
@ -3400,7 +3394,7 @@ WSError SceneSession::PendingSessionActivation(const sptr<AAFwk::SessionInfo> ab
}
session->sessionInfo_.startMethod = StartMethod::START_CALL;
SessionInfo info = MakeSessionInfoDuringPendingActivation(abilitySessionInfo, session);
if (session->systemConfig_.IsPcWindow() &&
if (MultiInstanceManager::IsSupportMultiInstance(session->systemConfig_) &&
MultiInstanceManager::GetInstance().IsMultiInstance(session->GetSessionInfo().bundleName_)) {
if (!MultiInstanceManager::GetInstance().MultiInstancePendingSessionActivation(info)) {
TLOGE(WmsLogTag::WMS_LIFE, "multi instance start fail, id:%{public}d instanceKey:%{public}s",
@ -4816,6 +4810,11 @@ bool SceneSession::CheckPermissionWithPropertyAnimation(const sptr<WindowSession
return true;
}
void SceneSession::PcUpdateZOrderAndDirty(const uint32_t zOrder)
{
dirtyFlags_ |= UpdateZOrderInner(zOrder) ? static_cast<uint32_t>(SessionUIDirtyFlag::Z_ORDER) : 0;
}
uint32_t SceneSession::UpdateUIParam(const SessionUIParam& uiParam)
{
bool lastVisible = IsVisible();
@ -5129,4 +5128,27 @@ void SceneSession::UpdateGestureBackEnabled()
specificCallback_->onUpdateGestureBackEnabled_(GetPersistentId());
}
}
bool SceneSession::CheckIdentityTokenIfMatched(const std::string& identityToken)
{
if (!identityToken.empty() && !clientIdentityToken_.empty() && identityToken != clientIdentityToken_) {
TLOGW(WmsLogTag::WMS_LIFE,
"failed, clientIdentityToken: %{public}s, identityToken: %{public}s, bundleName: %{public}s",
clientIdentityToken_.c_str(), identityToken.c_str(), GetSessionInfo().bundleName_.c_str());
return false;
}
return true;
}
bool SceneSession::CheckPidIfMatched()
{
int32_t callingPid = IPCSkeleton::GetCallingPid();
if (callingPid != -1 && callingPid != GetCallingPid()) {
TLOGW(WmsLogTag::WMS_LIFE,
"failed, callingPid_: %{public}d, callingPid: %{public}d, bundleName: %{public}s",
GetCallingPid(), callingPid, GetSessionInfo().bundleName_.c_str());
return false;
}
return true;
}
} // namespace OHOS::Rosen

View File

@ -217,6 +217,12 @@ void Session::SetSessionInfoWant(const std::shared_ptr<AAFwk::Want>& want)
sessionInfo_.want = want;
}
void Session::SetSessionInfoProcessOptions(const std::shared_ptr<AAFwk::ProcessOptions>& processOptions)
{
std::lock_guard<std::recursive_mutex> lock(sessionInfoMutex_);
sessionInfo_.processOptions = processOptions;
}
void Session::ResetSessionInfoResultCode()
{
std::lock_guard<std::recursive_mutex> lock(sessionInfoMutex_);
@ -482,6 +488,14 @@ void Session::UpdateSessionState(SessionState state)
state == SessionState::STATE_BACKGROUND) {
RemoveWindowDetectTask();
}
/* The state will be set background first when destroy keyboard, there is no need to notify scb if the state is
* already background, which may cause performance deterioration.
*/
if (GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT && state == state_ &&
state == SessionState::STATE_BACKGROUND) {
TLOGI(WmsLogTag::WMS_KEYBOARD, "Keyboard is already hide");
return;
}
state_ = state;
SetMainSessionUIStateDirty(true);
NotifySessionStateChange(state);
@ -1057,10 +1071,6 @@ void Session::InitSessionPropertyWhenConnect(const sptr<WindowSessionProperty>&
void Session::InitSystemSessionDragEnable(const sptr<WindowSessionProperty>& property)
{
auto defaultDragEnable = false;
auto sessionProperty = GetSessionProperty();
if (sessionProperty) {
defaultDragEnable = sessionProperty->GetDragEnabled();
}
auto isSystemWindow = WindowHelper::IsSystemWindow(property->GetWindowType());
bool isDialog = WindowHelper::IsDialogWindow(property->GetWindowType());
bool isSubWindow = WindowHelper::IsSubWindow(property->GetWindowType());

View File

@ -29,7 +29,6 @@
namespace OHOS::Rosen {
namespace {
constexpr int32_t FFRT_USER_INTERACTIVE_MAX_THREAD_NUM = 5;
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WSFFRTHelper"};
const std::unordered_map<TaskQos, ffrt::qos> FFRT_QOS_MAP = {
{ TaskQos::INHERIT, ffrt_qos_inherit },
@ -84,15 +83,7 @@ private:
std::shared_mutex mutex_;
};
WSFFRTHelper::WSFFRTHelper() : taskHandleMap_(std::make_unique<TaskHandleMap>())
{
static bool firstInit = [] {
int ret = ffrt_set_cpu_worker_max_num(ffrt_qos_user_interactive, FFRT_USER_INTERACTIVE_MAX_THREAD_NUM);
WLOGI("FFRT user interactive qos max thread number = %{public}d, retcode = %{public}d",
FFRT_USER_INTERACTIVE_MAX_THREAD_NUM, ret);
return true;
}();
}
WSFFRTHelper::WSFFRTHelper() : taskHandleMap_(std::make_unique<TaskHandleMap>()) {}
WSFFRTHelper::~WSFFRTHelper() = default;

View File

@ -446,6 +446,10 @@ WSError SessionProxy::PendingSessionActivation(sptr<AAFwk::SessionInfo> abilityS
TLOGE(WmsLogTag::WMS_LIFE, "Write instanceKey failed");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!data.WriteBool(abilitySessionInfo->isFromIcon)) {
TLOGE(WmsLogTag::WMS_LIFE, "Write isFromIcon failed");
return WSError::WS_ERROR_IPC_FAILED;
}
if (abilitySessionInfo->startWindowOption) {
if (!data.WriteBool(true) || !data.WriteParcelable(abilitySessionInfo->startWindowOption.get())) {
TLOGE(WmsLogTag::WMS_LIFE, "Write startWindowOption failed");
@ -671,7 +675,7 @@ WSError SessionProxy::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool
TLOGE(WmsLogTag::WMS_IMMS, "SendRequest failed");
return WSError::WS_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadUint32();
uint32_t ret = reply.ReadUint32();
return static_cast<WSError>(ret);
}
@ -694,7 +698,7 @@ WSError SessionProxy::OnRestoreMainWindow()
TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
return WSError::WS_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadUint32();
uint32_t ret = reply.ReadUint32();
return static_cast<WSError>(ret);
}
@ -894,7 +898,7 @@ WSError SessionProxy::OnNeedAvoid(bool status)
WLOGFE("WriteInterfaceToken failed");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!(data.WriteUint32(static_cast<uint32_t>(status)))) {
if (!data.WriteBool(status)) {
WLOGFE("Write status failed");
return WSError::WS_ERROR_IPC_FAILED;
}
@ -1439,7 +1443,7 @@ WSError SessionProxy::UpdatePiPRect(const Rect& rect, SizeChangeReason reason)
WLOGFE("write height_ failed.");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!data.WriteInt32(static_cast<int32_t>(reason))) {
if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
WLOGFE("reason write failed.");
return WSError::WS_ERROR_IPC_FAILED;
}

View File

@ -602,6 +602,10 @@ int SessionStub::HandlePendingSessionActivation(MessageParcel& data, MessageParc
TLOGE(WmsLogTag::WMS_LIFE, "Read instanceKey failed.");
return ERR_INVALID_DATA;
}
if (!data.ReadBool(abilitySessionInfo->isFromIcon)) {
TLOGE(WmsLogTag::WMS_LIFE, "Read isFromIcon failed.");
return ERR_INVALID_DATA;
}
bool hasStartWindowOption = false;
if (!data.ReadBool(hasStartWindowOption)) {
TLOGE(WmsLogTag::WMS_LIFE, "Read hasStartWindowOption failed.");
@ -636,6 +640,11 @@ int SessionStub::HandleUpdateSessionRect(MessageParcel& data, MessageParcel& rep
TLOGE(WmsLogTag::WMS_LAYOUT, "read changeReason failed");
return ERR_INVALID_DATA;
}
if (changeReason < static_cast<uint32_t>(SizeChangeReason::UNDEFINED) ||
changeReason > static_cast<uint32_t>(SizeChangeReason::END)) {
TLOGE(WmsLogTag::WMS_LAYOUT, "Unknown reason");
return ERR_INVALID_DATA;
}
SizeChangeReason reason = static_cast<SizeChangeReason>(changeReason);
bool isGlobal = false;
if (!data.ReadBool(isGlobal)) {
@ -744,7 +753,10 @@ int SessionStub::HandleGetGlobalMaximizeMode(MessageParcel& data, MessageParcel&
int SessionStub::HandleNeedAvoid(MessageParcel& data, MessageParcel& reply)
{
bool status = static_cast<bool>(data.ReadUint32());
bool status = false;
if (!data.ReadBool(status)) {
return ERR_INVALID_DATA;
}
WLOGFD("HandleNeedAvoid status:%{public}d", static_cast<int32_t>(status));
WSError errCode = OnNeedAvoid(status);
reply.WriteUint32(static_cast<uint32_t>(errCode));
@ -753,8 +765,14 @@ int SessionStub::HandleNeedAvoid(MessageParcel& data, MessageParcel& reply)
int SessionStub::HandleGetAvoidAreaByType(MessageParcel& data, MessageParcel& reply)
{
AvoidAreaType type = static_cast<AvoidAreaType>(data.ReadUint32());
WLOGFD("HandleGetAvoidArea type:%{public}d", static_cast<int32_t>(type));
uint32_t typeId = 0;
if (!data.ReadUint32(typeId) ||
typeId < static_cast<uint32_t>(AvoidAreaType::TYPE_SYSTEM) ||
typeId > static_cast<uint32_t>(AvoidAreaType::TYPE_NAVIGATION_INDICATOR)) {
return ERR_INVALID_DATA;
}
AvoidAreaType type = static_cast<AvoidAreaType>(typeId);
WLOGFD("HandleGetAvoidArea type:%{public}d", typeId);
AvoidArea avoidArea = GetAvoidAreaByType(type);
reply.WriteParcelable(&avoidArea);
return ERR_NONE;
@ -904,7 +922,7 @@ int SessionStub::HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply)
int32_t posY = 0;
uint32_t width = 0;
uint32_t height = 0;
int32_t reason = 0;
uint32_t reason = 0;
if (!data.ReadInt32(posX)) {
TLOGE(WmsLogTag::WMS_PIP, "read posX error");
return ERR_INVALID_DATA;
@ -922,10 +940,14 @@ int SessionStub::HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply)
return ERR_INVALID_DATA;
}
Rect rect = {posX, posY, width, height};
if (!data.ReadInt32(reason)) {
if (!data.ReadUint32(reason)) {
TLOGE(WmsLogTag::WMS_PIP, "read reason error");
return ERR_INVALID_DATA;
}
if (reason > static_cast<uint32_t>(SizeChangeReason::END)) {
TLOGE(WmsLogTag::WMS_PIP, "Unknown reason");
return ERR_INVALID_DATA;
}
WSError errCode = UpdatePiPRect(rect, static_cast<SizeChangeReason>(reason));
reply.WriteUint32(static_cast<uint32_t>(errCode));
return ERR_NONE;
@ -937,6 +959,15 @@ int SessionStub::HandleUpdatePiPControlStatus(MessageParcel& data, MessageParcel
uint32_t controlType = 0;
int32_t status = 0;
if (data.ReadUint32(controlType) && data.ReadInt32(status)) {
if (controlType > static_cast<uint32_t>(WsPiPControlType::END)) {
TLOGE(WmsLogTag::WMS_PIP, "Unknown controlType");
return ERR_INVALID_DATA;
}
if (status > static_cast<int32_t>(WsPiPControlStatus::PLAY) ||
status < static_cast<int32_t>(WsPiPControlStatus::DISABLED)) {
TLOGE(WmsLogTag::WMS_PIP, "Unknown status");
return ERR_INVALID_DATA;
}
WSError errCode = UpdatePiPControlStatus(static_cast<WsPiPControlType>(controlType),
static_cast<WsPiPControlStatus>(status));
reply.WriteInt32(static_cast<int32_t>(errCode));
@ -1127,7 +1158,7 @@ int SessionStub::HandleSetDialogSessionBackGestureEnabled(MessageParcel& data, M
int SessionStub::HandleRequestFocus(MessageParcel& data, MessageParcel& reply)
{
TLOGD(WmsLogTag::WMS_FOCUS, "called");
TLOGD(WmsLogTag::WMS_FOCUS, "in");
bool isFocused = false;
if (!data.ReadBool(isFocused)) {
TLOGE(WmsLogTag::WMS_FOCUS, "read isFocused failed");

View File

@ -95,6 +95,7 @@ public:
float GetVirtualPixelRatio() const;
void SetScreenRotation(Rotation rotation);
void SetRotationAndScreenRotationOnly(Rotation rotation);
Rotation GetScreenRotation() const;
void UpdateScreenRotation(Rotation rotation);
@ -108,6 +109,9 @@ public:
DisplayOrientation GetDisplayOrientation() const;
void CalcDefaultDisplayOrientation();
void SetPhysicalRotation(float rotation);
float GetPhysicalRotation() const;
float GetXDpi() const;
float GetYDpi() const;
@ -148,6 +152,7 @@ private:
return (rotation == Rotation::ROTATION_0 || rotation == Rotation::ROTATION_180);
}
float rotation_ { 0.0f };
float physicalRotation_ { 0.0f };
RRect bounds_;
RRect phyBounds_;

View File

@ -110,6 +110,7 @@ public:
void SetOrientation(Orientation orientation);
Rotation GetRotation() const;
void SetRotation(Rotation rotation);
void SetRotationAndScreenRotationOnly(Rotation rotation);
void SetScreenRequestedOrientation(Orientation orientation);
Orientation GetScreenRequestedOrientation() const;
void SetUpdateToInputManagerCallback(std::function<void(float)> updateToInputManagerCallback);
@ -119,6 +120,8 @@ public:
void SetScreenSceneDpiChangeListener(const SetScreenSceneDpiFunc& func);
void SetScreenSceneDpi(float density);
void SetDensityInCurResolution(float densityInCurResolution);
void SetDefaultDensity(float DefaultDensity);
void UpdateVirtualPixelRatio(const RRect& bounds);
void SetScreenType(ScreenType type);
void SetScreenSceneDestroyListener(const DestroyScreenSceneFunc& func);
@ -234,6 +237,7 @@ public:
void SetMirrorScreenType(MirrorScreenType mirrorType);
MirrorScreenType GetMirrorScreenType();
Rotation ConvertIntToRotation(int rotation);
void SetPhysicalRotation(int rotation, FoldStatus foldStatus);
void SetStartPosition(uint32_t startX, uint32_t startY);
private:

View File

@ -37,6 +37,16 @@ float ScreenProperty::GetRotation() const
return rotation_;
}
void ScreenProperty::SetPhysicalRotation(float rotation)
{
physicalRotation_ = rotation;
}
float ScreenProperty::GetPhysicalRotation() const
{
return physicalRotation_;
}
void ScreenProperty::SetBounds(const RRect& bounds)
{
bounds_ = bounds;
@ -237,6 +247,29 @@ void ScreenProperty::SetScreenRotation(Rotation rotation)
screenRotation_ = rotation;
}
void ScreenProperty::SetRotationAndScreenRotationOnly(Rotation rotation)
{
bool enableRotation = (system::GetParameter("persist.window.rotation.enabled", "1") == "1");
if (!enableRotation) {
return;
}
switch (rotation) {
case Rotation::ROTATION_90:
rotation_ = 90.f;
break;
case Rotation::ROTATION_180:
rotation_ = 180.f;
break;
case Rotation::ROTATION_270:
rotation_ = 270.f;
break;
default:
rotation_ = 0.f;
break;
}
screenRotation_ = rotation;
}
void ScreenProperty::UpdateScreenRotation(Rotation rotation)
{
screenRotation_ = rotation;

View File

@ -582,6 +582,24 @@ void ScreenSession::UpdateToInputManager(RRect bounds, int rotation, FoldDisplay
}
}
void ScreenSession::SetPhysicalRotation(int rotation, FoldStatus foldStatus)
{
int32_t realRotation = static_cast<int32_t>(rotation);
std::vector<std::string> phyOffsets = FoldScreenStateInternel::GetPhyRotationOffset();
int32_t offsetRotation = 0;
if (phyOffsets.size() == 1 || foldStatus == FoldStatus::FOLDED) {
offsetRotation = static_cast<int32_t>(std::stoi(phyOffsets[0]));
}
if ((foldStatus == FoldStatus::EXPAND || foldStatus == FoldStatus::HALF_FOLD) &&
phyOffsets.size() == 2) { // 2 is arg number
offsetRotation = static_cast<int32_t>(std::stoi(phyOffsets[1]));
}
realRotation = (rotation + offsetRotation) % 360; // 360 is 360 degree
property_.SetPhysicalRotation(static_cast<float>(realRotation));
WLOGFI("physicalrotation :%{public}f , rotation: %{public}d , phyOffset: %{public}d",
property_.GetPhysicalRotation(), rotation, offsetRotation);
}
void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode)
{
Rotation targetRotation = ConvertIntToRotation(rotation);
@ -688,6 +706,11 @@ void ScreenSession::SetRotation(Rotation rotation)
property_.SetScreenRotation(rotation);
}
void ScreenSession::SetRotationAndScreenRotationOnly(Rotation rotation)
{
property_.SetRotationAndScreenRotationOnly(rotation);
}
void ScreenSession::SetScreenRequestedOrientation(Orientation orientation)
{
property_.SetScreenRequestedOrientation(orientation);
@ -770,6 +793,16 @@ void ScreenSession::SetDensityInCurResolution(float densityInCurResolution)
property_.SetDensityInCurResolution(densityInCurResolution);
}
void ScreenSession::SetDefaultDensity(float DefaultDensity)
{
property_.SetDefaultDensity(DefaultDensity);
}
void ScreenSession::UpdateVirtualPixelRatio(const RRect& bounds)
{
property_.UpdateVirtualPixelRatio(bounds);
}
void ScreenSession::SetScreenType(ScreenType type)
{
property_.SetScreenType(type);
@ -812,31 +845,29 @@ Rotation ScreenSession::CalcRotation(Orientation orientation, FoldDisplayMode fo
DisplayOrientation ScreenSession::CalcDisplayOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const
{
// vertical: phone(Plugin screen); horizontal: pad & external screen
bool isVerticalScreen = property_.GetPhyWidth() < property_.GetPhyHeight();
if (foldDisplayMode != FoldDisplayMode::UNKNOWN
&& (g_screenRotationOffSet == ROTATION_90 || g_screenRotationOffSet == ROTATION_270)) {
WLOGD("foldDisplay is verticalScreen when width is greater than height");
isVerticalScreen = property_.GetPhyWidth() > property_.GetPhyHeight();
}
DisplayOrientation displayRotation = DisplayOrientation::UNKNOWN;
switch (rotation) {
case Rotation::ROTATION_0: {
return isVerticalScreen ? DisplayOrientation::PORTRAIT : DisplayOrientation::LANDSCAPE;
displayRotation = DisplayOrientation::PORTRAIT;
break;
}
case Rotation::ROTATION_90: {
return isVerticalScreen ? DisplayOrientation::LANDSCAPE : DisplayOrientation::PORTRAIT;
displayRotation = DisplayOrientation::LANDSCAPE;
break;
}
case Rotation::ROTATION_180: {
return isVerticalScreen ? DisplayOrientation::PORTRAIT_INVERTED : DisplayOrientation::LANDSCAPE_INVERTED;
displayRotation = DisplayOrientation::PORTRAIT_INVERTED;
break;
}
case Rotation::ROTATION_270: {
return isVerticalScreen ? DisplayOrientation::LANDSCAPE_INVERTED : DisplayOrientation::PORTRAIT_INVERTED;
displayRotation = DisplayOrientation::LANDSCAPE_INVERTED;
break;
}
default: {
WLOGE("unknown rotation %{public}u", rotation);
return DisplayOrientation::UNKNOWN;
}
}
return displayRotation;
}
ScreenSourceMode ScreenSession::GetSourceMode() const

View File

@ -60,6 +60,13 @@ public:
*/
WSError RequestExtensionSessionDestruction(
const sptr<ExtensionSession>& extensionSession, const std::function<void(WSError)>&& resultCallback);
/**
* @brief destroy extension session done
*
* @param extensionSession the extension session need to be destroyed
* @return WSError
*/
WSError RequestExtensionSessionDestructionDone(const sptr<ExtensionSession>& extensionSession);
private:
ExtensionSessionManager();

View File

@ -44,6 +44,7 @@
#include "include/core/SkRegion.h"
#include "ability_info.h"
#include "screen_fold_data.h"
#include "thread_safety_annotations.h"
namespace OHOS::AAFwk {
class SessionInfo;
@ -130,7 +131,7 @@ public:
void OnScreenshot(DisplayId displayId) override;
void OnImmersiveStateChange(ScreenId screenId, bool& immersive) override;
void OnGetSurfaceNodeIdsFromMissionIds(std::vector<uint64_t>& missionIds,
std::vector<uint64_t>& surfaceNodeIds) override;
std::vector<uint64_t>& surfaceNodeIds, bool isBlackList = false) override;
/*
* Fold Screen Status Change Report
@ -213,10 +214,6 @@ public:
WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
WSError SetFocusedSessionId(int32_t persistentId);
int32_t GetFocusedSessionId() const;
FocusChangeReason GetFocusChangeReason() const { return focusChangeReason_; }
/*
* Dump
*/
@ -226,24 +223,26 @@ public:
const std::string& strId);
WSError GetSCBDebugDumpInfo(std::string&& cmd, std::string& dumpInfo);
WSError GetSessionDumpInfo(const std::vector<std::string>& params, std::string& info) override;
WSError DumpSessionAll(std::vector<std::string>& infos) override;
WSError DumpSessionWithId(int32_t persistentId, std::vector<std::string>& infos) override;
/**
* @brief request focus status
*
* This function provides the ability for window to change focus status.
*
* @param persistentId window ID
* @param isFocused is Focused
* @param byForeground byForeground
* @param reason focus change reason
* @return Returns WSError::WS_OK if called success, otherwise failed.
/*
* Window Focus
*/
WSError SetFocusedSessionId(int32_t persistentId);
int32_t GetFocusedSessionId() const;
FocusChangeReason GetFocusChangeReason() const { return focusChangeReason_; }
WMError RequestFocusStatus(int32_t persistentId, bool isFocused, bool byForeground = true,
FocusChangeReason reason = FocusChangeReason::DEFAULT) override;
WMError RequestFocusStatusBySCB(int32_t persistentId, bool isFocused, bool byForeground = true,
FocusChangeReason reason = FocusChangeReason::DEFAULT);
void RequestAllAppSessionUnfocus();
WSError UpdateFocus(int32_t persistentId, bool isFocused);
WSError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId) override;
void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override;
WSError GetFocusSessionToken(sptr<IRemoteObject>& token) override;
WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override;
WSError UpdateWindowMode(int32_t persistentId, int32_t windowMode);
WSError SendTouchEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, uint32_t zIndex);
WSError RaiseWindowToTop(int32_t persistentId) override;
@ -255,14 +254,6 @@ public:
int32_t GetCurrentUserId() const;
void StartWindowInfoReportLoop();
/**
* @brief get the focused window info
*
* This function provides the ability for other services to get the focused window info.
*
* @param focusInfo the focused session info
*/
void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override;
void NotifyCompleteFirstFrameDrawing(int32_t persistentId);
void NotifySessionMovedToFront(int32_t persistentId);
WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) override;
@ -275,16 +266,6 @@ public:
WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject>& token,
bool shouldBackToCaller = true) override;
/**
* @brief get focus session token
*
* This function provides the ability for other services to get the focused session token.
*
* @param token the object of token
* @return Returns WSError::WS_OK if called success, otherwise failed.
*/
WSError GetFocusSessionToken(sptr<IRemoteObject>& token) override;
WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override;
WSError RegisterSessionListener(const sptr<ISessionListener>& listener) override;
WSError UnRegisterSessionListener(const sptr<ISessionListener>& listener) override;
WSError GetSessionInfos(const std::string& deviceId, int32_t numMax,
@ -293,8 +274,6 @@ public:
WSError GetSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) override;
WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId,
SessionInfoBean& sessionInfo) override;
WSError DumpSessionAll(std::vector<std::string>& infos) override;
WSError DumpSessionWithId(int32_t persistentId, std::vector<std::string>& infos) override;
WSError GetAllAbilityInfos(const AAFwk::Want& want, int32_t userId,
std::vector<SCBAbilityInfo>& scbAbilityInfos);
WSError GetBatchAbilityInfos(const std::vector<std::string>& bundleNames, int32_t userId,
@ -321,6 +300,11 @@ public:
WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override;
WMError GetParentMainWindowId(int32_t windowId, int32_t& mainWindowId) override;
/*
* PC Window
*/
WMError IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode) override;
std::map<int32_t, sptr<SceneSession>>& GetSessionMapByScreenId(ScreenId id);
void UpdatePrivateStateAndNotify(uint32_t persistentId);
void InitPersistentStorage();
@ -351,6 +335,7 @@ public:
WSError RegisterIAbilityManagerCollaborator(int32_t type,
const sptr<AAFwk::IAbilityManagerCollaborator>& impl) override;
WSError UnregisterIAbilityManagerCollaborator(int32_t type) override;
void ClearAllCollaboratorSessions();
bool IsInputEventEnabled();
void SetEnableInputEvent(bool enabled);
@ -371,7 +356,7 @@ public:
void NotifySessionUpdate(const SessionInfo& sessionInfo, ActionType type,
ScreenId fromScreenId = SCREEN_ID_INVALID);
WMError GetSurfaceNodeIdsFromMissionIds(std::vector<uint64_t>& missionIds,
std::vector<uint64_t>& surfaceNodeIds);
std::vector<uint64_t>& surfaceNodeIds, bool isBlackList = false);
WSError UpdateTitleInTargetPos(int32_t persistentId, bool isShow, int32_t height);
void RegisterCreateSubSessionListener(int32_t persistentId, const NotifyCreateSubSessionFunc& func);
void UnregisterCreateSubSessionListener(int32_t persistentId);
@ -393,16 +378,6 @@ public:
WSError UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener) override;
WMError SetSystemAnimatedScenes(SystemAnimatedSceneType sceneType);
/**
* @brief shift App window focus
*
* This function provides the ability for applications to shift focus in application.
*
* @param sourcePersistentId source persistent Id
* @param targetPersistentId target persistent Id
* @return Returns WSError::WS_OK if called success, otherwise failed.
*/
WSError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId) override;
std::shared_ptr<Media::PixelMap> GetSessionSnapshotPixelMap(const int32_t persistentId, const float scaleParam);
void RequestInputMethodCloseKeyboard(int32_t persistentId);
WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override;
@ -470,6 +445,10 @@ public:
WMError TerminateSessionByPersistentId(int32_t persistentId);
WMError GetProcessSurfaceNodeIdByPersistentId(const int32_t pid,
const std::vector<int32_t>& persistentIds, std::vector<uint64_t>& surfaceNodeIds) override;
/*
* Window ZOrder: PC
*/
void RefreshPcZOrderList(uint32_t startZOrder, std::vector<int32_t>&& persistentIds);
/*
@ -564,6 +543,9 @@ private:
void PostProcessFocus();
void PostProcessProperty(uint32_t dirty);
/*
* Window Focus
*/
std::vector<std::pair<int32_t, sptr<SceneSession>>> GetSceneSessionVector(CmpFunc cmp);
void TraverseSessionTree(TraverseFunc func, bool isFromTopToBottom);
void TraverseSessionTreeFromTopToBottom(TraverseFunc func);
@ -583,10 +565,7 @@ private:
sptr<SceneSession>& focusedSession, bool includingAppSession);
bool CheckClickFocusIsDownThroughFullScreen(const sptr<SceneSession>& focusedSession,
const sptr<SceneSession>& sceneSession, FocusChangeReason reason);
bool CheckParentSessionVisible(const sptr<SceneSession>& session);
void InitSceneSession(sptr<SceneSession>& sceneSession, const SessionInfo& sessionInfo,
const sptr<WindowSessionProperty>& property);
bool IsParentSessionVisible(const sptr<SceneSession>& session);
sptr<SceneSession> GetNextFocusableSession(int32_t persistentId);
sptr<SceneSession> GetTopNearestBlockingFocusSession(uint32_t zOrder, bool includingAppSession);
sptr<SceneSession> GetTopFocusableNonAppSession();
@ -600,9 +579,12 @@ private:
bool MissionChanged(sptr<SceneSession>& prevSession, sptr<SceneSession>& currSession);
std::string GetAllSessionFocusInfo();
void RegisterRequestFocusStatusNotifyManagerFunc(sptr<SceneSession>& sceneSession);
void RegisterGetStateFromManagerFunc(sptr<SceneSession>& sceneSession);
void RegisterSessionChangeByActionNotifyManagerFunc(sptr<SceneSession>& sceneSession);
void InitSceneSession(sptr<SceneSession>& sceneSession, const SessionInfo& sessionInfo,
const sptr<WindowSessionProperty>& property);
sptr<AAFwk::SessionInfo> SetAbilitySessionInfo(const sptr<SceneSession>& scnSession);
WSError DestroyDialogWithMainWindow(const sptr<SceneSession>& scnSession);
sptr<SceneSession> FindMainWindowWithToken(sptr<IRemoteObject> targetToken);
@ -676,10 +658,6 @@ private:
void RegisterVisibilityChangedDetectFunc(const sptr<SceneSession>& sceneSession);
void NotifySessionForCallback(const sptr<SceneSession>& scnSession, const bool needRemoveSession);
void DumpSessionInfo(const sptr<SceneSession>& session, std::ostringstream& oss);
void DumpSessionElementInfo(const sptr<SceneSession>& session,
const std::vector<std::string>& params, std::string& dumpInfo);
void DumpAllSessionFocusableInfo(int32_t persistentId);
void AddClientDeathRecipient(const sptr<ISessionStage>& sessionStage, const sptr<SceneSession>& sceneSession);
void DestroySpecificSession(const sptr<IRemoteObject>& remoteObject);
bool GetExtensionWindowIds(const sptr<IRemoteObject>& token, int32_t& persistentId, int32_t& parentId);
@ -695,7 +673,7 @@ private:
void NotifySessionAINavigationBarChange(int32_t persistentId);
void ReportWindowProfileInfos();
void UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing);
void removeFailRecoveredSession();
void RemoveFailRecoveredSession();
void GetAllSceneSessionForAccessibility(std::vector<sptr<SceneSession>>& sceneSessionList);
void FillAccessibilityInfo(std::vector<sptr<SceneSession>>& sceneSessionList,
std::vector<sptr<AccessibilityWindowInfo>>& accessibilityInfo);
@ -749,12 +727,12 @@ private:
ProcessStatusBarEnabledChangeFunc statusBarEnabledChangeFunc_;
ProcessGestureNavigationEnabledChangeFunc gestureNavigationEnabledChangeFunc_;
ProcessOutsideDownEventFunc outsideDownEventFunc_;
DumpRootSceneElementInfoFunc dumpRootSceneFunc_;
ProcessShiftFocusFunc shiftFocusFunc_;
NotifySCBAfterUpdateFocusFunc notifySCBAfterFocusedFunc_;
NotifySCBAfterUpdateFocusFunc notifySCBAfterUnfocusedFunc_;
ProcessCallingSessionIdChangeFunc callingSessionIdChangeFunc_;
ProcessStartUIAbilityErrorFunc startUIAbilityErrorFunc_;
DumpRootSceneElementInfoFunc dumpRootSceneFunc_;
DumpUITreeFunc dumpUITreeFunc_;
ProcessVirtualPixelRatioChangeFunc processVirtualPixelRatioChangeFunc_ = nullptr;
ProcessCloseTargetFloatWindowFunc closeTargetFloatWindowFunc_;
@ -827,7 +805,7 @@ private:
bool IsNeedRecover(const int32_t persistentId);
void RegisterSessionStateChangeNotifyManagerFunc(sptr<SceneSession>& sceneSession);
void RegisterSessionInfoChangeNotifyManagerFunc(sptr<SceneSession>& sceneSession);
void OnSessionStateChange(int32_t persistentId, const SessionState& state);
void OnSessionStateChange(int32_t persistentId, const SessionState& state) REQUIRES(SCENE_GUARD);
void ProcessFocusWhenForeground(sptr<SceneSession>& sceneSession);
void ProcessFocusWhenForegroundScbCore(sptr<SceneSession>& sceneSession);
void ProcessSubSessionForeground(sptr<SceneSession>& sceneSession);
@ -864,6 +842,7 @@ private:
std::shared_mutex collaboratorMapLock_;
std::unordered_map<int32_t, sptr<AAFwk::IAbilityManagerCollaborator>> collaboratorMap_;
std::atomic<int64_t> containerStartAbilityTime { 0 };
sptr<AgentDeathRecipient> collaboratorDeathRecipient_;
std::vector<uint64_t> skipSurfaceNodeIds_;
@ -912,9 +891,9 @@ private:
/*
* Window Snapshot
*/
void SetSessionSnapshotSkipForAppProcess(const sptr<SceneSession>& sceneSession);
void RemoveProcessSnapshotSkip(int32_t pid);
void SetSessionSnapshotSkipForAppBundleName(const sptr<SceneSession>& sceneSession);
void SetSessionSnapshotSkipForAppProcess(const sptr<SceneSession>& sceneSession) REQUIRES(SCENE_GUARD);
void RemoveProcessSnapshotSkip(int32_t pid) REQUIRES(SCENE_GUARD);
void SetSessionSnapshotSkipForAppBundleName(const sptr<SceneSession>& sceneSession) REQUIRES(SCENE_GUARD);
void HandleSpecialExtWindowFlagsChange(int32_t persistentId, ExtensionWindowFlags extWindowFlags,
ExtensionWindowFlags extWindowActions);
@ -950,13 +929,11 @@ private:
bool SetSessionWatermarkForAppProcess(const sptr<SceneSession>& sceneSession);
void RemoveProcessWatermarkPid(int32_t pid);
RunnableFuture<std::vector<std::string>> dumpInfoFuture_;
/*
* Window Snapshot
*/
std::unordered_set<int32_t> snapshotSkipPidSet_; // ONLY Accessed on OS_sceneSession thread
std::unordered_set<std::string> snapshotSkipBundleNameSet_; // ONLY Accessed on OS_sceneSession thread
std::unordered_set<int32_t> snapshotSkipPidSet_ GUARDED_BY(SCENE_GUARD); // ONLY Accessed on OS_sceneSession thread
std::unordered_set<std::string> snapshotSkipBundleNameSet_ GUARDED_BY(SCENE_GUARD);
int32_t sessionMapDirty_ { 0 };
std::condition_variable nextFlushCompletedCV_;
@ -972,6 +949,16 @@ private:
* Dump
*/
std::shared_ptr<ScbDumpSubscriber> scbDumpSubscriber_;
RunnableFuture<std::vector<std::string>> dumpInfoFuture_;
void DumpSessionInfo(const sptr<SceneSession>& session, std::ostringstream& oss);
void DumpSessionElementInfo(const sptr<SceneSession>& session,
const std::vector<std::string>& params, std::string& dumpInfo);
void DumpAllSessionFocusableInfo(int32_t persistentId);
/*
* Screen Manager
*/
bool IsInSecondaryScreen(const sptr<SceneSession>& sceneSession);
struct SessionInfoList {
int32_t uid_;

Some files were not shown because too many files have changed in this diff Show More