mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
complement Screen interface
Signed-off-by: wangxinpeng <wangxinpeng4@huawei.com> Change-Id: Ice8fa6740ddf27ddfb06156480195ae1333442e8
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "display.h"
|
||||
#include "screen.h"
|
||||
#include "screen_group.h"
|
||||
#include "dm_common.h"
|
||||
#include "display_manager_interface.h"
|
||||
#include "singleton_delegator.h"
|
||||
@@ -56,6 +57,10 @@ public:
|
||||
virtual void NotifyDisplayEvent(DisplayEvent event);
|
||||
virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId);
|
||||
virtual void Clear();
|
||||
virtual sptr<Screen> GetScreenById(ScreenId screenId);
|
||||
virtual sptr<ScreenGroup> GetScreenGroupById(ScreenId screenId);
|
||||
virtual std::vector<sptr<Screen>> GetAllScreens();
|
||||
virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint);
|
||||
|
||||
private:
|
||||
bool InitDMSProxyLocked();
|
||||
@@ -66,6 +71,8 @@ private:
|
||||
sptr<IDisplayManager> displayManagerServiceProxy_ = nullptr;
|
||||
sptr<DMSDeathRecipient> dmsDeath_ = nullptr;
|
||||
std::map<DisplayId, sptr<Display>> displayMap_;
|
||||
std::map<ScreenId, sptr<Screen>> screenMap_;
|
||||
std::map<ScreenId, sptr<ScreenGroup>> screenGroupMap_;
|
||||
DisplayId defaultDisplayId_;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
@@ -257,4 +257,85 @@ DMError DisplayManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<Scr
|
||||
}
|
||||
return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId);
|
||||
}
|
||||
|
||||
sptr<Screen> DisplayManagerAdapter::GetScreenById(ScreenId screenId)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (screenId == SCREEN_ID_INVALID) {
|
||||
WLOGFE("screen id is invalid");
|
||||
return nullptr;
|
||||
}
|
||||
auto iter = screenMap_.find(screenId);
|
||||
if (iter != screenMap_.end()) {
|
||||
WLOGFI("get screen in screen map");
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
if (!InitDMSProxyLocked()) {
|
||||
WLOGFE("InitDMSProxyLocked failed!");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<ScreenInfo> screenInfo = displayManagerServiceProxy_->GetScreenInfoById(screenId);
|
||||
if (screenInfo == nullptr) {
|
||||
WLOGFE("screenInfo is null");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<Screen> screen = new Screen(screenInfo.GetRefPtr());
|
||||
screenMap_.insert(std::make_pair(screenId, screen));
|
||||
return screen;
|
||||
}
|
||||
|
||||
sptr<ScreenGroup> DisplayManagerAdapter::GetScreenGroupById(ScreenId screenId)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (screenId == SCREEN_ID_INVALID) {
|
||||
WLOGFE("screenGroup id is invalid");
|
||||
return nullptr;
|
||||
}
|
||||
auto iter = screenGroupMap_.find(screenId);
|
||||
if (iter != screenGroupMap_.end()) {
|
||||
WLOGFI("get screenGroup in screenGroup map");
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
if (!InitDMSProxyLocked()) {
|
||||
WLOGFE("InitDMSProxyLocked failed!");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<ScreenGroupInfo> screenGroupInfo = displayManagerServiceProxy_->GetScreenGroupInfoById(screenId);
|
||||
if (screenGroupInfo == nullptr) {
|
||||
WLOGFE("screenGroupInfo is null");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<ScreenGroup> screenGroup = new ScreenGroup(screenGroupInfo.GetRefPtr());
|
||||
screenGroupMap_.insert(std::make_pair(screenId, screenGroup));
|
||||
return screenGroup;
|
||||
}
|
||||
|
||||
std::vector<sptr<Screen>> DisplayManagerAdapter::GetAllScreens()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
std::vector<sptr<Screen>> screens;
|
||||
if (!InitDMSProxyLocked()) {
|
||||
WLOGFE("InitDMSProxyLocked failed!");
|
||||
return screens;
|
||||
}
|
||||
std::vector<sptr<ScreenInfo>> screenInfos = displayManagerServiceProxy_->GetAllScreenInfos();
|
||||
for (auto info: screenInfos) {
|
||||
if (info == nullptr) {
|
||||
WLOGFE("screenInfo is null");
|
||||
continue;
|
||||
}
|
||||
screens.emplace_back(new Screen(info.GetRefPtr()));
|
||||
}
|
||||
return screens;
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
{
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED;
|
||||
}
|
||||
return displayManagerServiceProxy_->MakeExpand(screenId, startPoint);
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
+13
-4
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "screen.h"
|
||||
#include "screen_info.h"
|
||||
|
||||
#include "screen_group.h"
|
||||
|
||||
@@ -30,13 +31,21 @@ public:
|
||||
uint32_t virtualWidth_ { 0 };
|
||||
uint32_t virtualHeight_ { 0 };
|
||||
float virtualPixelRatio_ { 0.0 };
|
||||
sptr<ScreenGroup> parent_ { nullptr };
|
||||
ScreenId parent_ { SCREEN_ID_INVALID };
|
||||
bool hasChild_ { false };
|
||||
};
|
||||
|
||||
Screen::Screen()
|
||||
Screen::Screen(const ScreenInfo* info)
|
||||
: pImpl_(new Impl())
|
||||
{
|
||||
pImpl_ = new Impl();
|
||||
pImpl_->id_ = info->id_;
|
||||
pImpl_->width_ = info->width_;
|
||||
pImpl_->height_ = info->height_;
|
||||
pImpl_->virtualWidth_ = info->virtualWidth_;
|
||||
pImpl_->virtualHeight_ = info->virtualHeight_;
|
||||
pImpl_->virtualPixelRatio_ = info->virtualPixelRatio_;
|
||||
pImpl_->parent_ = info->parent_;
|
||||
pImpl_->hasChild_ = info->hasChild_;
|
||||
}
|
||||
|
||||
Screen::~Screen()
|
||||
@@ -88,7 +97,7 @@ bool Screen::RequestRotation(Rotation rotation)
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<ScreenGroup> Screen::GetParent() const
|
||||
ScreenId Screen::GetParentId() const
|
||||
{
|
||||
return pImpl_->parent_;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "screen_group.h"
|
||||
#include "screen.h"
|
||||
#include "screen_group_info.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class ScreenGroup::Impl : public RefBase {
|
||||
@@ -22,14 +24,17 @@ private:
|
||||
Impl() = default;
|
||||
~Impl() = default;
|
||||
|
||||
std::vector<sptr<Screen>> children_;
|
||||
std::vector<ScreenId> children_;
|
||||
std::vector<Point> position_;
|
||||
ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE };
|
||||
};
|
||||
|
||||
ScreenGroup::ScreenGroup()
|
||||
ScreenGroup::ScreenGroup(const ScreenGroupInfo* info)
|
||||
: Screen(info), pImpl_(new Impl())
|
||||
{
|
||||
pImpl_ = new Impl();
|
||||
pImpl_->children_ = info->children_;
|
||||
pImpl_->position_ = info->position_;
|
||||
pImpl_->combination_ = info->combination_;
|
||||
}
|
||||
|
||||
ScreenGroup::~ScreenGroup()
|
||||
@@ -41,7 +46,7 @@ ScreenCombination ScreenGroup::GetCombination() const
|
||||
return pImpl_->combination_;
|
||||
}
|
||||
|
||||
std::vector<sptr<Screen>> ScreenGroup::GetChildren() const
|
||||
std::vector<ScreenId> ScreenGroup::GetChildrenIds() const
|
||||
{
|
||||
return pImpl_->children_;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "screen_manager.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "display_manager_adapter.h"
|
||||
#include "singleton_delegator.h"
|
||||
|
||||
|
||||
#include <map>
|
||||
@@ -30,8 +31,7 @@ friend class ScreenManager;
|
||||
private:
|
||||
Impl() = default;
|
||||
~Impl() = default;
|
||||
|
||||
std::map<ScreenId, sptr<Screen>> monitorMap_;
|
||||
static inline SingletonDelegator<ScreenManager> delegator;
|
||||
};
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManager)
|
||||
|
||||
@@ -44,15 +44,19 @@ ScreenManager::~ScreenManager()
|
||||
{
|
||||
}
|
||||
|
||||
sptr<Screen> ScreenManager::GetScreenById(ScreenId id)
|
||||
sptr<Screen> ScreenManager::GetScreenById(ScreenId screenId)
|
||||
{
|
||||
return nullptr;
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetScreenById(screenId);
|
||||
}
|
||||
|
||||
std::vector<const sptr<Screen>> ScreenManager::GetAllScreens()
|
||||
sptr<ScreenGroup> ScreenManager::GetScreenGroupById(ScreenId screenId)
|
||||
{
|
||||
std::vector<const sptr<Screen>> res;
|
||||
return res;
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetScreenGroupById(screenId);
|
||||
}
|
||||
|
||||
std::vector<sptr<Screen>> ScreenManager::GetAllScreens()
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetAllScreens();
|
||||
}
|
||||
|
||||
void ScreenManager::RegisterScreenListener(sptr<IScreenListener> listener)
|
||||
@@ -61,6 +65,10 @@ void ScreenManager::RegisterScreenListener(sptr<IScreenListener> listener)
|
||||
|
||||
ScreenId ScreenManager::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
{
|
||||
DMError result = SingletonContainer::Get<DisplayManagerAdapter>().MakeExpand(screenId, startPoint);
|
||||
if (result == DMError::DM_OK) {
|
||||
WLOGFI("create mirror success");
|
||||
}
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "screen.h"
|
||||
#include "screen_group.h"
|
||||
#include "screen_info.h"
|
||||
#include "screen_group_info.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "dm_common.h"
|
||||
#include "screen.h"
|
||||
#include "display_info.h"
|
||||
#include "screen_info.h"
|
||||
#include "screen_group_info.h"
|
||||
#include "zidl/display_manager_agent_interface.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
@@ -46,8 +48,12 @@ public:
|
||||
TRANS_ID_NOTIFY_DISPLAY_EVENT,
|
||||
TRANS_ID_CREATE_VIRTUAL_SCREEN = 1000,
|
||||
TRANS_ID_DESTROY_VIRTUAL_SCREEN,
|
||||
TRANS_ID_GET_SCREEN_INFO_BY_ID,
|
||||
TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID,
|
||||
TRANS_ID_GET_ALL_SCREEN_INFOS,
|
||||
TRANS_ID_SCREENGROUP_BASE = 1100,
|
||||
TRANS_ID_SCREEN_MAKE_MIRROR = TRANS_ID_SCREENGROUP_BASE,
|
||||
TRANS_ID_SCREEN_MAKE_EXPAND,
|
||||
};
|
||||
|
||||
virtual DisplayId GetDefaultDisplayId() = 0;
|
||||
@@ -70,6 +76,10 @@ public:
|
||||
virtual DisplayState GetDisplayState(DisplayId displayId) = 0;
|
||||
virtual void NotifyDisplayEvent(DisplayEvent event) = 0;
|
||||
virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId) = 0;
|
||||
virtual sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) = 0;
|
||||
virtual sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) = 0;
|
||||
virtual std::vector<sptr<ScreenInfo>> GetAllScreenInfos() = 0;
|
||||
virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint) = 0;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ public:
|
||||
DisplayState GetDisplayState(DisplayId displayId) override;
|
||||
void NotifyDisplayEvent(DisplayEvent event) override;
|
||||
DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId) override;
|
||||
sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) override;
|
||||
sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) override;
|
||||
std::vector<sptr<ScreenInfo>> GetAllScreenInfos() override;
|
||||
DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<DisplayManagerProxy> delegator_;
|
||||
|
||||
@@ -64,6 +64,10 @@ public:
|
||||
|
||||
sptr<AbstractScreenController> GetAbstractScreenController();
|
||||
DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId) override;
|
||||
sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) override;
|
||||
sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) override;
|
||||
std::vector<sptr<ScreenInfo>> GetAllScreenInfos() override;
|
||||
DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint) override;
|
||||
|
||||
private:
|
||||
DisplayManagerService();
|
||||
|
||||
@@ -409,4 +409,134 @@ DMError DisplayManagerProxy::MakeMirror(ScreenId mainScreenId, std::vector<Scree
|
||||
}
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
sptr<ScreenInfo> DisplayManagerProxy::GetScreenInfoById(ScreenId screenId)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("GetScreenInfoById: remote is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("GetScreenInfoById: WriteInterfaceToken failed");
|
||||
return nullptr;
|
||||
}
|
||||
if (!data.WriteUint64(screenId)) {
|
||||
WLOGFE("GetScreenInfoById: Write screenId failed");
|
||||
return nullptr;
|
||||
}
|
||||
if (remote->SendRequest(TRANS_ID_GET_SCREEN_INFO_BY_ID, data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("GetScreenInfoById: SendRequest failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sptr<ScreenInfo> info = reply.ReadStrongParcelable<ScreenInfo>();
|
||||
if (info == nullptr) {
|
||||
WLOGFW("GetScreenInfoById SendRequest nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
sptr<ScreenGroupInfo> DisplayManagerProxy::GetScreenGroupInfoById(ScreenId screenId)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("GetScreenGroupInfoById: remote is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("GetScreenGroupInfoById: WriteInterfaceToken failed");
|
||||
return nullptr;
|
||||
}
|
||||
if (!data.WriteUint64(screenId)) {
|
||||
WLOGFE("GetScreenGroupInfoById: Write screenId failed");
|
||||
return nullptr;
|
||||
}
|
||||
if (remote->SendRequest(TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID, data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("GetScreenGroupInfoById: SendRequest failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sptr<ScreenGroupInfo> info = reply.ReadStrongParcelable<ScreenGroupInfo>();
|
||||
if (info == nullptr) {
|
||||
WLOGFW("GetScreenGroupInfoById SendRequest nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
std::vector<sptr<ScreenInfo>> DisplayManagerProxy::GetAllScreenInfos()
|
||||
{
|
||||
std::vector<sptr<ScreenInfo>> screenInfos;
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("GetAllScreenInfos: remote is nullptr");
|
||||
return screenInfos;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("GetAllScreenInfos: WriteInterfaceToken failed");
|
||||
return screenInfos;
|
||||
}
|
||||
if (remote->SendRequest(TRANS_ID_GET_ALL_SCREEN_INFOS, data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("GetAllScreenInfos: SendRequest failed");
|
||||
return screenInfos;
|
||||
}
|
||||
|
||||
uint32_t nums = reply.ReadUint32();
|
||||
for (uint32_t i = 0; i < nums; ++i) {
|
||||
sptr<ScreenInfo> info = reply.ReadStrongParcelable<ScreenInfo>();
|
||||
screenInfos.emplace_back(info);
|
||||
}
|
||||
return screenInfos;
|
||||
}
|
||||
|
||||
DMError DisplayManagerProxy::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("MakeExpand: remote is null");
|
||||
return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("MakeExpand: WriteInterfaceToken failed");
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (!data.WriteUInt64Vector(screenId)) {
|
||||
WLOGFE("MakeExpand: write screenId failed");
|
||||
return DMError::DM_ERROR_WRITE_DATA_FAILED;
|
||||
}
|
||||
uint32_t num = startPoint.size();
|
||||
if (!data.WriteUint32(num)) {
|
||||
WLOGFE("MakeExpand: write startPoint size failed");
|
||||
return DMError::DM_ERROR_WRITE_DATA_FAILED;
|
||||
}
|
||||
for (auto point: startPoint) {
|
||||
if (!(data.WriteInt32(point.posX_) && data.WriteInt32(point.posY_))) {
|
||||
WLOGFE("MakeExpand: write startPoint failed");
|
||||
return DMError::DM_ERROR_WRITE_DATA_FAILED;
|
||||
}
|
||||
}
|
||||
if (remote->SendRequest(TRANS_ID_SCREEN_MAKE_EXPAND, data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("MakeExpand: SendRequest failed");
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
@@ -249,4 +249,45 @@ DMError DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector<Scr
|
||||
WLOGFI("create mirror. NodeId: %{public}" PRIu64"", nodeId);
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
sptr<ScreenInfo> DisplayManagerService::GetScreenInfoById(ScreenId screenId)
|
||||
{
|
||||
auto screen = abstractScreenController_->GetAbstractScreen(screenId);
|
||||
if (screen == nullptr) {
|
||||
WLOGE("cannot find screenInfo: %{public}" PRIu64"", screenId);
|
||||
return nullptr;
|
||||
}
|
||||
return screen->ConvertToScreenInfo();
|
||||
}
|
||||
|
||||
sptr<ScreenGroupInfo> DisplayManagerService::GetScreenGroupInfoById(ScreenId screenId)
|
||||
{
|
||||
auto screenGroup = abstractScreenController_->GetAbstractScreenGroup(screenId);
|
||||
if (screenGroup == nullptr) {
|
||||
WLOGE("cannot find screenGroupInfo: %{public}" PRIu64"", screenId);
|
||||
return nullptr;
|
||||
}
|
||||
return screenGroup->ConvertToScreenGroupInfo();
|
||||
}
|
||||
|
||||
std::vector<sptr<ScreenInfo>> DisplayManagerService::GetAllScreenInfos()
|
||||
{
|
||||
std::vector<ScreenId> screenIds = abstractScreenController_->GetAllScreenIds();
|
||||
std::vector<sptr<ScreenInfo>> screenInfos;
|
||||
for (auto screenId: screenIds) {
|
||||
auto screenInfo = GetScreenInfoById(screenId);
|
||||
if (screenInfo == nullptr) {
|
||||
WLOGE("cannot find screenInfo: %{public}" PRIu64"", screenId);
|
||||
continue;
|
||||
}
|
||||
screenInfos.emplace_back(screenInfo);
|
||||
}
|
||||
return screenInfos;
|
||||
}
|
||||
|
||||
DMError DisplayManagerService::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
{
|
||||
// todo: make expand
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
@@ -146,6 +146,43 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
reply.WriteInt32(static_cast<int32_t>(result));
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_GET_SCREEN_INFO_BY_ID: {
|
||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||
auto screenInfo = GetScreenInfoById(screenId);
|
||||
reply.WriteStrongParcelable(screenInfo);
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID: {
|
||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||
auto screenGroupInfo = GetScreenGroupInfoById(screenId);
|
||||
reply.WriteStrongParcelable(screenGroupInfo);
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_GET_ALL_SCREEN_INFOS: {
|
||||
std::vector<sptr<ScreenInfo>> screenInfos = GetAllScreenInfos();
|
||||
uint32_t nums = static_cast<uint32_t>(screenInfos.size());
|
||||
reply.WriteUint32(nums);
|
||||
for (uint32_t i = 0; i < nums; ++i) {
|
||||
reply.WriteStrongParcelable(screenInfos[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_SCREEN_MAKE_EXPAND: {
|
||||
std::vector<ScreenId> screenId;
|
||||
if (!data.ReadUInt64Vector(&screenId)) {
|
||||
WLOGE("fail to receive expand screen in stub.");
|
||||
break;
|
||||
}
|
||||
std::vector<Point> startPoint;
|
||||
uint32_t nums = data.ReadUint32();
|
||||
for (uint32_t i = 0; i < nums; ++i) {
|
||||
Point point { data.ReadInt32(), data.ReadInt32() };
|
||||
startPoint.push_back(point);
|
||||
}
|
||||
DMError result = MakeExpand(screenId, startPoint);
|
||||
reply.WriteInt32(static_cast<int32_t>(result));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WLOGFW("unknown transaction code");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "dm_common.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class ScreenGroup;
|
||||
class ScreenInfo;
|
||||
using ScreenId = uint64_t;
|
||||
static constexpr ScreenId SCREEN_ID_INVALID = -1ULL;
|
||||
|
||||
@@ -44,7 +44,7 @@ struct VirtualScreenOption {
|
||||
|
||||
class Screen : public RefBase {
|
||||
public:
|
||||
Screen();
|
||||
Screen(const ScreenInfo* info);
|
||||
~Screen();
|
||||
bool IsGroup() const;
|
||||
ScreenId GetId() const;
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
float GetVirtualPixelRatio() const;
|
||||
bool RequestRotation(Rotation rotation);
|
||||
Rotation GetRotation() const;
|
||||
sptr<ScreenGroup> GetParent() const;
|
||||
ScreenId GetParentId() const;
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "screen.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class ScreenGroupInfo;
|
||||
enum class ScreenCombination : uint32_t {
|
||||
SCREEN_ALONE,
|
||||
SCREEN_EXPAND,
|
||||
@@ -29,13 +30,12 @@ enum class ScreenCombination : uint32_t {
|
||||
|
||||
class ScreenGroup : public Screen {
|
||||
public:
|
||||
ScreenGroup(const ScreenGroupInfo* info);
|
||||
~ScreenGroup();
|
||||
ScreenCombination GetCombination() const;
|
||||
std::vector<sptr<Screen>> GetChildren() const;
|
||||
std::vector<ScreenId> GetChildrenIds() const;
|
||||
|
||||
private:
|
||||
ScreenGroup();
|
||||
~ScreenGroup();
|
||||
|
||||
class Impl;
|
||||
sptr<Impl> pImpl_;
|
||||
};
|
||||
|
||||
@@ -34,8 +34,9 @@ public:
|
||||
class ScreenManager : public RefBase {
|
||||
WM_DECLARE_SINGLE_INSTANCE_BASE(ScreenManager);
|
||||
public:
|
||||
sptr<Screen> GetScreenById(ScreenId id);
|
||||
std::vector<const sptr<Screen>> GetAllScreens();
|
||||
sptr<Screen> GetScreenById(ScreenId screenId);
|
||||
sptr<ScreenGroup> GetScreenGroupById(ScreenId screenId);
|
||||
std::vector<sptr<Screen>> GetAllScreens();
|
||||
|
||||
void RegisterScreenListener(sptr<IScreenListener> listener);
|
||||
ScreenId MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint);
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
void Update(sptr<ScreenGroupInfo> info);
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override;
|
||||
ScreenGroupInfo* Unmarshalling(Parcel& parcel);
|
||||
static ScreenGroupInfo* Unmarshalling(Parcel& parcel);
|
||||
|
||||
std::vector<ScreenId> children_;
|
||||
std::vector<Point> position_;
|
||||
|
||||
Reference in New Issue
Block a user