mirror of
https://gitee.com/openharmony/window_window_manager
synced 2025-02-26 02:35:54 +00:00
add
Signed-off-by: c30063259 <chenjunliang26@h-partners.com>
This commit is contained in:
parent
4f38c85b26
commit
c8661b0b65
@ -823,13 +823,13 @@ public:
|
||||
WMError ReleaseForegroundSessionScreenLock();
|
||||
|
||||
/**
|
||||
* @brief Get window displayIds.
|
||||
* @brief Get displayId by windowId.
|
||||
*
|
||||
* @param windowIds list of window ids that need to get screen ids
|
||||
* @param windowDisplayIdMap map of windows and displayIds
|
||||
* @return WM_OK means get success, others means failed.
|
||||
*/
|
||||
WMError GetWindowDisplayIds(std::vector<uint64_t>& windowIds,
|
||||
WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap);
|
||||
|
||||
private:
|
||||
|
@ -485,7 +485,7 @@ public:
|
||||
/*
|
||||
* Window displayId
|
||||
*/
|
||||
WMError GetWindowDisplayIds(std::vector<uint64_t>& windowIds,
|
||||
WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap) override;
|
||||
|
||||
protected:
|
||||
|
@ -315,7 +315,7 @@ public:
|
||||
|
||||
WMError IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode) override { return WMError::WM_OK; }
|
||||
|
||||
WMError GetWindowDisplayIds(std::vector<uint64_t>& windowIds,
|
||||
WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap) override { return WMError::WM_OK; }
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -129,7 +129,7 @@ public:
|
||||
WMError ReleaseForegroundSessionScreenLock() override;
|
||||
WMError GetDisplayIdByPersistentId(int32_t persistentId, int32_t& displayId) override;
|
||||
WMError IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode) override;
|
||||
WMError GetWindowDisplayIds(std::vector<uint64_t>& windowIds,
|
||||
WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap) override;
|
||||
|
||||
private:
|
||||
|
@ -106,7 +106,7 @@ private:
|
||||
int HandleReleaseForegroundSessionScreenLock(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetDisplayIdByPersistentId(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleIsPcOrPadFreeMultiWindowMode(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetWindowDisplayIds(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetDisplayIdByWindowId(MessageParcel& data, MessageParcel& reply);
|
||||
|
||||
int ProcessRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option);
|
||||
};
|
||||
|
@ -11232,28 +11232,32 @@ WMError SceneSessionManager::IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMul
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError SceneSessionManager::GetWindowDisplayIds(std::vector<uint64_t>& windowIds,
|
||||
WMError SceneSessionManager::GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap)
|
||||
{
|
||||
if (!SessionPermission::IsSACalling() && !SessionPermission::IsShellCall()) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "permission denied!");
|
||||
return WMError::WM_ERROR_INVALID_PERMISSION;
|
||||
}
|
||||
for (uint64_t windowId : windowIds)
|
||||
{
|
||||
sptr<SceneSession> session = GetSceneSession(static_cast<int32_t>(windowId));
|
||||
if (session == nullptr) {
|
||||
continue;
|
||||
|
||||
auto task = [this, windowIds, &windowDisplayIdMap]() {
|
||||
for (uint64_t windowId : windowIds)
|
||||
{
|
||||
sptr<SceneSession> session = GetSceneSession(static_cast<int32_t>(windowId));
|
||||
if (session == nullptr) {
|
||||
continue;
|
||||
}
|
||||
sptr<WindowSessionProperty> sessionProperty = session->GetSessionProperty();
|
||||
if (sessionProperty == nullptr) {
|
||||
continue;
|
||||
}
|
||||
TLOGI(WmsLogTag::DEFAULT, "windowId:%{public}" PRIu64", displayId:%{public}" PRIu64"",
|
||||
windowId, sessionProperty->GetDisplayId());
|
||||
windowDisplayIdMap.insert({windowId, sessionProperty->GetDisplayId()});
|
||||
}
|
||||
sptr<WindowSessionProperty> sessionProperty = session->GetSessionProperty();
|
||||
if (sessionProperty == nullptr) {
|
||||
continue;
|
||||
}
|
||||
TLOGI(WmsLogTag::DEFAULT, "windowId:%{public}" PRIu64", displayId:%{public}" PRIu64"",
|
||||
windowId, sessionProperty->GetDisplayId());
|
||||
windowDisplayIdMap.insert({windowId, sessionProperty->GetDisplayId()});
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
return WMError::WM_OK;
|
||||
};
|
||||
return taskScheduler_->PostSyncTask(task, "GetDisplayIdByWindowId");
|
||||
}
|
||||
|
||||
} // namespace OHOS::Rosen
|
@ -2478,7 +2478,7 @@ WMError SceneSessionManagerProxy::IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFr
|
||||
return static_cast<WMError>(ret);
|
||||
}
|
||||
|
||||
WMError SceneSessionManagerProxy::GetWindowDisplayIds(std::vector<uint64_t>& windowIds,
|
||||
WMError SceneSessionManagerProxy::GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
@ -186,7 +186,7 @@ int SceneSessionManagerStub::ProcessRemoteRequest(uint32_t code, MessageParcel&
|
||||
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_PC_OR_PAD_FREE_MULTI_WINDOW_MODE):
|
||||
return HandleIsPcOrPadFreeMultiWindowMode(data, reply);
|
||||
case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_DISPLAYIDS):
|
||||
return HandleGetWindowDisplayIds(data, reply);
|
||||
return HandleGetDisplayIdByWindowId(data, reply);
|
||||
default:
|
||||
WLOGFE("Failed to find function handler!");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
@ -1244,7 +1244,7 @@ int SceneSessionManagerStub::HandleIsPcOrPadFreeMultiWindowMode(MessageParcel& d
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int SceneSessionManagerStub::HandleGetWindowDisplayIds(MessageParcel& data, MessageParcel& reply)
|
||||
int SceneSessionManagerStub::HandleGetDisplayIdByWindowId(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
std::vector<uint64_t> windowIds;
|
||||
if (!data.ReadUInt64Vector(&windowIds)) {
|
||||
@ -1252,7 +1252,7 @@ int SceneSessionManagerStub::HandleGetWindowDisplayIds(MessageParcel& data, Mess
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
|
||||
WMError errCode = GetWindowDisplayIds(windowIds, windowDisplayIdMap);
|
||||
WMError errCode = GetDisplayIdByWindowId(windowIds, windowDisplayIdMap);
|
||||
|
||||
if (!reply.WriteInt32(static_cast<int32_t>(windowDisplayIdMap.size()))) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "Write windowDisplayIdMap size faild");
|
||||
@ -1269,7 +1269,7 @@ int SceneSessionManagerStub::HandleGetWindowDisplayIds(MessageParcel& data, Mess
|
||||
}
|
||||
}
|
||||
if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
|
||||
TLOGE(WmsLogTag::WMS_SUB, "Write errCode fail.");
|
||||
TLOGE(WmsLogTag::DEFAULT, "Write errCode fail.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
return ERR_NONE;
|
||||
|
@ -1101,19 +1101,19 @@ HWTEST_F(sceneSessionManagerProxyTest, IsPcOrPadFreeMultiWindowMode, Function |
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetWindowDisplayIds
|
||||
* @tc.desc: GetWindowDisplayIds
|
||||
* @tc.name: GetDisplayIdByWindowId
|
||||
* @tc.desc: GetDisplayIdByWindowId
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(sceneSessionManagerProxyTest, GetWindowDisplayIds, Function | SmallTest | Level2)
|
||||
HWTEST_F(sceneSessionManagerProxyTest, GetDisplayIdByWindowId, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker();
|
||||
sptr<SceneSessionManagerProxy> sceneSessionManagerProxy =
|
||||
new SceneSessionManagerProxy(iRemoteObjectMocker);
|
||||
ASSERT_TRUE(sceneSessionManagerProxy != nullptr);
|
||||
std::vector<uint64_t> windowIds = {1, 2};
|
||||
const std::vector<uint64_t> windowIds = {1, 2};
|
||||
std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
|
||||
sceneSessionManagerProxy->GetWindowDisplayIds(windowIds, windowDisplayIdMap);
|
||||
sceneSessionManagerProxy->GetDisplayIdByWindowId(windowIds, windowDisplayIdMap);
|
||||
}
|
||||
} // namespace
|
||||
}
|
||||
|
@ -2126,18 +2126,18 @@ HWTEST_F(SceneSessionManagerStubTest, HandleIsPcOrPadFreeMultiWindowMode, Functi
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: HandleGetWindowDisplayIds
|
||||
* @tc.desc: test HandleGetWindowDisplayIds
|
||||
* @tc.name: HandleGetDisplayIdByWindowId
|
||||
* @tc.desc: test HandleGetDisplayIdByWindowId
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SceneSessionManagerStubTest, HandleGetWindowDisplayIds, Function | SmallTest | Level2)
|
||||
HWTEST_F(SceneSessionManagerStubTest, HandleGetDisplayIdByWindowId, Function | SmallTest | Level2)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
std::vector<uint64_t> windowIds = {1, 2};
|
||||
const std::vector<uint64_t> windowIds = {1, 2};
|
||||
data.WriteUInt64Vector(windowIds);
|
||||
|
||||
int res = stub_->HandleGetWindowDisplayIds(data, reply);
|
||||
int res = stub_->HandleGetDisplayIdByWindowId(data, reply);
|
||||
EXPECT_EQ(res, ERR_NONE);
|
||||
}
|
||||
}
|
||||
|
@ -2104,11 +2104,11 @@ HWTEST_F(SceneSessionManagerTest, IsPcOrPadFreeMultiWindowMode, Function | Small
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetWindowDisplayIds
|
||||
* @tc.desc: test function : GetWindowDisplayIds
|
||||
* @tc.name: GetDisplayIdByWindowId
|
||||
* @tc.desc: test function : GetDisplayIdByWindowId
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SceneSessionManagerTest, GetWindowDisplayIds, Function | SmallTest | Level3)
|
||||
HWTEST_F(SceneSessionManagerTest, GetDisplayIdByWindowId, Function | SmallTest | Level3)
|
||||
{
|
||||
SessionInfo info;
|
||||
info.abilityName_ = "test";
|
||||
@ -2123,9 +2123,9 @@ HWTEST_F(SceneSessionManagerTest, GetWindowDisplayIds, Function | SmallTest | Le
|
||||
property->SetDisplayId(displayId);
|
||||
sceneSession1->SetSessionProperty(property);
|
||||
|
||||
std::vector<uint64_t> windowIds = {1001, sceneSession1->GetPersistentId(), sceneSession2->GetPersistentId()};
|
||||
const std::vector<uint64_t> windowIds = {1001, sceneSession1->GetPersistentId(), sceneSession2->GetPersistentId()};
|
||||
std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
|
||||
ASSERT_EQ(ssm_->GetWindowDisplayIds(windowIds, windowDisplayIdMap), WMError::WM_OK);
|
||||
ASSERT_EQ(ssm_->GetDisplayIdByWindowId(windowIds, windowDisplayIdMap), WMError::WM_OK);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
*/
|
||||
virtual WMError IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode);
|
||||
|
||||
virtual WMError GetWindowDisplayIds(std::vector<uint64_t>& windowIds,
|
||||
virtual WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap);
|
||||
|
||||
private:
|
||||
|
@ -1001,13 +1001,13 @@ WMError WindowAdapter::IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWind
|
||||
return wmsProxy->IsPcOrPadFreeMultiWindowMode(isPcOrPadFreeMultiWindowMode);
|
||||
}
|
||||
|
||||
WMError WindowAdapter::GetWindowDisplayIds(std::vector<uint64_t>& windowIds,
|
||||
WMError WindowAdapter::GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
|
||||
auto wmsProxy = GetWindowManagerServiceProxy();
|
||||
CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
|
||||
return wmsProxy->GetWindowDisplayIds(windowIds, windowDisplayIdMap);
|
||||
return wmsProxy->GetDisplayIdByWindowId(windowIds, windowDisplayIdMap);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -1446,10 +1446,10 @@ WMError WindowManager::ReleaseForegroundSessionScreenLock()
|
||||
return ret;
|
||||
}
|
||||
|
||||
WMError WindowManager::GetWindowDisplayIds(std::vector<uint64_t>& windowIds,
|
||||
WMError WindowManager::GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap)
|
||||
{
|
||||
WMError ret = SingletonContainer::Get<WindowAdapter>().GetWindowDisplayIds(windowIds, windowDisplayIdMap);
|
||||
WMError ret = SingletonContainer::Get<WindowAdapter>().GetDisplayIdByWindowId(windowIds, windowDisplayIdMap);
|
||||
if (ret != WMError::WM_OK) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "failed");
|
||||
}
|
||||
|
@ -740,16 +740,16 @@ HWTEST_F(WindowAdapterTest, IsPcOrPadFreeMultiWindowMode, Function | SmallTest |
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetWindowDisplayIds
|
||||
* @tc.desc: WindowAdapter/GetWindowDisplayIds
|
||||
* @tc.name: GetDisplayIdByWindowId
|
||||
* @tc.desc: WindowAdapter/GetDisplayIdByWindowId
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAdapterTest, GetWindowDisplayIds, Function | SmallTest | Level2)
|
||||
HWTEST_F(WindowAdapterTest, GetDisplayIdByWindowId, Function | SmallTest | Level2)
|
||||
{
|
||||
WindowAdapter windowAdapter;
|
||||
std::vector<uint64_t> windowIds = {1, 2};
|
||||
const std::vector<uint64_t> windowIds = {1, 2};
|
||||
std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
|
||||
auto err = windowAdapter.GetWindowDisplayIds(windowIds, windowDisplayIdMap);
|
||||
auto err = windowAdapter.GetDisplayIdByWindowId(windowIds, windowDisplayIdMap);
|
||||
ASSERT_EQ(err, WMError::WM_OK);
|
||||
}
|
||||
}
|
||||
|
@ -1479,11 +1479,11 @@ HWTEST_F(WindowManagerTest, ReleaseForegroundSessionScreenLock, Function | Small
|
||||
* @tc.desc: check SetProcessWatermark
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerTest, GetWindowDisplayIds, Function | SmallTest | Level2)
|
||||
HWTEST_F(WindowManagerTest, GetDisplayIdByWindowId, Function | SmallTest | Level2)
|
||||
{
|
||||
std::vector<uint64_t> windowIds = {1, 2};
|
||||
const std::vector<uint64_t> windowIds = {1, 2};
|
||||
std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
|
||||
auto ret = WindowManager::GetInstance().GetWindowDisplayIds(windowIds, windowDisplayIdMap);
|
||||
auto ret = WindowManager::GetInstance().GetDisplayIdByWindowId(windowIds, windowDisplayIdMap);
|
||||
ASSERT_EQ(WMError::WM_OK, ret);
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ public:
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
virtual WMError IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode) { return WMError::WM_OK; }
|
||||
virtual WMError GetWindowDisplayIds(std::vector<uint64_t>& windowIds,
|
||||
virtual WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
|
||||
std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap) { return WMError::WM_OK; }
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user