mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
支持删除指定任务
Signed-off-by: hubijie <hubijie@huawei.com>
This commit is contained in:
commit
36a47d0172
@ -158,7 +158,7 @@ public:
|
||||
* @brief Clear a specified set of sessions.
|
||||
*
|
||||
* @param persistentIds a vector of session persistentId.
|
||||
* @return WM_OK means get success, others means get failed.
|
||||
* @return WM_OK means clear session success, others means clear failed.
|
||||
*/
|
||||
WMError ClearMainSessions(const std::vector<int32_t>& persistentIds);
|
||||
|
||||
@ -167,7 +167,7 @@ public:
|
||||
*
|
||||
* @param persistentIds a vector of session persistentId.
|
||||
* @param clearFailedIds a vector of sessioni persistentId which is clear failed.
|
||||
* @return WM_OK means get success, others means get failed.
|
||||
* @return WM_OK means clear session success, others means clear failed.
|
||||
*/
|
||||
WMError ClearMainSessions(const std::vector<int32_t>& persistentIds, std::vector<int32_t>& clearFailedIds);
|
||||
private:
|
||||
|
@ -432,9 +432,11 @@ struct MainWindowInfo : public Parcelable {
|
||||
if (!parcel.WriteString(bundleName_)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.WriteInt32(persistentId_)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.WriteInt32(bundleType_)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
std::vector<MainWindowInfo>& topNInfo));
|
||||
MOCK_METHOD1(GetAllMainWindowInfos, WMError(std::vector<MainWindowInfo>& infos));
|
||||
MOCK_METHOD1(ClearMainSessions, WMError(const std::vector<int32_t>& persistentIds));
|
||||
MOCK_METHOD2(ClearMainSessions, WMError(std::vector<int32_t>& persistentIds,
|
||||
MOCK_METHOD2(ClearMainSessions, WMError(const std::vector<int32_t>& persistentIds,
|
||||
std::vector<int32_t>& clearFailedIds));
|
||||
};
|
||||
}
|
||||
|
@ -2431,8 +2431,6 @@ bool Session::IsSupportDetectWindow(bool isAttach)
|
||||
}
|
||||
// Only detecting cold start scenarios on PC
|
||||
if (isPc && (!isAttach || state_ != SessionState::STATE_DISCONNECT)) {
|
||||
TLOGI(WmsLogTag::WMS_LIFE, "Window state detect not support: Only support cold start on pc, "
|
||||
"persistentId:%{public}d", persistentId_);
|
||||
RemoveWindowDetectTask();
|
||||
return false;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ private:
|
||||
int HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetWindowModeType(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetMainWinodowInfo(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetAllMainWinodowInfos(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleGetAllMainWindowInfos(MessageParcel& data, MessageParcel& reply);
|
||||
int HandleClearMainSessions(MessageParcel& data, MessageParcel& reply);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -8644,7 +8644,7 @@ WSError SceneSessionManager::NotifyEnterRecentTask(bool enterRecent)
|
||||
WMError SceneSessionManager::GetAllMainWindowInfos(std::vector<MainWindowInfo>& infos) const
|
||||
{
|
||||
if (!infos.empty()) {
|
||||
return WMError::WM_ERROR_INCALID_PARAM;
|
||||
return WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
if (!SessionPermission::IsSACalling() && !SessionPermission::IsShellCall()) {
|
||||
TLOGE(WmsLogTag::WMS_MAIN, "Get all mainWindow infos failed, only support SA calling.");
|
||||
@ -8659,17 +8659,18 @@ WMError SceneSessionManager::GetAllMainWindowInfos(std::vector<MainWindowInfo>&
|
||||
MainWindowInfo info;
|
||||
auto abilityInfo = session->GetSessionInfo().abilityInfo;
|
||||
if (abilityInfo == nullptr) {
|
||||
TLOGW(WmsLogTag::WMS_MAIN, "Session id:%{public}d abilityInfo is null." session->GetPersistentId());
|
||||
TLOGW(WmsLogTag::WMS_MAIN, "Session id:%{public}d abilityInfo is null.", session->GetPersistentId());
|
||||
continue;
|
||||
}
|
||||
info.pid_ = session->GetCallingPid();
|
||||
info.bundleName_ = session->GetSessionInfo().bundleName_;
|
||||
info.persistentId_ = session->GetPersistentId();
|
||||
info.bundleType_ = static_cast<int32_t>(abilityInfo->applicationInfo.bundleType)
|
||||
info.bundleType_ = static_cast<int32_t>(abilityInfo->applicationInfo.bundleType);
|
||||
TLOGD(WmsLogTag::WMS_MAIN, "Get mainWindow info, Session id:%{public}d, bundleName:%{public}s, "
|
||||
"bundleType:%{public}d", session->GetPersistentId(), info.bundleName_.c_str(), info.bundleType_);
|
||||
|
||||
infos.push_back(info);
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError SceneSessionManager::ClearMainSessions(const std::vector<int32_t>& persistentIds,
|
||||
@ -8688,7 +8689,7 @@ WMError SceneSessionManager::ClearMainSessions(const std::vector<int32_t>& persi
|
||||
clearFailedIds.push_back(persistentId);
|
||||
continue;
|
||||
}
|
||||
if (!WindowHelper::IsMainWindow(session->GetWindowType())) {
|
||||
if (!WindowHelper::IsMainWindow(sceneSession->GetWindowType())) {
|
||||
TLOGW(WmsLogTag::WMS_MAIN, "Session id:%{public}d is not mainWindow.", persistentId);
|
||||
clearFailedIds.push_back(persistentId);
|
||||
continue;
|
||||
|
@ -216,7 +216,7 @@ WMError SceneSessionManagerLite::GetAllMainWindowInfos(std::vector<MainWindowInf
|
||||
}
|
||||
|
||||
WMError SceneSessionManagerLite::ClearMainSessions(const std::vector<int32_t>& persistentIds,
|
||||
std::vector<int32_t>& clearFailedIds);
|
||||
std::vector<int32_t>& clearFailedIds)
|
||||
{
|
||||
return SceneSessionManager::GetInstance().ClearMainSessions(persistentIds, clearFailedIds);
|
||||
}
|
||||
|
@ -839,7 +839,7 @@ WMError SceneSessionManagerLiteProxy::GetAllMainWindowInfos(std::vector<MainWind
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (Remote()->SendRequest(static_cast<int32_t>(
|
||||
SceneSessionManagerLiteMessage::TRANS_ID_GET_ALL_MAIN_WINDOW_INFO), data, reply, option) != ERR_NONE) {
|
||||
SceneSessionManagerLiteMessage::TRANS_ID_GET_ALL_MAIN_WINDOW_INFO), data, reply, option) != ERR_NONE) {
|
||||
TLOGE(WmsLogTag::WMS_MAIN, "send request fail");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
@ -868,7 +868,7 @@ WMError SceneSessionManagerLiteProxy::ClearMainSessions(const std::vector<int32_
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (Remote()->SendRequest(static_cast<int32_t>(
|
||||
SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_MAIN_SESSIONS), data, reply, option) != ERR_NONE) {
|
||||
SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_MAIN_SESSIONS), data, reply, option) != ERR_NONE) {
|
||||
TLOGE(WmsLogTag::WMS_MAIN, "send request fail");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ const std::map<uint32_t, SceneSessionManagerLiteStubFunc> SceneSessionManagerLit
|
||||
std::make_pair(static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_WINDOW_MODE_TYPE),
|
||||
&SceneSessionManagerLiteStub::HandleGetWindowModeType),
|
||||
std::make_pair(static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_ALL_MAIN_WINDOW_INFO),
|
||||
&SceneSessionManagerLiteStub::HandleGetAllMainWinodowInfos),
|
||||
&SceneSessionManagerLiteStub::HandleGetAllMainWindowInfos),
|
||||
std::make_pair(static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_MAIN_SESSIONS),
|
||||
&SceneSessionManagerLiteStub::HandleClearMainSessions),
|
||||
};
|
||||
@ -464,11 +464,11 @@ int SceneSessionManagerLiteStub::HandleGetMainWinodowInfo(MessageParcel &data, M
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
int SceneSessionManagerLiteStub::HandleGetAllMainWinodowInfos(MessageParcel& data, MessageParcel& reply)
|
||||
int SceneSessionManagerLiteStub::HandleGetAllMainWindowInfos(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
std::vector<MainWindowInfo> infos;
|
||||
WMError errCode = GetAllMainWinodowInfos(infos);
|
||||
reply.WriteInt32(info.size());
|
||||
WMError errCode = GetAllMainWindowInfos(infos);
|
||||
reply.WriteInt32(infos.size());
|
||||
for (auto& info : infos) {
|
||||
if (!reply.WriteParcelable(&info)) {
|
||||
TLOGE(WmsLogTag::WMS_MAIN, "write main window info fail");
|
||||
|
@ -142,7 +142,7 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub {
|
||||
infos.push_back(mainWindowInfo);
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
WMError ClearMainSessions(const std::vector<int32_t>& persistentIds,
|
||||
WMError ClearMainSessions(const std::vector<int32_t>& persistentIds,
|
||||
std::vector<int32_t>& clearFailedIds) override
|
||||
{
|
||||
clearFailedIds.push_back(1);
|
||||
@ -578,16 +578,16 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetMainWinodowInfo, Function | S
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: HandleGetAllMainWinodowInfos
|
||||
* @tc.desc: test function : HandleGetAllMainWinodowInfos
|
||||
* @tc.name: HandleGetAllMainWindowInfos
|
||||
* @tc.desc: test function : HandleGetAllMainWindowInfos
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetAllMainWinodowInfos, Function | SmallTest | Level1)
|
||||
HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetAllMainWindowInfos, Function | SmallTest | Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = sceneSessionManagerLiteStub_->
|
||||
SceneSessionManagerLiteStub::HandleGetAllMainWinodowInfos(data, reply);
|
||||
SceneSessionManagerLiteStub::HandleGetAllMainWindowInfos(data, reply);
|
||||
EXPECT_EQ(ERR_NONE, res);
|
||||
}
|
||||
|
||||
|
@ -4404,7 +4404,7 @@ HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos001, Function | SmallTest
|
||||
std::vector<MainWindowInfo> infos;
|
||||
WMError result = ssm_->GetAllMainWindowInfos(infos);
|
||||
EXPECT_EQ(result, WMError::WM_OK);
|
||||
ssm_->sceneSessionMap_.erase(SceneSession->GetPersistentId());
|
||||
ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4444,7 +4444,6 @@ HWTEST_F(SceneSessionManagerTest, ClearMainSessions, Function | SmallTest | Leve
|
||||
auto result = ssm_->ClearMainSessions(persistentIds, clearFailedIds);
|
||||
EXPECT_EQ(result, WMError::WM_OK);
|
||||
EXPECT_EQ(clearFailedIds.size(), 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -353,9 +353,9 @@ ohos_shared_library("libwm_lite") {
|
||||
|
||||
deps = [
|
||||
"${window_base_path}/utils:libwmutil_base",
|
||||
"${window_base_path}/window_scene/common:window_scene_common",
|
||||
"${window_base_path}/window_scene/interfaces/innerkits:libwsutils",
|
||||
"${window_base_path}/window_scene/session_manager:session_manager_lite",
|
||||
"${window_base_path}/window_scene/common:window_scene_common",
|
||||
]
|
||||
|
||||
public_configs = [ ":libwm_public_config" ]
|
||||
|
@ -549,7 +549,7 @@ WMError WindowManagerLite::GetMainWindowInfos(int32_t topNum, std::vector<MainWi
|
||||
|
||||
WMError WindowManagerLite::GetAllMainWindowInfos(std::vector<MainWindowInfo>& infos) const
|
||||
{
|
||||
if (!info.empty()) {
|
||||
if (!infos.empty()) {
|
||||
TLOGE(WmsLogTag::WMS_MAIN, "infos is not empty.");
|
||||
return WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
@ -562,7 +562,7 @@ WMError WindowManagerLite::ClearMainSessions(const std::vector<int32_t>& persist
|
||||
TLOGW(WmsLogTag::WMS_MAIN, "Clear main Session failed, persistentIds is empty.");
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
return SingletonContainer::Get<WindowAdapterLite>().ClearMainSessions(persistentIds);
|
||||
return SingletonContainer::Get<WindowAdapterLite>().ClearMainSessions(persistentIds);
|
||||
}
|
||||
|
||||
WMError WindowManagerLite::ClearMainSessions(const std::vector<int32_t>& persistentIds,
|
||||
@ -572,11 +572,7 @@ WMError WindowManagerLite::ClearMainSessions(const std::vector<int32_t>& persist
|
||||
TLOGW(WmsLogTag::WMS_MAIN, "Clear main Session failed, persistentIds is empty.");
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
return SingletonContainer::Get<WindowAdapterLite>().ClearMainSessions(persistentIds, clearFailedIds);
|
||||
return SingletonContainer::Get<WindowAdapterLite>().ClearMainSessions(persistentIds, clearFailedIds);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -324,7 +324,7 @@ HWTEST_F(WindowManagerLiteTest, GetAllMainWindowInfos001, Function | SmallTest |
|
||||
infosResult.push_back(info2);
|
||||
infosResult.push_back(info3);
|
||||
|
||||
EXPECT_CALL(m->Mock(), GetMainWindowInfos(_)).Times(1).WillOnce(DoAll(SetArgReferee<0>(infosResult),
|
||||
EXPECT_CALL(m->Mock(), GetAllMainWindowInfos(_)).Times(1).WillOnce(DoAll(SetArgReferee<0>(infosResult),
|
||||
Return(WMError::WM_OK)));
|
||||
|
||||
auto errorCode = WindowManagerLite::GetInstance().GetAllMainWindowInfos(infos);
|
||||
@ -353,7 +353,7 @@ HWTEST_F(WindowManagerLiteTest, GetAllMainWindowInfos002, Function | SmallTest |
|
||||
info1.bundleName_ = "calendar";
|
||||
infos.push_back(info1);
|
||||
|
||||
EXPECT_CALL(m->Mock(), GetMainWindowInfos(_)).Times(0).WillOnce(DoAll(Return(WMError::WM_OK)));
|
||||
EXPECT_CALL(m->Mock(), GetAllMainWindowInfos(_)).Times(0).WillOnce(DoAll(Return(WMError::WM_OK)));
|
||||
|
||||
auto errorCode = WindowManagerLite::GetInstance().GetAllMainWindowInfos(infos);
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, errorCode);
|
||||
@ -385,7 +385,7 @@ HWTEST_F(WindowManagerLiteTest, ClearMainSessions002, Function | SmallTest | Lev
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
std::vector<int32_t> persistentIds = { 1, 2 };
|
||||
|
||||
EXPECT_CALL(m->Mock(), ClearMainSessions(_)).Times(0).WillOnce(Return(WMError::WM_OK));
|
||||
EXPECT_CALL(m->Mock(), ClearMainSessions(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
|
||||
auto errorCode = WindowManagerLite::GetInstance().ClearMainSessions(persistentIds);
|
||||
ASSERT_EQ(WMError::WM_OK, errorCode);
|
||||
@ -417,7 +417,7 @@ HWTEST_F(WindowManagerLiteTest, ClearMainSessions004, Function | SmallTest | Lev
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
std::vector<int32_t> persistentIds = { 1, 2 };
|
||||
std::vector<int32_t> clearFailedIds;
|
||||
EXPECT_CALL(m->Mock(), ClearMainSessions(_, _)).Times(0).WillOnce(Return(WMError::WM_OK));
|
||||
EXPECT_CALL(m->Mock(), ClearMainSessions(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
|
||||
auto errorCode = WindowManagerLite::GetInstance().ClearMainSessions(persistentIds, clearFailedIds);
|
||||
ASSERT_EQ(WMError::WM_OK, errorCode);
|
||||
|
Loading…
Reference in New Issue
Block a user