mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
modify the makemirror reture para type
Signed-off-by: xiaojianfeng <xiaojianfeng3@huawei.com> Change-Id: Ib5cd6d5a3927d200be1ec3f987d25e09238aa245
This commit is contained in:
@@ -84,8 +84,8 @@ public:
|
||||
virtual sptr<Screen> GetScreenById(ScreenId screenId);
|
||||
virtual sptr<ScreenGroup> GetScreenGroupById(ScreenId screenId);
|
||||
virtual std::vector<sptr<Screen>> GetAllScreens();
|
||||
virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId);
|
||||
virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint);
|
||||
virtual ScreenId MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId);
|
||||
virtual ScreenId MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint);
|
||||
virtual bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId);
|
||||
virtual void UpdateScreenInfo(ScreenId);
|
||||
|
||||
|
||||
@@ -373,11 +373,11 @@ void BaseAdapter::Clear()
|
||||
displayManagerServiceProxy_ = nullptr;
|
||||
}
|
||||
|
||||
DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
|
||||
ScreenId ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId);
|
||||
}
|
||||
@@ -495,11 +495,11 @@ std::vector<sptr<Screen>> ScreenManagerAdapter::GetAllScreens()
|
||||
return screens;
|
||||
}
|
||||
|
||||
DMError ScreenManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
ScreenId ScreenManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
return displayManagerServiceProxy_->MakeExpand(screenId, startPoint);
|
||||
}
|
||||
|
||||
@@ -172,23 +172,22 @@ ScreenId ScreenManager::MakeExpand(const std::vector<ExpandOption>& options)
|
||||
screenIds.emplace_back(option.screenId_);
|
||||
startPoints.emplace_back(Point(option.startX_, option.startY_));
|
||||
}
|
||||
DMError result = SingletonContainer::Get<ScreenManagerAdapter>().MakeExpand(screenIds, startPoints);
|
||||
if (result != DMError::DM_OK) {
|
||||
return SCREEN_ID_INVALID;
|
||||
ScreenId group = SingletonContainer::Get<ScreenManagerAdapter>().MakeExpand(screenIds, startPoints);
|
||||
if (group == SCREEN_ID_INVALID) {
|
||||
WLOGFI("make expand failed");
|
||||
}
|
||||
WLOGFI("make expand success");
|
||||
return screenIds.front(); // default main screenId is the first element of screenIds
|
||||
return group;
|
||||
}
|
||||
|
||||
ScreenId ScreenManager::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
|
||||
{
|
||||
WLOGFI("create mirror for screen: %{public}" PRIu64"", mainScreenId);
|
||||
// TODO: "record screen" should use another function, "MakeMirror" should return group id.
|
||||
DMError result = SingletonContainer::Get<ScreenManagerAdapter>().MakeMirror(mainScreenId, mirrorScreenId);
|
||||
if (result == DMError::DM_OK) {
|
||||
WLOGFI("create mirror success");
|
||||
ScreenId group = SingletonContainer::Get<ScreenManagerAdapter>().MakeMirror(mainScreenId, mirrorScreenId);
|
||||
if (group == SCREEN_ID_INVALID) {
|
||||
WLOGFI("create mirror failed");
|
||||
}
|
||||
return SCREEN_ID_INVALID;
|
||||
return group;
|
||||
}
|
||||
|
||||
ScreenId ScreenManager::CreateVirtualScreen(VirtualScreenOption option)
|
||||
|
||||
@@ -57,8 +57,8 @@ public:
|
||||
MOCK_METHOD1(GetScreenById, sptr<Screen>(ScreenId screenId));
|
||||
MOCK_METHOD1(GetScreenGroupById, sptr<ScreenGroup>(ScreenId screenId));
|
||||
MOCK_METHOD0(GetAllScreens, std::vector<sptr<Screen>>());
|
||||
MOCK_METHOD2(MakeMirror, DMError(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId));
|
||||
MOCK_METHOD2(MakeExpand, DMError(std::vector<ScreenId> screenId, std::vector<Point> startPoint));
|
||||
MOCK_METHOD2(MakeMirror, ScreenId(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId));
|
||||
MOCK_METHOD2(MakeExpand, ScreenId(std::vector<ScreenId> screenId, std::vector<Point> startPoint));
|
||||
MOCK_METHOD2(SetScreenActiveMode, bool(ScreenId screenId, uint32_t modeId));
|
||||
MOCK_METHOD1(UpdateScreenInfo, void(ScreenId screenId));
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ HWTEST_F(ScreenManagerTest, MakeExpand_001, Function | SmallTest | Level1)
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
EXPECT_CALL(m->Mock(), CreateVirtualScreen(_)).Times(1).WillOnce(Return(virtualScreenId));
|
||||
EXPECT_CALL(m->Mock(), DestroyVirtualScreen(_)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
EXPECT_CALL(m->Mock(), MakeExpand(_, _)).Times(1).WillOnce(Return(DMError::DM_OK));
|
||||
EXPECT_CALL(m->Mock(), MakeExpand(_, _)).Times(1).WillOnce(Return(0));
|
||||
ScreenId vScreenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
|
||||
std::vector<ExpandOption> options = {{validId, 0, 0}, {vScreenId, defaultWidth_, 0}};
|
||||
ScreenId expansionId = ScreenManager::GetInstance().MakeExpand(options);
|
||||
|
||||
@@ -99,8 +99,8 @@ public:
|
||||
virtual sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) = 0;
|
||||
virtual sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) = 0;
|
||||
virtual std::vector<sptr<ScreenInfo>> GetAllScreenInfos() = 0;
|
||||
virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId) = 0;
|
||||
virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint) = 0;
|
||||
virtual ScreenId MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId) = 0;
|
||||
virtual ScreenId MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint) = 0;
|
||||
virtual bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId) = 0;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
@@ -60,11 +60,11 @@ public:
|
||||
bool SetDisplayState(DisplayState state) override;
|
||||
DisplayState GetDisplayState(DisplayId displayId) override;
|
||||
void NotifyDisplayEvent(DisplayEvent event) override;
|
||||
DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId) override;
|
||||
ScreenId 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;
|
||||
ScreenId MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint) override;
|
||||
bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -82,11 +82,11 @@ public:
|
||||
sptr<AbstractDisplay> GetAbstractDisplay(DisplayId displayId);
|
||||
sptr<AbstractScreenController> GetAbstractScreenController();
|
||||
sptr<AbstractDisplay> GetDisplayByDisplayId(DisplayId displayId) const;
|
||||
DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId) override;
|
||||
ScreenId 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;
|
||||
ScreenId MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint) override;
|
||||
bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -625,12 +625,12 @@ void DisplayManagerProxy::NotifyDisplayEvent(DisplayEvent event)
|
||||
}
|
||||
}
|
||||
|
||||
DMError DisplayManagerProxy::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
|
||||
ScreenId DisplayManagerProxy::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("create mirror fail: remote is null");
|
||||
return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@@ -638,19 +638,19 @@ DMError DisplayManagerProxy::MakeMirror(ScreenId mainScreenId, std::vector<Scree
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("create mirror fail: WriteInterfaceToken failed");
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
bool res = data.WriteUint64(static_cast<uint64_t>(mainScreenId)) &&
|
||||
data.WriteUInt64Vector(mirrorScreenId);
|
||||
if (!res) {
|
||||
WLOGFE("create mirror fail: data write failed");
|
||||
return DMError::DM_ERROR_WRITE_DATA_FAILED;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
if (remote->SendRequest(TRANS_ID_SCREEN_MAKE_MIRROR, data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("create mirror fail: SendRequest failed");
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
return static_cast<ScreenId>(reply.ReadUint64());
|
||||
}
|
||||
|
||||
sptr<ScreenInfo> DisplayManagerProxy::GetScreenInfoById(ScreenId screenId)
|
||||
@@ -750,12 +750,12 @@ std::vector<sptr<ScreenInfo>> DisplayManagerProxy::GetAllScreenInfos()
|
||||
return screenInfos;
|
||||
}
|
||||
|
||||
DMError DisplayManagerProxy::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
ScreenId 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;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@@ -763,28 +763,28 @@ DMError DisplayManagerProxy::MakeExpand(std::vector<ScreenId> screenId, std::vec
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("MakeExpand: WriteInterfaceToken failed");
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
if (!data.WriteUInt64Vector(screenId)) {
|
||||
WLOGFE("MakeExpand: write screenId failed");
|
||||
return DMError::DM_ERROR_WRITE_DATA_FAILED;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
uint32_t num = startPoint.size();
|
||||
if (!data.WriteUint32(num)) {
|
||||
WLOGFE("MakeExpand: write startPoint size failed");
|
||||
return DMError::DM_ERROR_WRITE_DATA_FAILED;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
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;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
}
|
||||
if (remote->SendRequest(TRANS_ID_SCREEN_MAKE_EXPAND, data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("MakeExpand: SendRequest failed");
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
return static_cast<ScreenId>(reply.ReadUint64());
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
|
||||
@@ -380,7 +380,7 @@ void DisplayManagerService::SetShotScreen(ScreenId mainScreenId, std::vector<Scr
|
||||
transactionProxy->FlushImplicitTransaction();
|
||||
}
|
||||
|
||||
DMError DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds)
|
||||
ScreenId DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds)
|
||||
{
|
||||
WLOGFI("MakeMirror. mainScreenId :%{public}" PRIu64"", mainScreenId);
|
||||
abstractScreenController_->DumpScreenInfo();
|
||||
@@ -396,16 +396,21 @@ DMError DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector<Scr
|
||||
}
|
||||
if (mainScreenId == SCREEN_ID_INVALID || (shotScreenIds.empty() && allMirrorScreenIds.empty())) {
|
||||
WLOGFI("create mirror fail, screen is invalid. Screen :%{public}" PRIu64"", mainScreenId);
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
SetShotScreen(mainScreenId, shotScreenIds);
|
||||
WM_SCOPED_TRACE("dms:MakeMirror");
|
||||
if (!allMirrorScreenIds.empty() && !abstractScreenController_->MakeMirror(mainScreenId, allMirrorScreenIds)) {
|
||||
WLOGFE("make mirror failed.");
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
abstractScreenController_->DumpScreenInfo();
|
||||
return DMError::DM_OK;
|
||||
auto screen = abstractScreenController_->GetAbstractScreen(mainScreenId);
|
||||
if (screen == nullptr || abstractScreenController_->GetAbstractScreenGroup(screen->groupDmsId_) == nullptr) {
|
||||
WLOGFE("get screen group failed.");
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
return screen->groupDmsId_;
|
||||
}
|
||||
|
||||
void DisplayManagerService::UpdateRSTree(DisplayId displayId, std::shared_ptr<RSSurfaceNode>& surfaceNode,
|
||||
@@ -454,14 +459,14 @@ std::vector<sptr<ScreenInfo>> DisplayManagerService::GetAllScreenInfos()
|
||||
return screenInfos;
|
||||
}
|
||||
|
||||
DMError DisplayManagerService::MakeExpand(std::vector<ScreenId> expandScreenIds, std::vector<Point> startPoints)
|
||||
ScreenId DisplayManagerService::MakeExpand(std::vector<ScreenId> expandScreenIds, std::vector<Point> startPoints)
|
||||
{
|
||||
WLOGI("MakeExpand");
|
||||
if (expandScreenIds.empty() || startPoints.empty() || expandScreenIds.size() != startPoints.size()) {
|
||||
WLOGFI("create expand fail, input params is invalid. "
|
||||
"screenId vector size :%{public}ud, startPoint vector size :%{public}ud",
|
||||
static_cast<uint32_t>(expandScreenIds.size()), static_cast<uint32_t>(startPoints.size()));
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
abstractScreenController_->DumpScreenInfo();
|
||||
ScreenId defaultScreenId = abstractScreenController_->GetDefaultAbstractScreenId();
|
||||
@@ -484,10 +489,15 @@ DMError DisplayManagerService::MakeExpand(std::vector<ScreenId> expandScreenIds,
|
||||
WM_SCOPED_TRACE("dms:MakeExpand");
|
||||
if (!allExpandScreenIds.empty() && !abstractScreenController_->MakeExpand(allExpandScreenIds, startPoints)) {
|
||||
WLOGFE("make expand failed.");
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
abstractScreenController_->DumpScreenInfo();
|
||||
return DMError::DM_OK;
|
||||
auto screen = abstractScreenController_->GetAbstractScreen(allExpandScreenIds[0]);
|
||||
if (screen == nullptr || abstractScreenController_->GetAbstractScreenGroup(screen->groupDmsId_) == nullptr) {
|
||||
WLOGFE("get screen group failed.");
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
return screen->groupDmsId_;
|
||||
}
|
||||
|
||||
bool DisplayManagerService::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
|
||||
@@ -159,8 +159,8 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
WLOGE("fail to receive mirror screen in stub. screen:%{public}" PRIu64"", mainScreenId);
|
||||
break;
|
||||
}
|
||||
DMError result = MakeMirror(mainScreenId, mirrorScreenId);
|
||||
reply.WriteInt32(static_cast<int32_t>(result));
|
||||
ScreenId result = MakeMirror(mainScreenId, mirrorScreenId);
|
||||
reply.WriteUint64(static_cast<uint64_t>(result));
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_GET_SCREEN_INFO_BY_ID: {
|
||||
@@ -200,8 +200,8 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
Point point { data.ReadInt32(), data.ReadInt32() };
|
||||
startPoint.push_back(point);
|
||||
}
|
||||
DMError result = MakeExpand(screenId, startPoint);
|
||||
reply.WriteInt32(static_cast<int32_t>(result));
|
||||
ScreenId result = MakeExpand(screenId, startPoint);
|
||||
reply.WriteUint64(static_cast<uint64_t>(result));
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_SET_SCREEN_ACTIVE_MODE: {
|
||||
|
||||
Reference in New Issue
Block a user